trusty-clipped-extension 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. data/LICENSE +22 -0
  2. data/README.md +191 -0
  3. data/Rakefile +109 -0
  4. data/app/assets/flash/ZeroClipboard.swf +0 -0
  5. data/app/assets/images/admin/add.png +0 -0
  6. data/app/assets/images/admin/archive_icon.png +0 -0
  7. data/app/assets/images/admin/audio_icon.png +0 -0
  8. data/app/assets/images/admin/audio_thumbnail.png +0 -0
  9. data/app/assets/images/admin/c_icon.png +0 -0
  10. data/app/assets/images/admin/copy.png +0 -0
  11. data/app/assets/images/admin/css_icon.png +0 -0
  12. data/app/assets/images/admin/database_icon.png +0 -0
  13. data/app/assets/images/admin/delete.png +0 -0
  14. data/app/assets/images/admin/document_icon.png +0 -0
  15. data/app/assets/images/admin/document_thumbnail.png +0 -0
  16. data/app/assets/images/admin/flash_icon.png +0 -0
  17. data/app/assets/images/admin/flash_thumbnail.png +0 -0
  18. data/app/assets/images/admin/font_icon.png +0 -0
  19. data/app/assets/images/admin/gzip_icon.png +0 -0
  20. data/app/assets/images/admin/html_icon.png +0 -0
  21. data/app/assets/images/admin/image_icon.png +0 -0
  22. data/app/assets/images/admin/image_thumbnail.png +0 -0
  23. data/app/assets/images/admin/java_icon.png +0 -0
  24. data/app/assets/images/admin/page_edit.png +0 -0
  25. data/app/assets/images/admin/perl_icon.png +0 -0
  26. data/app/assets/images/admin/php_icon.png +0 -0
  27. data/app/assets/images/admin/presentation_icon.png +0 -0
  28. data/app/assets/images/admin/python_icon.png +0 -0
  29. data/app/assets/images/admin/reorder_assets.png +0 -0
  30. data/app/assets/images/admin/ruby_icon.png +0 -0
  31. data/app/assets/images/admin/script_icon.png +0 -0
  32. data/app/assets/images/admin/spreadsheet_icon.png +0 -0
  33. data/app/assets/images/admin/tar_icon.png +0 -0
  34. data/app/assets/images/admin/unknown_icon.png +0 -0
  35. data/app/assets/images/admin/unknown_thumbnail.png +0 -0
  36. data/app/assets/images/admin/video_icon.png +0 -0
  37. data/app/assets/images/admin/video_thumbnail.png +0 -0
  38. data/app/assets/images/admin/xml_icon.png +0 -0
  39. data/app/assets/images/admin/zip_icon.png +0 -0
  40. data/app/assets/javascripts/admin/assets.js +261 -0
  41. data/app/assets/javascripts/admin/jquery.fileupload.js +1457 -0
  42. data/app/assets/javascripts/admin/jquery.iframe-transport.js +214 -0
  43. data/app/assets/javascripts/admin/jquery.ui.widget.js +558 -0
  44. data/app/assets/javascripts/admin/prototype_assets.js +166 -0
  45. data/app/assets/stylesheets/admin/assets.sass +224 -0
  46. data/app/assets/stylesheets/application.scss +0 -0
  47. data/app/controllers/admin/assets_controller.rb +67 -0
  48. data/app/controllers/admin/page_attachments_controller.rb +18 -0
  49. data/app/helpers/admin/assets_helper.rb +16 -0
  50. data/app/helpers/admin/page_attachments_helper.rb +2 -0
  51. data/app/models/asset.rb +241 -0
  52. data/app/models/asset_type.rb +241 -0
  53. data/app/models/old_page_attachment.rb +26 -0
  54. data/app/models/page_attachment.rb +20 -0
  55. data/app/views/admin/assets/_asset.html.haml +12 -0
  56. data/app/views/admin/assets/_asset_table.html.haml +30 -0
  57. data/app/views/admin/assets/_errors.html.haml +3 -0
  58. data/app/views/admin/assets/_form.html.haml +21 -0
  59. data/app/views/admin/assets/_page_assets.html.haml +12 -0
  60. data/app/views/admin/assets/_search.html.haml +17 -0
  61. data/app/views/admin/assets/_search_results.html.haml +17 -0
  62. data/app/views/admin/assets/edit.html.haml +40 -0
  63. data/app/views/admin/assets/index.html.haml +16 -0
  64. data/app/views/admin/assets/new.html.haml +24 -0
  65. data/app/views/admin/assets/refresh.html.haml +14 -0
  66. data/app/views/admin/assets/remove.html.haml +16 -0
  67. data/app/views/admin/configuration/_clipped_edit.html.haml +8 -0
  68. data/app/views/admin/configuration/_clipped_show.html.haml +12 -0
  69. data/app/views/admin/page_attachments/_attachment.html.haml +25 -0
  70. data/app/views/admin/page_parts/_page_part.html.haml +21 -0
  71. data/app/views/admin/pages/_asset_popups.html.haml +56 -0
  72. data/app/views/admin/pages/_assets.html.haml +14 -0
  73. data/app/views/admin/removed/_assets_bucket.html.haml +8 -0
  74. data/app/views/admin/removed/_assets_container.html.haml +58 -0
  75. data/app/views/admin/removed/_bucket.html.haml +11 -0
  76. data/app/views/admin/removed/_bucket_asset.html.haml +9 -0
  77. data/app/views/admin/removed/_show_bucket_link.html.haml +4 -0
  78. data/app/views/admin/removed/_upload_to_page.html.haml +12 -0
  79. data/app/views/admin/removed/bucket/_iframe.html.haml +1 -0
  80. data/artwork/icons.png +0 -0
  81. data/clipped_extension.rb +53 -0
  82. data/config/initializers/interpolation.rb +6 -0
  83. data/config/initializers/processors.rb +43 -0
  84. data/config/initializers/radiant_config.rb +66 -0
  85. data/config/locales/de.yml +109 -0
  86. data/config/locales/en.yml +110 -0
  87. data/config/locales/nl.yml +107 -0
  88. data/config/locales/ru.yml +110 -0
  89. data/config/routes.rb +17 -0
  90. data/cucumber.yml +1 -0
  91. data/db/migrate/001_create_assets.rb +12 -0
  92. data/db/migrate/002_create_paperclip_attributes.rb +13 -0
  93. data/db/migrate/003_create_user_observer.rb +13 -0
  94. data/db/migrate/004_create_page_attachments.rb +19 -0
  95. data/db/migrate/005_rename_users.rb +13 -0
  96. data/db/migrate/20110513205050_asset_uuid.rb +11 -0
  97. data/db/migrate/20110606111250_update_configuration.rb +34 -0
  98. data/db/migrate/20110609101438_dimensions.rb +13 -0
  99. data/features/support/env.rb +11 -0
  100. data/features/support/paths.rb +22 -0
  101. data/lib/asset_tags.rb +346 -0
  102. data/lib/clipped/engine.rb +5 -0
  103. data/lib/clipped_admin_ui.rb +32 -0
  104. data/lib/cloud.rb +41 -0
  105. data/lib/generators/templates/clipped_config.rb +53 -0
  106. data/lib/page_asset_associations.rb +13 -0
  107. data/lib/paperclip/frame_grab.rb +73 -0
  108. data/lib/paperclip/geometry_transformation.rb +80 -0
  109. data/lib/tasks/clipped_extension_tasks.rake +124 -0
  110. data/lib/tasks/paperclip_tasks.rake +79 -0
  111. data/lib/trusty-clipped-extension.rb +8 -0
  112. data/spec/ci/before_script +23 -0
  113. data/spec/ci/script +2 -0
  114. data/spec/controllers/admin/assets_controller_spec.rb +50 -0
  115. data/spec/controllers/admin/page_attachments_controller_spec.rb +50 -0
  116. data/spec/datasets/assets_dataset.rb +36 -0
  117. data/spec/fixtures/5k.png +0 -0
  118. data/spec/fixtures/test.flv +0 -0
  119. data/spec/lib/asset_tags_spec.rb +107 -0
  120. data/spec/lib/frame_grab_spec.rb +17 -0
  121. data/spec/lib/geometry_transformation_spec.rb +63 -0
  122. data/spec/models/asset_spec.rb +72 -0
  123. data/spec/models/asset_type_spec.rb +70 -0
  124. data/spec/models/post_processing_spec.rb +62 -0
  125. data/spec/spec.opts +7 -0
  126. data/spec/spec_helper.rb +36 -0
  127. data/trusty-clipped-extension.gemspec +29 -0
  128. data/wireframes/edit-page-assets-2.bmml +453 -0
  129. data/wireframes/edit-page-assets-2.png +0 -0
  130. data/wireframes/edit-page-assets-3.bmml +454 -0
  131. data/wireframes/edit-page-assets-3.png +0 -0
  132. data/wireframes/edit-page-assets.bmml +433 -0
  133. data/wireframes/edit-page-assets.png +0 -0
  134. data/wireframes/edit-page.bmml +174 -0
  135. data/wireframes/edit-page.png +0 -0
  136. metadata +265 -0
