papermill 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -29,7 +29,7 @@ begin
29
29
  gemspec.summary = "Paperclip Swfupload UploadHelper wrapper"
30
30
  gemspec.description = "Paperclip Swfupload UploadHelper wrapper"
31
31
  gemspec.email = "benoit.benezech@gmail.com"
32
- gemspec.homepage = "http://github.com/BBenezech/papermill"
32
+ gemspec.homepage = "http://github.com/bbenezech/papermill"
33
33
  gemspec.authors = ["Benoit Bénézech"]
34
34
  gemspec.add_dependency('paperclip', '>= 2.1.2')
35
35
  gemspec.add_dependency('mime-types', '>= 1.16')
data/TODO.txt CHANGED
@@ -1,2 +1 @@
1
1
  * non-regression tests
2
- * check for necessity for requires over gemspec dependencies
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.0
1
+ 0.9.0
@@ -39,7 +39,7 @@ class PapermillController < ApplicationController
39
39
  def update
40
40
  @asset = PapermillAsset.find_by_id(params[:id])
41
41
  render :update do |page|
42
- if @asset && @asset.update(params)
42
+ if @asset && @asset.update_attributes(params[:papermill_asset])
43
43
  page << %{ notify("#{t("updated", :ressource => @asset.name, :scope => "papermill")}", "notice") }
44
44
  else
45
45
  page << %{ notify("#{@asset && @asset.errors.full_messages.to_sentence || t("not-found", :ressource => params[:id].to_s, :scope => "papermill")}", "warning") }
@@ -53,7 +53,9 @@ class PapermillController < ApplicationController
53
53
 
54
54
  def create
55
55
  asset_class = params[:asset_class].constantize
56
- params[:assetable_type] = params[:assetable_type].camelize if params[:assetable_type]
56
+ params[:assetable_id] = params[:assetable_id].try :to_i
57
+ params[:assetable_type] = params[:assetable_type].try :camelize
58
+ params[:assetable_key] = params[:assetable_key].try :to_s
57
59
  params[:swfupload_file] = params.delete(:Filedata)
58
60
  unless params[:gallery]
59
61
  @old_asset = asset_class.find(:first, :conditions => params.reject{|k, v| ![:assetable_key, :assetable_type, :assetable_id].include?(k)})
@@ -1,5 +1,39 @@
1
- <% if @asset.image? %>
2
- <%= image_tag @asset.url %>
3
- <% else %>
4
- <%= @asset.url %>
5
- <% end %>
1
+ <link href="/stylesheets/papermill.css" media="screen" rel="stylesheet" type="text/css" />
2
+ <div id="papermill-box">
3
+ <div id="left">
4
+ <%= link_to(@asset.image? ? image_tag(@asset.url("400x>")) : I18n.t("file_type", :type => @asset.content_type.join("/"), :scope => 'papermill'), @asset.url, :popup => true) %>
5
+ </div>
6
+ <div id="right">
7
+ <div id="read-only">
8
+ <h3><%= I18n.t("read-only", :scope => 'papermill') %></h3>
9
+ <p><%= I18n.t("name", :scope => 'papermill') %><span><%= @asset.name %></span></p>
10
+ <p><%= I18n.t("content_type", :scope => 'papermill') %><span><%= @asset.content_type.join('/') %></span></p>
11
+ <p><%= I18n.t("size", :scope => 'papermill') %><span><%= number_to_human_size(@asset.size.to_i) %></span></p>
12
+ <% if @asset.image? %>
13
+ <p><%= I18n.t("width", :scope => 'papermill') %><span><%= @asset.width %>px</span></p>
14
+ <p><%= I18n.t("height", :scope => 'papermill') %><span><%= @asset.height %>px</span></p>
15
+ <% end %>
16
+ <p><%= I18n.t("created_at", :scope => 'papermill') %><span><%= I18n.l(@asset.created_at) %></span></p>
17
+ <p><%= I18n.t("updated_at", :scope => 'papermill') %><span><%= I18n.l(@asset.updated_at) %></span></p>
18
+ <p><%= I18n.t("class_name", :scope => 'papermill') %><span><%= @asset.class.name.underscore.humanize %></span></p>
19
+ <% if assetable = @asset.assetable %>
20
+ <p onclick="jQuery('#parent-box').toggle(); jQuery('#parent-box-more').toggle(); return false;"><%= I18n.t("parent", :scope => 'papermill') %><span id="parent-box-more">...</span></p>
21
+ <span style="display:none;" id="parent-box"><%= debug assetable.to_yaml %></span>
22
+ <% end %>
23
+ </div>
24
+ <div id="read-write">
25
+ <h3><%= I18n.t("modifiable_fields", :scope => 'papermill') %></h3>
26
+ <% remote_form_for :papermill_asset, @asset, :url => papermill_path(@asset), :html => { :method => :put, :class => "edit_asset" } do |f| %>
27
+ <%= f.label :title, I18n.t("title", :scope => 'papermill') %>
28
+ <%= f.text_field :title, :class => "text_field" %>
29
+ <%= f.label :copyright, I18n.t("copyright", :scope => 'papermill') %>
30
+ <%= f.text_field :copyright, :class => "text_field" %>
31
+ <%= f.label :description, I18n.t("description", :scope => 'papermill') %>
32
+ <%= f.text_area :description %>
33
+ <div><%= submit_tag I18n.t('save', :scope => 'papermill') %></div>
34
+ <% end %>
35
+ </div>
36
+ </div>
37
+ <div style="clear:both;"></div>
38
+ <p id="footer"><%= I18n.t("location", :scope => 'papermill') + @asset.url %></p>
39
+ </div>
@@ -1,6 +1,6 @@
1
1
  en:
