Skip to content
This repository was archived by the owner on Jan 26, 2025. It is now read-only.

Commit 79c3efb

Browse files
committed
Merge branch 'master' of github.com:codeodor/plupload-rails3
2 parents c6d0bee + d2706be commit 79c3efb

38 files changed

+730
-391
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ Consider the common case of an Album which has_many Photos.
9090

9191
In your form for an album, you can use:
9292

93-
<%= plupload(@album, :photos, options={:plupload_container=>'uploader', :pluploader=>true, :field_name=>'album[photos][][payload]'}) %>
93+
<%= plupload(@album, :photos, options={:plupload_container=>'uploader', :pluploader=>true, :field_name=>'album[photos_attributes][][payload]'}) %>
9494
<div id="uploader" name="uploader" style="width: 100%;"></div>
9595

9696

lib/app/controllers/plupload_rails_controller.rb

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,32 @@ def _plupload_uploader
55
FileUtils.mv(params[:file].tempfile, plupload_temp_path)
66
add_fields_for_files_to_forms =<<END
77
function _pluploadRails_addFieldsForFilesToForms(){
8-
for(var i=0; document.forms.length; i++) {
9-
var theForm = document.forms[i];
10-
var input = document.createElement("input");
11-
input.name='_plupload_files[]';
12-
input.type='hidden';
13-
input.value='#{File.expand_path(params[:file].tempfile.path)}';
14-
theForm.appendChild(input);
8+
$('form').each(function() {
9+
var theForm = $(this);
1510
16-
var input = document.createElement("input");
17-
input.name='_plupload_original_names[]';
18-
input.type='hidden';
19-
input.value='#{params[:file].original_filename}';
20-
theForm.appendChild(input);
11+
var default_input = $('<input />').attr('type', 'hidden');
2112
22-
var input = document.createElement("input");
23-
input.name='_plupload_content_types[]';
24-
input.type='hidden';
25-
input.value='#{params[:file].content_type}';
26-
theForm.appendChild(input);
13+
var input = default_input.clone()
14+
.attr('name', '_plupload_files[]')
15+
.val('#{File.expand_path(params[:file].tempfile.path)}');
16+
theForm.append(input);
2717
28-
var input = document.createElement("input");
29-
input.name='_plupload_upload';
30-
input.type='hidden';
31-
input.value='#{params[:_plupload_upload]}';
32-
if(document.getElementsByName(input.name).length == 0) theForm.appendChild(input);
33-
}
18+
var input = default_input.clone()
19+
.attr('name', '_plupload_original_names[]')
20+
.val('#{params[:file].original_filename}');
21+
theForm.append(input);
22+
23+
var input = default_input.clone()
24+
.attr('name', '_plupload_content_types[]')
25+
.val('#{params[:file].content_type}');
26+
theForm.append(input);
27+
28+
var input = default_input.clone()
29+
.attr('name', '_plupload_upload')
30+
.val('#{params[:_plupload_upload]}');
31+
if(document.getElementsByName(input.name).length == 0) theForm.append(input);
32+
33+
});
3434
}
3535
_pluploadRails_addFieldsForFilesToForms();
3636
END

