aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2015-05-15 20:30:18 +0200
committerHarald Eilertsen <haraldei@anduin.net>2015-05-15 20:30:18 +0200
commit0cc7a1e703cd6097c82f41f5385f33cbd0cfcb5a (patch)
tree2c8ceaa8cff349e8d5418832a522f2c4aca4d540
parent1beba4bae98c2d6af47283cc2fe21c88225f8f0d (diff)
downloadrss2html-0cc7a1e703cd6097c82f41f5385f33cbd0cfcb5a.tar.gz
rss2html-0cc7a1e703cd6097c82f41f5385f33cbd0cfcb5a.tar.bz2
rss2html-0cc7a1e703cd6097c82f41f5385f33cbd0cfcb5a.zip
make the feed items nicer.
-rw-r--r--lib/rss2html/feed.rb9
-rw-r--r--lib/rss2html/feed_item.rb2
-rw-r--r--lib/rss2html/views/item.html.erb5
3 files changed, 12 insertions, 4 deletions
diff --git a/lib/rss2html/feed.rb b/lib/rss2html/feed.rb
index 909b08c..28d395c 100644
--- a/lib/rss2html/feed.rb
+++ b/lib/rss2html/feed.rb
@@ -17,6 +17,7 @@
require 'rss'
require 'open-uri'
require 'erb'
+require 'date'
module Rss2Html
class Feed
@@ -59,5 +60,13 @@ module Rss2Html
view_path = File.join(File.dirname(__FILE__), 'views')
ERB.new(IO.read(File.join(view_path, t)))
end
+
+ def pretty_date(d)
+ d.to_date
+ end
+
+ def pretty_url(u)
+ u.hostname.gsub(/www\./, '')
+ end
end
end
diff --git a/lib/rss2html/feed_item.rb b/lib/rss2html/feed_item.rb
index f632e3a..0f6ab2f 100644
--- a/lib/rss2html/feed_item.rb
+++ b/lib/rss2html/feed_item.rb
@@ -23,7 +23,7 @@ module Rss2Html
@author = item.author.name.content
@date = item.updated.content
@summary = item.summary.content.strip
- @url = item.link.href
+ @url = URI.parse(item.link.href)
end
end
end
diff --git a/lib/rss2html/views/item.html.erb b/lib/rss2html/views/item.html.erb
index 5c0aea8..9e7a2fe 100644
--- a/lib/rss2html/views/item.html.erb
+++ b/lib/rss2html/views/item.html.erb
@@ -1,8 +1,7 @@
<article>
<header>
- <h1><%= item.title %></h1>
- <section class="meta">Posted by <%= item.author %> at <%= item.date %></section>
+ <section class="meta"><%= pretty_date(item.date) %><br><%= pretty_url(item.url) %></section>
+ <h1><a href="<%= item.url %>"><%= item.title %></a></h1>
</header>
<section class="summary"><%= item.summary %></summary>
- <footer><a href="<%= item.url %>">Read more...</a></footer>
</article>