# MephistoFlickrAjax
require File.join(File.dirname(__FILE__), "..", "..", "..", "..", "lib", "mephisto", "routing.rb")
class FlickrController < ActionController::Base
def index
result = ""
pics = find_pictures
pics.each do |pic|
result << ""
end
render :inline => result
end
protected
def find_pictures
FlickrPictureProvider.new(:feed => feed_url, :count => count).choose(count)
end
def feed_url
params[:feed]
end
def count
params[:count].to_i
end
end
module Mephisto
class Routing
class << self
def connect_with_with_flickr(map)
map.connect 'flickr', :controller => 'flickr', :action => 'index'
connect_with_without_flickr(map)
end
alias_method_chain :connect_with, :flickr
end
end
end
require 'flickr_picture_provider'
class FlickrAjaxPhotoStream < Liquid::Block
def initialize(markup, tokens)
super
@attributes = {
:feed => 'http://api.flickr.com/services/feeds/photos_public.gne?id=57966634@N00&format=rss_200',
:count => 6,
:format => "square"
}
markup.scan(Liquid::TagAttributes) do |key, value|
@attributes[key.to_sym] = value
end
end
def feed_url
@attributes[:feed]
end
def count
@attributes[:count].to_i
end
def format
@attributes[:format]
end
def render(context)
<<-EOF