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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6fa0d4f3614285445c78586bf4d63163cb6419b8944dcb1e614a3e90f5b50925
4
- data.tar.gz: 17aaa52cf397c066edb770f98959fa3b9f211e398c1bca87c365d2c157691f5e
3
+ metadata.gz: a11f85e869328faff7d9244556f4b6c27ea30460c1ecbb9a691737d10f24daaa
4
+ data.tar.gz: 7a43d4c8821ce2e8d6899cdae404bb47a1db66c54032ac5cbc123e18cee394af
5
5
  SHA512:
6
- metadata.gz: c21a1b6b5ab70780a0e182f99d300239661c36f72cf3d8ea022a6be7edb8374e2b587233648d6939705bd073aeb1234a1e04e041f609f1ea7fcb82b36e99813b
7
- data.tar.gz: a92dacb2c646acd722b018eb948d2380567b38438cbf3ee09cc387c689fc0fd2375205e0c0044823f8bd306625ab40a87c34a2764f5969349331b6a9c7e27268
6
+ metadata.gz: fc3287be925560cb0ee03df33c04d8cb2de6a811345dc75385359afa94236a5500cac5c5a969b50bfb66b44117d4266e986fd86f624d84e38a83c995ffa503f0
7
+ data.tar.gz: 4eae0b7459aad9100e813ab916be76ef9c7c0aac7d814ac9524e358a98a06a6fb83f4e869f1bfccca426c2af3c3376cc405d93e3a8fe55950054b5f3a2992dd2
data/lib/flora/config.rb CHANGED
@@ -14,7 +14,7 @@ class Flora::Config
14
14
 
15
15
 
16
16
  def extend_view(mod)
17
- Kernel.prepend(mod)
17
+ Kernel.include(mod)
18
18
  end
19
19
 
20
20
 
@@ -18,7 +18,7 @@ class Flora::Plugins::Blog::Post
18
18
 
19
19
 
20
20
  def date
21
- @frontmatter['date']
21
+ @frontmatter['date'].to_time
22
22
  end
23
23
 
24
24
 
@@ -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 render_tree
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
@@ -1,3 +1,3 @@
1
1
  class Flora
2
- VERSION = '0.11.0'
2
+ VERSION = '0.12.0'
3
3
  end
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.prepend(Flora::Lilac)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flora
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Vladimiroff