dead_simple_cms 0.12.0 → 0.12.1

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.
@@ -10,6 +10,7 @@ require 'active_model'
10
10
 
11
11
  require 'dead_simple_cms/configuration'
12
12
 
13
+ require 'dead_simple_cms/util/string'
13
14
  require 'dead_simple_cms/util/identifier'
14
15
  require 'dead_simple_cms/file_uploader/base'
15
16
 
@@ -93,7 +94,7 @@ module DeadSimpleCMS
93
94
  # If you create your own, please provide the full class name.
94
95
  #
95
96
  # If you choose to use the database, make sure to create a database table to hold the data:
96
- #
97
+ #
97
98
  # create_table :dead_simple_cms, :force => true do |t|
98
99
  # t.string :key
99
100
  # t.text :value
@@ -119,11 +120,11 @@ module DeadSimpleCMS
119
120
  # def url
120
121
  # # This should retrieve the url to where the photo will be uploaded to.
121
122
  # end
122
- #
123
+ #
123
124
  # def upload!
124
125
  # AWS::S3::S3Object.store(path, data, "mybucket", :access => :public_read)
125
126
  # end
126
-
127
+
127
128
  # end
128
129
  #
129
130
  #
@@ -55,7 +55,7 @@ module DeadSimpleCMS
55
55
  section_or_group.groups.values.map do |group|
56
56
  next if group.attributes.empty? && group.groups.empty?
57
57
  fields_for(group.identifier, options) do |builder|
58
- @template.content_tag(:fieldset) do
58
+ @template.content_tag(:fieldset, :id => Util::String.csserize(group.identifier)) do
59
59
  # Following fieldset/legend convention: https://github.com/twitter/bootstrap/issues/1214
60
60
  legend = @template.content_tag(:legend, group.label) unless group.root? # don't show the group name if it's the root group.
61
61
  attributes = group.attributes.values.map { |attribute| builder.attribute(attribute) }.join.html_safe
@@ -33,12 +33,13 @@ module DeadSimpleCMS
33
33
  JAVASCRIPT
34
34
  js << javascript_include_tag(options.delete(:bootstrap_tab_js)) if options[:bootstrap_tab_js]
35
35
  lis = DeadSimpleCMS.sections.values.map do |section|
36
- content_tag(:li, link_to(section.label, "##{section.identifier.to_s.csserize}", :id => "#{section.identifier.to_s.csserize}-tab"))
36
+ section_id = Util::String.csserize(section.identifier)
37
+ content_tag(:li, link_to(section.label, "##{section_id}", :id => "#{section_id}-tab"))
37
38
  end.join.html_safe
38
39
  tabs = content_tag(:ul, lis, :class => "nav nav-tabs", :id => "section-tabs")
39
40
  sections = content_tag(:div, :class => "tab-content") do
40
41
  DeadSimpleCMS.sections.values.map do |section|
41
- content_tag(:div, section(section), :class => "tab-pane", :id => "#{section.identifier.to_s.csserize}")
42
+ content_tag(:div, section(section), :class => "tab-pane", :id => Util::String.csserize(section.identifier))
42
43
  end.join.html_safe
43
44
  end
44
45
 
@@ -51,7 +52,9 @@ module DeadSimpleCMS
51
52
 
52
53
  def form(section, options={})
53
54
  options.reverse_merge!(:builder => form_builder, :url => {:action => :edit})
54
- options.reverse_merge!(options[:builder].form_for_options)
55
+ # Options passed to simple_form_for are changed inplace inside gem, see -
56
+ # https://github.com/plataformatec/simple_form/blob/master/lib/simple_form/action_view_extensions/form_helper.rb#L26
57
+ options.reverse_merge!(options[:builder].form_for_options.deep_dup)
55
58
 
56
59
  (options[:html] ||= {}).update(:multipart => true) if section.attributes.values.any? { |a| a.input_type == :file }
57
60
 
@@ -0,0 +1,18 @@
1
+ module DeadSimpleCMS
2
+ module Util
3
+ module String
4
+ class << self
5
+ # Converts string into css DOM selector for use with class and ID. We
6
+ # currently do lowercase with dashes for cssnames.
7
+ def csserize(str)
8
+ name = str.to_s.dup
9
+ name.gsub!(/[^A-Za-z0-9]+/, " ") # can return nil
10
+ name.gsub!(/(\w)([A-Z])/, '\1-\2') # can return nil
11
+ name.squish!.downcase!
12
+ name.gsub!(" ", "-") # can return nil
13
+ name
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module DeadSimpleCMS
2
- VERSION = "0.12.0"
2
+ VERSION = "0.12.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dead_simple_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.12.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-19 00:00:00.000000000 Z
12
+ date: 2013-04-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -164,6 +164,7 @@ files:
164
164
  - lib/dead_simple_cms/storage/redis.rb
165
165
  - lib/dead_simple_cms/util/identifier.rb
166
166
  - lib/dead_simple_cms/util/identifier/dictionary.rb
167
+ - lib/dead_simple_cms/util/string.rb
167
168
  - lib/dead_simple_cms/version.rb
168
169
  - spec/dead_simple_cms/attribute/collection_spec.rb
169
170
  - spec/dead_simple_cms/attribute/type/all_spec.rb