@@ -0,0 +1,107 @@
1
+ ---
2
+ nl:
3
+ assets: 'Bestanden'
4
+ asset_types:
5
+ all: 'Alle'
6
+ documents: 'Documenten'
7
+ fonts: 'Fonts'
8
+ images: 'Afbeeldingen'
9
+ others: 'Andere'
10
+ audios: 'Audio'
11
+ flashes: 'Flash'
12
+ fonts: 'Fonts'
13
+ videos: 'Video'
14
+ pdfs: 'PDFs'
15
+ swfs: 'Flash'
16
+
17
+ activerecord:
18
+ errors:
19
+ models:
20
+ asset:
21
+ attributes:
22
+ asset:
23
+ blank: 'Er werd geen bestand geselecteerd om te uploaden!'
24
+
25
+ clipped_extension:
26
+ actions: Acties
27
+ all: 'Alle'
28
+ alt_text_or_title: 'Alt-Tekst of Titel <span class="hint">(optioneel)</span>'
29
+ asset: 'Bestand'
30
+ asset_edit_title: 'Bestand aanpassen'
31
+ asset_errors: 'Sorry. {{errors}}'
32
+ asset_page_attachment_note: 'Gekoppelde bestanden. Deze kunnen ingevoegd worden d.m.v. "drag & drop" of met de <code>&lt;r:assets:each /&gt;</code> tag.'
33
+ asset_note: 'Gekoppelde bestanden. '
34
+ assets: 'Bestanden'
35
+ assets_explanation: "Bestanden en afbeeldingen kunnen geüpload worden, en daarna gekoppeld of ingevoegd in pagina's pages, snippets en layouts. Klik op de naam van een bestand om het aan te passen."
36
+ assets_title: 'Bestanden'
37
+ asset_page_upload_note: 'Bestanden die je hier uploadt, zullen automatisch gekoppeld zijn aan deze pagina.'
38
+ asset_upload_note: 'Kies hier een bestand dat je wil uploaden. Als je het <code>Titel</code> veld leeg laat, wordt de naam afgeleid van de bestandsnaam. Klik <code>More</code> om een onderschrift toe te voegen.'
39
+ attached_assets: 'Gekoppelde bestanden'
40
+ attach: 'Koppelen'
41
+ attach_asset: 'Bestand koppelen'
42
+ attach_assets: 'Bestanden koppelen'
43
+ attach_existing: 'Bestaande bestanden koppelen'
44
+ attach_to_page: 'Koppelen aan pagina'
45
+ audio: 'Audio'
46
+ cancel_attachment: 'Ontkoppelen'
47
+ copy: 'Kopieren'
48
+ copy_alt: 'kopieer radius tag naar je klembord'
49
+ choose_file: 'Kies bestand'
50
+ documents: 'Documenten'
51
+ caption: 'Onderschrift'
52
+ confirm_remove_asset: 'Ben je zeker dat je dit bestand <strong class="warning">permanent</strong> wil verwijderen?'
53
+ confirm_remove_from_page: 'Ben je zeker dat je dit bestand wilt ontkoppelen van deze pagina?'
54
+ delete_asset: 'Bestand Verwijderen'
55
+ detach: 'Ontkoppelen'
56
+ edit: 'Aanpassen'
57
+ edit_asset: '{{asset}} aanpassen'
58
+ filename: 'Bestandsnaam'
59
+ find_assets: 'Bestanden zoeken'
60
+ images: 'Afbeeldingen'
61
+ images_automatically_created: 'afbeeldingen worden automatisch gecreëerd'
62
+ insert: 'Invoegen'
63
+ modify: 'Bijwerken'
64
+ movies: 'Filmpjes'
65
+ need_to_upload: 'Een afbeelding uploaden?'
66
+ new_asset: 'Nieuw bestand'
67
+ no_assets_found: 'Er werden geen bestanden gevonden'
68
+ no_assets: 'Geen bestanden'
69
+ no_attached_assets: 'Geen gekoppelde bestanden.'
70
+ others: 'Andere'
71
+ regenerate_all_thumbnails: 'Je kunt hier alle thumbnails opnieuw genereren. Hou er rekening mee dat dit even kan duren, en zeer belastend kan zijn voor de server.'
72
+ regenerate: 'Opnieuw genereren'
73
+ regenerate_thumbnails: 'Thumbnails opnieuw genereren'
74
+ remove_asset: 'Bestand verwijderen'
75
+ remove_from_page: 'Verwijderen van pagina'
76
+ reorder: 'Herschikken'
77
+ remove: 'Verwijderen'
78
+ replace_file: 'Bestand vervangen'
79
+ save_and_upload: 'Opslaan en uploaden'
80
+ search_assets: 'Zoek naar bestanden'
81
+ search: 'Zoek'
82
+ select: 'Selecteer'
83
+ thumbnails_refreshed: "Thumbnails successvol vernieuwd."
84
+ title: 'Titel'
85
+ type: 'Type'
86
+ types_to_find: 'Te doorzoeken types'
87
+ upload: 'Uploaden'
88
+ upload_asset: 'Bestand Uploaden'
89
+
90
+ config:
91
+ assets:
92
+ additional_thumbnails: 'Bijkomende thumbnail types'
93
+ content_types: 'Content Types'
94
+ create_image_thumbnails?: 'Genereer afbeelding thumbnails'
95
+ create_pdf_thumbnails?: 'Genereer PDF thumbnails'
96
+ create_video_thumbnails?: 'Genereer Video thumbnails'
97
+ display_size: 'Display Size'
98
+ insertion_size: 'Insertion Size'
99
+ max_asset_size: 'Max Asset Size'
100
+ path: 'Pad'
101
+ s3:
102
+ bucket: 'Bucket'
103
+ key: 'Key'
104
+ secret: 'Secret'
105
+ skip_filetype_validation: 'Laat alle bestandstypes toe'
106
+ storage: 'Storage'
107
+ url: 'Url'
@@ -0,0 +1,110 @@
1
+ ---
2
+ ru:
3
+ assets: 'Файлы'
4
+ asset_types:
5
+ all: 'Все'
6
+ documents: 'Документы'
7
+ fonts: 'Шрифты'
8
+ images: 'Изображения'
9
+ others: 'Другое'
10
+ audios: 'Аудио'
11
+ flashes: 'Flash'
12
+ fonts: 'Шрифты'
13
+ videos: 'Видео'
14
+ pdfs: 'PDF'
15
+ swfs: 'Flash'
16
+
17
+ activerecord:
18
+ errors:
19
+ models:
20
+ asset:
21
+ attributes:
22
+ asset:
23
+ blank: 'Вы должны выбрать файл для загрузки!'
24
+
25
+ clipped_extension:
26
+ actions: Действия
27
+ all: 'Все'
28
+ all_thumbnails_refreshed: 'Все превью (thumbnails) файлов обновлены.'
29
+ alt_text_or_title: 'Alt-Text или Title <span class="hint">(optional)</span>'
30
+ asset: 'Файл'
31
+ asset_edit_title: 'Редактировать Файл'
32
+ asset_errors: 'Извините. {{errors}}'
33
+ asset_page_attachment_note: 'Прикрепленные файлы. Могут быть вставлены простым перетаскиванием (drag and drop) или показаны с помощью <code>&lt;r:assets:each /&gt;</code> тега.'
34
+ asset_note: 'Прикрепленные файлы. '
35
+ assets: 'Файлы'
36
+ assets_explanation: 'Файлы и изображения могут быть загружены и прикреплены или вставлены в Страницы, Вставки и Макеты. Кликните на названии файла для редактирования или нажмите <code>Remove</code> для удаления.'
37
+ assets_title: 'Файлы'
38
+ asset_page_upload_note: 'Файлы, загруженные здесь, будут автоматически связаны с этой страницей.'
39
+ asset_upload_note: 'Выберите файл для загрузки. Если поле <code>Title</code> будет оставлено пустым, будет автоматически добавлено имя файла (без расширения файла). По нажатию на <code>More</code>, вы также можете добавить заголовок.'
40
+ attached_assets: 'Прикрепленные Файлы'
41
+ attach: 'Файл'
42
+ attach_asset: 'прикрепить файл'
43
+ attach_assets: 'Прикрепить файлы'
44
+ attach_existing: 'Прикрепить Существующие Файлы'
45
+ attach_to_page: 'Прикрепить к странице'
46
+ audio: 'Аудио'
47
+ cancel_attachment: 'Отвязать'
48
+ copy: 'Копировать'
49
+ copy_alt: 'скопировать radius тег в буфер обмена'
50
+ choose_file: 'Выбрать Файл'
51
+ documents: 'Документы'
52
+ caption: 'Заголовок'
53
+ confirm_refresh_assets: 'Вы уверены, что хотите перегенерировать превью (thumbnail) каждого файла? Это может занять длительное время и задействовать ресурсы сервера: <strong class="warning">производительность вашего сайта вероятно пострадает</strong> и ваш браузер может длительное время не отвечать до того, как операция завершится. Эта операция рекомендуется только если ваша коллекция файлов мала!'
54
+ confirm_remove_asset: 'Вы уверены, что хотите <strong class="warning">навсегда удалить</strong> этот файл?'
55
+ confirm_remove_from_page: 'Вы уверены, что хотите удалить эти файлы со страницы?'
56
+ delete_asset: 'Удалить Файл'
57
+ detach: 'Отцепить'
58
+ edit: 'Редактировать'
59
+ edit_asset: 'Редактировать {{asset}}'
60
+ filename: 'Имя файла'
61
+ find_assets: 'Найти Файлы'
62
+ images: 'Изображения'
63
+ images_automatically_created: 'изображения автоматически созданы'
64
+ insert: 'Вставить'
65
+ modify: 'Изменить'
66
+ movies: 'Фильмы'
67
+ need_to_upload: 'Хотите загрузить?'
68
+ new_asset: 'Новый Файл'
69
+ no_assets_found: 'Не найдено ни одного файла'
70
+ no_assets: 'Нет Файлов'
71
+ no_attached_assets: 'Нет прикрепленных файлов.'
72
+ others: 'Другие'
73
+ refresh_assets: 'Перегенерировать все превью'
74
+ regenerate: 'Перегенерировать'
75
+ regenerate_thumbnails: 'Перегенерировать Превью'
76
+ remove_asset: 'Удалить Файл'
77
+ remove_from_page: 'Удалить со страницы'
78
+ reorder: 'Упорядочить'
79
+ remove: 'Удалить'
80
+ refresh_assets_rake_task: 'Для лучшего результата пожалуйста войдите на ваш сервер и запустите <code>rake paperclip:refresh class=Asset</code>.'
81
+ replace_file: 'Заменить Файл'
82
+ save_and_upload: 'Сохранить и Загрузить'
83
+ search_assets: 'Найти файлы'
84
+ search: 'Искать'
85
+ select: 'Выбрать'
86
+ thumbnails_refreshed: "Превью обновлены."
87
+ title: 'Название'
88
+ type: 'Тип'
89
+ types_to_find: 'Типы для поиска'
90
+ upload: 'Загрузить'
91
+ upload_asset: 'Загрузить Файл'
92
+
93
+ config:
94
+ assets:
95
+ additional_thumbnails: 'Дополнительные Превью'
96
+ content_types: 'Content Types'
97
+ create_image_thumbnails?: 'Превью Изображений'
98
+ create_pdf_thumbnails?: 'Превью PDF'
99
+ create_video_thumbnails?: 'Превью Видео'
100
+ display_size: 'Отображаемый Размер'
101
+ insertion_size: 'Размер вставки'
102
+ max_asset_size: 'Максимальный Размер Файла'
103
+ path: 'Путь'
104
+ s3:
105
+ bucket: 'Корзина'
106
+ key: 'Ключ'
107
+ secret: 'Секрет'
108
+ skip_filetype_validation: 'Пропустить валидацию типов файлов'
109
+ storage: 'Хранилище'
110
+ url: 'Url'
data/config/routes.rb ADDED
@@ -0,0 +1,17 @@
1
+ TrustyCms::Application.routes.draw do
2
+ namespace :admin do
3
+ resources :assets do
4
+ get :remove, on: :member
5
+ get :refresh, on: :collection
6
+ post :regenerate, on: :collection
7
+ put :refresh, on: :member
8
+ end
9
+ resources :page_attachments, :only => [:new] do
10
+ get :remove, on: :member
11
+ end
12
+ resources :pages do
13
+ get :remove, on: :member
14
+ resources :page_attachments
15
+ end
16
+ end
17
+ end
data/cucumber.yml ADDED
@@ -0,0 +1 @@
1
+ default: --format progress features --tags ~@proposed,~@in_progress
@@ -0,0 +1,12 @@
1
+ class CreateAssets < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :assets do |t|
4
+ t.string :caption, :title
5
+ end
6
+
7
+ end
8
+
9
+ def self.down
10
+ drop_table :assets
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ class CreatePaperclipAttributes < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :assets, :asset_file_name, :string
4
+ add_column :assets, :asset_content_type, :string
5
+ add_column :assets, :asset_file_size, :integer
6
+ end
7
+
8
+ def self.down
9
+ remove_column :assets, :asset_file_name
10
+ remove_column :assets, :asset_content_type
11
+ remove_column :assets, :asset_file_size
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class CreateUserObserver < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :assets, :created_by, :integer
4
+ add_column :assets, :updated_by, :integer
5
+ add_column :assets, :created_at, :datetime
6
+ add_column :assets, :updated_at, :datetime
7
+ end
8
+
9
+ def self.down
10
+ remove_column :assets, :created_by
11
+ remove_column :assets, :updated_by
12
+ end
13
+ end
@@ -0,0 +1,19 @@
1
+ class CreatePageAttachments < ActiveRecord::Migration
2
+ def self.up
3
+ # See if a page_attachments table from the original 'page_attachments' extension already exists
4
+ # If so, rename the table to old_page_attachments so they can be migrated later
5
+ if self.connection.tables.include?('page_attachments')
6
+ rename_table :page_attachments, :old_page_attachments
7
+ end
8
+ create_table :page_attachments do |t|
9
+ t.column :asset_id, :integer
10
+ t.column :page_id, :integer
11
+ t.column :position, :integer
12
+ end
13
+
14
+ end
15
+
16
+ def self.down
17
+ drop_table :page_attachments
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ class RenameUsers < ActiveRecord::Migration
2
+
3
+ def self.up
4
+ rename_column :assets, :created_by, :created_by_id
5
+ rename_column :assets, :updated_by, :updated_by_id
6
+ end
7
+
8
+ def self.down
9
+ rename_column :assets, :created_by_id, :created_by
10
+ rename_column :assets, :updated_by_id, :updated_by
11
+ end
12
+
13
+ end
@@ -0,0 +1,11 @@
1
+ class AssetUuid < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :assets, :uuid, :string
4
+ Asset.reset_column_information
5
+ Asset.all.each { |a| a.save! } # triggers assign_uuid
6
+ end
7
+
8
+ def self.down
9
+ remove_column :assets, :uuid
10
+ end
11
+ end
@@ -0,0 +1,34 @@
1
+ class UpdateConfiguration < ActiveRecord::Migration
2
+ def self.up
3
+ if TrustyCms.config.table_exists?
4
+
5
+ puts "Importing paperclip configuration"
6
+ %w{url path skip_filetype_validation storage}.select{|k| !!TrustyCms.config["assets.#{k}"] }.each do |k|
7
+ begin
8
+ TrustyCms.config["paperclip.#{k}"] = TrustyCms.config["assets.#{k}"]
9
+ rescue ActiveRecord::RecordInvalid => e
10
+ print "Oops! There was trouble setting #{k} to '#{TrustyCms.config["assets.#{k}"]}'"
11
+ print "\nSetting it to 'fog'. Please see the clipped extension README for more details."
12
+ TrustyCms.config["paperclip.#{k}"] = 'fog'
13
+ end
14
+ end
15
+
16
+ puts "Importing s3 storage configuration"
17
+ %w{bucket key secret host_alias}.select{|k| !!TrustyCms.config["assets.s3.#{k}"] }.each do |k|
18
+ TrustyCms.config["paperclip.s3.#{k}"] = TrustyCms.config["assets.s3.#{k}"]
19
+ end
20
+
21
+ puts "Importing thumbnail configuration"
22
+ if thumbnails = TrustyCms.config["assets.additional_thumbnails"]
23
+ old_styles = thumbnails.to_s.gsub(' ','').split(',').collect{|s| s.split('=')}.inject({}) {|ha, (k, v)| ha[k.to_sym] = v; ha}
24
+ new_styles = old_styles.map {|k,v| "#{k}:size=#{v}"}
25
+ TrustyCms.config["assets.thumbnails.image"] = new_styles.join("|")
26
+ TrustyCms.config["assets.thumbnails.video"] = new_styles.map{|s| "#{s},format=jpg"}.join("|")
27
+ TrustyCms.config["assets.thumbnails.pdf"] = new_styles.map{|s| "#{s},format=jpg"}.join("|")
28
+ end
29
+ end
30
+ end
31
+
32
+ def self.down
33
+ end
34
+ end
@@ -0,0 +1,13 @@
1
+ class Dimensions < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :assets, :original_width, :integer
4
+ add_column :assets, :original_height, :integer
5
+ add_column :assets, :original_extension, :string
6
+ end
7
+
8
+ def self.down
9
+ remove_column :assets, :original_width
10
+ remove_column :assets, :original_height
11
+ remove_column :assets, :original_extension
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ # Sets up the Rails environment for Cucumber
2
+ ENV["RAILS_ENV"] = "test"
3
+ # Extension root
4
+ extension_env = File.expand_path(File.dirname(__FILE__) + '/../../../../../config/environment')
5
+ require extension_env+'.rb'
6
+
7
+ Dir.glob(File.join(RADIANT_ROOT, "features", "**", "*.rb")).each {|step| require step unless step =~ /datasets_loader\.rb$/}
8
+
9
+ Cucumber::Rails::World.class_eval do
10
+ dataset :assets
11
+ end
@@ -0,0 +1,22 @@
1
+ module NavigationHelpers
2
+
3
+ # Extend the standard PathMatchers with your own paths
4
+ # to be used in your features.
5
+ #
6
+ # The keys and values here may be used in your standard web steps
7
+ # Using:
8
+ #
9
+ # When I go to the "assets" admin page
10
+ #
11
+ # would direct the request to the path you provide in the value:
12
+ #
13
+ # admin_assets_path
14
+ #
15
+ PathMatchers = {} unless defined?(PathMatchers)
16
+ PathMatchers.merge!({
17
+ # /assets/i => 'admin_assets_path'
18
+ })
19
+
20
+ end
21
+
22
+ World(NavigationHelpers)
data/lib/asset_tags.rb ADDED
@@ -0,0 +1,346 @@
1
+ module AssetTags
2
+ include TrustyCms::Taggable
3
+ include ActionView::Helpers::TagHelper
4
+ include ActionView::Helpers::AssetTagHelper
5
+
6
+ class TagError < StandardError; end
7
+
8
+ %w{top_padding width height caption asset_file_name asset_content_type asset_file_size id filename image flash thumbnail url link extension if_content_type page:title page:url}.each do |name|
9
+ deprecated_tag "assets:#{name}", :substitute => "asset:#{name}", :deadline => '2.0'
10
+ end
11
+
12
+ desc %{
13
+ The namespace for referencing images and assets.
14
+
15
+ *Usage:*
16
+ <pre><code><r:asset [name="asset name"]>...</r:asset></code></pre>
17
+ }
18
+ tag 'asset' do |tag|
19
+ tag.locals.asset = find_asset(tag, tag.attr) unless tag.attr.empty?
20
+ tag.expand
21
+ end
22
+
23
+ desc %{
24
+ Cycles through all assets attached to the current page.
25
+ This tag does not require the name atttribute, nor do any of its children.
26
+ Use the @limit@ and @offset@ attribute to render a specific number of assets.
27
+ Use @by@ and @order@ attributes to control the order of assets.
28
+ Use @extensions@ attribute to specify which assets to be rendered.
29
+
30
+ *Usage:*
31
+ <pre><code><r:assets:each [limit=0] [offset=0] [order="asc|desc"] [by="position|title|..."] [extensions="png|pdf|doc"]>...</r:assets:each></code></pre>
32
+ }
33
+ tag 'assets' do |tag|
34
+ tag.expand
35
+ end
36
+ tag 'assets:each' do |tag|
37
+ options = tag.attr.dup
38
+ tag.locals.assets = tag.locals.page.assets.scoped(assets_find_options(tag))
39
+ tag.render('asset_list', tag.attr.dup, &tag.block)
40
+ end
41
+
42
+ # General purpose paginated asset lister. Very useful dryness.
43
+ # Tag.locals.assets must be defined but can be empty.
44
+
45
+ tag 'asset_list' do |tag|
46
+ raise TagError, "r:asset_list: no assets to list" unless tag.locals.assets
47
+ options = tag.attr.symbolize_keys
48
+ result = ""
49
+ paging = pagination_find_options(tag)
50
+ assets = paging ? tag.locals.assets.paginate(paging) : tag.locals.assets.all
51
+ assets.each do |asset|
52
+ tag.locals.asset = asset
53
+ result << tag.expand
54
+ end
55
+ if paging && assets.total_pages > 1
56
+ tag.locals.paginated_list = assets
57
+ result << tag.render('pagination', tag.attr.dup)
58
+ end
59
+ result
60
+ end
61
+
62
+ desc %{
63
+ References the first asset attached to the current page.
64
+
65
+ *Usage:*
66
+ <pre><code><r:assets:first>...</r:assets:first></code></pre>
67
+ }
68
+ tag 'assets:first' do |tag|
69
+ if tag.locals.asset = tag.locals.page.assets.first
70
+ tag.expand
71
+ end
72
+ end
73
+
74
+ desc %{
75
+ Renders the contained elements only if the current contextual page has one or
76
+ more assets. The @min_count@ attribute specifies the minimum number of required
77
+ assets. You can also filter by extensions with the @extensions@ attribute.
78
+
79
+ *Usage:*
80
+ <pre><code><r:if_assets [min_count="n"]>...</r:if_assets></code></pre>
81
+ }
82
+ tag 'if_assets' do |tag|
83
+ count = tag.attr['min_count'] && tag.attr['min_count'].to_i || 1
84
+ assets = tag.locals.page.assets.count(:conditions => assets_find_options(tag)[:conditions])
85
+ tag.expand if assets >= count
86
+ end
87
+
88
+ desc %{
89
+ The opposite of @<r:if_assets/>@.
90
+ }
91
+ tag 'unless_assets' do |tag|
92
+ count = tag.attr['min_count'] && tag.attr['min_count'].to_i || 1
93
+ assets = tag.locals.page.assets.count(:conditions => assets_find_options(tag)[:conditions])
94
+ tag.expand unless assets >= count
95
+ end
96
+
97
+ # Resets the page Url and title within the asset tag
98
+ [:title, :url].each do |method|
99
+ tag "asset:page:#{method.to_s}" do |tag|
100
+ tag.locals.page.send(method)
101
+ end
102
+ end
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+ desc %{
111
+ Renders the value for a top padding for a thumbnail. Put the thumbnail in a
112
+ container with specified height and using this tag you can vertically
113
+ align the image within its container.
114
+
115
+ *Usage*:
116
+ <pre><code><r:asset:top_padding container = "140" [size="icon"]/></code></pre>
117
+
118
+ *Working Example*:
119
+ <pre><code>
120
+ <ul>
121
+ <r:asset:each>
122
+ <li style="height:140px">
123
+ <img style="padding-top:<r:top_padding size='category' container='140' />px"
124
+ src="<r:url />" alt="<r:title />" />
125
+ </li>
126
+ </r:asset:each>
127
+ </ul>
128
+ </code></pre>
129
+ }
130
+ tag 'asset:top_padding' do |tag|
131
+ asset, options = asset_and_options(tag)
132
+ raise TagError, "'container' attribute required" unless options['container']
133
+ size = options['size'] ? options.delete('size') : 'icon'
134
+ raise TagError, "asset #{tag.locals.asset.title} has no '#{size}' thumbnail" unless tag.locals.asset.has_style?(size)
135
+ container = options.delete('container')
136
+ ((container.to_i - asset.height(size).to_i)/2).to_s
137
+ end
138
+
139
+ ['height','width'].each do |dimension|
140
+ desc %{
141
+ Renders the #{dimension} of the asset.
142
+ }
143
+ tag "asset:#{dimension}" do |tag|
144
+ asset, options = asset_and_options(tag)
145
+ unless asset.dimensions_known?
146
+ raise TagError, "Can't determine #{dimension} for this Asset. It may not be a supported type."
147
+ end
148
+ size = options['size'] ? options.delete('size') : 'original'
149
+ asset.send(dimension, size)
150
+ end
151
+ end
152
+
153
+ desc %{
154
+ Returns a string representing the orientation of the asset, which must be imageable.
155
+ (ie, it is an image or it has been processed to produce an image).
156
+ Can be 'horizontal', 'vertical' or 'square'.
157
+ }
158
+ tag 'asset:orientation' do |tag|
159
+ asset, options = asset_and_options(tag)
160
+ size = options['size'] ? options.delete('size') : 'original'
161
+ raise TagError, "asset #{tag.locals.asset.title} has no '#{size}' thumbnail" unless tag.locals.asset.has_style?(size)
162
+ asset.orientation(size)
163
+ end
164
+
165
+ desc %{
166
+ Returns the aspect ratio of the asset, which must be an image.
167
+ }
168
+ tag 'asset:aspect' do |tag|
169
+ asset, options = asset_and_options(tag)
170
+ size = options['size'] ? options.delete('size') : 'original'
171
+ raise TagError, "asset #{tag.locals.asset.title} has no '#{size}' thumbnail" unless tag.locals.asset.has_style?(size)
172
+ asset.aspect(size)
173
+ end
174
+
175
+ desc %{
176
+ Renders the containing elements only if the asset's content type matches
177
+ the regular expression given in the @matches@ attribute. If the
178
+ @ignore_case@ attribute is set to false, the match is case sensitive. By
179
+ default, @ignore_case@ is set to true.
180
+
181
+ The @name@ or @id@ attribute is required on the parent tag unless this tag is used in @asset:each@.
182
+
183
+ *Usage:*
184
+ <pre><code><r:asset:each><r:if_content_type matches="regexp" [ignore_case=true|false"]>...</r:if_content_type></r:asset:each></code></pre>
185
+ }
186
+ tag 'asset:if_content_type' do |tag|
187
+ options = tag.attr.dup
188
+ # XXX build_regexp_for comes from StandardTags
189
+ regexp = build_regexp_for(tag,options)
190
+ asset_content_type = tag.locals.asset.asset_content_type
191
+ tag.expand unless asset_content_type.match(regexp).nil?
192
+ end
193
+
194
+ #TODO: could use better docs for Asset#other? case explaining what types it covers
195
+
196
+ [:title, :caption, :asset_file_name, :extension, :asset_content_type, :asset_file_size, :id].each do |method|
197
+ desc %{
198
+ Renders the @#{method.to_s}@ attribute of the asset
199
+ }
200
+ tag "asset:#{method.to_s}" do |tag|
201
+ asset, options = asset_and_options(tag)
202
+ asset.send(method) rescue nil
203
+ end
204
+ end
205
+
206
+ tag 'asset:name' do |tag|
207
+ tag.render('asset:title', tag.attr.dup)
208
+ end
209
+
210
+ tag 'asset:filename' do |tag|
211
+ asset, options = asset_and_options(tag)
212
+ asset.asset_file_name rescue nil
213
+ end
214
+
215
+ desc %{
216
+ Renders an image tag for the asset.
217
+
218
+ Using the optional @size@ attribute, different sizes can be display.
219
+ "thumbnail" and "icon" sizes are built in, but custom ones can be set
220
+ by changing `assets.thumbnails.[type]` in the TrustyCms::Config settings.
221
+
222
+ *Usage:*
223
+ <pre><code><r:asset:image [name="asset name" or id="asset id"] [size="icon|thumbnail|whatever"]></code></pre>
224
+ }
225
+ tag 'asset:image' do |tag|
226
+ tag.locals.asset, options = asset_and_options(tag)
227
+ size = options.delete('size') || 'original'
228
+ raise TagError, "asset #{tag.locals.asset.title} has no '#{size}' thumbnail" unless tag.locals.asset.has_style?(size)
229
+ options['alt'] ||= tag.locals.asset.title
230
+ url = tag.locals.asset.thumbnail(size)
231
+ ActionController::Base.helpers.image_tag(url, options)
232
+ end
233
+
234
+ desc %{
235
+ Embeds a flash-movie in a cross-browser-compatible fashion using only HTML
236
+ If no width and height attributes are given it will use the intrinsic
237
+ dimensions of the swf file
238
+
239
+ *Usage:*
240
+ <pre><code><r:asset:flash [name="asset name" or id="asset id"] [width="100"] [height="100"]>Fallback content</flash></code></pre>
241
+
242
+ *Example with text fallback:*
243
+ <pre><code><r:asset:flash name="flash_movie">
244
+ Sorry, you need to have flash installed, <a href="http://adobe.com/flash">get it here</a>
245
+ </flash></code></pre>
246
+
247
+ *Example with image fallback and explicit dimensions:*
248
+ <pre><code><r:asset:flash name="flash_movie" width="300" height="200">
249
+ <r:asset:image name="flash_screenshot" />
250
+ </flash></code></pre>
251
+ }
252
+ tag 'asset:flash' do |tag|
253
+ asset, options = asset_and_options(tag)
254
+ if tag.locals.asset.flash?
255
+ url = asset.thumbnail('original')
256
+ dimensions = [(tag.attr['width'] || asset.width),(tag.attr['height'] || asset.height)]
257
+ swf_embed_markup url, dimensions, tag.expand
258
+ end
259
+ end
260
+
261
+ desc %{
262
+ Renders the url for the asset. If the asset is an image, the <code>size</code> attribute can be used to
263
+ generate the url for that size.
264
+
265
+ *Usage:*
266
+ <pre><code><r:url [name="asset name" or id="asset id"] [size="icon|thumbnail"]></code></pre>
267
+ }
268
+ tag 'asset:url' do |tag|
269
+ asset, options = asset_and_options(tag)
270
+ size = options['size'] ? options.delete('size') : 'original'
271
+ asset.thumbnail(size) rescue nil
272
+ end
273
+
274
+ desc %{
275
+ Renders a link to the asset. If the asset is an image, the <code>size</code> attribute can be used to
276
+ generate a link to that size.
277
+
278
+ *Usage:*
279
+ <pre><code><r:asset:link [name="asset name" or id="asset id"] [size="icon|thumbnail"] /></code></pre>
280
+ }
281
+ tag 'asset:link' do |tag|
282
+ asset, options = asset_and_options(tag)
283
+ size = options['size'] ? options.delete('size') : 'original'
284
+ text = options['text'] || asset.title
285
+ anchor = options['anchor'] ? "##{options.delete('anchor')}" : ''
286
+ attributes = options.inject('') { |s, (k, v)| s << %{#{k.downcase}="#{v}" } }.strip
287
+ attributes = " #{attributes}" unless attributes.empty?
288
+ text = tag.double? ? tag.expand : text
289
+ url = asset.thumbnail(size)
290
+ %{<a href="#{url }#{anchor}"#{attributes}>#{text}</a>} rescue nil
291
+ end
292
+
293
+ private
294
+ def asset_and_options(tag)
295
+ options = tag.attr.dup
296
+ [find_asset(tag, options), options]
297
+ end
298
+
299
+ def find_asset(tag, options)
300
+ tag.locals.asset ||= if title = (options.delete('name') || options.delete('title'))
301
+ Asset.find_by_title(title)
302
+ elsif id = options.delete('id')
303
+ Asset.find_by_id(id)
304
+ end
305
+ tag.locals.asset || raise(TagError, "Asset not found.")
306
+ end
307
+
308
+ def assets_find_options(tag)
309
+ attr = tag.attr.symbolize_keys
310
+ extensions = attr[:extensions] && attr[:extensions].split('|') || []
311
+ conditions = unless extensions.blank?
312
+ # this is soon to be removed in favour of asset types
313
+ [ extensions.map { |ext| "assets.asset_file_name LIKE ?"}.join(' OR '),
314
+ *extensions.map { |ext| "%.#{ext}" } ]
315
+ else
316
+ nil
317
+ end
318
+
319
+ by = attr[:by] || 'page_attachments.position'
320
+ order = attr[:order] || 'asc'
321
+
322
+ options = {
323
+ :order => "#{by} #{order}",
324
+ :limit => attr[:limit] || nil,
325
+ :offset => attr[:offset] || nil,
326
+ :conditions => conditions
327
+ }
328
+ end
329
+
330
+ def swf_embed_markup(url, dimensions, fallback_content)
331
+ width, height = dimensions
332
+ %{<!--[if !IE]> -->
333
+ <object type="application/x-shockwave-flash" data="#{url}" width="#{width}" height="#{height}">
334
+ <!-- <![endif]-->
335
+ <!--[if IE]>
336
+ <object width="#{width}" height="#{height}"
337
+ classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
338
+ codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0">
339
+ <param name="movie" value="#{url}" />
340
+ <!-->
341
+ #{fallback_content}
342
+ </object>
343
+ <!-- <![endif]-->}
344
+ end
345
+ end
346
+