diff --git a/app/controllers/albums_controller.rb b/app/controllers/albums_controller.rb
index e8e36d6..a4a08ed 100644
--- a/app/controllers/albums_controller.rb
+++ b/app/controllers/albums_controller.rb
@@ -16,9 +16,10 @@ class AlbumsController < ApplicationController
format.html
format.json { render :json => @album }
format.xml { render :xml => @album }
+ format.pdf { render :pdf => @album.title }
end
end
-
+
def new
@album = Album.new
end
diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb
index c80ff05..f0373b4 100644
--- a/app/controllers/photos_controller.rb
+++ b/app/controllers/photos_controller.rb
@@ -2,7 +2,7 @@ class PhotosController < ApplicationController
before_filter :require_user, :only => [:new, :create, :edit, :update, :destroy]
def index
- @photos = Photo.find(:all)
+ @photos = Tag.find_by_title( params[:tag_id] ).photos
respond_to do |format|
format.html
format.json { render :json => @photos }
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
new file mode 100644
index 0000000..a46d724
--- /dev/null
+++ b/app/controllers/tags_controller.rb
@@ -0,0 +1,11 @@
+class TagsController < ApplicationController
+
+ def index
+ @tags = Tag.find( :all)
+ respond_to do |format|
+ format.html
+ format.json { render :json => @tags }
+ format.xml { render :xml => @tags }
+ end
+ end
+end
diff --git a/app/models/photo.rb b/app/models/photo.rb
index c732266..99dc335 100644
--- a/app/models/photo.rb
+++ b/app/models/photo.rb
@@ -3,12 +3,30 @@ class Photo < ActiveRecord::Base
has_many :photo_tags, :dependent => :destroy
has_many :tags, :through => :photo_tags
+ #accepts_nested_attributes_for :photo_tags, :allow_destroy => true
+
validates_uniqueness_of :path, :message => "Photo already exsists on disc"
+ validates_presence_of :title
before_destroy :destroy_file
+ attr_accessor :tag_list
+
+ def tag_list
+ return self.tags.find(:all, :order => 'title').collect{ |t| t.title }.join(" ")
+ end
+
+ def tag_list=(tags)
+ ts = Array.new
+ tags.split(" ").each do |tag|
+ ts.push( Tag.find_or_create_by_title( :title => tag) )
+ end
+ self.tags = ts
+ end
+
private
+
def destroy_file
puts "DELETE FILE " + APP_CONFIG[:photos_path] + self.path
File.delete( APP_CONFIG[:photos_path] + self.path ) if File.exists?( APP_CONFIG[:photos_path] + self.path )
diff --git a/app/models/tag.rb b/app/models/tag.rb
index 0cb1278..4b4833f 100644
--- a/app/models/tag.rb
+++ b/app/models/tag.rb
@@ -1,4 +1,14 @@
class Tag < ActiveRecord::Base
has_many :photo_tags
has_many :photos, :through => :photo_tags
+
+ validates_uniqueness_of :title
+
+ 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
+ end
+
end
diff --git a/app/views/albums/_form.html.erb b/app/views/albums/_form.html.erb
index c1cc0c9..b11ee4f 100644
--- a/app/views/albums/_form.html.erb
+++ b/app/views/albums/_form.html.erb
@@ -1,4 +1,7 @@
<%= form.label :title %>
<%= form.text_field :title %>
+<%= form.label :description %>
+<%= form.text_area :description %>
-<%= @album.path %>
\ No newline at end of file
+Location on disk: <%= APP_CONFIG[:photos_path] + @album.path %>
+Contains: <%= @album.photos.count %> photos
\ No newline at end of file
diff --git a/app/views/albums/show.html.erb b/app/views/albums/show.html.erb
index 7e6796b..cf73b42 100644
--- a/app/views/albums/show.html.erb
+++ b/app/views/albums/show.html.erb
@@ -1,45 +1,30 @@
+<% content_for :head do %>
+
+<% end %>
+
+<% content_for :javascript do %>
+
+
+
+<% end %>
+
<%= @album.description %>
\ No newline at end of file diff --git a/app/views/albums/show.pdf.erb b/app/views/albums/show.pdf.erb new file mode 100644 index 0000000..8a40e71 --- /dev/null +++ b/app/views/albums/show.pdf.erb @@ -0,0 +1,3 @@ +