diff --git a/app/controllers/admin/api_contents_controller.rb b/app/controllers/admin/api_contents_controller.rb index c2002599..60693a02 100644 --- a/app/controllers/admin/api_contents_controller.rb +++ b/app/controllers/admin/api_contents_controller.rb @@ -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 diff --git a/app/controllers/admin/cross_domain_sessions_controller.rb b/app/controllers/admin/cross_domain_sessions_controller.rb index 9427deae..a33d12be 100644 --- a/app/controllers/admin/cross_domain_sessions_controller.rb +++ b/app/controllers/admin/cross_domain_sessions_controller.rb @@ -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 diff --git a/app/models/asset_collection.rb b/app/models/asset_collection.rb index c733f9eb..7a90363a 100644 --- a/app/models/asset_collection.rb +++ b/app/models/asset_collection.rb @@ -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 diff --git a/app/models/content_type.rb b/app/models/content_type.rb index 1d31aa32..37e848ca 100644 --- a/app/models/content_type.rb +++ b/app/models/content_type.rb @@ -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 diff --git a/app/models/site.rb b/app/models/site.rb index 72dc3533..326429cb 100644 --- a/app/models/site.rb +++ b/app/models/site.rb @@ -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 diff --git a/app/views/admin/current_sites/_form.html.haml b/app/views/admin/current_sites/_form.html.haml index 045f0b8e..7f094e08 100644 --- a/app/views/admin/current_sites/_form.html.haml +++ b/app/views/admin/current_sites/_form.html.haml @@ -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'   = 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'   %span.actions = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove first', :confirm => t('admin.messages.confirm') diff --git a/app/views/admin/imports/new.html.haml b/app/views/admin/imports/new.html.haml index fbed589b..60cb76d5 100644 --- a/app/views/admin/imports/new.html.haml +++ b/app/views/admin/imports/new.html.haml @@ -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 \ No newline at end of file diff --git a/app/views/admin/sites/_form.html.haml b/app/views/admin/sites/_form.html.haml index 147afe02..8f1f86b3 100644 --- a/app/views/admin/sites/_form.html.haml +++ b/app/views/admin/sites/_form.html.haml @@ -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'   = 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'   %span.actions = link_to image_tag('admin/form/icons/trash.png'), '#', :class => 'remove first', :confirm => t('admin.messages.confirm') diff --git a/config/mongoid.yml b/config/mongoid.yml index fa15c2f4..6f8a2978 100644 --- a/config/mongoid.yml +++ b/config/mongoid.yml @@ -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 diff --git a/doc/TODO b/doc/TODO index 83c4d4f2..ab5be540 100644 --- a/doc/TODO +++ b/doc/TODO @@ -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 ?!) \ No newline at end of file +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) diff --git a/lib/locomotive/import/asset_collections.rb b/lib/locomotive/import/asset_collections.rb index 7c36d8c2..3b5f4fa2 100644 --- a/lib/locomotive/import/asset_collections.rb +++ b/lib/locomotive/import/asset_collections.rb @@ -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 diff --git a/lib/locomotive/import/content_types.rb b/lib/locomotive/import/content_types.rb index 7aa3749e..d48febed 100644 --- a/lib/locomotive/import/content_types.rb +++ b/lib/locomotive/import/content_types.rb @@ -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 diff --git a/public/javascripts/admin/asset_collections.js b/public/javascripts/admin/asset_collections.js index 8aba5cbc..0deaa1be 100644 --- a/public/javascripts/admin/asset_collections.js +++ b/public/javascripts/admin/asset_collections.js @@ -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(); diff --git a/public/stylesheets/admin/formtastic_changes.css b/public/stylesheets/admin/formtastic_changes.css index ab6dcdc2..7d254f7d 100644 --- a/public/stylesheets/admin/formtastic_changes.css +++ b/public/stylesheets/admin/formtastic_changes.css @@ -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;