2
2
  papermill:
3
- not-processed: "Error/ressource not processed"
3
+ not-processed: "Error/resource not processed"
4
4
  updated: "{{ressource}} updated"
5
5
  not-deleted: "{{ressource}} could not be deleted"
6
6
  not-found: "Asset #{{ressource}} not found"
@@ -12,10 +12,27 @@ en:
12
12
  SWFUPLOAD_PENDING: "Pending..."
13
13
  SWFUPLOAD_LOADING: "Loading..."
14
14
  SWFUPLOAD_ERROR: "Something happened while loading" # + " <file_name> (<swfupload error message> [<error code>])"
15
+ file_type: "{{type.capitalize}} file"
16
+ read-only: "Read-only information: "
17
+ modifiable_fields: "Modifiable fields: "
18
+ name: "Name: "
19
+ content_type: "Content-type: "
20
+ size: "File size: "
21
+ class_name: "Asset type: "
22
+ created_at: "Created at: "
23
+ updated_at: "Updated at: "
24
+ title: "Title"
25
+ copyright: "Copyright: "
26
+ description: "Description: "
27
+ save: "Send to server"
28
+ location: "File-system location: "
29
+ parent: "Parent object: "
30
+ width: "Width: "
31
+ height: "Height: "
15
32
  fr:
16
33
  papermill:
17
34
  not-processed: "Erreur/ressource non trouvée"
18
- updated: "{{ressource}} mise à jour"
35
+ updated: "{{ressource}} mis(e) à jour"
19
36
  not-deleted: "{{ressource}} n'a pas pu être supprimée"
20
37
  not-found: "Asset #{{ressource}} non trouvé"
21
38
  edit-title: ""
@@ -25,4 +42,21 @@ fr:
25
42
  delete-confirmation: "Êtes-vous sûr de vouloir supprimer '{{resource}}' ?"
26
43
  SWFUPLOAD_PENDING: "En attente..."
27
44
  SWFUPLOAD_LOADING: "Chargement..."
28
- SWFUPLOAD_ERROR: "Une erreur est survenue pendant le chargement de"
45
+ SWFUPLOAD_ERROR: "Une erreur est survenue pendant le chargement de"
46
+ file_type: "Fichier {{type}}"
47
+ read-only: "Informations en lecture seule : "
48
+ modifiable_fields: "Informations modifiables : "
49
+ name: "Nom : "
50
+ content_type: "Content-type : "
51
+ size: "Taille du fichier : "
52
+ class_name: "Type d'asset : "
53
+ created_at: "Création : "
54
+ updated_at: "Mise à jour : "
55
+ title: "Titre : "
56
+ copyright: "Copyright : "
57
+ description: "Description : "
58
+ save: "Envoyer"
59
+ location: "Emplacement du fichier : "
60
+ parent: "Objet parent : "
61
+ width: "Largeur : "
62
+ height: "Hauteur : "
@@ -31,6 +31,14 @@ class PapermillAsset < ActiveRecord::Base
31
31
  file_file_name
32
32
  end
33
33
 
34
+ def width
35
+ image? && Paperclip::Geometry.from_file(file).width
36
+ end
37
+
38
+ def height
39
+ image? && Paperclip::Geometry.from_file(file).height
40
+ end
41
+
34
42
  def size
