alchemy_cms 2.5.0.b2 → 2.5.0.b5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -266,35 +266,63 @@ div#filter_bar {
266
266
  }
267
267
 
268
268
  div#tag_list {
269
+ height: 90%;
270
+
271
+ .js_filter_field_box {
272
+
273
+ input { width: 200px }
274
+ label { display: none }
275
+ }
269
276
 
270
277
  ul {
271
278
  list-style-type: none;
272
279
  padding: 0;
273
280
  margin: $default-margin 0 3*$default-margin 0;
281
+ height: inherit;
282
+ width: 204px;
283
+ overflow-x: hidden;
284
+ overflow-y: auto;
274
285
 
275
286
  li {
276
- @include inline-block;
277
- padding: $default-padding 2*$default-padding;
278
- margin: 0 $default-margin 2*$default-margin 0;
287
+ display: block;
288
+ padding: $default-padding 4*$default-padding $default-padding 6*$default-padding ;
289
+ margin: 2*$default-margin 0;
279
290
  background-color: $medium-gray;
280
291
  @include border-radius(16px);
281
292
  white-space: nowrap;
293
+ overflow: hidden;
294
+ position: relative;
295
+
296
+ &:before {
297
+ content: '';
298
+ position: absolute;
299
+ left: 8px;
300
+ top: 7px;
301
+ background: url("ui-icons_666666_256x240.png") -242px -100px;
302
+ width: 12px;
303
+ height: 12px;
304
+ }
282
305
 
283
306
  a {
284
307
  text-decoration: none;
308
+ display: block;
285
309
  }
286
310
 
311
+ &:hover { background-color: $very-light-blue }
312
+
287
313
  &.active {
288
314
  background-color: $dark-gray;
289
315
 
290
- a {
291
- color: $light-gray;
292
- }
316
+ a { color: $light-gray }
293
317
  }
294
318
  }
295
319
  }
296
320
  }
297
321
 
322
+ div#alchemy_window_body div#tag_list ul {
323
+ height: 364px;
324
+ }
325
+
298
326
  div#pictures_page_list {
299
327
 
300
328
  h2 { margin: 0 8px }
@@ -19,9 +19,25 @@ img.add_element_spinner {
19
19
  bottom: 6px;
20
20
  }
21
21
 
22
- #element_area h2#no_elements_on_page_notice {
23
- padding: 2*$default-padding;
24
- text-align: center;
22
+ div#element_area {
23
+ padding: 0;
24
+ margin: 0;
25
+ min-height: 90%;
26
+
27
+ .sortable_cell {
28
+ min-height: 100px;
29
+ padding: 8px 8px 2px;
30
+ }
31
+
32
+ textarea {
33
+ width: 100%;
34
+ height: 140px;
35
+ }
36
+
37
+ h2#no_elements_on_page_notice {
38
+ padding: 2*$default-padding;
39
+ text-align: center;
40
+ }
25
41
  }
26
42
 
27
43
  .element_handle {
@@ -294,21 +310,10 @@ div.picture_thumbnail div.picture_image {
294
310
  }
295
311
  }
296
312
 
297
- div#element_area {
298
- padding: 0;
299
- margin: 0;
300
- min-height: 90%;
301
- }
302
-
303
313
  div#cells {
304
314
  min-height: 100px;
305
315
  }
306
316
 
307
- div#element_area .sortable_cell {
308
- min-height: 100px;
309
- padding: 8px 8px 2px;
310
- }
311
-
312
317
  .place_element_spinner {
313
318
  position: absolute;
314
319
  right: 8px;
@@ -776,15 +781,14 @@ div.pictures_for_element {
776
781
  margin-top: 4px;
777
782
  }
778
783
 
779
- #element_area textarea {
780
- width: 97%;
781
- height: 140px;
782
- }
783
-
784
784
  textarea.default_tinymce, textarea.custom_tinymce {
785
785
  visibility: hidden;
786
786
  }
787
787
 
788
+ .essence_html_editor textarea {
789
+ font-family: $mono-font-face;
790
+ }
791
+
788
792
  .text_short_float_left {
789
793
  width: 170px;
790
794
  float: left;
@@ -808,7 +812,7 @@ textarea.default_tinymce, textarea.custom_tinymce {
808
812
  }
809
813
  }
810
814
 
