Permalink
Browse files

Clean up halm files, adding helpers to sinatra file.

  • Loading branch information...
1 parent 2346e36 commit e2cb76930b8f0946d5eac9f304e84c4ff6ffe5c2 @funkaoshi committed Feb 24, 2010
Showing with 57 additions and 33 deletions.
  1. +35 −10 i_shoot_film.rb
  2. +9 −0 views/_analytics.haml
  3. +7 −0 views/_film_rolls.haml
  4. +6 −23 views/index.haml
View
45 i_shoot_film.rb
@@ -2,6 +2,37 @@
require 'flickraw'
require 'haml'
+###
+
+class FlickRaw::Response
+ # Add helper method to print link from thumbnail to photo page.
+ def thumbnail_link
+ "<a href='#{FlickRaw::url_photopage(self)}'><img src=#{self.url_sq}></a>"
+ end
+end
+
+# Stores basic information about a film roll.
+class FilmRoll
+ attr_accessor :title, :roll_no, :images
+
+ def initialize(roll_no)
+ @roll_no = roll_no
+ @title = "Roll #{roll_no}"
+ @images = []
+ @film_dev_info = nil
+ end
+
+ def add(photo)
+ @images << photo
+ end
+
+ # For B&W images with a recipe, we will save a link to the recipe on filmdev.org
+ def film_dev_info()
+ return @film_dev_info unless @film_dev_info.nil?
+ @film_dev_info = @images.first.machine_tags =~ /filmdev:recipe=([0-9]+)/ ? "<span class='small'><a href='http://filmdev.org/recipe/show/#{$~[1]}'>development receipe #{$~[1]}</a></span>" : ""
+ end
+end
+
# Sinatra !!
configure do
@@ -42,18 +73,12 @@ def get_film_rolls(get_bw=false)
roll_no = photo.machine_tags.match(/funkaoshi:roll=([0-9]*)/)[1].to_i
roll_map = photo.tags.match(/byobw/) ? bw_film_rolls : colour_film_rolls
if !roll_map.has_key?(roll_no)
- roll_map[roll_no] = []
+ roll_map[roll_no] = FilmRoll.new(roll_no)
end
- roll_map[roll_no] << photo
- end
- @bw_film_rolls = bw_film_rolls.to_a.sort
- @colour_film_rolls = colour_film_rolls.to_a.sort
- end
-
- def get_film_dev_info(photo)
- if photo.machine_tags =~ /filmdev:recipe=([0-9]+)/
- "<span class='small'><a href='http://filmdev.org/recipe/show/#{$~[1]}'>development receipe #{$~[1]}</a></span>"
+ roll_map[roll_no].add(photo)
end
+ @bw_film_rolls = bw_film_rolls.sort
+ @colour_film_rolls = colour_film_rolls.sort
end
end
View
9 views/_analytics.haml
@@ -0,0 +1,9 @@
+- if @@analytics_token
+ :javascript
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+ :javascript
+ try {
+ var pageTracker = _gat._getTracker("#{@@analytics_token}");
+ pageTracker._trackPageview();
+ } catch(err) {}
View
7 views/_film_rolls.haml
@@ -0,0 +1,7 @@
+- film_rolls.each do |roll_no, roll|
+ .roll
+ %h3
+ = roll.title
+ = roll.film_dev_info
+ - roll.images.each do |photo|
+ = photo.thumbnail_link
View
29 views/index.haml
@@ -10,29 +10,12 @@
%h1 I Shoot Film
%h2 Some rolls are better than others.
%p I started tracking the rolls of film I shot more methodically at the start of 2008. I assigned each roll of film a number, each frame a numerical id. These are (almost) all the photos I've shot on film and <a href="http://flickr.com/photos/funkaoshi">posted to Flickr</a> since switching to this system. The <a href="http://www.flickr.com/photos/funkaoshi/sets/72157611013506478/">B&W I processed myself</a> is a complete listing, the colour not so much. Eventually I'll go back through all my pictures and tag them properly so they show up here. Film comes in rolls of 24 or 36 frames. That should give you a sense of just how many pictures don't get posted online.
- - @colour_film_rolls.each do |roll|
- .roll
- %h3= "Roll #{roll[0]}"
- - roll[1].each do |photo|
- %a{:href => FlickRaw::url_photopage(photo)}
- %img{:src => photo.url_sq}
+
+ = haml(:_film_rolls, :layout => false, :locals => { :film_rolls => @colour_film_rolls })
+
%h2 Black & White Film Processed by Me
- - @bw_film_rolls.each do |roll|
- .roll
- %h3
- = "Roll #{roll[0]}"
- = get_film_dev_info(roll[1].first)
- - roll[1].each do |photo|
- %a{:href => FlickRaw::url_photopage(photo)}
- %img{:src => photo.url_sq}
+ = haml(:_film_rolls, :layout => false, :locals => { :film_rolls => @bw_film_rolls })
+
%footer
%p Site designed and built by <a href="http://funkaoshi.com">Ramanan Sivaranjan</a>.
- - if @@analytics_token
- :javascript
- var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
- document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
- :javascript
- try {
- var pageTracker = _gat._getTracker("#{@@analytics_token}");
- pageTracker._trackPageview();
- } catch(err) {}
+ = haml(:_analytics, :layout => false)

0 comments on commit e2cb769

Please sign in to comment.