On Fri, Apr 23, 2010 at 7:06 PM, Ola Tuvesson <o...@mikrogroove.com> wrote:
> Hello all,
>
> I'm a new Raidant user (only on my second site using it) and fairly
> new to RoR (about six months experience) so please be gentle ;)
>
> The site I'm currently working on is for a tiny netlabel (2-3 releases
> per year) and I've opted to use Radiant as a CMS for the whole site.
> I'm using paperclipped to store the tracks on a release as page
> attachements which works quite nicely - it allows reordering,
> including the same track on multiple releases, replacing the audio
> files easily and simple rendering of the track list on each release.
> But there's one thing I need to work out which no doubt will involve
> some extending of paperclipped and/or Radiant; the tracks on a release
> should be downloadable as a ZIP file...
>
> I have nginx set up with the mod_zip extension and I understand I need
> to pass it a string with file names etc as well as set a couple of
> response headers. I believe this is best done as a method in the asset
> class but I'm a bit lost as to where to start. Should I add this as a
> Radiant extension? I've looked at the "Adding Custom Radius Tags"
> tutorial which I understand to some extent but I suppose I need to add
> a new method from which the response can be generated rather than a
> new tag. Any suggestions to help get me started are very welcome!
>
> Many thanks,
>
> Ola

You can create an extension which you load after paperclipped and
alter the Asset class with Asset.class_eval { ...your code... }
This would allow you to easily keep paperclipped up to date and only
make changes in your own extension.

Just be sure to load paperclipped before your custom extension in
config/environment.rb

config.extensions = [:paperclipped, :your_extension, :all ]

I'm not familiar with mod_zip but you could create a controller in
your extension that responds to some route such as
yoursite.com/zip/..some_asset_id...
If you want a custom tag for Page or some page class just use the
method you add to Asset in the tag:

tag 'zippy' do |tag|
  Asset.find(tag.attr['asset_id']).your_method # or whatever you need
end
This would give you a tag that would allow you to do <r:zippy asset_id="1234" />

Perhaps that could output a link to the URL for your custom controller
(or whatever you need).

I don't really have a clear idea of what you want to do, but hopefully
that helps.

-- 
Jim Gay
http://www.saturnflyer.com
_______________________________________________
Radiant mailing list
Post: Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
List Site: http://lists.radiantcms.org/mailman/listinfo/radiant
Radiant: http://radiantcms.org
Extensions: http://ext.radiantcms.org

Reply via email to