Skip to content

Commit

Permalink
* Update plugin because not works realy good
Browse files Browse the repository at this point in the history
  • Loading branch information
shingara committed Mar 22, 2008
1 parent ada5f7a commit 520753b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions lib/yoolink.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Yoolink
include REXML

attr_accessor :url, :items, :link, :title, :days
attr_accessor :url, :items, :link, :title, :days, :login

# This object holds given information of an item
class YoolinkItem < Struct.new(:link, :title, :description, :description_link, :date)
Expand All @@ -15,9 +15,10 @@ def to_s; title end
# Pass the url to the RSS feed you would like to keep tabs on
# by default this will request the rss from the server right away and
# fill the items array
def initialize(url, refresh = true)
def initialize(login, refresh = true)
self.items = []
self.url = url
self.url = "http://yoolink.fr/people/#{login}/rss"
self.login = login
self.days = {}
self.refresh if refresh
end
Expand All @@ -43,15 +44,15 @@ def parse(body)
XPath.each(xml, "//item/") do |elem|
item = YoolinkItem.new
item.title = XPath.match(elem, "title/text()").first.value rescue ""
item.link = XPath.match(elem, "link/text()").first.value rescue ""
item.link = XPath.match(elem, "guid/text()").first.value rescue ""
item.description = XPath.match(elem, "description/text()").first.value rescue ""
item.date = Time.mktime(*ParseDate.parsedate(XPath.match(elem, "dc:date/text()").first.value)) rescue Time.now
item.date = Time.mktime(*ParseDate.parsedate(XPath.match(elem, "pubDate/text()").first.value)) rescue Time.now

item.description_link = item.description
item.description.gsub!(/<\/?a\b.*?>/, "") # remove all <a> tags
items << item
end

self.items = items.sort_by { |item| item.date }
self.items = items.sort_by { |item| item.date }.reverse
end
end
2 changes: 1 addition & 1 deletion lib/yoolink_sidebar.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class YoolinkSidebar < Sidebar
def yoolink
require 'ruby-debug'
#debugger
@yoolink ||= Yoolink.new("http://yoolink.fr/people/#{login}/rss") rescue nil
@yoolink ||= Yoolink.new(login) rescue nil
end

def parse_request(contents, params)
Expand Down
2 changes: 1 addition & 1 deletion views/content.rhtml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<% if sidebar.yoolink -%>
<div id="yoolink">
<h3><a href="http://<%=h sidebar.yoolink.title %>"><%=h sidebar.yoolink.title %></a></h3>
<h3><a href="http://yoolink.fr/people/<%=h sidebar.yoolink.login %>">Yoolink/<%=h sidebar.yoolink.login %></a></h3>
<% (groupdate ? sidebar.yoolink.days : [{ :container => sidebar.yoolink.items }]).each do |group| -%>
<% if groupdate -%>
<span class="date"><%=h group[:date].to_s.to_date.strftime("%b %d") %></span>
Expand Down

0 comments on commit 520753b

Please sign in to comment.