alchemy_cms 2.1.rc2 → 2.1.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. data/Gemfile +1 -0
  2. data/app/assets/javascripts/alchemy/alchemy.link_overlay.js +3 -3
  3. data/app/assets/stylesheets/alchemy/elements.css.scss +20 -9
  4. data/app/assets/stylesheets/alchemy/jquery-ui.alchemy.css.scss +1 -1
  5. data/app/assets/stylesheets/alchemy/jquery.Jcrop.css.scss +1 -1
  6. data/app/assets/stylesheets/alchemy/jquery.sb.css.scss +1 -1
  7. data/app/assets/stylesheets/alchemy/menubar.css.scss +3 -2
  8. data/app/assets/stylesheets/alchemy/tinymce_content.css.scss +1 -1
  9. data/app/assets/stylesheets/alchemy/tinymce_dialog.css.scss +1 -1
  10. data/app/controllers/alchemy/admin/base_controller.rb +1 -1
  11. data/app/helpers/alchemy/admin/base_helper.rb +1 -40
  12. data/app/helpers/alchemy/admin/contents_helper.rb +7 -1
  13. data/app/helpers/alchemy/admin/elements_helper.rb +1 -5
  14. data/app/helpers/alchemy/admin/essences_helper.rb +50 -6
  15. data/app/helpers/alchemy/elements_helper.rb +17 -11
  16. data/app/helpers/alchemy/pages_helper.rb +75 -56
  17. data/app/models/alchemy/content.rb +23 -14
  18. data/app/models/alchemy/element.rb +56 -46
  19. data/app/views/alchemy/admin/contents/_missing.html.erb +2 -1
  20. data/app/views/alchemy/admin/contents/create.js.erb +7 -6
  21. data/app/views/alchemy/admin/dashboard/index.html.erb +1 -1
  22. data/app/views/alchemy/essences/_essence_text_editor.html.erb +11 -9
  23. data/app/views/alchemy/navigation/_renderer.html.erb +1 -1
  24. data/config/locales/alchemy.de.yml +1 -1
  25. data/config/locales/alchemy.en.yml +21 -21
  26. data/lib/alchemy/capistrano.rb +57 -48
  27. data/lib/alchemy/page_layout.rb +6 -8
  28. data/lib/alchemy/version.rb +1 -1
  29. data/spec/helpers/pages_helper_spec.rb +76 -2
  30. data/spec/integration/pages_controller_spec.rb +1 -1
  31. data/spec/models/content_spec.rb +24 -0
  32. data/spec/models/element_spec.rb +23 -0
  33. metadata +32 -31
data/Gemfile CHANGED
@@ -23,5 +23,6 @@ group :development do
23
23
  gem 'ruby-debug19', '~> 0.11.6', :require => 'ruby-debug', :platform => :ruby_19
24
24
  gem 'ruby-debug', :platform => :ruby_18
25
25
  gem 'guard-spork'
26
+ gem 'yard'
26
27
  end
27
28
  end
@@ -72,7 +72,7 @@ if (typeof(Alchemy) === 'undefined') {
72
72
  });
73
73
  editor.selection.collapse();
