|
|
||
IRC: irc://irc.opera.com/japanese <--Opera 日本語ユーザのためのIRCチャンネル。
上のがつながらない場合は irc://irc.se.opera.com/japanese
Speed Dial の 使いかたを考えてみる - opera:hige - チーム俺等 にコードを張っていなかったことにコメントがきて気づいた。 Thx, LDRマニア.
ちょっと手直ししてはっつけとく。
#!/usr/local/bin/ruby require 'open-uri' username = "higeorange" # livedoor のユーザネーム p = URI.parse("http://rpc.reader.livedoor.com/notify?user=#{username}").read unread = p[%r{\d+}i] print "Content-Type: text/html\n\n" print %Q{<html><head><title>livedoor reader Unread</title>} print "</head><body>" print %Q{<p style="font-size:300px">#{unread}</p>} print "</body></html>"
#!/usr/local/bin/ruby require 'open-uri' require 'rexml/document' city_number = 70 # http://weather.livedoor.com/forecast/rss/forecastmap.xml 参照 url = "http://weather.livedoor.com/forecast/webservice/rest/v1?city=#{city_number.to_s}&day=" date = Time.now if date.hour < 12 # 昼12 時までは今日の天気、それ以降は明日の天気 url += 'today' else url += 'tomorrow' end xml = URI.parse(url).read wt = REXML::Document.new(xml).root tt = wt.elements['./image/title'].text to = wt.elements['./image/url'].text tc = wt.elements['./title'].text tmax = wt.elements['./temperature/max/celsius'].text tmin = wt.elements['./temperature/min/celsius'].text print "Content-Type: text/html\n\n" print "<html><head>" print %Q{<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">} print "<title>Weather</title></head><body>" print %Q{<h1 style="font-size:80px">#{tc}</h1>} print %Q{<p><img src="#{to}" alt="#{tt}" width="600" heigth="600"></p>} print %Q{<p style="font-size: 80px">最高/最低気温: #{tmax}/#{tmin}</p>} print "</body></html>"
これだけだとあれなんで sinatra で未読数を JSON で返すのもやってみた。
require 'open-uri' require 'rubygems' require 'sinatra' require 'haml' get '/ldr/:username' do @username = params[:username] p = URI.parse("http://rpc.reader.livedoor.com/notify?user=#{@username}").read @unread = p[%r{\d+}i] @callback = params[:callback] content_type('text/javascript; charset=utf-8') erb :ldr end
<%= @callback %>({"unread": <%= @unread %>})
http://sinatra.higeorange.com/ldr/higeorange?callback=unread