joelw / page_attachments forked from AndrewO/page_attachments
- Source
- Commits
- Network (1)
- Issues (0)
- Downloads (0)
- Wiki (1)
- Graphs
-
Tree:
454eb88
Joel Williams (author)
Sun Jun 01 02:18:20 -0700 2008
page_attachments / page_attachments_extension.rb
| 91e654e6 » | Andrew O'Brien | 2008-02-29 | 1 | require_dependency 'application' | |
| 2 | require File.dirname(__FILE__)+'/lib/geometry' | ||||
| 3 | require 'tempfile' | ||||
| 4 | |||||
| 5 | class PageAttachmentsExtension < Radiant::Extension | ||||
| 6 | version "0.2" | ||||
| 7 | description "Adds page-attachment-style asset management." | ||||
| 8 | url "http://seancribbs.com" | ||||
| 9 | |||||
| 10 | # define_routes do |map| | ||||
| 11 | # map.connect 'admin/attachments/:action/:id', :controller => 'page_attachments' | ||||
| 12 | # end | ||||
| 13 | |||||
| 14 | def activate | ||||
| 15 | # Contents of attachment_fu/init.rb | ||||
| 16 | |||||
| 17 | Tempfile.class_eval do | ||||
| 18 | # overwrite so tempfiles use the extension of the basename. important for rmagick and image science | ||||
| 19 | def make_tmpname(basename, n) | ||||
| 20 | ext = nil | ||||
| 21 | sprintf("%s%d-%d%s", basename.to_s.gsub(/\.\w+$/) { |s| ext = s; '' }, $$, n, ext) | ||||
| 22 | end | ||||
| 23 | end | ||||
| 24 | |||||
| 25 | ActiveRecord::Base.send(:extend, Technoweenie::AttachmentFu::ActMethods) | ||||
| 26 | Technoweenie::AttachmentFu.tempfile_path = ATTACHMENT_FU_TEMPFILE_PATH if Object.const_defined?(:ATTACHMENT_FU_TEMPFILE_PATH) | ||||
| 27 | FileUtils.mkdir_p Technoweenie::AttachmentFu.tempfile_path | ||||
| 28 | |||||
| 29 | # Regular page attachments stuff | ||||
| 30 | Page.class_eval { | ||||
| 31 | include PageAttachmentAssociations | ||||
| 32 | include PageAttachmentTags | ||||
| 33 | } | ||||
| 34 | UserActionObserver.send :include, ObservePageAttachments | ||||
| 35 | Admin::PageController.send :include, PageAttachmentsInterface | ||||
| 36 | end | ||||
| 37 | |||||
| 38 | def deactivate | ||||
| 39 | end | ||||
| 40 | |||||
| 41 | end | ||||
