preparing mltiple style files
This commit is contained in:
parent
6a9e2182aa
commit
1270c59492
@ -55,7 +55,7 @@ module Merged
|
|||||||
size: (magick_image.size/1024).to_i
|
size: (magick_image.size/1024).to_i
|
||||||
self.insert(image) # assigns next id
|
self.insert(image) # assigns next id
|
||||||
full_filename = image.id.to_s + "." + ending
|
full_filename = image.id.to_s + "." + ending
|
||||||
magick_image.write(Rails.root.join("app/assets/images/cms/", full_filename))
|
magick_image.write(Rails.root.join(Image.asset_root, full_filename))
|
||||||
image
|
image
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ module Merged
|
|||||||
|
|
||||||
def full_filename
|
def full_filename
|
||||||
full_filename = self.id.to_s + "." + self.type
|
full_filename = self.id.to_s + "." + self.type
|
||||||
Rails.root.join(asset_root, full_filename)
|
Rails.root.join(Image.asset_root, full_filename)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.transform
|
def self.transform
|
||||||
@ -98,13 +98,12 @@ module Merged
|
|||||||
self.size = (magick_image.size/1024).to_i
|
self.size = (magick_image.size/1024).to_i
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
def self.asset_root
|
||||||
def asset_root
|
"app/assets/images/" + Merged.images_dir
|
||||||
"app/assets/images/" + image_root
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def image_root
|
def image_root
|
||||||
"cms"
|
Merged.images_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
module Merged
|
module Merged
|
||||||
class OptionDefinition < ActiveBase
|
class OptionDefinition < SharedBase
|
||||||
set_root_path Engine.root + "config"
|
|
||||||
|
|
||||||
fields :name , :default , :description , :values , :type
|
fields :name , :default , :description , :values , :type
|
||||||
|
|
||||||
|
15
app/models/merged/shared_base.rb
Normal file
15
app/models/merged/shared_base.rb
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
module Merged
|
||||||
|
# shared data across engine and app
|
||||||
|
# takes a little footwork, as seen below
|
||||||
|
class SharedBase < ActiveYaml::Base
|
||||||
|
def self.raw_data
|
||||||
|
paths = [ Merged::Engine.root.join("config")]
|
||||||
|
loaded_files = paths.collect do |path|
|
||||||
|
actual_filename = filename || name.tableize
|
||||||
|
full = File.join(path, "#{actual_filename}.#{extension}")
|
||||||
|
load_path(full)
|
||||||
|
end
|
||||||
|
loaded_files.sum
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
@ -1,7 +1,5 @@
|
|||||||
module Merged
|
module Merged
|
||||||
class Style < ActiveBase
|
class Style < SharedBase
|
||||||
|
|
||||||
set_root_path Engine.root + "config"
|
|
||||||
|
|
||||||
fields :options
|
fields :options
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ module Merged
|
|||||||
# and the fact that they persist in ActiveYaml
|
# and the fact that they persist in ActiveYaml
|
||||||
|
|
||||||
class ViewBase < ActiveBase
|
class ViewBase < ActiveBase
|
||||||
set_root_path Rails.root #ouside engines not necessary
|
set_root_path Merged.data_dir
|
||||||
include ActiveHash::Associations
|
include ActiveHash::Associations
|
||||||
|
|
||||||
belongs_to :image , class_name: "Merged::Image"
|
belongs_to :image , class_name: "Merged::Image"
|
||||||
|
Loading…
Reference in New Issue
Block a user