Permalink
Browse files

Added multi-storage (AWS/S3) functionality to attachments

  • Loading branch information...
1 parent 089ec8e commit b164a101261ae03572321128da49703ba483e311 Dimitrij Denissenko committed Dec 6, 2009
Showing with 500 additions and 248 deletions.
  1. +2 −0 .gems
  2. +1 −1 app/controllers/tickets_controller.rb
  3. +1 −1 extensions/retro_wiki/lib/wiki_files_controller.rb
  4. +1 −0 lib/retrospectiva/configuration_manager.rb
  5. +7 −0 lib/retrospectiva/configuration_manager/core_ext.rb
  6. +0 −9 locales/app/de-DE.yml
  7. +0 −9 locales/app/en-GB.yml
  8. +0 −9 locales/app/es-AR.yml
  9. +0 −9 locales/app/es-ES.yml
  10. +0 −9 locales/app/fr-FR.yml
  11. +0 −9 locales/app/ja-JP.yml
  12. +0 −9 locales/app/pt-BR.yml
  13. +0 −9 locales/app/ru-RU.yml
  14. +3 −0 locales/system/de-DE.yml
  15. +3 −0 locales/system/en-GB.yml
  16. +3 −1 locales/system/en-US.yml
  17. +3 −0 locales/system/es-AR.yml
  18. +3 −0 locales/system/es-ES.yml
  19. +3 −0 locales/system/fr-FR.yml
  20. +8 −0 locales/system/ja-JP.yml
  21. +3 −0 locales/system/pt-BR.yml
  22. +7 −0 locales/system/ru-RU.yml
  23. +10 −0 spec/models/attachment_spec.rb
  24. +1 −1 spec/support/defaults/attachments.rb
  25. +9 −0 vendor/plugins/has_attachment/Rakefile
  26. +0 −5 vendor/plugins/has_attachment/init.rb
  27. +50 −55 vendor/plugins/has_attachment/lib/attachment.rb
  28. +8 −1 vendor/plugins/has_attachment/lib/has_attachment.rb
  29. +116 −0 vendor/plugins/has_attachment/lib/has_attachment/storage.rb
  30. +52 −103 vendor/plugins/has_attachment/spec/attachment_spec.rb
  31. +45 −0 vendor/plugins/has_attachment/spec/default.rb
  32. +97 −0 vendor/plugins/has_attachment/spec/file_system_spec.rb
  33. +51 −0 vendor/plugins/has_attachment/spec/s3_spec.rb
  34. +13 −8 vendor/plugins/has_attachment/spec/spec_helper.rb
