Class: Yuzu::Core::WebsiteBase
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(path, parent) ⇒ WebsiteBase
Returns a new instance of WebsiteBase.
9
10
11
12
13
14
15
16
17
|
# File 'lib/yuzu/core/website_base.rb', line 9
def initialize(path, parent)
raise "WebsiteBase not initialized with a Path object." if not path.is_a?(Path)
@path = path
raise "@path is nil for #{self}" if @path.nil?
@parent = parent
@kind = nil
@stash = {}
end
|
Instance Attribute Details
Returns the value of attribute kind.
7
8
9
|
# File 'lib/yuzu/core/website_base.rb', line 7
def kind
@kind
end
|
Returns the value of attribute parent.
7
8
9
|
# File 'lib/yuzu/core/website_base.rb', line 7
def parent
@parent
end
|
Returns the value of attribute path.
7
8
9
|
# File 'lib/yuzu/core/website_base.rb', line 7
def path
@path
end
|
Instance Method Details
#==(other) ⇒ Object
19
20
21
22
|
# File 'lib/yuzu/core/website_base.rb', line 19
def == (other)
return false if not other.is_a?(WebsiteBase)
return @path == other.path
end
|
#asset? ⇒ Boolean
89
90
91
92
|
# File 'lib/yuzu/core/website_base.rb', line 89
def asset?
return false if folder?
config.asset?(@path)
end
|
#blog_folder ⇒ Object
36
37
38
|
# File 'lib/yuzu/core/website_base.rb', line 36
def blog_folder
@@blog ||= root.find_file_by_path(Path.new(config.blog_dir))
end
|
64
65
66
|
# File 'lib/yuzu/core/website_base.rb', line 64
def children
nil
end
|
52
53
54
|
# File 'lib/yuzu/core/website_base.rb', line 52
def config
@parent.config
end
|
#default_stash ⇒ Object
131
132
133
134
135
136
|
# File 'lib/yuzu/core/website_base.rb', line 131
def default_stash
{
:generated_siblings => [],
:catalog => nil
}
end
|
#file? ⇒ Boolean
56
57
58
|
# File 'lib/yuzu/core/website_base.rb', line 56
def file?
@kind == :file
end
|
#folder? ⇒ Boolean
60
61
62
|
# File 'lib/yuzu/core/website_base.rb', line 60
def folder?
@kind == :folder
end
|
#generated? ⇒ Boolean
144
145
146
|
# File 'lib/yuzu/core/website_base.rb', line 144
def generated?
false
end
|
#get_link_url ⇒ Object
111
112
113
|
# File 'lib/yuzu/core/website_base.rb', line 111
def get_link_url
folder? ? (currentpath + "index.html") : (currentpath + output_filename).full
end
|
#get_remote_path ⇒ Object
119
120
121
122
123
124
125
126
127
128
129
|
# File 'lib/yuzu/core/website_base.rb', line 119
def get_remote_path
if processable?
tr = file? ? @path.with_extension(extension) : @path
if tr == @path
raise "Remote path and source path are the same! Got #{tr} and #{@path}."
end
tr
else
@path
end
end
|
#hidden? ⇒ Boolean
94
95
96
97
|
# File 'lib/yuzu/core/website_base.rb', line 94
def hidden?
return false if root?
@parent.hidden? or @path.rootname[0].chr == "_"
end
|
#image? ⇒ Boolean
84
85
86
87
|
# File 'lib/yuzu/core/website_base.rb', line 84
def image?
return false if folder?
config.image?(@path)
end
|
#in_blog? ⇒ Boolean
40
41
42
|
# File 'lib/yuzu/core/website_base.rb', line 40
def in_blog?
blog_folder.nil? ? false : blog_folder.is_child?(self)
end
|
#index? ⇒ Boolean
48
49
50
|
# File 'lib/yuzu/core/website_base.rb', line 48
def index?
false
end
|
#is_blog? ⇒ Boolean
44
45
46
|
# File 'lib/yuzu/core/website_base.rb', line 44
def is_blog?
self == blog_folder or (index? and self.path.dirname == blog_folder.path.dirname)
end
|
#is_processable? ⇒ Boolean
72
73
74
75
76
77
|
# File 'lib/yuzu/core/website_base.rb', line 72
def is_processable?
return false if folder?
config_says = config.processable?(@path)
translators_say = Yuzu::Translators::Translator.can_translate?(self)
config_says and translators_say
end
|
#link_to_self(attr = {}) ⇒ Object
103
104
105
|
# File 'lib/yuzu/core/website_base.rb', line 103
def link_to_self(attr={})
Html::Link.new({:href => link_url}.merge(attr)) << name
end
|
107
108
109
|
# File 'lib/yuzu/core/website_base.rb', line 107
def link_url
@link_url ||= get_link_url
end
|
24
25
26
|
# File 'lib/yuzu/core/website_base.rb', line 24
def name
@path.basename
end
|
#processable? ⇒ Boolean
68
69
70
|
# File 'lib/yuzu/core/website_base.rb', line 68
def processable?
@processable ||= is_processable?
end
|
#remote_path ⇒ Object
115
116
117
|
# File 'lib/yuzu/core/website_base.rb', line 115
def remote_path
@remote_path ||= get_remote_path
end
|
#resource? ⇒ Boolean
79
80
81
82
|
# File 'lib/yuzu/core/website_base.rb', line 79
def resource?
return false if folder?
config.resource?(@path)
end
|
28
29
30
|
# File 'lib/yuzu/core/website_base.rb', line 28
def root
@root ||= (@parent.nil? ? self : @parent.root)
end
|
#root? ⇒ Boolean
32
33
34
|
# File 'lib/yuzu/core/website_base.rb', line 32
def root?
root == self
end
|
#stash(kwds = {}) ⇒ Object
Enables other processes to add imbue this node with information.
139
140
141
142
|
# File 'lib/yuzu/core/website_base.rb', line 139
def stash(kwds={})
@stash = default_stash if @stash.nil?
kwds.empty? ? @stash : @stash.update(kwds)
end
|