fix minor issues

This commit is contained in:
dinedine 2010-10-29 16:19:41 +02:00
parent cc0b50e22e
commit 9c77180a63
14 changed files with 98 additions and 50 deletions

View File

@ -32,7 +32,7 @@ module Admin
def set_content_type
@content_type = current_site.content_types.where(:slug => params[:slug]).first
render :json => { :error => 'Api not enabled'} and return false unless @content_type.api_enabled
render :json => { :error => 'Api not enabled' } and return false unless @content_type.api_enabled
end
end

View File

@ -11,7 +11,12 @@ module Admin
def new
if site = current_admin.sites.detect { |s| s._id.to_s == params[:target_id] }
@target = site.domains_without_subdomain.first || site.domains_with_subdomain.first
if Rails.env == 'development'
@target = site.full_subdomain
else
@target = site.domains_without_subdomain.first || site.full_subdomain
end
current_admin.reset_switch_site_token!
else
redirect_to admin_pages_path

View File

@ -18,6 +18,7 @@ class AssetCollection
## callbacks ##
before_validation :normalize_slug
before_save :store_asset_positions!
after_destroy :remove_uploaded_files
## validations ##
validates_presence_of :site, :name, :slug
@ -68,4 +69,13 @@ class AssetCollection
end
end
end
def remove_uploaded_files # callbacks are not called on each asset so we do it manually
self.assets.each do |asset|
self.asset_custom_fields.each do |field|
asset.send(:"remove_#{field._name}!") if field.kind == 'file'
end
end
end
end

View File

@ -25,6 +25,7 @@ class ContentType
## callbacks ##
before_validation :normalize_slug
before_save :set_default_values
after_destroy :remove_uploaded_files
## validations ##
validates_presence_of :site, :name, :slug
@ -102,4 +103,12 @@ class ContentType
self.slug.slugify! if self.slug.present?
end
def remove_uploaded_files # callbacks are not called on each content so we do it manually
self.contents.each do |content|
self.content_custom_fields.each do |field|
content.send(:"remove_#{field._name}!") if field.kind == 'file'
end
end
end
end

View File

@ -50,15 +50,19 @@ class Site
def add_subdomain_to_domains
self.domains ||= []
(self.domains << "#{self.subdomain}.#{Locomotive.config.default_domain}").uniq!
(self.domains << self.full_subdomain).uniq!
end
def domains_without_subdomain
(self.domains || []) - ["#{self.subdomain}.#{Locomotive.config.default_domain}"]
(self.domains || []) - [self.full_subdomain]
end
def domains_with_subdomain
((self.domains || []) + ["#{self.subdomain}.#{Locomotive.config.default_domain}"]).uniq
((self.domains || []) + [self.full_subdomain]).uniq
end
def full_subdomain
"#{self.subdomain}.#{Locomotive.config.default_domain}"
end
def to_liquid

View File

@ -23,7 +23,7 @@
%li{ :class => "item added #{'last' if index == @site.domains.size - 1}"}
%em
http://
= text_field_tag 'current_site[domains][]', name
= text_field_tag 'current_site[domains][]', name, :class => 'string label void domain'
&nbsp;
= error_on_domain(@site, name)
%span.actions
@ -32,7 +32,7 @@
%li.item.template
%em
http://
= text_field_tag 'label', t('formtastic.hints.site.domain_name'), :class => 'string label void'
= text_field_tag 'label', t('formtastic.hints.site.domain_name'), :class => 'string label void domain'
&nbsp;
%span.actions
= link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove first', :confirm => t('admin.messages.confirm')

View File

@ -18,4 +18,15 @@
%p.inline-errors= @error
%p.inline-hints= t('formtastic.hints.import.source')
%li.input
= label_tag 'samples', t('formtastic.labels.import.new.samples')
= check_box_tag 'samples'
%p.inline-hints= t('formtastic.hints.import.samples')
%li.input
= label_tag 'reset', t('formtastic.labels.import.new.reset')
= check_box_tag 'reset'
%p.inline-hints= t('formtastic.hints.import.reset')
= render 'admin/shared/form_actions', :button_label => :send

View File

@ -18,7 +18,7 @@
%li{ :class => "item added #{'last' if index == @site.domains.size - 1}"}
%em
http://
= text_field_tag 'site[domains][]', name
= text_field_tag 'site[domains][]', name, :class => 'string label void domain'
&nbsp;
= error_on_domain(@site, name)
%span.actions
@ -27,7 +27,7 @@
%li.item.template
%em
http://
= text_field_tag 'label', t('formtastic.hints.site.domain_name'), :class => 'string label void'
= text_field_tag 'label', t('formtastic.hints.site.domain_name'), :class => 'string label void domain'
&nbsp;
%span.actions
= link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove first', :confirm => t('admin.messages.confirm')

View File

@ -8,9 +8,11 @@ defaults: &defaults
development:
<<: *defaults
database: locomotive_dev_tmp
database: locomotive_dev
# database: locomotive_dev_tmp
# database: locomotive_hosting_production
test:
<<: *defaults
database: locomotive_test

