flora 0.11.0 → 0.12.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.
- checksums.yaml +4 -4
- data/lib/flora/config.rb +1 -1
- data/lib/flora/plugins/blog/post.rb +1 -1
- data/lib/flora/plugins/blog.rb +81 -1
- data/lib/flora/version.rb +1 -1
- data/lib/flora.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a11f85e869328faff7d9244556f4b6c27ea30460c1ecbb9a691737d10f24daaa
|
|
4
|
+
data.tar.gz: 7a43d4c8821ce2e8d6899cdae404bb47a1db66c54032ac5cbc123e18cee394af
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fc3287be925560cb0ee03df33c04d8cb2de6a811345dc75385359afa94236a5500cac5c5a969b50bfb66b44117d4266e986fd86f624d84e38a83c995ffa503f0
|
|
7
|
+
data.tar.gz: 4eae0b7459aad9100e813ab916be76ef9c7c0aac7d814ac9524e358a98a06a6fb83f4e869f1bfccca426c2af3c3376cc405d93e3a8fe55950054b5f3a2992dd2
|
data/lib/flora/config.rb
CHANGED
data/lib/flora/plugins/blog.rb
CHANGED
|
@@ -13,10 +13,67 @@ module Flora::Plugins::Blog
|
|
|
13
13
|
@post = Post.new(file, project.dir)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class Feed
|
|
20
|
+
|
|
21
|
+
def initialize(posts, config)
|
|
22
|
+
@posts = posts
|
|
23
|
+
@config = config
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def render
|
|
28
|
+
builder = Nokogiri::XML::Builder.new do |xml|
|
|
29
|
+
xml.feed(xmlns: 'http://www.w3.org/2005/Atom') do
|
|
30
|
+
xml.generator('Flora')
|
|
31
|
+
nokogiri_tag(xml, :title, @config.blog[:title])
|
|
32
|
+
xml.updated(last_updated.iso8601)
|
|
33
|
+
nokogiri_tag(xml, :link, href: @config.blog[:url])
|
|
34
|
+
xml.id(@config.blog[:url])
|
|
35
|
+
xml.author do
|
|
36
|
+
xml.name(@config.blog[:author])
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
@posts.each { to_entry(xml, it) }
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
builder.to_xml
|
|
44
|
+
end
|
|
45
|
+
|
|
16
46
|
|
|
17
47
|
private
|
|
18
48
|
|
|
19
|
-
def
|
|
49
|
+
def full_url(post)
|
|
50
|
+
@config.blog[:url] + post.url
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
def last_updated
|
|
55
|
+
@posts[0].date
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
def to_entry(xml, post)
|
|
60
|
+
xml.entry do
|
|
61
|
+
xml.id(full_url(post))
|
|
62
|
+
nokogiri_tag(xml, :title, post.title)
|
|
63
|
+
# TODO: actually support published vs updated.
|
|
64
|
+
xml.updated(post.date.iso8601)
|
|
65
|
+
xml.published(post.date.iso8601)
|
|
66
|
+
nokogiri_tag(xml, :link, rel: 'alternate', href: full_url(post))
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
# Nokogiri's builder uses method_missing, and some of Lilac's tags are
|
|
73
|
+
# named the same as some of the Atom tags we want to use which causes
|
|
74
|
+
# conflicts. Use this method to get around that!
|
|
75
|
+
def nokogiri_tag(xml, tag, *args, **opts, &block)
|
|
76
|
+
xml.method_missing(tag, *args, **opts, &block)
|
|
20
77
|
end
|
|
21
78
|
|
|
22
79
|
end
|
|
@@ -39,4 +96,27 @@ module Flora::Plugins::Blog
|
|
|
39
96
|
|
|
40
97
|
end
|
|
41
98
|
|
|
99
|
+
|
|
100
|
+
module FactoryMethods
|
|
101
|
+
|
|
102
|
+
def assemble(out_dir)
|
|
103
|
+
super
|
|
104
|
+
|
|
105
|
+
feed = Feed.new(@project.posts, @config)
|
|
106
|
+
out_dir.join('feed.xml').write(feed.render)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
module Config
|
|
113
|
+
|
|
114
|
+
def self.included(base)
|
|
115
|
+
base.class_eval do
|
|
116
|
+
attr_accessor(:blog)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
end
|
|
121
|
+
|
|
42
122
|
end
|
data/lib/flora/version.rb
CHANGED
data/lib/flora.rb
CHANGED
|
@@ -21,7 +21,7 @@ class Flora
|
|
|
21
21
|
# instance_eval isn't enough because it'll be missing in lib/ code.
|
|
22
22
|
#
|
|
23
23
|
# TODO: is there a less disruptive way to do this?
|
|
24
|
-
Kernel.
|
|
24
|
+
Kernel.include(Flora::Lilac)
|
|
25
25
|
|
|
26
26
|
# The classes that are pluggable get their own instances to avoid conflicting
|
|
27
27
|
# with other instances of Flora in the same process. This is mostly for the
|