diff --git a/app/controllers/tags.rb b/app/controllers/tags.rb index dd3f74f..8b7f5d6 100644 --- a/app/controllers/tags.rb +++ b/app/controllers/tags.rb @@ -10,8 +10,9 @@ class Tags < Application raise NotFound unless @tag @pages = @tag.pages @albums = @tag.albums + @photos = @tag.photos @secondary_title = "Content tagged with #{@tag.name}" - display @tag + render end def new diff --git a/app/views/albums/_albums.html.erb b/app/views/albums/_albums.html.erb new file mode 100644 index 0000000..6fb1526 --- /dev/null +++ b/app/views/albums/_albums.html.erb @@ -0,0 +1,13 @@ +<% if albums.nil? or albums.empty? -%> +

There were no albums found!

+<% else -%> + +<% albums.each_with_index do |album, index| -%> +
+

<%= album.name -%> (<%= album.photos.size -%> photos)

+ <% if album.album_thumbnail -%><% end -%> +
+<% end -%> +
+ +<% end -%> diff --git a/app/views/albums/_photos.html.erb b/app/views/albums/_photos.html.erb new file mode 100644 index 0000000..472f8a1 --- /dev/null +++ b/app/views/albums/_photos.html.erb @@ -0,0 +1,10 @@ +<% if photos.nil? or photos.empty? %> +

There were no photos found!

+<% else -%> + +<% photos.each_with_index do |photo, idx| -%> +
+ <% if (idx + 1) % 3 == 0 or photos.last == photo -%>
<% end -%> +<% end -%> + +<% end -%> diff --git a/app/views/albums/index.html.erb b/app/views/albums/index.html.erb index 4f33d08..9b6821f 100644 --- a/app/views/albums/index.html.erb +++ b/app/views/albums/index.html.erb @@ -7,45 +7,6 @@ <% end -%> -<% throw_content :for_stylesheet do -%> +<%= partial 'albums', :albums => @albums %> -.photo_collection_item { - word-wrap: break-word; - width: 170px; - height: 200px; - margin-top: 15px; - padding: 5px; - text-align: center; - border: 1px solid #BBB; - float: left; - position: relative; -} - -.col_1 { - margin-left: 10px; -} - -.col_2 { - margin-left: 10px; -} - -.col_0 { - margin-left: 10px; -} - -<% end -%> - -<% if @albums.empty? -%> -

There were no albums found!

-<% else -%> - <% @albums.each_with_index do |album, index| -%> -
-

<%= album.name -%> (<%= album.photos.size -%> photos)

- <% if album.album_thumbnail -%><% end -%> -
- <% end -%> - -
- - <%= partial 'shared/pagination_links' %> -<% end -%> \ No newline at end of file +<%= partial 'shared/pagination_links' %> diff --git a/app/views/albums/show.html.erb b/app/views/albums/show.html.erb index 8c09988..6d0a80a 100644 --- a/app/views/albums/show.html.erb +++ b/app/views/albums/show.html.erb @@ -20,34 +20,10 @@ <% end -%> <% end -%> -<% throw_content :for_stylesheet do -%> - -.photo_collection_item { - word-wrap: break-word; - max-width: 150px; - max-height: 150px; - margin-top: 15px; - margin-bottom: 15px; - padding: 3px; - border: 1px solid #BBB; - float: left; - position: relative; -} - -.col_1, .col_2, .col_0 { - margin-left: 15px; - margin-right: 15px; -} - -<% end -%> -

<%= @album.name -%>

-<% @photos.each_with_index do |photo, idx| -%> -
- <% if (idx + 1) % 3 == 0 or @photos.last == photo -%>
<% end -%> -<% end -%> +<%= partial 'photos', :photos => @photos %>
<%= partial 'shared/pagination_links' %> diff --git a/app/views/tags/show.html.erb b/app/views/tags/show.html.erb index 1ef9961..baa72f5 100644 --- a/app/views/tags/show.html.erb +++ b/app/views/tags/show.html.erb @@ -11,8 +11,9 @@ <% end %>

Albums

-<% if @albums.empty? -%> -

None!

-<% else -%> -
    <%= @albums.collect { |a| "
  1. #{a.name}
  2. " }.join -%>
-<% end -%> +<%= partial 'albums/albums', :albums => @albums %> + +
+ +

Photos

+<%= partial 'albums/photos', :photos => @photos %> diff --git a/public/stylesheets/content.css b/public/stylesheets/content.css index 8e47806..4796833 100644 --- a/public/stylesheets/content.css +++ b/public/stylesheets/content.css @@ -489,3 +489,32 @@ margin-left: auto; margin-right: auto; } + +.photo_album { + word-wrap: break-word; + width: 170px; + height: 200px; + margin-top: 15px; + padding: 5px; + text-align: center; + border: 1px solid #BBB; + float: left; + position: relative; +} + +.photo { + word-wrap: break-word; + max-width: 150px; + max-height: 150px; + margin-top: 15px; + margin-bottom: 15px; + padding: 3px; + border: 1px solid #BBB; + float: left; + position: relative; +} + +.col_1, .col_2, .col_0 { + margin-left: 10px; + margin-right: 10px; +}