planet 0.2.4 → 0.2.5
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.
- data/bin/planet +4 -5
- data/lib/planet.rb +7 -12
- data/lib/planet/version.rb +1 -1
- metadata +1 -1
data/bin/planet
CHANGED
@@ -60,7 +60,6 @@ blogs:
|
|
60
60
|
url: "http://blog.poteland.com" # => only required for people that don\'t have a \'url\' field on their RSS/Atom field'
|
61
61
|
|
62
62
|
|
63
|
-
|
64
63
|
File.open('planet.yml', 'w') { |f| f.write(default) }
|
65
64
|
|
66
65
|
puts '=> Created default planet.yml'
|
@@ -77,10 +76,10 @@ command :create_templates do |c|
|
|
77
76
|
Dir.mkdir(templates_dir) unless File.exists?(templates_dir)
|
78
77
|
|
79
78
|
author = '<div class="author">
|
80
|
-
<
|
81
|
-
<span style="position: absolute; padding:
|
82
|
-
|
83
|
-
</span>
|
79
|
+
<img src="{{ image }}" style="width: 96px; height: 96;">
|
80
|
+
<span style="position: absolute; padding: 32px 15px;">
|
81
|
+
<i>Original post by <a href="{{ twitter}}">{{ author }}</a> - check out <a href="{{ blog_url }}">{{ blog_title }}</a></i>
|
82
|
+
</span>
|
84
83
|
</div>
|
85
84
|
'
|
86
85
|
if !File.exists?(templates_dir + 'author.html')
|
data/lib/planet.rb
CHANGED
@@ -49,8 +49,11 @@ class Planet
|
|
49
49
|
@@_blogs.each do |blog|
|
50
50
|
puts "=> Parsing #{ blog.feed }"
|
51
51
|
feed = Feedzirra::Feed.fetch_and_parse(blog.feed)
|
52
|
+
|
53
|
+
blog.name ||= feed.title || 'the source'
|
52
54
|
blog.url ||= feed.url
|
53
55
|
raise "#{ blog.author }'s blog does not have a url field on it's feed, you will need to specify it on planet.yml" if blog.url.nil?
|
56
|
+
|
54
57
|
feed.entries.each do |entry|
|
55
58
|
@@_posts << @post = Post.new(
|
56
59
|
title: entry.title,
|
@@ -88,16 +91,6 @@ class Planet
|
|
88
91
|
self.blog = attributes.fetch(:blog, nil)
|
89
92
|
end
|
90
93
|
|
91
|
-
def to_hash
|
92
|
-
{
|
93
|
-
title: title,
|
94
|
-
date: date.strftime('%Y-%m-%d %H:%M'),
|
95
|
-
url: url,
|
96
|
-
content: content,
|
97
|
-
author: blog.author
|
98
|
-
}
|
99
|
-
end
|
100
|
-
|
101
94
|
def header
|
102
95
|
## TODO: We need categories/tags
|
103
96
|
file = self.blog.planet.config.fetch('templates_directory', '_layouts/') + 'header.md'
|
@@ -126,7 +119,8 @@ class Planet
|
|
126
119
|
data = {
|
127
120
|
image: self.blog.image,
|
128
121
|
author: self.blog.author,
|
129
|
-
|
122
|
+
blog_url: self.blog.url,
|
123
|
+
blog_title: self.blog.name,
|
130
124
|
twitter: self.blog.twitter ? "http://twitter.com/#{ self.blog.twitter }" : self.blog.url
|
131
125
|
}
|
132
126
|
|
@@ -138,11 +132,12 @@ class Planet
|
|
138
132
|
end
|
139
133
|
end
|
140
134
|
|
141
|
-
class Blog < Struct.new(:url, :feed, :author, :image, :twitter, :posts, :planet)
|
135
|
+
class Blog < Struct.new(:url, :feed, :name, :author, :image, :twitter, :posts, :planet)
|
142
136
|
|
143
137
|
def initialize(attributes = {})
|
144
138
|
self.url = attributes[:url]
|
145
139
|
self.feed = attributes[:feed]
|
140
|
+
self.name = attributes[:name]
|
146
141
|
self.author = attributes[:author]
|
147
142
|
self.image = attributes[:image]
|
148
143
|
self.twitter = attributes[:twitter]
|
data/lib/planet/version.rb
CHANGED