{"action":"created","issue":{"url":"https://api.github.com/repos/publiclab/plots2/issues/736","repository_url":"https://api.github.com/repos/publiclab/plots2","labels_url":"https://api.github.com/repos/publiclab/plots2/issues/736/labels{/name}","comments_url":"https://api.github.com/repos/publiclab/plots2/issues/736/comments","events_url":"https://api.github.com/repos/publiclab/plots2/issues/736/events","html_url":"https://github.com/publiclab/plots2/issues/736","id":173299463,"number":736,"title":"Replace all uses of wiki.slug in favor of wiki.path","user":{"login":"jywarren","id":24359,"avatar_url":"https://avatars.githubusercontent.com/u/24359?v=3","gravatar_id":"","url":"https://api.github.com/users/jywarren","html_url":"https://github.com/jywarren","followers_url":"https://api.github.com/users/jywarren/followers","following_url":"https://api.github.com/users/jywarren/following{/other_user}","gists_url":"https://api.github.com/users/jywarren/gists{/gist_id}","starred_url":"https://api.github.com/users/jywarren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jywarren/subscriptions","organizations_url":"https://api.github.com/users/jywarren/orgs","repos_url":"https://api.github.com/users/jywarren/repos","events_url":"https://api.github.com/users/jywarren/events{/privacy}","received_events_url":"https://api.github.com/users/jywarren/received_events","type":"User","site_admin":false},"labels":[{"id":42345818,"url":"https://api.github.com/repos/publiclab/plots2/labels/bug","name":"bug","color":"fc2929","default":true},{"id":173349489,"url":"https://api.github.com/repos/publiclab/plots2/labels/help-wanted","name":"help-wanted","color":"0e8a16","default":false},{"id":343384842,"url":"https://api.github.com/repos/publiclab/plots2/labels/Ruby","name":"Ruby","color":"006b75","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":7,"created_at":"2016-08-25T20:18:44Z","updated_at":"2016-12-13T22:14:49Z","closed_at":null,"body":"We no longer use `node.slug` and it's redundant with the `node.path` field, so we should remove all instances from the codebase. Here they are:\r\n\r\n```ruby\r\napp/views/wiki/show.html.erb:  <div class=\"alert alert-warning\"><%= raw t('wiki.show.revision_from', :time => @revision.created_at.to_s(:long)) %> <a href=\"/wiki/revisions/<%= @node.slug %>\"><%= t('wiki.show.view_all_revisions') %></a></div>\r\napp/views/wiki/show.html.erb:        <li><a href=\"/talk/<%= @node.slug %>\"><i class=\"fa fa-comments-o\"></i><span class=\"hidden-xs hidden-sm\"> <%= t('wiki.show.talk') %></span></a></li>\r\napp/views/wiki/show.html.erb:        <li><a href=\"/wiki/revisions/<%= @node.slug %>\"><span class=\"hidden-xs\"><%= @node.revisions.length %> </span><i class=\"fa fa-list\"></i></a></li>\r\napp/views/wiki/show.html.erb:    <% slug = @node.power_tag('parent') %>\r\napp/views/wiki/show.html.erb:    <% parent = DrupalNode.find_by_slug(slug) %>\r\napp/views/wiki/show.html.erb:          <p><a href=\"/tag/<%= @node.slug %>\"><%= raw t('wiki.show.more_research', :tag => @node.slug) %> &raquo;</a></p>\r\napp/views/wiki/edit.html.erb:      <li><a href=\"/wiki/<%= wiki.slug %>\"><i class=\"fa fa-book\"></i> <%= wiki.title %></a></li>\r\napp/views/wiki/edit.html.erb:      <% if @node.path %><li><a href=\"/wiki/revisions/<%= @node.slug %>\"><%= t('wiki.edit.revisions_for_this_page') %></a></li><% end %>\r\napp/views/wiki/revisions.html.erb:      <li><a href=\"/wiki/<%= @node.slug %>\"><%= t('wiki.revisions.view') %></a></li>\r\napp/views/wiki/revisions.html.erb:      <li><a href=\"/wiki/edit/<%= @node.slug %>\"><%= t('wiki.revisions.edit') %></a></li>\r\napp/views/wiki/revisions.html.erb:      <li class=\"active\"><a href=\"/wiki/revisions/<%= @node.slug %>\">Revisions (<%= @node.revisions.length %>)</a></li>\r\napp/views/talk/show.html.erb:<div><iframe src=\"https://pad.publiclab.org/p/<%= @node.slug[0,50] %>\" style=\"width: 100%; height:800px;\"><p><%= t('talk.show.try_direct_link', :url1 => 'https://pad.publiclab.org/p/'+@node.slug[0,50]) %></p></iframe></div>\r\napp/models/drupal_node.rb:  attr_accessible :title, :uid, :status, :type, :vid, :cached_likes, :comment, :path, :slug\r\napp/models/drupal_node.rb:  friendly_id :friendly_id_string, use: [:slugged, :history]\r\napp/models/drupal_node.rb:    slug.blank? || title_changed?\r\napp/models/drupal_node.rb:    self.slug[0..5] == 'place/'\r\napp/models/drupal_node.rb:  def self.find_root_by_slug(title)\r\napp/controllers/talk_controller.rb:    @node = DrupalNode.find_by_slug params[:id]\r\napp/controllers/wiki_controller.rb:      @wikis = DrupalTag.find_pages(@node.slug,30) if @node.has_tag('chapter') || @node.has_tag('tabbed:wikis')\r\napp/controllers/wiki_controller.rb:    @node = DrupalNode.find_root_by_slug(params[:id])\r\napp/controllers/admin_controller.rb:        redirect_to \"/wiki/revisions/<%= @node.slug %>\" + '?_=' + Time.now.to_i.to_s\r\n```\r\n\r\nNote that each time, we can't just use `path` -- If a wiki has slug `hello-world`, it's supposed to have a path of `/wiki/hello-world`. So we should make a new method on `DrupalNode` like:\r\n\r\n```ruby\r\ndef slug_from_path\r\n  self.path.split('/').last\r\nend\r\n```\r\n\r\nAnd then replace all of the above instances of `node.slug` with `node.slug_from_path`.\r\n\r\nAlso, `find_by_slug` and `find_root_by_slug` will have to be rewritten to search by `path` as well -- adding `/wiki/` back in, or potentially searching with a SQL wildcard like `%` in front of the `slug_from_path` result. I'm happy to offer ideas/help on that too, and it could become a separate issue for simplicity."},"comment":{"url":"https://api.github.com/repos/publiclab/plots2/issues/comments/266879117","html_url":"https://github.com/publiclab/plots2/issues/736#issuecomment-266879117","issue_url":"https://api.github.com/repos/publiclab/plots2/issues/736","id":266879117,"user":{"login":"jywarren","id":24359,"avatar_url":"https://avatars.githubusercontent.com/u/24359?v=3","gravatar_id":"","url":"https://api.github.com/users/jywarren","html_url":"https://github.com/jywarren","followers_url":"https://api.github.com/users/jywarren/followers","following_url":"https://api.github.com/users/jywarren/following{/other_user}","gists_url":"https://api.github.com/users/jywarren/gists{/gist_id}","starred_url":"https://api.github.com/users/jywarren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jywarren/subscriptions","organizations_url":"https://api.github.com/users/jywarren/orgs","repos_url":"https://api.github.com/users/jywarren/repos","events_url":"https://api.github.com/users/jywarren/events{/privacy}","received_events_url":"https://api.github.com/users/jywarren/received_events","type":"User","site_admin":false},"created_at":"2016-12-13T22:14:49Z","updated_at":"2016-12-13T22:14:49Z","body":"Where are they from? `app/views/wiki/show.html.erb`? Can you look at the context of that and see how (and whether) you need to convert from a path to a slug or back?"}}
{"actor":{"display_login":"jywarren"}}