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,166 @@
1
+ var Asset = {};
2
+
3
+ Asset.Upload = Behavior.create({
4
+ onsubmit: function (e) {
5
+ if (e) e.stop();
6
+ var uuid = Asset.GenerateUUID();
7
+ var ulframe = document.createElement('iframe');
8
+ ulframe.setAttribute('name', uuid); // this doesn't work on ie7: will need bodging
9
+ $('upload_holders').insert(ulframe);
10
+
11
+ var form = this.element;
12
+ var title = form.down('input.textbox').value || form.down('input.file').value;
13
+ var placeholder = Asset.AddPlaceholder(title);
14
+
15
+ form.setAttribute('target', uuid);
16
+ ulframe.observe('load', function (e) {
17
+ if (e) e.stop();
18
+ var response = ulframe.contentDocument.body.innerHTML;
19
+ if (response && response != "") {
20
+ placeholder.remove();
21
+ Asset.AddToList(response);
22
+ ulframe.remove();
23
+ }
24
+ });
25
+
26
+ form.submit();
27
+ $('upload_asset').closePopup();
28
+
29
+ // Small delay is required here to let safari assemble the payload
30
+ // form.down('input').clear().defer();
31
+ // form.down('input.file').clear().defer();
32
+ }
33
+ });
34
+
35
+
36
+ // this local attachment method works and is much quicker, but it's fragile and doesn't notice radiant configuration changes
37
+ // better to bounce off the server, provided it can be made responsive enough.
38
+
39
+ // Asset.Attach = Behavior.create({
40
+ // onclick: function (e) {
41
+ // if (e) e.stop();
42
+ // var container = this.element.up('li.asset');
43
+ // container.addClassName('waiting');
44
+ // var title = container.down('div.title').innerHTML;
45
+ // var image = container.down('img');
46
+ // var uuid = Asset.GenerateUUID();
47
+ // var asset_id = this.element.getAttribute('rel').split('_').last();
48
+ // var attachment_field = document.createElement('input');
49
+ // attachment_field.setAttribute('type', 'hidden');
50
+ // attachment_field.setAttribute('id', 'page_page_attachments_attributes_' + uuid + '_asset_id');
51
+ // attachment_field.setAttribute('name', 'page[page_attachments_attributes][' + uuid + '][asset_id]');
52
+ // attachment_field.value = asset_id;
53
+ // var placeholder = Asset.AddPlaceholder(title, image, attachment_field);
54
+ // container.removeClassName('waiting');
55
+ // placeholder.removeClassName('waiting');
56
+ // }
57
+ // });
58
+
59
+
60
+
61
+
62
+
63
+
64
+ Asset.Sortable = Behavior.create({
65
+ initialize: function (e) {
66
+ this.sorter = Asset.MakeSortable(this.element);
67
+ }
68
+ });
69
+
70
+ // Asset-filter and search functions are available wherever the asset_table partial is displayed
71
+
72
+ Asset.SearchForm = Behavior.create({
73
+ initialize: function () {
74
+ this.observer = new Form.Element.Observer(this.element.down('input.search'), 2, Asset.UpdateTable);
75
+ },
76
+ onsubmit: function (e) {
77
+ if (e) e.stop();
78
+ Asset.UpdateTable(true);
79
+ }
80
+ });
81
+
82
+ Asset.MakeSortable = function (element) {
83
+ var sorter = Sortable.create(element, {
84
+ overlap: 'horizontal',
85
+ constraint: false,
86
+ handle: 'back',
87
+ onChange: function (e) {
88
+ Asset.SetPositions();
89
+ Asset.Notify('Assets reordered. Save page to commit changes.');
90
+ }
91
+ });
92
+ element.addClassName('sortable');
93
+ Asset.SetPositions();
94
+ return sorter;
95
+ }
96
+
97
+ Asset.SetPositions = function () {
98
+ $('attachment_fields').select('input.pos').each(function (input, index) {
99
+ input.value = index;
100
+ });
101
+ }
102
+
103
+ // originally taken from phpMyAdmin
104
+ Asset.InsertAtCursor = function(field, insertion) {
105
+ if (document.selection) { // ie
106
+ field.focus();
107
+ var sel = document.selection.createRange();
108
+ sel.text = insertion;
109
+ }
110
+ else if (field.selectionStart || field.selectionStart == '0') { // moz
111
+ var startPos = field.selectionStart;
112
+ var endPos = field.selectionEnd;
113
+ field.value = field.value.substring(0, startPos) + insertion + field.value.substring(endPos, field.value.length);
114
+ field.selectionStart = field.selectionEnd = startPos + insertion.length;
115
+ } else {
116
+ field.value += value;
117
+ }
118
+ }
119
+
120
+ Asset.GenerateUUID = function () {
121
+ // http://www.ietf.org/rfc/rfc4122.txt
122
+ var s = [];
123
+ var hexDigits = "0123456789ABCDEF";
124
+ for (var i = 0; i < 32; i++) { s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1); }
125
+ s[12] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
126
+ s[16] = hexDigits.substr((s[16] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
127
+ return s.join('');
128
+ };
129
+
130
+ Asset.AddPlaceholder = function (title, image, contents) {
131
+ var placeholder = document.createElement('li').addClassName('asset').addClassName('waiting');
132
+ if (contents) placeholder.insert(contents);
133
+ var front = document.createElement('div').addClassName('front');
134
+ if (image) front.insert(document.createElement('div').addClassName('thumbnail').insert(image.clone()));
135
+ placeholder.insert(front);
136
+ if (!title) title = 'please wait';
137
+ var back = document.createElement('div').addClassName('back').insert(document.createElement('div').addClassName('title').update(title));
138
+ placeholder.insert(back);
139
+ $('attachment_fields').insert(placeholder);
140
+ Asset.ShowListIfHidden();
141
+ return placeholder;
142
+ }
143
+
144
+ Asset.AllWaiting = function (container) {
145
+ if (!container) container = $('assets_table');
146
+ container.select('li.asset').each(function (el) { el.addClassName('waiting'); });
147
+ }
148
+
149
+
150
+
151
+ Asset.HideListIfEmpty = function () {
152
+ var list = $('attachment_fields');
153
+ if (!list.down('li.asset:not(.detached)')) {
154
+ list.addClassName('empty');
155
+ // list.slideUp();
156
+ Asset.Notify('All assets detached. Save page to commit changes');
157
+ } else {
158
+ Asset.Notify('Assets detached. Save page to commit changes');
159
+ }
160
+ }
161
+
162
+ Event.addBehavior({
163
+ 'ul#attachment_fields': Asset.Sortable,
164
+ 'form.upload_asset': Asset.Upload,
165
+ 'a.insert_asset': Asset.Insert
166
+ });
@@ -0,0 +1,224 @@
1
+ @import "compass"
2
+
3
+ p.asset
4
+ img.preview
5
+ border: 5px solid white
6
+ +box-shadow
7
+
8
+ .asset_filters
9
+ float: left
10
+ padding: 2px 0
11
+ a
12
+ +border-radius(100px)
13
+ color: #555
14
+ padding: 3px 8px
15
+ text-decoration: none
16
+ font-size: 12px
17
+ &:hover
18
+ background: #ccc
19
+ &.pressed
20
+ background: #888
21
+ +box-shadow(0, 1px, 1px, #333, inset)
22
+ color: white
23
+ text-shadow: 0 1px 0 #333
24
+ &:hover
25
+ background: #888
26
+ +box-shadow(0, 1px, 1px, #333, inset)
27
+ color: white
28
+ text-shadow: 0 1px 0 #333
29
+
30
+ .popup
31
+ div.toolbar
32
+ background: white
33
+ +background-image(linear-gradient(white,#ddd))
34
+ border-bottom: 1px solid #ccc
35
+ +single-box-shadow(white, 0, 1px, 0)
36
+ margin: -20px -20px 0
37
+ padding: 6px 10px 3px 10px
38
+ font-size: 95%
39
+ height: 30px
40
+ +clearfix
41
+ .right
42
+ float: right
43
+ form.search
44
+ padding: 4px 2px 0
45
+ input[type=search]
46
+ font-size: 12px
47
+ +border-radius(100px)
48
+ border: 1px solid #ccc
49
+ border-top-color: #999
50
+ border-left-color: #b0b0b0
51
+ border-right-color: #bbb
52
+ background: white image_url('admin/search.png') 4px center no-repeat
53
+ +box-shadow(rgba(black, 0.2), 0, 1px, 0, inset)
54
+ width: 180px
55
+ padding: 2px 8px 2px 20px
56
+
57
+ #assets_table.assets
58
+ overflow: auto
59
+
60
+
61
+ #upload_holders
62
+ display: none
63
+
64
+ #attach_asset
65
+ .viewport
66
+ overflow-x: hidden
67
+ width: 610px
68
+ height: 310px
69
+
70
+ .attachment_actions
71
+ text-align: right
72
+ margin-bottom: -1em
73
+ ul
74
+ +inline-list
75
+ li
76
+ padding-left: 1em
77
+ a
78
+ color: white !important
79
+ text-shadow: 1px 1px 0 #888
80
+
81
+ .assets
82
+ padding-left: 5px
83
+ padding-right: 5px
84
+ ul
85
+ li.asset
86
+ display: block
87
+ float: left
88
+ margin: 8px 0 0 8px
89
+ width: 110px
90
+ height: 110px
91
+ position: relative
92
+ line-height: 1.2em
93
+ .front, .back
94
+ display: block
95
+ background: #e6eaed
96
+ border: 5px solid white
97
+ position: absolute
98
+ width: 100px
99
+ height: 100px
100
+ text-align: center
101
+ .front
102
+ +box-shadow
103
+ text-align: center
104
+ .back
105
+ color: #333
106
+ overflow: hidden
107
+ +opacity(0)
108
+ .title
109
+ color: #333
110
+ font-size: 10px
111
+ overflow: hidden
112
+ margin: 10px 4px
113
+ height: 15px
114
+ line-height: 15px
115
+ text-overflow: ellipsis
116
+ .icon
117
+ height: 63px
118
+ line-height: 63px
119
+ img
120
+ vertical-align: bottom
121
+ ul.actions
122
+ li
123
+ margin: 5px 0
124
+ padding: 0 10px
125
+ font-size: 10px
126
+ a
127
+ background: #666
128
+ background: rgba(black, 0.8)
129
+ +border-radius
130
+ color: #ddd
131
+ display: block
132
+ padding: 2px 10px
133
+ text-decoration: none
134
+ &:hover
135
+ background: #999
136
+ background: rgba(black, 0.6)
137
+ color: white
138
+ &.unsaved
139
+ .front
140
+ opacity: 0.4
141
+ &:hover
142
+ .back
143
+ +opacity(1)
144
+ background: rgba(white, 0.6)
145
+ &.waiting
146
+ background-color: #E6EAED
147
+ .back
148
+ display: none
149
+ .front
150
+ background: transparent url(/images/admin/spinner.gif) no-repeat center center
151
+ img
152
+ opacity: 0.2
153
+
154
+ #attachment_list.assets
155
+ background: #7e7e7e
156
+ +border-bottom-radius
157
+ margin: -1em 0.5em 1em 0.5em
158
+ overflow-y: hidden
159
+ overflow-x: auto
160
+ ul.empty
161
+ display: none
162
+ p.note
163
+ font-size: 80%
164
+ margin: 0
165
+ padding: 8px
166
+ clear: left
167
+ span.message
168
+ float: right
169
+ color: #aaa
170
+ &.important
171
+ color: #d99
172
+ ul.sortable
173
+ li.asset
174
+ div.back
175
+ cursor: move
176
+
177
+ #assets_table.assets
178
+ position: relative
179
+ font-size: 75%
180
+ p
181
+ padding: 40px
182
+ top: 45px
183
+ color: silver
184
+ text-align: center
185
+ font-style: oblique
186
+ ul
187
+ clear: both
188
+ li.asset
189
+ input
190
+ display: none
191
+ div.pagination
192
+ position: relative
193
+ overflow: hidden
194
+ clear: left
195
+ width: 100%
196
+ height: 3em
197
+ padding: 0.5em 0
198
+ span, a
199
+ display: block
200
+ float: left
201
+ padding: 0.25em
202
+ margin: 1em 2px 1em 0
203
+ +border-radius(2px)
204
+ text-decoration: none
205
+ span.current
206
+ color: #000
207
+ font-weight: bold
208
+ span.disabled
209
+ background-color: #eee
210
+ color: #ccc
211
+ a
212
+ background-color: #eee
213
+ color: #444
214
+ &:hover
215
+ background-color: #c00
216
+ color: #fff
217
+
218
+ span
219
+ color: #888
220
+ span, a
221
+ display: block
222
+ float: left
223
+ padding: 2px 6px
224
+ line-height: 1.5em
File without changes
@@ -0,0 +1,67 @@
1
+ class Admin::AssetsController < Admin::ResourceController
2
+ paginate_models(:per_page => 50)
3
+
4
+ def index
5
+ assets = Asset.scoped({:order => "created_at DESC"})
6
+
7
+ @term = params[:search] || ''
8
+ assets = assets.matching(@term) if @term && !@term.blank?
9
+
10
+ @types = params[:filter] ? params[:filter].split(",") : []
11
+ if @types.include?('all')
12
+ params[:filter] = nil
13
+ elsif @types.any?
14
+ assets = assets.of_types(@types)
15
+ end
16
+
17
+ @assets = paginated? ? assets.paginate(pagination_parameters) : assets.all
18
+ respond_to do |format|
19
+
20
+ format.js {
21
+ @page = Page.find_by_id(params[:page_id])
22
+ render :partial => 'asset_table', :locals => {:with_pagination => true}
23
+ }
24
+ format.html { render }
25
+ end
26
+ end
27
+
28
+ def create
29
+ @assets, @page_attachments = [], []
30
+ params[:asset][:asset].to_a.each do |uploaded_asset|
31
+ @asset = Asset.create(:asset => uploaded_asset, :title => params[:asset][:title], :caption => params[:asset][:caption])
32
+ if params[:for_attachment]
33
+ @page = Page.find_by_id(params[:page_id]) || Page.new
34
+ @page_attachments << @page_attachment = @asset.page_attachments.build(:page => @page)
35
+ end
36
+ @assets << @asset
37
+ end
38
+ if params[:for_attachment]
39
+ render :partial => 'admin/page_attachments/attachment', :collection => @page_attachments
40
+ else
41
+ response_for :create
42
+ end
43
+ end
44
+
45
+ def refresh
46
+ if params[:id]
47
+ @asset = Asset.find(params[:id])
48
+ @asset.asset.reprocess!
49
+ flash[:notice] = t('clipped_extension.thumbnails_refreshed')
50
+ redirect_to edit_admin_asset_path(@asset)
51
+ else
52
+ render
53
+ end
54
+ end
55
+
56
+ only_allow_access_to :regenerate,
57
+ :when => [:admin],
58
+ :denied_url => { :controller => 'admin/assets', :action => 'index' },
59
+ :denied_message => 'You must have admin privileges to refresh the whole asset set.'
60
+
61
+ def regenerate
62
+ Asset.all.each { |asset| asset.asset.reprocess! }
63
+ flash[:notice] = t('clipped_extension.all_thumbnails_refreshed')
64
+ redirect_to admin_assets_path
65
+ end
66
+
67
+ end