Class: Awestruct::Page
Constant Summary
AStructMixin::UNTRACKED_KEYS
Instance Attribute Summary collapse
Instance Method Summary
collapse
#[], #cascade_for_nils!, extended, #key?, #method_missing, #transform_entry
Constructor Details
#initialize(site, handler = nil) ⇒ Page
Returns a new instance of Page.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Awestruct::AStructMixin
Instance Attribute Details
#dependencies ⇒ Object
Returns the value of attribute dependencies.
16
17
18
|
# File 'lib/awestruct/page.rb', line 16
def dependencies
@dependencies
end
|
#handler ⇒ Object
Returns the value of attribute handler.
15
16
17
|
# File 'lib/awestruct/page.rb', line 15
def handler
@handler
end
|
#site ⇒ Object
Returns the value of attribute site.
14
15
16
|
# File 'lib/awestruct/page.rb', line 14
def site
@site
end
|
Instance Method Details
#==(other_page) ⇒ Object
134
135
136
|
# File 'lib/awestruct/page.rb', line 134
def ==(other_page)
self.object_id == other_page.object_id
end
|
#all_dependencies ⇒ Object
111
112
113
|
# File 'lib/awestruct/page.rb', line 111
def all_dependencies
@dependencies + handler.dependencies
end
|
#collective_dependencies_mtime ⇒ Object
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/awestruct/page.rb', line 99
def collective_dependencies_mtime
t = nil
@dependencies.each do |e|
if ( t == nil )
t = e.mtime
elsif ( t < e.mtime )
t = e.mtime
end
end
t
end
|
#content(with_layouts = false) ⇒ Object
130
131
132
|
# File 'lib/awestruct/page.rb', line 130
def content(with_layouts=false)
rendered_content( create_context(), with_layouts )
end
|
#content_syntax ⇒ Object
115
116
117
|
# File 'lib/awestruct/page.rb', line 115
def content_syntax
handler.content_syntax
end
|
#create_context(content = '') ⇒ Object
39
40
41
42
43
|
# File 'lib/awestruct/page.rb', line 39
def create_context(content='')
context = Awestruct::Context.new( :site=>site, :page=>self, :content=>content )
site.engine.pipeline.mixin_helpers( context )
context
end
|
#inherit_front_matter_from(hash) ⇒ Object
45
46
47
48
49
50
51
|
# File 'lib/awestruct/page.rb', line 45
def inherit_front_matter_from(hash)
hash.each do |k,v|
unless ( key?( k ) )
self[k.to_sym] = v
end
end
end
|
95
96
97
|
# File 'lib/awestruct/page.rb', line 95
def input_mtime
handler.input_mtime( self )
end
|
#inspect ⇒ Object
35
36
37
|
# File 'lib/awestruct/page.rb', line 35
def inspect
"Awestruct::Page{ #{self.object_id}: output_path=>#{output_path}, source_path=>#{source_path}, layout=>#{layout} }"
end
|
#output_extension ⇒ Object
76
77
78
|
# File 'lib/awestruct/page.rb', line 76
def output_extension
handler.output_extension
end
|
#output_path ⇒ Object
65
66
67
|
# File 'lib/awestruct/page.rb', line 65
def output_path
(@output_path || handler.output_path).to_s
end
|
#output_path=(path) ⇒ Object
69
70
71
72
73
74
|
# File 'lib/awestruct/page.rb', line 69
def output_path=(path)
case ( path )
when Pathname then @output_path = path
else @output_path = Pathname.new( path )
end
end
|
#prepare! ⇒ Object
31
32
33
|
# File 'lib/awestruct/page.rb', line 31
def prepare!
handler.inherit_front_matter( self )
end
|
#raw_content ⇒ Object
119
120
121
|
# File 'lib/awestruct/page.rb', line 119
def raw_content
handler.raw_content
end
|
#relative_source_path ⇒ Object
53
54
55
|
# File 'lib/awestruct/page.rb', line 53
def relative_source_path
@relative_source_path || handler.relative_source_path
end
|
#relative_source_path=(path) ⇒ Object
57
58
59
|
# File 'lib/awestruct/page.rb', line 57
def relative_source_path=(path)
@relative_source_path = path
end
|
#rendered_content(context = create_context(), with_layouts = true) ⇒ Object
123
124
125
126
127
128
|
# File 'lib/awestruct/page.rb', line 123
def rendered_content(context=create_context(), with_layouts=true)
Awestruct::Dependencies.push_page( self ) if context.site.config.track_dependencies
c = handler.rendered_content( context, with_layouts )
Awestruct::Dependencies.pop_page if context.site.config.track_dependencies
c
end
|
#simple_name ⇒ Object
61
62
63
|
# File 'lib/awestruct/page.rb', line 61
def simple_name
handler.simple_name
end
|
#source_path ⇒ Object
81
82
83
|
# File 'lib/awestruct/page.rb', line 81
def source_path
handler.path.to_s
end
|
#stale? ⇒ Boolean
85
86
87
|
# File 'lib/awestruct/page.rb', line 85
def stale?
handler.stale? || @dependencies.dependencies.any?(&:stale?)
end
|
#stale_output?(output_path) ⇒ Boolean
89
90
91
92
93
|
# File 'lib/awestruct/page.rb', line 89
def stale_output?(output_path)
return true if ! File.exist?( output_path )
return true if input_mtime > File.mtime( output_path )
false
end
|