811
- a.element_hint {
815
+ a.hint {
812
816
  position: absolute;
813
817
  right: 32px;
814
818
  top: 8px;
@@ -829,6 +833,7 @@ a.element_hint {
829
833
  padding: 8px;
830
834
  line-height: 1.5em;
831
835
  min-width: 180px;
836
+ font-size: 12px;
832
837
 
833
838
  &:before {
834
839
  content: '';
@@ -843,3 +848,24 @@ a.element_hint {
843
848
  }
844
849
  }
845
850
  }
851
+
852
+ .content_editor .hint {
853
+ position: relative;
854
+ top: auto;
855
+ right: auto;
856
+ display: inline-block;
857
+ margin-right: 4px;
858
+ margin-top: -2px;
859
+ margin-left: -1px;
860
+
861
+ .bubble {
862
+ right: auto;
863
+ left: -4px;
864
+ top: 24px;
865
+
866
+ &:before {
867
+ right: auto;
868
+ left: 5px;
869
+ }
870
+ }
871
+ }
@@ -329,3 +329,7 @@ h2#sitemap_heading {
329
329
  margin-left: 24px;
330
330
  }
331
331
  }
332
+
333
+ select#language_tree_select {
334
+ margin: 0;
335
+ }
@@ -11,6 +11,7 @@ $default-padding: 4px;
11
11
  $default-margin: $default-padding;
12
12
 
13
13
  $default-font-face: "Lucida Grande", "Lucida Sans Unicode", "Lucida Sans", Verdana, Tahoma, sans-serif;
14
+ $mono-font-face: Menlo, Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace;
14
15
  $default-font-size: 12px;
15
16
  $default-font-style: $default-font-size $default-font-face;
16
17
 
@@ -219,7 +219,7 @@ module Alchemy
219
219
  end
220
220
 
221
221
  def switch_language
222
- set_language_from(params[:language_id])
222
+ set_language(params[:language_id])
223
223
  redirect_path = request.referer.include?('admin/layoutpages') ? admin_layoutpages_path : admin_pages_path
224
224
  if request.xhr?
225
225
  @redirect_url = redirect_path
@@ -133,7 +133,8 @@ module Alchemy
133
133
  end
134
134
 
135
135
  def flush
136
- FileUtils.rm_rf Rails.root.join('public', Alchemy.mount_point, 'pictures')
136
+ # FileUtils.rm_rf only takes arrays of folders...
137
+ FileUtils.rm_rf Dir.glob(Rails.root.join('public', Alchemy.mount_point, 'pictures', '*'))
137
138
  @notice = t('Picture cache flushed')
138
139
  end
139
140
 
@@ -10,7 +10,7 @@ module Alchemy
10
10
  before_filter :set_language
11
11
  before_filter :mailer_set_url_options
12
12
 
13
- helper_method :current_server, :t
13
+ helper_method :current_server, :current_site, :t
14
14
 
15
15
  # Returns a host string with the domain the app is running on.
16
16
  def current_server
@@ -46,9 +46,17 @@ module Alchemy
46
46
 
47
47
  private
48
48
 
49
- # Sets the current site.
49
+ # Returns the current site.
50
+ #
51
+ def current_site
52
+ @current_site ||= Site.find_for_host(request.host)
53
+ end
54
+
55
+ # Sets the current site in a cvar so the Language model
56
+ # can be scoped against it.
57
+ #
50
58
  def set_current_site
51
- Site.current = Site.where(host: request.host).first || Site.default
59
+ Site.current = current_site
52
60
  end
53
61
 
54
62
  # Sets Alchemy's GUI translation to users preffered language and stores it in the session.
@@ -73,44 +81,49 @@ module Alchemy
73
81
  end
74
82
  end
75
83
 
76
- # Sets the language for rendering pages in pages controller
77
- def set_language
78
- if params[:lang].blank? and session[:language_id].blank?
79
- set_language_to_default
80
- elsif !params[:lang].blank?
81
- ::I18n.locale = set_language_from(params[:lang])
84
+ # Sets the language for rendering pages in pages controller.
85
+ #
86
+ def set_language(lang = nil)
87
+ if lang
88
+ @language = lang.is_a?(Language) ? lang : load_language_from(lang)
89
+ else
90
+ # find the best language and remember it for later
91
+ @language = load_language_from_params ||
92
+ load_language_from_session ||
93
+ load_language_default
82
94
  end
95
+
96
+ # store language in session
97
+ store_language_in_session(@language)
98
+
99
+ # switch locale to selected language
100
+ ::I18n.locale = @language.code
83
101
  end
84
102
 
85
- def set_language_from(language_code_or_id)
86
- if language_code_or_id.is_a?(String) && language_code_or_id.match(/^\d+$/)
87
- language_code_or_id = language_code_or_id.to_i
103
+ def load_language_from_params
104
+ if params[:lang].present?
105
+ Language.find_by_code(params[:lang])
88
106
  end
89
- case language_code_or_id.class.name
90
- when "String"
91
- @language = Language.find_by_code(language_code_or_id)
92
- when "Fixnum"
93
- @language = Language.find(language_code_or_id)
94
- end
95
- store_language_in_session(@language)
96
107
  end
97
108
 
