pluto-admin 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -7,11 +7,14 @@ lib/pluto/admin/public/feed-icon-10x10.png
7
7
  lib/pluto/admin/public/style.css
8
8
  lib/pluto/admin/server.rb
9
9
  lib/pluto/admin/version.rb
10
- lib/pluto/admin/views/_debug.erb
11
- lib/pluto/admin/views/_version.erb
12
10
  lib/pluto/admin/views/debug.erb
11
+ lib/pluto/admin/views/feed.erb
13
12
  lib/pluto/admin/views/feeds.erb
13
+ lib/pluto/admin/views/item.erb
14
14
  lib/pluto/admin/views/items.erb
15
15
  lib/pluto/admin/views/layout.erb
16
+ lib/pluto/admin/views/shared/_debug.erb
17
+ lib/pluto/admin/views/shared/_items.erb
18
+ lib/pluto/admin/views/shared/_version.erb
16
19
  lib/pluto/admin/views/sites.erb
17
20
  lib/pluto/admin/views/timeline.erb
data/README.md CHANGED
@@ -7,6 +7,7 @@ planet web admin - sintara web app ready to get mounted into your web app
7
7
  * bugs :: [github.com/feedreader/pluto.admin/issues](https://github.com/feedreader/pluto.admin/issues)
8
8
  * gem :: [rubygems.org/gems/pluto-admin](https://rubygems.org/gems/pluto-admin)
9
9
  * rdoc :: [rubydoc.info/gems/pluto-admin](http://rubydoc.info/gems/pluto-admin)
10
+ * forum :: [groups.google.com/group/feedreader](http://groups.google.com/group/feedreader)
10
11
 
11
12
 
12
13
  ## Usage
@@ -35,3 +36,9 @@ end
35
36
 
36
37
  The `pluto.admin` scripts are dedicated to the public domain.
37
38
  Use it as you please with no restrictions whatsoever.
39
+
40
+
41
+ ## Questions? Comments?
42
+
43
+ Send them along to the [Planet Pluto and Friends Forum/Mailing List](http://groups.google.com/group/feedreader).
44
+ Thanks!
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ Hoe.spec 'pluto-admin' do
11
11
  self.urls = ['https://github.com/feedreader/pluto.admin']
12
12
 
13
13
  self.author = 'Gerald Bauer'
14
- self.email = 'webslideshow@googlegroups.com'
14
+ self.email = 'feedreader@googlegroups.com'
15
15
 
16
16
  # switch extension to .markdown for gihub formatting
17
17
  self.readme_file = 'README.md'
@@ -29,4 +29,4 @@ Hoe.spec 'pluto-admin' do
29
29
  }
30
30
 
31
31
 
32
- end
32
+ end
@@ -50,11 +50,19 @@ class Server < Sinatra::Base
50
50
  def feeds_path
51
51
  "#{path_prefix}/feeds"
52
52
  end
53
+
54
+ def feed_path( feed )
55
+ "#{path_prefix}/feed/#{feed.key}"
56
+ end
53
57
 
54
58
  def items_path
55
59
  "#{path_prefix}/items"
56
60
  end
57
-
61
+
62
+ def item_path( item )
63
+ "#{path_prefix}/item/#{item.id}"
64
+ end
65
+
58
66
  def timeline_path
59
67
  "#{path_prefix}/time"
60
68
  end
@@ -67,6 +75,9 @@ class Server < Sinatra::Base
67
75
  url( '/' )
68
76
  end
69
77
 
78
+ def content_tag( tag, text )
79
+ "<#{tag}>#{text}</#{tag}>"
80
+ end
70
81
 
71
82
  def link_to( text, url, opts={} )
72
83
  attributes = ""
@@ -77,6 +88,38 @@ class Server < Sinatra::Base
77
88
  end
78
89
 
79
90
 
91
+ def render_items( items, opts={} )
92
+ erb( 'shared/_items'.to_sym,
93
+ layout: false,
94
+ locals: {
95
+ items: items,
96
+ show_feed: opts[:show_feed].present?
97
+ })
98
+ end
99
+
100
+ def prettify_xml( xml )
101
+ require 'rexml/document'
102
+
103
+ begin
104
+ d = REXML::Document.new( xml )
105
+
106
+ # d.write( pretty_xml="", 2 )
107
+ # pretty_xml # return prettified xml
108
+
109
+ formatter = REXML::Formatters::Pretty.new( 2 ) # indent=2
110
+ formatter.compact = true # This is the magic line that does what you need!
111
+ pretty_xml = formatter.write( d.root, "" ) # todo/checl: what's 2nd arg used for ??
112
+ pretty_xml
113
+ rescue Exception => ex
114
+ "warn: prettify_xml failed: #{ex}\n\n\n" + xml
115
+ end
116
+ end
117
+
118
+
119
+ def h( text )
120
+ Rack::Utils.escape_html(text)
121
+ end
122
+
80
123
  ##############################################
81
124
  # Controllers / Routing / Request Handlers
82
125
 
@@ -88,10 +131,20 @@ class Server < Sinatra::Base
88
131
  erb :sites # needed or default fallthrough possible ???
89
132
  end
90
133
 
134
+ get '/feed/:key' do |key|
135
+ @feed = Feed.find_by_key!( key )
136
+ erb :feed
137
+ end
138
+
91
139
  get '/feeds' do
92
140
  erb :feeds # needed or default fallthrough possible ???
93
141
  end
94
142
 
143
+ get '/item/:id' do |id|
144
+ @item = Item.find( id )
145
+ erb :item
146
+ end
147
+
95
148
  get '/items' do
96
149
  erb :items # needed or default fallthrough possible ???
97
150
  end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module PlutoAdmin
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
@@ -11,5 +11,5 @@
11
11
  timeline_path: <%= timeline_path %>
12
12
  </pre>
13
13
 
14
- <%= erb :'_debug' %>
14
+ <%= erb :'shared/_debug' %>
15
15
 
@@ -0,0 +1,100 @@
1
+
2
+ <% feed = @feed %>
3
+
4
+ <h2>
5
+
6
+ <span class='key'><%= feed.key %></span>
7
+
8
+ <a href='<%= feed.url %>'>
9
+ <b><%= feed.title %></b>
10
+ </a>
11
+
12
+ <!-- fix: use class format ?? -->
13
+ <span class='key'>
14
+ <%= feed.format %>
15
+ </span>
16
+
17
+
18
+ <a href='<%= feed.feed_url %>'>
19
+ <img src='<%= url( "/feed-icon-10x10.png" )%>'></img>
20
+ </a>
21
+
22
+ <span class='key'>
23
+ -
24
+ Update:
25
+ <% if feed.fetched %>
26
+ <%= feed.fetched.strftime( '%b %d, %Y %H:%M' ) %>
27
+ <% else %>
28
+ ---
29
+ <% end %>
30
+ </span>
31
+ </h2>
32
+
33
+ <p>
34
+
35
+ <%# if feed.summary || feed.title2 %>
36
+ <% if feed.summary %>
37
+ <%= feed.summary %> <!-- rss/description -->
38
+ <%#= feed.title2 %> <!-- atom/subtitle -->
39
+ <% else %>
40
+ --no-summary--
41
+ <% end %>
42
+ </p>
43
+
44
+ <p> published:
45
+ <% if feed.published? %>
46
+ <%= feed.published.strftime( '%b %d, %Y %H:%M' ) %>
47
+ <% else %>
48
+ ---
49
+ <% end %>
50
+
51
+ <br> updated:
52
+ <% if feed.touched? %>
53
+ <%= feed.touched.strftime( '%b %d, %Y %H:%M' ) %>
54
+ <% else %>
55
+ ---
56
+ <% end %>
57
+
58
+ <br> last-build:
59
+ <% if feed.built? %>
60
+ <%= feed.built.strftime( '%b %d, %Y %H:%M' ) %>
61
+ <% else %>
62
+ ---
63
+ <% end %>
64
+
65
+ <br> generator:
66
+ <% if feed.generator %>
67
+ <%= feed.generator %>
68
+ <% else %>
69
+ ---
70
+ <% end %>
71
+ </p>
72
+
73
+ <p> HTTP
74
+ <!-- make <> 200,304 red/bold??? -->
75
+ <%= feed.http_code %>
76
+
77
+ | last-modified:
78
+
79
+ <% if feed.http_last_modified %>
80
+ <%= feed.http_last_modified %>
81
+ <% else %>
82
+ ---
83
+ <% end %>
84
+
85
+ | etag:
86
+ <% if feed.http_etag %>
87
+ <%= feed.http_etag %>
88
+ <% else %>
89
+ ---
90
+ <% end %>
91
+ </p>
92
+
93
+ <%= render_items( feed.items.latest ) %>
94
+
95
+ <h3>Source</h3>
96
+
97
+ <% if feed.body %>
98
+ <pre><code><%= h prettify_xml( feed.body ) %>
99
+ </code></pre>
100
+ <% end %>
@@ -2,17 +2,16 @@
2
2
  <h2><%= Feed.count %> Feeds</h2>
3
3
 
4
4
  <table>
5
- <% Feed.latest.all.each do |feed| %>
5
+ <% Feed.latest.each do |feed| %>
6
6
  <tr>
7
7
  <td class='key'><%= feed.key %></td>
8
8
  <td>
9
- <a href='<%= feed.url %>'>
10
- <b><%= feed.title %></b>
11
- </a>
9
+ <%= link_to( content_tag( :b, feed.title ), feed_path( feed )) %>
12
10
  <span class='count'>(<%= feed.items.count %>)</span> <br>
13
- <% if feed.summary || feed.title2 %>
11
+ <%# if feed.summary || feed.title2 %>
12
+ <% if feed.summary %>
14
13
  <%= feed.summary %> <!-- rss/description -->
15
- <%= feed.title2 %> <!-- atom/subtitle -->
14
+ <%#= feed.title2 %> <!-- atom/subtitle -->
16
15
  <% else %>
17
16
  --no-summary--
18
17
  <% end %>
@@ -22,22 +21,22 @@
22
21
  </a>
23
22
  </td>
24
23
  <td>
25
- <% if feed.published_at? %>
26
- <%= feed.published_at.strftime( '%b %d, %Y %H:%M' ) %>
24
+ <% if feed.published? %>
25
+ <%= feed.published.strftime( '%b %d, %Y %H:%M' ) %>
27
26
  <% else %>
28
27
  --no-published--
29
28
  <% end %>
30
29
  </td>
31
30
  <td>
32
- <% if feed.touched_at %>
33
- <%= feed.touched_at.strftime( '%b %d, %Y %H:%M' ) %>
31
+ <% if feed.touched? %>
32
+ <%= feed.touched.strftime( '%b %d, %Y %H:%M' ) %>
34
33
  <% else %>
35
34
  --no-updated--
36
35
  <% end %>
37
36
  </td>
38
37
  <td>
39
- <% if feed.built_at %>
40
- <%= feed.built_at.strftime( '%b %d, %Y %H:%M' ) %>
38
+ <% if feed.built? %>
39
+ <%= feed.built.strftime( '%b %d, %Y %H:%M' ) %>
41
40
  <% else %>
42
41
  --no-last-build--
43
42
  <% end %>
@@ -50,13 +49,30 @@
50
49
  <% end %>
51
50
  </td>
52
51
  <td>
53
- <% if feed.fetched_at %>
54
- <%= feed.fetched_at.strftime( '%b %d, %Y %H:%M' ) %>
52
+ <% if feed.fetched %>
53
+ <%= feed.fetched.strftime( '%b %d, %Y %H:%M' ) %>
55
54
  <% else %>
56
55
  --no-fetched--
57
56
  <% end %>
58
57
  </td>
59
- <td><%= feed.etag %></td>
58
+ <td>
59
+ <!-- make <> 200,304 red/bold??? -->
60
+ <%= feed.http_code %>
61
+ </td>
62
+ <td>
63
+ <% if feed.http_etag %>
64
+ <%= feed.http_etag %>
65
+ <% else %>
66
+ --no-etag--
67
+ <% end %>
68
+ </td>
69
+ <td>
70
+ <% if feed.http_last_modified %>
71
+ <%= feed.http_last_modified %>
72
+ <% else %>
73
+ --no-last-modified--
74
+ <% end %>
75
+ </td>
60
76
  </tr>
61
77
  <% end %>
62
78
  </table>
@@ -0,0 +1,82 @@
1
+
2
+ <% item = @item %>
3
+
4
+ <p>
5
+ <%= link_to item.feed.title, feed_path( item.feed ) %>
6
+ </p>
7
+
8
+ <h2>
9
+ <%= link_to item.title, item.url %>
10
+
11
+ <!-- fix: use class format ?? -->
12
+ <span class='key'>
13
+ <%= item.feed.format %>
14
+ </span>
15
+
16
+ <a href='<%= item.feed.feed_url %>'>
17
+ <img src='<%= url( "/feed-icon-10x10.png" )%>'></img>
18
+ </a>
19
+
20
+ <span class='key'>
21
+ -
22
+ Update:
23
+ <% if item.fetched %>
24
+ <%= item.fetched.strftime( '%b %d, %Y %H:%M' ) %>
25
+ <% else %>
26
+ ---
27
+ <% end %>
28
+ </span>
29
+ </h2>
30
+
31
+ <p>
32
+ guid: <span class='key'><%= item.guid %></span>
33
+
34
+ <br>
35
+
36
+ published:
37
+ <% if item.published? %>
38
+ <%= item.published.strftime( '%b %d, %Y %H:%M' ) %>
39
+ <% else %>
40
+ ---
41
+ <% end %>
42
+
43
+ <br>
44
+ updated:
45
+ <% if item.touched? %>
46
+ <%= item.touched.strftime( '%b %d, %Y %H:%M' ) %>
47
+ <% else %>
48
+ ---
49
+ <% end %>
50
+ </p>
51
+
52
+
53
+ <% if item.summary? %>
54
+ <h3>Summary
55
+ <span class='key'><%= item.summary.length %> bytes</span>
56
+ </h3>
57
+ <div>
58
+ <pre><code><%= h item.summary %>
59
+ </code></pre>
60
+ </div>
61
+ <% else %>
62
+ <h3>Summary</h3>
63
+ <p>
64
+ --no-summary--
65
+ </p>
66
+ <% end %>
67
+
68
+
69
+ <% if item.content? %>
70
+ <h3>Content
71
+ <span class='key'><%= item.content.length %> bytes</span>
72
+ </h3>
73
+ <div>
74
+ <pre><code><%= h item.content %>
75
+ </code></pre>
76
+ </div>
77
+ <% else %>
78
+ <h3>Content</h3>
79
+ <p>
80
+ --no-content--
81
+ </p>
82
+ <% end %>
@@ -1,60 +1,2 @@
1
1
 
2
- <h2><%= Item.count %> Items</h2>
3
-
4
- <table>
5
- <% Item.latest.all.each do |item| %>
6
- <tr>
7
- <td><a href='<%= item.url %>'>
8
- <%= item.title %>
9
- </a>
10
- </td>
11
-
12
- <td>
13
- <% if item.summary? %>
14
- <%= item.summary.length %>
15
- <% else %>
16
- --no-summary--
17
- <% end %>
18
- </td>
19
-
20
- <td>
21
- <% if item.content? %>
22
- <%= item.content.length %>
23
- <% else %>
24
- --no-content--
25
- <% end %>
26
- </td>
27
-
28
- <td class='key'><%= item.guid %></td>
29
-
30
- <td>
31
- <% if item.published_at? %>
32
- <%= item.published_at.strftime( '%b %d, %Y %H:%M' ) %>
33
- <% else %>
34
- --no-published--
35
- <% end %>
36
- </td>
37
- <td>
38
- <% if item.touched_at %>
39
- <%= item.touched_at.strftime( '%b %d, %Y %H:%M' ) %>
40
- <% else %>
41
- --no-updated--
42
- <% end %>
43
- </td>
44
- <td><a href='<%= item.feed.url %>'>
45
- <%= item.feed.title %>
46
- </a>
47
- <a href='<%= item.feed.feed_url %>'>
48
- <img src='<%= url( "/feed-icon-10x10.png" )%>'></img>
49
- </a>
50
- </td>
51
- <td>
52
- <% if item.fetched_at %>
53
- <%= item.fetched_at.strftime( '%b %d, %Y %H:%M' ) %>
54
- <% else %>
55
- --no-fetched--
56
- <% end %>
57
- </td>
58
- </tr>
59
- <% end %>
60
- </table>
2
+ <%= render_items( Item.latest, show_feed: true ) %>
@@ -1,23 +1,23 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <meta charset='UTF-8'>
5
- <title>Pluto / Admin</title>
4
+ <meta charset='utf-8'>
5
+ <title>Pluto Admin</title>
6
6
  <link href="<%= url('/style.css') %>" rel='stylesheet'>
7
7
  </head>
8
8
  <body>
9
9
 
10
10
  <p>
11
- Pluto |
12
- <%= link_to 'Sites', sites_path %> <span class='count'>(<%= Site.count %>)</span> &bull;
13
- <%= link_to 'Feeds', feeds_path %> <span class='count'>(<%= Feed.count %>)</span> &bull;
14
- <%= link_to 'Items', items_path %> <span class='count'>(<%= Item.count %>)</span> &bull;
11
+ Pluto Admin |
12
+ <%= link_to 'Sites', sites_path %> <span class='count'>(<%= Site.count %>)</span> &nbsp;
13
+ <%= link_to 'Feeds', feeds_path %> <span class='count'>(<%= Feed.count %>)</span> &nbsp;
14
+ <%= link_to 'Items', items_path %> <span class='count'>(<%= Item.count %>)</span> &nbsp;
15
15
  <%= link_to 'Timeline', timeline_path %> <span class='count'>(<%= Action.count %>)</span>
16
16
  </p>
17
17
 
18
18
  <%= yield %>
19
19
 
20
- <%= erb :'_version' %>
20
+ <%= erb :'shared/_version' %>
21
21
 
22
22
  </body>
23
23
  </html>
@@ -0,0 +1,55 @@
1
+
2
+ <h2><%= items.count %> Items</h2>
3
+
4
+ <table>
5
+ <% items.each_with_index do |item,index| %>
6
+ <tr>
7
+ <td class='count'>
8
+ [<%= index+1 %>]
9
+ </td>
10
+ <td>
11
+ <%= link_to item.title, item_path( item ) %>
12
+ </td>
13
+
14
+ <td>
15
+ <% if item.summary? %>
16
+ <%= item.summary.length %>
17
+ <% else %>
18
+ --no-summary--
19
+ <% end %>
20
+ </td>
21
+
22
+ <td>
23
+ <% if item.content? %>
24
+ <%= item.content.length %>
25
+ <% else %>
26
+ --no-content--
27
+ <% end %>
28
+ </td>
29
+
30
+ <td class='key'><%= item.guid %></td>
31
+
32
+ <td>
33
+ <% if item.published? %>
34
+ <%= item.published.strftime( '%b %d, %Y %H:%M' ) %>
35
+ <% else %>
36
+ --no-published--
37
+ <% end %>
38
+ </td>
39
+ <td>
40
+ <% if item.touched? %>
41
+ <%= item.touched.strftime( '%b %d, %Y %H:%M' ) %>
42
+ <% else %>
43
+ --no-updated--
44
+ <% end %>
45
+ </td>
46
+
47
+ <% if show_feed %>
48
+ <td>
49
+ <%= link_to item.feed.title, feed_path( item.feed ) %>
50
+ </td>
51
+ <% end %>
52
+
53
+ </tr>
54
+ <% end %>
55
+ </table>
@@ -3,18 +3,19 @@
3
3
  <h2><%= Site.count %> Sites</h2>
4
4
 
5
5
  <table>
6
- <% Site.all.each do |site| %>
6
+ <% Site.order(:id).each do |site| %>
7
7
  <tr>
8
8
  <td class='key'><%= site.key %></td>
9
9
  <td><%= site.title %>
10
10
  <span class='count'>(<%= site.feeds.count %>)</span>
11
11
  </td>
12
12
  <td>
13
- <ul>
14
- <% site.feeds.each do |feed| %>
15
- <li><%= feed.title %></li>
13
+ <% site.feeds.order(:title).each_with_index do |feed,index| %>
14
+ <% if index > 0 %>
15
+ &bull;
16
+ <% end %>
17
+ <%= link_to feed.title, feed_path( feed ) %>
16
18
  <% end %>
17
- </ul>
18
19
  </td>
19
20
  </tr>
20
21
  <% end %>
@@ -2,7 +2,7 @@
2
2
  <h2>Timeline</h2>
3
3
 
4
4
  <table>
5
- <% Action.order( 'created_at DESC' ).all.each do |action| %>
5
+ <% Action.order( 'created_at DESC' ).each do |action| %>
6
6
  <tr>
7
7
  <td><%= action.title %></td>
8
8
  <td><%= action.object %></td>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pluto-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-21 00:00:00.000000000 Z
12
+ date: 2013-10-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: logutils
16
- requirement: &68931870 !ruby/object:Gem::Requirement
16
+ requirement: &73749590 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0.5'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *68931870
24
+ version_requirements: *73749590
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rdoc
27
- requirement: &68931620 !ruby/object:Gem::Requirement
27
+ requirement: &73749270 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.10'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *68931620
35
+ version_requirements: *73749270
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: hoe
38
- requirement: &68931310 !ruby/object:Gem::Requirement
38
+ requirement: &73749030 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '3.3'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *68931310
46
+ version_requirements: *73749030
47
47
  description: planet web admin - sintara web app ready to get mounted into your web
48
48
  app
49
- email: webslideshow@googlegroups.com
49
+ email: feedreader@googlegroups.com
50
50
  executables: []
51
51
  extensions: []
52
52
  extra_rdoc_files:
@@ -61,12 +61,15 @@ files:
61
61
  - lib/pluto/admin/public/style.css
62
62
  - lib/pluto/admin/server.rb
63
63
  - lib/pluto/admin/version.rb
64
- - lib/pluto/admin/views/_debug.erb
65
- - lib/pluto/admin/views/_version.erb
66
64
  - lib/pluto/admin/views/debug.erb
65
+ - lib/pluto/admin/views/feed.erb
67
66
  - lib/pluto/admin/views/feeds.erb
67
+ - lib/pluto/admin/views/item.erb
68
68
  - lib/pluto/admin/views/items.erb
69
69
  - lib/pluto/admin/views/layout.erb
70
+ - lib/pluto/admin/views/shared/_debug.erb
71
+ - lib/pluto/admin/views/shared/_items.erb
72
+ - lib/pluto/admin/views/shared/_version.erb
70
73
  - lib/pluto/admin/views/sites.erb
71
74
  - lib/pluto/admin/views/timeline.erb
72
75
  homepage: https://github.com/feedreader/pluto.admin