View
@@ -1,3 +1,5 @@
will_paginate --version '>= 2.3.8'
acts-as-taggable-on --version '>= 1.0.3'
RedCloth --version '>= 4.1.9'
+aws-s3 --version '>= 0.6.2'
+xml-simple --version '>= 1.0.12'
@@ -118,7 +118,7 @@ def update
end
def download
- send_file *@attachment.send_arguments
+ @attachment.redirect? ? redirect_to(@attachment.redirect) : send_file(*@attachment.send_arguments)
end
def toggle_subscription
@@ -26,7 +26,7 @@ def index
end
def show
- send_file *@wiki_file.send_arguments
+ @wiki_file.redirect? ? redirect_to(@wiki_file.redirect) : send_file(*@wiki_file.send_arguments)
end
def new
@@ -1,6 +1,7 @@
require 'retrospectiva/configuration_manager/exceptions'
require 'retrospectiva/configuration_manager/configuration'
require 'retrospectiva/configuration_manager/units'
+require 'retrospectiva/configuration_manager/core_ext'
module Retrospectiva
module ConfigurationManager
@@ -0,0 +1,7 @@
+Attachment.class_eval do
+ class << self
+ def max_size
+ RetroCM[:general][:attachments][:max_size].to_i.kilobytes
+ end
+ end
+end
@@ -435,9 +435,6 @@ de-DE:
# app/views/browse/show_binary.html.erb
"File content cannot be displayed for binary files.": "Inhalte von Binärdateien können nicht angezeigt werden."
- # vendor/plugins/has_attachment/lib/attachment.rb
- "File size exceeds the maximum limit": "Dateigröße überschreitet das obere Limit."
-
# app/views/tickets/index.html.erb
"Filter tickets": "Tickets filtern"
@@ -536,9 +533,6 @@ de-DE:
# app/views/admin/tasks/index.html.erb
Interval: Interval
- # vendor/plugins/has_attachment/lib/attachment.rb
- "Invalid file size": "Ungültige Dateigröße"
-
# app/views/browse/diff.html.erb
"Invalid or empty DIFF": "Ungültiger oder leerer DIFF"
@@ -1152,9 +1146,6 @@ de-DE:
# app/helpers/changesets_helper.rb
Updated: Aktualisiert
- # vendor/plugins/has_attachment/lib/attachment.rb
- "Upload is not permitted": "Datei-Upload ist nicht gestattet"
-
# app/views/admin/users/index.html.erb
User: Benutzer
@@ -435,9 +435,6 @@ en-GB:
# app/views/browse/show_binary.html.erb
"File content cannot be displayed for binary files.": "File content cannot be displayed for binary files."
- # vendor/plugins/has_attachment/lib/attachment.rb
- "File size exceeds the maximum limit": "File size exceeds the maximum limit"
-
# app/views/tickets/index.html.erb
"Filter tickets": "Filter tickets"
@@ -536,9 +533,6 @@ en-GB:
# app/views/admin/tasks/index.html.erb
Interval: Interval
- # vendor/plugins/has_attachment/lib/attachment.rb
- "Invalid file size": "Invalid file size"
-
# app/views/browse/diff.html.erb
"Invalid or empty DIFF": "Invalid or empty DIFF"
@@ -1152,9 +1146,6 @@ en-GB:
# app/helpers/changesets_helper.rb
Updated: Updated
- # vendor/plugins/has_attachment/lib/attachment.rb
- "Upload is not permitted": "Upload is not permitted"
-
# app/views/admin/users/index.html.erb
User: User
@@ -435,9 +435,6 @@ es-AR:
# app/views/browse/show_binary.html.erb
"File content cannot be displayed for binary files.": "El archivo no puede ser mostrado para archivos binarios."
- # vendor/plugins/has_attachment/lib/attachment.rb
- "File size exceeds the maximum limit": "El tamaño del archivo excede el límite máximo"
-
# app/views/tickets/index.html.erb
"Filter tickets": "Filtrar tickets"
@@ -536,9 +533,6 @@ es-AR:
# app/views/admin/tasks/index.html.erb
Interval: Intervalo
- # vendor/plugins/has_attachment/lib/attachment.rb
- "Invalid file size": "Tamaño de archivo inválido"
-
# app/views/browse/diff.html.erb
"Invalid or empty DIFF": "DIFF invalido o vacio"
@@ -1155,9 +1149,6 @@ es-AR:
# app/helpers/changesets_helper.rb
Updated: Actualizado
- # vendor/plugins/has_attachment/lib/attachment.rb
- "Upload is not permitted": "No está peritido subir"
-
# app/views/admin/users/index.html.erb
User: Usuario
@@ -435,9 +435,6 @@ es-ES:
# app/views/browse/show_binary.html.erb
"File content cannot be displayed for binary files.": "El archivo no puede ser mostrado para archivos binarios."
- # vendor/plugins/has_attachment/lib/attachment.rb
- "File size exceeds the maximum limit": "El tamaño del archivo excede el límite máximo"
-
# app/views/tickets/index.html.erb
"Filter tickets": "Filtrar tickets"
@@ -536,9 +533,6 @@ es-ES:
# app/views/admin/tasks/index.html.erb
Interval: Intervalo
- # vendor/plugins/has_attachment/lib/attachment.rb
- "Invalid file size": "Tamaño de archivo inválido"
-
# app/views/browse/diff.html.erb
"Invalid or empty DIFF": "DIFF invalido o vacio"
@@ -1155,9 +1149,6 @@ es-ES:
# app/helpers/changesets_helper.rb
Updated: Actualizado
- # vendor/plugins/has_attachment/lib/attachment.rb
- "Upload is not permitted": "No está peritido subir"
-
# app/views/admin/users/index.html.erb
User: Usuario
@@ -438,9 +438,6 @@ fr-FR:
# app/views/browse/show_binary.html.erb
"File content cannot be displayed for binary files.": "Le contenu des fichiers ne peut pas être affiché pour les fichiers binaires."
- # vendor/plugins/has_attachment/lib/attachment.rb
- "File size exceeds the maximum limit": "La taille du fichier dépasse la limite maximale"
-
# app/views/tickets/index.html.erb
"Filter tickets": "Filtrer les tickets"
@@ -542,9 +539,6 @@ fr-FR:
# app/views/admin/tasks/index.html.erb
Interval: Intervalle
- # vendor/plugins/has_attachment/lib/attachment.rb
- "Invalid file size": "Taille de fichier invalide"
-
# app/views/browse/diff.html.erb
"Invalid or empty DIFF": "Diff invalide ou vide"
@@ -1161,9 +1155,6 @@ fr-FR:
# app/helpers/changesets_helper.rb
Updated: "Mis à jour"
- # vendor/plugins/has_attachment/lib/attachment.rb
- "Upload is not permitted": "L'upload n'est pas autorisé"
-
# app/views/admin/users/index.html.erb
User: Utilisateur
@@ -438,9 +438,6 @@ ja-JP:
# app/views/browse/show_binary.html.erb
"File content cannot be displayed for binary files.": バイナリファイルの中身を表示することはできません。
- # vendor/plugins/has_attachment/lib/attachment.rb
- "File size exceeds the maximum limit": ファイルサイズが制限を越えました。
-
# app/views/tickets/index.html.erb
"Filter tickets": チケットを抽出
@@ -539,9 +536,6 @@ ja-JP:
# app/views/admin/tasks/index.html.erb
Interval: 間隔
- # vendor/plugins/has_attachment/lib/attachment.rb
- "Invalid file size": 不正なファイルサイズ
-
# app/views/browse/diff.html.erb
"Invalid or empty DIFF": 不正な差分あるいは差分がありません
@@ -1160,9 +1154,6 @@ ja-JP:
# app/helpers/changesets_helper.rb
Updated: 更新
- # vendor/plugins/has_attachment/lib/attachment.rb
- "Upload is not permitted": アップロードは許可されていません
-
# app/views/admin/users/index.html.erb
User: ユーザ
@@ -435,9 +435,6 @@ pt-BR:
# app/views/browse/show_binary.html.erb
"File content cannot be displayed for binary files.": "Conteúdo do arquivo não pode ser exibido para arquivos binários."
- # vendor/plugins/has_attachment/lib/attachment.rb
- "File size exceeds the maximum limit": "Tamanho do arquivo excede o limite máximo"
-
# app/views/tickets/index.html.erb
"Filter tickets": "Filtrar tarefas"
@@ -536,9 +533,6 @@ pt-BR:
# app/views/admin/tasks/index.html.erb
Interval: Intervalo
- # vendor/plugins/has_attachment/lib/attachment.rb
- "Invalid file size": "Tamanho de arquivo inválido"
-
# app/views/browse/diff.html.erb
"Invalid or empty DIFF": "DIFF inválido ou vazio"
@@ -1152,9 +1146,6 @@ pt-BR:
# app/helpers/changesets_helper.rb
Updated: Atualizado
- # vendor/plugins/has_attachment/lib/attachment.rb
- "Upload is not permitted": "Upload não é permitido"
-
# app/views/admin/users/index.html.erb
User: Usuário
@@ -436,9 +436,6 @@ ru-RU:
# app/views/browse/show_binary.html.erb
"File content cannot be displayed for binary files.": "Двоичные файлы не отображаются."
- # vendor/plugins/has_attachment/lib/attachment.rb
- "File size exceeds the maximum limit": "Превышен максимально допустимы размер"
-
# app/views/tickets/index.html.erb
"Filter tickets": "Использовать фильтр"
@@ -537,9 +534,6 @@ ru-RU:
# app/views/admin/tasks/index.html.erb
Interval: Интервал
- # vendor/plugins/has_attachment/lib/attachment.rb
- "Invalid file size": "Некорректный размер файла"
-
# app/views/browse/diff.html.erb
"Invalid or empty DIFF": "Некорректная или пустая разница"
@@ -1156,9 +1150,6 @@ ru-RU:
# app/helpers/changesets_helper.rb
Updated: Обновлен
- # vendor/plugins/has_attachment/lib/attachment.rb
- "Upload is not permitted": "Загрузки не разрешены"
-
# app/views/admin/users/index.html.erb
User: Пользователь
@@ -5,6 +5,9 @@ de-DE:
cannot_be_selected: kann nicht ausgewählt werden
cannot_be_disabled: kann nicht ausgeschaltet werden
must_be_specified: muss angegeben sein
+ file_size_exceeds_limit: "Dateigröße überschreitet das obere Limit"
+ invalid_file_size: "Ungültige Dateigröße"
+ upload_not_permitted: "Datei-Upload ist nicht gestattet"
models:
project:
attributes:
@@ -5,6 +5,9 @@ en-GB:
cannot_be_selected: cannot be selected
cannot_be_disabled: cannot be disabled
must_be_specified: must be specified
+ file_size_exceeds_limit: File size exceeds the maximum limit
+ invalid_file_size: Invalid file size
+ upload_not_permitted: Upload is not permitted
models:
project:
attributes:
@@ -5,6 +5,9 @@ en-US:
cannot_be_selected: cannot be selected
cannot_be_disabled: cannot be disabled
must_be_specified: must be specified
+ file_size_exceeds_limit: File size exceeds the maximum limit
+ invalid_file_size: Invalid file size
+ upload_not_permitted: Upload is not permitted
models:
project:
attributes:
@@ -36,4 +39,3 @@ en-US:
attributes:
name:
invalid: "may only contain one or many capitalized words. Examples: 'Component', 'Release Name'"
-
@@ -5,6 +5,9 @@ es-AR:
cannot_be_selected: no puede ser seleccionado
cannot_be_disabled: no puede ser deshabilitado
must_be_specified: debe ser especificado
+ file_size_exceeds_limit: "El tamaño del archivo excede el límite máximo"
+ invalid_file_size: "Tamaño de archivo inválido"
+ upload_not_permitted: "No está peritido subir"
models:
project:
attributes:
@@ -5,6 +5,9 @@ es-ES:
cannot_be_selected: no puede ser seleccionado
cannot_be_disabled: no puede ser deshabilitado
must_be_specified: debe ser especificado
+ file_size_exceeds_limit: "El tamaño del archivo excede el límite máximo"
+ invalid_file_size: "Tamaño de archivo inválido"
+ upload_not_permitted: "No está peritido subir"
models:
project:
attributes:
@@ -5,6 +5,9 @@ fr-FR:
cannot_be_selected: ne peut être sélectionné
cannot_be_disabled: ne peut être désactivé
must_be_specified: doit être spécifié
+ file_size_exceeds_limit: "La taille du fichier dépasse la limite maximale"
+ invalid_file_size: "Taille de fichier invalide"
+ upload_not_permitted: "L'upload n'est pas autorisé"
models:
project:
attributes:
@@ -0,0 +1,8 @@
+ja-JP:
+ activerecord:
+ errors:
+ messages:
+ file_size_exceeds_limit: ファイルサイズが制限を越えました。
+ invalid_file_size: 不正なファイルサイズ
+ upload_not_permitted: アップロードは許可されていません
+
@@ -5,6 +5,9 @@ pt-BR:
cannot_be_selected: não pode ser selecionado
cannot_be_disabled: não pode ser desabilitado
must_be_specified: deve ser especificado
+ file_size_exceeds_limit: "Tamanho do arquivo excede o limite máximo"
+ invalid_file_size: "Tamanho de arquivo inválido"
+ upload_not_permitted: "Upload não é permitido"
models:
project:
attributes:
@@ -0,0 +1,7 @@
+ru-RU:
+ activerecord:
+ errors:
+ messages:
+ file_size_exceeds_limit: "Превышен максимально допустимы размер"
+ invalid_file_size: "Некорректный размер файла"
+ upload_not_permitted: "Загрузки не разрешены"
@@ -0,0 +1,10 @@
+require 'spec_helper'
+
+describe Attachment do
+
+ it 'should use the RetroCM setting to determine the maximum file size' do
+ RetroCM[:general][:attachments].should_receive(:[]).with(:max_size).and_return(4096)
+ Attachment.max_size.should == 4096.kilobytes
+ end
+
+end
@@ -1 +1 @@
-Attachment.storage_path = '/dev/null'
+Attachment.storage = { :type => :file_system, :path => '/dev/null' }
Oops, something went wrong.

0 comments on commit b164a10

Please sign in to comment.