multi source style loading
@ -15,7 +15,7 @@ module Merged
|
|||||||
else
|
else
|
||||||
git = Git.open(Rails.root)
|
git = Git.open(Rails.root)
|
||||||
git.add("merged")
|
git.add("merged")
|
||||||
git.add( Image.root )
|
git.add( Image.asset_root )
|
||||||
begin
|
begin
|
||||||
git.config('user.email', current_member.email)
|
git.config('user.email', current_member.email)
|
||||||
git.commit(params[:message])
|
git.commit(params[:message])
|
||||||
@ -30,8 +30,8 @@ module Merged
|
|||||||
def reset
|
def reset
|
||||||
git = Git.open(Rails.root)
|
git = Git.open(Rails.root)
|
||||||
begin
|
begin
|
||||||
git.checkout_file("HEAD" , "merged")
|
git.checkout_file("HEAD" , Merged.data_dir)
|
||||||
git.checkout_file("HEAD" , "app/assets/images/cms")
|
git.checkout_file("HEAD" , Merged::Image.asset_root)
|
||||||
ChangeSet.current.zero
|
ChangeSet.current.zero
|
||||||
message = "Changes reset"
|
message = "Changes reset"
|
||||||
rescue
|
rescue
|
||||||
|
@ -2,8 +2,8 @@ module Merged
|
|||||||
module ChangesHelper
|
module ChangesHelper
|
||||||
|
|
||||||
def cms_part? name
|
def cms_part? name
|
||||||
return true if name.include?( Image.root )
|
return true if name.include?( Merged.images_dir )
|
||||||
return true if name.include?("merged/")
|
return true if name.include?(Merged.data_dir)
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ module Merged
|
|||||||
end
|
end
|
||||||
|
|
||||||
def asset_name
|
def asset_name
|
||||||
image_root + "/" + self.id.to_s + "." + self.type
|
Merged.images_dir + "/" + self.id.to_s + "." + self.type
|
||||||
end
|
end
|
||||||
|
|
||||||
def full_filename
|
def full_filename
|
||||||
@ -87,10 +87,6 @@ module Merged
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.root
|
|
||||||
"app/assets/images/cms"
|
|
||||||
end
|
|
||||||
|
|
||||||
def init_file_size
|
def init_file_size
|
||||||
magick_image = MiniMagick::Image.open(full_filename)
|
magick_image = MiniMagick::Image.open(full_filename)
|
||||||
self.width = magick_image.width
|
self.width = magick_image.width
|
||||||
@ -102,9 +98,5 @@ module Merged
|
|||||||
"app/assets/images/" + Merged.images_dir
|
"app/assets/images/" + Merged.images_dir
|
||||||
end
|
end
|
||||||
|
|
||||||
def image_root
|
|
||||||
Merged.images_dir
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -3,11 +3,13 @@ module Merged
|
|||||||
# takes a little footwork, as seen below
|
# takes a little footwork, as seen below
|
||||||
class SharedBase < ActiveYaml::Base
|
class SharedBase < ActiveYaml::Base
|
||||||
def self.raw_data
|
def self.raw_data
|
||||||
paths = [ Merged::Engine.root.join("config")]
|
paths = [ Merged::Engine.root.join("config") , Rails.root.join(Merged.data_dir) ]
|
||||||
loaded_files = paths.collect do |path|
|
loaded_files = paths.collect do |path|
|
||||||
actual_filename = filename || name.tableize
|
actual_filename = filename || name.tableize
|
||||||
full = File.join(path, "#{actual_filename}.#{extension}")
|
full = File.join(path, "#{actual_filename}.#{extension}")
|
||||||
load_path(full)
|
got = load_path(full)
|
||||||
|
raise "#{full} contained #{got.class}, not Array" unless got.class == Array
|
||||||
|
got
|
||||||
end
|
end
|
||||||
loaded_files.sum
|
loaded_files.sum
|
||||||
end
|
end
|
||||||
|
@ -1 +1 @@
|
|||||||
---[]
|
--- []
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
require "merged"
|
require "merged"
|
||||||
|
|
||||||
# directory inside /app/assets/images where the images are kept
|
# directory inside /app/assets/images where YOUR images are kept
|
||||||
Merged.images_dir = "cms"
|
# if you change this and add own styles, you will still need a merged directory
|
||||||
|
# for the previews (card_preview and section_preview)
|
||||||
|
Merged.images_dir = "merged"
|
||||||
|
|
||||||
# directory where data and styles are kept
|
# directory where data and styles are kept
|
||||||
# Notice that the data is ALWAYS inside a merged directory,
|
# Notice that the data is ALWAYS inside a merged directory,
|
||||||
|
@ -7,21 +7,8 @@ module Merged
|
|||||||
|
|
||||||
# Directory inside the app/assets/images
|
# Directory inside the app/assets/images
|
||||||
mattr_accessor :images_dir
|
mattr_accessor :images_dir
|
||||||
@@images_dir = "cms"
|
|
||||||
|
|
||||||
# directory in root to store data
|
# directory in root to store data
|
||||||
mattr_accessor :data_dir
|
mattr_accessor :data_dir
|
||||||
@@data_dir = "."
|
|
||||||
|
|
||||||
def self.load_data
|
|
||||||
# pre-load data
|
|
||||||
[OptionDefinition, CardStyle, SectionStyle , PageStyle,
|
|
||||||
Card , Section , Page , Image].each {|clazz| clazz.all }
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.load_from( kind , path )
|
|
||||||
return unless File.exists?(path)
|
|
||||||
clazz = "Merged::#{kind.camelcase}".constantize
|
|
||||||
clazz.load(YAML.load_file( path ))
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
@ -20,7 +20,7 @@ module Merged
|
|||||||
|
|
||||||
initializer "after_initialize" do |app|
|
initializer "after_initialize" do |app|
|
||||||
ActiveSupport::Reloader.to_prepare do
|
ActiveSupport::Reloader.to_prepare do
|
||||||
Merged.load_data
|
Merged::Engine.load_data
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -32,5 +32,17 @@ module Merged
|
|||||||
config.assets.precompile << kid
|
config.assets.precompile << kid
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
def self.load_data
|
||||||
|
# pre-load data
|
||||||
|
[OptionDefinition, CardStyle, SectionStyle , PageStyle,
|
||||||
|
Card , Section , Page , Image].each {|clazz| clazz.all }
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.load_from( kind , path )
|
||||||
|
return unless File.exists?(path)
|
||||||
|
clazz = "Merged::#{kind.camelcase}".constantize
|
||||||
|
clazz.load(YAML.load_file( path ))
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Before Width: | Height: | Size: 260 KiB After Width: | Height: | Size: 260 KiB |
Before Width: | Height: | Size: 211 KiB After Width: | Height: | Size: 211 KiB |
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 98 KiB |
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 40 KiB |
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 129 KiB |
Before Width: | Height: | Size: 246 KiB After Width: | Height: | Size: 246 KiB |
Before Width: | Height: | Size: 137 KiB After Width: | Height: | Size: 137 KiB |
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 82 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 137 KiB After Width: | Height: | Size: 137 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 372 KiB After Width: | Height: | Size: 372 KiB |
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 125 KiB After Width: | Height: | Size: 125 KiB |
Before Width: | Height: | Size: 135 KiB After Width: | Height: | Size: 135 KiB |
9
test/dummy/config/initializers/merged.rb
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
require "merged"
|
||||||
|
|
||||||
|
# directory inside /app/assets/images where the images are kept
|
||||||
|
Merged.images_dir = "merged"
|
||||||
|
|
||||||
|
# directory where data and styles are kept
|
||||||
|
# Notice that the data is ALWAYS inside a merged directory,
|
||||||
|
# so in the default case Rails.root/merged/*.yml
|
||||||
|
Merged.data_dir = "."
|