98
- def set_language_to_default
99
- @language = Language.get_default
100
- if @language
101
- store_language_in_session(@language)
102
- else
103
- raise "No Default Language found! Did you run `rake alchemy:db:seed` task?"
109
+ def load_language_from_session
110
+ if session[:language_id].present?
111
+ Language.find_by_id(session[:language_id])
104
112
  end
105
113
  end
106
114
 
115
+ def load_language_from(language_code_or_id)
116
+ Language.find_by_id(language_code_or_id) || Language.find_by_code(language_code_or_id)
117
+ end
118
+
119
+ def load_language_default
120
+ Language.get_default
121
+ end
122
+
107
123
  def store_language_in_session(language)
108
124
  if language && language.id
109
- session[:language_id] = language.id
125
+ session[:language_id] = language.id
110
126
  session[:language_code] = language.code
111
- else
112
- logger.warn "!!!! Language not found for #{language.inspect}. Setting to default!"
113
- set_language_to_default
114
127
  end
115
128
  end
116
129
 
@@ -10,6 +10,7 @@ module Alchemy
10
10
 
11
11
  rescue_from ActionController::RoutingError, :with => :render_404
12
12
 
13
+ before_filter :enforce_primary_host_for_site
13
14
  before_filter :render_page_or_redirect, :only => [:show, :sitemap]
14
15
  before_filter :perform_search, :only => :show, :if => proc { configuration(:ferret) }
15
16
 
@@ -58,26 +59,37 @@ module Alchemy
58
59
 
59
60
  private
60
61
 
62
+ # Load the current page and store it in @page.
63
+ #
61
64
  def load_page
62
- # we need this, because of a dec_auth bug (it calls this method after the before_filter again).
63
- return @page if @page
64
- if params[:urlname].blank?
65
- @page = Page.language_root_for(Language.get_default.id)
65
+ @page ||= if params[:urlname].present?
66
+ # Load by urlname. If a language is specified in the request parameters,
67
+ # scope pages to it to make sure we can raise a 404 if the urlname
68
+ # is not available in that language.
69
+ Page.contentpages.where(
70
+ urlname: params[:urlname],
71
+ language_id: @language.id,
72
+ language_code: params[:lang] || @language.code
73
+ ).first
66
74
  else
67
- if params[:lang].blank?
68
- @page = Page.contentpages.where(urlname: params[:urlname], language_id: Language.get_default).first
69
- store_language_in_session(@page.language) if @page.present?
70
- return @page
71
- else
72
- @page = Page.contentpages.where(
73
- :urlname => params[:urlname],
74
- :language_id => session[:language_id], # Make sure that the current language
75
- :language_code => params[:lang] # matches the requested language code.
76
- ).first
77
- end
75
+ # No urlname was given, so just load the language root for the
76
+ # currently active language.
77
+ Page.language_root_for(@language.id)
78
78
  end
79
79
  end
80
80
 
81
+ def enforce_primary_host_for_site
82
+ if needs_redirect_to_primary_host?
83
+ redirect_to url_for(host: current_site.host)
84
+ end
85
+ end
86
+
87
+ def needs_redirect_to_primary_host?
88
+ current_site.redirect_to_primary_host? &&
89
+ current_site.host != '*' &&
90
+ current_site.host != request.host
91
+ end
92
+
81
93
  def render_page_or_redirect
82
94
  @page ||= load_page
83
95
  if User.admins.count == 0 && @page.nil?
@@ -104,7 +116,7 @@ module Alchemy
104
116
  redirect_to main_app.url_for(@page.controller_and_action)
105
117
  else
106
118
  # setting the language to page.language to be sure it's correct
107
- set_language_from(@page.language_id)
119
+ set_language(@page.language)
108
120
  if params[:urlname].blank?
109
121
  @root_page = @page
110
122
  else
@@ -90,17 +90,17 @@ module Alchemy
90
90
  :id => "search_field"
91
91
  }
92
92
  options = default_options.merge(options)
93
- options[:onkeyup] << ";jQuery('#search_field').val().length >= 1 ? jQuery('.js_filter_field_clear').show() : jQuery('.js_filter_field_clear').hide();"
93
+ options[:onkeyup] << "; jQuery('##{options[:id]}').val().length >= 1 ? jQuery('.js_filter_field_clear').show() : jQuery('.js_filter_field_clear').hide();"
94
94
  filter_field = '<div class="js_filter_field_box">'
95
95
  filter_field << text_field_tag("filter", '', options)
96
96
  filter_field << content_tag('span', '', :class => 'icon search')
97
97
  filter_field << link_to('', '#', {
98
- :onclick => "jQuery('##{options[:id]}').val('');#{options[:onkeyup]}",
98
+ :onclick => "jQuery('##{options[:id]}').val(''); #{options[:onkeyup]}",
99
99
  :class => "js_filter_field_clear",
100
- :style => "display:none",
100
+ :style => "display: none",
101
101
  :title => t("click_to_show_all")
102
102
  })
