puffer_pages 0.0.19 → 0.1.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.
- data/.gitignore +8 -0
- data/Gemfile +2 -22
- data/Gemfile.lock +15 -19
- data/README.md +0 -4
- data/Rakefile +1 -11
- data/app/components/page_part_body/form.html.erb +3 -1
- data/app/components/page_parts/form.html.erb +27 -25
- data/app/{views/puffer_pages/pages_base → components/render}/_tree_page.html.erb +0 -0
- data/app/controllers/puffer_pages/pages_base.rb +2 -2
- data/app/helpers/puffer_pages_helper.rb +1 -1
- data/app/models/puffer_pages/page.rb +19 -10
- data/app/models/puffer_pages/page_part.rb +2 -2
- data/app/views/layouts/puffer_pages_layout.html.erb +1 -0
- data/lib/puffer_pages/extensions/controller.rb +34 -0
- data/lib/puffer_pages/extensions/mapper.rb +3 -5
- data/lib/puffer_pages/liquid/file_system.rb +2 -2
- data/lib/puffer_pages/liquid/tags/javascripts.rb +2 -2
- data/lib/puffer_pages/liquid/tags/stylesheets.rb +2 -2
- data/lib/puffer_pages/liquid/tags/yield.rb +4 -8
- data/lib/puffer_pages/liquid/tracker.rb +2 -8
- data/lib/puffer_pages/version.rb +3 -0
- data/lib/puffer_pages.rb +11 -1
- data/puffer_pages.gemspec +31 -185
- data/spec/controllers/articles_controller_spec.rb +65 -0
- data/spec/dummy/app/assets/javascripts/application.js +0 -4
- data/spec/dummy/app/assets/stylesheets/application.css +2 -2
- data/spec/dummy/app/controllers/admin/articles_controller.rb +18 -0
- data/spec/dummy/app/controllers/articles_controller.rb +9 -0
- data/spec/dummy/app/models/article.rb +16 -0
- data/spec/dummy/app/views/articles/show.html.erb +1 -0
- data/spec/dummy/app/views/layouts/articles.html.erb +1 -0
- data/spec/dummy/config/routes.rb +3 -0
- data/spec/dummy/db/migrate/20111117081813_create_articles.rb +11 -0
- data/spec/dummy/db/schema.rb +9 -1
- data/spec/fabricators/articles_fabricator.rb +4 -0
- data/spec/lib/tags_spec.rb +1 -1
- data/spec/models/page_spec.rb +101 -5
- data/spec/spec_helper.rb +2 -2
- metadata +54 -51
- data/VERSION +0 -1
data/.gitignore
ADDED
data/Gemfile
CHANGED
|
@@ -1,25 +1,5 @@
|
|
|
1
1
|
source "http://rubygems.org"
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
gem 'puffer', :git => 'git://github.com/puffer/puffer.git'
|
|
5
|
-
gem 'liquid', :git => 'git://github.com/puffer/liquid.git'
|
|
6
|
-
gem 'nested_set'
|
|
7
|
-
|
|
8
|
-
group :development, :test, :pg_test do
|
|
9
|
-
gem "sqlite3-ruby", :require => "sqlite3"
|
|
10
|
-
gem "pg"
|
|
11
|
-
gem "mysql"
|
|
12
|
-
|
|
13
|
-
gem "rspec-rails"
|
|
14
|
-
gem "capybara", ">= 0.4.0"
|
|
15
|
-
gem 'database_cleaner'
|
|
16
|
-
|
|
17
|
-
gem 'guard'
|
|
18
|
-
gem 'libnotify'
|
|
19
|
-
gem 'guard-rspec'
|
|
20
|
-
|
|
21
|
-
gem 'forgery'
|
|
22
|
-
gem 'fabrication'
|
|
23
|
-
gem "jeweler"
|
|
24
|
-
end
|
|
3
|
+
gemspec
|
|
25
4
|
|
|
5
|
+
gem 'puffer', :git => 'git://github.com/puffer/puffer.git'
|
data/Gemfile.lock
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
GIT
|
|
2
|
-
remote: git://github.com/puffer/liquid.git
|
|
3
|
-
revision: 3885290fefa0e6f92cfd812455a7cbd8eee9871b
|
|
4
|
-
specs:
|
|
5
|
-
liquid (2.2.2)
|
|
6
|
-
|
|
7
1
|
GIT
|
|
8
2
|
remote: git://github.com/puffer/puffer.git
|
|
9
|
-
revision:
|
|
3
|
+
revision: cdbcc66e5b205cd8f95a48e84568c6748640f349
|
|
10
4
|
specs:
|
|
11
|
-
puffer (0.0
|
|
5
|
+
puffer (0.1.0)
|
|
12
6
|
kaminari
|
|
13
7
|
orm_adapter
|
|
14
8
|
rails (~> 3.1.0)
|
|
15
9
|
|
|
10
|
+
PATH
|
|
11
|
+
remote: .
|
|
12
|
+
specs:
|
|
13
|
+
puffer_pages (0.1.0)
|
|
14
|
+
liquid
|
|
15
|
+
nested_set
|
|
16
|
+
puffer
|
|
17
|
+
rails (~> 3.1.0)
|
|
18
|
+
|
|
16
19
|
GEM
|
|
17
20
|
remote: http://rubygems.org/
|
|
18
21
|
specs:
|
|
@@ -61,22 +64,18 @@ GEM
|
|
|
61
64
|
fabrication (1.1.0)
|
|
62
65
|
ffi (1.0.9)
|
|
63
66
|
forgery (0.5.0)
|
|
64
|
-
git (1.2.5)
|
|
65
67
|
guard (0.6.3)
|
|
66
68
|
thor (~> 0.14.6)
|
|
67
69
|
guard-rspec (0.4.5)
|
|
68
70
|
guard (>= 0.4.0)
|
|
69
71
|
hike (1.2.1)
|
|
70
72
|
i18n (0.6.0)
|
|
71
|
-
jeweler (1.6.4)
|
|
72
|
-
bundler (~> 1.0)
|
|
73
|
-
git (>= 1.2.5)
|
|
74
|
-
rake
|
|
75
73
|
json (1.6.1)
|
|
76
74
|
json_pure (1.6.0)
|
|
77
75
|
kaminari (0.12.4)
|
|
78
76
|
rails (>= 3.0.0)
|
|
79
77
|
libnotify (0.5.7)
|
|
78
|
+
liquid (2.3.0)
|
|
80
79
|
mail (2.3.0)
|
|
81
80
|
i18n (>= 0.4.0)
|
|
82
81
|
mime-types (~> 1.16)
|
|
@@ -90,7 +89,7 @@ GEM
|
|
|
90
89
|
nokogiri (1.5.0)
|
|
91
90
|
orm_adapter (0.0.5)
|
|
92
91
|
pg (0.11.0)
|
|
93
|
-
polyglot (0.3.
|
|
92
|
+
polyglot (0.3.3)
|
|
94
93
|
rack (1.3.5)
|
|
95
94
|
rack-cache (1.1)
|
|
96
95
|
rack (>= 0.4)
|
|
@@ -149,7 +148,7 @@ GEM
|
|
|
149
148
|
treetop (1.4.10)
|
|
150
149
|
polyglot
|
|
151
150
|
polyglot (>= 0.3.1)
|
|
152
|
-
tzinfo (0.3.
|
|
151
|
+
tzinfo (0.3.31)
|
|
153
152
|
xpath (0.1.4)
|
|
154
153
|
nokogiri (~> 1.3)
|
|
155
154
|
|
|
@@ -163,13 +162,10 @@ DEPENDENCIES
|
|
|
163
162
|
forgery
|
|
164
163
|
guard
|
|
165
164
|
guard-rspec
|
|
166
|
-
jeweler
|
|
167
165
|
libnotify
|
|
168
|
-
liquid!
|
|
169
166
|
mysql
|
|
170
|
-
nested_set
|
|
171
167
|
pg
|
|
172
168
|
puffer!
|
|
173
|
-
|
|
169
|
+
puffer_pages!
|
|
174
170
|
rspec-rails
|
|
175
171
|
sqlite3-ruby
|
data/README.md
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
# Warning! This puffer_pages version requires liquid from puffer repo. So, add following line to your Gemfile until new liquid version will release.
|
|
2
|
-
<pre>gem 'liquid', :git => 'git://github.com/puffer/liquid.git'</pre>
|
|
3
|
-
I hope, it's temporarly
|
|
4
|
-
|
|
5
1
|
# Puffer_pages is lightweight rails 3.1 CMS
|
|
6
2
|
|
|
7
3
|
Interface of pages based on [puffer](https://github.com/puffer/puffer)
|
data/Rakefile
CHANGED
|
@@ -24,14 +24,4 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
|
|
|
24
24
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
require
|
|
28
|
-
|
|
29
|
-
Jeweler::Tasks.new do |gem|
|
|
30
|
-
gem.name = "puffer_pages"
|
|
31
|
-
gem.summary = %Q{Content management system}
|
|
32
|
-
gem.description = %Q{Puffer pages is integratable rails CMS with puffer admin interface}
|
|
33
|
-
gem.email = "kinwizard@gmail.com"
|
|
34
|
-
gem.homepage = "http://github.com/puffer/puffer_pages"
|
|
35
|
-
gem.authors = ["pyromaniac"]
|
|
36
|
-
end
|
|
37
|
-
Jeweler::GemcutterTasks.new
|
|
27
|
+
require "bundler/gem_tasks"
|
|
@@ -1,31 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
<ul>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
</ul>
|
|
7
|
-
<% opts[:form].object.send(field.name).each_with_index do |page_part, index| -%>
|
|
8
|
-
<li id="<%= "page_part_tab_#{index}" %>">
|
|
9
|
-
<% opts[:form].fields_for field.name, page_part, :hidden_field_id => true do |page_part_builder| %>
|
|
10
|
-
<% field.children.each do |field| %>
|
|
11
|
-
<%= field.render parent_controller, :form, :form => page_part_builder %>
|
|
12
|
-
<% end %>
|
|
13
|
-
<%= page_part_builder.hidden_field :id unless page_part_builder.object.persisted? %>
|
|
1
|
+
<%= fields_for @record do |f| %>
|
|
2
|
+
<ul id="<%= field.name %>" data-tabs="{closable: true, onRemove: page_part_tab_remove, addButton: page_part_tab_add}">
|
|
3
|
+
<ul>
|
|
4
|
+
<% @record.send(field.name).each_with_index do |page_part, index| %>
|
|
5
|
+
<li><%= link_to page_part.name, "#page_part_tab_#{index}" %></li>
|
|
14
6
|
<% end %>
|
|
15
|
-
</
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
7
|
+
</ul>
|
|
8
|
+
<% @record.send(field.name).each_with_index do |page_part, index| -%>
|
|
9
|
+
<li id="<%= "page_part_tab_#{index}" %>">
|
|
10
|
+
<%= f.fields_for field.name, page_part do |page_part_builder| %>
|
|
11
|
+
<% field.children.each do |field| %>
|
|
12
|
+
<%= field.render :form, parent_controller, page_part_builder.object, :builder => page_part_builder %>
|
|
13
|
+
<% end %>
|
|
14
|
+
<%= page_part_builder.hidden_field :id unless page_part_builder.object.persisted? %>
|
|
15
|
+
<% end %>
|
|
16
|
+
</li>
|
|
17
|
+
<% end -%>
|
|
18
|
+
</ul>
|
|
19
|
+
<div id="page_parts_marked_for_destroy">
|
|
20
|
+
</div>
|
|
20
21
|
|
|
21
|
-
<% new_page_part_tab_panel = capture do %>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
<% new_page_part_tab_panel = capture do %>
|
|
23
|
+
<%= f.fields_for field.name, PagePart.new, :child_index => 'new_page_part_tab_panel_index' do |page_part_builder| %>
|
|
24
|
+
<% field.children.each do |field| %>
|
|
25
|
+
<%= field.render :form, parent_controller, page_part_builder.object, :builder => page_part_builder %>
|
|
26
|
+
<% end %>
|
|
25
27
|
<% end %>
|
|
26
28
|
<% end %>
|
|
27
|
-
<% end %>
|
|
28
29
|
|
|
29
|
-
<%= javascript_tag do %>
|
|
30
|
-
|
|
30
|
+
<%= javascript_tag do %>
|
|
31
|
+
var new_page_part_tab_panel = '<%= j new_page_part_tab_panel.strip.html_safe %>'
|
|
32
|
+
<% end %>
|
|
31
33
|
<% end %>
|
|
File without changes
|
|
@@ -27,8 +27,8 @@ class PufferPages::PagesBase < Puffer::TreeBase
|
|
|
27
27
|
field :name, :type => :hidden
|
|
28
28
|
field :_destroy, :type => :hidden, :html => { :class => 'destroy_mark' }
|
|
29
29
|
end
|
|
30
|
-
field :layout_name, :select => :possible_layouts
|
|
31
|
-
field :status, :select => :possible_statuses
|
|
30
|
+
field :layout_name, :select => :possible_layouts, :include_blank => false
|
|
31
|
+
field :status, :select => :possible_statuses, :include_blank => false
|
|
32
32
|
field :title
|
|
33
33
|
field :description
|
|
34
34
|
field :keywords
|
|
@@ -15,8 +15,16 @@ class PufferPages::Page < ActiveRecord::Base
|
|
|
15
15
|
|
|
16
16
|
def self.find_page location
|
|
17
17
|
page = PufferPages.single_section_page_path ?
|
|
18
|
-
|
|
19
|
-
raise ActiveRecord::RecordNotFound
|
|
18
|
+
find_by_slug(location) : find_by_location(location)
|
|
19
|
+
raise ActiveRecord::RecordNotFound unless page
|
|
20
|
+
raise PufferPages::DraftPage.new("PufferPages can`t show this page because it is draft") if page.draft?
|
|
21
|
+
page
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.find_layout_page location
|
|
25
|
+
location.gsub!(/^\/|\/$/, '')
|
|
26
|
+
page = where(['? like location', location]).where(['status not in (?)', 'draft']).order('lft desc').first
|
|
27
|
+
raise PufferPages::LayoutMissed.new("PufferPages can`t render this page because layout page missed or draft") unless page
|
|
20
28
|
page
|
|
21
29
|
end
|
|
22
30
|
|
|
@@ -28,7 +36,7 @@ class PufferPages::Page < ActiveRecord::Base
|
|
|
28
36
|
validates_uniqueness_of :slug, :scope => (:parent_id unless PufferPages.single_section_page_path)
|
|
29
37
|
validates_inclusion_of :status, :in => statuses
|
|
30
38
|
validates_format_of :slug, :with => /\A\s*\Z/, :message => :root_slug_format, :if => :root?
|
|
31
|
-
validates_format_of :slug, :with => /\A([\w]+[\w-]*(\.[\w]+)
|
|
39
|
+
validates_format_of :slug, :with => /\A([\w]+[\w-]*(\.[\w]+)?|%)\Z/, :message => :slug_format, :unless => :root?
|
|
32
40
|
validate do |page|
|
|
33
41
|
page.errors.add(:layout_name, :blank) unless page.inherited_layout_name.present?
|
|
34
42
|
end
|
|
@@ -42,14 +50,15 @@ class PufferPages::Page < ActiveRecord::Base
|
|
|
42
50
|
self.location = [swallow_nil{parent.location}, slug].compact.join('/').presence
|
|
43
51
|
end
|
|
44
52
|
|
|
45
|
-
before_update :update_locations
|
|
53
|
+
before_update :update_locations, :if => :location_changed?
|
|
46
54
|
def update_locations
|
|
47
|
-
self.class.update_all "location = replace(location, '#{location_was}', '#{location}')", ["location like ?", location_was + '%']
|
|
55
|
+
self.class.update_all "location = replace(location, '#{location_was}', '#{location}')", ["location like ?", location_was + '%']
|
|
48
56
|
end
|
|
49
57
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
58
|
+
after_initialize :build_main_part, :if => :root?
|
|
59
|
+
before_save :build_main_part, :if => :root?
|
|
60
|
+
def build_main_part
|
|
61
|
+
page_parts.build(:name => PufferPages.primary_page_part_name) unless page_parts.map(&:name).include?(PufferPages.primary_page_part_name)
|
|
53
62
|
end
|
|
54
63
|
|
|
55
64
|
statuses.each do |status_name|
|
|
@@ -63,9 +72,9 @@ class PufferPages::Page < ActiveRecord::Base
|
|
|
63
72
|
def render(drops_or_context)
|
|
64
73
|
if inherited_layout
|
|
65
74
|
@template = Liquid::Template.parse(inherited_layout.body)
|
|
66
|
-
tracker.cleanup @template.render(drops_or_context, :registers => {:tracker => tracker, :page => self, :file_system => PufferPages::Liquid::FileSystem.new})
|
|
75
|
+
tracker.cleanup @template.render!(drops_or_context, :registers => {:tracker => tracker, :page => self, :file_system => PufferPages::Liquid::FileSystem.new})
|
|
67
76
|
else
|
|
68
|
-
inherited_page_parts.map{|part| part.render(drops_or_context, self)}.join
|
|
77
|
+
inherited_page_parts.reverse.map{|part| part.render(drops_or_context, self)}.join
|
|
69
78
|
end
|
|
70
79
|
end
|
|
71
80
|
|
|
@@ -6,10 +6,10 @@ class PufferPages::PagePart < ActiveRecord::Base
|
|
|
6
6
|
validates_presence_of :name
|
|
7
7
|
validates_uniqueness_of :name, :scope => :page_id
|
|
8
8
|
|
|
9
|
-
def render(drops_or_context, page =
|
|
9
|
+
def render(drops_or_context, page = page)
|
|
10
10
|
template = Liquid::Template.parse(body)
|
|
11
11
|
result = tracker.cleanup template.render(drops_or_context, :registers => {:tracker => tracker, :page => page, :file_system => PufferPages::Liquid::FileSystem.new})
|
|
12
|
-
main? ? result : "<% content_for
|
|
12
|
+
main? ? result : "<% content_for :'#{name}' do %>#{result}<% end %>"
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
def tracker
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<%= render :inline => layout_page.render(layout_page_drops), :layout => ("layouts/#{layout_page.render_layout}" if layout_page.render_layout) %>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module PufferPages
|
|
2
|
+
module Extensions
|
|
3
|
+
module ActionController
|
|
4
|
+
module Base
|
|
5
|
+
extend ActiveSupport::Concern
|
|
6
|
+
|
|
7
|
+
included do
|
|
8
|
+
helper_method :layout_page, :layout_page_drops
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
module InstanceMethods
|
|
12
|
+
def puffer_pages
|
|
13
|
+
'puffer_pages_layout'
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def layout_page
|
|
17
|
+
@layout_page ||= ::Page.find_layout_page(request.path_info)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def layout_page_drops
|
|
21
|
+
{
|
|
22
|
+
:self => PufferPages::Liquid::PageDrop.new(layout_page, layout_page, self),
|
|
23
|
+
:root => PufferPages::Liquid::PageDrop.new(layout_page.root, layout_page, self)
|
|
24
|
+
}.merge(@drops.presence || {}).stringify_keys
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
ActionController::Base.send :include, PufferPages::Extensions::ActionController::Base
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
module PufferPages
|
|
2
2
|
module Extensions
|
|
3
3
|
module Mapper
|
|
4
|
+
extend ActiveSupport::Concern
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
class_attribute :_puffer_pages
|
|
8
|
-
include InstanceMethods
|
|
9
|
-
end
|
|
6
|
+
included do
|
|
7
|
+
class_attribute :_puffer_pages
|
|
10
8
|
end
|
|
11
9
|
|
|
12
10
|
module InstanceMethods
|
|
@@ -6,12 +6,12 @@ module PufferPages
|
|
|
6
6
|
case template_type template_path
|
|
7
7
|
when :snippet then
|
|
8
8
|
template_path = template_path.gsub(/^snippets\//, '')
|
|
9
|
-
snippet = Snippet.find_by_name(template_path)
|
|
9
|
+
snippet = ::Snippet.find_by_name(template_path)
|
|
10
10
|
raise ::Liquid::FileSystemError, "No such snippet '#{template_path}' found" unless snippet
|
|
11
11
|
snippet.body
|
|
12
12
|
when :layout then
|
|
13
13
|
template_path = template_path.gsub(/^layouts\//, '')
|
|
14
|
-
layout = Layout.find_by_name(template_path)
|
|
14
|
+
layout = ::Layout.find_by_name(template_path)
|
|
15
15
|
raise ::Liquid::FileSystemError, "No such layout '#{template_path}' found" unless layout
|
|
16
16
|
layout.body
|
|
17
17
|
when :page_part then
|
|
@@ -24,8 +24,8 @@ module PufferPages
|
|
|
24
24
|
|
|
25
25
|
def variables_from_string(markup)
|
|
26
26
|
markup.split(',').map do |var|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
var.strip =~ /\s*(#{::Liquid::QuotedFragment})\s*/
|
|
28
|
+
$1 ? $1 : nil
|
|
29
29
|
end.compact
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -24,8 +24,8 @@ module PufferPages
|
|
|
24
24
|
|
|
25
25
|
def variables_from_string(markup)
|
|
26
26
|
markup.split(',').map do |var|
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
var.strip =~ /\s*(#{::Liquid::QuotedFragment})\s*/
|
|
28
|
+
$1 ? $1 : nil
|
|
29
29
|
end.compact
|
|
30
30
|
end
|
|
31
31
|
|
|
@@ -8,21 +8,17 @@ module PufferPages
|
|
|
8
8
|
def initialize(tag_name, markup, tokens)
|
|
9
9
|
if markup =~ Syntax
|
|
10
10
|
@name = $1
|
|
11
|
+
elsif markup.blank?
|
|
12
|
+
@name = nil
|
|
11
13
|
else
|
|
12
|
-
|
|
14
|
+
raise SyntaxError.new("Syntax Error in 'yield' - Valid syntax: yield [content_name]")
|
|
13
15
|
end
|
|
14
16
|
|
|
15
17
|
super
|
|
16
18
|
end
|
|
17
19
|
|
|
18
20
|
def render(context)
|
|
19
|
-
name
|
|
20
|
-
part = context.registers[:page].part(name)
|
|
21
|
-
if part
|
|
22
|
-
part.render(context)
|
|
23
|
-
else
|
|
24
|
-
raise ArgumentError.new("Argument error in 'yield' - Can not find page part named '#{name}'")
|
|
25
|
-
end
|
|
21
|
+
context.registers[:tracker].register(@name ? "<%= yield :'#{@name}' %>" : "<%= yield %>")
|
|
26
22
|
end
|
|
27
23
|
end
|
|
28
24
|
|
|
@@ -7,23 +7,17 @@ module PufferPages
|
|
|
7
7
|
end
|
|
8
8
|
|
|
9
9
|
def register content
|
|
10
|
-
@ids <<
|
|
10
|
+
@ids << Digest::MD5.hexdigest(SecureRandom.uuid)
|
|
11
11
|
content.gsub(/<%/, "<#{@ids.last}%").gsub(/%>/, "%#{@ids.last}>")
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def cleanup text
|
|
15
15
|
ids = @ids.join('|')
|
|
16
16
|
@ids = []
|
|
17
|
-
text = text.gsub(/<%/, "<%").gsub(/%>/, "%>")# unless
|
|
17
|
+
text = text.gsub(/<%/, "<%").gsub(/%>/, "%>")# unless PufferPages.config[:allow_erb]
|
|
18
18
|
text.gsub(/<(#{ids})%/, "<%").gsub(/%(#{ids})>/, "%>")
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
def uid
|
|
24
|
-
Digest::MD5.hexdigest("#{rand}#{Time.now.to_f}")
|
|
25
|
-
end
|
|
26
|
-
|
|
27
21
|
end
|
|
28
22
|
end
|
|
29
23
|
end
|
data/lib/puffer_pages.rb
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
module PufferPages
|
|
2
2
|
|
|
3
|
+
class PufferPagesError < StandardError
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
class DraftPage < PufferPagesError
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class LayoutMissed < PufferPagesError
|
|
10
|
+
end
|
|
11
|
+
|
|
3
12
|
mattr_accessor :primary_page_part_name
|
|
4
13
|
self.primary_page_part_name = 'body'
|
|
5
14
|
|
|
@@ -19,6 +28,7 @@ require 'nested_set'
|
|
|
19
28
|
require 'puffer_pages/engine'
|
|
20
29
|
require 'puffer_pages/extensions/core'
|
|
21
30
|
require 'puffer_pages/extensions/mapper'
|
|
22
|
-
|
|
31
|
+
require 'puffer_pages/extensions/controller'
|
|
32
|
+
require 'puffer_pages/liquid/tags/yield'
|
|
23
33
|
require 'puffer_pages/liquid/tags/stylesheets'
|
|
24
34
|
require 'puffer_pages/liquid/tags/javascripts'
|