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
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ == MIT License
2
+
3
+ Copyright (c) 2011 Keith Bingman, Benny Degezelle, William Ross, and John W. Long
4
+ Copyright (c) 2008-2010, Keith Bingman
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,191 @@
1
+ # TrustyCms Clipped Extension
2
+
3
+ [![Build Status](https://secure.travis-ci.org/radiant/radiant-clipped-extension.png)](http://travis-ci.org/radiant/radiant-clipped-extension)
4
+
5
+ Asset management for TrustyCms CMS.
6
+
7
+ The Clipped extension comes bundled with the TrustyCms gem but may be updated separately. Only TrustyCms versions 1.0 or newer are supported.
8
+
9
+ Please file bugs and feature requests on [Github][issues]. If you have questions regarding usage ask on the [mailing list][mailing-list].
10
+
11
+ [issues]: https://github.com/pgharts/trusty-clipped-extension/issues
12
+
13
+ ## Features
14
+
15
+ * Concurrent uploads
16
+ * Automatic thumbnail generation
17
+ * requires ImageMagick for images
18
+ * requires FFmpeg for videos
19
+ * requires Ghostscript for PDFs
20
+ * In-page and dedicated management interfaces
21
+ * Easily to extended with new asset types and processors
22
+
23
+ ## Installation
24
+
25
+ If you installed the TrustyCms gem then you already have Clipped installed. You can upgrade to a newer version using `bundle update trusty-clipped-extension`.
26
+
27
+ Installation of the optional post-processors varies by system but are likely available through your package manager.
28
+
29
+ ### Mac OSX
30
+
31
+ brew install ghostscript imagemagick ffmpeg
32
+ # or
33
+ port install ghostscript imagemagick ffmpeg
34
+
35
+ ### Debian
36
+
37
+ apt-get install ghostscript imagemagick ffmpeg
38
+
39
+ ### Windows
40
+
41
+ [Ghostscript][ghostscript], [ImageMagick][imagemagick] and [FFmpeg][ffmpeg] all
42
+ offer Windows installers that you can install in the usual way.
43
+
44
+ [ghostscript]: http://sourceforge.net/projects/ghostscript/
45
+ [imagemagick]: http://www.imagemagick.org/script/binary-releases.php
46
+ [ffmpeg]: http://ffmpeg.zeranoe.com/builds/
47
+
48
+ If the post-processors are not in your `PATH` or you're running Passenger you might need to set `Paperclip.options[:command_path]` to the location where the binaries are installed.
49
+
50
+ ## Configuration
51
+
52
+ The clipped extension is configured in the usual way, but only its minor settings are exposed in the admin interface. The more architectural settings shouldn't be changed at runtime and some of them will require a lot of sorting out if they're changed at all, so those are only accessible through the console or by editing the database. Eventually they will be made part of the initial trusty-cms installation process.
53
+
54
+ ### Structural settings
55
+
56
+ * `paperclip.url` sets the url scheme for attached files. Paperclip interpolations are applied. You probably don't want to change this.
57
+ * `paperclip.path` sets the path scheme for attached files. Paperclip interpolations are applied. You might conceivably want to change this.
58
+ * `paperclip.storage` can be 'filesystem' (the default) or 'fog' for cloud storage (such as s3).
59
+ * `paperclip.skip_filetype_validation` is true by default and allows uploads of any mime type.
60
+
61
+ ### Cloud Storage
62
+
63
+ Set `paperclip.storage` to 'fog' and add the following line to your `Gemfile`
64
+
65
+ `gem "fog", "~> 1.0"`
66
+
67
+ You also have to provide the following settings:
68
+
69
+ * `paperclip.fog.provider` # set to one of "AWS", "Google" or "Rackspace"
70
+
71
+ If set to AWS, provide the following:
72
+
73
+ * `paperclip.s3.bucket`
74
+ * `paperclip.s3.key`
75
+ * `paperclip.s3.secret`
76
+ * `paperclip.s3.region`
77
+
78
+ If set to "Google", provide the following:
79
+
80
+ * `paperclip.fog.directory`
81
+ * `paperclip.google_storage.access_key_id`
82
+ * `paperclip.google_storage.secret_access_key`
83
+
84
+ If set to "Rackspace", provide the following:
85
+
86
+ * `paperclip.fog.directory`
87
+ * `paperclip.rackspace.username`
88
+ * `paperclip.rackspace.api_key`
89
+
90
+ And optionally:
91
+
92
+ * `paperclip.fog.host`
93
+ * `paperclip.fog.public?`
94
+
95
+ ### Configurable settings
96
+
97
+ If you want to disable a whole category of post-processing, set one of these options to false:
98
+
99
+ * `assets.create_image_thumbnails?`
100
+ * `assets.create_video_thumbnails?`
101
+ * `assets.create_pdf_thumbnails?`
102
+
103
+ If we can't find ffmpeg on initialization, video thumbnailing will be disabled automatically by setting `assets.create_video_thumbnails?` to false.
104
+
105
+ To set a threshold for the size of uploads permitted:
106
+
107
+ * `assets.max_asset_size` which should be an integer number of MB
108
+
109
+ And you can set some defaults:
110
+
111
+ * `assets.insertion_size` is the name of the style that's used when you click on 'insert' to add a radius asset tag to your text. You can edit it after insertion, of course.
112
+ * `assets.display_size` is the name of the style that's shows when you edit a single asset in the admin interface.
113
+
114
+
115
+ ### Asset Thumbnail Sizes
116
+
117
+ To configure different thumbnail sizes, set `assets.thumbnails.image`. Here is an example of setting two custom thumbnail sizes:
118
+
119
+ TrustyCms::Config['assets.thumbnails.image'] = "custom:geometry=200x300>,format=jpg|bigger:geometry=600x700>,format=jpg"
120
+
121
+ ## Usage
122
+
123
+ For most purposes you will probably work with assets while you're working on pages. Click on one of the 'assets' links and a panel will pop up allowing you to find, insert and attach existing assets or upload new ones.
124
+
125
+ For tidying up, replacing files and other admin, click on the 'assets' tab to get a larger version of the same list. Here again you can search for assets and filter the results by type, but the options are 'edit' and 'remove' and on editing you can change name, file and caption while keeping page associations intact.
126
+
127
+ ## Radius Tags
128
+
129
+ The asset manager has its own family of radius tags. The basic tag is `<r:asset/>`, which can be used either alone or as a double tag. This tag requires a `name` or `id` attribute, which references the asset. The `<r:asset/>` tag can be combined with other tags for a variety of uses:
130
+
131
+ <r:asset:image name="image.png"/> #=> <img src="/path/to/image.png" />
132
+ <r:asset:link name="image.png"/> #=> <a href="/path/to/image.png">image.png</a>
133
+
134
+ You could also use:
135
+
136
+ <r:asset:link name="bar.pdf">Download PDF</r:asset:link>
137
+
138
+ Asset links are also available, such as content_type, file_size, and url.
139
+
140
+ Another important tag is the `<r:assets:each>...</r:assets:each>` (note the plural namespace tag "assets"). If a page has attached assets, the `<r:assets:each>` tag will cycle through each asset. You can then use an image, `link` or `url` tag to display and connect your assets. Usage:
141
+
142
+ <r:assets:each [limit=0] [offset=0] [order="asc|desc"] [by="position|title|..."]>
143
+ ...
144
+ </r:assets:each>
145
+
146
+ This tag uses the following parameters:
147
+
148
+ * `limit` and `offset` let you specify a range of assets
149
+ * `order` and `by` lets you control sorting
150
+
151
+ The conditional tags `<r:if_assets [min_count="0"]>` and `<r:unless_assets [min_count="0"]>` allow you to optionally render content based on the existence of tags. They accept the same options as `<r:assets:each>`.
152
+
153
+ Thumbnails are automatically generated for images when the images are uploaded. By default, two sizes are made for use within the extension itself. These are "icon" 42px by 42px and "thumbnail" which is 100px square.
154
+
155
+ You can access sizes of image assets for various versions with tags like `<r:asset:width [size="original"]/>` and `<r:asset:height [size="original"]/>`.
156
+
157
+ Also, for vertical centering of images, you have the handy `<r:asset:top_padding container="<container height>" [size="icon"]/>` tag. Working example:
158
+
159
+ <ul>
160
+ <r:assets:each>
161
+ <li style="height:140px">
162
+ <img style="padding-top:<r:top_padding size='category' container='140'/>px" src="<r:url/>" alt="<r:caption/>">
163
+ </li>
164
+ </r:assets:each>
165
+ </ul>
166
+
167
+ ## Contributions
168
+
169
+ If you would like to contribute, please [fork the project][fork] and submit a [pull request][pull-request].
170
+
171
+ [fork]: http://help.github.com/fork-a-repo/
172
+ [pull-request]: http://help.github.com/send-pull-requests/
173
+
174
+ Pull requests with working tests are preferred and have a greater chance of being merged.
175
+
176
+ ## TODO
177
+
178
+ * Progress bars while uploading assets
179
+ * Warning if you try and save a page while assets are still uploading
180
+ * Radius tags for the HTML video and audio elements
181
+ * Auxiliary extension to add video transcoding support
182
+
183
+ ## Authors
184
+
185
+ * Keith Bingman
186
+ * John Long
187
+ * William Ross
188
+ * Eric Sipple
189
+
190
+
191
+ Copyright 2011 the TrustyCms team. Released under the same terms as TrustyCms.
data/Rakefile ADDED
@@ -0,0 +1,109 @@
1
+ # Determine where the RSpec plugin is by loading the boot
2
+ unless defined? RADIANT_ROOT
3
+ ENV["RAILS_ENV"] = "test"
4
+ case
5
+ when ENV["RADIANT_ENV_FILE"]
6
+ require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
7
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
8
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
9
+ else
10
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
11
+ end
12
+ end
13
+
14
+ require 'rake'
15
+ require 'rdoc/task'
16
+ require 'rake/testtask'
17
+
18
+ rspec_base = File.expand_path(RADIANT_ROOT + '/vendor/plugins/rspec/lib')
19
+ $LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
20
+ require 'spec/rake/spectask'
21
+ require 'cucumber'
22
+ require 'cucumber/rake/task'
23
+
24
+ # Cleanup the RADIANT_ROOT constant so specs will load the environment
25
+ Object.send(:remove_const, :RADIANT_ROOT)
26
+
27
+ extension_root = File.expand_path(File.dirname(__FILE__))
28
+
29
+ task :default => [:spec, :features]
30
+ task :stats => "spec:statsetup"
31
+
32
+ desc "Run all specs in spec directory"
33
+ Spec::Rake::SpecTask.new(:spec) do |t|
34
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
35
+ t.spec_files = FileList['spec/**/*_spec.rb']
36
+ end
37
+
38
+ task :features => 'spec:integration'
39
+
40
+ namespace :spec do
41
+ desc "Run all specs in spec directory with RCov"
42
+ Spec::Rake::SpecTask.new(:rcov) do |t|
43
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
44
+ t.spec_files = FileList['spec/**/*_spec.rb']
45
+ t.rcov = true
46
+ t.rcov_opts = ['--exclude', 'spec', '--rails']
47
+ end
48
+
49
+ desc "Print Specdoc for all specs"
50
+ Spec::Rake::SpecTask.new(:doc) do |t|
51
+ t.spec_opts = ["--format", "specdoc", "--dry-run"]
52
+ t.spec_files = FileList['spec/**/*_spec.rb']
53
+ end
54
+
55
+ [:models, :controllers, :views, :helpers].each do |sub|
56
+ desc "Run the specs under spec/#{sub}"
57
+ Spec::Rake::SpecTask.new(sub) do |t|
58
+ t.spec_opts = ['--options', "\"#{extension_root}/spec/spec.opts\""]
59
+ t.spec_files = FileList["spec/#{sub}/**/*_spec.rb"]
60
+ end
61
+ end
62
+
63
+ desc "Run the Cucumber features"
64
+ Cucumber::Rake::Task.new(:integration) do |t|
65
+ t.fork = true
66
+ t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
67
+ # t.feature_pattern = "#{extension_root}/features/**/*.feature"
68
+ t.profile = "default"
69
+ end
70
+
71
+ # Setup specs for stats
72
+ task :statsetup do
73
+ require 'code_statistics'
74
+ ::STATS_DIRECTORIES << %w(Model\ specs spec/models)
75
+ ::STATS_DIRECTORIES << %w(View\ specs spec/views)
76
+ ::STATS_DIRECTORIES << %w(Controller\ specs spec/controllers)
77
+ ::STATS_DIRECTORIES << %w(Helper\ specs spec/views)
78
+ ::CodeStatistics::TEST_TYPES << "Model specs"
79
+ ::CodeStatistics::TEST_TYPES << "View specs"
80
+ ::CodeStatistics::TEST_TYPES << "Controller specs"
81
+ ::CodeStatistics::TEST_TYPES << "Helper specs"
82
+ ::STATS_DIRECTORIES.delete_if {|a| a[0] =~ /test/}
83
+ end
84
+
85
+ namespace :db do
86
+ namespace :fixtures do
87
+ desc "Load fixtures (from spec/fixtures) into the current environment's database. Load specific fixtures using FIXTURES=x,y"
88
+ task :load => :environment do
89
+ require 'active_record/fixtures'
90
+ ActiveRecord::Base.establish_connection(Rails.env.to_sym)
91
+ (ENV['FIXTURES'] ? ENV['FIXTURES'].split(/,/) : Dir.glob(File.join(Rails.root, 'spec', 'fixtures', '*.{yml,csv}'))).each do |fixture_file|
92
+ Fixtures.create_fixtures('spec/fixtures', File.basename(fixture_file, '.*'))
93
+ end
94
+ end
95
+ end
96
+ end
97
+ end
98
+
99
+ desc 'Generate documentation for the clipped extension.'
100
+ RDoc::Task.new(:rdoc) do |rdoc|
101
+ rdoc.rdoc_dir = 'rdoc'
102
+ rdoc.title = 'ClippedExtension'
103
+ rdoc.options << '--line-numbers' << '--inline-source'
104
+ rdoc.rdoc_files.include('README')
105
+ rdoc.rdoc_files.include('lib/**/*.rb')
106
+ end
107
+
108
+ # Load any custom rakefiles for extension
109
+ Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,261 @@
1
+ Assets = {
2
+ attachEvents: function() {
3
+ $('a.attach_asset').click(function(e){
4
+ e.preventDefault();
5
+ var link = $(this);
6
+ var container = link.parents('li.asset');
7
+ var title = link.parents('div.title').html();
8
+ var image = link.parents('img');
9
+ container.addClass('waiting');
10
+ $.ajax({
11
+ url: link.attr('href'),
12
+ success: function(data, textStatus, jqXHR) {
13
+ container.removeClass('waiting');
14
+ Assets.addToList(data);
15
+ }
16
+ });
17
+ });
18
+
19
+ $('a.detach_asset').click(function(e){
20
+ e.preventDefault();
21
+ var link = $(this);
22
+ Assets.removeFromList(link.parents('li.asset'));
23
+ });
24
+
25
+ $('a.insert_asset').click(function(e){
26
+ e.preventDefault();
27
+ var part_name = $("a.tab.here").children('span').html();
28
+ if (part_name.indexOf(' ')) part_name = part_name.replace(' ', '-');
29
+ var part_id = 'part_' + part_name + '_content';
30
+ var tag_parts = $(this).attr('rel').split('_');
31
+ var tag_name = tag_parts[0];
32
+ var asset_size = tag_parts[1];
33
+ var asset_id = tag_parts[2];
34
+ var radius_tag = '<r:asset:' + tag_name;
35
+ if (asset_size != '') radius_tag = radius_tag + ' size="' + asset_size + '"';
36
+ radius_tag = radius_tag +' id="' + asset_id + '" />';
37
+ Assets.insertAtCursor(part_id, radius_tag);
38
+
39
+ });
40
+
41
+ $(".pagination a").click(function(e){
42
+ e.preventDefault();
43
+ $.ajax({
44
+ method: 'get',
45
+ url: $(this).attr('href') + Assets.assetFilterParameters(),
46
+ complete: function(data, textStatus, jqXHR) {
47
+ Assets.updateTable(data.responseText);
48
+ Assets.attachEvents();
49
+ }
50
+ });
51
+ });
52
+
53
+ },
54
+
55
+ assetFilterParameters: function() {
56
+ var parameters = [];
57
+ if ($('#filesearchforminput').val() !== '') {
58
+ parameters.push(['search', $('#filesearchforminput').val()]);
59
+ }
60
+ var filters = [];
61
+ var url_params = "";
62
+ $('a.selective.pressed').each(function(){
63
+ filters.push($(this).attr('rel'));
64
+ });
65
+
66
+ if (filters.length > 0) {parameters.push(['filter', filters.toString()])}
67
+
68
+ for(var i = 0; i < parameters.length; i++) {
69
+ if (i > 0) {url_params = url_params + '&'}
70
+ url_params = url_params + parameters[i][0] + '=' + parameters[i][1];
71
+ }
72
+ return url_params + '&pp=20';
73
+ },
74
+
75
+ activateUpload: function(){
76
+ $('#upload-controls').hide();
77
+ $('#update-controls').show();
78
+ $('#asset_title').prop( "disabled", false );
79
+ $('#new_asset input[name="commit"]').prop( "disabled", false );
80
+ },
81
+ activateUpdate: function() {
82
+ $('#upload-controls').show();
83
+ $('#update-controls').hide();
84
+ $('#asset_title').prop( "disabled", true );
85
+ $('#new_asset input[name="commit"]').prop( "disabled", true );
86
+ },
87
+
88
+ insertAtCursor: function(part_id, insertion) {
89
+ if (CKEDITOR.instances[part_id].mode == 'wysiwyg') {
90
+ CKEDITOR.instances[part_id].insertText( insertion );
91
+ } else {
92
+ var textbox = $("textarea.cke_source[title~=" + part_id +"]");
93
+ var caretPos = textbox[0].selectionStart;
94
+ var textAreaTxt = textbox.val();
95
+ textbox.val(textAreaTxt.substring(0, caretPos) + insertion + textAreaTxt.substring(caretPos) );
96
+ }
97
+ },
98
+ filterAssets: function() {
99
+ var url = $("#filesearchform").attr('action');
100
+ var parameters = Assets.assetFilterParameters();
101
+
102
+ url = url + "?" + parameters;
103
+ $.ajax({
104
+ url: url,
105
+ complete: function(data, textStatus, jqXHR) {
106
+ Assets.updateTable(data.responseText);
107
+ }
108
+ });
109
+ },
110
+ updateTable: function(html) {
111
+ $("#assets_table").html(html);
112
+ Assets.attachEvents();
113
+ },
114
+ addToList: function(html){
115
+ var list = $('#attachment_fields');
116
+ list.append(html);
117
+ Assets.showListIfHidden();
118
+ Assets.notify('Save page to commit changes');
119
+ Assets.attachEvents();
120
+ // I'm not sure what Sortable does and can't find any example of
121
+ // its use in current Radiant, so I'm going to comment it out for now.
122
+
123
+ //Assets.makeSortable(list);
124
+
125
+ },
126
+ removeFromList: function(container) {
127
+ container.children('input.attacher').remove();
128
+ container.children('input.pos').remove();
129
+ container.children('input.destroyer').val(1);
130
+ container.fadeOut();
131
+ container.addClass('detached');
132
+ },
133
+ showListIfHidden: function() {
134
+ var list = $('#attachment_fields');
135
+ if (list.hasClass('empty')) {
136
+ list.removeClass('empty');
137
+ }
138
+ },
139
+ notify: function(message){
140
+ $('#attachment_list span.message').html(message).addClass('important');
141
+ }
142
+
143
+ };
144
+
145
+
146
+ $(function() {
147
+
148
+ $('a.selective').click(function(e){
149
+ e.preventDefault();
150
+ var element = $(this);
151
+ var type_id = element.attr('rel');
152
+ var type_check = $('#' + type_id + '-check');
153
+
154
+ if(element.hasClass('pressed')) {
155
+ element.removeClass('pressed');
156
+ $(type_check).prop('checked', false);
157
+ if ($('a.selective.pressed').length == 0) $('#select_all').addClass('pressed');
158
+ }
159
+ else {
160
+ element.addClass('pressed');
161
+ $('a.deselective').each(function() { $(this).removeClass('pressed'); });
162
+ $(type_check).prop('checked', true);
163
+ }
164
+ Assets.filterAssets();
165
+ Assets.attachEvents();
166
+
167
+ });
168
+
169
+ $('a.deselective').click(function(e){
170
+ e.preventDefault();
171
+ var element = $(this);
172
+ if(!element.hasClass('pressed')) {
173
+ $('a.selective').each(function() { $(this).removeClass('pressed'); });
174
+ $('input.selective').each(function() { $(this).prop('checked', false); });
175
+ element.addClass('pressed');
176
+ Assets.filterAssets();
177
+ Assets.attachEvents();
178
+ }
179
+ });
180
+
181
+ $('#filesearchforminput').keyup(function(){
182
+ Assets.filterAssets();
183
+ Assets.attachEvents();
184
+ });
185
+
186
+ $("#attach_assets").click(function(e) {
187
+ e.preventDefault();
188
+ Popup.show('attach_asset');
189
+ $('.close_popup').click(function(e){
190
+ e.preventDefault();
191
+ Popup.close();
192
+ $('#attach_asset').hide();
193
+ });
194
+ });
195
+
196
+ $('#filesearchforminput').keyup(function(){
197
+ Assets.filterAssets();
198
+ });
199
+
200
+ $("#upload_asset_link").click(function(e) {
201
+ e.preventDefault();
202
+ Popup.close();
203
+ $('#attach_asset').hide();
204
+ Assets.activateUpdate();
205
+ Popup.show('upload_asset');
206
+
207
+ $("#attach-popup").click(function(e) {
208
+ e.preventDefault();
209
+ Popup.close();
210
+ $('#upload_asset').hide();
211
+ Popup.show('attach_asset');
212
+ $('.close_popup').click(function(e){
213
+ e.preventDefault();
214
+ Popup.close();
215
+ $('#attach_asset').hide();
216
+ });
217
+ });
218
+
219
+ $('.close_popup').click(function(e){
220
+ e.preventDefault();
221
+ Popup.close();
222
+ $('#upload_asset').hide();
223
+ });
224
+ });
225
+
226
+ $('#update_asset').submit(function(e){
227
+ e.preventDefault();
228
+ $("#update-asset").attr("disabled", true);
229
+ $('#update-status').show();
230
+ $.ajax({
231
+ method: 'put',
232
+ url: $(this).attr('action') + $("#asset_id").val(),
233
+ data: $(this).serialize(),
234
+ complete: function(data, textStatus, jqXHR) {
235
+ Popup.close();
236
+ $('#upload_asset').hide();
237
+ $('#update-status').hide();
238
+ $("#update-asset").attr("disabled", false);
239
+ $('#update_asset').trigger("reset");
240
+ }
241
+ });
242
+ });
243
+
244
+ $('#asset_asset').fileupload({
245
+ add: function(e, data) {
246
+ $("#asset_asset").attr("disabled", true);
247
+ $('#upload-status').show();
248
+ data.submit();
249
+ },
250
+ done: function (e, data) {
251
+ $("#asset_id").val($(data.result).find(".attacher").val());
252
+ Assets.addToList($(data.result));
253
+ Assets.activateUpload();
254
+ $("#asset_asset").attr("disabled", false);
255
+ $('#upload-status').hide();
256
+ }
257
+ });
258
+
259
+ Assets.attachEvents();
260
+
261
+ });