simple_ssi 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,23 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+ .bundle
21
+ .document
22
+
23
+ ## PROJECT::SPECIFIC
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+ gemspec
3
+
4
+
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 seenmyfate
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.
data/README.md ADDED
@@ -0,0 +1,78 @@
1
+ # simple_ssi
2
+
3
+ Make full use of Nginx Server Side Includes quickly and easily in your Rails 3 app. First up require the gem in your Gemfile:
4
+
5
+ gem 'simple_ssi'
6
+
7
+ Turn on server side includes in nginx
8
+
9
+ location / {
10
+ ssi on;
11
+ #etc
12
+ }
13
+
14
+ In your view, use the helper to specify the action you want to include:
15
+
16
+ <%= ssi :controller => 'users', :action => 'notifications' %>
17
+
18
+ Nginx will now include the HTML created by your action in the page dynamically, so you can cache the rest of the page and still include user specific information.
19
+
20
+ The example above assumes that you have something along these lines in your application:
21
+
22
+ #application_controller.rb
23
+ class ApplicationController < ActionController::Base
24
+
25
+ def current_user
26
+ #some kind current user method
27
+ end
28
+ end
29
+
30
+ #users_controller.rb
31
+ class Users < ApplicationController
32
+ def notifications
33
+ @notifications = current_user.notifications
34
+ end
35
+ end
36
+
37
+ #views/users/notifications.html.erb
38
+
39
+ <% for notification in @notifications %>
40
+ <%# do stuff%>
41
+ <% end %>
42
+
43
+ #config/routes.rb
44
+
45
+ match '/users/notifications' => 'users#notifications'
46
+
47
+ If you want to keep your ssi action separate, and you don't want to have to add a new route everytime, run the simple_ssi generator:
48
+
49
+ rails g simple_ssi
50
+
51
+ Now simply add any methods to app/controllers/ssi_controller.rb, add a view under app/views/ssi and pass the method name to the helper:
52
+
53
+ <%= ssi :notifications %>
54
+
55
+ * * *
56
+ To do:
57
+
58
+ * Better readme
59
+ * Example app
60
+ * Benchmarks
61
+ * Apache support
62
+
63
+
64
+ * * *
65
+
66
+ Note on Patches/Pull Requests
67
+
68
+ * Fork the project.
69
+ * Make your feature addition or bug fix.
70
+ * Add tests for it. This is important so I don't break it in a
71
+ future version unintentionally.
72
+ * Commit, do not mess with rakefile, version, or history.
73
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
74
+ * Send me a pull request. Bonus points for topic branches.
75
+
76
+ * * *
77
+
78
+ Copyright (c) 2010 seenmyfate. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "simple_ssi"
8
+ gem.summary = %Q{Easily add nginx sever side includes to you rails 3 app}
9
+ gem.description = %Q{Easily add nginx sever side includes to you rails 3 app}
10
+ gem.email = "seenmyfate@gmail.com"
11
+ gem.homepage = "http://github.com/seenmyfate/simple_ssi"
12
+ gem.authors = ["seenmyfate"]
13
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
14
+ end
15
+ Jeweler::GemcutterTasks.new
16
+ rescue LoadError
17
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
18
+ end
19
+
20
+ require 'rake/testtask'
21
+ Rake::TestTask.new(:test) do |test|
22
+ test.libs << 'lib' << 'test'
23
+ test.pattern = 'test/**/test_*.rb'
24
+ test.verbose = true
25
+ end
26
+
27
+ begin
28
+ require 'rcov/rcovtask'
29
+ Rcov::RcovTask.new do |test|
30
+ test.libs << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+ rescue LoadError
35
+ task :rcov do
36
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
37
+ end
38
+ end
39
+
40
+ task :test => :check_dependencies
41
+
42
+ task :default => :test
43
+
44
+ require 'rake/rdoctask'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "simple_ssi #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.4
@@ -0,0 +1,3 @@
1
+ class SsiController < ApplicationController
2
+
3
+ end
@@ -0,0 +1,13 @@
1
+ module SsiHelper
2
+
3
+ def ssi(path={})
4
+ if path.is_a? Hash
5
+ url = url_for(path)
6
+ elsif path.is_a? Symbol
7
+ url = url_for(:controller => "ssi", :action => path.to_s)
8
+ elsif path.is_a? String
9
+ url = url_for(:controller => "ssi", :action => path)
10
+ end
11
+ "<!--# include file='#{url}' -->".html_safe
12
+ end
13
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ Rails.application.routes.draw do |map|
2
+ match 'tom' => 'tom#index'
3
+ match 'ssi(/:action(/:id(.:format)))', :controller => 'ssi'
4
+ end
@@ -0,0 +1,5 @@
1
+ Description:
2
+ Creates an SsiController in your application
3
+
4
+ Example:
5
+ rails generate nginx_ssi
@@ -0,0 +1,9 @@
1
+ class SimpleSsiGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('../templates', __FILE__)
3
+
4
+ def ssi
5
+ copy_file "ssi_controller.rb", 'app/controllers/ssi_controller.rb'
6
+ empty_directory "app/controllers/ssi"
7
+ empty_directory "app/views/ssi"
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ class SsiController < ApplicationController
2
+ #Add your endpoints here
3
+ end
data/lib/simple_ssi.rb ADDED
@@ -0,0 +1,8 @@
1
+ require 'simple_ssi'
2
+ require 'rails'
3
+ module SimpleSsi
4
+ #
5
+ # Nginx Server Side Includes
6
+ #
7
+ require 'simple_ssi/engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
8
+ end
@@ -0,0 +1,5 @@
1
+ class Engine < Rails::Engine
2
+ initializer 'my_engine.helper' do |app|
3
+ ActionView::Base.send :include, SsiHelper
4
+ end
5
+ end
@@ -0,0 +1,52 @@
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{simple_ssi}
8
+ s.version = "0.0.4"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["seenmyfate"]
12
+ s.date = %q{2010-11-07}
13
+ s.description = %q{Easily add nginx sever side includes to you rails 3 app}
14
+ s.email = %q{seenmyfate@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".gitignore",
21
+ "Gemfile",
22
+ "LICENSE",
23
+ "README.md",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "app/controllers/ssi_controller.rb",
27
+ "app/helpers/ssi_helper.rb",
28
+ "config/routes.rb",
29
+ "lib/generators/simple_ssi/USAGE",
30
+ "lib/generators/simple_ssi/simple_ssi_generator.rb",
31
+ "lib/generators/simple_ssi/templates/ssi_controller.rb",
32
+ "lib/simple_ssi.rb",
33
+ "lib/simple_ssi/engine.rb",
34
+ "simple_ssi.gemspec"
35
+ ]
36
+ s.homepage = %q{http://github.com/seenmyfate/simple_ssi}
37
+ s.rdoc_options = ["--charset=UTF-8"]
38
+ s.require_paths = ["lib"]
39
+ s.rubygems_version = %q{1.3.7}
40
+ s.summary = %q{Easily add nginx sever side includes to you rails 3 app}
41
+
42
+ if s.respond_to? :specification_version then
43
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ else
48
+ end
49
+ else
50
+ end
51
+ end
52
+
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: simple_ssi
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 4
10
+ version: 0.0.4
11
+ platform: ruby
12
+ authors:
13
+ - seenmyfate
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-07 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Easily add nginx sever side includes to you rails 3 app
23
+ email: seenmyfate@gmail.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - LICENSE
30
+ - README.md
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - VERSION
38
+ - app/controllers/ssi_controller.rb
39
+ - app/helpers/ssi_helper.rb
40
+ - config/routes.rb
41
+ - lib/generators/simple_ssi/USAGE
42
+ - lib/generators/simple_ssi/simple_ssi_generator.rb
43
+ - lib/generators/simple_ssi/templates/ssi_controller.rb
44
+ - lib/simple_ssi.rb
45
+ - lib/simple_ssi/engine.rb
46
+ - simple_ssi.gemspec
47
+ has_rdoc: true
48
+ homepage: http://github.com/seenmyfate/simple_ssi
49
+ licenses: []
50
+
51
+ post_install_message:
52
+ rdoc_options:
53
+ - --charset=UTF-8
54
+ require_paths:
55
+ - lib
56
+ required_ruby_version: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ hash: 3
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ requirements: []
75
+
76
+ rubyforge_project:
77
+ rubygems_version: 1.3.7
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: Easily add nginx sever side includes to you rails 3 app
81
+ test_files: []
82
+