35
43
  file_file_size
36
44
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{papermill}
8
- s.version = "0.8.0"
8
+ s.version = "0.9.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Benoit B\303\251n\303\251zech"]
12
- s.date = %q{2009-09-23}
12
+ s.date = %q{2009-09-24}
13
13
  s.description = %q{Paperclip Swfupload UploadHelper wrapper}
14
14
  s.email = %q{benoit.benezech@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -59,7 +59,7 @@ Gem::Specification.new do |s|
59
59
  "test/test_helper.rb",
60
60
  "uninstall.rb"
61
61
  ]
62
- s.homepage = %q{http://github.com/BBenezech/papermill}
62
+ s.homepage = %q{http://github.com/bbenezech/papermill}
63
63
  s.rdoc_options = ["--charset=UTF-8"]
64
64
  s.require_paths = ["lib"]
65
65
  s.rubygems_version = %q{1.3.4}
@@ -1,12 +1,52 @@
1
1
  popup = function(title1, title) {
2
2
  window.open (title1, title, config='height=700, width=600, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no')
3
3
  }
4
- // override at will
4
+
5
+
6
+ /*
7
+ If you have a popup library, override popup
8
+
9
+ * e.g. facebox :
10
+
11
+ popup = function(url) {
12
+ jQuery.facebox(function() {
13
+ jQuery.get(url, function(data) {
14
+ jQuery.facebox(data)
15
+ })
16
+ })
17
+ return false;
18
+ }
19
+
20
+ * e.g. Shadowbox :
21
+
22
+ popup = function(url) {
23
+ if(url) {
24
+ Shadowbox.open({
25
+ content: url,
26
+ player: "iframe",
27
+ width: 1280,
28
+ height: 768
29
+ });
30
+ }
31
+ return false;
32
+ }
33
+ */
5
34
 
6
35
  notify = function(message, type) {
7
36
  alert(type + ": " + message)
8
37
  }
9
- // You can override notify later, with your own notification system
38
+ /*
39
+ If you have a notification library, override notify
40
+
41
+ * e.g. jGrowl :
42
+
43
+ notify = function(message, type) {
44
+ if(type == "notice") { jQuery.noticeAdd({ text: message, stayTime: 4000, stay: false, type: type }) }
45
+ if(type == "warning") { jQuery.noticeAdd({ text: message, stayTime: 9000, stay: false, type: type }) }
46
+ if(type == "error") { jQuery.noticeAdd({ text: message, stayTime: 20000, stay: false, type: type }) }
47
+ }
48
+
49
+ */
10
50
 
11
51
  var Upload = {
12
52
  files_queued: 0,
@@ -1,3 +1,17 @@
1
+ #papermill-box{width:942px; margin-bottom:10px;}
2
+ #papermill-box #left {float:left; width:400px; padding-bottom:10px;}
3
+ #papermill-box #right {float:right; width:500px; margin-left:20px; border-left:2px solid GREY; padding-left:20px; padding-bottom:10px;}
4
+ #papermill-box #read-only {}
5
+ #papermill-box #read-write {margin-top:30px;}
6
+ #papermill-box p {margin:4px;}
7
+ #papermill-box p span{font-weight:bold;}
8
+ #papermill-box #parent-box {display:block; border:1px solid GREY; padding: 5px; margin:5px;}
9
+ #papermill-box h3 {}
10
+ #papermill-box input.text_field {width:400px; margin:10px; margin-top:5px;}
11
+ #papermill-box textarea {width:400px; height:100px; margin:10px; margin-top:5px;}
12
+ #papermill-box label {margin-left:4px;}
13
+ #papermill-box #footer {text-align:center; font-size:12px; padding:5px}
14
+
1
15
  .papermill a:hover { background:none; color:inherit; }
2
16
  .papermill a img { border:0px; }
3
17
  .papermill li:hover { border-color:blue; }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: papermill
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Benoit B\xC3\xA9n\xC3\xA9zech"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-23 00:00:00 +02:00
12
+ date: 2009-09-24 00:00:00 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -104,7 +104,7 @@ files:
104
104
  - test/test_helper.rb
105
105
  - uninstall.rb
106
106
  has_rdoc: true
107
- homepage: http://github.com/BBenezech/papermill
107
+ homepage: http://github.com/bbenezech/papermill
108
108
  licenses: []
109
109
 
110
110
  post_install_message: