pagelime-rails 0.3.0 → 0.4.0

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: 89efb96d666bc2018fa4afb670fb9a3280cbfb76
4
- data.tar.gz: 44b9b84b7e0f39348865dbe6438a5fd356f718e4
3
+ metadata.gz: 98a56419e15fd1630981b3d13471398bf07530a6
4
+ data.tar.gz: d05819fae445c52f43e2b13d1913206cd013f2f0
5
5
  SHA512:
6
- metadata.gz: 93874dc43eb8964a0f5f8389555c28ffc22717d9c7e925b7c0dda9a8a5ca525056e1f369c7911cab2d12b702bbd151f48fca618ce5e05796bf9981e9775e6c53
7
- data.tar.gz: bb1dc6ab448bacbf48b70721009190900621e9639a8d352b2de1d8fb4bda32eb4e7f91025a87257ce256d77cbc7980f2b5935b7ead96b9572b4b02dfae1c04aa
6
+ metadata.gz: 5ca9ada4e2d378e325a4513d88378b1ad9ad56ee3119bc0199622d16fa2d3a8948cca09a86ef94776eb9c17a8c490bb74d4eb1f94475b0436f9d9aa7c786a702
7
+ data.tar.gz: 1d1392d3ce7db894119adbc309f07da79e153d6b0f4334ae7fd1e46242ad752cb1a3609602142ffd784607c2f82143d7e9e25797d2121d1cace2932cd4f7a303
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source "http://rubygems.org"
2
2
  # Add dependencies required to use your gem here.
3
3
  # Example:
4
4
 
5
- gem 'pagelime-rack', '>= 0.3.0'
5
+ gem 'pagelime-rack', '>= 0.4.3'
6
6
 
7
7
  # Add dependencies to develop your gem here.
8
8
  # Include everything needed to run rake, tests, features, etc.
data/README.md CHANGED
@@ -67,6 +67,17 @@ You can pass an `:except` parameter just like with a filter like so:
67
67
 
68
68
  acts_as_cms_editable :except => :index
69
69
 
70
+ Optionally, enable caching and logging:
71
+
72
+ Pagelime.configure do |config|
73
+ # object that responds to `fetch` and `delete`
74
+ config.cache = Rails.cache
75
+ # options passed to `fetch(key, options = {}, &block)`
76
+ config.cache_fetch_options = { :expires_in => 1.year }
77
+ # any standard logger
78
+ config.logger = Rails.logger
79
+ end
80
+
70
81
  #### Only for Rails 2.3.x
71
82
 
72
83
  Add the plugin routes to your `config/routes.rb` configuration:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
@@ -6,12 +6,22 @@ Pagelime.logger.debug "PAGELIME CMS RAILS PLUGIN: pagelime-rails gem loaded"
6
6
 
7
7
  # start plugin
8
8
  if Rails::VERSION::MAJOR == 2
9
- require_relative 'pagelime/rails/routing_extensions'
9
+
10
+ # TODO: Use pagelime-rack for Rails 2.3+ instead of routes and controllers
11
+
12
+ require_relative 'pagelime/rails2/routing_extensions'
10
13
 
11
14
  ActionController::Routing::RouteSet::Mapper.send :include, ::Pagelime::Rails::RoutingExtensions
12
- # below is not needed in Rails 2 as you can use the map.cms_routes from the routing_extensions
13
- # require File.join(File.dirname(__FILE__), "/../config/routes.rb")
15
+
16
+ controllers_path = File.expand_path File.join(File.dirname(__FILE__), 'pagelime', 'rails2', 'controllers')
17
+
18
+ # add dependencies to load paths
19
+ $LOAD_PATH << controllers_path
20
+ load_paths << controllers_path
21
+ load_once_paths.delete(controllers_path)
22
+
14
23
  Pagelime::Rails.initialize!
24
+
15
25
  elsif Rails::VERSION::MAJOR >= 3
16
26
  require_relative 'pagelime/rails/engine'
17
27
  end
@@ -5,36 +5,20 @@ module Pagelime
5
5
 
6
6
  ::Rails.logger.debug "PAGELIME CMS RAILS PLUGIN: initializing plugin"
7
7
 
8
- app_path_relative = File.join('..', '..', 'app')
9
- app_path = File.expand_path File.join(File.dirname(__FILE__), app_path_relative)
10
-
11
- # add dependencies to load paths
12
- %w{ models controllers helpers }.each do |dir|
13
- path = File.join(app_path, dir)
14
- $LOAD_PATH << path
15
-
16
- if ::Rails::VERSION::MAJOR == 2
17
- ActiveSupport::Dependencies.load_paths << path
18
- ActiveSupport::Dependencies.load_once_paths.delete(path)
19
- elsif ::Rails::VERSION::MAJOR >= 3
20
- ActiveSupport::Dependencies.autoload_paths << path
21
- ActiveSupport::Dependencies.autoload_once_paths.delete(path)
22
- end
23
- end
24
-
25
8
  # wire controller extensions
