radiant-clipped-extension 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +22 -0
- data/README.md +230 -0
- data/Rakefile +109 -0
- data/app/controllers/admin/assets_controller.rb +60 -0
- data/app/controllers/admin/page_attachments_controller.rb +18 -0
- data/app/helpers/admin/assets_helper.rb +16 -0
- data/app/models/asset.rb +224 -0
- data/app/models/asset_tags.rb +384 -0
- data/app/models/asset_type.rb +170 -0
- data/app/models/old_page_attachment.rb +26 -0
- data/app/models/page_attachment.rb +21 -0
- data/app/views/admin/assets/_asset.html.haml +12 -0
- data/app/views/admin/assets/_asset_table.html.haml +30 -0
- data/app/views/admin/assets/_errors.html.haml +3 -0
- data/app/views/admin/assets/_form.html.haml +20 -0
- data/app/views/admin/assets/_page_assets.html.haml +12 -0
- data/app/views/admin/assets/_search.html.haml +17 -0
- data/app/views/admin/assets/_search_results.html.haml +17 -0
- data/app/views/admin/assets/edit.html.haml +40 -0
- data/app/views/admin/assets/index.html.haml +19 -0
- data/app/views/admin/assets/new.html.haml +24 -0
- data/app/views/admin/assets/refresh.html.haml +14 -0
- data/app/views/admin/assets/remove.html.haml +16 -0
- data/app/views/admin/configuration/_edit.html.haml +8 -0
- data/app/views/admin/configuration/_show.html.haml +12 -0
- data/app/views/admin/page_attachments/_attachment.html.haml +25 -0
- data/app/views/admin/page_parts/_page_part.html.haml +21 -0
- data/app/views/admin/pages/_asset_popups.html.haml +42 -0
- data/app/views/admin/pages/_assets.html.haml +11 -0
- data/app/views/admin/removed/_assets_bucket.html.haml +8 -0
- data/app/views/admin/removed/_assets_container.html.haml +58 -0
- data/app/views/admin/removed/_bucket.html.haml +11 -0
- data/app/views/admin/removed/_bucket_asset.html.haml +9 -0
- data/app/views/admin/removed/_show_bucket_link.html.haml +4 -0
- data/app/views/admin/removed/_upload_to_page.html.haml +12 -0
- data/app/views/admin/removed/bucket/_iframe.html.haml +1 -0
- data/artwork/icons.png +0 -0
- data/clipped_extension.rb +89 -0
- data/config/initializers/interpolation.rb +6 -0
- data/config/initializers/processors.rb +43 -0
- data/config/initializers/radiant_config.rb +34 -0
- data/config/locales/en.yml +108 -0
- data/config/locales/nl.yml +105 -0
- data/config/routes.rb +8 -0
- data/cucumber.yml +1 -0
- data/db/migrate/001_create_assets.rb +12 -0
- data/db/migrate/002_create_paperclip_attributes.rb +13 -0
- data/db/migrate/003_create_user_observer.rb +13 -0
- data/db/migrate/004_create_page_attachments.rb +19 -0
- data/db/migrate/005_rename_users.rb +13 -0
- data/db/migrate/20090316132151_disable_file_types.rb +20 -0
- data/db/migrate/20110513205050_asset_uuid.rb +11 -0
- data/db/migrate/20110606111250_update_configuration.rb +28 -0
- data/db/migrate/20110609101438_dimensions.rb +13 -0
- data/features/support/env.rb +11 -0
- data/features/support/paths.rb +22 -0
- data/lib/clipped_admin_ui.rb +32 -0
- data/lib/page_asset_associations.rb +13 -0
- data/lib/paperclip/frame_grab.rb +73 -0
- data/lib/paperclip/geometry_transformation.rb +79 -0
- data/lib/radiant-clipped-extension.rb +2 -0
- data/lib/radiant-clipped-extension/version.rb +3 -0
- data/lib/tasks/clipped_extension_tasks.rake +126 -0
- data/lib/tasks/paperclip_tasks.rake +79 -0
- data/public/flash/ZeroClipboard.swf +0 -0
- data/public/images/admin/assets/add.png +0 -0
- data/public/images/admin/assets/archive_icon.png +0 -0
- data/public/images/admin/assets/audio_icon.png +0 -0
- data/public/images/admin/assets/audio_thumbnail.png +0 -0
- data/public/images/admin/assets/c_icon.png +0 -0
- data/public/images/admin/assets/copy.png +0 -0
- data/public/images/admin/assets/css_icon.png +0 -0
- data/public/images/admin/assets/database_icon.png +0 -0
- data/public/images/admin/assets/delete.png +0 -0
- data/public/images/admin/assets/document_icon.png +0 -0
- data/public/images/admin/assets/document_thumbnail.png +0 -0
- data/public/images/admin/assets/flash_icon.png +0 -0
- data/public/images/admin/assets/flash_thumbnail.png +0 -0
- data/public/images/admin/assets/font_icon.png +0 -0
- data/public/images/admin/assets/gzip_icon.png +0 -0
- data/public/images/admin/assets/html_icon.png +0 -0
- data/public/images/admin/assets/image_icon.png +0 -0
- data/public/images/admin/assets/image_thumbnail.png +0 -0
- data/public/images/admin/assets/java_icon.png +0 -0
- data/public/images/admin/assets/page_edit.png +0 -0
- data/public/images/admin/assets/perl_icon.png +0 -0
- data/public/images/admin/assets/php_icon.png +0 -0
- data/public/images/admin/assets/presentation_icon.png +0 -0
- data/public/images/admin/assets/python_icon.png +0 -0
- data/public/images/admin/assets/reorder_assets.png +0 -0
- data/public/images/admin/assets/ruby_icon.png +0 -0
- data/public/images/admin/assets/script_icon.png +0 -0
- data/public/images/admin/assets/spreadsheet_icon.png +0 -0
- data/public/images/admin/assets/tar_icon.png +0 -0
- data/public/images/admin/assets/unknown_icon.png +0 -0
- data/public/images/admin/assets/unknown_thumbnail.png +0 -0
- data/public/images/admin/assets/video_icon.png +0 -0
- data/public/images/admin/assets/video_thumbnail.png +0 -0
- data/public/images/admin/assets/xml_icon.png +0 -0
- data/public/images/admin/assets/zip_icon.png +0 -0
- data/public/javascripts/admin/assets.js +296 -0
- data/public/stylesheets/sass/admin/assets.sass +209 -0
- data/radiant-clipped-extension.gemspec +33 -0
- data/spec/controllers/admin/assets_controller_spec.rb +50 -0
- data/spec/controllers/admin/page_attachments_controller_spec.rb +50 -0
- data/spec/datasets/assets_dataset.rb +35 -0
- data/spec/fixtures/test.flv +0 -0
- data/spec/lib/asset_tags_spec.rb +101 -0
- data/spec/lib/frame_grab_spec.rb +17 -0
- data/spec/lib/geometry_transformation_spec.rb +63 -0
- data/spec/models/asset_spec.rb +72 -0
- data/spec/models/asset_type_spec.rb +63 -0
- data/spec/spec.opts +6 -0
- data/spec/spec_helper.rb +36 -0
- data/wireframes/edit-page-assets-2.bmml +453 -0
- data/wireframes/edit-page-assets-2.png +0 -0
- data/wireframes/edit-page-assets-3.bmml +454 -0
- data/wireframes/edit-page-assets-3.png +0 -0
- data/wireframes/edit-page-assets.bmml +433 -0
- data/wireframes/edit-page-assets.png +0 -0
- data/wireframes/edit-page.bmml +174 -0
- data/wireframes/edit-page.png +0 -0
- metadata +249 -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,230 @@
|
|
1
|
+
Radiant Clipped Extension
|
2
|
+
------------------------
|
3
|
+
|
4
|
+
This is a new core extension intended for use with Radiant version 1.0 or higher.
|
5
|
+
It is based on Keith Bingman's excellent Paperclipped extension, for which it is a drop-in replacement.
|
6
|
+
It should also be an easy upgrade from `page_attachments`, but I haven't tested that yet.
|
7
|
+
|
8
|
+
## Changes
|
9
|
+
|
10
|
+
* video files frame-grabbed (automatically disabled if FFmpeg is not found)
|
11
|
+
* pdfs thumbnailed
|
12
|
+
* new asset-retrieval and page-attachment interface (by John Long)
|
13
|
+
* new inline upload mechanism that allows several concurrent uploads and attachment to new pages
|
14
|
+
* easily extended with new asset types and processors
|
15
|
+
* helpful insert buttons that do the right thing.
|
16
|
+
|
17
|
+
## Still to do
|
18
|
+
|
19
|
+
* progress bars on uploading assets
|
20
|
+
* warning if you try and save a page while assets are still uploading
|
21
|
+
* html5 video and audio tags in radius (with sensible flash fallbacks)
|
22
|
+
|
23
|
+
Video transcoding support will be in an optional extension with `delayed_job` support.
|
24
|
+
|
25
|
+
# Known bugs
|
26
|
+
|
27
|
+
At the moment I think uploads probably don't work in IE7. See github for more issues.
|
28
|
+
|
29
|
+
## Requirements
|
30
|
+
|
31
|
+
The `paperclip`, `uuidtools` and `acts_as_list` gems are required. For S3 storage you need the `aws-s3` gem.
|
32
|
+
|
33
|
+
Paperclip's post-processors require ImageMagick. PDF-thumbnailing also requires ghostscript, which is usually
|
34
|
+
installed with ImageMagick anyway, and if you want to generate thumbnails from video clips then you also need FFmpeg.
|
35
|
+
|
36
|
+
On unixy systems there should be packages available to satisfy all these requirements. You don't need to
|
37
|
+
install development libraries, but you will get a lot of little file-type utilities if you don't have them already.
|
38
|
+
|
39
|
+
On OS X, with macports:
|
40
|
+
|
41
|
+
port install ghostscript imagemagick ffmpeg
|
42
|
+
|
43
|
+
On debian-like systems:
|
44
|
+
|
45
|
+
apt-get install ghostscript imagemagick ffmpeg
|
46
|
+
|
47
|
+
And I expect it's very similar with yum.
|
48
|
+
|
49
|
+
On Windows, you can get binary installers of all the required pieces and apparently these days they're simple
|
50
|
+
to install and connect:
|
51
|
+
|
52
|
+
* ImageMagick: http://www.imagemagick.org/script/binary-releases.php
|
53
|
+
* Ghostscript: http://sourceforge.net/projects/ghostscript/
|
54
|
+
* FFMpeg: http://ffmpeg.zeranoe.com/builds/
|
55
|
+
|
56
|
+
If your paths are strange, or you're running under passenger, you may need to set `Paperclip.options[:command_path]`
|
57
|
+
to the location of these binaries for each of your environments. On OS X that's usually `/opt/local/bin`.
|
58
|
+
|
59
|
+
## Installation
|
60
|
+
|
61
|
+
This extension is not currently compatible with versions of radiant earlier than 1.0rc. The incompatibilities
|
62
|
+
are fairly minor and it may be backported, but for now if you're running a version of radiant which with the assets
|
63
|
+
extension will work, you will find it is already installed. If you don't have it in your radiant distribution, it
|
64
|
+
probably wouldn't work anyway.
|
65
|
+
|
66
|
+
## Upgrading from paperclipped
|
67
|
+
|
68
|
+
No special steps are required. Paperclipped migrations are respected. The /images/assets directory is no longer needed.
|
69
|
+
and can be deleted. See below for some radius tag changes that won't affect you yet but should be borne in mind.
|
70
|
+
|
71
|
+
## Upgrading from page_attachments
|
72
|
+
|
73
|
+
This is supposed to be straightforward too. In theory once the clipped extension has been migrated all you need is:
|
74
|
+
|
75
|
+
rake radiant:extensions:clipped:migrate_from_page_attachments
|
76
|
+
|
77
|
+
But I haven't tested that theory recently.
|
78
|
+
|
79
|
+
## Radius tag changes
|
80
|
+
|
81
|
+
The full radius tag set of paperclipped is still supported, so your pages should just work. If they worked before.
|
82
|
+
|
83
|
+
The preferred syntax is slightly different, though. Where paperlipped used the `r:assets` namespace for everything, the
|
84
|
+
assets extension has adopted a readable system of singular and plural tags that will be familiar from other bits of radiant:
|
85
|
+
|
86
|
+
<r:assets:each>
|
87
|
+
<a href="<r:asset:url size="download" />">
|
88
|
+
<r:asset:image size="thumbnail" />
|
89
|
+
</a>
|
90
|
+
<span class="caption"><r:asset:caption /></span>
|
91
|
+
</r:assets:each>
|
92
|
+
|
93
|
+
Anything to do with the collection of assets is plural. Anything to do with a particular asset is singular. The old plural
|
94
|
+
forms still work but they are deprecated and (as the log messages will keep telling you) likely to removed in version 2.
|
95
|
+
|
96
|
+
## Configuration
|
97
|
+
|
98
|
+
The clipped extension is configured in the usual way, but only its minor settings are exposed in the admin interface. The
|
99
|
+
more architectural settings shouldn't be changed at runtime and some of them will require a lot of sorting out if they're
|
100
|
+
changed at all, so those are only accessible through the console or by editing the database. Eventually they will be made
|
101
|
+
part of the initial radiant installation process.
|
102
|
+
|
103
|
+
### Structural settings
|
104
|
+
|
105
|
+
* `clipped.url` sets the url scheme for attached files. Paperclip interpolations are applied. You probably don't want to change this.
|
106
|
+
* `clipped.path` sets the path scheme for attached files. Paperclip interpolations are applied. You might conceivably want to change this.
|
107
|
+
* `clipped.additional_thumbnails` is a string of comma-separated style definitions that is passed to paperclip for any asset type that has a post-processor (that is, currently, images, pdfs and video clips). The definitions are in the format name=geometry and when assembled the string will look something like `preview=640x640>,square=#260x260`. Thumbnail and icon styles are already defined and don't need to be configured this way.
|
108
|
+
* `clipped.storage` can be 'filesystem' (the default) or 's3' for amazon's cloud service.
|
109
|
+
* `clipped.skip_filetype_validation` is true by default and allows uploads of any mime type.
|
110
|
+
|
111
|
+
If the storage option is set to 's3' then these settings are also required:
|
112
|
+
|
113
|
+
* `clipped.s3.bucket`
|
114
|
+
* `clipped.s3.key`
|
115
|
+
* `clipped.s3.secret`
|
116
|
+
|
117
|
+
And optionally:
|
118
|
+
|
119
|
+
* `clipped.s3.host_alias`
|
120
|
+
|
121
|
+
### Configurable settings
|
122
|
+
|
123
|
+
If you want to disable a whole category of post-processing, set one of these options to false:
|
124
|
+
|
125
|
+
* `clipped.create_image_thumbnails?`
|
126
|
+
* `clipped.create_video_thumbnails?`
|
127
|
+
* `clipped.create_pdf_thumbnails?`
|
128
|
+
|
129
|
+
If we can't find ffmpeg on initialization, video thumbnailing will be disabled automatically by setting `clipped.create_video_thumbnails?` to false.
|
130
|
+
|
131
|
+
To set a threshold for the size of uploads permitted:
|
132
|
+
|
133
|
+
* `assets.max_asset_size` which should be an integer number of MB
|
134
|
+
|
135
|
+
And you can set some defaults:
|
136
|
+
|
137
|
+
* `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.
|
138
|
+
* `assets.display_size` is the name of the style that's shows when you edit a single asset in the admin interface.
|
139
|
+
|
140
|
+
## Usage
|
141
|
+
|
142
|
+
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.
|
143
|
+
|
144
|
+
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.
|
145
|
+
|
146
|
+
## Radius Tags
|
147
|
+
|
148
|
+
The asset manager has its own family of radius tags. The basic tag is <code><r:asset /></code>,
|
149
|
+
which can be used either alone or as a double tag. This tag requires a `name` or `id` attribute,
|
150
|
+
which references the asset. The <code><r:asset /></code> tag can be combined with other tags for a
|
151
|
+
variety of uses:
|
152
|
+
|
153
|
+
<r:asset:image name="image.png" /> #=> <img src="/path/to/image.png" />
|
154
|
+
<r:asset:link name="image.png" /> #=> <a href="/path/to/image.png">image.png</a>
|
155
|
+
|
156
|
+
You could also use:
|
157
|
+
|
158
|
+
<r:asset:link name="bar.pdf">Download PDF</r:asset:link>
|
159
|
+
|
160
|
+
Asset links are also available, such as content_type, file_size, and url.
|
161
|
+
|
162
|
+
Another important tag is the <code><r:assets:each>...</r:assets:each></code>.
|
163
|
+
(Note the plural namespace tag "assets".) If a page has attached assets, the
|
164
|
+
assets:each tag will cycle through each asset. You can then use an image,
|
165
|
+
link or url tag to display and connect your assets. Usage:
|
166
|
+
|
167
|
+
<r:assets:each [limit=0] [offset=0] [order="asc|desc"] [by="position|title|..."]>
|
168
|
+
...
|
169
|
+
</r:assets:each>
|
170
|
+
|
171
|
+
This tag uses the following parameters:
|
172
|
+
|
173
|
+
* `limit` and `offset` let you specify a range of assets
|
174
|
+
* `order` and `by` lets you control sorting
|
175
|
+
|
176
|
+
The conditional tags <code><r:if_assets [min_count="0"]></code> and
|
177
|
+
<code><r:unless_assets [min_count="0"]></code> allow you to optionally render
|
178
|
+
content based on the existence of tags. They accept the same options as
|
179
|
+
`<r:assets:each>`.
|
180
|
+
|
181
|
+
Thumbnails are automatically generated for images when the images are
|
182
|
+
uploaded. By default, two sizes are made for use within the extension itself.
|
183
|
+
These are "icon" 42px by 42px and "thumbnail" which is 100px square.
|
184
|
+
|
185
|
+
You can access sizes of image assets for various versions with tags like
|
186
|
+
`<r:asset:width [size="original"]/>` and <code><r:asset:height
|
187
|
+
[size="original"]/></code>.
|
188
|
+
|
189
|
+
Also, for vertical centering of images, you have the handy
|
190
|
+
`<r:asset:top_padding container="<container height>" [size="icon"]/>` tag.
|
191
|
+
Working example:
|
192
|
+
|
193
|
+
<ul>
|
194
|
+
<r:assets:each>
|
195
|
+
<li style="height:140px">
|
196
|
+
<img style="padding-top:<r:top_padding size='category' container='140' />px"
|
197
|
+
src="<r:url />" alt="<r:title />" />
|
198
|
+
</li>
|
199
|
+
</r:assets:each>
|
200
|
+
</ul>
|
201
|
+
|
202
|
+
## Contributions
|
203
|
+
|
204
|
+
This extension is a work in progress. If you would like to
|
205
|
+
contribute, please fork the project and submit a pull request:
|
206
|
+
|
207
|
+
<https://github.com/radiant/radiant-clipped-extension>
|
208
|
+
|
209
|
+
Pull requests with working tests are preferred and have a greater chance of
|
210
|
+
being merged.
|
211
|
+
|
212
|
+
## Support
|
213
|
+
|
214
|
+
If you have questions about this extension please post a message to the
|
215
|
+
Radiant-Dev mailing list:
|
216
|
+
|
217
|
+
<http://groups.google.com/group/radiantcms-dev>
|
218
|
+
|
219
|
+
If you would like to file a bug report or feature request, please create a
|
220
|
+
GitHub issue here:
|
221
|
+
|
222
|
+
<https://github.com/radiant/radiant-clipped-extension/issues>
|
223
|
+
|
224
|
+
## Authors
|
225
|
+
|
226
|
+
* Keith Bingman
|
227
|
+
* John Long
|
228
|
+
* William Ross
|
229
|
+
|
230
|
+
Copyright 2011 the radiant team. Released under the same terms as radiant.
|
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 'rake/rdoctask'
|
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
|
+
Rake::RDocTask.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 }
|
@@ -0,0 +1,60 @@
|
|
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] || []
|
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
|
+
format.html { render }
|
20
|
+
format.js {
|
21
|
+
@page = Page.find_by_id(params[:page_id])
|
22
|
+
render :partial => 'asset_table', :locals => {:with_pagination => !!@page}
|
23
|
+
}
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def create
|
28
|
+
@asset.update_attributes!(params[:asset])
|
29
|
+
if params[:for_attachment]
|
30
|
+
@page = Page.find_by_id(params[:page_id]) || Page.new
|
31
|
+
@page_attachment = @asset.page_attachments.build(:page => @page)
|
32
|
+
render :partial => 'admin/page_attachments/attachment', :object => @page_attachment
|
33
|
+
else
|
34
|
+
response_for :create
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def refresh
|
39
|
+
if params[:id]
|
40
|
+
@asset = Asset.find(params[:id])
|
41
|
+
@asset.asset.reprocess!
|
42
|
+
flash[:notice] = t('clipped_extension.thumbnails_refreshed')
|
43
|
+
redirect_to edit_admin_asset_path(@asset)
|
44
|
+
else
|
45
|
+
render
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
only_allow_access_to :regenerate,
|
50
|
+
:when => [:admin],
|
51
|
+
:denied_url => { :controller => 'admin/assets', :action => 'index' },
|
52
|
+
:denied_message => 'You must have admin privileges to refresh the whole asset set.'
|
53
|
+
|
54
|
+
def regenerate
|
55
|
+
Asset.all.each { |asset| asset.asset.reprocess! }
|
56
|
+
flash[:notice] = t('clipped_extension.all_thumbnails_refreshed')
|
57
|
+
redirect_to admin_assets_path
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Admin::PageAttachmentsController < Admin::ResourceController
|
2
|
+
helper 'admin/assets'
|
3
|
+
|
4
|
+
def new
|
5
|
+
render :partial => 'attachment', :object => model
|
6
|
+
end
|
7
|
+
|
8
|
+
def load_model
|
9
|
+
begin
|
10
|
+
@asset = Asset.find(params[:asset_id])
|
11
|
+
@page = params[:page_id].blank? ? Page.new : Page.find_by_id(params[:page_id])
|
12
|
+
rescue ActiveRecord::RecordNotFound
|
13
|
+
render :nothing => true, :layout => false
|
14
|
+
end
|
15
|
+
self.model = PageAttachment.new(:asset => @asset, :page => @page)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Admin::AssetsHelper
|
2
|
+
|
3
|
+
def automatic_size_descriptions
|
4
|
+
Asset.thumbnail_sizes.collect{|k,v| "#{k} (#{(v.to_s).match(/\d+x\d+/)})"}.join(', ')
|
5
|
+
end
|
6
|
+
|
7
|
+
def asset_insertion_link(asset)
|
8
|
+
radius_tag = asset.asset_type.default_radius_tag || 'link';
|
9
|
+
link_to t('clipped_extension.insert'), '#', :class => 'insert_asset', :rel => "#{radius_tag}_#{Radiant.config['assets.insertion_size']}_#{asset.id}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def asset_attachment_link(asset)
|
13
|
+
link_to t("clipped_extension.attach"), new_admin_page_attachment_path(:asset_id => asset.id), :class => 'attach_asset', :rel => "attach_#{asset.id}"
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|