<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,4 @@
+# -*- coding: utf-8 -*-
 require 'rubygems'
 require 'sinatra'
 require 'avaticon'
@@ -6,13 +7,13 @@ require 'erb'
 include ERB::Util
 
 def encode64url arg
-  [arg].pack('m').tr('+/', '-_')
+  [arg].pack('m').tr('+/', '-_').strip
 end
 
 URL = 'http://usericons.relucks.org/'
 CACHE_DIR = 'tmp'
-CACHE_EXPIRE = 60 * 60 * 3
-HTTP_CACHE_EXPIRE = 60 * 60 * 3
+CACHE_EXPIRE = 60 * 60 * 24
+HTTP_CACHE_EXPIRE = 60 * 60 * 24
 
 get '/' do
   avt = Avaticon.new
@@ -36,7 +37,8 @@ get '/' do
 end
 
 get '/:service/:user_id' do
-  avt = Avaticon.new
+  tw_auth = YAML.load_file 'tw.yaml'
+  avt = Avaticon.new :tw_id =&gt; tw_auth['id'], :tw_pw =&gt; tw_auth['pw']
   avt.load_siteinfo File.join(CACHE_DIR, 'siteinfo.json')
 
   service = params[:service]
@@ -54,6 +56,7 @@ get '/:service/:user_id' do
 
   begin
     icon_url = avt.get_icon service, user_id
+    raise 'error' unless icon_url
     open(path, 'w') { |f| f.puts icon_url }
     set_cache
     redirect icon_url</diff>
      <filename>usericons.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>4817ab01d2ab05f8594259f9ac078b96d832f9eb</id>
    </parent>
  </parents>
  <author>
    <name>swdyh</name>
    <email>youhei@gmail.com</email>
  </author>
  <url>http://github.com/swdyh/usericons.relucks.org/commit/90846613e506feb5b2d4ce7d50272330f92f1def</url>
  <id>90846613e506feb5b2d4ce7d50272330f92f1def</id>
  <committed-date>2009-09-22T04:16:47-07:00</committed-date>
  <authored-date>2009-09-22T04:16:47-07:00</authored-date>
  <message>added twitter auth.</message>
  <tree>dca3e421c88dbfb739eb8f3d94c29086b8f64e88</tree>
  <committer>
    <name>swdyh</name>
    <email>youhei@gmail.com</email>
  </committer>
</commit>
