menu on top. not very nice but works. tags as arrays not strings. fixed tagging for album. shows all tags for photos in album now
This commit is contained in:
parent
fb8d2f4eb0
commit
0fb47748db
|
@ -1,7 +1,11 @@
|
|||
class TagsController < ApplicationController
|
||||
|
||||
def index
|
||||
@tags = Tag.find( :all)
|
||||
if params[:album_id]
|
||||
@tags = Album.find( params[:album_id] ).photo_tags
|
||||
else
|
||||
@tags = Tag.find( :all, :order => 'title')
|
||||
end
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render :json => @tags }
|
||||
|
|
|
@ -14,12 +14,12 @@ module ApplicationHelper
|
|||
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)
|
||||
#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("p", links, :id => "breadcrumb")
|
||||
content_tag("div", links, :id => "breadcrumb")
|
||||
end
|
||||
end
|
||||
|
|
|
@ -49,6 +49,7 @@ class Album < ActiveRecord::Base
|
|||
else
|
||||
# combine arrays if they have identical tags.
|
||||
# Will remove tags that are only tagged to one photo
|
||||
#tags = tags & photo_tags
|
||||
tags = tags & photo_tags
|
||||
end
|
||||
}
|
||||
|
@ -57,27 +58,34 @@ class Album < ActiveRecord::Base
|
|||
|
||||
def tags=(tags)
|
||||
tags = tags.split(" ").sort
|
||||
current_tags = ( self.tags.nil? ? [] : self.tags.split(" ") )
|
||||
current_tags = ( self.tags.nil? ? [] : self.tags.map{|tag|tag.title} )
|
||||
return if tags == self.tags
|
||||
|
||||
# find tags that should be removed from this album - thus remove from all photos in album
|
||||
# i.e. tags listed in self.tag_list but no in parameter tags
|
||||
#current_tags.map {|tag|tag if !tags.include?(tag) }.compact
|
||||
(current_tags - tags).each { |tag|
|
||||
#puts "remove #{tag}"
|
||||
self.photos.each {|photo|
|
||||
photo.untag( tag )
|
||||
}
|
||||
}
|
||||
|
||||
# add universial tags to all photos in album
|
||||
tags.each do |tag|
|
||||
#puts "tag photos with #{tag}" if !current_tags.include?( tag )
|
||||
(tags - current_tags).each do |tag|
|
||||
self.photos.each { |photo|
|
||||
photo.tag( tag ) if !current_tags.include?( tag ) # no need to re-tag
|
||||
photo.tag( tag )
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
def photo_tags
|
||||
tags = Array.new
|
||||
self.photos.each{ |photo|
|
||||
tags = tags | photo.tags
|
||||
}
|
||||
return tags
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
private
|
||||
|
|
|
@ -92,7 +92,7 @@ class Photo < ActiveRecord::Base
|
|||
img.thumbnail(210) do |thumb|
|
||||
thumb.save APP_CONFIG[:thumbs_path] + self.album.path + "/" + self.id.to_s + "_preview" + self.extension
|
||||
end
|
||||
img.thumbnail(950) do |thumb|
|
||||
img.thumbnail(800) do |thumb|
|
||||
thumb.save APP_CONFIG[:thumbs_path] + self.album.path + "/" + self.id.to_s + "_single" + self.extension
|
||||
end
|
||||
end
|
||||
|
@ -127,7 +127,7 @@ class Photo < ActiveRecord::Base
|
|||
self.longitude = photo.GPSLongitude if self.longitude.nil?
|
||||
self.latitude = photo.GPSLatitude if self.latitude.nil?
|
||||
self.title = photo.DocumentName if self.title.nil?
|
||||
self.description = photo.ImageDescription if self.description.nil? || photo.ImageDescription == 'Exif_JPEG_PICTURE'
|
||||
self.description = photo.ImageDescription if self.description.nil? || photo.ImageDescription != 'Exif_JPEG_PICTURE'
|
||||
self.tag_list = (self.tags.empty? ? "" : self.album.tag_list) + " " + (photo.Keywords.nil? ? "" : photo.Keywords.to_a.map { |tag| tag.gsub(" ", "_") }.join(" "))
|
||||
end
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
<%= form.text_area :note %><br />
|
||||
|
||||
<%= form.label :tags %><br />
|
||||
<%= form.text_field :tags, { :autocomplete => "off", :class => 'tag_list'} %><br />
|
||||
<%= form.text_field :tags, { :autocomplete => "off", :class => 'tag_list', :value => @album.tags.map{|tag|tag.title}.join(" ") } %><br />
|
||||
|
||||
<br />
|
||||
<% if @album.path? %>
|
||||
|
|
|
@ -13,7 +13,11 @@
|
|||
</div>
|
||||
|
||||
<p><%= @album.description %></p>
|
||||
<p>Tagged with: <%= @album.tags.map {|tag| (link_to tag.title, album_tag_photos_path(@album, tag) ) + " " } unless @album.tags.nil? %></p>
|
||||
<p>Tagged with:
|
||||
<% for tag in @album.photo_tags.map{|tag|tag.title}.sort %>
|
||||
<%= link_to tag, album_tag_photos_path(@album, tag )%>
|
||||
<% end %>
|
||||
</p>
|
||||
|
||||
<% if has_role?("admin") %>
|
||||
<p><%= @album.address %></p>
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
<% content_for :action_links do %>
|
||||
<% if has_role?("admin") %>
|
||||
<%= link_to "New collection", new_collection_path %></p>
|
||||
<%= link_to "New collection", new_collection_path %>
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -12,7 +12,15 @@
|
|||
|
||||
<div id="header">
|
||||
<%= breadcrumbs %>
|
||||
<div id="action_links">
|
||||
<%= yield :action_links %>
|
||||
<% if current_user %>
|
||||
Logged in as <%= current_user.name %>
|
||||
<%= link_to 'Logout', logout_path %>
|
||||
<% else %>
|
||||
<%= link_to 'Login', login_path %>
|
||||
<% end %>
|
||||
</div>
|
||||
<h1>ImageGallery</h1>
|
||||
<form action="/photos" method="get" id="search">
|
||||
<input type="text" name="q" class="textfie.d"/>
|
||||
|
|
|
@ -1 +1 @@
|
|||
<%= link_to (image_tag photo.path_modified_public(defined?(photosize) ? photosize : "album") ), photo_path(photo) %>
|
||||
<%= link_to (image_tag photo.path_modified_public(defined?(photosize) ? photosize : "album") ), [photo.album.collections.first, photo.album, photo] %>
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
<% content_for :action_links do %>
|
||||
<%= link_to "Show albums containing photos tagged with #{params[:q]}", albums_path(:q => params[:q]) if params[:q] %>
|
||||
<%= link_to "Show all photos tagged with #{params[:tag_id]}", tag_photos_path(params[:tag_id]) if params[:tag_id] && params[:album_id] %>
|
||||
<% end %>
|
|
@ -19,12 +19,12 @@
|
|||
|
||||
<p><%= @photo.description %></p>
|
||||
<p>Tagged with:
|
||||
<% for tag in @photo.tags %>
|
||||
<%= link_to tag.title, tag_photos_path(tag) %>
|
||||
<% for tag in @photo.tags.map{|tag|tag.title}.sort %>
|
||||
<%= link_to tag, tag_photos_path(tag) %>
|
||||
<% end %>
|
||||
|
||||
<% content_for :action_links do %>
|
||||
<% if has_role?("admin") %>
|
||||
<br /><%= link_to "Edit photo", edit_photo_path(@photo) %>
|
||||
<%= link_to "Edit photo", edit_photo_path(@photo) %>
|
||||
<% end %>
|
||||
<% end %>
|
|
@ -10,5 +10,3 @@
|
|||
<% end%>
|
||||
<p><%= f.submit "Submit" %></p>
|
||||
<% end %>
|
||||
|
||||
<br /><%= link_to "Back to #{@album.title}", @album %>
|
|
@ -1,4 +1,4 @@
|
|||
<h1>Tags</h1>
|
||||
<% for tag in @tags %>
|
||||
<p><%= link_to tag.title, tag_photos_path(tag) %></p>
|
||||
<%= link_to tag.title, tag_photos_path(tag) %>
|
||||
<% end %>
|
|
@ -13,6 +13,7 @@ Rails::Initializer.run do |config|
|
|||
config.gem 'mime-types', :lib => 'mime/types'
|
||||
config.gem "image_science"
|
||||
config.gem "mini_exiftool"
|
||||
# config.gem "inline"
|
||||
|
||||
config.load_paths += %W( #{RAILS_ROOT}/app/middleware )
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ div#header h1 {
|
|||
letter-spacing: 10px;
|
||||
margin: 10px 0 0 0;
|
||||
float: left;
|
||||
clear: left;
|
||||
}
|
||||
|
||||
div#header {
|
||||
|
@ -189,6 +190,16 @@ div#header h1 p {
|
|||
letter-spacing: normal;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
DIV#breadcrumb {
|
||||
float: left;
|
||||
}
|
||||
|
||||
DIV#action_links {
|
||||
float: right;
|
||||
clear: right;
|
||||
}
|
||||
|
||||
td {
|
||||
vertical-align: bottom;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue