• This repository has been archived on 30/Apr/2024
  • Stars
    star
    122
  • Rank 292,031 (Top 6 %)
  • Language
    Ruby
  • License
    Other
  • Created over 16 years ago
  • Updated almost 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Please note, this extension is no longer being developed. Please take a look at the radiant-clipped-extension instead. Radiant extension for managing assets and images with the Paperclip plugin.

Paperclipped

IMPORTANT!

This version of Paperclipped now requires Radiant 0.9.0 or higher. Just in case, the previous version is still around, on a branch marked Radiant-0.8

Let me know if this works and if you run into any issues.

###Installation

To install paperclipped, just run

rake production db:migrate:extensions
rake production radiant:extensions:paperclipped:update

This runs the database migrations and installs the javascripts, images and css.

###Configuration

If you install the Settings Extension (highly recommended), you can also easily adjust both the sizes of any additional thumbnails and which thumbnails are displayed in the image edit view. The default is the original file, but any image size can be used by giving in the name of that size.

If you do install the Settings Extension you should be sure to add a config.extensions line to your environment.rb file:

config.extensions = [ :settings, :all ]

Also the Settings Extension migration should be run before Paperclipped's migration.

The configuration settings also enable a list of the allowed file types, maximum file size and should you need it, the path to your installation of Image Magick (this should not be needed, but I sometimes had a problem when using mod_rails).

Paperclipped will integrate with the Styles'n'Scripts extension. For that to work, you'll need to load that extension before paperclipped:

config.extensions = [ :sns, :all ]

###Using Paperclipped

Once installed, you get a new Tab with the entire assets library, a Bucket Γ  la Mephisto (though only the concept is stolen) and a search. You can also easily attach assets to any page and directly upload them to a page.

###Asset Tags

There are a veriety of new tags. The basic tag is the <r:assets /> tag, which can be used either alone or as a double tag. This tag requires the "title" attribute, which references the asset. If you use the drag and drop from the asset bucket, this title will be added for you.

The <r:assets /> tag can be combined with other tags for a variety of uses:

<r:assets:image title="foo" /> will return <img src="/path/to/foo" alt="foo" />

<r:assets:link title="foo" /> will return <a href="/path/to/foo">foo</a>

You could also use:

<r:assets:link title="foo" text="This is the link to foo" /> will return <a href="/path/to/foo">This is the link to foo</a>

or

<r:assets:link title="foo">This is another link</r:link>

Asset links are also available, such as content_type, file_size, and url.

Another important tag is the <r:assets:each>...</r:assets:each>. If a page has attached assets, the assets:each tag will cycle through each asset. You can then use an image, link or url tag to display or connect your assets. Usage:

<r:assets:each [limit=0] [offset=0] [order="asc|desc"] [by="position|title|..."] [extensions="png|pdf|doc"]>
  ...
</r:assets:each>

<r:assets:each> parameters:

  • limit and offset let you specify a range of assets;
  • order and by lets you control sorting;
  • extensions allows you to filter assets by file extensions; you can specify multiple extensions separated by |.

<r:if_assets [min_count="0"]> and <r:unless_assets [min_count="0"]>

conditional tags let you optionally render content based on the existance of tags. They accept the same options as <r:assets:each>.

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 fit into 100px, maintaining its aspect ratio.

You can access sizes of image assets for various versions with the tags <r:assets:width [size="original"]/> and <r:assets:height [size="original"]/>.

Also, for vertical centering of images, you have the handy <r:assets:top_padding container="<container height>" [size="icon"]/> tag. Working example:

<ul>
  <r:assets:each>
    <li style="height:140px">
      <img style="padding-top:<r:top_padding size='category' container='140' />px" 
           src="<r:url />" alt="<r:title />" />
    </li>
  </r:assets:each>
</ul>

###Using Amazon s3 First, be sure you have the aws-s3 gem installed.

gem install aws-s3

Everything works as before, but now if you want to add S3 support, you simply set the storage setting to "s3".