lib/app/helpers/plupload_helper.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ def plupload(model_object, model_object_method, options={})
66
options[:params] ||= {}
77
options[:field_name] ||= [model_object].flatten.pop.class.name.underscore.downcase + "[#{model_object_method}]"
88
options[:runtimes] ||= "html5,flash,silverlight,gears,browserplus"
9-
render :partial=>'plupload/uploader_scripts', :locals=>{
10-
:model_object=>model_object,
11-
:model_object_method=>model_object_method,
12-
:options=>options
9+
render :partial => 'plupload/uploader_scripts',
10+
:locals => {
11+
:model_object => model_object,
12+
:model_object_method => model_object_method,
13+
:options => options
1314
}
1415
end
1516
end

lib/app/middleware/plupload_params_renamer.rb

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ def call(env)
99
req = Rack::Request.new(env)
1010
form_hash = Rails.version < "3.1" ? req.POST : env['rack.request.form_hash']
1111
form_hash ||= {}
12-
12+
1313
if form_hash["_plupload_upload"]
1414
object, method = form_hash["_plupload_upload"].split(/[\[\]]/)
15-
submethod = form_hash["_plupload_upload"].split(/[\[\]]/)[-1]
15+
submethod = form_hash["_plupload_upload"].split(/[\[\]]/)[-1]
1616
form_hash[object] ||= {}
1717
if form_hash["_plupload_files"]
1818
form_hash[object][method] = []
@@ -23,9 +23,14 @@ def call(env)
2323
original_filename = form_hash["_plupload_original_names"][i]
2424
content_type = form_hash["_plupload_content_types"][i]
2525

26-
uploaded_file = ActionDispatch::Http::UploadedFile.new(:tempfile=>File.new(file), :content_type=>content_type, :filename=>original_filename)
26+
uploaded_file = ActionDispatch::Http::UploadedFile.new(
27+
:tempfile => File.new(file),
28+
:type => content_type,
29+
:head => "Content-Disposition: form-data; name=\"file\"; filename=\"#{original_filename}\"\r\nContent-Type: #{content_type}\r\n",
30+
:filename => original_filename
31+
)
2732

28-
form_hash[object][method] << {submethod=>uploaded_file}
33+
form_hash[object][method] << {submethod => uploaded_file}
2934
end
3035
else
3136
form_hash[object][method] = form_hash["file"]

lib/app/views/plupload/_uploader_scripts.html.erb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
<% else %>
1919

2020
<style type="text/css">@import url(/assets/plupload-rails3/plupload.queue.3.1.css);</style>
21-
<%= stylesheet_link_tag 'plupload-rails3/plupload/js/plupload.full.js' %>
2221
<%= javascript_include_tag 'plupload-rails3/plupload/js/plupload.full.js' %>
2322
<%= javascript_include_tag 'plupload-rails3/plupload/js/jquery.plupload.queue/jquery.plupload.queue.js' %>
2423
<%= javascript_include_tag 'plupload-rails3/plupload/js/plupload.gears.js' %>
@@ -27,7 +26,7 @@
2726

2827

2928
<script type="text/javascript">
30-
29+
3130
// Convert divs to queue widgets when the DOM is ready
3231
$(function() {
3332
var authtoken = $("input[name=authenticity_token]").val();

lib/plupload-rails3/asset_mover.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ def install_plupload_assets
3838

3939
dest = File.join(Rails.root, 'tmp/plupload-rails3')
4040
puts "Creating tmp folder at #{dest}"
41-
FileUtils.mkdir(dest)
41+
FileUtils.mkdir(dest) unless File.exists?(dest)
4242
end
4343

4444
def uninstall_plupload_assets
4545
plupload_asset_destination.keys.each do |asset_type|
4646
directory = File.join(Rails.root, plupload_asset_destination[asset_type], "plupload-rails3")
4747
puts "Removing directory #{directory} and its contents"
48-
FileUtils.rm_r(directory)
48+
FileUtils.rm_r(directory) if File.exists?(directory)
4949
end
5050

5151
directory = File.join(Rails.root,'tmp/plupload-rails3')
5252
puts "Removing directory #{directory} and its contents"
53-
FileUtils.rm_r(directory)
53+
FileUtils.rm_r(directory) if File.exists?(directory)
5454
end
Loading
Binary file not shown.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// .po file like language pack
2+
plupload.addI18n({
3+
'Select files' : 'Vyberte soubory',
4+
'Add files to the upload queue and click the start button.' : 'Přidejte soubory do fronty a pak spusťte nahrávání.',
5+
'Filename' : 'Název souboru',
6+
'Status' : 'Status',
7+
'Size' : 'Velikost',
8+
'Add Files' : 'Přidat soubory',
9+
'Stop current upload' : 'Zastavit nahrávání',
10+
'Start uploading queue' : 'Spustit frontu nahrávání',
11+
'Drag files here.' : 'Sem přetáhněte soubory.',
12+
'Start Upload': 'Spustit nahrávání',
13+
'Uploaded %d/%d files': 'Nahráno %d/%d souborů'
14+
});
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// .po file like language pack
2+
plupload.addI18n({
3+
'Select files' : 'Vælg filer',
4+
'Add files to the upload queue and click the start button.' : 'Tilføj filer til køen, og tryk på start.',
5+
'Filename' : 'Filnavn',
6+
'Status' : 'Status',
7+
'Size' : 'Størrelse',
8+
'Add files' : 'Tilføj filer',
9+
'Stop current upload' : 'Stop upload',
10+
'Start uploading queue' : 'Start upload',
11+
'Drag files here.' : 'Træk filer her.'
12+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// German
2+
plupload.addI18n({
3+
'Select files' : 'W&auml;hlen Sie die Dateien:',
4+
'Add files to the upload queue and click the start button.' : 'Dateien hinzuf&uuml;gen und danach auf \'Starten des Uploads\' klicken und die Datei hochzuladen.',
5+
'Filename' : 'Dateiname',
6+
'Status' : 'Status',
7+
'Size' : 'Gr&ouml;&szlig;e',
8+
'Add files' : 'Hinzuf&uuml;gen von Dateien',
9+
'Stop current upload' : 'Stop aktuellen Upload',
10+
'Start uploading queue' : 'Starte Upload',
11+
'Uploaded %d/%d files': '%d/%d Dateien sind Hochgeladen',
12+
'N/A' : 'Nicht verf&uuml;gbar',
13+
'Drag files here.' : 'Ziehen Sie die Dateien hier hin',
14+
'File extension error.': 'Dateiendungs Fehler.',
15+
'File size error.': 'Dateigr&ouml;ßen Fehler.',
16+
'Init error.': 'Initialisierungs Fehler.',
17+
'HTTP Error.': 'HTTP Fehler.',
18+
'Security error.': 'Sicherheits Fehler.',
19+
'Generic error.': 'Generic Fehler.',
20+
'IO error.': 'Ein/Ausgabe Fehler.',
21+
'Stop Upload': 'Stoppen des Uploads.',
22+
'Add Files': 'Dateien hinzuf&uuml;gen',
23+
'Start Upload': 'Starten des Uploads.',
24+
'%d files queued': '%d Dateien in der Warteschlange.'
25+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Spanish
2+
plupload.addI18n({
3+
'Select files' : 'Elija archivos:',
4+
'Add files to the upload queue and click the start button.' : 'Agregue archivos a la cola de subida y haga click en el boton de iniciar.',
5+
'Filename' : 'Nombre de archivo',
6+
'Status' : 'Estado',
7+
'Size' : 'Tama&ntilde;o',
8+
'Add files' : 'Agregue archivos',
9+
'Stop current upload' : 'Detener subida actual',
10+
'Start uploading queue' : 'Iniciar subida de cola',
11+
'Uploaded %d/%d files': 'Subidos %d/%d archivos',
12+
'N/A' : 'No disponible',
13+
'Drag files here.' : 'Arrastre archivos aqu&iacute;',
14+
'File extension error.': 'Error de extensi&oacute;n de archivo.',
15+
'File size error.': 'Error de tama&ntilde;o de archivo.',
16+
'Init error.': 'Error de inicializaci&oacute;n.',
17+
'HTTP Error.': 'Error de HTTP.',
18+
'Security error.': 'Error de seguridad.',
19+
'Generic error.': 'Error gen&eacute;rico.',
20+
'IO error.': 'Error de entrada/salida.',
21+
'Stop Upload': 'Detener Subida.',
22+
'Add Files': 'Agregar Archivos',
23+
'Start Upload': 'Comenzar Subida.',
24+
'%d files queued': '%d archivos en cola.'
25+
});
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// .fi file like language pack
2+
plupload.addI18n({
3+
'Select files' : 'Valitse tiedostoja',
4+
'Add files to the upload queue and click the start button.' : 'Lisää tiedostoja latausjonoon ja klikkaa aloita-nappia.',
5+
'Filename' : 'Tiedostonimi',
6+
'Status' : 'Tila',
7+
'Size' : 'Koko',
8+
'Add files' : 'Lisää tiedostoja',
9+
'Stop current upload' : 'Pysäytä nykyinen lataus',
10+
'Start uploading queue' : 'Aloita jonon lataus',
11+
'Drag files here.' : 'Raahaa tiedostot tänne.',
12+
'Start upload' : 'Aloita lataus',
13+
'Uploaded %d/%d files': 'Ladattu %d/%d tiedostoa',
14+
'Stop upload': 'Pysäytä lataus',
15+
'Start upload': 'Aloita lataus',
16+
'%d files queued': '%d tiedostoa jonossa',
17+
'File: %s': 'Tiedosto: %s',
18+
'Close': 'Sulje',
19+
'Using runtime: ': 'Käytetään ajonaikaista: ',
20+
'File: %f, size: %s, max file size: %m': 'Tiedosto: %f, koko: %s, maksimi tiedostokoko: %m',
21+
'Upload element accepts only %d file(s) at a time. Extra files were stripped.': 'Latauselementti sallii ladata vain %d tiedosto(a) kerrallaan. Ylimääräiset tiedostot ohitettiin.',
22+
'Upload URL might be wrong or doesn\'t exist': 'Lataus URL saattaa olla väärin tai ei ole olemassa',
23+
'Error: File too large: ': 'Virhe: Tiedosto liian suuri: ',
24+
'Error: Invalid file extension: ': 'Virhe: Kelpaamaton tiedostopääte: ',
25+
'File extension error.': 'Tiedostopäätevirhe.',
26+
'File size error.': 'Tiedostokokovirhe.',
27+
'File count error.': 'Tiedostolaskentavirhe.',
28+
'Init error.': 'Init virhe.',
29+
'HTTP Error.': 'HTTP virhe.',
30+
'Security error.': 'Tietoturvavirhe.',
31+
'Generic error.': 'Yleinen virhe.',
32+
'IO error.': 'I/O virhe.'
33+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// .po file like language pack
2+
plupload.addI18n({
3+
'Select files' : 'Sélectionnez les fichiers',
4+
'Add files to the upload queue and click the start button.' : 'Ajoutez des fichiers à la file et appuyez sur le bouton démarrer.',
5+
'Filename' : 'Nom de fichier',
6+
'Status' : 'Status',
7+
'Size' : 'Taille',
8+
'Add files' : 'Ajouter Fichiers',
9+
'Stop current upload' : 'Arrêter l\'envoi en cours',
10+
'Start uploading queue' : 'Démarrer l\'envoi',
11+
'Uploaded %d/%d files': '%d/%d fichiers envoyés',
12+
'N/A' : 'Non applicable',
13+
'Drag files here.' : 'Déposer les fichiers ici.',
14+
'File extension error.': 'Erreur extension fichier',
15+
'File size error.': 'Erreur taille fichier.',
16+
'Init error.': 'Erreur d\'initialisation.',
17+
'HTTP Error.': 'Erreur HTTP.',
18+
'Security error.': 'Erreur de sécurité.',
19+
'Generic error.': 'Erreur générique.',
20+
'IO error.': 'Erreur E/S.',
21+
'Stop Upload': 'Arrêter les envois.',
22+
'Add Files': 'Ajouter des fichiers',
23+
'Start Upload': 'Démarrer les envois.',
24+
'%d files queued': '%d fichiers en attente.'
25+
});
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// .po file like language pack
2+
plupload.addI18n({
3+
'Select files' : 'Seleziona i files',
4+
'Add files to the upload queue and click the start button.' : 'Aggiungi i file alla coda di caricamento e clicca il pulsante di avvio.',
5+
'Filename' : 'Nome file',
6+
'Status' : 'Stato',
7+
'Size' : 'Dimensione',
8+
'Add files' : 'Aggiungi file',
9+
'Stop current upload' : 'Interrompi il caricamento',
10+
'Start uploading queue' : 'Avvia il caricamento',
11+
'Uploaded %d/%d files': 'Caricati %d/%d file',
12+
'N/A' : 'N/D',
13+
'Drag files here.' : 'Trascina i file qui.',
14+
'File extension error.': 'Errore estensione file.',
15+
'File size error.': 'Errore dimensione file.',
16+
'Init error.': 'Errore inizializzazione.',
17+
'HTTP Error.': 'Errore HTTP.',
18+
'Security error.': 'Errore sicurezza.',
19+
'Generic error.': 'Errore generico.',
20+
'IO error.': 'Errore IO.'
21+
});
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Japanese
2+
plupload.addI18n({
3+
'Select files' : 'ファイル選択',
4+
'Add files to the upload queue and click the start button.' : 'ファイルをアップロードキューに追加してスタートボタンをクリックしてください',
5+
'Filename' : 'ファイル名',
6+
'Status' : 'ステータス',
7+
'Size' : 'サイズ',
8+
'Add Files' : 'ファイルを追加',
9+
'Stop Upload' : 'アップロード停止',
10+
'Start Upload' : 'アップロード',
11+
'Add files' : 'ファイルを追加',
12+
'Add files.' : 'ファイルを追加',
13+
'Stop current upload' : '現在のアップロードを停止',
14+
'Start uploading queue' : 'アップロード',
15+
'Stop upload' : 'アップロード停止',
16+
'Start upload' : 'アップロード',
17+
'Uploaded %d/%d files': 'アップロード中 %d/%d ファイル',
18+
'N/A' : 'N/A',
19+
'Drag files here.' : 'ここにファイルをドラッグ',
20+
'File extension error.': 'ファイル拡張子エラー',
21+
'File size error.': 'ファイルサイズエラー',
22+
'File count error.': 'ファイル数エラー',
23+
'Init error.': 'イニシャライズエラー',
24+
'HTTP Error.': 'HTTP エラー',
25+
'Security error.': 'セキュリティエラー',
26+
'Generic error.': 'エラー',
27+
'IO error.': 'IO エラー',
28+
'File: %s': 'ファイル: %s',
29+
'Close': '閉じる',
30+
'%d files queued': '%d ファイルが追加されました',
31+
'Using runtime: ': 'モード: ',
32+
'File: %f, size: %s, max file size: %m': 'ファイル: %f, サイズ: %s, 最大ファイルサイズ: %m',
33+
'Upload element accepts only %d file(s) at a time. Extra files were stripped.': 'アップロード可能なファイル数は %d です。余分なファイルは削除されました',
34+
'Upload URL might be wrong or doesn\'t exist': 'アップロード先の URL が存在しません',
35+
'Error: File too large: ': 'エラー: サイズが大きすぎます: ',
36+
'Error: Invalid file extension: ': 'エラー: 拡張子が許可されていません: '
37+
});
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// .lv file like language pack
2+
plupload.addI18n({
3+
'Select files' : 'Izvēlieties failus',
4+
'Add files to the upload queue and click the start button.' : 'Pieveinojiet failus rindai un klikšķiniet uz "Sākt augšupielādi" pogas.',
5+
'Filename' : 'Faila nosaukums',
6+
'Status' : 'Statuss',
7+
'Size' : 'Izmērs',
8+
'Add files' : 'Pievienot failus',
9+
'Stop current upload' : 'Apturēt pašreizējo augšupielādi',
10+
'Start uploading queue' : 'Sākt augšupielādi',
11+
'Drag files here.' : 'Ievelciet failus šeit',
12+
'Start upload' : 'Sākt augšupielādi',
13+
'Uploaded %d/%d files': 'Augšupielādēti %d/%d faili',
14+
'Stop upload': 'Pārtraukt augšupielādi',
15+
'Start upload': 'Sākt augšupielādi',
16+
'%d files queued': '%d faili pievienoti rindai',
17+
'File: %s': 'Fails: %s',
18+
'Close': 'Aizvērt',
19+
'Using runtime: ': 'Lieto saskarni: ',
20+
'File: %f, size: %s, max file size: %m': 'Fails: %f, izmērs: %s, maksimālais faila izmērs: %m',
21+
'Upload element accepts only %d file(s) at a time. Extra files were stripped.': 'Iespējams ielādēt tikai %d failus vienā reizē. Atlikušie faili netika pievienoti',
22+
'Upload URL might be wrong or doesn\'t exist': 'Augšupielādes URL varētu būt nepareizs vai neeksistē',
23+
'Error: File too large: ': 'Kļūda: Fails pārāk liels: ',
24+
'Error: Invalid file extension: ': 'Kļūda: Nekorekts faila paplašinājums:',
25+
'File extension error.': 'Faila paplašinājuma kļūda.',
26+
'File size error.': 'Faila izmēra kļūda.',
27+
'File count error.': 'Failu skaita kļūda',
28+
'Init error.': 'Inicializācijas kļūda.',
29+
'HTTP Error.': 'HTTP kļūda.',
30+
'Security error.': 'Drošības kļūda.',
31+
'Generic error.': 'Vispārēja rakstura kļūda.',
32+
'IO error.': 'Ievades/Izvades kļūda.'
33+
});

0 commit comments

Comments
 (0)