pagelime-rails 0.2.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.
- checksums.yaml +15 -0
- data/Gemfile +13 -0
- data/Heroku.md +95 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +48 -0
- data/Readme.md +81 -0
- data/VERSION +1 -0
- data/app/controllers/pagelime_receiver_controller.rb +95 -0
- data/app/helpers/pagelime_helper.rb +13 -0
- data/config/routes.rb +29 -0
- data/init.rb +2 -0
- data/install.rb +1 -0
- data/lib/pagelime-rails.rb +21 -0
- data/lib/pagelime/rails.rb +38 -0
- data/lib/pagelime/rails/controller_extensions.rb +21 -0
- data/lib/pagelime/rails/engine.rb +12 -0
- data/lib/pagelime/rails/routing_extensions.rb +9 -0
- data/lib/pagelime/s3_rails_cache.rb +45 -0
- data/lib/tasks/pagelime.rake +19 -0
- data/pagelime-rails.gemspec +64 -0
- data/rails/init.rb +2 -0
- data/test/pagelime_test.rb +8 -0
- data/test/test_helper.rb +3 -0
- data/uninstall.rb +1 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
OWI4NGZiMTQ5ZGY4YWE4NmQxN2I3YzFkNzYzMzJhYTNjMDEyMTA4Yw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
OGMxNTZlMThjZjM0MjEyNWFlMmRiM2E5YjVhM2I2NzI3MGQzN2FkYg==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
OTg4MjQwMTEwZGMyNTFjYjNkNjc1NTU1OWNkMThmMTg1NDZhYWU4YjZmMmRh
|
10
|
+
M2M1MzY3MWUyOTUyZWU5YzEwODc2YWUzZDFlNmUwMjU4Mjg5Y2UwNzJiYmVm
|
11
|
+
OTUzMGQ5ZmUyOWMyMGM3MjEyMDU3NTMwMjExYjQwOWE2M2U3YzE=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NDE0OWZiZDA5ZjNiNzM3NzI3M2JjMjQ4ZDllN2ExMTc4OWFlNDdiYzkxNzhj
|
14
|
+
ZWQ4MTM1MmI0ZmFkOGUyMTNhMTE5MzMxMGJlOTljMGY5ZjI3ZTViYTZiYjc4
|
15
|
+
MDg1ZTRiMzZmNTIxYmZhMjg5YmM2M2YwNzcxYWI3ZGZjNzNkOGU=
|
data/Gemfile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
|
5
|
+
gem 'pagelime-rack', '>= 0.2.0'
|
6
|
+
|
7
|
+
# Add dependencies to develop your gem here.
|
8
|
+
# Include everything needed to run rake, tests, features, etc.
|
9
|
+
group :development do
|
10
|
+
gem "bundler", ">= 1.0.0"
|
11
|
+
gem "jeweler", ">= 1.6.4"
|
12
|
+
#gem "rcov", ">= 0"
|
13
|
+
end
|
data/Heroku.md
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
Pagelime CMS Addon
|
2
|
+
=====================
|
3
|
+
|
4
|
+
The CMS add-on enables the Pagelime CMS for your app, and allows your team to edit content on your Heroku app without commiting new code, modifying the database, or impacting the release process.
|
5
|
+
|
6
|
+
Pagelime is a simple CMS service that allows you to define editable regions in your content without installing any software on your site or app. Simply add a `class="cms-editable"` to any HTML element, and log-in to the Pagelime CMS service to edit your content and images with a nice UI. We host all of the code, content, and data until you publish a page. When you publish a page, we push the content to your site/app via secure FTP or web APIs.
|
7
|
+
|
8
|
+
In your views, make any element editable just by adding a CSS class:
|
9
|
+
`<div id="my_content" class="cms-editable">This content is now editable in Pagelime... no code... no databases... no fuss</div>`
|
10
|
+
|
11
|
+
Installing the Addon
|
12
|
+
---------------
|
13
|
+
|
14
|
+
Run `heroku addons:add pagelime` from the command line. After setup, to access the CMS, find the menu item labeled "Pagelime" will appear under the addons dropdown for your app.
|
15
|
+
|
16
|
+
Getting Started
|
17
|
+
---------------
|
18
|
+
|
19
|
+
### Step 1.
|
20
|
+
Require the **pagelime_rails** gem
|
21
|
+
|
22
|
+
#### For Rails 2
|
23
|
+
edit your `config/environment.rb` file and add:
|
24
|
+
|
25
|
+
`config.gem "pagelime_rails"`
|
26
|
+
|
27
|
+
then run
|
28
|
+
|
29
|
+
`rake gems:install`
|
30
|
+
|
31
|
+
#### For Rails 3
|
32
|
+
edit your `Gemfile` and add
|
33
|
+
|
34
|
+
`gem "pagelime_rails"`
|
35
|
+
|
36
|
+
then run
|
37
|
+
|
38
|
+
`bundle install`
|
39
|
+
|
40
|
+
### Step 2. (Only for Rails 2.3.X)
|
41
|
+
Add the plugin routes to your `config/routes.rb` configuration:
|
42
|
+
|
43
|
+
`map.cms_routes`
|
44
|
+
|
45
|
+
These routes are used by Pagelime to clear any caches after save and publish events on your files.
|
46
|
+
|
47
|
+
*Rails 3 does not need this statement, as the plugin will behave as an engine*
|
48
|
+
|
49
|
+
### Step 3.
|
50
|
+
For any controller that renders views that you want editable, add the acts_as_cms_editable behavior like so:
|
51
|
+
|
52
|
+
class CmsPagesController < ApplicationController
|
53
|
+
# attach the cms behavior to the controller
|
54
|
+
acts_as_cms_editable
|
55
|
+
|
56
|
+
def index
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
You can pass an `:except` parameter just like with a filter like so:
|
61
|
+
|
62
|
+
`acts_as_cms_editable :except => :index`
|
63
|
+
|
64
|
+
### Step 4.
|
65
|
+
Create some editable regions in your views like so:
|
66
|
+
|
67
|
+
`<div id="my_content" class="cms-editable">this is now editable</div>`
|
68
|
+
|
69
|
+
*The ID and the class are required for the CMS to work*
|
70
|
+
|
71
|
+
If you want to add an editable area that is shared across multiple views (such as a partial, or your layout), use the following format:
|
72
|
+
|
73
|
+
`<div id="my_content" class="cms-editable cms-shared">this is now editable and shared</div>`
|
74
|
+
|
75
|
+
|
76
|
+
### Step 5. (OPTIONAL)
|
77
|
+
If you don't want to have your entire controller CMS editable for some reason, you can sorround areas in your view with a code block like so:
|
78
|
+
|
79
|
+
<% cms_content do %>
|
80
|
+
<div id="my_content" class="cms-editable">hello world</div>
|
81
|
+
<% end %>
|
82
|
+
|
83
|
+
### Step 6.
|
84
|
+
Add the pagelime addon to your app from the command line:
|
85
|
+
|
86
|
+
`heroku addons:add pagelime`
|
87
|
+
|
88
|
+
|
89
|
+
Accessing the CMS
|
90
|
+
---------------
|
91
|
+
To access the CMS, find the menu item labeled "Pagelime" will appear under the addons dropdown for your app.
|
92
|
+
|
93
|
+
How it works under the hood
|
94
|
+
---------------------------
|
95
|
+
Pagelime is a cloud CMS. It provides a simple WYSIWYG editing interface for your pages, and pushes updated content and images to your app.
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 [name of plugin creator]
|
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/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
YAML::ENGINE.yamler= 'syck'
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'bundler'
|
8
|
+
begin
|
9
|
+
Bundler.setup(:default, :development)
|
10
|
+
rescue Bundler::BundlerError => e
|
11
|
+
$stderr.puts e.message
|
12
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
13
|
+
exit e.status_code
|
14
|
+
end
|
15
|
+
require 'rake'
|
16
|
+
|
17
|
+
require 'jeweler'
|
18
|
+
Jeweler::Tasks.new do |gem|
|
19
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
20
|
+
gem.name = "pagelime-rails"
|
21
|
+
gem.homepage = "http://github.com/eanticev/pagelime_rails"
|
22
|
+
gem.license = "MIT"
|
23
|
+
gem.summary = "Pagelime Rails Plugin"
|
24
|
+
gem.description = ""
|
25
|
+
gem.email = "emil@pagelime.com"
|
26
|
+
gem.authors = ["Emil Anticevic", "Joel Van Horn"]
|
27
|
+
# dependencies defined in Gemfile
|
28
|
+
end
|
29
|
+
Jeweler::RubygemsDotOrgTasks.new
|
30
|
+
|
31
|
+
require 'rake/testtask'
|
32
|
+
Rake::TestTask.new(:test) do |test|
|
33
|
+
test.libs << 'lib' << 'test'
|
34
|
+
test.pattern = 'test/**/test_*.rb'
|
35
|
+
test.verbose = true
|
36
|
+
end
|
37
|
+
|
38
|
+
task :default => :test
|
39
|
+
|
40
|
+
require 'rdoc/task'
|
41
|
+
Rake::RDocTask.new do |rdoc|
|
42
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
43
|
+
|
44
|
+
rdoc.rdoc_dir = 'rdoc'
|
45
|
+
rdoc.title = "pagelime-rails #{version}"
|
46
|
+
rdoc.rdoc_files.include('README*')
|
47
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
48
|
+
end
|
data/Readme.md
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
Pagelime Rails Plugin
|
2
|
+
=====================
|
3
|
+
|
4
|
+
Easily add the Pagelime CMS to your rails app.
|
5
|
+
|
6
|
+
Pagelime is a simple CMS service that allows you to define editable regions in your content without installing any software on your site or app. Simply add a class="cms-editable" to any HTML element, and log-in to the Pagelime CMS service to edit your content and images with a nice UI. We host all of the code, content, and data until you publish a page. When you publish a page, we push the content to your site/app via secure FTP or web APIs.
|
7
|
+
|
8
|
+
One line example:
|
9
|
+
`<div id="my_content" class="cms-editable">This content is now editable in Pagelime... no code... no databases... no fuss</div>`
|
10
|
+
|
11
|
+
Getting Started
|
12
|
+
---------------
|
13
|
+
|
14
|
+
Requirements:
|
15
|
+
|
16
|
+
* Pagelime account (either a standalone from pagelime.com or as a Heroku add-on)
|
17
|
+
* Nokogiri gem
|
18
|
+
|
19
|
+
### Step 1. (Skip if using Heroku add-on)
|
20
|
+
If NOT on Heroku, set up a site for your Rails app in Pagelime. Make sure that the "Integration Method" for your site on the advanced tab is set to "web services"
|
21
|
+
|
22
|
+
### Step 2.
|
23
|
+
Require the **pagelime_rails** gem
|
24
|
+
|
25
|
+
#### For Rails 2
|
26
|
+
edit your `config/environment.rb` file and add:
|
27
|
+
|
28
|
+
`config.gem "pagelime_rails"`
|
29
|
+
|
30
|
+
then run
|
31
|
+
|
32
|
+
`rake gems:install`
|
33
|
+
|
34
|
+
#### For Rails 3
|
35
|
+
edit your `Gemfile` and add
|
36
|
+
|
37
|
+
`gem "pagelime_rails"`
|
38
|
+
|
39
|
+
then run
|
40
|
+
|
41
|
+
`bundle install`
|
42
|
+
|
43
|
+
### Step 3. (Only for Rails 2.3.X)
|
44
|
+
Add the plugin routes to your `config/routes.rb` configuration:
|
45
|
+
|
46
|
+
`map.cms_routes`
|
47
|
+
|
48
|
+
These routes are used by Pagelime to clear any caches after save and publish events on your files.
|
49
|
+
|
50
|
+
*Rails 3 does not need this statement, as the plugin will behave as an engine*
|
51
|
+
|
52
|
+
### Step 4.
|
53
|
+
For any controller that renders views that you want editable, add the acts_as_cms_editable behavior like so:
|
54
|
+
|
55
|
+
class CmsPagesController < ApplicationController
|
56
|
+
# attach the cms behavior to the controller
|
57
|
+
acts_as_cms_editable
|
58
|
+
|
59
|
+
def index
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
You can pass an `:except` parameter just like with a filter like so:
|
64
|
+
|
65
|
+
`acts_as_cms_editable :except => :index`
|
66
|
+
|
67
|
+
### Step 5.
|
68
|
+
Create some editable regions in your views like so:
|
69
|
+
|
70
|
+
`<div id="my_content" class="cms-editable">this is now editable</div>`
|
71
|
+
|
72
|
+
*The ID and the class are required for the CMS to work*
|
73
|
+
|
74
|
+
### Step 6. (OPTIONAL)
|
75
|
+
If you don't want to have your entire controller CMS editable for some reason, you can sorround areas in your view with a code block like so:
|
76
|
+
|
77
|
+
<% cms_content do %>
|
78
|
+
<div id="my_content" class="cms-editable">hello world</div>
|
79
|
+
<% end %>
|
80
|
+
|
81
|
+
Copyright (c) 2011 Pagelime LLC, released under the MIT license
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.2.0
|
@@ -0,0 +1,95 @@
|
|
1
|
+
class PagelimeReceiverController < ApplicationController
|
2
|
+
|
3
|
+
def index
|
4
|
+
render :inline => "working", :status => 200
|
5
|
+
end
|
6
|
+
|
7
|
+
def after_publish_callback
|
8
|
+
|
9
|
+
Pagelime.client.clear params[:path]
|
10
|
+
Pagelime.clinet.clear_shared
|
11
|
+
|
12
|
+
# don't do the prefetch below, as the page isn't done publishing (mySQL transaction hasn't completed) at the point when this gets called
|
13
|
+
=begin
|
14
|
+
begin
|
15
|
+
new_content = fetch_cms_xml(params[:path]);
|
16
|
+
rescue
|
17
|
+
end
|
18
|
+
=end
|
19
|
+
|
20
|
+
render :inline => "cache cleared", :status => 200
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
def after_publish_callback_old
|
25
|
+
|
26
|
+
# the page_id will come from the request
|
27
|
+
page_id = params[:page_id]
|
28
|
+
|
29
|
+
# TODO: use the API to get content
|
30
|
+
uri = URI.parse("http://qa.cms.pagelime.com/API/Account/SOAP/Page.asmx/Get")
|
31
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
32
|
+
# http.use_ssl = true
|
33
|
+
http.open_timeout = 2
|
34
|
+
http.read_timeout = 7
|
35
|
+
# http.set_debug_output $stderr
|
36
|
+
data = {:apiKey => "0fa155c4-9c42-4df6-856a-5cff6e2ff631", :pageId => page_id}.to_json
|
37
|
+
response = http.post(uri.path,data,{"content-type"=>"application/json; charset=utf-8","accept"=>"application/json, text/javascript, */*"})
|
38
|
+
|
39
|
+
page_json = JSON.parse(response.body)
|
40
|
+
page_json = page_json["d"]
|
41
|
+
|
42
|
+
# try to find existing page
|
43
|
+
page = PagelimePage.find_by_page_id(page_id)
|
44
|
+
if (page)
|
45
|
+
# delete existing content
|
46
|
+
page.editable_areas.destroy
|
47
|
+
page.meta_data.destroy
|
48
|
+
else
|
49
|
+
# if no page is found, create a new one
|
50
|
+
page = PagelimePage.new
|
51
|
+
end
|
52
|
+
|
53
|
+
# set the page data
|
54
|
+
page.page_id = page_id
|
55
|
+
page.path = page_json[:Path]
|
56
|
+
page.title = page_json[:Title]
|
57
|
+
page.date_published = DateTime.now
|
58
|
+
|
59
|
+
# save the page
|
60
|
+
page.save
|
61
|
+
|
62
|
+
# for each piece of content
|
63
|
+
for page_content_json in page_json["EditableRegions"]
|
64
|
+
|
65
|
+
# create the content data
|
66
|
+
page_content = PagelimeContent.new
|
67
|
+
page_content.client_id = page_content_json[:ClientID]
|
68
|
+
page_content.page = page
|
69
|
+
page_content.html = page_content_json[:Html]
|
70
|
+
|
71
|
+
# save content
|
72
|
+
page_content.save
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
# for each piece of meta data
|
77
|
+
for metadata_json in page_json["MetaDataJSON"]
|
78
|
+
|
79
|
+
# create the content data
|
80
|
+
page_metadata = PagelimeMetaData.new
|
81
|
+
page_metadata.name = metadata_json[0]
|
82
|
+
page_metadata.content = metadata_json[1]
|
83
|
+
page_metadata.page = page
|
84
|
+
|
85
|
+
# save content
|
86
|
+
page_metadata.save
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
# respond with an OK status or CREATED status
|
91
|
+
render :status => 200
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
@@ -0,0 +1,13 @@
|
|
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.processor.process_fragment(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
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
if Rails::VERSION::MAJOR == 2
|
3
|
+
|
4
|
+
ActionController::Routing::Routes.draw do |map|
|
5
|
+
puts "PAGELIME CMS PLUGIN: setting up rails 2 routes"
|
6
|
+
map.connect "pagelime/:action", :controller => :pagelime_receiver_controller
|
7
|
+
end
|
8
|
+
|
9
|
+
elsif Rails::VERSION::MAJOR == 3 && Rails::VERSION::MINOR == 0
|
10
|
+
|
11
|
+
puts "PAGELIME CMS PLUGIN: setting up rails 3 routes"
|
12
|
+
|
13
|
+
Rails.application.routes.draw do
|
14
|
+
match 'pagelime/:action' => 'pagelime_receiver'
|
15
|
+
end
|
16
|
+
|
17
|
+
elsif Rails::VERSION::MAJOR >= 3
|
18
|
+
|
19
|
+
puts "PAGELIME CMS PLUGIN: setting up rails 3.1 routes"
|
20
|
+
|
21
|
+
Pagelime::Rails::Engine.routes.draw do
|
22
|
+
get 'pagelime/:action' => 'pagelime_receiver'
|
23
|
+
end
|
24
|
+
|
25
|
+
Rails.application.routes.draw do
|
26
|
+
mount Pagelime::Rails::Engine => "/"
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/init.rb
ADDED
data/install.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Install hook code here
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'pagelime'
|
2
|
+
require 'pagelime/rails'
|
3
|
+
require 'pagelime/s3_rails_cache'
|
4
|
+
|
5
|
+
puts "PAGELIME CMS PLUGIN: included"
|
6
|
+
|
7
|
+
Pagelime.configure do |config|
|
8
|
+
config.client_class = Pagelime::S3RailsCache
|
9
|
+
end
|
10
|
+
|
11
|
+
# start plugin
|
12
|
+
if Rails::VERSION::MAJOR == 2
|
13
|
+
require_relative 'pagelime/rails/routing_extensions'
|
14
|
+
|
15
|
+
ActionController::Routing::RouteSet::Mapper.send :include, ::Pagelime::Rails::RoutingExtensions
|
16
|
+
# below is not needed in Rails 2 as you can use the map.cms_routes from the routing_extensions
|
17
|
+
# require File.join(File.dirname(__FILE__), "/../config/routes.rb")
|
18
|
+
Pagelime::Rails.initialize!
|
19
|
+
elsif Rails::VERSION::MAJOR >= 3
|
20
|
+
require_relative 'pagelime/rails/engine'
|
21
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Pagelime
|
2
|
+
module Rails
|
3
|
+
module ClassMethods
|
4
|
+
def initialize!
|
5
|
+
|
6
|
+
puts "PAGELIME CMS PLUGIN: initializing"
|
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
|
+
# wire controller extensions
|
26
|
+
require_relative 'rails/controller_extensions'
|
27
|
+
ActionController::Base.extend ControllerExtensions
|
28
|
+
|
29
|
+
# wire helper
|
30
|
+
require_relative File.join('.', app_path_relative, "helpers", "pagelime_helper")
|
31
|
+
ActionView::Base.send :include, PagelimeHelper
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
extend ClassMethods
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Pagelime
|
2
|
+
module Rails
|
3
|
+
module ControllerExtensions
|
4
|
+
|
5
|
+
def acts_as_cms_editable(opts = {})
|
6
|
+
after_filter :cms_process_rendered_body, :except => opts[:except]
|
7
|
+
include InstanceMethods
|
8
|
+
end
|
9
|
+
|
10
|
+
module InstanceMethods
|
11
|
+
def cms_process_rendered_body
|
12
|
+
puts "PAGELIME CMS PLUGIN: Processing response body"
|
13
|
+
|
14
|
+
# parse response body, cache, and use result as response body
|
15
|
+
response.body = Pagelime.processor.process_document(response.body, request.path)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Pagelime
|
2
|
+
class S3RailsCache < Pagelime::S3Client
|
3
|
+
module ClassMethods
|
4
|
+
def generate_cache_key(page_path, format = default_format)
|
5
|
+
"pagelime:cms:#{format}:page:#{Base64.encode64(page_path)}"
|
6
|
+
end
|
7
|
+
|
8
|
+
def shared_cache_key(format = default_format)
|
9
|
+
"pagelime:cms:#{format}:shared"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
extend ClassMethods
|
14
|
+
|
15
|
+
def fetch(page_path, format = self.class.default_format)
|
16
|
+
cache_key = self.class.generate_cache_key(page_path, format)
|
17
|
+
|
18
|
+
::Rails.cache.fetch(cache_key, :expires_in => 1.year) do
|
19
|
+
Pagelime.logger.debug "PAGELIME CMS RAILS PLUGIN: NO '#{page_path}' CACHE... loading #{format}"
|
20
|
+
super
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def fetch_shared(format = self.class.default_format)
|
25
|
+
cache_key = self.class.shared_cache_key(format)
|
26
|
+
|
27
|
+
::Rails.cache.fetch(cache_key, :expires_in => 1.year) do
|
28
|
+
Pagelime.logger.debug "PAGELIME CMS RAILS PLUGIN: NO SHARED CACHE... loading #{format}"
|
29
|
+
super
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def clear(page_path, format = self.class.default_format)
|
34
|
+
cache_key = self.class.generate_cache_key(page_path, format)
|
35
|
+
|
36
|
+
Rails.cache.delete cache_key
|
37
|
+
end
|
38
|
+
|
39
|
+
def clear_shared(page_path, format = self.class.default_format)
|
40
|
+
cache_key = self.class.shared_cache_key(format)
|
41
|
+
|
42
|
+
Rails.cache.delete cache_key
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# desc "Explaining what the task does"
|
2
|
+
# task :pagelime do
|
3
|
+
# # Task goes here
|
4
|
+
# end
|
5
|
+
|
6
|
+
namespace :db do
|
7
|
+
namespace :migrate do
|
8
|
+
description = "Migrate the database through scripts in vendor/plugins/pagelime/lib/db/migrate"
|
9
|
+
description << "and update db/schema.rb by invoking db:schema:dump."
|
10
|
+
description << "Target specific version with VERSION=x. Turn off output with VERBOSE=false."
|
11
|
+
|
12
|
+
desc description
|
13
|
+
task :pagelime => :environment do
|
14
|
+
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
|
15
|
+
ActiveRecord::Migrator.migrate("vendor/plugins/pagelime/lib/db/migrate/", ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
|
16
|
+
Rake::Task["db:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "pagelime-rails"
|
8
|
+
s.version = "0.2.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Emil Anticevic", "Joel Van Horn"]
|
12
|
+
s.date = "2013-09-05"
|
13
|
+
s.description = ""
|
14
|
+
s.email = "emil@pagelime.com"
|
15
|
+
s.files = [
|
16
|
+
"Gemfile",
|
17
|
+
"Heroku.md",
|
18
|
+
"MIT-LICENSE",
|
19
|
+
"Rakefile",
|
20
|
+
"Readme.md",
|
21
|
+
"VERSION",
|
22
|
+
"app/controllers/pagelime_receiver_controller.rb",
|
23
|
+
"app/helpers/pagelime_helper.rb",
|
24
|
+
"config/routes.rb",
|
25
|
+
"init.rb",
|
26
|
+
"install.rb",
|
27
|
+
"lib/pagelime-rails.rb",
|
28
|
+
"lib/pagelime/rails.rb",
|
29
|
+
"lib/pagelime/rails/controller_extensions.rb",
|
30
|
+
"lib/pagelime/rails/engine.rb",
|
31
|
+
"lib/pagelime/rails/routing_extensions.rb",
|
32
|
+
"lib/pagelime/s3_rails_cache.rb",
|
33
|
+
"lib/tasks/pagelime.rake",
|
34
|
+
"pagelime-rails.gemspec",
|
35
|
+
"rails/init.rb",
|
36
|
+
"test/pagelime_test.rb",
|
37
|
+
"test/test_helper.rb",
|
38
|
+
"uninstall.rb"
|
39
|
+
]
|
40
|
+
s.homepage = "http://github.com/eanticev/pagelime_rails"
|
41
|
+
s.licenses = ["MIT"]
|
42
|
+
s.require_paths = ["lib"]
|
43
|
+
s.rubygems_version = "2.0.7"
|
44
|
+
s.summary = "Pagelime Rails Plugin"
|
45
|
+
|
46
|
+
if s.respond_to? :specification_version then
|
47
|
+
s.specification_version = 4
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_runtime_dependency(%q<pagelime-rack>, [">= 0.2.0"])
|
51
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.0"])
|
52
|
+
s.add_development_dependency(%q<jeweler>, [">= 1.6.4"])
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<pagelime-rack>, [">= 0.2.0"])
|
55
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
56
|
+
s.add_dependency(%q<jeweler>, [">= 1.6.4"])
|
57
|
+
end
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<pagelime-rack>, [">= 0.2.0"])
|
60
|
+
s.add_dependency(%q<bundler>, [">= 1.0.0"])
|
61
|
+
s.add_dependency(%q<jeweler>, [">= 1.6.4"])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
data/rails/init.rb
ADDED
data/test/test_helper.rb
ADDED
data/uninstall.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Uninstall hook code here
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pagelime-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Emil Anticevic
|
8
|
+
- Joel Van Horn
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: pagelime-rack
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ! '>='
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.2.0
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ! '>='
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.2.0
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - ! '>='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 1.0.0
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ! '>='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 1.0.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: jeweler
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.6.4
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 1.6.4
|
56
|
+
description: ''
|
57
|
+
email: emil@pagelime.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- Gemfile
|
63
|
+
- Heroku.md
|
64
|
+
- MIT-LICENSE
|
65
|
+
- Rakefile
|
66
|
+
- Readme.md
|
67
|
+
- VERSION
|
68
|
+
- app/controllers/pagelime_receiver_controller.rb
|
69
|
+
- app/helpers/pagelime_helper.rb
|
70
|
+
- config/routes.rb
|
71
|
+
- init.rb
|
72
|
+
- install.rb
|
73
|
+
- lib/pagelime-rails.rb
|
74
|
+
- lib/pagelime/rails.rb
|
75
|
+
- lib/pagelime/rails/controller_extensions.rb
|
76
|
+
- lib/pagelime/rails/engine.rb
|
77
|
+
- lib/pagelime/rails/routing_extensions.rb
|
78
|
+
- lib/pagelime/s3_rails_cache.rb
|
79
|
+
- lib/tasks/pagelime.rake
|
80
|
+
- pagelime-rails.gemspec
|
81
|
+
- rails/init.rb
|
82
|
+
- test/pagelime_test.rb
|
83
|
+
- test/test_helper.rb
|
84
|
+
- uninstall.rb
|
85
|
+
homepage: http://github.com/eanticev/pagelime_rails
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ! '>='
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.0.7
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: Pagelime Rails Plugin
|
109
|
+
test_files: []
|