26
9
  require_relative 'rails/controller_extensions'
27
10
  ActionController::Base.extend ControllerExtensions
28
11
 
29
12
  # wire helper
30
- require_relative File.join('.', app_path_relative, "helpers", "pagelime_helper")
31
- ActionView::Base.send :include, PagelimeHelper
13
+ require_relative 'rails/view_helper'
14
+ ActionView::Base.send :include, ViewHelper
32
15
 
33
16
  configure_pagelime!
34
17
  end
35
18
 
36
19
  def configure_pagelime!
37
20
  ::Pagelime.configure do |config|
21
+ config.toggle_processing = "per_request"
38
22
  config.logger = ::Rails.logger
39
23
  config.cache = ::Rails.cache
40
24
  config.cache_fetch_options = { :expires_in => 1.year }
@@ -11,8 +11,8 @@ module Pagelime
11
11
  def cms_process_rendered_body
12
12
  ::Rails.logger.debug "PAGELIME CMS RAILS PLUGIN: Processing response body in controller"
13
13
 
14
- # parse response body, cache, and use result as response body
15
- response.body = Pagelime.process_page(response.body, request.path)
14
+ # tell pagelime-rack to parse response body, cache, and use result as response body
15
+ ::Rack::Pagelime.enable_processing_for_request(request.env)
16
16
  end
17
17
  end
18
18
 
@@ -3,9 +3,11 @@ module Pagelime
3
3
  module Rails
4
4
  class Engine < ::Rails::Engine
5
5
  engine_name :pagelime
6
- # paths["config/routes"] << 'config/routes.rb'
6
+
7
7
  initializer "pagelime.initialize" do |app|
8
8
  ::Pagelime::Rails.initialize!
9
+
10
+ app.middleware.use Rack::Pagelime
9
11
  end
10
12
  end
11
13
  end
@@ -0,0 +1,20 @@
1
+ module Pagelime
2
+ module Rails
3
+ module ViewHelper
4
+
5
+ def cms_content(&block)
6
+
7
+ # TODO: How to let pagelime-rack handle this?
8
+
9
+ # the block contents loaded into a variable
10
+ editable_content = capture(&block)
11
+ processed_html = ::Pagelime.process_region(editable_content, request.path)
12
+
13
+ # output the final content
14
+ concat(processed_html)
15
+
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ class PagelimeReceiverController < ApplicationController
2
+
3
+ def index
4
+ ::Rails.logger.debug "PAGELIME RAILS RECEIVER index"
5
+ status, headers, body = Rack::Pagelime.handle_status_check(request.env)
6
+
7
+ render :inline => body.string, :status => status
8
+ end
9
+
10
+ def after_publish_callback
11
+ ::Rails.logger.debug "PAGELIME RAILS RECEIVER after_publish_callback"
12
+ status, headers, body = Rack::Pagelime.handle_publish_callback(request.env)
13
+
14
+ render :inline => body.string, :status => status
15
+ end
16
+ end
@@ -1,5 +1,5 @@
1
1
  module Pagelime #:nodoc:
2
- module Rails #:nodoc:
2
+ module Rails2 #:nodoc:
3
3
  module RoutingExtensions
4
4
  def cms_routes
5
5
  @set.add_route "/pagelime/:action", :controller => "pagelime_receiver"
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "pagelime-rails"
8
- s.version = "0.3.0"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Emil Anticevic", "Joel Van Horn"]
12
- s.date = "2013-09-11"
12
+ s.date = "2013-09-24"
13
13
  s.description = ""
14
14
  s.email = "emil@pagelime.com"
