dead_simple_cms 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -1
- data/.rvmrc.dev +2 -0
- data/README.md +23 -8
- data/lib/dead_simple_cms.rb +1 -1
- data/lib/dead_simple_cms/attribute/type/all.rb +5 -0
- data/lib/dead_simple_cms/attribute/type/base.rb +0 -1
- data/lib/dead_simple_cms/section.rb +0 -2
- data/lib/dead_simple_cms/version.rb +1 -1
- data/spec/dead_simple_cms/attribute/type/all_spec.rb +20 -0
- metadata +15 -14
data/.gitignore
CHANGED
data/.rvmrc.dev
ADDED
data/README.md
CHANGED
@@ -19,10 +19,20 @@ What it doesn't have:
|
|
19
19
|
* Timing - set start and end time for different content
|
20
20
|
* Page builder tools - this is not the right tool if you want to design full pages
|
21
21
|
|
22
|
+
Install
|
23
|
+
------------
|
24
|
+
|
25
|
+
`gem install dead_simple_cms`
|
26
|
+
|
22
27
|
Setup
|
23
28
|
------------
|
24
29
|
|
25
|
-
|
30
|
+
Before getting started, it's important to note that this Gem does not have generators for building migrations, yet,
|
31
|
+
so integrating it with the app is sort of manual process for now.
|
32
|
+
|
33
|
+
----
|
34
|
+
|
35
|
+
If you're Redis store isn't persistent, you can use the default option of using the database.
|
26
36
|
If you decide to use the database, you can create the schema with this:
|
27
37
|
|
28
38
|
```ruby
|
@@ -34,7 +44,7 @@ If you decide to use the database, you can create the schema with this:
|
|
34
44
|
add_index :dead_simple_cms, :key, :unique => true
|
35
45
|
```
|
36
46
|
|
37
|
-
Now, let's add the controller methods. Find a controller you want to use for your CMS:
|
47
|
+
Now, let's add the controller methods. Find (or create) a controller you want to use for your CMS:
|
38
48
|
|
39
49
|
```ruby
|
40
50
|
class Admin::CmsController < Admin::ApplicationController
|
@@ -89,7 +99,7 @@ Configuration
|
|
89
99
|
-------------
|
90
100
|
|
91
101
|
Create an initializer for your app in lib/config/initializers/dead_simple_cms. You can overwrite any of the original
|
92
|
-
settings.
|
102
|
+
settings. Here is an example template from which you can modify on your own.
|
93
103
|
|
94
104
|
```ruby
|
95
105
|
DeadSimpleCMS.configure do
|
@@ -177,7 +187,8 @@ DeadSimpleCMS.configure do
|
|
177
187
|
# with the current template as the first arg, and any other arguments afterwards.
|
178
188
|
display Mixbook::DeadSimpleCMS::Presenters::SiteAnnouncement::TopBarPresenter
|
179
189
|
end
|
180
|
-
group :banner => :image_tag, :width =>
|
190
|
+
group :banner => :image_tag, :width => 400, :height => 600 do
|
191
|
+
# Here additional fields to add onto the group.
|
181
192
|
boolean :show
|
182
193
|
string :promotional_href, :hint => "Used for all custom coupon banners not from the site announcement."
|
183
194
|
display Mixbook::DeadSimpleCMS::Presenters::SiteAnnouncement::BannerPresenter
|
@@ -189,7 +200,7 @@ DeadSimpleCMS.configure do
|
|
189
200
|
end
|
190
201
|
```
|
191
202
|
|
192
|
-
For the view presenters, inherit from the `::DeadSimpleCMS::Group::Presenter
|
203
|
+
For the view presenters, inherit from the `::DeadSimpleCMS::Group::Presenter`.
|
193
204
|
|
194
205
|
```ruby
|
195
206
|
# Public: Handles the banners on the site.
|
@@ -197,6 +208,7 @@ class BannerPresenter < ::DeadSimpleCMS::Group::Presenter
|
|
197
208
|
|
198
209
|
attr_reader :coupon, :options, :size
|
199
210
|
|
211
|
+
# The render method is used to create the html that will be inserted into the page.
|
200
212
|
def render
|
201
213
|
return unless coupon
|
202
214
|
url, alt, href, show, html_options = if coupon.same_code?(site_announcement.coupon_code)
|
@@ -212,6 +224,8 @@ class BannerPresenter < ::DeadSimpleCMS::Group::Presenter
|
|
212
224
|
|
213
225
|
private
|
214
226
|
|
227
|
+
# If you define this method, you can add on additional arguments. I created a separate function like this instead of
|
228
|
+
# overwriting initialize since I don't want the user to have to know how this works internally.
|
215
229
|
def initialize_extra_arguments(coupon, options={})
|
216
230
|
@coupon, @options = coupon, options
|
217
231
|
@size = options.delete(:size) || :small # Currently we have two sizes for these banners: 715x85 and 890x123. - Aryk
|
@@ -260,10 +274,11 @@ DeadSimpleCMS.sections.section1.groups[:group1].groups[:group2].attributes[:attr
|
|
260
274
|
Meta
|
261
275
|
----
|
262
276
|
|
263
|
-
Dead Simple CMS was originally written in the course of a week for [mixbook.com](http://www.mixbook.com).
|
277
|
+
Dead Simple CMS was originally written by Aryk Grosz in the course of a week for [mixbook.com](http://www.mixbook.com).
|
264
278
|
|
265
|
-
|
266
|
-
(read: anal) about creating high quality products that makes people happy, please reach out
|
279
|
+
Mixbook is based in Palo Alto (near California Ave) and we're hiring. We like dogs, beer, and music. If you're
|
280
|
+
passionate (read: anal) about creating high quality products and software that makes people happy, please reach out
|
281
|
+
to us at jobs@mixbook.com.
|
267
282
|
|
268
283
|
Author
|
269
284
|
------
|
data/lib/dead_simple_cms.rb
CHANGED
@@ -80,7 +80,7 @@ module DeadSimpleCMS
|
|
80
80
|
|
81
81
|
# Register any additional attribute classes for use in your configuration.
|
82
82
|
register_attribute_classes(Attribute::Type::String, Attribute::Type::Text, Attribute::Type::Numeric, Attribute::Type::Integer,
|
83
|
-
Attribute::Type::Boolean, Attribute::Type::File, Attribute::Type::Image, Attribute::Type::Symbol)
|
83
|
+
Attribute::Type::Float, Attribute::Type::Boolean, Attribute::Type::File, Attribute::Type::Image, Attribute::Type::Symbol)
|
84
84
|
|
85
85
|
# Set the default form builder used for building the CMS forms in the app. You can replace this with :simple_form,
|
86
86
|
# :simple_form_with_bootstrap or pass in the actual builder class. Your builder class must include the interface:
|
@@ -36,6 +36,11 @@ module DeadSimpleCMS
|
|
36
36
|
self.default_input_type = :string
|
37
37
|
include CollectionSupport
|
38
38
|
end
|
39
|
+
class Float < Numeric
|
40
|
+
def convert_value(value)
|
41
|
+
value && value.to_f
|
42
|
+
end
|
43
|
+
end
|
39
44
|
class Integer < Numeric
|
40
45
|
def convert_value(value)
|
41
46
|
value && value.to_i
|
@@ -52,7 +52,6 @@ module DeadSimpleCMS
|
|
52
52
|
|
53
53
|
# Public: Returns the non-blank value from the storage or the default.
|
54
54
|
def value
|
55
|
-
# return @value if instance_variable_defined?(:@value) # If the value was set to nil, we should return that value.
|
56
55
|
attributes = attributes_from_storage
|
57
56
|
attributes.key?(section_identifier) ? attributes[section_identifier] : default
|
58
57
|
end
|
@@ -138,6 +138,26 @@ describe DeadSimpleCMS::Attribute::Type::Integer do
|
|
138
138
|
|
139
139
|
end
|
140
140
|
|
141
|
+
end
|
142
|
+
describe DeadSimpleCMS::Attribute::Type::Float do
|
143
|
+
|
144
|
+
include_context "Attribute Setup"
|
145
|
+
|
146
|
+
it_behaves_like DeadSimpleCMS::Attribute::Type::CollectionSupport
|
147
|
+
|
148
|
+
its(:default_input_type) { should == :string }
|
149
|
+
|
150
|
+
describe "#convert_value" do
|
151
|
+
it "should convert the value into an integer" do
|
152
|
+
subject.send(:convert_value, "5.45").should eq 5.45
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should return nil if nil passed in" do
|
156
|
+
subject.send(:convert_value, nil).should eq nil
|
157
|
+
end
|
158
|
+
|
159
|
+
end
|
160
|
+
|
141
161
|
end
|
142
162
|
describe DeadSimpleCMS::Attribute::Type::File do
|
143
163
|
|
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.10.
|
4
|
+
version: 0.10.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,12 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-13 00:00:00.000000000 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
17
|
-
requirement: &
|
17
|
+
requirement: &2168634220 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,10 +22,10 @@ dependencies:
|
|
22
22
|
version: '3.0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *2168634220
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: activemodel
|
28
|
-
requirement: &
|
28
|
+
requirement: &2168633620 !ruby/object:Gem::Requirement
|
29
29
|
none: false
|
30
30
|
requirements:
|
31
31
|
- - ! '>='
|
@@ -33,10 +33,10 @@ dependencies:
|
|
33
33
|
version: '3.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
|
-
version_requirements: *
|
36
|
+
version_requirements: *2168633620
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: simple_form
|
39
|
-
requirement: &
|
39
|
+
requirement: &2168632880 !ruby/object:Gem::Requirement
|
40
40
|
none: false
|
41
41
|
requirements:
|
42
42
|
- - ! '>='
|
@@ -44,10 +44,10 @@ dependencies:
|
|
44
44
|
version: '0'
|
45
45
|
type: :development
|
46
46
|
prerelease: false
|
47
|
-
version_requirements: *
|
47
|
+
version_requirements: *2168632880
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rails
|
50
|
-
requirement: &
|
50
|
+
requirement: &2168632220 !ruby/object:Gem::Requirement
|
51
51
|
none: false
|
52
52
|
requirements:
|
53
53
|
- - ! '>='
|
@@ -55,10 +55,10 @@ dependencies:
|
|
55
55
|
version: '3.0'
|
56
56
|
type: :development
|
57
57
|
prerelease: false
|
58
|
-
version_requirements: *
|
58
|
+
version_requirements: *2168632220
|
59
59
|
- !ruby/object:Gem::Dependency
|
60
60
|
name: rspec
|
61
|
-
requirement: &
|
61
|
+
requirement: &2168631700 !ruby/object:Gem::Requirement
|
62
62
|
none: false
|
63
63
|
requirements:
|
64
64
|
- - ! '>='
|
@@ -66,10 +66,10 @@ dependencies:
|
|
66
66
|
version: '0'
|
67
67
|
type: :development
|
68
68
|
prerelease: false
|
69
|
-
version_requirements: *
|
69
|
+
version_requirements: *2168631700
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: sqlite3
|
72
|
-
requirement: &
|
72
|
+
requirement: &2168631200 !ruby/object:Gem::Requirement
|
73
73
|
none: false
|
74
74
|
requirements:
|
75
75
|
- - ! '>='
|
@@ -77,7 +77,7 @@ dependencies:
|
|
77
77
|
version: '0'
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
|
-
version_requirements: *
|
80
|
+
version_requirements: *2168631200
|
81
81
|
description: ! "Dead Simple CMS is a library for modifying different parts of your
|
82
82
|
website without the overhead of having a\nfullblown CMS. The idea with this library
|
83
83
|
is simple: provide an easy way to hook into different parts of your\napplication
|
@@ -99,6 +99,7 @@ extra_rdoc_files: []
|
|
99
99
|
files:
|
100
100
|
- .gitignore
|
101
101
|
- .rspec
|
102
|
+
- .rvmrc.dev
|
102
103
|
- Gemfile
|
103
104
|
- LICENSE
|
104
105
|
- README.md
|