diff --git a/changelog.md b/changelog.md index 84e5b64a0a..b956770976 100644 --- a/changelog.md +++ b/changelog.md @@ -2,7 +2,8 @@ * Refactored wysiwyg fields into a partial. [#1796](https://github.com/resolve/refinerycms/pull/1796). [Rob Yurkowski](https://github.com/robyurkowski) * Shortened all authentication helpers. [#1719](https://github.com/resolve/refinerycms/pull/1719). [Ryan Bigg](https://github.com/radar) -* Added canonical page id to body to allow CSS selectors to target specific pages instead of including special CSS files. [#1700](https://github.com/resolve/refinerycms/pull/1700) & [#1828](https://github.com/resolve/refinerycms/pull/1828). [Philip Arndy](https://github.com/parndt) & [Graham Wagener](https://github.com/gwagener/) +* Added canonical page id to body to allow CSS selectors to target specific pages instead of including special CSS files. [#1700](https://github.com/resolve/refinerycms/pull/1700) & [#1828](https://github.com/resolve/refinerycms/pull/1828). [Philip Arndt](https://github.com/parndt) & [Graham Wagener](https://github.com/gwagener/) +* Removed Refinery::Page#title_with_meta in favour of view helpers. [#1847](https://github.com/resolve/refinerycms/pull/1847). [Philip Arndt](https://github.com/parndt) * [See full list](https://github.com/resolve/refinerycms/compare/2-0-stable...master) diff --git a/pages/app/controllers/refinery/admin/pages_dialogs_controller.rb b/pages/app/controllers/refinery/admin/pages_dialogs_controller.rb index 88a11d5031..7837c86bf4 100644 --- a/pages/app/controllers/refinery/admin/pages_dialogs_controller.rb +++ b/pages/app/controllers/refinery/admin/pages_dialogs_controller.rb @@ -4,6 +4,8 @@ module Refinery module Admin class PagesDialogsController < ::Refinery::Admin::DialogsController + helper :'refinery/admin/pages' + def link_to # Get the switch_local variable to determine the locale we're currently editing # Set up Globalize with our current locale diff --git a/pages/app/helpers/refinery/admin/pages_helper.rb b/pages/app/helpers/refinery/admin/pages_helper.rb index 98b8f4d6ed..08add6f34e 100644 --- a/pages/app/helpers/refinery/admin/pages_helper.rb +++ b/pages/app/helpers/refinery/admin/pages_helper.rb @@ -22,6 +22,31 @@ def template_options(template_type, current_page) { :selected => Refinery::Pages.send("#{template_type}_whitelist").first } end end + + # In the admin area we use a slightly different title + # to inform the which pages are draft or hidden pages + def page_meta_information(page) + meta_information = ActiveSupport::SafeBuffer.new + meta_information << content_tag(:span, :class => 'label') do + ::I18n.t('hidden', :scope => 'refinery.admin.pages.page') + end unless page.show_in_menu? + + meta_information << content_tag(:span, :class => 'label notice') do + ::I18n.t('draft', :scope => 'refinery.admin.pages.page') + end if page.draft? + + meta_information.html_safe + end + + # We show the title from the next available locale + # if there is no title for the current locale + def page_title_with_translations(page) + if page.title.present? + page.title + else + page.translations.detect {|t| t.title.present?}.title + end + end end end end diff --git a/pages/app/models/refinery/page.rb b/pages/app/models/refinery/page.rb index c565400d08..e45db8be1b 100644 --- a/pages/app/models/refinery/page.rb +++ b/pages/app/models/refinery/page.rb @@ -383,21 +383,6 @@ def part_with_title(part_title) end end - # In the admin area we use a slightly different title to inform the which pages are draft or hidden pages - # We show the title from the next available locale if there is no title for the current locale - def title_with_meta - if self.title.present? - title = [self.title] - else - title = [self.translations.detect {|t| t.title.present?}.title] - end - - title << "#{::I18n.t('hidden', :scope => 'refinery.admin.pages.page')}" unless show_in_menu? - title << "#{::I18n.t('draft', :scope => 'refinery.admin.pages.page')}" if draft? - - title.join(' ') - end - # Used to index all the content on this page so it can be easily searched. def all_page_part_content parts.map(&:body).join(" ") diff --git a/pages/app/views/refinery/admin/pages/_page.html.erb b/pages/app/views/refinery/admin/pages/_page.html.erb index 30d6179af1..32de667a10 100644 --- a/pages/app/views/refinery/admin/pages/_page.html.erb +++ b/pages/app/views/refinery/admin/pages/_page.html.erb @@ -7,7 +7,8 @@ <% end %> '> - <%= page.title_with_meta.html_safe %> + <%= page_title_with_translations page %> + <%= page_meta_information page %> <% if Refinery.i18n_enabled? and Refinery::I18n.frontend_locales.many? %> @@ -37,7 +38,10 @@ :class => "cancel confirm-delete", :title => t('delete', :scope => 'refinery.admin.pages'), :data => { - :confirm => t('message', :scope => 'refinery.admin.delete', :title => page.title_with_meta.gsub(/\ ?.*<\/em>/, "")) + :confirm => t('message', + :scope => 'refinery.admin.delete', + :title => page_title_with_translations(page) + ) }, :method => :delete if page.deletable? %> diff --git a/pages/app/views/refinery/admin/pages_dialogs/_page_link.html.erb b/pages/app/views/refinery/admin/pages_dialogs/_page_link.html.erb index 1fc0d9d489..a53606d054 100644 --- a/pages/app/views/refinery/admin/pages_dialogs/_page_link.html.erb +++ b/pages/app/views/refinery/admin/pages_dialogs/_page_link.html.erb @@ -6,11 +6,14 @@ page_link_url = "#{[request.protocol, request.host_with_port].join}#{page_link_url}" if Refinery::Pages.absolute_page_links -%>
  • - <%= link_to page_link.title_with_meta.html_safe, page_link_url, { + <%= link_to page_link_url, { :title => t('.link_to_this_page'), :rel => page_link.title, :class => 'page_link' - }.merge(link_args) %> + }.merge(link_args) do %> + <%= page_title_with_translations page_link %> + <%= page_meta_information page_link %> + <% end %>
  • <%= render :partial => 'page_link', :collection => page_link.children,