15
15
  s.extra_rdoc_files = [
@@ -22,16 +22,15 @@ Gem::Specification.new do |s|
22
22
  "README.md",
23
23
  "Rakefile",
24
24
  "VERSION",
25
- "app/controllers/pagelime_receiver_controller.rb",
26
- "app/helpers/pagelime_helper.rb",
27
- "config/routes.rb",
28
25
  "init.rb",
29
26
  "install.rb",
30
27
  "lib/pagelime-rails.rb",
31
28
  "lib/pagelime/rails.rb",
32
29
  "lib/pagelime/rails/controller_extensions.rb",
33
30
  "lib/pagelime/rails/engine.rb",
34
- "lib/pagelime/rails/routing_extensions.rb",
31
+ "lib/pagelime/rails/view_helper.rb",
32
+ "lib/pagelime/rails2/controllers/pagelime_receiver_controller.rb",
33
+ "lib/pagelime/rails2/routing_extensions.rb",
35
34
  "lib/tasks/pagelime.rake",
36
35
  "pagelime-rails.gemspec",
37
36
  "rails/init.rb",
@@ -49,16 +48,16 @@ Gem::Specification.new do |s|
49
48
  s.specification_version = 4
50
49
 
51
50
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
- s.add_runtime_dependency(%q<pagelime-rack>, [">= 0.3.0"])
51
+ s.add_runtime_dependency(%q<pagelime-rack>, [">= 0.4.3"])
53
52
  s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
54
53
  s.add_development_dependency(%q<jeweler>, [">= 1.6.4"])
55
54
  else
56
- s.add_dependency(%q<pagelime-rack>, [">= 0.3.0"])
55
+ s.add_dependency(%q<pagelime-rack>, [">= 0.4.3"])
57
56
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
58
57
  s.add_dependency(%q<jeweler>, [">= 1.6.4"])
59
58
  end
60
59
  else
61
- s.add_dependency(%q<pagelime-rack>, [">= 0.3.0"])
60
+ s.add_dependency(%q<pagelime-rack>, [">= 0.4.3"])
62
61
  s.add_dependency(%q<bundler>, [">= 1.0.0"])
63
62
  s.add_dependency(%q<jeweler>, [">= 1.6.4"])
64
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagelime-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emil Anticevic
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-11 00:00:00.000000000 Z
12
+ date: 2013-09-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pagelime-rack
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - '>='
19
19
  - !ruby/object:Gem::Version
20
- version: 0.3.0
20
+ version: 0.4.3
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '>='
26
26
  - !ruby/object:Gem::Version
27
- version: 0.3.0
27
+ version: 0.4.3
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: bundler
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -66,16 +66,15 @@ files:
66
66
  - README.md
67
67
  - Rakefile
68
68
  - VERSION
69
- - app/controllers/pagelime_receiver_controller.rb
70
- - app/helpers/pagelime_helper.rb
71
- - config/routes.rb
72
69
  - init.rb
73
70
  - install.rb
74
71
  - lib/pagelime-rails.rb
75
72
  - lib/pagelime/rails.rb
76
73
  - lib/pagelime/rails/controller_extensions.rb
77
74
  - lib/pagelime/rails/engine.rb
78
- - lib/pagelime/rails/routing_extensions.rb
75
+ - lib/pagelime/rails/view_helper.rb
76
+ - lib/pagelime/rails2/controllers/pagelime_receiver_controller.rb
77
+ - lib/pagelime/rails2/routing_extensions.rb
79
78
  - lib/tasks/pagelime.rake
80
79
  - pagelime-rails.gemspec
81
80
  - rails/init.rb
@@ -1,13 +0,0 @@
1
- class PagelimeReceiverController < ApplicationController
2
-
3
- def index
4
- render :inline => "working", :status => 200
5
- end
6
-
7
- def after_publish_callback
8
- Pagelime.cache.clear_page params[:path]
9
- Pagelime.cache.clear_shared
10
-
11
- render :inline => "cache cleared", :status => 200
12
- end
13
- end
@@ -1,13 +0,0 @@
1
- module PagelimeHelper
2
-
3
- def cms_content(&block)
4
- # the block contents loaded into a variable
5
- input_content = capture(&block)
6
- html = ::Pagelime.process_region(input_content, request.path)
7
- # output the final content
8
- concat(html)
9
- # raw capture(&block) + "<div>hello world</div>"
10
- # raw "BLA!";
11
- end
12
-
13
- end
data/config/routes.rb DELETED
@@ -1,32 +0,0 @@
1
-
2
- if Rails::VERSION::MAJOR == 2
3
-
4
- ActionController::Routing::Routes.draw do |map|
5
- Rails.logger.debug "PAGELIME CMS RAILS PLUGIN: setting up rails 2 routes"
6
-
7
- map.connect "pagelime/:action", :controller => :pagelime_receiver_controller
8
- end
9
-
10
- elsif Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 0
11
-
12
- Rails.application.routes.draw do
13
- Rails.logger.debug "PAGELIME CMS RAILS PLUGIN: setting up rails 3 routes"
14
-
15
- match 'pagelime/:action' => 'pagelime_receiver'
16
- end
17
-
18
- elsif Rails::VERSION::MAJOR >= 3
19
-
20
- Pagelime::Rails::Engine.routes.draw do
21
- Rails.logger.debug "PAGELIME CMS RAILS PLUGIN: setting up rails 3.1+ routes"
22
-
23
- get 'pagelime/:action' => 'pagelime_receiver'
24
- end
25
-
26
- Rails.application.routes.draw do
27
- Rails.logger.debug "PAGELIME CMS RAILS PLUGIN: mounting Pagelime in rails 3.1+ routes"
28
-
29
- mount Pagelime::Rails::Engine => "/"
30
- end
31
-
32
- end