Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

edit picture data, turned off metadata storage

  • Loading branch information...
commit 75f24b8d83877cab8ae1e28f2eeb3ceb51c8ec23 1 parent 5de6ba4
@zlorfi authored
View
19 app.rb
@@ -25,6 +25,7 @@ class App < Sinatra::Base
d.datastore.root_path = File.join('upload')
d.datastore.server_root = File.join('upload')
d.url_format = '/images/:job/:basename.:format'
+ d.store_meta = false
end
Mongoid.load!('config/mongoid.yml', ENV['RACK_ENV'] )
@@ -155,7 +156,7 @@ def page_title
file = params[:file][:tempfile]
prepared_image = app.fetch_file(file).process!(:resize, '1000x1000>')
- image_uid = app.store(prepared_image, :meta => {:upload_time => Time.now, :name => filename})
+ image_uid = app.store(prepared_image)
picture = Picture.create(image_uid: image_uid,
image_name: filename,
image_title: params[:title],
@@ -163,7 +164,7 @@ def page_title
)
flash[:success] = "Upload successful of #{filename}"
- redirect "/i/#{picture.id}" if !request.xhr?
+ redirect "/e/#{picture.id}" if !request.xhr?
picture.to_json
else
flash[:alert] = 'You have to choose an image file first'
@@ -172,17 +173,25 @@ def page_title
end
- get '/i/:image_id' do |image_id|
+ put '/e/:image_id' do |image_id|
+ protected!
+ picture = Picture.find(image_id)
+ picture.update_attributes(image_title: params[:title])
+ flash[:success] = "Update successful"
+ redirect "/"
+ end
+
+ get '/e/:image_id' do |image_id|
@image = Picture.find(image_id).image
@picture = Picture.find(image_id)
- haml :show
+ haml :edit
end
get '/t/:image_id' do |image_id|
Picture.find(image_id).image.thumb("400x400#").to_response(env)
end
- delete '/delete/:image_id' do
+ delete '/d/:image_id' do
protected!
p = Picture.find(params[:image_id])
if p.delete
View
34 views/edit.haml
@@ -0,0 +1,34 @@
+.row
+ .large-12.columns
+ .row
+ .large-8.columns
+ -#%i#loading.icon-spinner.icon-spin.icon-2x
+ %img{:src => "#{@image.thumb('600x600').url}"}/
+ -# %img{:src => "#{@image.thumb("200x200").png.convert("-background #666666 +polaroid").url}"}/
+ -# %img{:src => "#{@image.thumb('200x220#').url}"}/
+
+
+ .large-4.columns
+ - if admin?
+ %form(action="/e/#{@picture.id}" method="post")
+ %fieldset
+ %legend Edit image
+ .row
+ .large-12.columns
+ %label Picture ID
+ %input{:type => 'text', :placeholder => "#{@picture.id}", :disabled => ""}
+ .row
+ .large-12.columns
+ %label Title
+ %input{:type => 'text', :name => 'title', :value => "#{@picture.image_title}"}
+ .row
+ .large-6.columns
+ %a.small.button.info.radius{:href => '/'} Go Back
+ .large-6.columns
+ %input{:type => :hidden, :name => "_method", :value => "put"}
+ %input.small.button.success.radius.right{:type => "submit", :value => "Update"}
+ %form{:action => "/d/#{@picture.id}", :method => 'post'}
+ .row
+ .large-12.columns
+ %input{:type => :hidden, :name => "_method", :value => "delete"}
+ %input.small.button.alert.expand{:type => "submit", :value => "Delete this Image"}
View
12 views/index.haml
@@ -6,9 +6,9 @@
%a.fancybox{:href => "#{key.image.thumb('800x800').url}", 'data-fancybox-group' => 'button', :title => "#{key.image_title}"}
%img.lazy{'data-original' => "#{key.image.thumb('200x200#').url}", :src => "/image/grey.gif"}
-if admin?
- %form(action="/delete/#{key.id}" method="post")
+ %form(action="/d/#{key.id}" method="post")
%input{:type => :hidden, :name => "_method", :value => "delete"}
- -#%a.tiny.button.info.radius{:href => "/i/#{key.id}"} Show
+ %a.tiny.button.info.radius{:href => "/e/#{key.id}"} Edit
%input.tiny.button.alert.radius{:type => "submit", :value => "Delete"}
.row
@@ -75,7 +75,7 @@
}
});
- $('.fancybox').fancybox({
+ $('a.fancybox').fancybox({
openEffect: 'none',
closeEffect: 'none',
@@ -92,6 +92,12 @@
type: 'inside'
}
},
+ beforeShow: function () {
+ /* Disable right click */
+ $.fancybox.wrap.bind("contextmenu", function (e) {
+ return false;
+ });
+ },
afterLoad : function() {
this.title = 'Bild ' + (this.index + 1) + ' von ' + this.group.length + (this.title ? ' - ' + this.title : '');
View
2  views/sass/app.scss
@@ -50,7 +50,7 @@
// body
body {
-//background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB3aWR0aD0iNiIgaGVpZ2h0PSI2Ij4KPHJlY3Qgd2lkdGg9IjYiIGhlaWdodD0iNiIgZmlsbD0iI2VlZWVlZSI+PC9yZWN0Pgo8ZyBpZD0iYyI+CjxyZWN0IHdpZHRoPSIzIiBoZWlnaHQ9IjMiIGZpbGw9IiNlNmU2ZTYiPjwvcmVjdD4KPHJlY3QgeT0iMSIgd2lkdGg9IjMiIGhlaWdodD0iMiIgZmlsbD0iI2Q4ZDhkOCI+PC9yZWN0Pgo8L2c+Cjx1c2UgaHJlZj0iI2MiIHg9IjMiIHk9IjMiPjwvdXNlPgo8L3N2Zz4=");
+//background-image: url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNSIgaGVpZ2h0PSIxNSI+CjxyZWN0IHdpZHRoPSI1MCIgaGVpZ2h0PSI1MCIgZmlsbD0iIzI4MjgyOCI+PC9yZWN0Pgo8Y2lyY2xlIGN4PSIzIiBjeT0iNC4zIiByPSIxLjgiIGZpbGw9IiMzOTM5MzkiPjwvY2lyY2xlPgo8Y2lyY2xlIGN4PSIzIiBjeT0iMyIgcj0iMS44IiBmaWxsPSJibGFjayI+PC9jaXJjbGU+CjxjaXJjbGUgY3g9IjEwLjUiIGN5PSIxMi41IiByPSIxLjgiIGZpbGw9IiMzOTM5MzkiPjwvY2lyY2xlPgo8Y2lyY2xlIGN4PSIxMC41IiBjeT0iMTEuMyIgcj0iMS44IiBmaWxsPSJibGFjayI+PC9jaXJjbGU+Cjwvc3ZnPg==");
}
a.title {
View
22 views/show.haml
@@ -1,22 +0,0 @@
-.row
- .large-12.columns
- .row
- .large-8.columns
- -#%i#loading.icon-spinner.icon-spin.icon-2x
- %img{:src => "#{@image.thumb('600x600').url}"}/
- -# %img{:src => "#{@image.thumb("200x200").png.convert("-background #666666 +polaroid").url}"}/
- -# %img{:src => "#{@image.thumb('200x220#').url}"}/
-
-
- .large-4.columns
- =# @image.remote_url
- =# @image.url
- Picture ID:
- = @picture.id
- %br/
- Title
- = @picture.image_title
- - if admin?
- %form(action="/delete/#{@picture.id}" method="post")
- %input{:type => :hidden, :name => "_method", :value => "delete"}
- %input.small.button.alert.radius{:type => "submit", :value => "Delete"}
Please sign in to comment.
Something went wrong with that request. Please try again.