103
- filter_field << %(<label for="search_field">#{t(:search)}</label>)
103
+ filter_field << %(<label for="#{options[:id]}">#{t(:search)}</label>)
104
104
  filter_field << '</div>'
105
105
  filter_field.html_safe
106
106
  end
@@ -541,8 +541,8 @@ module Alchemy
541
541
 
542
542
  def render_hint_for(element)
543
543
  return unless element.has_hint?
544
- link_to '#', :class => 'element_hint' do
545
- render_icon(:hint) + content_tag(:span, element.hint, :class => 'bubble')
544
+ link_to '#', :class => 'hint' do
545
+ render_icon(:hint) + content_tag(:span, element.hint.html_safe, :class => 'bubble')
546
546
  end
547
547
  end
548
548
 
@@ -108,7 +108,7 @@ module Alchemy
108
108
  # Renders the label and a remove link for a content.
109
109
  def label_and_remove_link(content)
110
110
  content_tag :label do
111
- [render_content_name(content).to_s, delete_content_link(content).to_s].join('&nbsp;').html_safe
111
+ [render_hint_for(content), render_content_name(content), delete_content_link(content)].compact.join('&nbsp;').html_safe
112
112
  end
113
113
  end
114
114
 
@@ -44,7 +44,7 @@ module Alchemy
44
44
  return ""
45
45
  end
46
46
  content = element.content_by_name(name)
47
- render_essence(content, :view, {:for_view => options}, html_options)
47
+ render_essence_view(content, options, html_options)
48
48
  end
49
49
 
50
50
  # Renders the +Essence+ view partial from given +Element+ and +Essence+ type.
@@ -130,12 +130,11 @@ module Alchemy
130
130
  #
131
131
  # :image_size => "111x93" # Used by EssencePicture to render the image via RMagick to that size. [Default nil]
132
132
  # :date_format => "Am %d. %m. %Y, um %H:%Mh" # Especially for EssenceDate. See Rubys Date.strftime for date formatting options. [Default nil]
133
- # :show_caption => true # Pass Boolean to show/hide the caption of an EssencePicture. [Default true]
133
+ # :show_caption => false # Pass Boolean to show/hide the caption of an EssencePicture. [Default true]
134
+ # :disable_link => true # You can surpress the link of an EssencePicture. Default false
134
135
  #
135
136
  def render_essence_view(content, options = {}, html_options = {})
136
- defaults = {
137
- :show_caption => true
138
- }
137
+ defaults = {:show_caption => true, :disable_link => false}
139
138
  render_essence(content, :view, {:for_view => defaults.update(options)}, html_options)
140
139
  end
141
140
 
@@ -151,6 +151,7 @@ module Alchemy
151
151
  end
152
152
  end
153
153
  end
154
+ alias_method :definition, :description
154
155
 
155
156
  # Gets the ingredient from essence
156
157
  def ingredient
@@ -265,5 +266,51 @@ module Alchemy
265
266
  end
266
267
  end
267
268
 
269
+ # Returns the hint for this content
270
+ #
271
+ # To add a hint to a content pass +hint: true+ to the element definition in its element.yml
272
+ #
273
+ # Then the hint itself is placed in the locale yml files.
274
+ #
275
+ # Alternativly you can pass the hint itself to the hint key.
276
+ #
277
+ # == Locale Example:
278
+ #
279
+ # # elements.yml
280
+ # - name: headline
281
+ # contents:
282
+ # - name: headline
283
+ # type: EssenceText
284
+ # hint: true
285
+ #
286
+ # # config/locales/de.yml
287
+ # de:
288
+ # content_hints:
289
+ # headline: Lorem ipsum
290
+ #
291
+ # == Hint Key Example:
292
+ #
293
+ # - name: headline
294
+ # contents:
295
+ # - name: headline
296
+ # type: EssenceText
297
+ # hint: Lorem ipsum
298
+ #
299
+ # @return String
300
+ #
301
+ def hint
302
+ hint = definition['hint']
303
+ if hint == true
304
+ I18n.t(name, scope: :content_hints)
305
+ else
306
+ hint
307
+ end
308
+ end
309
+
310
+ # Returns true if the element has a hint
311
+ def has_hint?
312
+ hint.present?
313
+ end
314
+
268
315
  end
269
316
  end
@@ -561,7 +561,12 @@ module Alchemy
561
561
  end
562
562
 
563
563
  def cache_key(request = nil)
564
- "alchemy/#{language_code}/#{urlname}"
564
+ if timestamp = updated_at
565
+ timestamp = timestamp.utc.to_s(:number)
566
+ "alchemy/pages/#{id}-#{timestamp}"
567
+ else
568
+ "alchemy/pages/#{id}"
569
+ end
565
570
  end
566
571
 
567
572
  def taggable?
@@ -1,8 +1,6 @@
1
1
  module Alchemy
2
2
  class Site < ActiveRecord::Base
3
- cattr_accessor :current
4
-
5
- attr_accessible :host, :name, :public
3
+ attr_accessible :host, :aliases, :name, :public, :redirect_to_primary_host
6
4
 
7
5
  # validations
8
6
  validates_presence_of :host
@@ -19,9 +17,32 @@ module Alchemy
19
17
  end
20
18
 
21
19
  class << self
20
+ def current=(v)
21
+ Thread.current[:alchemy_current_site] = v
22
+ end
23
+
24
+ def current
25
+ Thread.current[:alchemy_current_site]
26
+ end
27
+
22
28
  def default
23
29
  Site.first
24
30
  end
31
+
32
+ def find_for_host(host)
33
+ # These are split up into two separate queries in order to run the
34
+ # fastest query first (selecting the domain by its primary host name).
35
+ #
36
+ where(host: host).first || find_in_aliases(host) || default
37
+ end
38
+
39
+ def find_in_aliases(host)
40
+ return nil if host.blank?
41
+
42
+ all.find do |site|
43
+ site.aliases.split.include?(host) if site.aliases.present?
44
+ end
45
+ end
25
46
  end
26
47
 
27
48
  before_create do
@@ -1,9 +1,10 @@
1
1
  <% p = params.dup %>
2
2
  <h2><%= t("Filter by tag") %></h2>
3
+ <%#= js_filter_field :onkeyup => "Alchemy.ListFilter('#tag_list li')", :id => 'tag_list_filter' %>
3
4
  <ul>
4
5
  <% Alchemy::Picture.tag_counts.each do |t| %>
5
6
  <% picture_tags = pictures_filtered_by_tag?(t) ? picture_tag_filter(:remove => t) : picture_tag_filter(:add => t) %>
6
- <%= content_tag 'li', :class => p[:tagged_with].try(:split, ',').try(:include?, t.name) ? 'active' : nil do %>
7
+ <%= content_tag 'li', :name => t.name, :class => p[:tagged_with].try(:split, ',').try(:include?, t.name) ? 'active' : nil do %>
7
8
  <%= link_to(
8
9
  "#{t.name} (#{t.count})",
9
10
  url_for(
@@ -17,7 +17,7 @@
17
17
  </td>
18
18
  <%- elsif attribute[:type] == :text -%>
19
19
  <td class="label"><%= f.send :label, attribute[:name] %></td>
20
- <td class="input"><%= f.send :text_area, attribute[:name] -%></td>
20
+ <td class="input"><%= f.send :text_area, attribute[:name], :rows => 4 -%></td>
21
21
  <%- elsif attribute[:type] == :datetime -%>
22
22
  <td class="label"><%= f.send :label, attribute[:name] %></td>
23
23
  <td class="input"><%= f.send :text_field, attribute[:name], :type => :date -%></td>
@@ -1,8 +1,8 @@
1
- <div class="content_editor content_text_editor"<%= " style=\"float: left;\"" if options[:css_class] == "text_short" %>>
1
+ <div class="content_editor essence_html_editor"<%= " style=\"float: left;\"" if options[:css_class] == "text_short" %>>
2
2
  <%= label_and_remove_link(content) %>
3
- <%= text_field_tag(
3
+ <%= text_area_tag(
4
4
  content.form_field_name,
5
5
  content.ingredient,
6
- :class => 'thin_border text_long'
6
+ :class => 'thin_border'
7
7
  ) %>
8
- </div>
8
+ </div>
@@ -1,6 +1,11 @@
1
1
  <div id="<%= content_dom_id(content) %>" class="essence_picture_editor<%= ' dragable_picture' if options[:dragable] %><%= ' content_editor' unless options[:grouped] %>">
2
2
  <% unless options[:grouped] %>
3
- <label><%= render_content_name(content) %></label>
3
+ <label>
4
+ <% if content.has_hint? %>
5
+ <%= render_hint_for(content) %>
6
+ <% end %>
7
+ <%= render_content_name(content) %>
8
+ </label>
4
9
  <% end %>
5
10
  <div class="picture_thumbnail">
6
11
  <span class="picture_tool delete">
@@ -1,42 +1,39 @@
1
1
  <% if content.essence.picture.present? %>
2
2
 
3
- <% img_tag = image_tag(
4
- show_alchemy_picture_url(content.essence.picture,
5
- options.merge(
6
- :size => options.delete(:image_size),
7
- :crop_from => options[:crop] && !content.essence.crop_from.blank? ? content.essence.crop_from : nil,
8
- :crop_size => options[:crop] && !content.essence.crop_size.blank? ? content.essence.crop_size : nil
9
- ).delete_if { |k,v| v.blank? || k.to_sym == :show_caption || k.to_sym == :disable_link }
10
- ),
11
- {
12
- :alt => (content.essence.alt_tag.blank? ? nil : content.essence.alt_tag),
13
- :title => (content.essence.title.blank? ? nil : content.essence.title),
14
- :class => (content.essence.css_class.blank? ? nil : content.essence.css_class)
15
- }.merge(html_options)
16
- ) %>
17
-
18
- <% caption = content_tag("div", content.essence.caption, :id => "#{dom_id(content.essence.picture)}_caption", :class => "image_caption") %>
3
+ <% img_tag = image_tag(
4
+ show_alchemy_picture_url(content.essence.picture,
5
+ options.merge(
6
+ :size => options.delete(:image_size),
7
+ :crop_from => options[:crop] && !content.essence.crop_from.blank? ? content.essence.crop_from : nil,
8
+ :crop_size => options[:crop] && !content.essence.crop_size.blank? ? content.essence.crop_size : nil
9
+ ).delete_if { |k,v| v.blank? || k.to_sym == :show_caption || k.to_sym == :disable_link }
10
+ ),
11
+ {
12
+ :alt => (content.essence.alt_tag.blank? ? nil : content.essence.alt_tag),
13
+ :title => (content.essence.title.blank? ? nil : content.essence.title),
14
+ :class => (content.essence.css_class.blank? ? nil : content.essence.css_class)
15
+ }.merge(html_options)
16
+ ) %>
17
+
18
+ <% if content.essence.caption.present? && options[:show_caption] %>
19
+ <% caption = content_tag(:figcaption, content.essence.caption, :id => "#{dom_id(content.essence.picture)}_caption", :class => "image_caption") %>
20
+ <figure>
21
+ <% end %>
19
22
 
20
23
  <% if content.essence.link.blank? || options[:disable_link] %>
21
24
 
22
- <%= img_tag %>
23
-
24
- <% if options[:show_caption] && content.essence.caption.present? %>
25
-
26
- <%= caption %>
27
-
28
- <% end %>
25
+ <%= caption ? img_tag + caption : img_tag %>
29
26
 
30
27
  <% else %>
31
28
 
32
- <%= link_to(
33
- content.essence.caption.blank? || options[:show_caption] == false ? img_tag : img_tag + caption,
34
- url_for(content.essence.link),
29
+ <%= link_to(url_for(content.essence.link), {
35
30
  :title => content.essence.link_title,
36
31
  :target => (content.essence.link_target == "blank" ? "_blank" : nil),
37
32
  'data-link-target' => content.essence.link_target
38
- ) %>
33
+ }) do %>
34
+ <%= caption ? img_tag + caption : img_tag %>
35
+ <% end %>
39
36
 
40
37
  <% end %>
41
-
38
+ <% if caption %></figure><% end %>
42
39
  <% end %>
@@ -562,7 +562,7 @@ de:
562
562
  cancel_uploads: "Hochladen abbrechen"
563
563
  tag_list: Tags
564
564
  tags_get_created_if_used_the_first_time: 'Ein Tag wird automatisch erstellt, sobald Sie es das erste mal verwenden.'
565
- this_picture_is_not_used_on_any_page: "Dieses Bild wird auf keiner Seiten benutzt."
565
+ this_picture_is_not_used_on_any_page: "Dieses Bild wird auf keiner Seite benutzt."
566
566
  this_picture_is_used_on_these_pages: "Dieses Bild wird auf folgenden Seiten benutzt"
567
567
  title: "Titel"
568
568
  "trash element": "Element in den Papierkorb legen"
@@ -930,8 +930,10 @@ de:
930
930
 
931
931
  alchemy/site:
932
932
  name: "Bezeichnung"
933
- host: "Host/Domain"
933
+ host: "primäre Domain"
934
934
  public: "veröffentlicht"
935
+ aliases: "Domain-Aliases"
936
+ redirect_to_primary_host: "Auf primäre Domain weiterleiten"
935
937
 
936
938
  errors:
937
939
  <<: *errors
@@ -652,7 +652,7 @@ en:
652
652
  role: "Userrole"
653
653
 
654
654
  alchemy/site:
655
- host: Host/Domain
655
+ host: primary Host
656
656
 
657
657
  errors:
658
658
  <<: *errors
@@ -0,0 +1,6 @@
1
+ class AddAliasesToSite < ActiveRecord::Migration
2
+ def change
3
+ add_column :alchemy_sites, :aliases, :text
4
+ add_column :alchemy_sites, :redirect_to_primary_host, :boolean
5
+ end
6
+ end
@@ -1,6 +1,6 @@
1
1
  module Alchemy
2
2
 
3
- VERSION = "2.5.0.b2"
3
+ VERSION = "2.5.0.b5"
4
4
 
5
5
  def self.version
6
6
  VERSION
@@ -1,64 +1,84 @@
1
1
  require 'spec_helper'
2
2
 
3
+ # Here's a tiny custom matcher making it a bit easier to check the
4
+ # current session for a language configuration.
5
+ #
6
+ RSpec::Matchers.define :include_language_information_for do |expected|
7
+ match do |actual|
8
+ actual[:language_id] == expected.id && actual[:language_code] == expected.code
9
+ end
10
+ end
11
+
3
12
  module Alchemy
4
13
  describe BaseController do
5
14
 
6
15
  let(:default_language) { Language.get_default }
7
16
  let(:klingonian) { FactoryGirl.create(:klingonian) }
8
17
 
9
- describe "#set_language_from" do
18
+ describe "#set_language" do
10
19
 
11
- it "should set the language from id" do
12
- controller.send :set_language_from, default_language.id
13
- controller.session[:language_id].should == default_language.id
20
+ context "with a Language argument" do
21
+ it "should set the language to the passed Language instance" do
22
+ controller.send :set_language, klingonian
23
+ assigns(:language).should == klingonian
24
+ end
14
25
  end
15
26
 
16
- it "should set the language from code" do
17
- controller.send :set_language_from, klingonian.code
18
- controller.session[:language_id].should == klingonian.id
19
- controller.session[:language_code].should == klingonian.code
27
+ context "with a language id argument" do
28
+ it "should set the language to the language specified by the passed id" do
29
+ controller.send :set_language, klingonian.id
30
+ assigns(:language).should == klingonian
31
+ end
20
32
  end
21
33
 
22
- it "should set the language from id as string" do
23
- controller.send :set_language_from, default_language.id.to_s
24
- controller.session[:language_id].should == default_language.id
25
- controller.session[:language_code].should == default_language.code
34
+ context "with a language code argument" do
35
+ it "should set the language to the language specified by the passed code" do
36
+ controller.send :set_language, klingonian.code
37
+ assigns(:language).should == klingonian
38
+ end
26
39
  end
27
40
 
28
- end
29
-
30
- describe "#set_language" do
31
-
32
41
  context "with no lang param" do
33
42
 
34
43
  it "should set the default language" do
35
44
  controller.stub!(:params).and_return({})
36
45
  controller.send :set_language
37
- controller.session[:language_id].should == default_language.id
38
- controller.session[:language_code].should == default_language.code
46
+ assigns(:language).should == default_language
47
+ controller.session.should include_language_information_for(default_language)
48
+ end
49
+
50
+ end
51
+
52
+ context "with language set in the session" do
53
+ before do
54
+ controller.stub!(:session).and_return(language_id: klingonian.id, language_code: klingonian.code)
39
55
  end
40
56
 
57
+ it "should use the language set in the session cookie" do
58
+ controller.send :set_language
59
+ assigns(:language).should == klingonian
60
+ end
41
61
  end
42
62
 
43
63
  context "with lang param" do
44
64
 
45
65
  it "should set the language" do
46
- controller.stub!(:params).and_return({:lang => klingonian.code})
66
+ controller.stub!(:params).and_return(:lang => klingonian.code)
47
67
  controller.send :set_language
48
- controller.session[:language_id].should == klingonian.id
49
- controller.session[:language_code].should == klingonian.code
68
+ assigns(:language).should == klingonian
69
+ controller.session.should include_language_information_for(klingonian)
50
70
  end
51
71
 
52
72
  context "for language that does not exist" do
53
73
 
54
74
  before do
55
- controller.stub!(:params).and_return({:lang => 'fo'})
75
+ controller.stub!(:params).and_return(:lang => 'fo')
56
76
  controller.send :set_language
57
77
  end
58
78
 
59
79
  it "should set the language to default" do
60
- controller.session[:language_id].should == default_language.id
61
- controller.session[:language_code].should == default_language.code
80
+ assigns(:language).should == default_language
81
+ controller.session.should include_language_information_for(default_language)
62
82
  end
63
83
 
64
84
  it "should set the rails locale to default language code" do
@@ -0,0 +1,6 @@
1
+ class AddAliasesToSite < ActiveRecord::Migration
2
+ def change
3
+ add_column :alchemy_sites, :aliases, :text
4
+ add_column :alchemy_sites, :redirect_to_primary_host, :boolean
5
+ end
6
+ end
@@ -11,7 +11,7 @@
11
11
  #
12
12
  # It's strongly recommended to check this file into your version control system.
13
13
 
14
- ActiveRecord::Schema.define(:version => 20121211163003) do
14
+ ActiveRecord::Schema.define(:version => 20121220102223) do
15
15
 
16
16
  create_table "alchemy_attachments", :force => true do |t|
17
17
  t.string "name"
@@ -246,9 +246,11 @@ ActiveRecord::Schema.define(:version => 20121211163003) do
246
246
  create_table "alchemy_sites", :force => true do |t|
247
247
  t.string "host"
248
248
  t.string "name"
249
- t.datetime "created_at", :null => false
250
- t.datetime "updated_at", :null => false
251
- t.boolean "public", :default => false
249
+ t.datetime "created_at", :null => false
250
+ t.datetime "updated_at", :null => false
251
+ t.boolean "public", :default => false
252
+ t.text "aliases"
253
+ t.boolean "redirect_to_primary_host"
252
254
  end
253
255
 
254
256
  add_index "alchemy_sites", ["host", "public"], :name => "alchemy_sites_public_hosts_idx"
@@ -8,7 +8,7 @@ module Alchemy
8
8
  describe 'new instances' do
9
9
  subject { FactoryGirl.build(:site) }
10
10
 
11
- it 'should start out with on languages' do
11
+ it 'should start out with no languages' do
12
12
  subject.languages.should be_empty
13
13
  end
14
14
 
@@ -35,6 +35,46 @@ module Alchemy
35
35
  end
36
36
  end
37
37
 
38
+ describe '.find_for_host' do
39
+ # No need to create a default site, as it has already been added through the seeds.
40
+ # But let's add some more:
41
+ #
42
+ let(:default_site) { Site.default }
43
+ let!(:magiclabs_site) { FactoryGirl.create(:site, host: 'www.magiclabs.de', aliases: 'magiclabs.de magiclabs.com www.magiclabs.com') }
44
+
45
+ subject { Site.find_for_host(host) }
46
+
47
+ context "when the request doesn't match anything" do
48
+ let(:host) { 'oogabooga.com' }
49
+ it { should == default_site }
50
+ end
51
+
52
+ context "when the request matches a site's host field" do
53
+ let(:host) { 'www.magiclabs.de' }
54
+ it { should == magiclabs_site }
55
+ end
56
+
57
+ context "when the request matches one of the site's aliases" do
58
+ let(:host) { 'magiclabs.com' }
59
+ it { should == magiclabs_site }
60
+ end
61
+
62
+ context "when the request matches the site's first alias" do
63
+ let(:host) { 'magiclabs.de' }
64
+ it { should == magiclabs_site }
65
+ end
66
+
67
+ context "when the request matches the site's last alias" do
68
+ let(:host) { 'www.magiclabs.com' }
69
+ it { should == magiclabs_site }
70
+ end
71
+
72
+ context "when the request host matches only part of a site's aliases" do
73
+ let(:host) { 'labs.com' }
74
+ it { should == default_site }
75
+ end
76
+ end
77
+
38
78
  describe '.current' do
39
79
  context 'when set to a site' do
40
80
  before { Site.current = site }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alchemy_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0.b2
4
+ version: 2.5.0.b5
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2012-12-14 00:00:00.000000000 Z
16
+ date: 2012-12-20 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rails
@@ -769,6 +769,7 @@ files:
769
769
  - db/migrate/20121121162313_switch_from_fleximage_to_dragonfly.rb
770
770
  - db/migrate/20121205155004_create_alchemy_sites.rb
771
771
  - db/migrate/20121211163003_add_public_to_alchemy_sites.rb
772
+ - db/migrate/20121220102223_add_aliases_to_site.rb
772
773
  - lib/alchemy/auth_engine.rb
773
774
  - lib/alchemy/authentication_helpers.rb
774
775
  - lib/alchemy/capistrano.rb
@@ -878,6 +879,7 @@ files:
878
879
  - spec/dummy/db/migrate/20121121162313_switch_from_fleximage_to_dragonfly.rb
879
880
  - spec/dummy/db/migrate/20121205155004_create_alchemy_sites.rb
880
881
  - spec/dummy/db/migrate/20121211163003_add_public_to_alchemy_sites.rb
882
+ - spec/dummy/db/migrate/20121220102223_add_aliases_to_site.rb
881
883
  - spec/dummy/db/schema.rb
882
884
  - spec/dummy/lib/assets/.gitkeep
883
885
  - spec/dummy/public/404.html
@@ -1132,6 +1134,7 @@ test_files:
1132
1134
  - spec/dummy/db/migrate/20121121162313_switch_from_fleximage_to_dragonfly.rb
1133
1135
  - spec/dummy/db/migrate/20121205155004_create_alchemy_sites.rb
1134
1136
  - spec/dummy/db/migrate/20121211163003_add_public_to_alchemy_sites.rb
1137
+ - spec/dummy/db/migrate/20121220102223_add_aliases_to_site.rb
1135
1138
  - spec/dummy/db/schema.rb
1136
1139
  - spec/dummy/lib/assets/.gitkeep
1137
1140
  - spec/dummy/public/404.html