jbasdf-cms_lite 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Justin Ball
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,42 @@
1
+ CMS Lite Engine
2
+ =================
3
+ CMS Lite makes it simple to add lots of content to your rails application without having to add a full CMS system. Frequently,
4
+ the parties involved in developing your website will have enough technical knowledge to be able to build html pages and add
5
+ content, but not be experienced enough to build out new controllers and deal with rendering the appropriate templates. CMS Lite
6
+ addresses this need by centralizing all content into a 'content' subdirectory. Tell
7
+ your content developers to put their code into /content/pages/en or /content/protected-page/en (for content that requires a login)
8
+ and you're ready to go.
9
+
10
+ Installation
11
+ =================
12
+ Install the gem:
13
+
14
+ CMS Lite Requires a login method called 'login_required' that will be called in the event the user is not logged in and
15
+ attempts to load a protected page.
16
+
17
+ Routes:
18
+ ------------------
19
+ CMS Lite will add a route for each subdirectory found under /content/pages/en.
20
+
21
+
22
+ Example:
23
+ - - -
24
+ Place test_me.html into /content/pages/en/cms/test_me.html
25
+ Visit
26
+ http: http://localhost:3000/cms/test_me
27
+
28
+ The Basics
29
+ =================
30
+ The cms lite plugin provides basic template rendering functionality.
31
+ Any templates added to /content/pages will be publicly visible.
32
+ Any pages added to /content/protected-pages will require a login.
33
+ CMS lite will use the layout specified in application_controller.rb
34
+
35
+
36
+ Advanced Stuff
37
+ =================
38
+ The CMS Lite engine can display localization content. To add spanish simply add an 'es' directory next to the 'en' directory
39
+ and then copy your content pages to that directory.
40
+
41
+
42
+ Copyright (c) 2009 Justin Ball, released under the MIT license
@@ -0,0 +1,37 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test the cms_lite plugin.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.libs << 'test'
12
+ t.pattern = 'test/**/*_test.rb'
13
+ t.verbose = true
14
+ end
15
+
16
+ desc 'Generate documentation for the cms_lite plugin.'
17
+ Rake::RDocTask.new(:rdoc) do |rdoc|
18
+ rdoc.rdoc_dir = 'rdoc'
19
+ rdoc.title = 'CmsLite'
20
+ rdoc.options << '--line-numbers' << '--inline-source'
21
+ rdoc.rdoc_files.include('README')
22
+ rdoc.rdoc_files.include('lib/**/*.rb')
23
+ end
24
+
25
+ begin
26
+ require 'jeweler'
27
+ Jeweler::Tasks.new do |gemspec|
28
+ gemspec.name = "cms_lite"
29
+ gemspec.summary = "Simple CMS system"
30
+ gemspec.email = "justinball@gmail.com.com"
31
+ gemspec.homepage = "http://github.com/jbasdf/cms_lite"
32
+ gemspec.description = "CMS gem that makes it simple to interact with your content developers by serving pages from '/content'."
33
+ gemspec.authors = ["Justin Ball"]
34
+ end
35
+ rescue LoadError
36
+ puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
37
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -0,0 +1,30 @@
1
+ class CmsLiteController < ApplicationController
2
+
3
+ before_filter :login_required, :only => [:show_protected_page]
4
+
5
+ def show_page
6
+ render_content_page(CmsLite::CMS_LITE_PAGES_PATH)
7
+ end
8
+
9
+ def show_protected_page
10
+ render_content_page(CmsLite::CMS_LITE_PROTECTED_PAGES_PATH)
11
+ end
12
+
13
+ def render_content_page(cms_lite_path, request_layout = '')
14
+ path = File.join(RAILS_ROOT, CmsLite::CMS_LITE_CONTENT_PATH, cms_lite_path, I18n.locale.to_s, params[:content_key], params[:content_page].join('/'))
15
+ format = params[:format] || 'htm'
16
+ content_page = Dir.glob("/#{path}.#{format}").first
17
+ content_page = Dir.glob("/#{path}").first if content_page.nil?
18
+ content_page = Dir.glob("/#{path}.*").first if content_page.nil?
19
+ raise CmsLiteExceptions::MissingTemplateError, "Could not find template for: '#{path}'" if content_page.nil?
20
+ respond_to do |format|
21
+ format.html { render :file => content_page }
22
+ format.js { render :file => content_page, :layout => false }
23
+ format.xml { render :file => content_page, :layout => false }
24
+ end
25
+ rescue CmsLiteExceptions::MissingTemplateError => ex
26
+
27
+ render :file => "#{RAILS_ROOT}/public/404.html", :status => 404
28
+ end
29
+
30
+ end
@@ -0,0 +1,51 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{cms_lite}
5
+ s.version = "0.1.1"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Justin Ball"]
9
+ s.date = %q{2009-05-06}
10
+ s.description = %q{CMS gem that makes it simple to interact with your content developers by serving pages from '/content'.}
11
+ s.email = %q{justinball@gmail.com.com}
12
+ s.extra_rdoc_files = [
13
+ "README.markdown"
14
+ ]
15
+ s.files = [
16
+ "MIT-LICENSE",
17
+ "README.markdown",
18
+ "Rakefile",
19
+ "VERSION",
20
+ "app/controllers/cms_lite_controller.rb",
21
+ "cms_lite.gemspec",
22
+ "config/cms_lite_routes.rb",
23
+ "lib/cms_lite.rb",
24
+ "lib/cms_lite_exceptions.rb",
25
+ "rails/init.rb",
26
+ "tasks/cms_lite_tasks.rake",
27
+ "test/cms_lite_test.rb",
28
+ "test/test_helper.rb",
29
+ "uninstall.rb"
30
+ ]
31
+ s.has_rdoc = true
32
+ s.homepage = %q{http://github.com/jbasdf/cms_lite}
33
+ s.rdoc_options = ["--charset=UTF-8"]
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = %q{1.3.1}
36
+ s.summary = %q{Simple CMS system}
37
+ s.test_files = [
38
+ "test/cms_lite_test.rb",
39
+ "test/test_helper.rb"
40
+ ]
41
+
42
+ if s.respond_to? :specification_version then
43
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
+ s.specification_version = 2
45
+
46
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
47
+ else
48
+ end
49
+ else
50
+ end
51
+ end
@@ -0,0 +1,11 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+
3
+ CmsLite.cms_routes.each do |cms_route|
4
+ map.connect cms_route[:uri], :controller => 'cms_lite', :action => 'show_page', :content_key => cms_route[:content_key]
5
+ end
6
+
7
+ CmsLite.protected_cms_routes.each do |cms_route|
8
+ map.connect cms_route[:uri], :controller => 'cms_lite', :action => 'show_protected_page', :content_key => cms_route[:content_key]
9
+ end
10
+
11
+ end
@@ -0,0 +1,96 @@
1
+ require 'cms_lite_exceptions'
2
+
3
+ class ActionController::Routing::RouteSet
4
+ def load_routes_with_cms_lite!
5
+ cms_lite_routes = File.join(File.dirname(__FILE__), *%w[.. config cms_lite_routes.rb])
6
+ add_configuration_file(cms_lite_routes) unless configuration_files.include? cms_lite_routes
7
+ load_routes_without_cms_lite!
8
+ end
9
+
10
+ alias_method_chain :load_routes!, :cms_lite
11
+ end
12
+
13
+ class CmsLite
14
+ CMS_LITE_CONTENT_PATH = 'content'
15
+ CMS_LITE_PAGES_PATH = 'pages'
16
+ CMS_LITE_PROTECTED_PAGES_PATH = 'protected-pages'
17
+ class << self
18
+
19
+ def cms_routes
20
+ get_cms_routes(CMS_LITE_PAGES_PATH)
21
+ end
22
+
23
+ def protected_cms_routes
24
+ get_cms_routes(CMS_LITE_PROTECTED_PAGES_PATH)
25
+ end
26
+
27
+ def get_cms_routes(pages_path)
28
+ cms_routes = []
29
+ cms_lite_page_path = File.join(RAILS_ROOT, CMS_LITE_CONTENT_PATH, pages_path)
30
+ Dir.glob("#{cms_lite_page_path}/*").each do |localization_directory|
31
+ if File.directory?(localization_directory)
32
+ Dir.glob("#{localization_directory}/*").each do |content_item|
33
+ path = File.basename(content_item)
34
+ content_key = content_item.gsub(localization_directory, '')
35
+ cms_routes << { :uri => "/#{path}/*content_page",
36
+ :content_key => content_key }
37
+ end
38
+ end
39
+ end
40
+ cms_routes
41
+ end
42
+
43
+ end
44
+ end
45
+
46
+ # module CmsLite
47
+ #
48
+ # class << self
49
+ #
50
+ # def enable
51
+ #
52
+ # end
53
+ #
54
+ # def add_route(path, route_options)
55
+ # map.connect page.url, :controller => 'pages', :action => 'show', :id => page
56
+ # new_route = ActionController::Routing::Routes.builder.build(path, route_options)
57
+ # if !ActionController::Routing::Routes.routes.include?(new_route)
58
+ # puts new_route
59
+ # ActionController::Routing::Routes.routes.insert(0, new_route)
60
+ # end
61
+ # end
62
+ #
63
+ # end
64
+ # end
65
+
66
+ #CmsLite::enable
67
+
68
+
69
+ #ActionController::Base.send :include, ActionController::CmsLite
70
+
71
+ # map.content '/content/*content_page', :controller => 'cms_lite', :action => 'show_page'
72
+ #
73
+ # map.genealogy_records '/genealogy-records/*content_page', :controller => 'cms_lite', :action => 'show_page'
74
+ # map.help '/help/*content_page', :controller => 'cms_lite', :action => 'show_page'
75
+ # map.protected_page '/protected/*content_page', :controller => 'cms_lite', :action => 'show_protected_page'
76
+
77
+ # map.content '/content/*content_page', :controller => 'cms_lite', :action => 'show_page'
78
+ # map.protected_page '/protected/*content_page', :controller => 'cms_lite', :action => 'show_protected_page'
79
+ #
80
+
81
+ # path = File.join(base_path, page_path, I18n.locale.to_s, url_key)
82
+ # content_page = Dir.glob("/#{path}.*").first
83
+
84
+
85
+
86
+ # ActionController::Routing::RouteSet.add_route("/#{root_path}/*content_page", { :controller => 'cms_lite',
87
+ # :action => 'show_page',
88
+ # :content_directory => root_path,
89
+ # :protect => content_directory.include?('protected') })
90
+ # new_route = ActionController::Routing::Routes.builder.build(name, route_options)
91
+ # ActionController::Routing::Routes.routes.insert(0, new_route)
92
+
93
+ # config.to_prepare do
94
+ # ApplicationController.helper(AnnouncementsHelper)
95
+ # end
96
+
@@ -0,0 +1,3 @@
1
+ module CmsLiteExceptions
2
+ class MissingTemplateError < StandardError; end
3
+ end
@@ -0,0 +1 @@
1
+ require 'cms_lite'
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :cms_lite do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class CmsLiteEngineTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'active_support/test_case'
File without changes
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jbasdf-cms_lite
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Justin Ball
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-06 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: CMS gem that makes it simple to interact with your content developers by serving pages from '/content'.
17
+ email: justinball@gmail.com.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.markdown
24
+ files:
25
+ - MIT-LICENSE
26
+ - README.markdown
27
+ - Rakefile
28
+ - VERSION
29
+ - app/controllers/cms_lite_controller.rb
30
+ - cms_lite.gemspec
31
+ - config/cms_lite_routes.rb
32
+ - lib/cms_lite.rb
33
+ - lib/cms_lite_exceptions.rb
34
+ - rails/init.rb
35
+ - tasks/cms_lite_tasks.rake
36
+ - test/cms_lite_test.rb
37
+ - test/test_helper.rb
38
+ - uninstall.rb
39
+ has_rdoc: true
40
+ homepage: http://github.com/jbasdf/cms_lite
41
+ post_install_message:
42
+ rdoc_options:
43
+ - --charset=UTF-8
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ version:
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ requirements: []
59
+
60
+ rubyforge_project:
61
+ rubygems_version: 1.2.0
62
+ signing_key:
63
+ specification_version: 2
64
+ summary: Simple CMS system
65
+ test_files:
66
+ - test/cms_lite_test.rb
67
+ - test/test_helper.rb