fix assets upload with S3 in production + enhance a couple of things
This commit is contained in:
parent
339d791e7d
commit
28211edad6
@ -41,7 +41,7 @@ class ThemeAsset
|
||||
|
||||
def plain_text
|
||||
@plain_text ||= (if self.stylesheet? || self.javascript?
|
||||
File.read(self.source.path)
|
||||
self.source.read
|
||||
else
|
||||
nil
|
||||
end)
|
||||
@ -63,19 +63,10 @@ class ThemeAsset
|
||||
|
||||
self.source = CarrierWave::SanitizedFile.new({
|
||||
:tempfile => StringIO.new(self.plain_text),
|
||||
:filename => self.filename
|
||||
:filename => "#{self.slug}.#{self.stylesheet? ? 'css' : 'js'}"
|
||||
})
|
||||
end
|
||||
|
||||
def filename
|
||||
if not self.image?
|
||||
# TODO: fix that for handling not image / stylesheets / javascripts assets
|
||||
"#{self.slug}.#{self.stylesheet? ? 'css' : 'js'}"
|
||||
else
|
||||
"#{self.slug}#{File.extname(self.source.file.original_filename)}"
|
||||
end
|
||||
end
|
||||
|
||||
def to_liquid
|
||||
{ :url => self.source.url }.merge(self.attributes)
|
||||
end
|
||||
|
@ -8,6 +8,10 @@ class AssetUploader < CarrierWave::Uploader::Base
|
||||
"sites/#{model.collection.site_id}/assets/#{model.id}"
|
||||
end
|
||||
|
||||
def cache_dir
|
||||
"#{Rails.root}/tmp/uploads"
|
||||
end
|
||||
|
||||
version :thumb do
|
||||
process :resize_to_fill => [50, 50]
|
||||
process :convert => 'png'
|
||||
|
@ -29,14 +29,4 @@ class ThemeAssetUploader < AssetUploader
|
||||
%w(jpg jpeg gif png css js)
|
||||
end
|
||||
|
||||
def filename
|
||||
if model.slug.present?
|
||||
model.filename
|
||||
else
|
||||
extension = File.extname(original_filename)
|
||||
basename = File.basename(original_filename, extension).slugify(:underscore => true)
|
||||
"#{basename}#{extension}"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -10,7 +10,7 @@
|
||||
- elsif field.text?
|
||||
= f.input field._alias.to_sym, :label => field.label, :as => :text
|
||||
|
||||
- if @asset.image?
|
||||
- if @asset.image? && @asset.valid?
|
||||
= f.foldable_inputs :name => "#{t('formtastic.titles.preview')} #{image_dimensions_and_size(@asset)}", :class => 'preview' do
|
||||
%li
|
||||
.image
|
||||
|
@ -7,7 +7,7 @@
|
||||
%ul
|
||||
- current_site.pages.latest_updated.each do |page|
|
||||
%li
|
||||
= link_to truncate(page.title, :length => 40), edit_admin_page_url(page)
|
||||
= link_to truncate(page.title, :length => 30), edit_admin_page_url(page)
|
||||
%span= time_ago_in_words(page.updated_at)
|
||||
|
||||
- current_site.content_types.each do |content_type|
|
||||
@ -20,7 +20,7 @@
|
||||
%ul
|
||||
- content_type.contents.latest_updated.each do |content|
|
||||
%li
|
||||
= link_to truncate(content.send(content_type.highlighted_field_name), :length => 40), edit_admin_content_path(content_type.slug, content)
|
||||
= link_to truncate(content.send(content_type.highlighted_field_name), :length => 30), edit_admin_content_path(content_type.slug, content)
|
||||
%span= time_ago_in_words(content.updated_at)
|
||||
|
||||
.action
|
||||
|
@ -31,5 +31,4 @@ end
|
||||
CarrierWave.configure do |config|
|
||||
config.storage = :file
|
||||
config.root = File.join(Rails.root, 'public')
|
||||
end
|
||||
|
||||
end
|
15
doc/TODO
15
doc/TODO
@ -1,10 +1,8 @@
|
||||
BOARD:
|
||||
|
||||
- deploy on Heroku
|
||||
- observers to add / remove domains
|
||||
- truncate nom dans le menu de contents
|
||||
x comment console.log
|
||||
- missing translation for the edit categories popup
|
||||
- observers to add / remove domains
|
||||
- "field name" for alias / hint for custom fields
|
||||
|
||||
BACKLOG:
|
||||
|
||||
@ -16,7 +14,6 @@ BACKLOG:
|
||||
|
||||
- theme assets: disable version if not image
|
||||
|
||||
- migrate content_instance to its collection
|
||||
- new custom field types
|
||||
- file
|
||||
- boolean
|
||||
@ -125,4 +122,10 @@ x missing translation in english
|
||||
x api security option in content types
|
||||
x password resets (url is not handled correctly)
|
||||
x mongoid hack for nested attributes
|
||||
x convert 2 plugins into gems (mongo_session_store / actionmailer_with_request)
|
||||
x convert 2 plugins into gems (mongo_session_store / actionmailer_with_request)
|
||||
x comment console.log
|
||||
x upload files in S3
|
||||
x [BUG] asset vignette: name + icon not vertically aligned
|
||||
x truncate nom dans le menu de contents
|
||||
x site subdomain regexp [a-z][A-Z][0-9]
|
||||
! migrate content_instance to its own collection => http://www.mongodb.org/display/DOCS/Advanced+Queries#AdvancedQueries-%24sliceoperator
|
@ -1,7 +1,7 @@
|
||||
module Locomotive
|
||||
module Regexps
|
||||
|
||||
SUBDOMAIN = /^[a-z][a-z0-9_]*[a-z0-9]{1}$/
|
||||
SUBDOMAIN = /^[a-z][a-z0-9]*[a-z0-9]{1}$/
|
||||
|
||||
DOMAIN = /^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/ix
|
||||
|
||||
|
@ -121,7 +121,7 @@ ul.assets li.asset h4 { margin: 0px; height: 30px; }
|
||||
|
||||
ul.assets li.asset h4 a {
|
||||
position: relative;
|
||||
top: 0px;
|
||||
top: 6px;
|
||||
left: 12px;
|
||||
font-weight: bold;
|
||||
font-size: 0.6em;
|
||||
@ -149,7 +149,7 @@ ul.assets li.asset div.image div.inside {
|
||||
|
||||
ul.assets li.asset div.actions {
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
top: 7px;
|
||||
right: 12px;
|
||||
}
|
||||
|
||||
|
@ -20,13 +20,13 @@ describe Site do
|
||||
site.errors[:subdomain].should == ["can't be blank"]
|
||||
end
|
||||
|
||||
%w{test foo_bar test42}.each do |subdomain|
|
||||
%w{test test42}.each do |subdomain|
|
||||
it "should accept subdomain like '#{subdomain}'" do
|
||||
Factory.build(:site, :subdomain => subdomain).should be_valid
|
||||
end
|
||||
end
|
||||
|
||||
['-', '_test', 'test_', 't est', '42', '42test'].each do |subdomain|
|
||||
['-', '_test', 'test_', 't est', '42', '42test', 'foo_bar'].each do |subdomain|
|
||||
it "should not accept subdomain like '#{subdomain}'" do
|
||||
(site = Factory.build(:site, :subdomain => subdomain)).should_not be_valid
|
||||
site.errors[:subdomain].should == ['is invalid']
|
||||
|
Loading…
Reference in New Issue
Block a user