View File

@ -5,24 +5,9 @@ BOARD:
- editable elements should wrap a tag: div, h1, ...etc (default span)
- edit images (upload new ones, ...etc) => wait for aloha or send them an email ?
x import tool:
x asset whitelist
x do not override existing site name
x add samples option
x content types
x asset collections
x page templatized (tied to content type)
x remove existing pages / contents option => reset
- cosmetic / ui bugs / bugs:
x segmentation with with_scope
x paginate is not working
- assets within custom contents are not deleted when the whole content type gets destroyed (after_destroy callback ?)
- increase the input field for domain names
- drag&drop for assets ('last' class issue)
x api
x handle html request (for now, it's just json)
- import tools
- give choice to reset site / add samples
- french translatations
- refactor slugify method (use parameterize + create a module)
- [content types] the "display column" selector should not include file types
@ -30,16 +15,6 @@ x api
- global regions: keyword in editable element (http://www.mongodb.org/display/DOCS/Updating)
- write my first tutorial about locomotive
x installation guide
x detect if new installation
x no-site error redirects to the first step
x steps:
x welcome: domains, ...etc
x Create account
x Create new site (name, subdomain) / Import theme (worker or list of sites from fs)
! add dom_id and css_class fields in page (body structure ?)
BACKLOG:
- notify accounts when new instance of models (opt): none, one or many accounts. Used for contact form.
@ -159,4 +134,28 @@ x import tool:
x fonts
x asset collections
x rewrite the unzip process (for the import)
x bug with asset collections (assets disappear if we save the collection ?!)
x bug with asset collections (assets disappear if we save the collection ?!)
x import tool:
x asset whitelist
x do not override existing site name
x add samples option
x content types
x asset collections
x page templatized (tied to content type)
x remove existing pages / contents option => reset
x cosmetic / ui bugs / bugs:
x segmentation fault with with_scope
x paginate is not working
x redirection in dev does not work correctly for cross domain
x drag&drop for assets ('last' class issue)
x increase the input field width for domain names
x assets within custom contents are not deleted when the whole content type gets destroyed (after_destroy callback ?)
x api
x handle html request (for now, it's just json)
x installation guide
x detect if new installation
x no-site error redirects to the first step
x steps:
x welcome: domains, ...etc
x Create account
x Create new site (name, subdomain) / Import theme (worker or list of sites from fs)

View File

@ -17,7 +17,7 @@ module Locomotive
self.add_or_update_fields(asset_collection, attributes['fields'])
if options[:samples] && attributes['assets']
self.insert_samples(asset_collection, attributes['assets'].symbolize_keys)
self.insert_samples(asset_collection, attributes['assets'])
end
asset_collection.save!
@ -59,7 +59,7 @@ module Locomotive
url = attributes.delete('url')
# build with default attributes
asset = asset_collection.assets.build(:name => value, :position => position, :url => self.open_sample_asset(url))
asset = asset_collection.assets.build(:name => value, :position => position, :source => self.open_sample_asset(url))
attributes.each do |name, value|
field = asset_collection.asset_custom_fields.detect { |f| f._alias == name }
@ -76,7 +76,7 @@ module Locomotive
asset.save
self.log "insert asset '#{name}'"
self.log "insert asset '#{asset.name}'"
end
end

View File

@ -82,7 +82,7 @@ module Locomotive
content.save
self.log "insert content '#{value}'"
self.log "insert content '#{content.send(content_type.highlighted_field_name.to_sym)}'"
end
end

View File

@ -24,9 +24,18 @@ $(document).ready(function() {
$('#asset_collection_assets_order').val(ids || '');
}
var setLastClassForAssets = function() {
$('ul.assets li.last').removeClass('last');
var i = parseInt($('ul.assets li.asset').size() / 6);
while (i > 0) {
$('ul.assets li.asset:eq(' + (i * 6 - 1) + ')').addClass('last');
i--;
}
}
$('ul.assets.sortable').sortable({
items: 'li.asset',
stop: function(event, ui) { updateAssetsOrder(); }
stop: function(event, ui) { updateAssetsOrder(); setLastClassForAssets(); }
});
$('ul.assets.sortable li div.actions a.remove').click(function(e) {
@ -37,12 +46,7 @@ $(document).ready(function() {
if ($('ul.assets li.asset').size() == 0) $('p.no-items').show();
$('ul.assets li.last').removeClass('last');
var i = parseInt($('ul.assets li.asset').size() / 6);
while (i > 0) {
$('ul.assets li.asset:eq(' + (i * 6 - 1) + ')').addClass('last');
i--;
}
setLastClassForAssets();
}
e.preventDefault();
e.stopPropagation();

View File

@ -299,6 +299,10 @@ form.formtastic fieldset.editable-list ol li.added input {
cursor: pointer;
}
form.formtastic fieldset.editable-list ol li.added input.domain {
width: 250px;
}
form.formtastic fieldset.editable-list ol li.added input:hover {
background: #fffbe5;
border: 1px dotted #efe4a5;