bugs when accessign assets from asset collections in templates + uploader for custom fields was buggy
This commit is contained in:
parent
32f8351889
commit
86ac74e290
@ -32,6 +32,10 @@ class Asset
|
||||
end
|
||||
end
|
||||
|
||||
def site_id # needed by the uploader of custom fields
|
||||
self.collection.site_id
|
||||
end
|
||||
|
||||
def to_liquid
|
||||
Locomotive::Liquid::Drops::Asset.new(self)
|
||||
end
|
||||
|
@ -29,6 +29,10 @@ class ContentInstance
|
||||
|
||||
alias :visible? :_visible?
|
||||
|
||||
def site_id # needed by the uploader of custom fields
|
||||
self.content_type.site_id
|
||||
end
|
||||
|
||||
def visible?
|
||||
self._visible || self._visible.nil?
|
||||
end
|
||||
|
@ -27,11 +27,10 @@ class AssetUploader < CarrierWave::Uploader::Base
|
||||
process :convert => 'png'
|
||||
end
|
||||
|
||||
process :set_content_type
|
||||
process :set_size
|
||||
process :set_width_and_height
|
||||
|
||||
after :cache, :set_size
|
||||
after :cache, :set_content_type
|
||||
|
||||
def set_content_type(*args)
|
||||
value = :other
|
||||
|
||||
|
@ -1,13 +0,0 @@
|
||||
# encoding: utf-8
|
||||
|
||||
class FontUploader < CarrierWave::Uploader::Base
|
||||
|
||||
def store_dir
|
||||
"sites/#{model.id}/theme/fonts"
|
||||
end
|
||||
|
||||
def cache_dir
|
||||
"#{Rails.root}/tmp/uploads"
|
||||
end
|
||||
|
||||
end
|
12
doc/TODO
12
doc/TODO
@ -30,14 +30,16 @@ x snippet dependencies => do not work correctly
|
||||
x exceptions
|
||||
x page to import theme
|
||||
x contents: group_by, oder_by, api_enabled
|
||||
? asset collections
|
||||
? fonts
|
||||
? folders for theme assets
|
||||
? theme assets whitelist
|
||||
x folders for theme assets
|
||||
x theme assets whitelist
|
||||
x fonts
|
||||
x asset collections
|
||||
- add samples ?
|
||||
x mask internal asset_collections
|
||||
- refactor ui for the theme assets page
|
||||
x refactor ui for the theme assets page
|
||||
x fix assets liquid tags / filters
|
||||
- proxy for fonts
|
||||
- fix tests
|
||||
- order yaml file (http://www.ruby-forum.com/topic/120295)
|
||||
- global regions: keyword in editable element (http://www.mongodb.org/display/DOCS/Updating)
|
||||
- write my first tutorial about locomotive
|
||||
|
@ -5,7 +5,8 @@ module CustomFields
|
||||
class FileUploader < ::CarrierWave::Uploader::Base
|
||||
|
||||
def store_dir
|
||||
"sites/#{model.content_type.site_id}/contents/#{model.id}/files"
|
||||
puts
|
||||
"sites/#{model.site_id}/contents/#{model.class.model_name.underscore}/#{model.id}/files"
|
||||
end
|
||||
|
||||
def cache_dir
|
||||
|
@ -11,6 +11,10 @@ module Locomotive
|
||||
end
|
||||
end
|
||||
|
||||
def url
|
||||
@source.source.url
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -5,13 +5,13 @@ module Locomotive
|
||||
class AssetCollections < ::Liquid::Drop
|
||||
|
||||
def before_method(meth)
|
||||
collection = @context.registers[:site].asset_collections.where(:slug => meth.to_s)
|
||||
AssetCollection.new(collection)
|
||||
collection = @context.registers[:site].asset_collections.where(:slug => meth.to_s).first
|
||||
AssetCollectionProxy.new(collection)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class AssetCollection < ::Liquid::Drop
|
||||
class AssetCollectionProxy < ::Liquid::Drop
|
||||
|
||||
def initialize(collection)
|
||||
@collection = collection
|
||||
|
@ -6,9 +6,10 @@ module Locomotive
|
||||
class Base < ::Liquid::Drop
|
||||
|
||||
def before_method(meth)
|
||||
content_type = self.class.name.demodulize.underscore.singularize
|
||||
content_type = self.class.name.demodulize.underscore #.singularize
|
||||
|
||||
asset = ThemeAsset.new(:site => @context.registers[:site], :folder => content_type)
|
||||
|
||||
asset = ThemeAsset.new(:site => @context.registers[:site], :content_type => content_type)
|
||||
'/' + ThemeAssetUploader.new(asset).store_path(meth.gsub('__', '.'))
|
||||
end
|
||||
|
||||
|
@ -7,6 +7,14 @@ module Locomotive
|
||||
# input: url of the css file
|
||||
def stylesheet_tag(input)
|
||||
return '' if input.nil?
|
||||
|
||||
unless input =~ /^(\/|http:)/
|
||||
stylesheet = ThemeAsset.new(:site => @context.registers[:site], :folder => 'stylesheets')
|
||||
input = '/' + ThemeAssetUploader.new(stylesheet).store_path(input)
|
||||
end
|
||||
|
||||
# puts "stylesheet_tag context ? #{@context}"
|
||||
|
||||
input = "#{input}.css" unless input.ends_with?('.css')
|
||||
%{<link href="#{input}" media="screen" rel="stylesheet" type="text/css" />}
|
||||
end
|
||||
@ -15,6 +23,12 @@ module Locomotive
|
||||
# input: url of the javascript file
|
||||
def javascript_tag(input)
|
||||
return '' if input.nil?
|
||||
|
||||
unless input =~ /^(\/|http:)/
|
||||
javascript = ThemeAsset.new(:site => @context.registers[:site], :folder => 'javascripts')
|
||||
input = '/' + ThemeAssetUploader.new(javascript).store_path(input)
|
||||
end
|
||||
|
||||
input = "#{input}.js" unless input.ends_with?('.js')
|
||||
%{<script src="#{input}" type="text/javascript"></script>}
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user