pagelime-rack 0.4.0 → 0.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31190639b8f777f1cb45f8686a62fcba12cf3471
4
- data.tar.gz: 2bedf88cb41d6e5e84433a3e5558189674e53803
3
+ metadata.gz: e6f9dea9eac27aa1acd84261c8e8bfcef985bb67
4
+ data.tar.gz: e389bcd63e7e2f2aede5e5620662e46d258e312f
5
5
  SHA512:
6
- metadata.gz: 6680f8a6043ad9b09d19269f4402085265ee86fec4f6f10c055f2ebe04d5a3d1f1fbe4bd457b515801b5f87aebc922f4e60bbcdb68b3501a07e24a0dfef37745
7
- data.tar.gz: 45f0641b2217676ad2d6c066cbb0ee0ed856c8d79d46e6ccc5a2bff09132e2713de066be836be6b8d47ed1e0a93b1020dd498422d044f226f0675d7d62265b72
6
+ metadata.gz: 32a04b8649cfcfd7b4b4ec723ca3ba94f41ba53137bd25fc0c1bd0e067ae94e9791493beab954fbee7ec9c7992ededa5f56500a53342589656d115c8dd1aabaf
7
+ data.tar.gz: 224bb4ccb38b5fdd3f37e224ee806975fbd1c8a166908e788cb88146468b5ce149d39381f71327451d2e04083b70fb257e390d0e6c0338db5a3cae4eb6d0ed9d
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.0
1
+ 0.4.1
@@ -8,6 +8,10 @@ module Rack
8
8
  include Rack::Utils
9
9
 
10
10
  TOGGLE_PROCESSING_ENV_KEY = "pagelime.toggle_processing"
11
+ ROUTE_RESPONSES = {
12
+ "index" => "working",
13
+ "after_publish_callback" => "cache cleared"
14
+ }
11
15
 
12
16
  module ClassMethods
13
17
  def enable_processing_for_request(env)
@@ -26,6 +30,30 @@ module Rack
26
30
 
27
31
  return config_option == "on"
28
32
  end
33
+
34
+ # responses
35
+
36
+ def handle_publish_callback(env)
37
+
38
+ req = Rack::Request.new(env)
39
+
40
+ ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Route for publish callback called!"
41
+
42
+ ::Pagelime.cache.clear_page(req.params["path"].to_s)
43
+ ::Pagelime.cache.clear_shared
44
+
45
+ [200, {"Content-Type" => "text/html"}, StringIO.new(ROUTE_RESPONSES["after_publish_callback"])]
46
+ end
47
+
48
+ def handle_status_check(env)
49
+
50
+ req = Rack::Request.new(env)
51
+
52
+ ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Route for index called!"
53
+
54
+ [200, {"Content-Type" => "text/html"}, StringIO.new(ROUTE_RESPONSES["index"])]
55
+ end
56
+
29
57
  end
30
58
 
31
59
  include ClassMethods
@@ -51,10 +79,10 @@ module Rack
51
79
  case action
52
80
  # handle publish callback
53
81
  when "after_publish_callback"
54
- resp = handle_publish_callback(status, headers, response, env)
82
+ resp = handle_publish_callback(status, headers, response, env, "after_publish_callback")
55
83
  # handle "index"
56
84
  when ""
57
- resp = handle_status_check(status, headers, response, env)
85
+ resp = handle_status_check(status, headers, response, env, "index")
58
86
  else
59
87
  ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Unable to route action! (URL prefix: #{::Pagelime.config.url_path}, Request path: #{req.path})"
60
88
  end
@@ -63,69 +91,40 @@ module Rack
63
91
  end
64
92
 
65
93
  # only process original output if routing wasn't handled
66
- resp ||= handle_html_processing(status, headers, response, env)
67
-
68
- resp
69
- end
70
-
71
- # responses
72
-
73
- def handle_publish_callback(status, headers, response, env)
74
-
75
- req = Rack::Request.new(env)
76
-
77
- ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Route for publish callback called!"
78
-
79
- ::Pagelime.cache.clear_page(req.params["path"].to_s)
80
- ::Pagelime.cache.clear_shared
81
-
82
- [200, {"Content-Type" => "text/html"}, ["cache cleared"]]
83
- end
84
-
85
- def handle_status_check(status, headers, response, env)
86
-
87
- req = Rack::Request.new(env)
88
-
89
- ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Route for index called!"
94
+ unless resp
90
95
 
91
- [200, {"Content-Type" => "text/html"}, ["working"]]
92
- end
93
-
94
- def handle_html_processing(status, headers, response, env)
95
-
96
- req = Rack::Request.new(env)
97
-
98
- status, headers, response = @app.call(env)
99
-
100
- ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Headers: #{headers}"
101
- ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Status: #{status}"
102
- ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Response: #{response}"
103
-
104
- if processing_enabled_for_request?(env) && status == 200 &&
105
- headers["content-type"] && headers["content-type"].include?("text/html")
96
+ ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Headers: #{headers}"
97
+ ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Status: #{status}"
98
+ ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Response: #{response}"
99
+
100
+ if processing_enabled_for_request?(env) && status == 200 &&
101
+ headers["content-type"] && headers["content-type"].include?("text/html")
102
+
103
+ body_content = StringIO.new(response)
104
+ #response.each{|part| body_content << part}
106
105
 
107
- body_content = StringIO.new(response)
108
- #response.each{|part| body_content << part}
106
+ ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Processing For Path: #{req.path}"
107
+ ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Processing Body (size:#{body_content.length})"
108
+
109
+ body = ::Pagelime.process_page(body_content, req.path)
110
+
111
+ headers['content-length'] = body.length.to_s
112
+
113
+ body = [body]
114
+
115
+ else
116
+
117
+ ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Not touching this request"
118
+
119
+ body = response
120
+
121
+ end
122
+
123
+ resp = [status, headers, body]
109
124
 
110
- ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Processing For Path: #{req.path}"
111
- ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Processing Body (size:#{body_content.length})"
112
-
113
- body = ::Pagelime.process_page(body_content, req.path)
114
-
115
- headers['content-length'] = body.length.to_s
116
-
117
- body = [body]
118
-
119
- else
120
-
121
- ::Pagelime.logger.debug "PAGELIME CMS RACK PLUGIN: Not touching this request"
122
-
123
- body = response
124
-
125
125
  end
126
126
 
127
- [status, headers, body]
128
-
127
+ resp
129
128
  end
130
129
 
131
130
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "pagelime-rack"
8
- s.version = "0.4.0"
8
+ s.version = "0.4.1"
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"]
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.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Emil Anticevic