very_simple_cms 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8c31143f5b3cb58c68b19d9e4583722ad82a2a0b
4
- data.tar.gz: e2d0b4572733627fa1f89112ea139eca80cd8a93
3
+ metadata.gz: e70eb17ddefbfea866529ac40ee167ce4390c3e5
4
+ data.tar.gz: a7da6847f9a8bfce88c9248af79ac0d0edeb17ed
5
5
  SHA512:
6
- metadata.gz: b87309ade643ec5b192f17d32dcbfdfc321fe7a8c945022e84625a0532cc1ab6a178424b21a1ec3f23dc3c8c3fe97e9ad921a06e20609a55df4f91fbac6cc2ae
7
- data.tar.gz: ec55949c3c1f3e48a6f1e47162bc2cd2a5d9434de922b1470badc460f7a156eb2472b8890170b0887771b563a343c9e54c5753160449c8014388c79c31500542
6
+ metadata.gz: 4248af94d68464c44306ddb5cff5cbfcef1fef5ec9370051f3693568cbf263a662b83d3a8871355454083c4db92b231202c4ed81761a21789847e3995d6c85d8
7
+ data.tar.gz: dc2aaf6eebcd6b8334dc90b84f5cf4318a4a6bc34e0f3dc286f96939d5d6141ee708dcdb57bb6a1ce7078d2548de3d4660f120b24cfa29a5e6c7a21a16fbf8ad
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2013 YOURNAME
1
+ Copyright 2013 Eduard Gataullin
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # Very Simple Cms
2
+
3
+ Very Simple Cms is a lightweight Content Management System, that support Ruby on Rails 4. Very-Simple-Cms has the simplicity of a static site
4
+ generator, but allows you to
5
+ serve dynamic content on demand.
6
+
7
+ Content is stored on disk in plain text files (there is no database).
8
+ Edit your content in a text editor and keep it under version control
9
+ (most people use git, but any version control system will do fine).
10
+
11
+ This CMS is fully support [Mercury Editor](https://github.com/jejacks0n/mercury), and we recomend to use this CMS with this editor to change CMS content
12
+
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ gem "very_simple_cms"
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ After that run
25
+
26
+ $ rails generate very_simple_cms:install
27
+ this code will create file config/initializers/very_simple_cms.rb.
28
+ After that you could change default settings at config/initializers/very_simple_cms.rb
29
+
30
+ If you would like to use Very Simple Cms with mercury editor, you should add this line to your application's Gemfile:
31
+
32
+ gem 'mercury-rails', git: 'git@github.com:jejacks0n/mercury.git', branch: 'master'
33
+
34
+ After that run
35
+
36
+ $ rails generate mercury:install
37
+
38
+ this command will install mercury editor, we recomend you to install it with layout
39
+
40
+ $ rails generate very_simple_cms:init_mercury
41
+ this command will added 2 needed methods to app/assets/javascripts/mercury.js that are needed to integrate mercury editor with VerySimpleCms
42
+
43
+ ## Usage
44
+ To create a link to your editor (like mercury) use this helper
45
+
46
+ cms_edit_link('custom_user_class')
47
+
48
+ To show text from cms use
49
+
50
+ cms_block('title_of_text_area')
51
+ this code will display content that located by default in config/cms/{your_locale}/html_blocks.yml and have following title, also you can change file name and it's path by editing config/initializers/very_simple_cms.rb
52
+
53
+ ##Options
54
+ - **editor path**
55
+ `VerySimpleCms.editor_path`
56
+ it is path to wysiwyg editor that you use in your app
57
+ - **translate** CMS support I18n. If you want to use multiple languages in your app simply set
58
+ `VerySimpleCms.translatable = true`
59
+ this will say cms to use folders that have name of locale to save cms content like
60
+ `config/cms/{your_locale}/html_blocks.yml`
61
+ if you set
62
+ `VerySimpleCms.translatable = false`
63
+ cms will save changes in path like
64
+ `config/cms/{your_locale}/html_blocks.yml`
65
+ - **name of yml file** You can change filename to save changes like
66
+ `VerySimpleCms.source_file_name = '/html_blocks'
67
+ - **source files root** You can change path to save changes like
68
+ `VerySimpleCms.source_files_root = "config/cms/"`
69
+
70
+ ##Caching
71
+ This Cms use yml files to save user data, but reading from disk is very slow, so to improve your application pervomance you should use caching.
72
+ Very-Simple-Cms fully support caching, so to cash all cms fragments simple set
73
+
74
+ config.action_controller.perform_caching = true
75
+
76
+ to learn more about caching that rails provides visit [Ruby on Rails Guides](http://guides.rubyonrails.org/caching_with_rails.html)
77
+
78
+
79
+ ##Example
80
+ VerySimpleCms have build in simple test and example application that located in 'test/dummy' path
81
+
82
+ To run this app you should firstly clone VerySimpleCms project
83
+
84
+ git clone git@github.com:edikgat/very_simple_cms.git
85
+
86
+ than
87
+
88
+ cd very_simple_cms/test/dummy
89
+
90
+ and run rails server
91
+
92
+ rails s
93
+
94
+ ## P.S.
95
+ This CMS was tested only with Mercury editor and Rails 4 framework
@@ -1,5 +1,7 @@
1
1
  module VerySimpleCms
2
2
  class ApplicationController < ActionController::Base
3
3
  include SharedHelper
4
+ include ApplicationHelper
5
+
4
6
  end
5
7
  end
@@ -17,6 +17,7 @@ module VerySimpleCms
17
17
  )
18
18
  static_text.save
19
19
  end
20
+ Rails.cache.write(cache_name_string(key), (static_text.try(:body).html_safe))
20
21
  end
21
22
  render text: ""
22
23
  end
@@ -1,4 +1,8 @@
1
1
  module VerySimpleCms
2
2
  module ApplicationHelper
3
+ def cache_name_string(title, save_source = nil )
4
+ save_source ||= dynamic_save_source
5
+ "verysimplecms::htmlblocks/#{save_source}/#{title}"
6
+ end
3
7
  end
4
8
  end
@@ -1,7 +1,10 @@
1
1
  module VerySimpleCms
2
2
  module CmsHelper
3
3
  def cms_block(title)
4
- raw(HtmlBlock.find_by_attribute(dynamic_save_source, :title, title).try(:body))
4
+ Rails.cache.fetch(cache_name_string(title)) do
5
+ block = HtmlBlock.find_by_attribute(dynamic_save_source, :title, title)
6
+ raw(block.try(:body))
7
+ end
5
8
  end
6
9
 
7
10
  def cms_edit_link(advanced_class=nil)
@@ -1,14 +1,15 @@
1
1
  module VerySimpleCms
2
2
  class HtmlBlock < YamlRecord::Base
3
3
  include SharedHelper
4
- properties :title, :body, :dynamic_source
4
+ properties :title, :body, :dynamic_source, :updated_at
5
5
  adapter :local
6
6
  source Rails.root.join(VerySimpleCms.source_files_root)
7
7
  source_file_name VerySimpleCms.source_file_name
8
8
  before_create :set_dynamic_source
9
+ before_save :set_updated_at
9
10
 
10
11
  def to_s
11
- {title: title, body: body, dynamic_source: dynamic_source}.to_s
12
+ {title: title, body: body, dynamic_source: dynamic_source, updated_at: updated_at}.to_s
12
13
  end
13
14
 
14
15
  private
@@ -17,5 +18,9 @@ module VerySimpleCms
17
18
  self.dynamic_source = dynamic_save_source
18
19
  end
19
20
  end
21
+
22
+ def set_updated_at
23
+ self.updated_at = Time.zone.now.to_s :bd
24
+ end
20
25
  end
21
26
  end
@@ -6,6 +6,7 @@ module VerySimpleCms
6
6
  ActiveSupport.on_load :action_controller do
7
7
  helper VerySimpleCms::CmsHelper
8
8
  helper VerySimpleCms::SharedHelper
9
+ helper VerySimpleCms::ApplicationHelper
9
10
  end
10
11
  end
11
12
  end
@@ -1,3 +1,3 @@
1
1
  module VerySimpleCms
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1,16 @@
1
+ # Very Simple Cms test application
2
+
3
+ This application use [mercury-editor](https://github.com/jejacks0n/mercury) as editor of cms content, to support latest versions of jquery and work with mercury editor it use [jquery-migrate plugin](https://github.com/jquery/jquery-migrate/).
4
+
5
+ ## Installation
6
+
7
+ $ cd test/dummy
8
+ $ bundle
9
+
10
+ ## Usage
11
+ Simple run
12
+
13
+ $ rails s
14
+
15
+ to edit content click to 'edit' link
16
+
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -2,4 +2,5 @@
2
2
  - :title: first
3
3
  :body: It works!
4
4
  :dynamic_source: en
5
+ :updated_at: '2013-09-30 13:23:08 UTC'
5
6
  :id: 3f7adda07e9887265fb380df676024
File without changes
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: very_simple_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduard Gataullin, Ruslan Hamidullin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-26 00:00:00.000000000 Z
11
+ date: 2013-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -52,72 +52,80 @@ executables: []
52
52
  extensions: []
53
53
  extra_rdoc_files: []
54
54
  files:
55
- - app/assets/javascripts/very_simple_cms/application.js
56
- - app/assets/stylesheets/very_simple_cms/application.css
57
- - app/controllers/very_simple_cms/application_controller.rb
58
- - app/controllers/very_simple_cms/contents_controller.rb
59
- - app/helpers/very_simple_cms/cms_helper.rb
55
+ - app/models/very_simple_cms/html_block.rb
60
56
  - app/helpers/very_simple_cms/application_helper.rb
61
57
  - app/helpers/very_simple_cms/shared_helper.rb
62
- - app/models/very_simple_cms/html_block.rb
63
- - config/locales/en.yml
58
+ - app/helpers/very_simple_cms/cms_helper.rb
59
+ - app/controllers/very_simple_cms/application_controller.rb
60
+ - app/controllers/very_simple_cms/contents_controller.rb
61
+ - app/assets/javascripts/very_simple_cms/application.js
62
+ - app/assets/stylesheets/very_simple_cms/application.css
64
63
  - config/routes.rb
65
- - lib/very_simple_cms/version.rb
66
- - lib/very_simple_cms/engine.rb
67
- - lib/very_simple_cms.rb
64
+ - config/locales/en.yml
68
65
  - lib/generators/very_simple_cms/init_mercury/USAGE
69
66
  - lib/generators/very_simple_cms/init_mercury/init_mercury_generator.rb
70
67
  - lib/generators/very_simple_cms/install/USAGE
71
68
  - lib/generators/very_simple_cms/install/install_generator.rb
72
69
  - lib/generators/very_simple_cms/install/templates/very_simple_cms.rb
70
+ - lib/very_simple_cms/version.rb
71
+ - lib/very_simple_cms/engine.rb
73
72
  - lib/tasks/very_simple_cms_tasks.rake
73
+ - lib/very_simple_cms.rb
74
74
  - MIT-LICENSE
75
75
  - Rakefile
76
- - test/integration/navigation_test.rb
77
- - test/very_simple_cms_test.rb
76
+ - README.md
78
77
  - test/controllers/very_simple_cms/mercury_controller_test.rb
79
- - test/test_helper.rb
80
- - test/helpers/very_simple_cms/cms_helper_test.rb
81
- - test/helpers/very_simple_cms/mercury_helper_test.rb
82
- - test/dummy/bin/rails
78
+ - test/dummy/README.md
79
+ - test/dummy/Rakefile
80
+ - test/dummy/app/assets/images/.keep
81
+ - test/dummy/app/assets/javascripts/application.js
82
+ - test/dummy/app/assets/javascripts/jquery-migrate-1.2.1.js
83
+ - test/dummy/app/assets/javascripts/mercury.js
84
+ - test/dummy/app/assets/stylesheets/application.css
85
+ - test/dummy/app/assets/stylesheets/mercury.css
86
+ - test/dummy/app/controllers/application_controller.rb
87
+ - test/dummy/app/controllers/concerns/.keep
88
+ - test/dummy/app/controllers/home_controller.rb
89
+ - test/dummy/app/helpers/application_helper.rb
90
+ - test/dummy/app/mailers/.keep
91
+ - test/dummy/app/models/.keep
92
+ - test/dummy/app/models/concerns/.keep
93
+ - test/dummy/app/views/home/index.html.erb
94
+ - test/dummy/app/views/layouts/application.html.erb
95
+ - test/dummy/app/views/layouts/mercury.html.erb
83
96
  - test/dummy/bin/bundle
97
+ - test/dummy/bin/rails
84
98
  - test/dummy/bin/rake
99
+ - test/dummy/config.ru
100
+ - test/dummy/config/application.rb
101
+ - test/dummy/config/boot.rb
85
102
  - test/dummy/config/cms/en/html_blocks.yml
103
+ - test/dummy/config/environment.rb
104
+ - test/dummy/config/environments/development.rb
105
+ - test/dummy/config/environments/production.rb
106
+ - test/dummy/config/environments/test.rb
86
107
  - test/dummy/config/initializers/backtrace_silencers.rb
87
108
  - test/dummy/config/initializers/filter_parameter_logging.rb
88
- - test/dummy/config/initializers/wrap_parameters.rb
89
- - test/dummy/config/initializers/session_store.rb
90
- - test/dummy/config/initializers/secret_token.rb
91
- - test/dummy/config/initializers/very_simple_cms.rb
92
109
  - test/dummy/config/initializers/inflections.rb
93
110
  - test/dummy/config/initializers/mime_types.rb
94
- - test/dummy/config/application.rb
95
- - test/dummy/config/environment.rb
96
- - test/dummy/config/environments/test.rb
97
- - test/dummy/config/environments/development.rb
98
- - test/dummy/config/environments/production.rb
111
+ - test/dummy/config/initializers/secret_token.rb
112
+ - test/dummy/config/initializers/session_store.rb
113
+ - test/dummy/config/initializers/very_simple_cms.rb
114
+ - test/dummy/config/initializers/wrap_parameters.rb
99
115
  - test/dummy/config/routes.rb
100
- - test/dummy/config/boot.rb
101
- - test/dummy/README.rdoc
116
+ - test/dummy/lib/assets/.keep
117
+ - test/dummy/log/.keep
102
118
  - test/dummy/public/404.html
103
- - test/dummy/public/500.html
104
119
  - test/dummy/public/422.html
120
+ - test/dummy/public/500.html
105
121
  - test/dummy/public/favicon.ico
106
- - test/dummy/Rakefile
107
- - test/dummy/config.ru
108
- - test/dummy/app/assets/javascripts/application.js
109
- - test/dummy/app/assets/javascripts/mercury.js
110
- - test/dummy/app/assets/javascripts/jquery-migrate-1.2.1.js
111
- - test/dummy/app/assets/stylesheets/mercury.css
112
- - test/dummy/app/assets/stylesheets/application.css
113
- - test/dummy/app/views/layouts/mercury.html.erb
114
- - test/dummy/app/views/layouts/application.html.erb
115
- - test/dummy/app/views/home/index.html.erb
116
- - test/dummy/app/controllers/home_controller.rb
117
- - test/dummy/app/controllers/application_controller.rb
118
- - test/dummy/app/helpers/application_helper.rb
119
122
  - test/dummy/test/controllers/home_controller_test.rb
120
123
  - test/dummy/test/helpers/home_helper_test.rb
124
+ - test/helpers/very_simple_cms/cms_helper_test.rb
125
+ - test/helpers/very_simple_cms/mercury_helper_test.rb
126
+ - test/integration/navigation_test.rb
127
+ - test/test_helper.rb
128
+ - test/very_simple_cms_test.rb
121
129
  homepage: https://github.com/edikgat/very_simple_cms
122
130
  licenses:
123
131
  - MIT
@@ -138,53 +146,60 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
146
  version: '0'
139
147
  requirements: []
140
148
  rubyforge_project:
141
- rubygems_version: 2.0.7
149
+ rubygems_version: 2.1.5
142
150
  signing_key:
143
151
  specification_version: 4
144
152
  summary: Ruby CMS, written in Ruby on Rails and use YML files to store content
145
153
  test_files:
146
- - test/integration/navigation_test.rb
147
- - test/very_simple_cms_test.rb
148
154
  - test/controllers/very_simple_cms/mercury_controller_test.rb
149
- - test/test_helper.rb
150
- - test/helpers/very_simple_cms/cms_helper_test.rb
151
- - test/helpers/very_simple_cms/mercury_helper_test.rb
152
- - test/dummy/bin/rails
155
+ - test/dummy/README.md
156
+ - test/dummy/Rakefile
157
+ - test/dummy/app/assets/images/.keep
158
+ - test/dummy/app/assets/javascripts/application.js
159
+ - test/dummy/app/assets/javascripts/jquery-migrate-1.2.1.js
160
+ - test/dummy/app/assets/javascripts/mercury.js
161
+ - test/dummy/app/assets/stylesheets/application.css
162
+ - test/dummy/app/assets/stylesheets/mercury.css
163
+ - test/dummy/app/controllers/application_controller.rb
164
+ - test/dummy/app/controllers/concerns/.keep
165
+ - test/dummy/app/controllers/home_controller.rb
166
+ - test/dummy/app/helpers/application_helper.rb
167
+ - test/dummy/app/mailers/.keep
168
+ - test/dummy/app/models/.keep
169
+ - test/dummy/app/models/concerns/.keep
170
+ - test/dummy/app/views/home/index.html.erb
171
+ - test/dummy/app/views/layouts/application.html.erb
172
+ - test/dummy/app/views/layouts/mercury.html.erb
153
173
  - test/dummy/bin/bundle
174
+ - test/dummy/bin/rails
154
175
  - test/dummy/bin/rake
176
+ - test/dummy/config.ru
177
+ - test/dummy/config/application.rb
178
+ - test/dummy/config/boot.rb
155
179
  - test/dummy/config/cms/en/html_blocks.yml
180
+ - test/dummy/config/environment.rb
181
+ - test/dummy/config/environments/development.rb
182
+ - test/dummy/config/environments/production.rb
183
+ - test/dummy/config/environments/test.rb
156
184
  - test/dummy/config/initializers/backtrace_silencers.rb
157
185
  - test/dummy/config/initializers/filter_parameter_logging.rb
158
- - test/dummy/config/initializers/wrap_parameters.rb
159
- - test/dummy/config/initializers/session_store.rb
160
- - test/dummy/config/initializers/secret_token.rb
161
- - test/dummy/config/initializers/very_simple_cms.rb
162
186
  - test/dummy/config/initializers/inflections.rb
163
187
  - test/dummy/config/initializers/mime_types.rb
164
- - test/dummy/config/application.rb
165
- - test/dummy/config/environment.rb
166
- - test/dummy/config/environments/test.rb
167
- - test/dummy/config/environments/development.rb
168
- - test/dummy/config/environments/production.rb
188
+ - test/dummy/config/initializers/secret_token.rb
189
+ - test/dummy/config/initializers/session_store.rb
190
+ - test/dummy/config/initializers/very_simple_cms.rb
191
+ - test/dummy/config/initializers/wrap_parameters.rb
169
192
  - test/dummy/config/routes.rb
170
- - test/dummy/config/boot.rb
171
- - test/dummy/README.rdoc
193
+ - test/dummy/lib/assets/.keep
194
+ - test/dummy/log/.keep
172
195
  - test/dummy/public/404.html
173
- - test/dummy/public/500.html
174
196
  - test/dummy/public/422.html
197
+ - test/dummy/public/500.html
175
198
  - test/dummy/public/favicon.ico
176
- - test/dummy/Rakefile
177
- - test/dummy/config.ru
178
- - test/dummy/app/assets/javascripts/application.js
179
- - test/dummy/app/assets/javascripts/mercury.js
180
- - test/dummy/app/assets/javascripts/jquery-migrate-1.2.1.js
181
- - test/dummy/app/assets/stylesheets/mercury.css
182
- - test/dummy/app/assets/stylesheets/application.css
183
- - test/dummy/app/views/layouts/mercury.html.erb
184
- - test/dummy/app/views/layouts/application.html.erb
185
- - test/dummy/app/views/home/index.html.erb
186
- - test/dummy/app/controllers/home_controller.rb
187
- - test/dummy/app/controllers/application_controller.rb
188
- - test/dummy/app/helpers/application_helper.rb
189
199
  - test/dummy/test/controllers/home_controller_test.rb
190
200
  - test/dummy/test/helpers/home_helper_test.rb
201
+ - test/helpers/very_simple_cms/cms_helper_test.rb
202
+ - test/helpers/very_simple_cms/mercury_helper_test.rb
203
+ - test/integration/navigation_test.rb
204
+ - test/test_helper.rb
205
+ - test/very_simple_cms_test.rb
@@ -1,28 +0,0 @@
1
- == README
2
-
3
- This README would normally document whatever steps are necessary to get the
4
- application up and running.
5
-
6
- Things you may want to cover:
7
-
8
- * Ruby version
9
-
10
- * System dependencies
11
-
12
- * Configuration
13
-
14
- * Database creation
15
-
16
- * Database initialization
17
-
18
- * How to run the test suite
19
-
20
- * Services (job queues, cache servers, search engines, etc.)
21
-
22
- * Deployment instructions
23
-
24
- * ...
25
-
26
-
27
- Please feel free to use a different markup language if you do not plan to run
28
- <tt>rake doc:app</tt>.