pluto 0.3.0 → 0.4.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.
- data/Manifest.txt +10 -2
- data/README.markdown +23 -5
- data/Rakefile +20 -7
- data/lib/pluto.rb +8 -4
- data/lib/pluto/{opts.rb → cli/opts.rb} +8 -1
- data/lib/pluto/{runner.rb → cli/runner.rb} +20 -35
- data/lib/pluto/fetcher.rb +101 -62
- data/lib/pluto/formatter.rb +6 -5
- data/lib/pluto/models.rb +1 -1
- data/lib/pluto/schema.rb +32 -0
- data/lib/pluto/server.rb +50 -0
- data/lib/pluto/server/public/style.css +6 -0
- data/lib/pluto/server/views/_debug.erb +16 -0
- data/lib/pluto/server/views/_version.erb +5 -0
- data/lib/pluto/server/views/debug.erb +2 -0
- data/lib/pluto/server/views/index.erb +8 -0
- data/lib/pluto/server/views/layout.erb +15 -0
- data/lib/pluto/version.rb +3 -1
- metadata +84 -65
data/Manifest.txt
CHANGED
@@ -4,11 +4,19 @@ README.markdown
|
|
4
4
|
Rakefile
|
5
5
|
bin/pluto
|
6
6
|
lib/pluto.rb
|
7
|
+
lib/pluto/cli/opts.rb
|
8
|
+
lib/pluto/cli/runner.rb
|
7
9
|
lib/pluto/fetcher.rb
|
8
10
|
lib/pluto/formatter.rb
|
9
11
|
lib/pluto/models.rb
|
10
|
-
lib/pluto/
|
11
|
-
lib/pluto/
|
12
|
+
lib/pluto/schema.rb
|
13
|
+
lib/pluto/server.rb
|
14
|
+
lib/pluto/server/public/style.css
|
15
|
+
lib/pluto/server/views/_debug.erb
|
16
|
+
lib/pluto/server/views/_version.erb
|
17
|
+
lib/pluto/server/views/debug.erb
|
18
|
+
lib/pluto/server/views/index.erb
|
19
|
+
lib/pluto/server/views/layout.erb
|
12
20
|
lib/pluto/version.rb
|
13
21
|
templates/blank.html.erb
|
14
22
|
templates/blank.top.html.erb
|
data/README.markdown
CHANGED
@@ -3,16 +3,19 @@
|
|
3
3
|
Another Planet Generator in Ruby - Lets You Build Web Pages
|
4
4
|
from Published Web Feeds
|
5
5
|
|
6
|
-
* [
|
6
|
+
* home :: [github.com/geraldb/pluto](https://github.com/geraldb/pluto)
|
7
|
+
* bugs :: [github.com/geraldb/pluto/issues](https://github.com/geraldb/pluto/issues)
|
8
|
+
* gem :: [rubygems.org/gems/pluto](https://rubygems.org/gems/pluto)
|
9
|
+
* rdoc :: [rubydoc.info/gems/pluto](http://rubydoc.info/gems/pluto)
|
7
10
|
|
8
11
|
|
9
12
|
## Usage
|
10
13
|
|
11
|
-
Use the `pluto` command line tool and pass in one or more planet configuration files.
|
14
|
+
Use the `pluto` command line tool and pass in one or more planet configuration files.
|
15
|
+
Example:
|
12
16
|
|
13
17
|
pluto ruby.yml
|
14
18
|
|
15
|
-
|
16
19
|
This will
|
17
20
|
|
18
21
|
1) fetch all feeds listed in `ruby.yml` and
|
@@ -24,6 +27,21 @@ This will
|
|
24
27
|
Open up `ruby.html` to see your planet web page. Voila!
|
25
28
|
|
26
29
|
|
30
|
+
### Command Line Tool
|
31
|
+
|
32
|
+
~~~
|
33
|
+
pluto - Lets you build web pages from published web feeds.
|
34
|
+
|
35
|
+
Usage: pluto [options] FILE
|
36
|
+
-t, --template MANIFEST Template Manifest (default is blank)
|
37
|
+
-c, --config PATH Configuration Path (default is ~/.pluto)
|
38
|
+
-o, --output PATH Output Path (default is .)
|
39
|
+
-v, --version Show version
|
40
|
+
--verbose Show debug trace
|
41
|
+
-h, --help Show this message
|
42
|
+
~~~
|
43
|
+
|
44
|
+
|
27
45
|
### Planet Configuration Sample
|
28
46
|
|
29
47
|
`ruby.yml`:
|
@@ -80,10 +98,10 @@ Just install the gem:
|
|
80
98
|
|
81
99
|
planet.rb by Akira Yamada [(Site)](http://planet.rubyforge.org)
|
82
100
|
|
83
|
-
Planet.rb by Pablo Astigarraga [(Site)](https://github.com/pote/planet.rb) - Used with Jekyll/Octopress Site
|
101
|
+
Planet.rb by Pablo Astigarraga [(Site)](https://github.com/pote/planet.rb) - Used with Jekyll/Octopress Site Generator
|
84
102
|
|
85
103
|
|
86
104
|
## License
|
87
105
|
|
88
106
|
The `pluto` scripts are dedicated to the public domain.
|
89
|
-
Use it as you please with no restrictions whatsoever.
|
107
|
+
Use it as you please with no restrictions whatsoever.
|
data/Rakefile
CHANGED
@@ -2,19 +2,32 @@ require 'hoe'
|
|
2
2
|
require './lib/pluto/version.rb'
|
3
3
|
|
4
4
|
Hoe.spec 'pluto' do
|
5
|
-
|
5
|
+
|
6
6
|
self.version = Pluto::VERSION
|
7
|
-
|
7
|
+
|
8
8
|
self.summary = 'pluto - Another Planet Generator'
|
9
9
|
self.description = 'pluto - Another Planet Generator (Lets You Build Web Pages from Published Web Feeds)'
|
10
10
|
|
11
|
-
self.urls = ['
|
12
|
-
|
11
|
+
self.urls = ['https://github.com/geraldb/pluto']
|
12
|
+
|
13
13
|
self.author = 'Gerald Bauer'
|
14
14
|
self.email = 'webslideshow@googlegroups.com'
|
15
|
-
|
15
|
+
|
16
16
|
# switch extension to .markdown for gihub formatting
|
17
17
|
self.readme_file = 'README.markdown'
|
18
18
|
self.history_file = 'History.markdown'
|
19
|
-
|
20
|
-
|
19
|
+
|
20
|
+
self.extra_deps = [
|
21
|
+
['pakman', '>= 0.5'],
|
22
|
+
['fetcher', '>= 0.3'],
|
23
|
+
['logutils', '>= 0.6']
|
24
|
+
## ['activerecord', '~> 3.2'], # NB: soft dependency, will include activesupport,etc.
|
25
|
+
]
|
26
|
+
|
27
|
+
self.licenses = ['Public Domain']
|
28
|
+
|
29
|
+
self.spec_extras = {
|
30
|
+
:required_ruby_version => '>= 1.9.2'
|
31
|
+
}
|
32
|
+
|
33
|
+
end
|
data/lib/pluto.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
###
|
2
2
|
# NB: for local testing run like:
|
3
3
|
#
|
4
|
-
# 1.8.x: ruby -Ilib -rrubygems lib/pakman.rb
|
5
4
|
# 1.9.x: ruby -Ilib lib/pakman.rb
|
6
5
|
|
7
6
|
# core and stlibs
|
@@ -18,18 +17,23 @@ require 'rss'
|
|
18
17
|
|
19
18
|
require 'active_record' ## todo: add sqlite3? etc.
|
20
19
|
|
20
|
+
|
21
|
+
require 'logutils'
|
21
22
|
require 'fetcher' # fetch (download) files
|
22
23
|
require 'pakman' # template pack manager
|
23
24
|
|
25
|
+
|
24
26
|
# our own code
|
25
27
|
|
28
|
+
require 'pluto/version' # let version always get first
|
29
|
+
require 'pluto/schema'
|
26
30
|
require 'pluto/models'
|
27
|
-
require 'pluto/version'
|
28
|
-
require 'pluto/opts'
|
29
|
-
require 'pluto/runner'
|
30
31
|
require 'pluto/fetcher'
|
31
32
|
require 'pluto/formatter'
|
32
33
|
|
34
|
+
require 'pluto/cli/opts'
|
35
|
+
require 'pluto/cli/runner'
|
36
|
+
|
33
37
|
module Pluto
|
34
38
|
|
35
39
|
def self.banner
|
@@ -7,9 +7,16 @@ class Opts
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def manifest
|
10
|
-
@manifest || 'blank.txt'
|
10
|
+
@manifest || 'blank.txt' ## todo - just return blank (no .txt extension - possible?)
|
11
11
|
end
|
12
12
|
|
13
|
+
def verbose=(value)
|
14
|
+
@verbose = true # note: assumes true; default is false
|
15
|
+
end
|
16
|
+
|
17
|
+
def verbose?
|
18
|
+
@verbose || false
|
19
|
+
end
|
13
20
|
|
14
21
|
def config_path=(value)
|
15
22
|
@config_path = value
|
@@ -3,21 +3,22 @@ module Pluto
|
|
3
3
|
|
4
4
|
class Runner
|
5
5
|
|
6
|
+
include LogUtils::Logging
|
7
|
+
|
6
8
|
def initialize
|
7
|
-
|
8
|
-
@logger.level = Logger::INFO
|
9
|
-
|
10
|
-
@opts = Opts.new
|
9
|
+
@opts = Opts.new
|
11
10
|
end
|
12
11
|
|
13
|
-
attr_reader :
|
12
|
+
attr_reader :opts
|
14
13
|
|
15
14
|
def run( args )
|
16
15
|
opt=OptionParser.new do |cmd|
|
17
16
|
|
18
|
-
cmd.banner = "Usage: pluto [options]"
|
17
|
+
cmd.banner = "Usage: pluto [options] FILE"
|
18
|
+
|
19
|
+
## fix/todo: remove .txt from default manifest
|
19
20
|
|
20
|
-
cmd.on( '-t', '--template MANIFEST',
|
21
|
+
cmd.on( '-t', '--template MANIFEST', "Template Manifest (default is #{opts.manifest})" ) do |manifest|
|
21
22
|
opts.manifest = manifest
|
22
23
|
end
|
23
24
|
|
@@ -33,10 +34,10 @@ class Runner
|
|
33
34
|
end
|
34
35
|
|
35
36
|
cmd.on( "--verbose", "Show debug trace" ) do
|
36
|
-
|
37
|
-
logger.level = Logger::DEBUG
|
37
|
+
LogUtils::Logger.root.level = :debug
|
38
38
|
end
|
39
39
|
|
40
|
+
## todo: add/allow -? too
|
40
41
|
cmd.on_tail( "-h", "--help", "Show this message" ) do
|
41
42
|
puts <<EOS
|
42
43
|
|
@@ -45,10 +46,10 @@ pluto - Lets you build web pages from published web feeds.
|
|
45
46
|
#{cmd.help}
|
46
47
|
|
47
48
|
Examples:
|
48
|
-
pluto ruby
|
49
|
+
pluto ruby
|
49
50
|
|
50
51
|
Further information:
|
51
|
-
|
52
|
+
https://github.com/geraldb/pluto
|
52
53
|
|
53
54
|
EOS
|
54
55
|
exit
|
@@ -64,8 +65,8 @@ EOS
|
|
64
65
|
name = File.basename( arg, '.*' )
|
65
66
|
|
66
67
|
db_config = {
|
67
|
-
:
|
68
|
-
:
|
68
|
+
adapter: 'sqlite3',
|
69
|
+
database: "#{opts.output_path}/#{name}.sqlite"
|
69
70
|
}
|
70
71
|
|
71
72
|
setup_db( db_config )
|
@@ -78,8 +79,8 @@ EOS
|
|
78
79
|
puts "dump >#{config_path}<:"
|
79
80
|
pp config
|
80
81
|
|
81
|
-
Fetcher.new(
|
82
|
-
Formatter.new(
|
82
|
+
Fetcher.new( opts, config ).run
|
83
|
+
Formatter.new( opts, config ).run( name )
|
83
84
|
|
84
85
|
end
|
85
86
|
|
@@ -91,29 +92,13 @@ EOS
|
|
91
92
|
private
|
92
93
|
|
93
94
|
def setup_db( db_config )
|
94
|
-
|
95
|
+
puts 'db settings:'
|
96
|
+
pp db_config
|
97
|
+
|
95
98
|
ActiveRecord::Base.establish_connection( db_config )
|
96
99
|
|
97
100
|
unless Feed.table_exists?
|
98
|
-
|
99
|
-
create_table :feeds do |t|
|
100
|
-
t.string :title, :null => false
|
101
|
-
t.string :url, :null => false
|
102
|
-
t.string :feed_url, :null => false
|
103
|
-
t.string :key, :null => false
|
104
|
-
t.timestamps
|
105
|
-
end
|
106
|
-
|
107
|
-
create_table :items do |t|
|
108
|
-
t.string :title # todo: add some :null => false ??
|
109
|
-
t.string :url
|
110
|
-
t.string :guid
|
111
|
-
t.text :content
|
112
|
-
t.datetime :published_at
|
113
|
-
t.references :feed, :null => false
|
114
|
-
t.timestamps
|
115
|
-
end
|
116
|
-
end
|
101
|
+
CreateDb.new.up # run db migratation, that is, create db tables
|
117
102
|
end
|
118
103
|
end # method setup_db
|
119
104
|
|
data/lib/pluto/fetcher.rb
CHANGED
@@ -3,17 +3,53 @@ module Pluto
|
|
3
3
|
|
4
4
|
class Fetcher
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
include LogUtils::Logging
|
7
|
+
|
8
|
+
def initialize( opts, config )
|
8
9
|
@opts = opts
|
9
10
|
@config = config
|
11
|
+
@worker = ::Fetcher::Worker.new
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :opts, :config, :worker
|
15
|
+
|
16
|
+
|
17
|
+
def fetch_feed( url )
|
18
|
+
xml = worker.read( url )
|
19
|
+
|
20
|
+
###
|
21
|
+
# NB: Net::HTTP will NOT set encoding UTF-8 etc.
|
22
|
+
# will mostly be ASCII
|
23
|
+
# - try to change encoding to UTF-8 ourselves
|
24
|
+
logger.debug "xml.encoding.name (before): #{xml.encoding.name}"
|
25
|
+
|
26
|
+
#####
|
27
|
+
# NB: ASCII-8BIT == BINARY == Encoding Unknown; Raw Bytes Here
|
28
|
+
|
29
|
+
## NB:
|
30
|
+
# for now "hardcoded" to utf8 - what else can we do?
|
31
|
+
# - note: force_encoding will NOT change the chars only change the assumed encoding w/o translation
|
32
|
+
xml = xml.force_encoding( Encoding::UTF_8 )
|
33
|
+
logger.debug "xml.encoding.name (after): #{xml.encoding.name}"
|
34
|
+
xml
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
def parse_feed( xml )
|
39
|
+
parser = RSS::Parser.new( xml )
|
40
|
+
parser.do_validate = false
|
41
|
+
parser.ignore_unknown_element = true
|
42
|
+
|
43
|
+
puts "Parsing feed..."
|
44
|
+
feed = parser.parse
|
45
|
+
|
46
|
+
puts " feed.class=#{feed.class.name}"
|
47
|
+
feed
|
10
48
|
end
|
11
49
|
|
12
|
-
attr_reader :logger, :opts, :config
|
13
50
|
|
14
|
-
|
15
51
|
def run
|
16
|
-
|
52
|
+
logger.debug "RSS::VERSION #{RSS::VERSION}"
|
17
53
|
|
18
54
|
config[ 'feeds' ].each do |feed_key|
|
19
55
|
|
@@ -32,50 +68,62 @@ class Fetcher
|
|
32
68
|
feed_rec.title = feed_hash[ 'title' ] # todo: use title from feed?
|
33
69
|
feed_rec.save!
|
34
70
|
|
35
|
-
|
36
|
-
end
|
71
|
+
feed_xml = fetch_feed( feed_url )
|
37
72
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
feed_hash = config[ feed_key ]
|
43
|
-
feed_rec = Feed.find_by_key!( feed_key )
|
73
|
+
# if opts.verbose? # also write a copy to disk
|
74
|
+
# ## fix: use just File.write instead of fetching again
|
75
|
+
# worker.copy( feed_url, "./#{feed_key}.xml" )
|
76
|
+
# end
|
44
77
|
|
45
|
-
xml = File.read( "./#{feed_key}.xml" )
|
46
|
-
|
47
|
-
puts "Before parsing feed >#{feed_key}<..."
|
78
|
+
# xml = File.read( "./#{feed_key}.xml" )
|
48
79
|
|
49
|
-
|
50
|
-
parser.do_validate = false
|
51
|
-
parser.ignore_unknown_element = true
|
52
|
-
|
53
|
-
puts "Parsing feed >#{feed_key}<..."
|
54
|
-
feed = parser.parse
|
55
|
-
puts "After parsing feed >#{feed_key}<..."
|
56
|
-
|
57
|
-
puts "feed.class=#{feed.class.name}"
|
80
|
+
puts "Before parsing feed >#{feed_key}<..."
|
58
81
|
|
82
|
+
feed = parse_feed( feed_xml )
|
59
83
|
|
60
84
|
if feed.class == RSS::Atom::Feed
|
61
|
-
|
62
|
-
else
|
63
|
-
|
85
|
+
puts "== #{feed.title.content} =="
|
86
|
+
else ## assume RSS::Rss::Feed
|
87
|
+
puts "== #{feed.channel.title} =="
|
64
88
|
end
|
65
|
-
|
66
|
-
feed.items.each do |item|
|
67
89
|
|
90
|
+
feed.items.each do |item|
|
68
91
|
if feed.class == RSS::Atom::Feed
|
92
|
+
item_attribs = handle_feed_item_atom( item )
|
93
|
+
else ## assume RSS::Rss::Feed
|
94
|
+
item_attribs = handle_feed_item_rss( item )
|
95
|
+
end
|
96
|
+
|
97
|
+
# add feed_id fk_ref
|
98
|
+
item_attribs[ :feed_id ] = feed_rec.id
|
99
|
+
|
100
|
+
rec = Item.find_by_guid( item_attribs[ :guid ] )
|
101
|
+
if rec.nil?
|
102
|
+
rec = Item.new
|
103
|
+
puts "** NEW"
|
104
|
+
else
|
105
|
+
puts "UPDATE"
|
106
|
+
end
|
107
|
+
|
108
|
+
rec.update_attributes!( item_attribs )
|
109
|
+
end # each item
|
110
|
+
|
111
|
+
end # each feed
|
112
|
+
|
113
|
+
end # method run
|
114
|
+
|
115
|
+
|
116
|
+
def handle_feed_item_atom( item )
|
69
117
|
|
70
118
|
## todo: if content.content empty use summary for example
|
71
119
|
item_attribs = {
|
72
|
-
:
|
73
|
-
:
|
74
|
-
:
|
75
|
-
# :
|
76
|
-
:feed_id => feed_rec.id
|
120
|
+
title: item.title.content,
|
121
|
+
url: item.link.href,
|
122
|
+
published_at: item.updated.content.utc.strftime( "%Y-%m-%d %H:%M" ),
|
123
|
+
# content: item.content.content,
|
77
124
|
}
|
78
|
-
|
125
|
+
|
126
|
+
item_attribs[ :guid ] = item.id.content
|
79
127
|
|
80
128
|
if item.summary
|
81
129
|
item_attribs[ :content ] = item.summary.content
|
@@ -98,14 +146,19 @@ class Fetcher
|
|
98
146
|
puts " updated (~pubDate) >#{item.updated.content}< >#{item.updated.content.utc.strftime( "%Y-%m-%d %H:%M" )}< : #{item.updated.content.class.name}"
|
99
147
|
puts
|
100
148
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
149
|
+
# puts "*** dump item:"
|
150
|
+
# pp item
|
151
|
+
|
152
|
+
item_attribs
|
153
|
+
end
|
154
|
+
|
155
|
+
def handle_feed_item_rss( item )
|
156
|
+
|
157
|
+
item_attribs = {
|
158
|
+
title: item.title,
|
159
|
+
url: item.link,
|
160
|
+
published_at: item.pubDate.utc.strftime( "%Y-%m-%d %H:%M" ),
|
161
|
+
# content: item.content_encoded,
|
109
162
|
}
|
110
163
|
|
111
164
|
# if item.content_encoded.nil?
|
@@ -113,7 +166,7 @@ class Fetcher
|
|
113
166
|
item_attribs[ :content ] = item.description
|
114
167
|
# end
|
115
168
|
|
116
|
-
guid = item.guid.content
|
169
|
+
item_attribs[ :guid ] = item.guid.content
|
117
170
|
|
118
171
|
puts "- #{item.title}"
|
119
172
|
puts " link (#{item.link})"
|
@@ -121,26 +174,12 @@ class Fetcher
|
|
121
174
|
puts " pubDate >#{item.pubDate}< >#{item.pubDate.utc.strftime( "%Y-%m-%d %H:%M" )}< : #{item.pubDate.class.name}"
|
122
175
|
puts
|
123
176
|
|
124
|
-
end
|
125
|
-
|
126
|
-
rec = Item.find_by_guid( guid )
|
127
|
-
if rec.nil?
|
128
|
-
rec = Item.new
|
129
|
-
rec.guid = guid
|
130
|
-
puts "** NEW"
|
131
|
-
else
|
132
|
-
puts "UPDATE"
|
133
|
-
end
|
134
|
-
|
135
|
-
rec.update_attributes!( item_attribs )
|
136
|
-
|
137
177
|
# puts "*** dump item:"
|
138
178
|
# pp item
|
139
|
-
|
140
|
-
end # each item
|
141
|
-
end # each feed
|
142
179
|
|
143
|
-
|
180
|
+
item_attribs
|
181
|
+
end
|
182
|
+
|
144
183
|
|
145
184
|
end # class Fetcher
|
146
185
|
|
data/lib/pluto/formatter.rb
CHANGED
@@ -2,13 +2,14 @@ module Pluto
|
|
2
2
|
|
3
3
|
class Formatter
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
include LogUtils::Logging
|
6
|
+
|
7
|
+
def initialize( opts, config )
|
7
8
|
@opts = opts
|
8
9
|
@config = config
|
9
10
|
end
|
10
11
|
|
11
|
-
attr_reader :
|
12
|
+
attr_reader :opts
|
12
13
|
|
13
14
|
def headers
|
14
15
|
@config
|
@@ -33,7 +34,7 @@ class Formatter
|
|
33
34
|
|
34
35
|
|
35
36
|
name = arg
|
36
|
-
Pakman::Templater.new
|
37
|
+
Pakman::Templater.new.merge_pak( manifestsrc, pakpath, binding, name )
|
37
38
|
end
|
38
39
|
|
39
40
|
private
|
@@ -68,7 +69,7 @@ private
|
|
68
69
|
"*/Manifest.txt"
|
69
70
|
]
|
70
71
|
|
71
|
-
Pakman::Finder.new
|
72
|
+
Pakman::Finder.new.find_manifests( installed_template_manifest_patterns, excludes )
|
72
73
|
end
|
73
74
|
|
74
75
|
end # class Formatter
|
data/lib/pluto/models.rb
CHANGED
data/lib/pluto/schema.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
module Pluto
|
3
|
+
|
4
|
+
class CreateDb < ActiveRecord::Migration
|
5
|
+
|
6
|
+
def up
|
7
|
+
create_table :feeds do |t|
|
8
|
+
t.string :title, :null => false
|
9
|
+
t.string :url, :null => false
|
10
|
+
t.string :feed_url, :null => false
|
11
|
+
t.string :key, :null => false
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
|
15
|
+
create_table :items do |t|
|
16
|
+
t.string :title # todo: add some :null => false ??
|
17
|
+
t.string :url
|
18
|
+
t.string :guid
|
19
|
+
t.text :content
|
20
|
+
t.datetime :published_at
|
21
|
+
t.references :feed, :null => false
|
22
|
+
t.timestamps
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def down
|
27
|
+
raise ActiveRecord::IrreversibleMigration
|
28
|
+
end
|
29
|
+
|
30
|
+
end # class CreateDb
|
31
|
+
|
32
|
+
end # module Pluto
|
data/lib/pluto/server.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
######
|
2
|
+
# NB: use rackup to startup Sinatra service (see config.ru)
|
3
|
+
#
|
4
|
+
# e.g. config.ru:
|
5
|
+
# require './boot'
|
6
|
+
# run Pluto::Server
|
7
|
+
|
8
|
+
|
9
|
+
# 3rd party libs/gems
|
10
|
+
|
11
|
+
require 'sinatra/base'
|
12
|
+
|
13
|
+
|
14
|
+
module Pluto
|
15
|
+
|
16
|
+
class Server < Sinatra::Base
|
17
|
+
|
18
|
+
def self.banner
|
19
|
+
"pluto-service #{Pluto::VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] on Sinatra/#{Sinatra::VERSION} (#{ENV['RACK_ENV']})"
|
20
|
+
end
|
21
|
+
|
22
|
+
PUBLIC_FOLDER = "#{Pluto.root}/lib/pluto/server/public"
|
23
|
+
VIEWS_FOLDER = "#{Pluto.root}/lib/pluto/server/views"
|
24
|
+
|
25
|
+
puts "[boot] pluto-service - setting public folder to: #{PUBLIC_FOLDER}"
|
26
|
+
puts "[boot] pluto-service - setting views folder to: #{VIEWS_FOLDER}"
|
27
|
+
|
28
|
+
set :public_folder, PUBLIC_FOLDER # set up the static dir (with images/js/css inside)
|
29
|
+
set :views, VIEWS_FOLDER # set up the views dir
|
30
|
+
|
31
|
+
set :static, true # set up static file routing
|
32
|
+
|
33
|
+
##############################################
|
34
|
+
# Controllers / Routing / Request Handlers
|
35
|
+
|
36
|
+
get '/' do
|
37
|
+
erb :index
|
38
|
+
end
|
39
|
+
|
40
|
+
get '/d*' do
|
41
|
+
erb :debug
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
end # class Server
|
46
|
+
end # module Pluto
|
47
|
+
|
48
|
+
|
49
|
+
# say hello
|
50
|
+
puts Pluto::Server.banner
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<h3>Debug</h3>
|
2
|
+
|
3
|
+
<pre>
|
4
|
+
request.scheme <%= request.scheme %>
|
5
|
+
request.script_name <%= request.script_name %>
|
6
|
+
request.path_info <%= request.path_info %>
|
7
|
+
request.port <%= request.port %>
|
8
|
+
request.request_method <%= request.request_method %>
|
9
|
+
request.query_string <%= request.query_string %>
|
10
|
+
request.host <%= request.host %>
|
11
|
+
request.referrer <%= request.referrer %>
|
12
|
+
request.user_agent <%= request.user_agent %>
|
13
|
+
request.url <%= request.url %>
|
14
|
+
request.path <%= request.path %>
|
15
|
+
request.ip <%= request.ip %>
|
16
|
+
</pre>
|
data/lib/pluto/version.rb
CHANGED
metadata
CHANGED
@@ -1,111 +1,130 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: pluto
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 0
|
10
|
-
version: 0.3.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Gerald Bauer
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
date: 2013-09-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: pakman
|
16
|
+
requirement: &81211800 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0.5'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *81211800
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: fetcher
|
27
|
+
requirement: &81211430 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0.3'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *81211430
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: logutils
|
38
|
+
requirement: &81211020 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0.6'
|
44
|
+
type: :runtime
|
22
45
|
prerelease: false
|
23
|
-
|
46
|
+
version_requirements: *81211020
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rdoc
|
49
|
+
requirement: &81210620 !ruby/object:Gem::Requirement
|
24
50
|
none: false
|
25
|
-
requirements:
|
51
|
+
requirements:
|
26
52
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 3
|
31
|
-
- 10
|
32
|
-
version: "3.10"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.10'
|
33
55
|
type: :development
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: hoe
|
37
56
|
prerelease: false
|
38
|
-
|
57
|
+
version_requirements: *81210620
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: hoe
|
60
|
+
requirement: &81210350 !ruby/object:Gem::Requirement
|
39
61
|
none: false
|
40
|
-
requirements:
|
62
|
+
requirements:
|
41
63
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
segments:
|
45
|
-
- 3
|
46
|
-
- 0
|
47
|
-
version: "3.0"
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '3.3'
|
48
66
|
type: :development
|
49
|
-
|
50
|
-
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *81210350
|
69
|
+
description: pluto - Another Planet Generator (Lets You Build Web Pages from Published
|
70
|
+
Web Feeds)
|
51
71
|
email: webslideshow@googlegroups.com
|
52
|
-
executables:
|
72
|
+
executables:
|
53
73
|
- pluto
|
54
74
|
extensions: []
|
55
|
-
|
56
|
-
extra_rdoc_files:
|
75
|
+
extra_rdoc_files:
|
57
76
|
- Manifest.txt
|
58
77
|
- templates/blank.txt
|
59
|
-
files:
|
78
|
+
files:
|
60
79
|
- History.markdown
|
61
80
|
- Manifest.txt
|
62
81
|
- README.markdown
|
63
82
|
- Rakefile
|
64
83
|
- bin/pluto
|
65
84
|
- lib/pluto.rb
|
85
|
+
- lib/pluto/cli/opts.rb
|
86
|
+
- lib/pluto/cli/runner.rb
|
66
87
|
- lib/pluto/fetcher.rb
|
67
88
|
- lib/pluto/formatter.rb
|
68
89
|
- lib/pluto/models.rb
|
69
|
-
- lib/pluto/
|
70
|
-
- lib/pluto/
|
90
|
+
- lib/pluto/schema.rb
|
91
|
+
- lib/pluto/server.rb
|
92
|
+
- lib/pluto/server/public/style.css
|
93
|
+
- lib/pluto/server/views/_debug.erb
|
94
|
+
- lib/pluto/server/views/_version.erb
|
95
|
+
- lib/pluto/server/views/debug.erb
|
96
|
+
- lib/pluto/server/views/index.erb
|
97
|
+
- lib/pluto/server/views/layout.erb
|
71
98
|
- lib/pluto/version.rb
|
72
99
|
- templates/blank.html.erb
|
73
100
|
- templates/blank.top.html.erb
|
74
101
|
- templates/blank.txt
|
75
102
|
- templates/feed-icon-10x10.png
|
76
|
-
homepage:
|
77
|
-
licenses:
|
78
|
-
|
103
|
+
homepage: https://github.com/geraldb/pluto
|
104
|
+
licenses:
|
105
|
+
- Public Domain
|
79
106
|
post_install_message:
|
80
|
-
rdoc_options:
|
107
|
+
rdoc_options:
|
81
108
|
- --main
|
82
109
|
- README.markdown
|
83
|
-
require_paths:
|
110
|
+
require_paths:
|
84
111
|
- lib
|
85
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
113
|
none: false
|
87
|
-
requirements:
|
88
|
-
- -
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
|
91
|
-
|
92
|
-
- 0
|
93
|
-
version: "0"
|
94
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ! '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.9.2
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
119
|
none: false
|
96
|
-
requirements:
|
97
|
-
- -
|
98
|
-
- !ruby/object:Gem::Version
|
99
|
-
|
100
|
-
segments:
|
101
|
-
- 0
|
102
|
-
version: "0"
|
120
|
+
requirements:
|
121
|
+
- - ! '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
103
124
|
requirements: []
|
104
|
-
|
105
125
|
rubyforge_project: pluto
|
106
|
-
rubygems_version: 1.8.
|
126
|
+
rubygems_version: 1.8.17
|
107
127
|
signing_key:
|
108
128
|
specification_version: 3
|
109
129
|
summary: pluto - Another Planet Generator
|
110
130
|
test_files: []
|
111
|
-
|