cms-lite 0.4.1 → 0.5.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.
- data/README.rdoc +11 -2
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/app/controllers/cms_lite_controller.rb +2 -1
- data/cms-lite.gemspec +4 -2
- data/config/cms_lite_routes.rb +3 -3
- data/lib/cms_lite.rb +24 -4
- data/test/rails_root/content/pages/en/default/root.html.erb +1 -0
- data/test/rails_root/features/view_cms_pages.feature +15 -4
- data/test/rails_root/test/functional/cms_lite_controller_test.rb +7 -0
- data/test/rails_root/test/test_helper.rb +7 -0
- data/test/rails_root/themes/blue/content/pages/en/default/blue_root.html.erb +1 -0
- metadata +4 -2
data/README.rdoc
CHANGED
@@ -15,7 +15,6 @@ and you're ready to go.
|
|
15
15
|
=== Add the gem to environment.rb
|
16
16
|
config.gem 'cms-lite', :lib => 'cms_lite'
|
17
17
|
|
18
|
-
|
19
18
|
=== Handy Rake Tasks
|
20
19
|
CMS Lite comes with rake tasks that can help you manage your project. These include the ability to send all files from one language
|
21
20
|
to google for translation into 24 other languages. To gain access to these tasks simple add the following lines to Rakefile:
|
@@ -32,8 +31,18 @@ then visit:
|
|
32
31
|
or
|
33
32
|
http://localhost:3000/cmslite-protected/hello-world
|
34
33
|
|
34
|
+
== Usage
|
35
|
+
To have a page with the url 'http://www.example.com/blue/home' create a page '/content/pages/en/blue/home.html.erb
|
36
|
+
To create a page that requires a login at the url 'http://www.example.com/red/protected' create a page '/content/protected-page/en/red/protected.html.erb'
|
37
|
+
|
38
|
+
If you want a page mapped directly off the root ie http://www.example.com/wow create a directory called default and put the file there.
|
39
|
+
ie 'content/pages/en/default/wow.html.erb'
|
40
|
+
|
41
|
+
You can add new 'content' paths by calling append_content_path:
|
42
|
+
CmsLite.append_content_path("somewhere/else/content")
|
43
|
+
This let's you add pages like 'somewhere/else/content/en/green/home.html.erb' and find them at http://www.example.com/green/home
|
35
44
|
|
36
|
-
|
45
|
+
== Translate your content with Google
|
37
46
|
rake cms_lite:translate
|
38
47
|
|
39
48
|
Will translate all files in the 'en' directory into the following languages (codes):
|
data/Rakefile
CHANGED
@@ -71,7 +71,7 @@ begin
|
|
71
71
|
)
|
72
72
|
|
73
73
|
host = "#{config['username']}@rubyforge.org"
|
74
|
-
remote_dir = "/var/www/gforge-projects/
|
74
|
+
remote_dir = "/var/www/gforge-projects/cms-lite/"
|
75
75
|
local_dir = 'rdoc'
|
76
76
|
|
77
77
|
Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.5.0
|
@@ -14,7 +14,8 @@ class CmsLiteController < ApplicationController
|
|
14
14
|
def render_content_page(cms_lite_path, request_layout = '')
|
15
15
|
content_page = nil
|
16
16
|
CmsLite.content_paths.each do |content_path|
|
17
|
-
|
17
|
+
content_page_key = params[:content_page].is_a?(Array) ? params[:content_page].join('/') : params[:content_page]
|
18
|
+
path = File.join(RAILS_ROOT, content_path, cms_lite_path, I18n.locale.to_s, params[:content_key], content_page_key)
|
18
19
|
format = params[:format] || 'htm'
|
19
20
|
content_page = Dir.glob("#{path}.#{format}").first
|
20
21
|
content_page = Dir.glob("#{path}").first if content_page.nil?
|
data/cms-lite.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{cms-lite}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.5.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Justin Ball"]
|
9
|
-
s.date = %q{2009-07-
|
9
|
+
s.date = %q{2009-07-22}
|
10
10
|
s.description = %q{CMS gem that makes it simple to interact with your content developers by serving pages from '/content'.}
|
11
11
|
s.email = %q{justinball@gmail.com}
|
12
12
|
s.extra_rdoc_files = [
|
@@ -58,6 +58,7 @@ Gem::Specification.new do |s|
|
|
58
58
|
"test/rails_root/config/initializers/requires.rb",
|
59
59
|
"test/rails_root/config/initializers/session_store.rb",
|
60
60
|
"test/rails_root/config/routes.rb",
|
61
|
+
"test/rails_root/content/pages/en/default/root.html.erb",
|
61
62
|
"test/rails_root/content/pages/en/demo/hi.html.erb",
|
62
63
|
"test/rails_root/content/pages/en/open/hello.html.erb",
|
63
64
|
"test/rails_root/content/protected-pages/en/demo/hi.html.erb",
|
@@ -265,6 +266,7 @@ Gem::Specification.new do |s|
|
|
265
266
|
"test/rails_root/test/unit/.keep",
|
266
267
|
"test/rails_root/test/unit/cms_lite_test.rb",
|
267
268
|
"test/rails_root/themes/blue/content/pages/en/blue/blue.html.erb",
|
269
|
+
"test/rails_root/themes/blue/content/pages/en/default/blue_root.html.erb",
|
268
270
|
"test/rails_root/themes/blue/content/pages/en/open/blue.html.erb",
|
269
271
|
"test/rails_root/themes/blue/description.txt",
|
270
272
|
"test/rails_root/themes/blue/locales/en.yml",
|
data/config/cms_lite_routes.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
ActionController::Routing::Routes.draw do |map|
|
2
2
|
|
3
3
|
CmsLite.cms_routes.each do |cms_route|
|
4
|
-
map.connect cms_route[:uri],
|
4
|
+
map.connect cms_route[:uri], CmsLite.build_route_options('show_page', cms_route)
|
5
5
|
end
|
6
6
|
|
7
7
|
CmsLite.protected_cms_routes.each do |cms_route|
|
8
|
-
map.connect cms_route[:uri],
|
8
|
+
map.connect cms_route[:uri], CmsLite.build_route_options('show_protected_page', cms_route)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
end
|
data/lib/cms_lite.rb
CHANGED
@@ -7,6 +7,7 @@ class CmsLite
|
|
7
7
|
CONTENT_PATH = 'content'
|
8
8
|
PAGES_PATH = 'pages'
|
9
9
|
PROTECTED_PAGES_PATH = 'protected-pages'
|
10
|
+
ROOT_PATH = 'default' # pages located in this directory will be served off the root of the website. ie http://www.example.com/my-page
|
10
11
|
|
11
12
|
class << self
|
12
13
|
|
@@ -43,10 +44,23 @@ class CmsLite
|
|
43
44
|
path = File.basename(content_item)
|
44
45
|
content_key = content_item.gsub(localization_directory, '')
|
45
46
|
if !content_key.blank?
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
# pages found in the root path get root mapping
|
48
|
+
if path == ROOT_PATH
|
49
|
+
Dir.glob("#{content_item}/*").each do |root_page|
|
50
|
+
root_page_key = File.basename(File.basename(root_page, ".*"), ".*") # for files that look like root.html.erb
|
51
|
+
cms_route = { :uri => "/#{root_page_key}",
|
52
|
+
:content_page => "#{root_page_key}",
|
53
|
+
:content_key => content_key }
|
54
|
+
if !cms_routes.include?(cms_route)
|
55
|
+
cms_routes << cms_route
|
56
|
+
end
|
57
|
+
end
|
58
|
+
else
|
59
|
+
cms_route = { :uri => "/#{path}/*content_page",
|
60
|
+
:content_key => content_key }
|
61
|
+
if !cms_routes.include?(cms_route)
|
62
|
+
cms_routes << cms_route
|
63
|
+
end
|
50
64
|
end
|
51
65
|
end
|
52
66
|
end
|
@@ -55,6 +69,12 @@ class CmsLite
|
|
55
69
|
cms_routes
|
56
70
|
end
|
57
71
|
|
72
|
+
def build_route_options(action, cms_route)
|
73
|
+
options = { :controller => 'cms_lite', :action => action, :content_key => cms_route[:content_key] }
|
74
|
+
options = options.merge(:content_page => cms_route[:content_page]) if cms_route[:content_page]
|
75
|
+
options
|
76
|
+
end
|
77
|
+
|
58
78
|
def content_paths
|
59
79
|
@@content_paths ||= [CONTENT_PATH]
|
60
80
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
hello from the root
|
@@ -9,26 +9,37 @@ Scenario: Anonymous user visits public cms lite page
|
|
9
9
|
When I go to "/open/hello"
|
10
10
|
Then I should see "hello world"
|
11
11
|
|
12
|
+
Scenario: Anonymous user visits root public page
|
13
|
+
Given cms lite file "content/pages/en/default/root.html.erb" contains "hello from the root"
|
14
|
+
And I am not logged in
|
15
|
+
When I go to "/root"
|
16
|
+
Then I should see "hello from the root"
|
17
|
+
|
12
18
|
Scenario: Anonymous user visits public cms lite page in blue theme
|
13
19
|
Given cms lite file "themes/blue/content/pages/en/open/blue.html.erb" contains "blue world"
|
14
20
|
And I am not logged in
|
15
21
|
When I go to "/open/blue"
|
16
22
|
Then I should see "blue world"
|
17
|
-
|
23
|
+
|
24
|
+
Scenario: Anonymous user visits public root page in blue theme
|
25
|
+
Given cms lite file "themes/blue/content/pages/en/default/blue_root.html.erb" contains "blue root"
|
26
|
+
And I am not logged in
|
27
|
+
When I go to "/blue_root"
|
28
|
+
Then I should see "blue root"
|
29
|
+
|
18
30
|
Scenario: Anonymous user visits protected cms lite page
|
19
31
|
Given protected cms lite file "content/protected-pages/en/protected/safe-hello.html.erb" contains "protect hello world"
|
20
32
|
And I am not logged in
|
21
33
|
When I go to "/protected/safe-hello"
|
22
34
|
Then I should see the login
|
23
35
|
And I should see a "notice" flash message
|
24
|
-
|
36
|
+
|
25
37
|
Scenario: Logged in user visits protected cms lite page
|
26
38
|
Given protected cms lite file "content/protected-pages/en/protected/safe-hello.html.erb" contains "protect hello world"
|
27
39
|
And I log in as new user
|
28
40
|
When I go to "/protected/safe-hello"
|
29
41
|
Then I should see "protect hello world"
|
30
|
-
|
31
|
-
|
42
|
+
|
32
43
|
Scenario: Logged in user visits protected cms lite page in red theme
|
33
44
|
Given protected cms lite file "themes/red/content/protected-pages/en/red/red.html.erb" contains "protect red world"
|
34
45
|
And I log in as new user
|
@@ -12,6 +12,13 @@ class CmsLiteControllerTest < ActionController::TestCase
|
|
12
12
|
should_respond_with :success
|
13
13
|
end
|
14
14
|
|
15
|
+
context "unprotected root pages" do
|
16
|
+
setup do
|
17
|
+
get :show_page, :content_key => '/default', :content_page => 'root'
|
18
|
+
end
|
19
|
+
should_respond_with :success
|
20
|
+
end
|
21
|
+
|
15
22
|
context "protected pages"do
|
16
23
|
context "not logged in" do
|
17
24
|
setup do
|
@@ -2,6 +2,7 @@ $:.reject! { |e| e.include? 'TextMate' }
|
|
2
2
|
ENV["RAILS_ENV"] = "test"
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
|
4
4
|
require 'test_help'
|
5
|
+
require 'ruby-debug'
|
5
6
|
gem 'thoughtbot-factory_girl' # from github
|
6
7
|
require 'factory_girl'
|
7
8
|
require 'mocha'
|
@@ -35,4 +36,10 @@ class ActiveSupport::TestCase
|
|
35
36
|
def ensure_flash(val)
|
36
37
|
assert_contains flash.values, val, ", Flash: #{flash.inspect}"
|
37
38
|
end
|
39
|
+
|
40
|
+
# For Selenium
|
41
|
+
# setup do |session|
|
42
|
+
# session.host! "localhost:3001"
|
43
|
+
# end
|
44
|
+
|
38
45
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
blue root
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cms-lite
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Ball
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-07-
|
12
|
+
date: 2009-07-22 00:00:00 -06:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- test/rails_root/config/initializers/requires.rb
|
72
72
|
- test/rails_root/config/initializers/session_store.rb
|
73
73
|
- test/rails_root/config/routes.rb
|
74
|
+
- test/rails_root/content/pages/en/default/root.html.erb
|
74
75
|
- test/rails_root/content/pages/en/demo/hi.html.erb
|
75
76
|
- test/rails_root/content/pages/en/open/hello.html.erb
|
76
77
|
- test/rails_root/content/protected-pages/en/demo/hi.html.erb
|
@@ -278,6 +279,7 @@ files:
|
|
278
279
|
- test/rails_root/test/unit/.keep
|
279
280
|
- test/rails_root/test/unit/cms_lite_test.rb
|
280
281
|
- test/rails_root/themes/blue/content/pages/en/blue/blue.html.erb
|
282
|
+
- test/rails_root/themes/blue/content/pages/en/default/blue_root.html.erb
|
281
283
|
- test/rails_root/themes/blue/content/pages/en/open/blue.html.erb
|
282
284
|
- test/rails_root/themes/blue/description.txt
|
283
285
|
- test/rails_root/themes/blue/locales/en.yml
|