From 829921d3825435d4a12331d1e048a0fd99129f81 Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Fri, 6 Mar 2015 09:59:43 +0100 Subject: [PATCH] Formatted source editing and sitemap overload option --- .../cmtool/structure.js.coffee.erb | 1 + lib/cmtool/includes/page.rb | 4 ++++ lib/cmtool/includes/pages_controller.rb | 2 +- lib/cmtool/menu.rb | 19 +++++++++++++------ 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/cmtool/structure.js.coffee.erb b/app/assets/javascripts/cmtool/structure.js.coffee.erb index 927f43e..b2481fe 100644 --- a/app/assets/javascripts/cmtool/structure.js.coffee.erb +++ b/app/assets/javascripts/cmtool/structure.js.coffee.erb @@ -7,6 +7,7 @@ $ -> image_list: '<%= cmtool.images_path(format: :js) %>' relative_urls: false removed_menuitems: 'newdocument' + apply_source_formatting: true $('.editor_basic').tinymce theme: 'modern' language: tinymce_language diff --git a/lib/cmtool/includes/page.rb b/lib/cmtool/includes/page.rb index 4f14d84..76f5632 100644 --- a/lib/cmtool/includes/page.rb +++ b/lib/cmtool/includes/page.rb @@ -67,6 +67,10 @@ module Cmtool :en end + def for_sitemap + all + end + def top_menu ActiveSupport::Deprecation.warn("Page.top_menu is a stupid name. Use Page.menu_roots instead") menu_roots diff --git a/lib/cmtool/includes/pages_controller.rb b/lib/cmtool/includes/pages_controller.rb index 3160990..7fa61da 100644 --- a/lib/cmtool/includes/pages_controller.rb +++ b/lib/cmtool/includes/pages_controller.rb @@ -33,7 +33,7 @@ module Cmtool def sitemap respond_to do |format| format.xml do - page_uris = ::Page.all.map{|p| page_path(p.name, locale: p.locale)} + page_uris = ::Page.for_sitemap.map{|p| page_path(p.name, locale: p.locale)} pages_xml = page_uris.map{|uri| "#{uri}"}.join("\n") result = <<-XML diff --git a/lib/cmtool/menu.rb b/lib/cmtool/menu.rb index 671a1f8..388e50d 100644 --- a/lib/cmtool/menu.rb +++ b/lib/cmtool/menu.rb @@ -64,7 +64,7 @@ module Cmtool ## class Divider < ElementBase end - + ## # A group element, works as a new kind of menu, but then within another one ## @@ -74,8 +74,9 @@ module Cmtool @register = Register.new @options = options @block = block - @register.instance_eval &block + @register.instance_eval(&block) end + def title @register.title.respond_to?(:call) ? @register.title.call : @register.title end @@ -108,10 +109,10 @@ module Cmtool def path case options[:path] - when Symbol then engine.routes.url_helpers.send(:"#{options[:path]}_path") - when String then options[:path] - else engine.routes.url_helpers.root_path - end + when Symbol then engine.routes.url_helpers.send(:"#{options[:path]}_path") + when String then options[:path] + else engine.routes.url_helpers.root_path + end end end @@ -163,19 +164,24 @@ module Cmtool ## class Register attr_reader :items + def initialize @items = [] end + def t(*args) -> { I18n.t(*args) } end + def group(options = {}, &block) @items << Group.new(options, &block) end + def title(*args) return @title if args.empty? @title = args.first end + def resource_link(resource, options = {}) @items << ResourceLink.new(resource, options) end @@ -187,6 +193,7 @@ module Cmtool def resource_links @items.select{|i| i.is_a?(ResourceLink)} end + def method_missing(*args) @items.send(*args).to_a end