Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Touching up install.rb and adding Atom check to popular posts logger …

…in BlogLogger
  • Loading branch information...
commit 917c3ef3002c4ba41349142caaafe67dd38c5d12 1 parent 6bd9945
@ttscoff authored
Showing with 15 additions and 5 deletions.
  1. +3 −2 install.rb
  2. +12 −3 plugins/BlogLogger.rb
View
5 install.rb
@@ -36,7 +36,7 @@
puts "Is your Mac routinely offline at 11:50PM?"
print "(Y/n)"
ans = gets.chomp
- flags += " -s" if ans.downcase == "y"
+ flags += "-s" unless ans.downcase == "n"
print "Setting up launchd... "
xml=<<LAUNCHCTLPLIST
@@ -49,7 +49,8 @@
<key>ProgramArguments</key>
<array>
<string>/usr/bin/ruby</string>
- <string>#{dir}/slogger#{flags}</string>
+ <string>#{dir}/slogger</string>
+ <string>#{flags}</string>
</array>
<key>StartCalendarInterval</key>
<dict>
View
15 plugins/BlogLogger.rb
@@ -89,12 +89,18 @@ def parse_feed(rss_feed)
end
rss = RSS::Parser.parse(rss_content, false)
-
+ p rss.class
if @blogconfig['get_most_popular']
@log.info("Checking for most tweeted posts on #{rss.title.content}")
posts = []
rss.items.each { |item|
- url = item.link.href
+ if item.class == RSS::Atom::Feed::Entry
+ title = item.title.content.gsub(/\n+/,' ')
+ url = item.link.href
+ else
+ title = item.title.gsub(/\n+/,' ')
+ url = item.link
+ end
count = 0
begin
open("http://urls.api.twitter.com/1/urls/count.json?url=#{CGI.escape(url)}") do |f|
@@ -102,7 +108,7 @@ def parse_feed(rss_feed)
count = json['count']
end
posts << {
- 'title' => item.title.content.gsub(/\n+/,' '),
+ 'title' => title,
'url' => url,
'count' => count
}
@@ -124,6 +130,9 @@ def parse_feed(rss_feed)
end
end
rss.items.each { |item|
+ puts item.inspect
+ puts item.class
+ puts item.methods
begin
if item.class == RSS::Atom::Feed::Entry
item_date = Time.parse(item.updated.to_s) + Time.now.gmt_offset
Please sign in to comment.
Something went wrong with that request. Please try again.