Radiant::Config[assets.storage] = "s3"

Then add 3 new settings with your Amazon credentials, either in the console or with the Settings extension:

Radiant::Config[assets.s3.bucket] = "my_supercool_bucket"
Radiant::Config[assets.s3.key] = "123456"
Radiant::Config[assets.s3.secret] = "123456789ABCDEF"

and finally the path you want to use within your bucket, which uses the same notation as the Paperclip plugin.

Radiant::Config[assets.path] = :class/:id/:basename_:style.:extension 

The path setting, along with a new url setting can be used with the file system to customize both the path and url of your assets.

Migrating from the page_attachments extension

If you're moving from page_attachments to paperclipped, here's how to migrate smoothly:

First, remove or disable the page_attachments extension, and install the paperclipped extension. For example:

rake ray:dis name=page_attachments
rake ray:assets

The migration has now copied your original page_attachments table to old_page_attachments.

rake radiant:extensions:paperclipped:migrate_from_page_attachments

This rake task will create paperclipped-style attachments for all OldPageAttachments. It will also ask you if you want to clean up the old table and thumbnails in /public/page_attachments.

Done!

More Repositories

1

assets_extension

Radiant Image and Assets Extension
Ruby
11
star
2

admin_tree_structure

Extension for Radiant CMS that sorts children of ArchivePages by year and by month on the backend
Ruby
8
star
3

radiant-paperclipped_multisite-extension

Adds multisite support to paperclipped, showing assets only for the current site if the user is not an admin
Ruby
8
star
4

bkr

The Bitch Kitty Racing CMS
JavaScript
5
star
5

accretejs

Fork and expansion of tmanderson/Accrete.js
JavaScript
5
star
6

flatiron_demo

Flatrion and Node.js demo app
JavaScript
4
star
7

asset_tree

Yet another asset manager for Radiant, but only for the Blade interface and i18n branch
Ruby
4
star
8

highguard

A very nerdy Starship generator for Traveller Highguard ships
Ruby
3
star
9

radiant-jargon-extension

Translation of the Radiant Admin interface using Gibberish
Ruby
3
star
10

websockets-demo

Basic Node.js web socket using Union.js
JavaScript
3
star
11

custom-hooks-intro

A short intro to custom hooks
TypeScript
2
star
12

brewgirls

Brewgirls Gallery
JavaScript
2
star
13

monk_mapper

Monkrb skeleton with MongoMapper, RSpec and Steak
Ruby
2
star
14

pages-skeleton

Monk Skeleton for simple markdown pages
Ruby
2
star
15

image_scraper_demo

JavaScript
2
star
16

flatiron_demo_2

Controller Demo
JavaScript
2
star
17

polyglot-2015-event-driven-lessons

CSS
1
star
18

radiant-page-roles-extension

Adds roles to pages to determine who is allowed to view and edit them
Ruby
1
star
19

html5-course

HTML5 CSS Course
JavaScript
1
star
20

generator-webpack-scaffold

A basic webpack setup with LibSASS and Mocha / Karma tests
JavaScript
1
star
21

virtual-dom-demo

A small demo app with virtual-dom and hogan templates
JavaScript
1
star
22

nightwatch-demo

Demo for testing mobified sites using nightwatch.js
JavaScript
1
star
23

accrete

Fork of a javascript Accrete port
JavaScript
1
star
24

theexpanseapi

A Rust API using Tide for all things regarding The Expanse
TypeScript
1
star
25

verlagcms

Backbone based cms.
JavaScript
1
star
26

functional-exercises

TypeScript
1
star
27

solar-ts

TypeScript
1
star
28

gulp-lodash-compile

A hacky lodash template compiler. It will get better.
JavaScript
1
star
29

typescript-starters

A few demo starters with Typescript
TypeScript
1
star
30

docker-ide

Docker container for node and vim
Vim Script
1
star
31

gravity-ts

TypeScript
1
star
32

full_of_stars

It's full of stars...
JavaScript
1
star