74
74
  } else {
75
- // aka: we are linking an content
75
+ // aka: we are linking an essence
76
76
  var essence_type = element.name.replace('essence_', '').split('_')[0];
77
77
  var content_id = null;
78
78
  switch (essence_type) {
@@ -83,7 +83,7 @@ if (typeof(Alchemy) === 'undefined') {
83
83
  content_id = element.name.replace('essence_text_', '');
84
84
  break;
85
85
  }
86
- $('#contents_content_' + content_id + '_link').val(url);
86
+ $('#contents_content_' + content_id + '_link').val(url).change();
87
87
  $('#contents_content_' + content_id + '_link_title').val(title);
88
88
  $('#contents_content_' + content_id + '_link_class_name').val(link_type);
89
89
  $('#contents_content_' + content_id + '_link_target').val(target);
@@ -203,7 +203,7 @@ if (typeof(Alchemy) === 'undefined') {
203
203
 
204
204
  removeLink : function(link, content_id) {
205
205
  Alchemy.setElementDirty($(link).parents('.element_editor'));
206
- $('#contents_content_' + content_id + '_link').val('');
206
+ $('#contents_content_' + content_id + '_link').val('').change();
207
207
  $('#contents_content_' + content_id + '_link_title').val('');
208
208
  $('#contents_content_' + content_id + '_link_class_name').val('');
209
209
  $('#contents_content_' + content_id + '_link_target').val('');
@@ -321,17 +321,28 @@ div#element_area .sortable_cell {
321
321
  top: 5px;
322
322
  }
323
323
 
324
- div.content_editor a.icon_button {
325
- margin: 0 0 0 4px;
324
+ span.linkable_text_essence_tools {
326
325
  position: absolute;
327
326
  bottom: 0;
328
- right: 24px;
329
- @include reset-border-radius;
330
- }
331
-
332
- div.content_editor a.icon_button.unlink {
333
- @include right-rounded-border;
334
- right: 1px;
327
+ right: 2px;
328
+ a.icon_button {
329
+ margin: 0 0 0 4px;
330
+ position: absolute;
331
+ bottom: 0;
332
+ right: 26px;
333
+ @include reset-border-radius;
334
+ height: 27px;
335
+ width: 27px;
336
+ background-position: 0 -72px;
337
+ &.unlink {
338
+ right: 0;
339
+ @include right-rounded-border;
340
+ }
341
+ .icon {
342
+ left: 5px;
343
+ top: 6px;
344
+ }
345
+ }
335
346
  }
336
347
 
337
348
  a.expand_element {
@@ -1,4 +1,4 @@
1
- @import "defaults";
1
+ @import "alchemy/defaults";
2
2
 
3
3
  /*
4
4
  * jQuery UI CSS Framework 1.8.7
@@ -1,4 +1,4 @@
1
- @import "defaults";
1
+ @import "alchemy/defaults";
2
2
  /* Fixes issue here http://code.google.com/p/jcrop/issues/detail?id=1 */
3
3
  .jcrop-holder { text-align: left; }
4
4
 
@@ -1,4 +1,4 @@
1
- @import "defaults";
1
+ @import "alchemy/defaults";
2
2
 
3
3
  /* always visible styles */
4
4
 
@@ -2,7 +2,7 @@
2
2
  *= require_self
3
3
  */
4
4
 
5
- @import "defaults";
5
+ @import "alchemy/defaults";
6
6
 
7
7
  @mixin transition {
8
8
  -webkit-transition: left 0.15s ease;
@@ -61,8 +61,9 @@
61
61
  background: image-url('alchemy/icons.png') -240px 0;
62
62
  };
63
63
  ul {
64
- padding: 6px 0;
64
+ padding: 0;
65
65
  margin: 0;
66
+ line-height: 2em;
66
67
  li {
67
68
  line-height: normal;
68
69
  margin-right: $default-padding;
@@ -1,4 +1,4 @@
1
- @import "defaults";
1
+ @import "alchemy/defaults";
2
2
 
3
3
  body, td, pre {
4
4
  color: $text-color;
@@ -1,4 +1,4 @@
1
- @import "defaults";
1
+ @import "alchemy/defaults";
2
2
 
3
3
  /* Generic */
4
4
 
@@ -61,7 +61,7 @@ module Alchemy
61
61
 
62
62
  def get_clipboard(category = nil)
63
63
  clipboard = (session[:clipboard] ||= {})
64
- clipboard[category.pluralize] ||= [] if category
64
+ clipboard[category.to_s.pluralize] ||= [] if category
65
65
  end
66
66
 
67
67
  def clipboard_empty?(category = nil)
@@ -105,45 +105,6 @@ module Alchemy
105
105
  )
106
106
  end
107
107
 
108
- # Renders a form select tag for storing page urlnames
109
- # Options:
110
- # * element - element the Content find via content_name to store the pages urlname in.
111
- # * content_name - the name of the content from element to store the pages urlname in.
112
- # * options (Hash)
113
- # ** :only (Hash) - pass page_layout names to :page_layout => [""] so only pages with this page_layout will be displayed inside the select.
114
- # ** :except (Hash) - pass page_layout names to :page_layout => [""] so all pages except these with this page_layout will be displayed inside the select.
115
- # ** :page_attribute (Symbol) - The Page attribute which will be stored.
116
- # * select_options (Hash) - will be passed to the select_tag helper
117
- def page_selector(element, content_name, options = {}, select_options = {})
118
- default_options = {
119
- :except => {
120
- :page_layout => [""]
121
- },
122
- :only => {
123
- :page_layout => [""]
124
- },
125
- :page_attribute => :urlname,
126
- :prompt => t('Choose page')
127
- }
128
- options = default_options.merge(options)
129
- content = element.content_by_name(content_name)
130
- if content.nil?
131
- return warning('Content', t('content_not_found'))
132
- elsif content.essence.nil?
133
- return warning('Content', t('content_essence_not_found'))
134
- end
135
- pages = Page.where({
136
- :language_id => session[:language_id],
137
- :page_layout => options[:only][:page_layout],
138
- :public => true
139
- })
140
- select_tag(
141
- "contents[content_#{content.id}][body]",
142
- pages_for_select(pages, content.essence.body, options[:prompt], options[:page_attribute]),
143
- select_options
144
- )
145
- end
146
-
147
108
  # Returns an Array build for passing it to the options_for_select helper inside an essence editor partial.
148
109
  # Usefull for the select_values options from the render_essence_editor helpers.
149
110
  # Options:
@@ -318,7 +279,7 @@ module Alchemy
318
279
  'paste_from_clipboard',
319
280
  !@page.new_record? && @page.can_have_cells? ? grouped_elements_for_select(items, :id) : options_for_select(options),
320
281
  {
321
- :class => html_options[:class] || 'very_long',
282
+ :class => html_options[:class],
322
283
  :style => html_options[:style]
323
284
  }
324
285
  )
@@ -27,7 +27,7 @@ module Alchemy
27
27
  if content.description.blank?
28
28
  warning("Content #{content.name} is missing its description")
29
29
  title = t("Warning: Content is missing its description.", :contentname => content.name)
30
- content_name = %(<span class="warning icon" title="#{title}"></span>&nbsp;) + content_name.html_safe
30
+ content_name = %(<span class="warning icon" title="#{title}"></span>&nbsp;#{content_name}).html_safe
31
31
  end
32
32
  content.has_validations? ? "#{content_name}<span class='validation_indicator'>*</span>".html_safe : content_name
33
33
  end
@@ -70,6 +70,12 @@ module Alchemy
70
70
  )
71
71
  end
72
72
 
73
+ # Returns a textarea ready to use with tinymce
74
+ def tinymce_tag(name, content = '', options = {})
75
+ append_class_name(options, 'tinymce')
76
+ text_area_tag(name, content, options)
77
+ end
78
+
73
79
  end
74
80
  end
75
81
  end
@@ -4,6 +4,7 @@ module Alchemy
4
4
 
5
5
  include Alchemy::ElementsHelper
6
6
  include Alchemy::Admin::BaseHelper
7
+ include Alchemy::Admin::ContentsHelper
7
8
  include Alchemy::Admin::EssencesHelper
8
9
 
9
10
  # Returns an Array for essence_text_editor select options_for_select.
@@ -108,11 +109,6 @@ module Alchemy
108
109
  end
109
110
  end
110
111
 
111
- def tinymce_tag(name, content = '', options = {})
112
- append_class_name(options, 'tinymce')
113
- text_area_tag(name, content, options)
114
- end
115
-
116
112
  end
117
113
  end
118
114
  end
@@ -34,11 +34,11 @@ module Alchemy
34
34
  if options[:all]
35
35
  contents = element.contents.find_all_by_essence_type_and_name(essence_type, options[:all])
36
36
  contents.each do |content|
37
- return_string << render_essence(content, :editor, :for_editor => editor_options)
37
+ return_string << render_essence_editor(content, editor_options)
38
38
  end
39
39
  else
40
40
  content = element.contents.find_by_essence_type_and_position(essence_type, options[:position])
41
- return_string = render_essence(content, :editor, :for_editor => editor_options)
41
+ return_string = render_essence_editor(content, editor_options)
42
42
  end
43
43
  return_string
44
44
  end
@@ -51,7 +51,11 @@ module Alchemy
51
51
  return ""
52
52
  end
53
53
  content = element.contents.find_by_position(position)
54
- render_essence(content, :editor, :for_editor => options)
54
+ if content.nil?
55
+ render_missing_content(element, position, options)
56
+ else
57
+ render_essence_editor(content, options)
58
+ end
55
59
  end
56
60
 
57
61
  # Renders the Content editor partial found in views/contents/ for the content with name inside the passed Element.
@@ -66,13 +70,53 @@ module Alchemy
66
70
  return warning('Element is nil', t("no_element_given"))
67
71
  end
68
72
  content = element.content_by_name(name)
69
- if content.blank?
70
- render :partial => 'alchemy/admin/contents/missing', :locals => {:element => element, :name => name}
73
+ if content.nil?
74
+ render_missing_content(element, name, options)
75
+ else
76
+ render_essence_editor(content, options)
77
+ end
78
+ end
79
+
80
+ # Renders the EssenceText editor partial with a form select for storing page urlnames
81
+ # Options:
82
+ # * element - element the Content find via content_name to store the pages urlname in.
83
+ # * content_name - the name of the content from element to store the pages urlname in.
84
+ # * options (Hash)
85
+ # ** :only (Hash) - pass page_layout names to :page_layout => [""] so only pages with this page_layout will be displayed inside the select.
86
+ # ** :except (Hash) - pass page_layout names to :page_layout => [""] so all pages except these with this page_layout will be displayed inside the select.
87
+ # ** :page_attribute (Symbol) - The Page attribute which will be stored.
88
+ def page_selector(element, content_name, options = {}, select_options = {})
89
+ default_options = {
90
+ :except => {
91
+ :page_layout => [""]
92
+ },
93
+ :only => {
94
+ :page_layout => [""]
95
+ },
96
+ :page_attribute => :id,
97
+ :prompt => t('Choose page')
98
+ }
99
+ options = default_options.merge(options)
100
+ pages = Page.where({
101
+ :language_id => session[:language_id],
102
+ :page_layout => options[:only][:page_layout],
103
+ :public => true
104
+ })
105
+ content = element.content_by_name(content_name)
106
+ options.update(
107
+ :select_values => pages_for_select(pages, content ? content.essence.body : nil, options[:prompt], options[:page_attribute])
108
+ )
109
+ if content.nil?
110
+ render_missing_content(element, content_name, options)
71
111
  else
72
- render_essence(content, :editor, :for_editor => options)
112
+ render_essence_editor(content, options)
73
113
  end
74
114
  end
75
115
 
116
+ def render_missing_content(element, name, options)
117
+ render :partial => 'alchemy/admin/contents/missing', :locals => {:element => element, :name => name, :options => options}
118
+ end
119
+
76
120
  end
77
121
  end
78
122
  end
@@ -3,18 +3,24 @@ module Alchemy
3
3
 
4
4
  include Alchemy::EssencesHelper
5
5
 
6
- # Renders all elements from @page.
7
- # ---
8
- # == Options are:
9
- # :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.
10
- # :except => [] A list of element names to be rendered. The opposite of the only option.
11
- # :from_page The Alchemy::Page.page_layout string from which the elements are rendered from, or you even pass a Page object.
12
- # :count The amount of elements to be rendered (begins with first element found)
13
- # :fallback => {:for => 'ELEMENT_NAME', :with => 'ELEMENT_NAME', :from => 'PAGE_LAYOUT'} when no element from this name is found on page, then use this element from that page
14
- # :sort_by => Content#name A Content name to sort the elements by
15
- # :reverse => boolean Reverse the rendering order
16
- # :random => boolean Random output of elements
6
+ # Renders all elements from current page.
17
7
  #
8
+ # === Options are:
9
+ #
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
+ # :except => [] # A list of element names to be rendered. The opposite of the only option.
12
+ # :from_page # The Alchemy::Page.page_layout string from which the elements are rendered from, or you even pass a Page object.
13
+ # :count # The amount of elements to be rendered (begins with first element found)
14
+ # :fallback => { # You can use the fallback option as an override. So you can take elements from a glo´bal laout page and only if the user adds an element on current page the local one gets rendered.
15
+ # :for => 'ELEMENT_NAME', # The name of the element the fallback is for
16
+ # :with => 'ELEMENT_NAME', # (OPTIONAL) the name of element to fallback with
17
+ # :from => 'PAGE_LAYOUT' # The page_layout name from the global page the fallback elements lie on. I.E 'left_column'
18
+ # } #
19
+ # :sort_by => Content#name # A Content name to sort the elements by
20
+ # :reverse => boolean # Reverse the rendering order
21
+ # :random => boolean # Randomize the output of elements
22
+ #
23
+ # === Note:
18
24
  # This helper also stores all pages where elements gets rendered on, so we can sweep them later if caching expires!
19
25
  #
20
26
  def render_elements(options = {})
@@ -69,8 +69,21 @@ module Alchemy
69
69
  )
70
70
  end
71
71
 
72
- # helper for language switching
73
- # returns a string with links or nil
72
+ # == Helper for rendering language switches
73
+ #
74
+ # Renders links to all public language root pages
75
+ #
76
+ # === Options:
77
+ #
78
+ # :linkname => :name,
79
+ # :spacer => "",
80
+ # :link_to_public_child => configuration(:redirect_to_public_child),
81
+ # :link_to_page_with_layout => nil,
82
+ # :show_title => true,
83
+ # :reverse => false,
84
+ # :as_select_box => false,
85
+ # :show_flags => false
86
+ #
74
87
  def language_switcher(options={})
75
88
  default_options = {
76
89
  :linkname => :name,
@@ -79,7 +92,8 @@ module Alchemy
79
92
  :link_to_page_with_layout => nil,
80
93
  :show_title => true,
81
94
  :reverse => false,
82
- :as_select_box => false
95
+ :as_select_box => false,
96
+ :show_flags => false
83
97
  }
84
98
  options = default_options.merge(options)
85
99
  if multi_language?
@@ -99,7 +113,7 @@ module Alchemy
99
113
  language_links << [linkname, show_page_url(:urlname => page.urlname, :lang => page.language.code)]
100
114
  else
101
115
  language_links << link_to(
102
- "#{content_tag(:span, '', :class => "flag")}#{ content_tag(:span, linkname)}".html_safe,
116
+ "#{content_tag(:span, '', :class => "flag") if options[:show_flags]}#{ content_tag(:span, linkname)}".html_safe,
103
117
  alchemy.show_page_path(:urlname => page.urlname, :lang => page.language.code),
104
118
  :class => "#{(active ? 'active ' : nil)}#{page.language.code} #{(i == 0) ? 'first' : (i==pages.length-1) ? 'last' : nil}",
105
119
  :title => options[:show_title] ? Alchemy::I18n.t("alchemy.language_links.#{page.language.code}.title", :default => page.language.name) : nil
@@ -152,18 +166,18 @@ module Alchemy
152
166
  page_title.ingredient('name')
153
167
  end
154
168
 
155
- # == This helper renders the navigation.
169
+ # Renders the navigation.
156
170
  #
157
171
  # It produces a html <ul><li></li></ul> structure with all necessary classes and ids so you can produce every navigation the web uses today.
158
172
  # I.E. dropdown-navigations, simple mainnavigations or even complex nested ones.
159
173
  #
160
174
  # === En detail:
161
175
  #
162
- # <ul class="navigation_level_1">
163
- # <li class="first home"><a href="/home" class="active" title="Homepage" lang="en" data-page-id="1">Homepage</a></li>
164
- # <li class="contact"><a href="/contact" title="Contact" lang="en" data-page-id="2">Contact</a></li>
165
- # <li class="last imprint"><a href="/imprint" title="Imprint" lang="en" data-page-id="3">Imprint</a></li>
166
- # </ul>
176
+ # <ul class="navigation_level_1">
177
+ # <li class="first home"><a href="/home" class="active" title="Homepage" lang="en" data-page-id="1">Homepage</a></li>
178
+ # <li class="contact"><a href="/contact" title="Contact" lang="en" data-page-id="2">Contact</a></li>
179
+ # <li class="last imprint"><a href="/imprint" title="Imprint" lang="en" data-page-id="3">Imprint</a></li>
180
+ # </ul>
167
181
  #
168
182
  # As you can see: Everything you need.
169
183
  #
@@ -172,18 +186,18 @@ module Alchemy
172
186
  #
173
187
  # === The options are:
174
188
  #
175
- # :submenu => false Do you want a nested <ul> <li> structure for the deeper levels of your navigation, or not? Used to display the subnavigation within the mainnaviagtion. E.g. for dropdown menues.
176
- # :all_sub_menues => false
177
- # :from_page => @root_page Do you want to render a navigation from a different page then the current page? Then pass an Page instance or a Alchemy::PageLayout name as string.
178
- # :spacer => "" Yeah even a spacer for the entries can be passed. Simple string, or even a complex html structure. E.g: "<span class='spacer'>|</spacer>". Only your imagination is the limit. And the W3C of course :)
179
- # :navigation_partial => "navigation/renderer" Pass a different partial to be taken for the navigation rendering. CAUTION: Only for the advanced Alchemy webdevelopers. The standard partial takes care of nearly everything. But maybe you are an adventures one ^_^
180
- # :navigation_link_partial => "navigation/link" Alchemy places an <a> html link in <li> tags. The tag automatically has an active css class if necessary. So styling is everything. But maybe you don't want this. So feel free to make you own partial and pass the filename here.
181
- # :show_nonactive => false Commonly Alchemy only displays the submenu of the active page (if :submenu => true). If you want to display all child pages then pass true (together with :submenu => true of course). E.g. for the popular css-driven dropdownmenues these days.
182
- # :show_title => true For our beloved SEOs :). Appends a title attribute to all links and places the page.title content into it.
183
- # :restricted_only => nil Render only restricted pages.
184
- # :show_title => true Show a title on navigation links. Title attribute from page.
185
- # :reverse => false Reverse the navigation
186
- # :reverse_children => false Reverse the nested children
189
+ # :submenu => false # Do you want a nested <ul> <li> structure for the deeper levels of your navigation, or not? Used to display the subnavigation within the mainnaviagtion. E.g. for dropdown menues.
190
+ # :all_sub_menues => false # Renders the whole page tree.
191
+ # :from_page => @root_page # Do you want to render a navigation from a different page then the current page? Then pass an Page instance or a Alchemy::PageLayout name as string.
192
+ # :spacer => "" # Yeah even a spacer for the entries can be passed. Simple string, or even a complex html structure. E.g: "<span class='spacer'>|</spacer>". Only your imagination is the limit. And the W3C of course :)
193
+ # :navigation_partial => "navigation/renderer" # Pass a different partial to be taken for the navigation rendering. CAUTION: Only for the advanced Alchemy webdevelopers. The standard partial takes care of nearly everything. But maybe you are an adventures one ^_^
194
+ # :navigation_link_partial => "navigation/link" # Alchemy places an <a> html link in <li> tags. The tag automatically has an active css class if necessary. So styling is everything. But maybe you don't want this. So feel free to make you own partial and pass the filename here.
195
+ # :show_nonactive => false # Commonly Alchemy only displays the submenu of the active page (if :submenu => true). If you want to display all child pages then pass true (together with :submenu => true of course). E.g. for the popular css-driven dropdownmenues these days.
196
+ # :show_title => true # For our beloved SEOs :). Appends a title attribute to all links and places the page.title content into it.
197
+ # :restricted_only => nil # Render only restricted pages.
198
+ # :show_title => true # Show a title on navigation links. Title attribute from page.
199
+ # :reverse => false # Reverse the navigation
200
+ # :reverse_children => false # Reverse the nested children
187
201
  #
188
202
  def render_navigation(options = {})
189
203
  default_options = {
@@ -224,20 +238,28 @@ module Alchemy
224
238
  render :partial => options[:navigation_partial], :locals => {:options => options, :pages => pages}
225
239
  end
226
240
 
227
- # Renders the children of the given page (standard is the current page), the given page and its siblings if there are no children, or it renders just nil.
228
- # Use this helper if you want to render the subnavigation independent from the mainnavigation. E.g. to place it in a different layer on your website.
229
- # If :from_page's level in the site-hierarchy is greater than :level (standard is 2) and the given page has no children, the returned output will be the :from_page and it's siblings
230
- # This method will assign all its options to the the render_navigation method, so you are able to assign the same options as to the render_navigation method.
231
- # Normally there is no need to change the level parameter, just in a few special cases.
241
+ # Renders navigation the children and all siblings of the given page (standard is the current page).
242
+ #
243
+ # 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.
244
+ #
245
+ # This helper passes all its options to the the render_navigation helper.
246
+ #
247
+ # === Options:
248
+ #
249
+ # :from_page => @page # The page to render the navigation from
250
+ # :submenu => true # Shows the nested children
251
+ # :level => 2 # Normally there is no need to change the level parameter, just in a few special cases
252
+ #
232
253
  def render_subnavigation(options = {})
233
254
  default_options = {
234
255
  :from_page => @page,
256
+ :submenu => true,
235
257
  :level => 2
236
258
  }
237
259
  options = default_options.merge(options)
238
260
  if !options[:from_page].nil?
239
- if (options[:from_page].children.blank? && options[:from_page].level > options[:level])
240
- options = options.merge(:from_page => Page.find(options[:from_page].parent_id))
261
+ while options[:from_page].level > options[:level] do
262
+ options[:from_page] = options[:from_page].parent
241
263
  end
242
264
  render_navigation(options)
243
265
  else
@@ -245,23 +267,23 @@ module Alchemy
245
267
  end
246
268
  end
247
269
 
248
- # returns true if page is in the active branch
270
+ # Returns true if page is in the active branch
249
271
  def page_active?(page)
250
272
  @breadcrumb ||= breadcrumb(@page)
251
273
  @breadcrumb.include?(page)
252
274
  end
253
275
 
254
- # Returns a HTML string for a linked breadcrumb from root to current page.
276
+ # Returns page links in a breadcrumb beginning from root to current page.
255
277
  #
256
- # == Options:
278
+ # === Options:
257
279
  #
258
- # :seperator => %(<span class="seperator">></span>) Maybe you don't want this seperator. Pass another one.
259
- # :page => @page Pass a different Page instead of the default (@page).
260
- # :without => nil Pass Pageobject or array of Pages that must not be displayed.
261
- # :public_only => false Pass boolean for displaying published pages only.
262
- # :visible_only => true Pass boolean for displaying (in navigation) visible pages only.
263
- # :restricted_only => false Pass boolean for displaying restricted pages only.
264
- # :reverse => false Pass boolean for displaying reversed breadcrumb.
280
+ # :seperator => %(<span class="seperator">></span>) # Maybe you don't want this seperator. Pass another one.
281
+ # :page => @page # Pass a different Page instead of the default (@page).
282
+ # :without => nil # Pass Pageobject or array of Pages that must not be displayed.
283
+ # :public_only => false # Pass boolean for displaying published pages only.
284
+ # :visible_only => true # Pass boolean for displaying (in navigation) visible pages only.
285
+ # :restricted_only => false # Pass boolean for displaying restricted pages only.
286
+ # :reverse => false # Pass boolean for displaying reversed breadcrumb.
265
287
  #
266
288
  def render_breadcrumb(options={})
267
289
  default_options = {
@@ -310,34 +332,31 @@ module Alchemy
310
332
  bc.join(options[:seperator]).html_safe
311
333
  end
312
334
 
313
- # Returns @page.title
335
+ # Returns current page title
314
336
  #
315
- # The options are:
337
+ # === Options:
316
338
  #
317
- # :prefix => ""
318
- # :seperator => "|"
339
+ # :prefix => "" # Prefix
340
+ # :seperator => "" # Seperating prefix and title
319
341
  #
320
- # == Webdevelopers:
342
+ # === Webdevelopers
321
343
  #
322
- # Please use the render_meta_data() helper. There all important meta information gets rendered in one helper.
344
+ # Please use the render_meta_data() helper instead. There all important meta information gets rendered in one helper.
323
345
  # So you dont have to worry about anything.
324
346
  #
325
347
  def render_page_title(options={})
348
+ return "" if @page.title.blank?
326
349
  default_options = {
327
350
  :prefix => "",
328
- :seperator => "|"
351
+ :seperator => ""
329
352
  }
330
353
  default_options.update(options)
331
- unless @page.title.blank?
332
- h("#{default_options[:prefix]} #{default_options[:seperator]} #{@page.title}")
333
- else
334
- h("")
335
- end
354
+ [default_options[:prefix], @page.title].join(default_options[:seperator])
336
355
  end
337
356
 
338
357
  # Returns a complete html <title> tag for the <head> part of the html document.
339
358
  #
340
- # == Webdevelopers:
359
+ # === Webdevelopers:
341
360
  #
342
361
  # Please use the render_meta_data() helper. There all important meta information gets rendered in one helper.
343
362
  # So you dont have to worry about anything.
@@ -354,7 +373,7 @@ module Alchemy
354
373
 
355
374
  # Renders a html <meta> tag for :name => "" and :content => ""
356
375
  #
357
- # == Webdevelopers:
376
+ # === Webdevelopers:
358
377
  #
359
378
  # Please use the render_meta_data() helper. There all important meta information gets rendered in one helper.
360
379
  # So you dont have to worry about anything.
@@ -370,7 +389,7 @@ module Alchemy
370
389
  %(<meta name="#{options[:name]}" content="#{options[:content]}" lang="#{lang}">).html_safe
371
390
  end
372
391
 
373
- # = This helper takes care of all important meta tags for your @page.
392
+ # This helper takes care of all important meta tags for your page.
374
393
  #
375
394
  # 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.
376
395
  #
@@ -489,7 +508,7 @@ module Alchemy
489
508
  if options[:html5]
490
509
  search_field_tag(:query, params[:query])
491
510
  else
492
- text_field_tag(:query, params[:query]) + submit_tag(:search)
511
+ text_field_tag(:query, params[:query]) + submit_tag(t("search"))
493
512
  end
494
513
  end
495
514
  end
@@ -560,7 +579,7 @@ module Alchemy
560
579
  }
561
580
  </script>
562
581
  STR
563
- content_for(:layout) { menu_bar_string.html_safe }
582
+ menu_bar_string.html_safe
564
583
  else
565
584
  nil
566
585
  end