Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 62 lines (48 sloc) 1.533 kb
2ce2cdf @pyromaniac Initial commit
pyromaniac authored
1 module PufferPages
2 module Liquid
3 class PageDrop < ::Liquid::Drop
4
c147279 @pyromaniac PufferPages UUID integration
pyromaniac authored
5 delegate *(PufferPages::Page.statuses.map {|s| "#{s}?"} << {:to => :page})
cf01950 @pyromaniac Added puffer_pages method to controller
pyromaniac authored
6 delegate :id, :slug, :created_at, :updated_at, :to => :page
2ce2cdf @pyromaniac Initial commit
pyromaniac authored
7
eaee95b @pyromaniac Controller now awaible from context registers
pyromaniac authored
8 def initialize page
9 @page = page
2ce2cdf @pyromaniac Initial commit
pyromaniac authored
10 end
11
c147279 @pyromaniac PufferPages UUID integration
pyromaniac authored
12 def name
13 @context ? page.render(page.name, @context) : page.name
c4825f0 @pyromaniac Removed page attributes tags. Renderable drop methods instead
pyromaniac authored
14 end
15
50b8b97 @pyromaniac Improved page drop specs
pyromaniac authored
16 %w(parent root ancestors self_and_ancestors children self_and_children siblings
17 self_and_siblings descendants, self_and_descendants).each do |attribute|
1321154 @pyromaniac Fixed root page drop method
pyromaniac authored
18 define_method attribute do
50b8b97 @pyromaniac Improved page drop specs
pyromaniac authored
19 instance_variable_get("@#{attribute}") ||
c147279 @pyromaniac PufferPages UUID integration
pyromaniac authored
20 instance_variable_set("@#{attribute}", page.send(attribute))
2ce2cdf @pyromaniac Initial commit
pyromaniac authored
21 end
22 end
23
24 def path
c147279 @pyromaniac PufferPages UUID integration
pyromaniac authored
25 controller.puffer_pages.puffer_page_path page.to_location
2ce2cdf @pyromaniac Initial commit
pyromaniac authored
26 end
27
28 def url
c147279 @pyromaniac PufferPages UUID integration
pyromaniac authored
29 controller.puffer_pages.puffer_page_url page.to_location
e5f227e @pyromaniac Added url helpers to page drop
pyromaniac authored
30 end
31
32 def current?
b11a516 @pyromaniac Returned attributes tags, removed root from context
pyromaniac authored
33 current_page && page == current_page
e5f227e @pyromaniac Added url helpers to page drop
pyromaniac authored
34 end
35
36 def ancestor?
b11a516 @pyromaniac Returned attributes tags, removed root from context
pyromaniac authored
37 current_page && page.is_ancestor_of?(current_page)
e5f227e @pyromaniac Added url helpers to page drop
pyromaniac authored
38 end
39
0d345c3 @pyromaniac Assets tags refactored
pyromaniac authored
40 def == other
41 page == other.send(:page)
578f95b @pyromaniac Added == method to drop
pyromaniac authored
42 end
43
c147279 @pyromaniac PufferPages UUID integration
pyromaniac authored
44 def before_method name
45 page_part = page.inherited_page_part(name)
46 page_part.handle(@context) if page_part && @context
808a4b3 @pyromaniac Added page part access to page drop
pyromaniac authored
47 end
48
e5f227e @pyromaniac Added url helpers to page drop
pyromaniac authored
49 private
eaee95b @pyromaniac Controller now awaible from context registers
pyromaniac authored
50 attr_reader :page
e5f227e @pyromaniac Added url helpers to page drop
pyromaniac authored
51
b11a516 @pyromaniac Returned attributes tags, removed root from context
pyromaniac authored
52 def current_page
01fb9ff @pyromaniac Added `super` tag for parent page parts rendering
pyromaniac authored
53 @current_page ||= @context.registers[:page] if @context
b11a516 @pyromaniac Returned attributes tags, removed root from context
pyromaniac authored
54 end
55
eaee95b @pyromaniac Controller now awaible from context registers
pyromaniac authored
56 def controller
57 @controller ||= @context.registers[:controller] if @context
58 end
2ce2cdf @pyromaniac Initial commit
pyromaniac authored
59 end
60 end
61 end
Something went wrong with that request. Please try again.