From 65099002271cb54215781a5188e0b28f4cdb880d Mon Sep 17 00:00:00 2001
From: Espen Antonsen
Date: Thu, 11 Jun 2009 13:05:09 +0200
Subject: [PATCH] rerouting. deizzzzign
---
app/controllers/albums_controller.rb | 2 +-
app/controllers/collections_controller.rb | 2 +-
app/controllers/photos_controller.rb | 19 +-
app/helpers/application_helper.rb | 23 ++-
app/models/album.rb | 4 +
app/models/collection.rb | 6 +-
app/models/photo.rb | 6 +
app/models/tag.rb | 6 +-
app/views/albums/_album.html.erb | 6 +-
app/views/albums/show.html.erb | 18 +-
app/views/collections/index.html.erb | 12 +-
app/views/collections/show.html.erb | 19 +-
app/views/layouts/admin.html.erb | 16 --
app/views/layouts/application.html.erb | 39 +++-
app/views/photos/_photo.html.erb | 4 -
app/views/photos/_thumb.html.erb | 2 +-
app/views/photos/show.html.erb | 18 +-
config/routes.rb | 17 +-
public/stylesheets/application.css | 232 +++++++++++++++++-----
19 files changed, 331 insertions(+), 120 deletions(-)
delete mode 100644 app/views/layouts/admin.html.erb
delete mode 100644 app/views/photos/_photo.html.erb
diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb
index ec8e73a..dbf6b66 100644
--- a/app/controllers/albums_controller.rb
+++ b/app/controllers/albums_controller.rb
@@ -27,7 +27,7 @@ class AlbumsController < ApplicationController
end
def show
- @album = Album.find( params[:id])
+ @album = Album.find_by_title( params[:id])
respond_to do |format|
format.html
format.json { render :json => @album }
diff --git a/app/controllers/collections_controller.rb b/app/controllers/collections_controller.rb
index 1ebf860..18f2187 100644
--- a/app/controllers/collections_controller.rb
+++ b/app/controllers/collections_controller.rb
@@ -11,7 +11,7 @@ class CollectionsController < ApplicationController
end
def show
- @collection = Collection.find( params[:id])
+ @collection = Collection.find_by_title( params[:id] )
respond_to do |format|
format.html
format.json { render :json => @collection }
diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb
index 4bbaab1..4f32199 100644
--- a/app/controllers/photos_controller.rb
+++ b/app/controllers/photos_controller.rb
@@ -4,13 +4,13 @@ class PhotosController < ApplicationController
def index
if params[:tag_id]
- @photos = Tag.find_by_title( params[:tag_id] ).photos
+ @photos = Tag.find_by_title( params[:tag_id] ).photos.find(:all, :order => "Photos.Id ASC")
elsif params[:album_id]
- @photos = Album.find( params[:album_id]).photos.find(:all)
+ @photos = Album.find_by_title( params[:album_id]).photos.find(:all, :order => "Photos.Id ASC")
elsif params[:q]
- @photos = Photo.find(:all, :limit => 20, :conditions => [ "Photos.description LIKE :q OR Photos.title LIKE :q OR Photos.Id IN ( SELECT Photo_Id FROM Photo_Tags LEFT OUTER JOIN Tags ON Photo_Tags.Tag_Id = Tags.Id WHERE Tags.Title LIKE :q) ", { :q => '%' + params[:q] + '%' } ], :include => :album )
+ @photos = Photo.find(:all, :limit => 20, :conditions => [ "Photos.description LIKE :q OR Photos.title LIKE :q OR Photos.Id IN ( SELECT Photo_Id FROM Photo_Tags LEFT OUTER JOIN Tags ON Photo_Tags.Tag_Id = Tags.Id WHERE Tags.Title LIKE :q) ", { :q => '%' + params[:q] + '%' } ], :include => :album, :order => "Photos.Id ASC" )
else
- @photos = Photo.find(:all)
+ @photos = Photo.find(:all, :order => "Photos.Id ASC")
end
respond_to do |format|
format.html
@@ -21,7 +21,7 @@ class PhotosController < ApplicationController
def untouched
if params[:album_id]
- @album = Album.find( params[:album_id])
+ @album = Album.find_by_title( params[:album_id])
@photos = @album.photos.untouched
else
@photos = Photo.untouched()
@@ -34,7 +34,12 @@ class PhotosController < ApplicationController
end
def show
- @photo = Photo.find( params[:id])
+ @photo = Photo.find( params[:id] )
+ previous_rs = Photo.previous( @photo.id, @photo.album )
+ @previous = previous_rs.first if !previous_rs.empty?
+ next_rs = Photo.next( @photo.id, @photo.album )
+ puts next_rs.inspect
+ @next = next_rs.first if !next_rs.empty?
respond_to do |format|
format.html
format.json { render :json => @photo }
@@ -47,7 +52,7 @@ class PhotosController < ApplicationController
end
def upload
- @album = Album.find( params[:album_id])
+ @album = Album.find_by_title( params[:album_id])
end
def create
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e6dc3eb..c89fa05 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,4 +1,25 @@
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
-
+
+ def breadcrumbs(sep = "/", include_home = true)
+ levels = request.path.split('?')[0].split('/')
+ levels.delete_at(0)
+
+ #links = "You are here: "
+ links = content_tag('a', "HOME", :href => "/") if include_home
+
+ nocrumb = ["collections", "albums", "photos", "tags"]
+
+ levels.each_with_index do |level, index|
+ level = level.gsub(/[0-9]+-/,"") if levels[index-1] == "photos"
+ level = level.gsub("-", " ")
+ if index+1 == levels.length
+ links += " #{sep} #{level.upcase}" unless nocrumb.include?(level)
+ else
+ links += " #{sep} #{content_tag('a', level.upcase, :href => '/'+levels[0..index].join('/'))}" unless nocrumb.include?(level)
+ end
+ end
+
+ content_tag("div", content_tag("p", links ), :id => "breadcrumb")
+ end
end
diff --git a/app/models/album.rb b/app/models/album.rb
index 4397886..09e794f 100644
--- a/app/models/album.rb
+++ b/app/models/album.rb
@@ -14,6 +14,10 @@ class Album < ActiveRecord::Base
named_scope :untouched, :conditions => "Albums.Id IN ( SELECT DISTINCT Photos.Album_Id FROM Photos WHERE Photos.description IS NULL AND Photos.Id NOT IN ( SELECT Photo_ID FROM Photo_Tags) )"
+ def to_param
+ title.gsub(/[^a-z0-9]+/i, '-')
+ end
+
def ensure_path
diff --git a/app/models/collection.rb b/app/models/collection.rb
index a572f2a..ec408c7 100644
--- a/app/models/collection.rb
+++ b/app/models/collection.rb
@@ -2,4 +2,8 @@ class Collection < ActiveRecord::Base
has_many :collection_albums
has_many :albums, :through => :collection_albums
-end
+ def to_param
+ title.gsub(/[^a-z0-9]+/i, '-')
+ end
+
+end
\ No newline at end of file
diff --git a/app/models/photo.rb b/app/models/photo.rb
index e439b2b..4983369 100644
--- a/app/models/photo.rb
+++ b/app/models/photo.rb
@@ -18,6 +18,12 @@ class Photo < ActiveRecord::Base
#attr_protected :path
named_scope :untouched, :conditions => "Photos.description IS NULL AND Photos.Id NOT IN ( SELECT Photo_ID FROM Photo_Tags)", :include => :album
+ named_scope :previous, lambda { |p,a| { :conditions => ["id < :id AND Album_Id = :album ", { :id => p, :album => a } ], :limit => 1, :order => "Id DESC"} }
+ named_scope :next, lambda { |p,a| { :conditions => ["id > :id AND Album_Id = :album ", { :id => p, :album => a } ], :limit => 1, :order => "Id ASC"} }
+
+ def to_param
+ id.to_s + '-' + title.gsub(/[^a-z0-9]+/i, '-')
+ end
def path_original_public
return APP_CONFIG[:photos_path_public] + self.path
diff --git a/app/models/tag.rb b/app/models/tag.rb
index 9b719ed..14985d3 100644
--- a/app/models/tag.rb
+++ b/app/models/tag.rb
@@ -11,10 +11,8 @@ class Tag < ActiveRecord::Base
end
def to_param
- #{ }"#{id}-#{name.gsub(/[^a-z0-9]+/i, '-')}"
- #id.to_s+'-'+name.downcase.gsub(/[^a-z0-9]+/i, '-')
- #id.to_s+'-'+name.downcase.gsub(' ', '-')
- self.title
+ #id.to_s+'-'+
+ title.downcase.gsub(/[^a-z0-9]+/i, '-')
end
protected
diff --git a/app/views/albums/_album.html.erb b/app/views/albums/_album.html.erb
index ac35b87..4e1e5ad 100644
--- a/app/views/albums/_album.html.erb
+++ b/app/views/albums/_album.html.erb
@@ -1,5 +1 @@
-<%= link_to album.title, album %>
-
-<%= render :partial => album.photos.find(:all, :limit => 2) %>
-
-
\ No newline at end of file
+<%= render :partial => "photos/thumb", :locals => {:photo => album.photos.find(:first) } %>
\ No newline at end of file
diff --git a/app/views/albums/show.html.erb b/app/views/albums/show.html.erb
index 52e97d4..c5cae28 100644
--- a/app/views/albums/show.html.erb
+++ b/app/views/albums/show.html.erb
@@ -1,7 +1,17 @@
-<%= @album.title %>
-<% for photo in @album.photos %>
-<%= link_to image_tag( photo.path_modified_public("album") ), photo %>
-<% end %>
+<%= @album.title %>
+
+
+
+ <% count = 0.0 %>
+ <% for photo in @album.photos.find(:all, :order => "Id ASC") %>
+ <% count += 1%>
+ <% if count == 1 || ( (count-1) / 4.0 == ( (count-1) / 4.0).to_i ) %><% end %>
+ <%= link_to image_tag( photo.path_modified_public("album") ), [@album.collections.first, @album, photo] %> |
+ <% if count / 4.0 == (count / 4.0).to_i %>
<% end %>
+ <% end %>
+
+
+
<%= @album.description %>
<% if has_permission?("see_album_note") %>
<%= @album.note %>
diff --git a/app/views/collections/index.html.erb b/app/views/collections/index.html.erb
index ddbbbd4..a7e0aa1 100644
--- a/app/views/collections/index.html.erb
+++ b/app/views/collections/index.html.erb
@@ -1,5 +1,9 @@
-Collections
+Collections
+
<% for collection in @collections %>
-<%= link_to collection.title, collection %>
-<%= render :partial => collection.albums %>
-<% end %>
\ No newline at end of file
+
+
<%= link_to collection.title, collection %>
+ <%= render :partial => collection.albums.find(:first) %>
+
+<% end %>
+
\ No newline at end of file
diff --git a/app/views/collections/show.html.erb b/app/views/collections/show.html.erb
index 7cec281..e943563 100644
--- a/app/views/collections/show.html.erb
+++ b/app/views/collections/show.html.erb
@@ -1,8 +1,21 @@
-<%= h @collection.title %>
+<%= h @collection.title %>
<%= h @collection.description %>
-<%= render :partial => @collection.albums %>
+<% for album in @collection.albums %>
+
+
+ <%= render :partial => "photos/thumb", :locals => {:photo => album.photos.first } %>
+
<%= link_to album.title, collection_album_path(@collection, album) %>
+
+
+ <%= render :partial => "photos/thumb", :collection => album.photos.find(:all, :limit => 5, :offset => 1), :as => :photo %>
+
+
+<% end %>
+
+
<% if has_role?("admin") %>
<%= link_to "Update collection", edit_collection_path(@collection) %>
<% end %>
-
<%= link_to "All collections", collections_path %>
\ No newline at end of file
+
<%= link_to "All collections", collections_path %>
+
\ No newline at end of file
diff --git a/app/views/layouts/admin.html.erb b/app/views/layouts/admin.html.erb
deleted file mode 100644
index a6ac18e..0000000
--- a/app/views/layouts/admin.html.erb
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
- Gallery admin
-
-
-
-
-<%= yield%>
-
-
-
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 11ea262..8951e33 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -1,19 +1,38 @@
-
+
-
+
-
-
- Gallery
+
+ ImageGallery
<%= yield :head %>
<%= stylesheet_link_tag 'application' %>
-
-
-<%= flash[:notice] %>
-<%= yield %>
+
+
+
+
+
+
<%= flash[:notice] %>
+ <%= yield %>
+
+
+
+
<%= javascript_include_tag 'jquery-1.3.2.js', 'application' %>
<%= yield :javascript %>
diff --git a/app/views/photos/_photo.html.erb b/app/views/photos/_photo.html.erb
deleted file mode 100644
index 37ba320..0000000
--- a/app/views/photos/_photo.html.erb
+++ /dev/null
@@ -1,4 +0,0 @@
-
- " title="<%= photo.title %>">
- <%= image_tag photo.path_modified_public("album"), { :id => 'thumb_' + photo.id.to_s } %>
-
diff --git a/app/views/photos/_thumb.html.erb b/app/views/photos/_thumb.html.erb
index dbc1468..fe124ba 100644
--- a/app/views/photos/_thumb.html.erb
+++ b/app/views/photos/_thumb.html.erb
@@ -1 +1 @@
-<%= image_tag photo.public_path_modified("thumb") %>
+<%= link_to ( image_tag photo.path_modified_public("album"), { :id => 'thumb_' + photo.id.to_s } ), photo_path(photo) %>
\ No newline at end of file
diff --git a/app/views/photos/show.html.erb b/app/views/photos/show.html.erb
index 314a0b5..d9f5eb7 100644
--- a/app/views/photos/show.html.erb
+++ b/app/views/photos/show.html.erb
@@ -1,5 +1,21 @@
<%= @photo.title%>
-<%= image_tag @photo.path_modified_public("large") %>
+
+
+
+
+ <% unless @previous.nil?%>
+ <%= link_to "Previous", [ @photo.album.collections.first, @photo.album, @previous] %>
+ <% unless @next.nil? %>
+ |
+ <% end %>
+ <% end %>
+ <% unless @next.nil? %>
+ <%= link_to "Next", [ @photo.album.collections.first, @photo.album, @next] %>
+ <% end %>
+
+
+
<%= image_tag @photo.path_modified_public("large") %>
+
Tagged with: <%= @photo.tag_list %>
diff --git a/config/routes.rb b/config/routes.rb
index 283a185..9300ce1 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -4,16 +4,21 @@ ActionController::Routing::Routes.draw do |map|
map.authenticate "authenticate", :controller => "user_sessions", :action => "create"
map.logout "logout", :controller => "user_sessions", :action => "destroy"
- map.resources :photos,
- :collection => { :untouched => :get, :edit_multiple => :post, :update_multiple => :put, :upload => :get }
- map.resources :albums, :collection => { :untouched => :get} do |album|
- album.resources :photos, :collection => { :untouched => :get, :upload => :get, :edit_multiple => :get }, :shallow => true
+ map.resources :photos, :collection => { :untouched => :get, :edit_multiple => :post, :update_multiple => :put, :upload => :get }
+ map.resources :albums, :collection => { :untouched => :get, } do |album|
+ album.resources :photos, :collection => { :untouched => :get, :upload => :get, :edit_multiple => :get }
end
- map.resources :collections
+ map.resources :collections do |collection|
+ collection.resources :albums do |album|
+ album.resources :photos
+ #album.resources :photos, :collection => { :untouched => :get, :upload => :get, :edit_multiple => :get }
+ end
+ end
+
map.resources :tags, :has_many => [ :photos, :albums ], :shallow => true
map.resources :users, :controller => "admin/users"
map.root :controller => "collections"
-end
+end
\ No newline at end of file
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 4e7e0d7..aeb082e 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -1,64 +1,194 @@
-.galleria_container {
- margin:0 auto;
- text-align: center;
-}
+/* @group Reset */
-#thumbstrip {
-
- /* required settings */
- position:relative;
- overflow:hidden;
- width: 602px;
- height: 85px;
+html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, code, del, dfn, em, img, q, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {margin:0;padding:0;border:0;font-weight:inherit;font-style:inherit;font-size:100%;font-family:inherit;vertical-align:baseline;}
+body {line-height:1.5;}
+table {border-collapse:separate;border-spacing:0;}
+caption, th, td {text-align:left;font-weight:normal;}
+table, td, th {vertical-align:middle;}
+blockquote:before, blockquote:after, q:before, q:after {content:"";}
+blockquote, q {quotes:"" "";}
+a img {border:none;}
+
+
+
+/* @end */
+
+/* @group Typography */
+
+body {font-size:75%;color:#222;background:#fff;font-family:"Helvetica Neue", Arial, Helvetica, sans-serif;}
+h1, h2, h3, h4, h5, h6 {font-weight:normal;}
+h1 {font-size:3em;line-height:1;margin-bottom:0.5em;}
+h2 {font-size:2em;margin-bottom:0.75em;}
+h3 {font-size:1.5em;line-height:1;margin-bottom:1em;}
+h4 {font-size:1.2em;line-height:1.25;margin-bottom:1.25em;}
+h5 {font-size:1em;font-weight:bold;margin-bottom:1.5em;}
+h6 {font-size:1em;font-weight:bold;}
+h1 img, h2 img, h3 img, h4 img, h5 img, h6 img {margin:0;}
+p {margin:0 0 1.5em;}
+p img.left {float:left;margin:1.5em 1.5em 1.5em 0;padding:0;}
+p img.right {float:right;margin:1.5em 0 1.5em 1.5em;}
+a:focus, a:hover {color:#000;}
+a {color:#009;text-decoration:underline;}
+blockquote {margin:1.5em;color:#666;font-style:italic;}
+strong {font-weight:bold;}
+em, dfn {font-style:italic;}
+dfn {font-weight:bold;}
+sup, sub {line-height:0;}
+abbr, acronym {border-bottom:1px dotted #666;}
+address {margin:0 0 1.5em;font-style:italic;}
+del {color:#666;}
+pre {margin:1.5em 0;white-space:pre;}
+pre, code, tt {font:1em 'andale mono', 'lucida console', monospace;line-height:1.5;}
+li ul, li ol {margin:0 1.5em;}
+ul, ol {margin:0 1.5em 1.5em 1.5em;}
+ul {list-style-type:disc;}
+ol {list-style-type:decimal;}
+dl {margin:0 0 1.5em 0;}
+dl dt {font-weight:bold;}
+dd {margin-left:1.5em;}
+table {margin-bottom:1.4em;width:100%;}
+th {font-weight:bold;}
+thead th {background:#c3d9ff;}
+th, td, caption {padding:4px 10px 4px 5px;}
+tr.even td {background:#e5ecf9;}
+tfoot {font-style:italic;}
+caption {background:#eee;}
+.small {font-size:.8em;margin-bottom:1.875em;line-height:1.875em;}
+.large {font-size:1.2em;line-height:2.5em;margin-bottom:1.25em;}
+.hide {display:none;}
+.quiet {color:#666;}
+.loud {color:#000;}
+.highlight {background:#ff0;}
+.added {background:#060;color:#fff;}
+.removed {background:#900;color:#fff;}
+.first {margin-left:0;padding-left:0;}
+.last {margin-right:0;padding-right:0;}
+.top {margin-top:0;padding-top:0;}
+.bottom {margin-bottom:0;padding-bottom:0;}
+
+
+
+/* @end */
+
+#container {
+ width: 950px;
margin: 0 auto;
- padding: 0;
- background-color: #000000;
}
-#thumbstrip ul {
- /* this cannot be too large */
- width:20000em;
- position:absolute;
- list-style-type: none;
- margin: 0;
- padding: 0;
-}
-
-/*
- a single item. must be floated on horizontal scrolling
- typically this element is the one that *you* will style
- the most.
-*/
-
-LABEL.big {
- font-weight: bold;
+div#header h1 {
+ text-transform: uppercase;
+ font-weight: bold;
+ letter-spacing: 10px;
+ margin: 10px 0 0 0;
+ float: left;
}
-INPUT.big {
- font-size: 22px;
+div#header {
+ padding: 10px 0;
}
-
-#thumbstrip ul li {
- float:left;
- background: black;
- padding: 5px;
- margin: 0;
- cursor: pointer;
+div#content {
+ clear: both;
}
-
-
-#photo_large img {
+div#footer {
+ clear: both;
+}
+form#search {
+ margin: 5px 0;
+ padding: 5px 10px;
+ float: right;
+}
+form#search input {
+ padding: 5px 5px 5px;
+ font-size: 13px;
+}
+form#search input.textfield {
+ width: 400px;
border: 1px solid black;
}
-
-SPAN.tagMatches {
- margin-left: 10px;
+p.links {
+ margin: 5px 0;
+ text-transform: uppercase;
+}
+p.links a {
+ text-decoration: none;
+}
+p.links a:hover {
+ text-decoration: underline;
+}
+hr.seperator {
+ clear: both;
+ border: none;
+ background-color: #ddd;
+ height: 1px;
+}
+div.thumb {
+ background-color: #eee;
+ float: left;
+ padding: 10px;
+ margin-right: 10px;
+ margin-bottom: 10px;
+}
+div.thumb h3 {
+ text-transform: uppercase;
+ font-weight: bold;
+ font-size: 13px;
+}
+div.thumb h3 a {
+ color: black;
+ text-decoration: none;
+}
+div.thumb h3 a:hover {
+ border-bottom: 1px solid #999;}
+div.thumb img {
+ width: 200px;
+ height: 200px;
+}
+div.thumb p {
+ text-align: center;
+ margin: 0;
+}
+.row {
+ clear: both;
+ padding-bottom: 40px;
}
-SPAN.tagMatches SPAN {
- padding: 2px;
- margin-right: 4px;
- background-color: #0000AB;
- color: #fff;
- cursor: pointer;
+img {
+
+
+}
+.row div.image {
+ margin: 10px 0 0;
+ float: left;
+}
+.row div.image img {
+ margin: 0 0 0 10px;
+}
+div.title {
+ margin: 10px 0 0;
+ border-right: 1px solid #bbb;
+ display: block;
+ float: left;
+ width: 240px;
+}
+.row div.title img, .row div.image img {
+ width: 100px;
+ height: 100px;
+}
+div.title img {
+ float: right;
+ padding-right: 10px;
+ width: 100px;
+}
+div.title p {
+ font-weight: bold;
+ font-size: 18px;
+}
+div#header h1 p {
+ display: inline;
+ font-size: 12px;
+ letter-spacing: normal;
+ font-weight: normal;
+}
+td {
+ vertical-align: bottom;
}
\ No newline at end of file