planet 0.1.3 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/planet +11 -8
- data/lib/planet.rb +32 -13
- data/lib/planet/version.rb +2 -2
- metadata +31 -11
data/bin/planet
CHANGED
@@ -19,11 +19,12 @@ command :generate do |c|
|
|
19
19
|
|
20
20
|
conf['blogs'].each do |blog|
|
21
21
|
@planet.blogs << Planet::Blog.new(
|
22
|
-
blog['feed'],
|
23
|
-
blog['author'],
|
24
|
-
blog['image'],
|
25
|
-
[],
|
26
|
-
@planet
|
22
|
+
feed: blog['feed'],
|
23
|
+
author: blog['author'],
|
24
|
+
image: blog['image'],
|
25
|
+
posts: [],
|
26
|
+
planet: @planet,
|
27
|
+
twitter: blog['twitter']
|
27
28
|
)
|
28
29
|
end
|
29
30
|
|
@@ -48,10 +49,12 @@ blogs:
|
|
48
49
|
- author: "Pablo Astigarraga"
|
49
50
|
feed: "http://blog.poteland.com/atom.xml"
|
50
51
|
image: "http://poteland.com/images/avatars/red_mage.png"
|
52
|
+
twitter: "poteland"
|
51
53
|
|
52
54
|
- author: "Cubox"
|
53
55
|
feed: "http://blog.cuboxlabs.com/atom.xml"
|
54
|
-
image: "http://cuboxlabs.com/img/cubox-humans/could-be-you.png"
|
56
|
+
image: "http://cuboxlabs.com/img/cubox-humans/could-be-you.png"
|
57
|
+
twitter: "cubox"'
|
55
58
|
|
56
59
|
File.open('planet.yml', 'w') { |f| f.write(default) }
|
57
60
|
|
@@ -69,9 +72,9 @@ command :create_templates do |c|
|
|
69
72
|
Dir.mkdir(templates_dir) unless File.exists?(templates_dir)
|
70
73
|
|
71
74
|
author = '<div class="author">
|
72
|
-
<img src="{{ image }}" style="width: 48px; height: 48px;">
|
75
|
+
<a href="{{ twitter }}"><img src="{{ image }}" style="width: 48px; height: 48px;"></a>
|
73
76
|
<span style="position: absolute; padding: 12px;">
|
74
|
-
<i>Original post by {{ author }} - <a href="{{
|
77
|
+
<i>Original post by {{ author }} - <a href="{{ blog }}">check out the original blog</a></i>
|
75
78
|
</span>
|
76
79
|
</div>
|
77
80
|
'
|
data/lib/planet.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'open-uri'
|
1
|
+
require 'feedzirra'
|
3
2
|
require 'mustache'
|
4
3
|
|
5
4
|
class Planet
|
@@ -49,14 +48,15 @@ class Planet
|
|
49
48
|
def aggregate
|
50
49
|
@@_blogs.each do |blog|
|
51
50
|
puts "=> Parsing #{ blog.feed }"
|
52
|
-
|
53
|
-
|
51
|
+
feed = Feedzirra::Feed.fetch_and_parse(blog.feed)
|
52
|
+
blog.url = feed.url
|
53
|
+
feed.entries.each do |entry|
|
54
54
|
@@_posts << @post = Post.new(
|
55
|
-
entry.
|
56
|
-
entry.
|
57
|
-
entry.
|
58
|
-
|
59
|
-
blog
|
55
|
+
title: entry.title,
|
56
|
+
content: entry.content.strip.gsub('<img src="', "<img src=\"#{ blog.url }"),
|
57
|
+
date: entry.published,
|
58
|
+
url: blog.url + entry.url,
|
59
|
+
blog: blog
|
60
60
|
)
|
61
61
|
|
62
62
|
blog.posts << @post
|
@@ -77,13 +77,21 @@ class Planet
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
class Post < Struct.new(:title, :content, :date, :
|
80
|
+
class Post < Struct.new(:title, :content, :date, :url, :blog)
|
81
|
+
|
82
|
+
def initialize(attributes = {})
|
83
|
+
self.title = attributes.fetch(:title, nil)
|
84
|
+
self.content = attributes.fetch(:content, nil)
|
85
|
+
self.date = attributes.fetch(:date, nil)
|
86
|
+
self.url = attributes.fetch(:url, nil)
|
87
|
+
self.blog = attributes.fetch(:blog, nil)
|
88
|
+
end
|
81
89
|
|
82
90
|
def to_hash
|
83
91
|
{
|
84
92
|
title: title,
|
85
93
|
date: date.strftime('%Y-%m-%d %H:%M'),
|
86
|
-
|
94
|
+
url: url,
|
87
95
|
content: content,
|
88
96
|
author: blog.author
|
89
97
|
}
|
@@ -117,7 +125,8 @@ class Planet
|
|
117
125
|
data = {
|
118
126
|
image: self.blog.image,
|
119
127
|
author: self.blog.author,
|
120
|
-
|
128
|
+
blog: self.blog.url,
|
129
|
+
twitter: self.blog.twitter ? "http://twitter.com/#{ self.blog.twitter }" : self.blog.url
|
121
130
|
}
|
122
131
|
|
123
132
|
Mustache.render(file_contents, data)
|
@@ -128,6 +137,16 @@ class Planet
|
|
128
137
|
end
|
129
138
|
end
|
130
139
|
|
131
|
-
class Blog < Struct.new(:feed, :author, :image, :posts, :planet)
|
140
|
+
class Blog < Struct.new(:url, :feed, :author, :image, :twitter, :posts, :planet)
|
141
|
+
|
142
|
+
def initialize(attributes = {})
|
143
|
+
self.url = attributes[:url]
|
144
|
+
self.feed = attributes[:feed]
|
145
|
+
self.author = attributes[:author]
|
146
|
+
self.image = attributes[:image]
|
147
|
+
self.twitter = attributes[:twitter]
|
148
|
+
self.posts = attributes.fetch('posts', [])
|
149
|
+
self.planet = attributes[:planet]
|
150
|
+
end
|
132
151
|
end
|
133
152
|
end
|
data/lib/planet/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: planet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-04-20 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: gli
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement:
|
47
|
+
name: feedzirra
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: mustache
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ! '>='
|
@@ -54,7 +69,12 @@ dependencies:
|
|
54
69
|
version: '0'
|
55
70
|
type: :runtime
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
58
78
|
description:
|
59
79
|
email: pote@tardis.com.uy
|
60
80
|
executables:
|
@@ -86,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
106
|
version: '0'
|
87
107
|
requirements: []
|
88
108
|
rubyforge_project:
|
89
|
-
rubygems_version: 1.8.
|
109
|
+
rubygems_version: 1.8.22
|
90
110
|
signing_key:
|
91
111
|
specification_version: 3
|
92
112
|
summary: An awesome rss/atom feed aggregator designed to work with Octopress/Jekyll
|