acts_as_static_controller 0.1.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.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Vlad Alive (http://vladalive.com)
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,34 @@
1
+ = ActsAsStaticController
2
+
3
+ Creates StaticPages Controller to serve static pages.
4
+
5
+ == Install
6
+
7
+ Install Ruby Gem:
8
+ gem install acts_as_static_controller
9
+
10
+ Add to /config/environment.rb
11
+ config.gem "acts_as_static_controller"
12
+
13
+ Or install as a plugin:
14
+ ruby script/plugin install git://github.com/vladalive/acts_as_static_controller.git
15
+
16
+ Configure routes:
17
+ /config/routes.rb:
18
+ map.static_pages # place after all routes
19
+
20
+ Create your static pages views at:
21
+ /views/static_pages/**/*
22
+
23
+ Use name convention:
24
+ view: /somepage.html.erb or /somepage/index.html.erb
25
+ route generated: /somepage or /somepage/
26
+ link: link_to static_page("somepage")
27
+
28
+ == Examples
29
+ name.html.erb => /name
30
+ folder/two.html.erb => /folder/two
31
+ folder/two/index.html.erb => /folder/two
32
+
33
+ == Copyright
34
+ Copyright (c) 2009 Vlad Alive (http://vladalive.com), released under the MIT license
@@ -0,0 +1,54 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ PKG_FILES = FileList[
9
+ '[a-zA-Z]*',
10
+ 'app/**/*',
11
+ 'lib/**/*',
12
+ 'tasks/**/*',
13
+ 'test/**/*'
14
+ ]
15
+
16
+ begin
17
+ GEM = "acts_as_static_controller"
18
+ AUTHOR = "Vlad Alive"
19
+ EMAIL = "vladalive@gmail.com"
20
+ SUMMARY = "Rails Plugin: Creates StaticPages Controller to serve static pages."
21
+ HOMEPAGE = "http://github.com/vladalive/acts_as_static_controller"
22
+
23
+ require 'jeweler'
24
+ Jeweler::Tasks.new do |s|
25
+ s.name = GEM
26
+ s.summary = SUMMARY
27
+ s.email = EMAIL
28
+ s.homepage = HOMEPAGE
29
+ s.description = SUMMARY
30
+ s.authors = [AUTHOR]
31
+
32
+ s.require_path = 'lib'
33
+ s.files = PKG_FILES.to_a
34
+ end
35
+ Jeweler::GemcutterTasks.new
36
+ rescue LoadError
37
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
38
+ end
39
+
40
+ desc 'Generate documentation for the acts_as_static_controller plugin.'
41
+ Rake::RDocTask.new do |rdoc|
42
+ rdoc.rdoc_dir = 'rdoc'
43
+ rdoc.title = 'crack'
44
+ rdoc.options << '--line-numbers' << '--inline-source'
45
+ rdoc.rdoc_files.include('README*')
46
+ rdoc.rdoc_files.include('lib/**/*.rb')
47
+ end
48
+
49
+ desc 'Test the acts_as_static_controller plugin.'
50
+ Rake::TestTask.new(:test) do |test|
51
+ test.libs << 'lib' << 'test'
52
+ test.pattern = 'test/**/*_test.rb'
53
+ test.verbose = false
54
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,55 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{acts_as_static_controller}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Vlad Alive"]
12
+ s.date = %q{2009-11-30}
13
+ s.description = %q{Rails Plugin: Creates StaticPages Controller to serve static pages.}
14
+ s.email = %q{vladalive@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ "MIT-LICENSE",
20
+ "README.rdoc",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "acts_as_static_controller.gemspec",
24
+ "app/controllers/static_pages_controller.rb",
25
+ "init.rb",
26
+ "install.rb",
27
+ "lib/acts_as_static_controller.rb",
28
+ "lib/acts_as_static_controller/acts_as_static_controller.rb",
29
+ "lib/acts_as_static_controller/routing.rb",
30
+ "tasks/acts_as_static_controller_tasks.rake",
31
+ "test/acts_as_static_controller_test.rb",
32
+ "test/test_helper.rb",
33
+ "uninstall.rb"
34
+ ]
35
+ s.homepage = %q{http://github.com/vladalive/acts_as_static_controller}
36
+ s.rdoc_options = ["--charset=UTF-8"]
37
+ s.require_paths = ["lib"]
38
+ s.rubygems_version = %q{1.3.5}
39
+ s.summary = %q{Rails Plugin: Creates StaticPages Controller to serve static pages.}
40
+ s.test_files = [
41
+ "test/acts_as_static_controller_test.rb",
42
+ "test/test_helper.rb"
43
+ ]
44
+
45
+ if s.respond_to? :specification_version then
46
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
47
+ s.specification_version = 3
48
+
49
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
50
+ else
51
+ end
52
+ else
53
+ end
54
+ end
55
+
@@ -0,0 +1,5 @@
1
+ class StaticPagesController < ApplicationController
2
+
3
+ acts_as_static_controller
4
+
5
+ end
data/init.rb ADDED
@@ -0,0 +1,2 @@
1
+ # Include hook code here
2
+ require 'acts_as_static_controller'
@@ -0,0 +1 @@
1
+ # Install hook code here
@@ -0,0 +1,2 @@
1
+ require 'acts_as_static_controller/acts_as_static_controller'
2
+ require 'acts_as_static_controller/routing'
@@ -0,0 +1,53 @@
1
+ module ActsAsStaticController
2
+
3
+ def self.included(base)
4
+ base.extend(ClassMethods)
5
+ end
6
+
7
+ module ClassMethods
8
+ def acts_as_static_controller
9
+ include ActsAsStaticController::InstanceMethods
10
+ end
11
+ end
12
+
13
+ module InstanceMethods
14
+
15
+ def index
16
+ if template_exists? path = "#{self.controller_name}/#{params[:path].join('/')}"
17
+ render :template => path
18
+ elsif template_exists? path += "/index"
19
+ render :template => path
20
+ else
21
+ # pass through to the global error page handler
22
+ # method_missing params[:path].to_s
23
+ raise ActionController::RoutingError, params[:path].join('/')
24
+ end
25
+ end
26
+
27
+ protected
28
+
29
+ def each_page
30
+ template_root = "#{RAILS_ROOT}/app/views/#{self.controller_name}"
31
+ excluded_actions = ['.', '..'].concat(self.hidden_actions)
32
+ Dir.foreach(template_root) do |action|
33
+ if !excluded_actions.include? action
34
+ template_path = "#{template_root}/#{action}"
35
+ yield action, template_path
36
+ end
37
+ end
38
+ end
39
+
40
+ private
41
+
42
+ unless ActionController::Base.private_instance_methods.include? 'template_exists?'
43
+ def template_exists?(path)
44
+ self.view_paths.find_template(path, response.template.template_format)
45
+ rescue ActionView::MissingTemplate
46
+ false
47
+ end
48
+ end
49
+
50
+ end
51
+ end
52
+
53
+ ActionController::Base.send(:include, ActsAsStaticController)
@@ -0,0 +1,11 @@
1
+ module ActsAsStaticController #:nodoc:
2
+ module Routing #:nodoc:
3
+ module MapperExtensions
4
+ def static_pages
5
+ @set.add_route("*path", {:controller => "static_pages", :action => "index"})
6
+ end
7
+ end
8
+ end
9
+ end
10
+
11
+ ActionController::Routing::RouteSet::Mapper.send :include, ActsAsStaticController::Routing::MapperExtensions
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :acts_as_static_controller do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class ActsAsStaticControllerTest < 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'
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: acts_as_static_controller
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Vlad Alive
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-30 00:00:00 +03:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: "Rails Plugin: Creates StaticPages Controller to serve static pages."
17
+ email: vladalive@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ files:
25
+ - MIT-LICENSE
26
+ - README.rdoc
27
+ - Rakefile
28
+ - VERSION
29
+ - acts_as_static_controller.gemspec
30
+ - app/controllers/static_pages_controller.rb
31
+ - init.rb
32
+ - install.rb
33
+ - lib/acts_as_static_controller.rb
34
+ - lib/acts_as_static_controller/acts_as_static_controller.rb
35
+ - lib/acts_as_static_controller/routing.rb
36
+ - tasks/acts_as_static_controller_tasks.rake
37
+ - test/acts_as_static_controller_test.rb
38
+ - test/test_helper.rb
39
+ - uninstall.rb
40
+ has_rdoc: true
41
+ homepage: http://github.com/vladalive/acts_as_static_controller
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options:
46
+ - --charset=UTF-8
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ version:
61
+ requirements: []
62
+
63
+ rubyforge_project:
64
+ rubygems_version: 1.3.5
65
+ signing_key:
66
+ specification_version: 3
67
+ summary: "Rails Plugin: Creates StaticPages Controller to serve static pages."
68
+ test_files:
69
+ - test/acts_as_static_controller_test.rb
70
+ - test/test_helper.rb