#!/usr/bin/ruby

dsize = Dir.entries('.').size

(0..dsize).step(100) do |x|
  File.open("#{x}.html", "w") do |file|
    i=1
    file << "<table><tr><td>"
    d  = Dir.entries('.')
    (x..x+100).each do |r|
      e = d[r]
      if e =~ /jpg$/
        puts "#{x} - #{i}"
        file << "</tr><tr>" if i % 10 == 1
        file << "<td id='#{i}'><a href='#{e}'><img width='80' border='0' src='#{e}'></a></td>\n"
        i+=1
      end
    end
    until i % 10 == 1 do
      file << "<td></td>"
      i+=1
    end
    file << "</tr></table>"
    file << "<a href='#{x+100}.html'>#{x+100}.html</a>"
  end
end

require 'rubygems'
require 'activerecord'

class Artist < ActiveRecord::Base
  establish_connection({ :adapter => 'postgresql', :host => 'nina.sxsw.com', :database => 'artist_admin', :username => 'sxsw' })
  #set_table_name 'showcasing_artists'
end

#artists = Artist.find(:all, :select => "name, id, photofn", :conditions => "photofn != ''", :order => :name)
artists = Artist.find(:all, :select => "name, id, photofn", :conditions => "photofn != '' and has_showcase", :order => :name)

File.open("photo_index.html", "w") do |file|
  artists.each do |artist|
    file << "<a href='http://mgr.sxsw.com/artist_admin/photos/#{artist.id}/#{artist.photofn}'>#{artist.name}</a><br/>\n"
  end
end

