pagelime-rack 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/README.md +60 -32
- data/VERSION +1 -1
- data/lib/pagelime/s3_client.rb +15 -6
- data/lib/pagelime/xml_processor.rb +27 -8
- data/lib/rack/pagelime.rb +7 -7
- data/pagelime-rack.gemspec +2 -2
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MmZlZjA0YjZiN2UyYmRmYjdmNDY5NDM3MWNhN2I2Njk3ZjE1ODQ4NTU1OWQ2
|
10
|
-
Y2I4Y2UwMDljZTBkZDNhMmU5MzU0YWIwMTdkNThjMTgwZTM0MjMyNzBkYWY0
|
11
|
-
NjA1YmU2ODE0M2Y3ZTRkNDg4NGI5NTM2NTJhMjQ2ZTgwN2Y4Zjk=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZjYyN2EwNDEwMGIwMWQ0NGZlZGRjNjIyMmY3NTdmNzRlY2Q3NGEyOTQ1MTc4
|
14
|
-
MzZlYTRlZDU0N2Y2OWEyMGNlNTFhZjRiYWE1NDcyNTU4MWExNDMwMmI4M2Jj
|
15
|
-
MjA4NWM1MTY3MjY3OThjM2U3Y2FmNGU2MmNkYTRkNjVmYzU1MjQ=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 56d7efd14f1b1ae6347a91fd55553809d7597973
|
4
|
+
data.tar.gz: 0c539f4aef56a8359361ab74c68e4077bd680cba
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8da392f81941b3f5e33fc36da3d68b7bc8b30e3161dfa410b900264b7c56d9c70b02ab1509851a1753b4da324558cec1d53e99eef1c9a758f57b23080f9c8f0f
|
7
|
+
data.tar.gz: 9b1fd19ad4255167cc1bd4d22e22cb6ba4d4fd62fb0c3ed56b52951f461a9c60370ab5396d8747bd08bd1f4837ff92d979f59d331ab823b3d5cbbcef204b9e31
|
data/README.md
CHANGED
@@ -1,60 +1,88 @@
|
|
1
1
|
Pagelime Rack Plugin
|
2
2
|
=====================
|
3
3
|
|
4
|
-
Easily add the Pagelime CMS to your
|
4
|
+
Easily add the Pagelime CMS to your Rack app.
|
5
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.
|
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.
|
7
|
+
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.
|
8
|
+
We host all of the code, content, and data until you publish a page.
|
9
|
+
When you publish a page, we push the content to your site/app via secure FTP or web APIs.
|
7
10
|
|
8
11
|
One line example:
|
9
|
-
|
12
|
+
|
13
|
+
<div id="my_content" class="cms-editable">
|
14
|
+
This content is now editable in Pagelime... no code... no databases... no fuss
|
15
|
+
</div>
|
10
16
|
|
11
17
|
Getting Started
|
12
18
|
---------------
|
13
19
|
|
14
|
-
Requirements
|
20
|
+
### Requirements
|
15
21
|
|
16
|
-
* Pagelime account (either
|
22
|
+
* Pagelime account (either standalone [pagelime.com](http://pagelime.com) or via the [Pagelime Heroku add-on](https://addons.heroku.com/pagelime))
|
17
23
|
* Nokogiri gem
|
18
24
|
|
19
|
-
|
20
|
-
|
25
|
+
### Step 1: Install the Pagelime Rack gem
|
26
|
+
|
27
|
+
Edit your `Gemfile` and add
|
21
28
|
|
22
|
-
|
29
|
+
gem "pagelime-rack"
|
23
30
|
|
24
31
|
then run
|
25
32
|
|
26
|
-
|
33
|
+
bundle install
|
27
34
|
|
28
|
-
### Step 2:
|
35
|
+
### Step 2: Setup your Pagelime credentials
|
29
36
|
|
30
|
-
|
31
|
-
ENV['PAGELIME_ACCOUNT_SECRET'] = "..."
|
32
|
-
ENV['PAGELIME_RACK_API_VERSION'] = "1.0"`
|
37
|
+
*(Skip if using Heroku add-on)*
|
33
38
|
|
34
|
-
|
35
|
-
|
39
|
+
If you are NOT using the [Pagelime Heroku add-on](https://addons.heroku.com/pagelime), set up an account at [pagelime.com](http://pagelime.com).
|
40
|
+
Make sure that the "Integration Method" for your site on the advanced tab is set to "web services".
|
36
41
|
|
37
|
-
|
42
|
+
### Step 3: Configure your application
|
38
43
|
|
39
|
-
|
44
|
+
Set up your Environment variables: *(Skip if using Heroku add-on)*
|
40
45
|
|
41
|
-
|
42
|
-
|
46
|
+
ENV['PAGELIME_ACCOUNT_KEY'] = "..."
|
47
|
+
ENV['PAGELIME_ACCOUNT_SECRET'] = "..."
|
48
|
+
ENV['PAGELIME_RACK_API_VERSION'] = "1.0"
|
49
|
+
|
50
|
+
Alternatively, configure them explicitly:
|
43
51
|
|
44
|
-
|
45
|
-
|
52
|
+
Pagelime.configure do |config|
|
53
|
+
config.account_key = "..."
|
54
|
+
config.account_secret = "..."
|
55
|
+
config.api_version = "1.0"
|
56
|
+
end
|
46
57
|
|
47
|
-
|
48
|
-
ENV['PAGELIME_ACCOUNT_KEY'] = "..."
|
49
|
-
ENV['PAGELIME_ACCOUNT_SECRET'] = "..."
|
50
|
-
ENV['PAGELIME_RACK_API_VERSION'] = "1.0"
|
51
|
-
end
|
58
|
+
### Step 4: Make pages editable
|
52
59
|
|
53
|
-
|
60
|
+
Create some editable regions in your views like so:
|
61
|
+
|
62
|
+
<div id="my_content" class="cms-editable">
|
63
|
+
this is now editable
|
64
|
+
</div>
|
65
|
+
|
66
|
+
*The ID and the class are required for the CMS to work*
|
67
|
+
|
68
|
+
Sinatra Sample
|
69
|
+
--------------
|
54
70
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
71
|
+
require 'sinatra'
|
72
|
+
require 'pagelime-rack'
|
73
|
+
|
74
|
+
configure :development do
|
75
|
+
ENV['PAGELIME_ACCOUNT_KEY'] = "..."
|
76
|
+
ENV['PAGELIME_ACCOUNT_SECRET'] = "..."
|
77
|
+
ENV['PAGELIME_RACK_API_VERSION'] = "1.0"
|
78
|
+
end
|
79
|
+
|
80
|
+
use Rack::Pagelime
|
81
|
+
|
82
|
+
get '/page/about' do
|
83
|
+
content_type "text/html"
|
84
|
+
return "<div id=\"content\" class=\"cms-editable\">Hello World!</div>"
|
85
|
+
end
|
86
|
+
|
87
|
+
Copyright (c) 2013 Pagelime LLC, released under the MIT license
|
59
88
|
|
60
|
-
Copyright (c) 2011 Pagelime LLC, released under the MIT license
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/lib/pagelime/s3_client.rb
CHANGED
@@ -37,11 +37,13 @@ module Pagelime
|
|
37
37
|
|
38
38
|
# TODO: check cache (see the rails plugin for info)
|
39
39
|
|
40
|
-
::Pagelime.logger.debug "PAGELIME CMS PLUGIN: NO SHARED CACHE... loading #{format}"
|
40
|
+
::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: NO SHARED CACHE... loading #{format}"
|
41
41
|
|
42
42
|
content = request_content("/cms_assets/heroku/#{account_key}/shared-regions.#{format}")
|
43
43
|
|
44
|
-
#
|
44
|
+
# ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: shared XML: #{content}"
|
45
|
+
|
46
|
+
Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Shared content: #{content.inspect}"
|
45
47
|
|
46
48
|
content
|
47
49
|
end
|
@@ -55,25 +57,32 @@ module Pagelime
|
|
55
57
|
|
56
58
|
# TODO: check cache (see the rails plugin for info)
|
57
59
|
|
58
|
-
Pagelime.logger.debug "PAGELIME CMS PLUGIN: NO '#{page_path}' CACHE... loading #{format}"
|
60
|
+
Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: NO '#{page_path}' CACHE... loading #{format}"
|
59
61
|
|
60
62
|
content = request_content("/cms_assets/heroku/#{account_key}/pages#{page_path}.#{format}")
|
61
63
|
|
64
|
+
Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Content: #{content.inspect}"
|
65
|
+
|
62
66
|
content
|
63
67
|
end
|
64
68
|
|
65
69
|
def clear(page_path, format = self.class.default_format)
|
66
|
-
Pagelime.logger.warn "#{self.class.name}##{__method__} is not implemented!"
|
70
|
+
Pagelime.logger.warn "PAGELIME CMS RACK PLUGIN: #{self.class.name}##{__method__} is not implemented!"
|
67
71
|
end
|
68
72
|
|
69
73
|
def clear_shared(format = self.class.default_format)
|
70
|
-
Pagelime.logger.warn "#{self.class.name}##{__method__} is not implemented!"
|
74
|
+
Pagelime.logger.warn "PAGELIME CMS RACK PLUGIN: #{self.class.name}##{__method__} is not implemented!"
|
71
75
|
end
|
72
76
|
|
73
77
|
private
|
74
78
|
|
75
79
|
def request_content(url)
|
76
|
-
http.get(url)
|
80
|
+
response = http.get(url)
|
81
|
+
|
82
|
+
Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: S3 response code: #{response.code.inspect}"
|
83
|
+
|
84
|
+
# only return the body if response code 200-399
|
85
|
+
response.body if (200...400).include?(response.code)
|
77
86
|
end
|
78
87
|
|
79
88
|
def http
|
@@ -12,17 +12,37 @@ module Pagelime
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def process_document(html, page_path = false)
|
15
|
+
Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Document HTML: #{html.inspect}"
|
16
|
+
|
15
17
|
doc = Nokogiri::HTML::Document.parse(html)
|
16
18
|
|
17
19
|
# return original HTML if nil returned
|
18
|
-
parse_document(doc, page_path) || html
|
20
|
+
output = parse_document(doc, page_path) || html
|
21
|
+
|
22
|
+
if html == output
|
23
|
+
Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Document output: UNCHANGED!"
|
24
|
+
else
|
25
|
+
Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Document output: #{output.inspect}"
|
26
|
+
end
|
27
|
+
|
28
|
+
output
|
19
29
|
end
|
20
30
|
|
21
31
|
def process_fragment(html, page_path = false)
|
32
|
+
Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Fragment HTML: #{html.inspect}"
|
33
|
+
|
22
34
|
doc = Nokogiri::HTML::DocumentFragment.parse(html)
|
23
35
|
|
24
36
|
# return original HTML if nil returned
|
25
|
-
parse_document(doc, page_path) || html
|
37
|
+
output = parse_document(doc, page_path) || html
|
38
|
+
|
39
|
+
if html == output
|
40
|
+
Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Fragment output: UNCHANGED!"
|
41
|
+
else
|
42
|
+
Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Fragment output: #{output.inspect}"
|
43
|
+
end
|
44
|
+
|
45
|
+
output
|
26
46
|
end
|
27
47
|
|
28
48
|
private
|
@@ -31,7 +51,7 @@ module Pagelime
|
|
31
51
|
def parse_document(doc, page_path = false)
|
32
52
|
|
33
53
|
unless client.configured?
|
34
|
-
::Pagelime.logger.warn "PAGELIME CMS PLUGIN: Environment variables not configured"
|
54
|
+
::Pagelime.logger.warn "PAGELIME CMS RACK PLUGIN: Environment variables not configured"
|
35
55
|
return nil
|
36
56
|
end
|
37
57
|
|
@@ -48,7 +68,7 @@ module Pagelime
|
|
48
68
|
|
49
69
|
def patch_regions(editable_regions, xml_content)
|
50
70
|
|
51
|
-
::Pagelime.logger.debug "PAGELIME CMS PLUGIN: parsing xml"
|
71
|
+
::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: parsing xml"
|
52
72
|
|
53
73
|
editable_regions.each do |div|
|
54
74
|
|
@@ -57,14 +77,13 @@ module Pagelime
|
|
57
77
|
soap = Nokogiri::XML::Document.parse(xml_content)
|
58
78
|
nodes = soap.css("EditableRegion[@ElementID=\"#{client_id}\"]")
|
59
79
|
|
60
|
-
::Pagelime.logger.debug "PAGELIME CMS PLUGIN: looking for region: #{client_id}"
|
61
|
-
::Pagelime.logger.debug "regions found: #{nodes.count}"
|
80
|
+
::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: looking for region: #{client_id}"
|
81
|
+
::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: regions found: #{nodes.count}"
|
62
82
|
|
63
83
|
if nodes.any?
|
64
84
|
new_content = nodes[0].css("Html")[0].content
|
65
85
|
|
66
|
-
::Pagelime.logger.debug "PAGELIME CMS PLUGIN: NEW CONTENT:"
|
67
|
-
::Pagelime.logger.debug new_content
|
86
|
+
::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: NEW CONTENT: #{new_content.inspect}"
|
68
87
|
|
69
88
|
if new_content
|
70
89
|
# div.content = "Replaced content"
|
data/lib/rack/pagelime.rb
CHANGED
@@ -11,16 +11,16 @@ module Rack
|
|
11
11
|
@app = app
|
12
12
|
@options = options
|
13
13
|
|
14
|
-
::Pagelime.logger.debug "PAGELIME: Rack Plugin Initialized"
|
14
|
+
::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Rack Plugin Initialized"
|
15
15
|
end
|
16
16
|
|
17
17
|
def call(env)
|
18
18
|
|
19
19
|
status, headers, response = @app.call(env)
|
20
20
|
|
21
|
-
::Pagelime.logger.debug "PAGELIME: Headers: #{headers}"
|
22
|
-
::Pagelime.logger.debug "PAGELIME: Status: #{status}"
|
23
|
-
::Pagelime.logger.debug "PAGELIME: Response: #{response}"
|
21
|
+
::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Headers: #{headers}"
|
22
|
+
::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Status: #{status}"
|
23
|
+
::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Response: #{response}"
|
24
24
|
|
25
25
|
if status == 200 && headers["content-type"].include?("text/html")
|
26
26
|
|
@@ -29,8 +29,8 @@ module Rack
|
|
29
29
|
|
30
30
|
req = Rack::Request.new(env)
|
31
31
|
|
32
|
-
::Pagelime.logger.debug "PAGELIME: Processing For Path: #{req.path}"
|
33
|
-
::Pagelime.logger.debug "PAGELIME: Processing Body (size:#{body_content.length})"
|
32
|
+
::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Processing For Path: #{req.path}"
|
33
|
+
::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Processing Body (size:#{body_content.length})"
|
34
34
|
|
35
35
|
body = ::Pagelime.html_processor.process_document(body_content, req.path)
|
36
36
|
|
@@ -40,7 +40,7 @@ module Rack
|
|
40
40
|
|
41
41
|
else
|
42
42
|
|
43
|
-
::Pagelime.logger.debug "PAGELIME: Not touching this request"
|
43
|
+
::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Not touching this request"
|
44
44
|
|
45
45
|
return [status, headers, response]
|
46
46
|
|
data/pagelime-rack.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "pagelime-rack"
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.2"
|
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"]
|
@@ -37,7 +37,7 @@ Gem::Specification.new do |s|
|
|
37
37
|
s.homepage = "http://github.com/eanticev/pagelime-rack"
|
38
38
|
s.licenses = ["MIT"]
|
39
39
|
s.require_paths = ["lib"]
|
40
|
-
s.rubygems_version = "2.0.
|
40
|
+
s.rubygems_version = "2.0.6"
|
41
41
|
s.summary = "Rack Middleware for integrating Pagelime into ruby frameworks"
|
42
42
|
|
43
43
|
if s.respond_to? :specification_version then
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagelime-rack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Emil Anticevic
|
@@ -15,84 +15,84 @@ dependencies:
|
|
15
15
|
name: nokogiri
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - '>='
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0'
|
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
27
|
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rack
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - '>='
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - '>='
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: shoulda
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - '>='
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - '>='
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rdoc
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - '>='
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '3.12'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - '>='
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '3.12'
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: bundler
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
|
-
- -
|
74
|
+
- - '>='
|
75
75
|
- !ruby/object:Gem::Version
|
76
76
|
version: 1.0.0
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - '>='
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: 1.0.0
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: jeweler
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- -
|
88
|
+
- - '>='
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: 1.8.4
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- -
|
95
|
+
- - '>='
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: 1.8.4
|
98
98
|
description: The Pagelime Rack Middleware will process outgoing HTML, look for editable
|
@@ -131,17 +131,17 @@ require_paths:
|
|
131
131
|
- lib
|
132
132
|
required_ruby_version: !ruby/object:Gem::Requirement
|
133
133
|
requirements:
|
134
|
-
- -
|
134
|
+
- - '>='
|
135
135
|
- !ruby/object:Gem::Version
|
136
136
|
version: '0'
|
137
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
138
|
requirements:
|
139
|
-
- -
|
139
|
+
- - '>='
|
140
140
|
- !ruby/object:Gem::Version
|
141
141
|
version: '0'
|
142
142
|
requirements: []
|
143
143
|
rubyforge_project:
|
144
|
-
rubygems_version: 2.0.
|
144
|
+
rubygems_version: 2.0.6
|
145
145
|
signing_key:
|
146
146
|
specification_version: 4
|
147
147
|
summary: Rack Middleware for integrating Pagelime into ruby frameworks
|