Plots2: 按页面名称添加重定向标签功能

创建于 2018-03-27  ·  3评论  ·  资料来源: publiclab/plots2

嗨,这是一个仅限初学者的问题。 这意味着我们一直致力于让之前没有为我们的代码库做出贡献的人,甚至之前没有为开源做出贡献的人更容易阅读。

如果这就是您,我们有兴趣帮助您迈出第一步,并可以像您一样回答问题并帮助您解决问题。 请注意,我们对自由和开源软件中代表性不足的群体的贡献特别感兴趣!

我们知道创建拉取请求的过程是新贡献者的最大障碍。 这个问题是给你的💝

如果您以前有过贡献,请考虑将这个留给新人,并查看我们的一般帮助需要的问题。 谢谢!

🤔 你需要知道什么。

没有。 本期旨在欢迎您使用开源 :) 我们很高兴引导您完成整个过程。

我们有一个使用标签的重定向系统——在https://publiclab.org/wiki/power-tags阅读更多内容——但它需要标签指向像redirect:12345这样的“节点 ID”。 这很难记住并且有点晦涩——所以让我们也可以使用页面“slug”。 然后你可以使用redirect:openhour重定向到/wiki/openhour的页面。

📋 一步一步

  • [ ] 🙋 提出这个问题:在下面评论。 如果其他人已经声明了它,请询问他们是否已经打开了拉取请求以及他们是否被卡住了——也许你可以帮助他们解决问题或继续前进!

  • [ ] 📝更新plots2存储库中的文件app/controllers/wiki_controller.rb (按小笔图标)并编辑如下所示的行。

请参阅此页面以获取一些帮助您迈出第一步!

下面是一个“差异”,以红色(和- )显示要删除的行,以绿色(和+ )显示要添加的行:

@@ -33,6 +33,14 @@ def show
         flash.now[:warning] = "Only moderators and admins see this page, as it is redirected to <a href='#{Node.find(@node.power_tag('redirect')).path}'>#{Node.find(@node.power_tag('redirect')).title}</a>.
         To remove the redirect, delete the tag beginning with 'redirect:'"
       end
+    elsif @node&.has_power_tag('redirect') && Node.where(slug: @node.power_tag('redirect')).exists?
+      if current_user.nil? || !current_user.can_moderate?
+        redirect_to Node.find_by(slug: @node.power_tag('redirect')).path
+        return
+      elsif current_user.can_moderate?
+        flash.now[:warning] = "Only moderators and admins see this page, as it is redirected to <a href='#{Node.find_by(slug: @node.power_tag('redirect')).path}'>#{Node.find_by(slug: @node.power_tag('redirect')).title}</a>.
+        To remove the redirect, delete the tag beginning with 'redirect:'"
+      end
     end

     if @node&.has_power_tag('abtest') && !Node.where(nid: @node.power_tag('abtest')).empty?
  • [ ] 💾提交您的更改

  • [ ] 🔀 发起拉取请求。 有两种方法可以启动拉取请求:

  1. 如果您熟悉终端或想学习它,这里有一个关于如何使用终端发送拉取请求

  2. 您还可以直接在浏览器中编辑文件并从那里打开拉取请求。

  • [ ] 🏁完成在评论中询问评论:)

🤔❓有问题吗?

在下方发表评论!

其他人已经在做这件事了吗?

我们鼓励您通过在拉取请求中提及问题 # 来链接到此问题,以便我们可以查看是否有人已经开始使用它。 如果有人看起来卡住了,请给他们一些帮助! 否则,请查看您可以帮助解决的其他一些问题。 谢谢!

(这个问题是由First-Timers-Bot创建的。)

Ruby first-timers-only has-pull-request help wanted

最有用的评论

我想索赔这个。

所有3条评论

这应该有效——我很乐意帮忙!!!

我想索赔这个。

伟大的 ! 你可以解决这个问题:-)

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

first-timers[bot] picture first-timers[bot]  ·  3评论

jywarren picture jywarren  ·  3评论

keshavsethi picture keshavsethi  ·  3评论

first-timers[bot] picture first-timers[bot]  ·  3评论

divyabaid16 picture divyabaid16  ·  3评论