Class: Yuzu::Filters::PostTitleFilter
Instance Attribute Summary
Attributes inherited from Filter
#directive, #name
Instance Method Summary
collapse
Methods inherited from Filter
#filter_type, filters, #get_match, #match, #process, #regex, registry, #replacement, #value
Constructor Details
Returns a new instance of PostTitleFilter.
5
6
7
8
|
# File 'lib/yuzu/filters/post_title.rb', line 5
def initialize
@directive = "TITLE"
@name = :post_title
end
|
Instance Method Details
#default(website_file) ⇒ Object
10
11
12
|
# File 'lib/yuzu/filters/post_title.rb', line 10
def default(website_file)
(website_file.path)
end
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
# File 'lib/yuzu/filters/post_title.rb', line 26
def (path)
post_filename = nil
name = path.rootname
raw_path = path.relative
if name.include?("index")
post_filename = path.parent.rootname
return post_filename.blank? ? "Home" : post_filename.titlecase
end
if post_filename.nil?
m = raw_path.match(/[0-9]{4}\/[0-9]{2}\/[0-9]{2}\-/)
if not m.nil?
post_filename = name[3..-1]
end
end
if post_filename.nil?
m = raw_path.match(/[0-9]{4}\/[0-9]{2}\//)
if not m.nil?
post_filename = name
end
end
if post_filename.nil?
post_filename = name
end
post_filename = post_filename.sub(/[0-9]{4}\-[0-9]{2}\-[0-9]{2}\-/, "")
return post_filename.titlecase
end
|
#get_value(website_file) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/yuzu/filters/post_title.rb', line 14
def get_value(website_file)
contents = website_file.raw_contents
title = match(contents)
if title.nil? and website_file.markdown?
m = contents.match(/^#\s+.*?\n/)
title = m.nil? ? nil : m[0].sub("#", "").strip
end
return title
end
|