dead_simple_cms 0.9.0

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.
Files changed (66) hide show
  1. data/.gitignore +19 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +22 -0
  5. data/README.md +266 -0
  6. data/Rakefile +17 -0
  7. data/dead_simple_cms.gemspec +47 -0
  8. data/lib/dead_simple_cms.rb +132 -0
  9. data/lib/dead_simple_cms/attribute/collection.rb +45 -0
  10. data/lib/dead_simple_cms/attribute/type/all.rb +104 -0
  11. data/lib/dead_simple_cms/attribute/type/base.rb +79 -0
  12. data/lib/dead_simple_cms/attribute/type/collection_support.rb +26 -0
  13. data/lib/dead_simple_cms/configuration.rb +50 -0
  14. data/lib/dead_simple_cms/file_uploader/base.rb +29 -0
  15. data/lib/dead_simple_cms/group.rb +58 -0
  16. data/lib/dead_simple_cms/group/configuration.rb +32 -0
  17. data/lib/dead_simple_cms/group/presenter.rb +23 -0
  18. data/lib/dead_simple_cms/rails/action_controller/extensions.rb +24 -0
  19. data/lib/dead_simple_cms/rails/action_controller/fragment_sweeper.rb +19 -0
  20. data/lib/dead_simple_cms/rails/action_view/extensions.rb +14 -0
  21. data/lib/dead_simple_cms/rails/action_view/form_builders/default.rb +16 -0
  22. data/lib/dead_simple_cms/rails/action_view/form_builders/interface.rb +72 -0
  23. data/lib/dead_simple_cms/rails/action_view/form_builders/simple_form.rb +43 -0
  24. data/lib/dead_simple_cms/rails/action_view/form_builders/simple_form_with_bootstrap.rb +19 -0
  25. data/lib/dead_simple_cms/rails/action_view/presenter.rb +63 -0
  26. data/lib/dead_simple_cms/section.rb +103 -0
  27. data/lib/dead_simple_cms/section/builder.rb +73 -0
  28. data/lib/dead_simple_cms/storage/base.rb +49 -0
  29. data/lib/dead_simple_cms/storage/database.rb +33 -0
  30. data/lib/dead_simple_cms/storage/memory.rb +20 -0
  31. data/lib/dead_simple_cms/storage/rails_cache.rb +19 -0
  32. data/lib/dead_simple_cms/storage/redis.rb +23 -0
  33. data/lib/dead_simple_cms/util/identifier.rb +40 -0
  34. data/lib/dead_simple_cms/util/identifier/dictionary.rb +65 -0
  35. data/lib/dead_simple_cms/version.rb +3 -0
  36. data/spec/dead_simple_cms/attribute/collection_spec.rb +46 -0
  37. data/spec/dead_simple_cms/attribute/type/all_spec.rb +252 -0
  38. data/spec/dead_simple_cms/attribute/type/base_spec.rb +117 -0
  39. data/spec/dead_simple_cms/configuration_spec.rb +117 -0
  40. data/spec/dead_simple_cms/file_uploader/base_spec.rb +35 -0
  41. data/spec/dead_simple_cms/group/configuration_spec.rb +24 -0
  42. data/spec/dead_simple_cms/group/presenter_spec.rb +28 -0
  43. data/spec/dead_simple_cms/group_spec.rb +65 -0
  44. data/spec/dead_simple_cms/rails/action_view/form_builders/default_spec.rb +8 -0
  45. data/spec/dead_simple_cms/rails/action_view/form_builders/simple_form_spec.rb +8 -0
  46. data/spec/dead_simple_cms/rails/action_view/form_builders/simple_form_with_bootstrap_spec.rb +8 -0
  47. data/spec/dead_simple_cms/rails/action_view/fragment_sweeper_spec.rb +22 -0
  48. data/spec/dead_simple_cms/rails/action_view/presenter_spec.rb +54 -0
  49. data/spec/dead_simple_cms/section/builder_spec.rb +28 -0
  50. data/spec/dead_simple_cms/section_spec.rb +78 -0
  51. data/spec/dead_simple_cms/storage/base_spec.rb +59 -0
  52. data/spec/dead_simple_cms/storage/database_spec.rb +51 -0
  53. data/spec/dead_simple_cms/storage/memory_spec.rb +25 -0
  54. data/spec/dead_simple_cms/storage/rails_cache_spec.rb +33 -0
  55. data/spec/dead_simple_cms/storage/redis_spec.rb +33 -0
  56. data/spec/dead_simple_cms/util/identifier/dictionary/duplciate_item_spec.rb +10 -0
  57. data/spec/dead_simple_cms/util/identifier/dictionary/invalid_entry_class_spec.rb +10 -0
  58. data/spec/dead_simple_cms/util/identifier/dictionary_spec.rb +42 -0
  59. data/spec/dead_simple_cms/util/identifier_spec.rb +27 -0
  60. data/spec/setup.rb +26 -0
  61. data/spec/setup/banner_presenter.rb +19 -0
  62. data/spec/setup/rspec_template_builder.rb +104 -0
  63. data/spec/setup/shared.rb +57 -0
  64. data/spec/setup/test_file_uploader.rb +12 -0
  65. data/spec/spec_helper.rb +48 -0
  66. metadata +221 -0
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+
19
+ dead_simple_cms.sqlite3
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --backtrace
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dead_simple_cms.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Aryk Grosz
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,266 @@
1
+ Dead Simple CMS
2
+ ======
3
+
4
+ Dead Simple CMS is a library for modifying different parts of your website without the overhead of having a
5
+ fullblown CMS. The idea with this library is simple: provide an easy way to hook into different parts of your
6
+ application (not only views) by defining the different parts to modify in an easy, straight-forward DSL.
7
+
8
+ The basic components of this library include:
9
+
10
+ * A DSL to define the changeable values in your app
11
+ * Form generators based on SimpleForm (with or without Bootstrap) and default rails FormBuilder
12
+ * Expandable storage mechanisms so you can store the data in different locations
13
+ * Currently supported: Redis, Database, Memcache, even Memory (for testing)
14
+ * Presenters/renderers so you can take groups of variables and render them into your views (ie image_tag)
15
+
16
+ What it doesn't have:
17
+
18
+ * Versioning - be able to look at old versions of the content
19
+ * Timing - set start and end time for different content
20
+ * Page builder tools - this is not the right tool if you want to design full pages
21
+
22
+ Setup
23
+ ------------
24
+
25
+ If you're Redis store isn't persistence, you can use the default option of using the database.
26
+ If you decide to use the database, you can create the schema with this:
27
+
28
+ ```ruby
29
+ create_table :dead_simple_cms, :force => true do |t|
30
+ t.string :key
31
+ t.text :value
32
+ t.timestamps
33
+ end
34
+ add_index :dead_simple_cms, :key, :unique => true
35
+ ```
36
+
37
+ Now, let's add the controller methods. Find a controller you want to use for your CMS:
38
+
39
+ ```ruby
40
+ class Admin::CmsController < Admin::ApplicationController
41
+
42
+ include DeadSimpleCMS::Rails::ActionController::Extensions
43
+
44
+ cms_cache_sweeper :only => :edit
45
+
46
+ def edit
47
+ if request.post?
48
+ sections_updated = update_sections_from_params
49
+ redirect_to :action => :edit
50
+ end
51
+ end
52
+
53
+ end
54
+ ```
55
+
56
+ In your CMSHelper, add the view helper methods:
57
+
58
+ ```ruby
59
+ module Admin
60
+ module CmsHelper
61
+ include DeadSimpleCMS::Rails::ActionView::Extensions
62
+ end
63
+ end
64
+ ```
65
+
66
+ This will give you access to the CMS presenter:
67
+
68
+ ```ruby
69
+ def dead_simple_cms
70
+ @dead_simple_cms ||= Presenter.new(self)
71
+ end
72
+ ```
73
+
74
+ From here you can do:
75
+
76
+ ```ruby
77
+ <%= dead_simple_cms.with_bootstrap_tabs %>
78
+ ```
79
+
80
+ to render the forms for the different sections along with tabs to switch between them.
81
+
82
+ Or, if you don't have bootstrap installed, you can use the default form builder and simply call:
83
+
84
+ ```ruby
85
+ <%= dead_simple_cms.sections %>
86
+ ```
87
+
88
+ Configuration
89
+ -------------
90
+
91
+ Create an initializer for your app in lib/config/initializers/dead_simple_cms. You can overwrite any of the original
92
+ settings.
93
+
94
+ ```ruby
95
+ DeadSimpleCMS.configure do
96
+
97
+ default_form_builder :simple_form_with_bootstrap
98
+
99
+ file_uploader_class Mixbook::DeadSimpleCMS::FileUploader
100
+
101
+ link_hint = "Please enter just the path (ie '/some-path')"
102
+
103
+ # In the group_configuration you can create configurations to use to bootstrap other groups. See below.
104
+ group_configuration(:image_tag) do
105
+ image :url, :required => true
106
+ string :alt, :default => "Design Beautiful Books"
107
+ string :href, :hint => link_hint, :required => true
108
+
109
+ # To render the display, just call #render with the instance of the view.
110
+ #
111
+ # <%= group.render(self, {:class => "hi there"}, :alt => "alt value") %>
112
+ display do |group, html_options, image_html_options|
113
+ (image_html_options ||= {}).reverse_merge!(:alt => group.alt)
114
+ link_to_if(group.href, image_tag(group.url, image_html_options), group.href, html_options)
115
+ end
116
+ end
117
+
118
+ section(:application) do
119
+ group(:settings) do
120
+ [:option1, :option2, :options3].each do |setting|
121
+ boolean setting
122
+ end
123
+ end
124
+ end
125
+
126
+ section(:products_page, :path => "/products") do
127
+ [:left, :center, :right].each do |pos|
128
+ group(pos) do
129
+ image :url, :width => 272, :height => 238, :default => "/images/products_lander/products_1.jpg"
130
+ # You can provide a default value as well, for when the CMS starts up.
131
+ string :header, :default => "#{pos.to_s.titleize} Header"
132
+
133
+ # Define a collection on "string", "integer" or "numeric" types if you want to limit the user to only a couple
134
+ # of options. You can pass in an array or a lambda which yields an array (for deferred instantiation).
135
+ string :product_scope, :collection => lambda { SomeTable.all.map(&:product_scope) },
136
+ :default => "books"
137
+
138
+ string :href, :hint => link_hint
139
+ end
140
+ end
141
+ end
142
+
143
+ # Here we create another CMS section for the cards page. I can define the :fragments to sweep in either a Hash
144
+ # or a lambda with the section yielded.
145
+ section(:cards_page, :path => "/cards",
146
+ :fragments => lambda { |section| {:controller => "/some_controller", :action => :index, :product_type => "cards", :section => section} }) do
147
+
148
+ # Here, we leverage the :image_tag group_configuration from above. Any values that are already present will be
149
+ # overwritten by the values below.
150
+ group(:hero => :image_tag, :attribute_options => {
151
+ :url => {:width => 715, :height => 301, :default => "/images/storefront/design_beautiful_wedding_invitations.jpg"},
152
+ :alt => {:default => "Design Beautiful Books"},
153
+ :href => {:hint => link_hint, :default => "cards/wedding-invitations"}
154
+ })
155
+ end
156
+
157
+ section(:site_announcement, :path => "/") do
158
+ boolean :show_default, :default => false
159
+ [:current, :default].each do |type|
160
+ group(type) do
161
+ string :coupon_code
162
+ group(:top_bar) do
163
+ string :css_class, :collection => %w{facebook default christmas green}, :default => "facebook"
164
+ string :strong, :default => "FREE Priority Shipping on Orders $50+"
165
+ string :normal
166
+ string :action
167
+ string :href
168
+
169
+ # Here we can display custom presenter for this content. The presenter class must respond_to "render"
170
+ # with the current template as the first arg, and any other arguments afterwards.
171
+ display Mixbook::DeadSimpleCMS::Presenters::SiteAnnouncement::TopBarPresenter
172
+ end
173
+ group :banner => :image_tag, :width => width, :height => height do
174
+ boolean :show
175
+ string :promotional_href, :hint => "Used for all custom coupon banners not from the site announcement."
176
+ display Mixbook::DeadSimpleCMS::Presenters::SiteAnnouncement::BannerPresenter
177
+ end
178
+ end
179
+ end
180
+ end
181
+
182
+ end
183
+ ```
184
+
185
+ For the view presenters, inherit from the `::DeadSimpleCMS::Group::Presenter`:
186
+
187
+ ```ruby
188
+ # Public: Handles the banners on the site.
189
+ class BannerPresenter < ::DeadSimpleCMS::Group::Presenter
190
+
191
+ attr_reader :coupon, :options, :size
192
+
193
+ def render
194
+ return unless coupon
195
+ url, alt, href, show, html_options = if coupon.same_code?(site_announcement.coupon_code)
196
+ [group.url, group.alt, group.href, group.show, {}]
197
+ else
198
+ url = "http://www.gettyimages.com/basketball.jpg"
199
+ [url, nil, group.promotional_href, true, {:onerror => "$(this).hide()"}]
200
+ end
201
+
202
+ # We can use any method accessible from the template since we simply delegate to the template.
203
+ link_to_if(href, image_tag(url, html_options.update(:class => "banner", :alt => alt)), href) if show
204
+ end
205
+
206
+ private
207
+
208
+ def initialize_extra_arguments(coupon, options={})
209
+ @coupon, @options = coupon, options
210
+ @size = options.delete(:size) || :small # Currently we have two sizes for these banners: 715x85 and 890x123. - Aryk
211
+ raise("Invalid size: #{size}") unless [:small, :large].include?(size)
212
+ end
213
+
214
+ end
215
+ ```
216
+
217
+ Then in your views, you can do:
218
+
219
+ ```ruby
220
+ <%= DeadSimpleCMS.sections.current.banner.render(self, coupon, :size => :large) %>
221
+ ```
222
+
223
+ For the file uploader, simply extend from ::DeadSimpleCMS::FileUploader::Base and add #url and #upload! methods.
224
+
225
+ ```ruby
226
+ class Mixbook::DeadSimpleCMS::FileUploader < ::DeadSimpleCMS::FileUploader::Base
227
+
228
+ def url
229
+ # this should retrieve the url to where the photo will be uploaded to.
230
+ end
231
+
232
+ def upload!
233
+ AWS::S3::S3Object.store(path, data, "mybucket", :access => :public_read)
234
+ end
235
+
236
+ end
237
+ ```
238
+
239
+ Accessing Values
240
+ -----
241
+
242
+ To access the values and modify them directly:
243
+
244
+ ```ruby
245
+ DeadSimpleCMS.sections.section1.group1.group2.group3.attribute = "new value"
246
+ DeadSimpleCMS.sections.section1.save!
247
+
248
+ # Access the data:
249
+ DeadSimpleCMS.sections.section1.group1.group2.group3.attribute # => "new value"
250
+ DeadSimpleCMS.sections.section1.groups[:group1].groups[:group2].attributes[:attribute].value # => "new value"
251
+ ```
252
+
253
+ Meta
254
+ ----
255
+
256
+ Dead Simple CMS was originally written in two days and came out of the real business
257
+ needs of [mixbook.com](http://www.mixbook.com).
258
+
259
+ We're based in Palo Alto (near California Ave) and we're hiring. We like dogs, beer, and music. If you're passionate
260
+ (read: anal) about creating high quality products that makes people happy, please reach out to us at jobs@mixbook.com.
261
+
262
+
263
+ Author
264
+ ------
265
+
266
+ Aryk Grosz :: aryk.grosz@gmail.com :: @arykg
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ # RSpec 2.0
5
+ require 'rspec/core/rake_task'
6
+
7
+ desc 'Default: run specs'
8
+ task :default => :spec
9
+ RSpec::Core::RakeTask.new do |t|
10
+ t.pattern = "spec/**/*_spec.rb"
11
+ end
12
+
13
+ RSpec::Core::RakeTask.new('rcov') do |t|
14
+ t.pattern = "spec/**/*_spec.rb"
15
+ t.rcov = true
16
+ t.rcov_opts = ['--exclude', 'spec']
17
+ end
@@ -0,0 +1,47 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/dead_simple_cms/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Aryk Grosz"]
6
+ gem.email = ["aryk@mixbook.com"]
7
+ gem.summary = %q{DeadSimpleCMS provides a way to define, modify, and present custom variables and content in your application.}
8
+ gem.homepage = "http://github.com/Aryk/dead_simple_cms"
9
+
10
+ gem.files = `git ls-files`.split($\)
11
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
12
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
+ gem.name = "dead_simple_cms"
14
+ gem.require_paths = ["lib"]
15
+ gem.version = DeadSimpleCMS::VERSION
16
+
17
+ gem.test_files = Dir["spec/**/*"]
18
+
19
+ gem.add_dependency "activesupport", ">= 3.0"
20
+ gem.add_dependency "activemodel", ">= 3.0"
21
+
22
+ gem.add_development_dependency "simple_form"
23
+ gem.add_development_dependency "rails", ">= 3.0"
24
+ gem.add_development_dependency "rspec"
25
+ gem.add_development_dependency "sqlite3"
26
+
27
+ gem.description = <<-description
28
+ Dead Simple CMS is a library for modifying different parts of your website without the overhead of having a
29
+ fullblown CMS. The idea with this library is simple: provide an easy way to hook into different parts of your
30
+ application (not only views) by defining the different parts to modify in an easy, straight-forward DSL.
31
+
32
+ The basic components of this library include:
33
+
34
+ * A DSL to define the changeable values in your app
35
+ * Form generators based on SimpleForm (with or without Bootstrap) and default rails FormBuilder
36
+ * Expandable storage mechanisms so you can store the data in different locations
37
+ * Currently supported: Redis, Database, Memcache, even Memory (for testing)
38
+ * Presenters/renderers so you can take groups of variables and render them into your views (ie image_tag)
39
+
40
+ What it doesn't have:
41
+
42
+ * Versioning - be able to look at old versions of the content
43
+ * Timing - set start and end time for different content
44
+ * Page builder tools - this is not the right tool if you want to design full pages
45
+ description
46
+
47
+ end
@@ -0,0 +1,132 @@
1
+ require 'rubygems'
2
+ require "dead_simple_cms/version"
3
+
4
+ module DeadSimpleCMS ; end
5
+
6
+ # These are the only two things needed from the rails family to run this. ActiveModel is necessary for observing and
7
+ # callbacks done in the DeadSimpleCMS::Section class.
8
+ require 'active_support/core_ext'
9
+ require 'active_model'
10
+
11
+ require 'dead_simple_cms/configuration'
12
+
13
+ require 'dead_simple_cms/util/identifier'
14
+ require 'dead_simple_cms/file_uploader/base'
15
+
16
+ require 'dead_simple_cms/storage/base'
17
+ require 'dead_simple_cms/storage/memory'
18
+ module DeadSimpleCMS::Storage
19
+ autoload :RailsCache, 'dead_simple_cms/storage/rails_cache'
20
+ autoload :Redis, 'dead_simple_cms/storage/redis'
21
+ autoload :Database, 'dead_simple_cms/storage/database'
22
+ end
23
+
24
+ require 'dead_simple_cms/attribute/collection'
25
+
26
+ require 'dead_simple_cms/attribute/type/collection_support'
27
+ require 'dead_simple_cms/attribute/type/base'
28
+ require 'dead_simple_cms/attribute/type/all'
29
+
30
+ require 'dead_simple_cms/group'
31
+ require 'dead_simple_cms/group/configuration'
32
+ require 'dead_simple_cms/group/presenter'
33
+
34
+ require 'dead_simple_cms/section'
35
+ require 'dead_simple_cms/section/builder'
36
+
37
+ if defined?(ActionView)
38
+ require 'dead_simple_cms/rails/action_view/form_builders/interface'
39
+ require 'dead_simple_cms/rails/action_view/form_builders/default'
40
+ module DeadSimpleCMS::Rails::ActionView::FormBuilders
41
+ autoload :SimpleForm, 'dead_simple_cms/rails/action_view/form_builders/simple_form'
42
+ autoload :SimpleFormWithBootstrap, 'dead_simple_cms/rails/action_view/form_builders/simple_form_with_bootstrap'
43
+ end
44
+
45
+ require 'dead_simple_cms/rails/action_view/extensions'
46
+ require 'dead_simple_cms/rails/action_view/presenter'
47
+ end
48
+
49
+ if defined?(ActionController)
50
+ require 'dead_simple_cms/rails/action_controller/extensions'
51
+ require 'dead_simple_cms/rails/action_controller/fragment_sweeper'
52
+ end
53
+
54
+ module DeadSimpleCMS
55
+
56
+ extend self
57
+
58
+ def configuration
59
+ @configuration ||= Configuration.new
60
+ end
61
+
62
+ def configure(&block)
63
+ configuration.instance_eval(&block)
64
+ end
65
+
66
+ def sections
67
+ @sections ||= Section.new_dictionary
68
+ end
69
+
70
+ def group_configurations
71
+ @group_configurations ||= Group::Configuration.new_dictionary
72
+ end
73
+
74
+ configure do
75
+
76
+ # Register any additional attribute classes for use in your configuration.
77
+ register_attribute_classes(Attribute::Type::String, Attribute::Type::Text, Attribute::Type::Numeric, Attribute::Type::Integer,
78
+ Attribute::Type::Boolean, Attribute::Type::File, Attribute::Type::Image, Attribute::Type::Symbol)
79
+
80
+ # Set the default form builder used for building the CMS forms in the app. You can replace this with :simple_form,
81
+ # :simple_form_with_bootstrap or pass in the actual builder class. Your builder class must include the interface:
82
+ # DeadSimpleCMS::Rails::ActionView::FormBuilders::Interface.
83
+ default_form_builder :default if defined?(ActionView)
84
+
85
+ # Set the default storage class for attributes to be store. The current available options are
86
+ # [:rails_cache, :database, :redis, :memory]. You can also extend DeadSimpleCMS::Storage::Base and provide your own.
87
+ # If you create your own, please provide the full class name.
88
+ #
89
+ # If you choose to use the database, make sure to create a database table to hold the data:
90
+ #
91
+ # create_table :dead_simple_cms, :force => true do |t|
92
+ # t.string :key
93
+ # t.text :value
94
+ # t.timestamps
95
+ # end
96
+ # add_index :dead_simple_cms, :key, :unique => true
97
+ #
98
+ if defined?(ActiveRecord)
99
+ storage_class :database
100
+ else
101
+ puts "ATTENTION: DeadSimpleCMS did not find ActiveRecord. It will store the CMS in memory and you will lose it when your application shutsdown!!!"
102
+ storage_class :memory
103
+ end
104
+
105
+ # If you are going to use the 'file' type, make sure to provide an uploader class. By default file uploads
106
+ # **WILL NOT WORK**. Create your own uploader by extending from DeadSimpleCMS::FileUploader::Base and creating
107
+ # a #url and a #upload! method.
108
+ #
109
+ # Example
110
+ #
111
+ # class MyFileUploader < DeadSimpleCMS::FileUploader::Base
112
+ #
113
+ # def url
114
+ # # This should retrieve the url to where the photo will be uploaded to.
115
+ # end
116
+ #
117
+ # def upload!
118
+ # AWS::S3::S3Object.store(path, data, "mybucket", :access => :public_read)
119
+ # end
120
+
121
+ # end
122
+ #
123
+ #
124
+ # file_uploader_class MyOwnFileUploader
125
+
126
+ # Set the serializer class to use. It must output to a string and have #dump and #load methods on it.
127
+ require 'psych'
128
+ storage_serializer_class Psych
129
+
130
+ end
131
+
132
+ end