Formatted source editing and sitemap overload option

This commit is contained in:
2015-03-06 09:59:43 +01:00
parent b0491aa997
commit 829921d382
4 changed files with 19 additions and 7 deletions
@@ -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
+4
View File
@@ -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
+1 -1
View File
@@ -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| "<url><loc>#{uri}</loc></url>"}.join("\n")
result = <<-XML
<?xml version="1.0" encoding="UTF-8"?>
+13 -6
View File
@@ -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