|
Revision 732, 1.3 kB
(checked in by seancribbs, 7 months ago)
|
Import page_attachments into the Radiant repository.
|
| Line | |
|---|
| 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() { |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 |
|---|