alchemy_cms 2.2.rc14 → 2.2.rc15
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/alchemy/alchemy.gui.js.coffee +11 -0
- data/app/assets/javascripts/alchemy/alchemy.js +2 -1
- data/app/assets/javascripts/alchemy/alchemy.routes.js.erb +1 -1
- data/app/assets/stylesheets/alchemy/elements.css.scss +0 -4
- data/app/assets/stylesheets/alchemy/menubar.css.scss +21 -4
- data/app/controllers/alchemy/admin/contents_controller.rb +3 -4
- data/app/controllers/alchemy/admin/elements_controller.rb +4 -4
- data/app/controllers/alchemy/admin/pages_controller.rb +7 -25
- data/app/controllers/alchemy/pages_controller.rb +5 -16
- data/app/helpers/alchemy/admin/base_helper.rb +3 -3
- data/app/helpers/alchemy/admin/contents_helper.rb +3 -2
- data/app/helpers/alchemy/admin/elements_helper.rb +22 -0
- data/app/helpers/alchemy/elements_helper.rb +12 -12
- data/app/helpers/alchemy/pages_helper.rb +43 -43
- data/app/models/alchemy/element.rb +3 -3
- data/app/models/alchemy/message.rb +5 -1
- data/app/models/alchemy/page.rb +23 -11
- data/app/sweepers/alchemy/content_sweeper.rb +6 -8
- data/app/sweepers/alchemy/pages_sweeper.rb +4 -20
- data/app/views/alchemy/admin/contents/create.js.coffee +49 -0
- data/app/views/alchemy/admin/elements/create.js.erb +30 -0
- data/app/views/alchemy/admin/elements/trash.js.erb +12 -13
- data/app/views/alchemy/admin/elements/update.js.erb +19 -22
- data/app/views/alchemy/admin/pages/update.js.erb +30 -0
- data/app/views/alchemy/admin/users/_user.html.erb +1 -0
- data/app/views/alchemy/admin/users/index.html.erb +1 -0
- data/app/views/alchemy/essences/_essence_select_editor.html.erb +1 -1
- data/config/locales/alchemy.de.yml +1 -0
- data/config/locales/alchemy.en.yml +1 -0
- data/lib/alchemy/upgrader.rb +0 -2
- data/lib/alchemy/version.rb +1 -1
- data/spec/controllers/admin/elements_controller_spec.rb +1 -1
- data/spec/controllers/admin/pages_controller_spec.rb +23 -3
- data/spec/models/page_spec.rb +12 -0
- metadata +6 -5
- data/app/views/alchemy/admin/contents/create.js.erb +0 -49
- data/app/views/alchemy/admin/elements/create.js.coffee +0 -31
- data/app/views/alchemy/admin/pages/update.js.coffee +0 -36
@@ -0,0 +1,11 @@
|
|
1
|
+
if typeof window.Alchemy == 'undefined'
|
2
|
+
window.Alchemy = {}
|
3
|
+
|
4
|
+
Alchemy.GUI =
|
5
|
+
|
6
|
+
initElement: ($el) ->
|
7
|
+
Alchemy.ElementDirtyObserver($el)
|
8
|
+
Alchemy.SelectBox('select', $el)
|
9
|
+
Alchemy.ButtonObserver('button.button', $el)
|
10
|
+
Alchemy.Datepicker('input[type="date"]', $el)
|
11
|
+
Alchemy.overlayObserver($el)
|
@@ -14,11 +14,12 @@
|
|
14
14
|
//= require alchemy/alchemy.dragndrop
|
15
15
|
//= require alchemy/alchemy.element_editor_selector
|
16
16
|
//= require alchemy/alchemy.growler
|
17
|
+
//= require alchemy/alchemy.gui
|
17
18
|
//= require alchemy/alchemy.image_cropper
|
18
19
|
//= require alchemy/alchemy.js_extensions
|
19
20
|
//= require alchemy/alchemy.link_overlay
|
20
21
|
//= require alchemy/alchemy.page_sorter
|
21
|
-
//= require alchemy/alchemy.uploader
|
22
|
+
//= require alchemy/alchemy.uploader
|
22
23
|
//= require alchemy/alchemy.file_progress
|
23
24
|
//= require alchemy/alchemy.swf_upload
|
24
25
|
//= require alchemy/alchemy.windows
|
@@ -1,6 +1,6 @@
|
|
1
1
|
// This object provides dynamically generated Rails routes in Javascript.
|
2
2
|
// A little bit hacky, but the best solution so far. ^_^
|
3
|
-
<% self.class.
|
3
|
+
<% self.class.instance_eval { include Alchemy::Engine.routes.url_helpers } %>
|
4
4
|
|
5
5
|
if (typeof(Alchemy) === 'undefined') {
|
6
6
|
var Alchemy = {};
|
@@ -39,6 +39,12 @@
|
|
39
39
|
box-shadow: $shadow;
|
40
40
|
}
|
41
41
|
|
42
|
+
@mixin box-sizing($box-sizing-type: content-box) {
|
43
|
+
-webkit-box-sizing: $box-sizing-type;
|
44
|
+
-moz-box-sizing: $box-sizing-type;
|
45
|
+
box-sizing: $box-sizing-type;
|
46
|
+
}
|
47
|
+
|
42
48
|
#alchemy_menubar {
|
43
49
|
position: fixed;
|
44
50
|
top: 0;
|
@@ -50,17 +56,23 @@
|
|
50
56
|
@include bounce;
|
51
57
|
@include bottom-right-rounded-border;
|
52
58
|
@include box-shadow;
|
59
|
+
@include box-sizing;
|
53
60
|
border-right: $default-border;
|
54
61
|
border-bottom: $default-border;
|
55
|
-
line-height: 8
|
56
|
-
height: 8
|
62
|
+
line-height: 8 * $default-padding;
|
63
|
+
height: 8 * $default-padding;
|
57
64
|
padding: 4px 40px 4px 8px;
|
58
65
|
overflow: hidden;
|
66
|
+
|
67
|
+
* {
|
68
|
+
@include box-sizing;
|
69
|
+
}
|
70
|
+
|
59
71
|
&:hover {
|
60
72
|
left: 0;
|
61
73
|
@include transition;
|
62
74
|
}
|
63
|
-
|
75
|
+
|
64
76
|
&:after {
|
65
77
|
content: '';
|
66
78
|
width: 24px;
|
@@ -70,11 +82,12 @@
|
|
70
82
|
top: 8px;
|
71
83
|
background: image-url('alchemy/icons.png') -240px 0;
|
72
84
|
}
|
73
|
-
|
85
|
+
|
74
86
|
ul {
|
75
87
|
padding: 0;
|
76
88
|
margin: 0;
|
77
89
|
height: 32px;
|
90
|
+
|
78
91
|
li {
|
79
92
|
height: 32px;
|
80
93
|
margin: 0 $default-padding 0 0;
|
@@ -82,6 +95,7 @@
|
|
82
95
|
display: inline;
|
83
96
|
display: inline-block;
|
84
97
|
list-style-type: none;
|
98
|
+
|
85
99
|
a {
|
86
100
|
@include button-styles;
|
87
101
|
display: block;
|
@@ -91,9 +105,12 @@
|
|
91
105
|
width: 90px;
|
92
106
|
text-decoration: none;
|
93
107
|
outline: none;
|
108
|
+
white-space: nowrap;
|
109
|
+
|
94
110
|
&:hover {
|
95
111
|
@include button-hover-styles;
|
96
112
|
}
|
113
|
+
|
97
114
|
&:active {
|
98
115
|
outline: none;
|
99
116
|
}
|
@@ -14,19 +14,18 @@ module Alchemy
|
|
14
14
|
@content = Content.create_from_scratch(@element, params[:content])
|
15
15
|
@options = params[:options] || {}
|
16
16
|
@html_options = params[:html_options] || {}
|
17
|
-
# If options params come from Flash uploader then we have to parse them as hash.
|
18
17
|
if @options.is_a?(String)
|
19
|
-
@options =
|
18
|
+
@options = JSON.parse(@options)
|
20
19
|
end
|
21
20
|
if @content.essence_type == "Alchemy::EssencePicture"
|
22
|
-
@
|
21
|
+
@content_dom_id = "#add_content_#{@element.id}"
|
23
22
|
@content.essence.picture_id = params[:picture_id]
|
24
23
|
@content.essence.save
|
25
24
|
@contents_of_this_type = @element.contents.find_all_by_essence_type('Alchemy::EssencePicture')
|
26
25
|
@dragable = @contents_of_this_type.length > 1
|
27
26
|
@options = @options.merge(:dragable => @dragable)
|
28
27
|
else
|
29
|
-
@
|
28
|
+
@content_dom_id = "#add_content_for_element_#{@element.id}"
|
30
29
|
end
|
31
30
|
@locals = {
|
32
31
|
:content => @content,
|
@@ -2,7 +2,7 @@ module Alchemy
|
|
2
2
|
module Admin
|
3
3
|
class ElementsController < Alchemy::Admin::BaseController
|
4
4
|
|
5
|
-
cache_sweeper Alchemy::ContentSweeper, :only => [:update]
|
5
|
+
cache_sweeper Alchemy::ContentSweeper, :only => [:create, :update, :destroy]
|
6
6
|
|
7
7
|
def index
|
8
8
|
@page = Page.find(params[:page_id], :include => {:elements => :contents})
|
@@ -20,7 +20,7 @@ module Alchemy
|
|
20
20
|
if @page_id.blank? && !params[:page_urlname].blank?
|
21
21
|
@page_id = Page.find_by_urlname_and_language_id(params[:page_urlname], session[:language_id]).id
|
22
22
|
end
|
23
|
-
@elements = Element.
|
23
|
+
@elements = Element.published.find_all_by_page_id(@page_id)
|
24
24
|
end
|
25
25
|
|
26
26
|
def new
|
@@ -77,7 +77,7 @@ module Alchemy
|
|
77
77
|
# Trashes the Element instead of deleting it.
|
78
78
|
def trash
|
79
79
|
@element = Element.find(params[:id])
|
80
|
-
@
|
80
|
+
@page = @element.page
|
81
81
|
@element.trash
|
82
82
|
end
|
83
83
|
|
@@ -100,7 +100,7 @@ module Alchemy
|
|
100
100
|
@element.save
|
101
101
|
end
|
102
102
|
|
103
|
-
|
103
|
+
private
|
104
104
|
|
105
105
|
def put_element_in_cell
|
106
106
|
element_with_cell_name = @paste_from_clipboard ? params[:paste_from_clipboard] : params[:element][:name]
|
@@ -6,7 +6,7 @@ module Alchemy
|
|
6
6
|
|
7
7
|
before_filter :set_translation, :except => [:show]
|
8
8
|
|
9
|
-
filter_access_to [:show, :unlock, :visit, :publish, :configure, :edit, :update, :destroy, :fold], :attribute_check => true, :load_method => :
|
9
|
+
filter_access_to [:show, :unlock, :visit, :publish, :configure, :edit, :update, :destroy, :fold], :attribute_check => true, :load_method => :load_page, :model => Alchemy::Page
|
10
10
|
filter_access_to [:index, :link, :layoutpages, :new, :switch_language, :create, :move, :flush], :attribute_check => false
|
11
11
|
|
12
12
|
cache_sweeper Alchemy::PagesSweeper, :only => [:publish], :if => proc { Alchemy::Config.get(:cache_pages) }
|
@@ -225,43 +225,25 @@ module Alchemy
|
|
225
225
|
|
226
226
|
def flush
|
227
227
|
Page.with_language(session[:language_id]).flushables.each do |page|
|
228
|
-
|
228
|
+
expire_action(page.cache_key)
|
229
229
|
end
|
230
230
|
respond_to do |format|
|
231
231
|
format.js
|
232
232
|
end
|
233
233
|
end
|
234
234
|
|
235
|
-
|
235
|
+
private
|
236
236
|
|
237
|
-
def
|
238
|
-
@page ||= Page.
|
237
|
+
def load_page
|
238
|
+
@page ||= Page.with_language(session[:language_id]).find_by_urlname(params[:id])
|
239
|
+
@page ||= Page.find_by_id(params[:id])
|
240
|
+
raise ActiveRecord::RecordNotFound if @page.nil?
|
239
241
|
end
|
240
242
|
|
241
243
|
def pages_from_raw_request
|
242
244
|
request.raw_post.split('&').map { |i| i = {i.split('=')[0].gsub(/[^0-9]/, '') => i.split('=')[1]} }
|
243
245
|
end
|
244
246
|
|
245
|
-
def expire_page(page)
|
246
|
-
return if page.do_not_sweep
|
247
|
-
# TODO: We should change this back to expire_action after Rails 3.2 was released.
|
248
|
-
# expire_action(
|
249
|
-
# alchemy.show_page_url(
|
250
|
-
# :urlname => page.urlname_was,
|
251
|
-
# :lang => multi_language? ? page.language_code : nil
|
252
|
-
# )
|
253
|
-
# )
|
254
|
-
# Temporarily fix for Rails 3 bug
|
255
|
-
expire_fragment(ActionController::Caching::Actions::ActionCachePath.new(
|
256
|
-
self,
|
257
|
-
alchemy.show_page_url(
|
258
|
-
:urlname => page.urlname_was,
|
259
|
-
:lang => multi_language? ? page.language_code : nil
|
260
|
-
),
|
261
|
-
false
|
262
|
-
).path) unless page.redirects_to_external?
|
263
|
-
end
|
264
|
-
|
265
247
|
# Taken from https://github.com/matenia/jQuery-Awesome-Nested-Set-Drag-and-Drop
|
266
248
|
def sort_children(element, dbitem)
|
267
249
|
prevchild = nil
|
@@ -14,27 +14,16 @@ module Alchemy
|
|
14
14
|
|
15
15
|
filter_access_to :show, :attribute_check => true, :model => Alchemy::Page, :load_method => :load_page
|
16
16
|
|
17
|
-
caches_action(
|
18
|
-
:
|
19
|
-
:cache_path => proc { show_page_url(:urlname => params[:urlname], :lang => multi_language? ? params[:lang] : nil) },
|
17
|
+
caches_action(:show,
|
18
|
+
:cache_path => proc { @page.cache_key(request) },
|
20
19
|
:if => proc {
|
21
20
|
if Alchemy::Config.get(:cache_pages)
|
22
|
-
|
23
|
-
|
24
|
-
session[:language_id],
|
25
|
-
true,
|
26
|
-
:select => 'page_layout, language_id, urlname'
|
27
|
-
)
|
28
|
-
if page
|
29
|
-
pagelayout = PageLayout.get(page.page_layout)
|
30
|
-
pagelayout['cache'].nil? || pagelayout['cache']
|
31
|
-
end
|
21
|
+
pagelayout = PageLayout.get(@page.page_layout)
|
22
|
+
pagelayout['cache'].nil? || pagelayout['cache']
|
32
23
|
else
|
33
24
|
false
|
34
25
|
end
|
35
|
-
},
|
36
|
-
:layout => false
|
37
|
-
)
|
26
|
+
}, :layout => false)
|
38
27
|
|
39
28
|
layout :layout_for_page
|
40
29
|
|
@@ -150,9 +150,9 @@ module Alchemy
|
|
150
150
|
page = options[:from_page].is_a?(String) ? Page.find_by_page_layout(options[:from_page]) : options[:from_page]
|
151
151
|
end
|
152
152
|
if page
|
153
|
-
elements = options[:elements_with_name].blank? ? page.elements.
|
153
|
+
elements = options[:elements_with_name].blank? ? page.elements.published : page.elements.published.where(:name => options[:elements_with_name])
|
154
154
|
else
|
155
|
-
elements = options[:elements_with_name].blank? ? Element.
|
155
|
+
elements = options[:elements_with_name].blank? ? Element.published : Element.published.where(:name => options[:elements_with_name])
|
156
156
|
end
|
157
157
|
select_options = [[options[:prompt], ""]]
|
158
158
|
elements.each do |e|
|
@@ -171,7 +171,7 @@ module Alchemy
|
|
171
171
|
def pages_for_select(pages = nil, selected = nil, prompt = "", page_attribute = :id)
|
172
172
|
result = [[prompt.blank? ? t('Choose page') : prompt, ""]]
|
173
173
|
if pages.blank?
|
174
|
-
pages = Page.
|
174
|
+
pages = Page.with_language(session[:language_id]).published
|
175
175
|
end
|
176
176
|
pages.each do |p|
|
177
177
|
result << [p.name, p.send(page_attribute).to_s]
|
@@ -75,7 +75,7 @@ module Alchemy
|
|
75
75
|
#
|
76
76
|
# <%= render_create_content_link(element, 'file', :label => 'Add a file') %>
|
77
77
|
#
|
78
|
-
def render_create_content_link(element, content_name, options = {})
|
78
|
+
def render_create_content_link(element, content_name, options = {}, options_for_content = {})
|
79
79
|
defaults = {
|
80
80
|
:label => t('Add %{name}', :name => t(content_name, :scope => :content_names))
|
81
81
|
}
|
@@ -84,7 +84,8 @@ module Alchemy
|
|
84
84
|
:content => {
|
85
85
|
:name => content_name,
|
86
86
|
:element_id => element.id
|
87
|
-
}
|
87
|
+
},
|
88
|
+
:options => options_for_content.to_json
|
88
89
|
),
|
89
90
|
:method => :post,
|
90
91
|
:remote => true,
|
@@ -112,6 +112,28 @@ module Alchemy
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
+
def update_elements_with_essence_selects(page, element)
|
116
|
+
elements = page.contents.essence_selects.collect(&:element).uniq.delete_if { |e| e == element }
|
117
|
+
if elements.any?
|
118
|
+
js = "var $ess_sel_el;"
|
119
|
+
elements.each do |element|
|
120
|
+
rtfs = element.contents.essence_richtexts
|
121
|
+
js += "\n$ess_sel_el = $('#element_#{element.id}');"
|
122
|
+
rtfs.each do |content|
|
123
|
+
js += "\ntinymce.get('contents_content_#{content.id}_body').remove();"
|
124
|
+
end
|
125
|
+
js += "\n$('div.element_content', $ess_sel_el).html('#{escape_javascript render_editor(element)}');"
|
126
|
+
js += "\nAlchemy.GUI.initElement($ess_sel_el);"
|
127
|
+
rtfs.each do |content|
|
128
|
+
js += "\nAlchemy.Tinymce.addEditor('#{content.form_field_id}');"
|
129
|
+
end
|
130
|
+
end
|
131
|
+
js
|
132
|
+
else
|
133
|
+
nil
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
115
137
|
end
|
116
138
|
end
|
117
139
|
end
|
@@ -4,9 +4,9 @@ module Alchemy
|
|
4
4
|
include Alchemy::EssencesHelper
|
5
5
|
|
6
6
|
# Renders all elements from current page.
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# === Options are:
|
9
|
-
#
|
9
|
+
#
|
10
10
|
# :only => [] # A list of element names to be rendered only. Very useful if you want to render a specific element type in a special html part (e.g.. <div>) of your page and all other elements in another part.
|
11
11
|
# :except => [] # A list of element names to be rendered. The opposite of the only option.
|
12
12
|
# :from_page # The Alchemy::Page.page_layout string from which the elements are rendered from, or you even pass a Page object.
|
@@ -16,14 +16,14 @@ module Alchemy
|
|
16
16
|
# :for => 'ELEMENT_NAME', # The name of the element the fallback is for
|
17
17
|
# :with => 'ELEMENT_NAME', # (OPTIONAL) the name of element to fallback with
|
18
18
|
# :from => 'PAGE_LAYOUT' # The page_layout name from the global page the fallback elements lie on. I.E 'left_column'
|
19
|
-
# } #
|
19
|
+
# } #
|
20
20
|
# :sort_by => Content#name # A Content name to sort the elements by
|
21
21
|
# :reverse => boolean # Reverse the rendering order
|
22
22
|
# :random => boolean # Randomize the output of elements
|
23
|
-
#
|
23
|
+
#
|
24
24
|
# === Note:
|
25
25
|
# This helper also stores all pages where elements gets rendered on, so we can sweep them later if caching expires!
|
26
|
-
#
|
26
|
+
#
|
27
27
|
def render_elements(options = {})
|
28
28
|
default_options = {
|
29
29
|
:except => [],
|
@@ -116,13 +116,13 @@ module Alchemy
|
|
116
116
|
}
|
117
117
|
options = default_options.merge(options)
|
118
118
|
if options[:from_page] == :all
|
119
|
-
elements = Element.
|
119
|
+
elements = Element.published.where(:name => name).limit(options[:count] == :all ? nil : options[:count])
|
120
120
|
elsif options[:from_page].class == String
|
121
|
-
page = Page.
|
121
|
+
page = Page.with_language(session[:language_id]).find_by_page_layout(options[:from_page])
|
122
122
|
return [] if page.blank?
|
123
|
-
elements = page.elements.
|
123
|
+
elements = page.elements.published.where(:name => name).limit(options[:count] == :all ? nil : options[:count])
|
124
124
|
else
|
125
|
-
elements = options[:from_page].elements.
|
125
|
+
elements = options[:from_page].elements.published.where(:name => name).limit(options[:count] == :all ? nil : options[:count])
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
@@ -135,12 +135,12 @@ module Alchemy
|
|
135
135
|
}
|
136
136
|
options = default_options.merge(options)
|
137
137
|
if options[:page_id].blank?
|
138
|
-
page = Page.
|
138
|
+
page = Page.published.find_by_urlname(options[:page_urlname])
|
139
139
|
else
|
140
|
-
page = Page.
|
140
|
+
page = Page.published.find_by_id(options[:page_id])
|
141
141
|
end
|
142
142
|
return "" if page.blank?
|
143
|
-
element = page.elements.
|
143
|
+
element = page.elements.published.find_by_name(options[:element_name])
|
144
144
|
return element
|
145
145
|
end
|
146
146
|
|
@@ -17,11 +17,11 @@ module Alchemy
|
|
17
17
|
end
|
18
18
|
|
19
19
|
# == Helper for rendering language switches
|
20
|
-
#
|
20
|
+
#
|
21
21
|
# Renders links to all public language root pages
|
22
|
-
#
|
22
|
+
#
|
23
23
|
# === Options:
|
24
|
-
#
|
24
|
+
#
|
25
25
|
# :linkname => :name,
|
26
26
|
# :spacer => "",
|
27
27
|
# :link_to_public_child => configuration(:redirect_to_public_child),
|
@@ -30,7 +30,7 @@ module Alchemy
|
|
30
30
|
# :reverse => false,
|
31
31
|
# :as_select_box => false,
|
32
32
|
# :show_flags => false
|
33
|
-
#
|
33
|
+
#
|
34
34
|
def language_switcher(options={})
|
35
35
|
default_options = {
|
36
36
|
:linkname => :name,
|
@@ -114,9 +114,9 @@ module Alchemy
|
|
114
114
|
#
|
115
115
|
# It produces a html <ul><li></li></ul> structure with all necessary classes so you can produce every navigation the web uses today.
|
116
116
|
# I.E. dropdown-navigations, simple mainnavigations or even complex nested ones.
|
117
|
-
#
|
117
|
+
#
|
118
118
|
# === En detail:
|
119
|
-
#
|
119
|
+
#
|
120
120
|
# <ul class="navigation level_1">
|
121
121
|
# <li class="first home"><a href="/home" class="active" title="Homepage" lang="en" data-page-id="1">Homepage</a></li>
|
122
122
|
# <li class="contact"><a href="/contact" title="Contact" lang="en" data-page-id="2">Contact</a></li>
|
@@ -142,15 +142,15 @@ module Alchemy
|
|
142
142
|
# :show_title => true # Show a title on navigation links. Title attribute from page.
|
143
143
|
# :reverse => false # Reverse the navigation
|
144
144
|
# :reverse_children => false # Reverse the nested children
|
145
|
-
#
|
145
|
+
#
|
146
146
|
# === Passing HTML classes and ids to the renderer
|
147
|
-
#
|
147
|
+
#
|
148
148
|
# A second hash will be passed as html_options to the navigation renderer partial.
|
149
|
-
#
|
149
|
+
#
|
150
150
|
# ==== Example:
|
151
|
-
#
|
151
|
+
#
|
152
152
|
# <%= render_navigation({from_page => 'subnavi'}, {:class => 'navigation', :id => 'subnavigation'}) %>
|
153
|
-
#
|
153
|
+
#
|
154
154
|
def render_navigation(options = {}, html_options = {})
|
155
155
|
default_options = {
|
156
156
|
:submenu => false,
|
@@ -196,17 +196,17 @@ module Alchemy
|
|
196
196
|
end
|
197
197
|
|
198
198
|
# Renders navigation the children and all siblings of the given page (standard is the current page).
|
199
|
-
#
|
199
|
+
#
|
200
200
|
# Use this helper if you want to render the subnavigation independent from the mainnavigation. I.E. to place it in a different area on your website.
|
201
|
-
#
|
201
|
+
#
|
202
202
|
# This helper passes all its options to the the render_navigation helper.
|
203
|
-
#
|
203
|
+
#
|
204
204
|
# === Options:
|
205
|
-
#
|
205
|
+
#
|
206
206
|
# :from_page => @page # The page to render the navigation from
|
207
207
|
# :submenu => true # Shows the nested children
|
208
208
|
# :level => 2 # Normally there is no need to change the level parameter, just in a few special cases
|
209
|
-
#
|
209
|
+
#
|
210
210
|
def render_subnavigation(options = {})
|
211
211
|
default_options = {
|
212
212
|
:from_page => @page,
|
@@ -237,9 +237,9 @@ module Alchemy
|
|
237
237
|
end
|
238
238
|
|
239
239
|
# Returns page links in a breadcrumb beginning from root to current page.
|
240
|
-
#
|
240
|
+
#
|
241
241
|
# === Options:
|
242
|
-
#
|
242
|
+
#
|
243
243
|
# :seperator => %(<span class="seperator">></span>) # Maybe you don't want this seperator. Pass another one.
|
244
244
|
# :page => @page # Pass a different Page instead of the default (@page).
|
245
245
|
# :without => nil # Pass Pageobject or array of Pages that must not be displayed.
|
@@ -247,7 +247,7 @@ module Alchemy
|
|
247
247
|
# :visible_only => true # Pass boolean for displaying (in navigation) visible pages only.
|
248
248
|
# :restricted_only => false # Pass boolean for displaying restricted pages only.
|
249
249
|
# :reverse => false # Pass boolean for displaying reversed breadcrumb.
|
250
|
-
#
|
250
|
+
#
|
251
251
|
def render_breadcrumb(options={})
|
252
252
|
default_options = {
|
253
253
|
:seperator => %(<span class="seperator">></span>),
|
@@ -296,15 +296,15 @@ module Alchemy
|
|
296
296
|
# Returns current page title
|
297
297
|
#
|
298
298
|
# === Options:
|
299
|
-
#
|
299
|
+
#
|
300
300
|
# :prefix => "" # Prefix
|
301
301
|
# :seperator => "" # Seperating prefix and title
|
302
302
|
#
|
303
303
|
# === Webdevelopers
|
304
|
-
#
|
304
|
+
#
|
305
305
|
# Please use the render_meta_data() helper instead. There all important meta information gets rendered in one helper.
|
306
306
|
# So you dont have to worry about anything.
|
307
|
-
#
|
307
|
+
#
|
308
308
|
def render_page_title(options={})
|
309
309
|
return "" if @page.title.blank?
|
310
310
|
default_options = {
|
@@ -318,10 +318,10 @@ module Alchemy
|
|
318
318
|
# Returns a complete html <title> tag for the <head> part of the html document.
|
319
319
|
#
|
320
320
|
# === Webdevelopers:
|
321
|
-
#
|
321
|
+
#
|
322
322
|
# Please use the render_meta_data() helper. There all important meta information gets rendered in one helper.
|
323
323
|
# So you dont have to worry about anything.
|
324
|
-
#
|
324
|
+
#
|
325
325
|
def render_title_tag(options={})
|
326
326
|
default_options = {
|
327
327
|
:prefix => "",
|
@@ -334,10 +334,10 @@ module Alchemy
|
|
334
334
|
# Renders a html <meta> tag for :name => "" and :content => ""
|
335
335
|
#
|
336
336
|
# === Webdevelopers:
|
337
|
-
#
|
337
|
+
#
|
338
338
|
# Please use the render_meta_data() helper. There all important meta information gets rendered in one helper.
|
339
339
|
# So you dont have to worry about anything.
|
340
|
-
#
|
340
|
+
#
|
341
341
|
def render_meta_tag(options={})
|
342
342
|
default_options = {
|
343
343
|
:name => "",
|
@@ -350,17 +350,17 @@ module Alchemy
|
|
350
350
|
end
|
351
351
|
|
352
352
|
# This helper takes care of all important meta tags for your page.
|
353
|
-
#
|
353
|
+
#
|
354
354
|
# The meta data is been taken from the @page.title, @page.meta_description, @page.meta_keywords, @page.updated_at and @page.language database entries managed by the Alchemy user via the Alchemy cockpit.
|
355
|
-
#
|
355
|
+
#
|
356
356
|
# Assume that the user has entered following data into the Alchemy cockpit of the Page "home" and that the user wants that the searchengine (aka. google) robot should index the page and should follow all links on this page:
|
357
|
-
#
|
357
|
+
#
|
358
358
|
# Title = Homepage
|
359
359
|
# Description = Your page description
|
360
360
|
# Keywords: cms, ruby, rubyonrails, rails, software, development, html, javascript, ajax
|
361
|
-
#
|
361
|
+
#
|
362
362
|
# Then placing +render_meta_data(:title_prefix => "company", :title_seperator => "-")+ into the <head> part of the +pages.html.erb+ layout produces:
|
363
|
-
#
|
363
|
+
#
|
364
364
|
# <meta charset="UTF-8">
|
365
365
|
# <title>Company - #{@page.title}</title>
|
366
366
|
# <meta name="description" content="Your page description">
|
@@ -368,7 +368,7 @@ module Alchemy
|
|
368
368
|
# <meta name="generator" content="Alchemy VERSION">
|
369
369
|
# <meta name="date" content="Tue Dec 16 10:21:26 +0100 2008">
|
370
370
|
# <meta name="robots" content="index, follow">
|
371
|
-
#
|
371
|
+
#
|
372
372
|
def render_meta_data options={}
|
373
373
|
if @page.blank?
|
374
374
|
warning("No Page found!")
|
@@ -382,13 +382,13 @@ module Alchemy
|
|
382
382
|
options = default_options.merge(options)
|
383
383
|
#render meta description of the root page from language if the current meta description is empty
|
384
384
|
if @page.meta_description.blank?
|
385
|
-
description = Page.
|
385
|
+
description = Page.published.with_language(session[:language_id]).find_by_language_root(true).try(:meta_description)
|
386
386
|
else
|
387
387
|
description = @page.meta_description
|
388
388
|
end
|
389
389
|
#render meta keywords of the root page from language if the current meta keywords is empty
|
390
390
|
if @page.meta_keywords.blank?
|
391
|
-
keywords = Page.
|
391
|
+
keywords = Page.published.with_language(session[:language_id]).find_by_language_root(true).try(:meta_keywords)
|
392
392
|
else
|
393
393
|
keywords = @page.meta_keywords
|
394
394
|
end
|
@@ -410,14 +410,14 @@ module Alchemy
|
|
410
410
|
end
|
411
411
|
|
412
412
|
# This helper returns a path for use inside a link_to helper.
|
413
|
-
#
|
413
|
+
#
|
414
414
|
# You may pass a page_layout or an urlname.
|
415
415
|
# Any additional options are passed to the url_helper, so you can add arguments to your url.
|
416
|
-
#
|
416
|
+
#
|
417
417
|
# Example:
|
418
|
-
#
|
418
|
+
#
|
419
419
|
# <%= link_to '» order now', page_path_for(:page_layout => 'orderform', :product_id => element.id) %>
|
420
|
-
#
|
420
|
+
#
|
421
421
|
def page_path_for(options={})
|
422
422
|
return warning("No page_layout, or urlname given. I got #{options.inspect} ") if options[:page_layout].blank? && options[:urlname].blank?
|
423
423
|
if options[:urlname].blank?
|
@@ -435,9 +435,9 @@ module Alchemy
|
|
435
435
|
|
436
436
|
# Renders the partial for the cell with the given name of the current page.
|
437
437
|
# Cell partials are located in +app/views/cells/+ of your project.
|
438
|
-
#
|
438
|
+
#
|
439
439
|
# === Options are:
|
440
|
-
#
|
440
|
+
#
|
441
441
|
# :from_page => Alchemy::Page # Alchemy::Page object from which the elements are rendered from.
|
442
442
|
# :locals => Hash # Hash of variables that will be available in the partial. Example: {:user => var1, :product => var2}
|
443
443
|
#
|
@@ -521,12 +521,12 @@ module Alchemy
|
|
521
521
|
return multi_language? ? url_params.update(:lang => page.language_code) : url_params
|
522
522
|
end
|
523
523
|
|
524
|
-
#
|
524
|
+
#
|
525
525
|
def show_alchemy_page_path(page, optional_params={})
|
526
526
|
alchemy.show_page_path(show_page_path_params(page, optional_params))
|
527
527
|
end
|
528
528
|
|
529
|
-
#
|
529
|
+
#
|
530
530
|
def show_alchemy_page_url(page, optional_params={})
|
531
531
|
alchemy.show_page_url(show_page_path_params(page, optional_params))
|
532
532
|
end
|
@@ -542,7 +542,7 @@ module Alchemy
|
|
542
542
|
<script type="text/javascript">
|
543
543
|
try {
|
544
544
|
Alchemy.loadAlchemyMenuBar({
|
545
|
-
page_id: #{@page.id},
|
545
|
+
page_id: '#{@page.urlname || @page.id}',
|
546
546
|
route: '#{Alchemy.mount_point}',
|
547
547
|
locale: '#{current_user.language}'
|
548
548
|
});
|