diff --git a/Gemfile.lock b/Gemfile.lock index d0336f94f7..2ed858687c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -339,3 +339,9 @@ DEPENDENCIES uglifier (>= 1.0.3) will_paginate (>= 3.0.6) will_paginate-bootstrap (>= 1.0.1) + +RUBY VERSION + ruby 2.1.2p95 + +BUNDLED WITH + 1.13.6 diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb index b026f1955f..8a41eb78c5 100644 --- a/app/controllers/admin_controller.rb +++ b/app/controllers/admin_controller.rb @@ -147,7 +147,7 @@ def mark_spam_revision @revision.spam @revision.author.ban flash[:notice] = "Item marked as spam and author banned. You can undo this on the spam moderation page." - redirect_to "/wiki/revisions/<%= @node.slug %>" + '?_=' + Time.now.to_i.to_s + redirect_to "/wiki/revisions/" + @revision.drupal_node.slug_from_path + '?_=' + Time.now.to_i.to_s else flash[:notice] = "Item already marked as spam and author banned. You can undo this on the spam moderation page." redirect_to "/dashboard" diff --git a/app/controllers/talk_controller.rb b/app/controllers/talk_controller.rb index c6c41c4b88..9c12d04713 100644 --- a/app/controllers/talk_controller.rb +++ b/app/controllers/talk_controller.rb @@ -1,5 +1,5 @@ class TalkController < ApplicationController def show - @node = DrupalNode.find_by_slug params[:id] + @node = DrupalNode.find_by_path params[:id] end end diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index a35d5f00d2..8247f7e2c8 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -51,7 +51,7 @@ def show end @tagnames = @tags.collect(&:name) set_sidebar :tags, @tagnames, {:videos => true} - @wikis = DrupalTag.find_pages(@node.slug,30) if @node.has_tag('chapter') || @node.has_tag('tabbed:wikis') + @wikis = DrupalTag.find_pages(@node.slug_from_path,30) if @node.has_tag('chapter') || @node.has_tag('tabbed:wikis') @node.view @revision = @node.latest @@ -206,7 +206,7 @@ def revert # wiki pages which have a root URL, like /about def root - @node = DrupalNode.find_root_by_slug(params[:id]) + @node = DrupalNode.find_by_path(params[:id]) return if check_and_redirect_node(@node) if @node @revision = @node.latest diff --git a/app/models/drupal_node.rb b/app/models/drupal_node.rb index 39445b9fab..bcefbaf959 100644 --- a/app/models/drupal_node.rb +++ b/app/models/drupal_node.rb @@ -102,6 +102,10 @@ def self.inheritance_column "rails_type" end + def slug_from_path + self.path.split('/').last + end + before_save :set_changed_and_created after_create :setup before_validation :set_path, on: :create @@ -320,7 +324,7 @@ def gallery # base this on a tag! def is_place? # self.has_tag('chapter') - self.slug[0..5] == 'place/' + self.path[0..6] == '/wiki/place' end # ============================================ @@ -497,7 +501,7 @@ def edit_path path end - def self.find_root_by_slug(title) + def self.find_by_path(title) DrupalNode.where(path: ["/#{title}"]).first end diff --git a/app/views/talk/show.html.erb b/app/views/talk/show.html.erb index 5965f0875d..44233f2dca 100644 --- a/app/views/talk/show.html.erb +++ b/app/views/talk/show.html.erb @@ -1,2 +1,2 @@

<%= raw t('talk.show.welcome', :page => @node.latest.title, :url1 => @node.path, :url2 => '/wiki/talk-pages') %>

-
+
diff --git a/app/views/wiki/edit.html.erb b/app/views/wiki/edit.html.erb index b778f98a09..9cc677dea5 100644 --- a/app/views/wiki/edit.html.erb +++ b/app/views/wiki/edit.html.erb @@ -4,7 +4,7 @@

<%= t('wiki.edit.did_you_mean') %>:

<%= raw t('wiki.edit.try_searching_for', :url1 => "/search/"+params[:id], :wiki => params[:id]) %>

@@ -17,7 +17,7 @@ diff --git a/app/views/wiki/revisions.html.erb b/app/views/wiki/revisions.html.erb index 9b1ad4032c..6ccf211e35 100644 --- a/app/views/wiki/revisions.html.erb +++ b/app/views/wiki/revisions.html.erb @@ -4,9 +4,9 @@

<%= raw t('wiki.revisions.revisions_for', :wiki => @node.title) %>

diff --git a/app/views/wiki/show.html.erb b/app/views/wiki/show.html.erb index 6271d27fa2..44fef3882d 100644 --- a/app/views/wiki/show.html.erb +++ b/app/views/wiki/show.html.erb @@ -26,7 +26,7 @@

<%= @revision.title %>

<% if @is_revision %> -
<%= raw t('wiki.show.revision_from', :time => @revision.created_at.to_s(:long)) %> <%= t('wiki.show.view_all_revisions') %>
+
<%= raw t('wiki.show.revision_from', :time => @revision.created_at.to_s(:long)) %> <%= t('wiki.show.view_all_revisions') %>
<% end %> @@ -44,8 +44,8 @@
  • <% if current_user && current_user.role == "admin" %>
  • <%= link_to "/wiki/delete/"+@node.id.to_s, :confirm => I18n.t('wiki.show.are_you_sure_delete', :path => @node.path) do %><% end %>
  • <% end %> -
  • -
  • +
  • +
  • @@ -53,8 +53,7 @@
    <% if @node.has_power_tag('parent') %> - <% slug = @node.power_tag('parent') %> - <% parent = DrupalNode.find_by_slug(slug) %> + <% parent = DrupalNode.find_by_path("/wiki/" + @node.power_tag('parent')) %> <% if parent %>
    « <%= raw t('wiki.show.back_to_wiki', :url1 => parent.path, :title => parent.latest.title) %>
    <% end %> @@ -77,7 +76,7 @@ <% if @node.power_tags('tabbed').include?("notes") %>
    <%= render :partial => "notes/notes" %> -

    <%= raw t('wiki.show.more_research', :tag => @node.slug) %> »

    +

    <%= raw t('wiki.show.more_research', :tag => @node.slug_from_path) %> »


    <% end %> diff --git a/test/functional/admin_controller_test.rb b/test/functional/admin_controller_test.rb index 1e3f6b0f27..f256ebcf1c 100644 --- a/test/functional/admin_controller_test.rb +++ b/test/functional/admin_controller_test.rb @@ -321,7 +321,7 @@ def teardown assert_equal 0, revision.status assert_equal 0, revision.author.status assert_not_equal node(:spam_targeted_page).latest.vid, revision.vid - assert_redirected_to "/wiki/revisions/<%= @node.slug %>" + '?_=' + Time.now.to_i.to_s + assert_redirected_to "/wiki/revisions/" + revision.drupal_node.slug_from_path + '?_=' + Time.now.to_i.to_s end test "admin user should be able to republish a revision" do