diff --git a/Gemfile.lock b/Gemfile.lock index e29773ac..f5fc6b76 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,19 +1,17 @@ -GIT - remote: git://github.com/locomotivecms/custom_fields.git - revision: b187a16acbf581b4eef857d2958a69422407a047 - branch: experimental - specs: - custom_fields (2.0.0.rc1) - activesupport (~> 3.1.3) - carrierwave-mongoid (~> 0.1.3) - mongoid (~> 2.4.0) - GIT remote: git@github.com:locomotivecms/mongoid_acts_as_tree.git revision: ca494d22c3d7946385aba1153c017d9c30e9f9d3 specs: locomotive_mongoid_acts_as_tree (0.1.5.7) +PATH + remote: ../gems/custom_fields + specs: + custom_fields (2.0.0.rc1) + activesupport (~> 3.1.3) + carrierwave-mongoid (~> 0.1.3) + mongoid (~> 2.4.0) + GEM remote: http://rubygems.org/ specs: diff --git a/app/assets/javascripts/locomotive/application.js.coffee b/app/assets/javascripts/locomotive/application.js.coffee index 57bdc3fd..2930b9e8 100644 --- a/app/assets/javascripts/locomotive/application.js.coffee +++ b/app/assets/javascripts/locomotive/application.js.coffee @@ -5,9 +5,9 @@ #= require_tree ./views window.Locomotive = - mount_on: '/locomotive' - Models: {} - Collections: {} - Views: {} + mounted_on: '/locomotive' # default path + Models: {} + Collections: {} + Views: {} window.Locomotive.Views.Memberships = {} \ No newline at end of file diff --git a/app/assets/javascripts/locomotive/models/account.js.coffee b/app/assets/javascripts/locomotive/models/account.js.coffee index 563a911b..29b09fb0 100644 --- a/app/assets/javascripts/locomotive/models/account.js.coffee +++ b/app/assets/javascripts/locomotive/models/account.js.coffee @@ -2,10 +2,10 @@ class Locomotive.Models.Account extends Backbone.Model paramRoot: 'account' - urlRoot: "#{Locomotive.mount_on}/accounts" + urlRoot: "#{Locomotive.mounted_on}/accounts" class Locomotive.Models.CurrentAccount extends Locomotive.Models.Account - url: "#{Locomotive.mount_on}/my_account" + url: "#{Locomotive.mounted_on}/my_account" diff --git a/app/assets/javascripts/locomotive/models/content_asset.js.coffee b/app/assets/javascripts/locomotive/models/content_asset.js.coffee index 69e752dd..6fce2b11 100644 --- a/app/assets/javascripts/locomotive/models/content_asset.js.coffee +++ b/app/assets/javascripts/locomotive/models/content_asset.js.coffee @@ -2,7 +2,7 @@ class Locomotive.Models.ContentAsset extends Backbone.Model paramRoot: 'content_asset' - urlRoot: "#{Locomotive.mount_on}/content_assets" + urlRoot: "#{Locomotive.mounted_on}/content_assets" initialize: -> @prepare() @@ -17,4 +17,4 @@ class Locomotive.Models.ContentAssetsCollection extends Backbone.Collection model: Locomotive.Models.ContentAsset - url: "#{Locomotive.mount_on}/content_assets" \ No newline at end of file + url: "#{Locomotive.mounted_on}/content_assets" \ No newline at end of file diff --git a/app/assets/javascripts/locomotive/models/content_entry.js.coffee b/app/assets/javascripts/locomotive/models/content_entry.js.coffee index 6df3ada1..e247ce73 100644 --- a/app/assets/javascripts/locomotive/models/content_entry.js.coffee +++ b/app/assets/javascripts/locomotive/models/content_entry.js.coffee @@ -2,7 +2,7 @@ class Locomotive.Models.ContentEntry extends Backbone.Model paramRoot: 'content_entry' - urlRoot: "#{Locomotive.mount_on}/content_types/:slug/entries" + urlRoot: "#{Locomotive.mounted_on}/content_types/:slug/entries" initialize: -> @urlRoot = @urlRoot.replace(':slug', @get('content_type_slug')) @@ -29,4 +29,4 @@ class Locomotive.Models.ContentEntriesCollection extends Backbone.Collection model: Locomotive.Models.ContentEntry - url: "#{Locomotive.mount_on}/content_types/:slug/entries" \ No newline at end of file + url: "#{Locomotive.mounted_on}/content_types/:slug/entries" \ No newline at end of file diff --git a/app/assets/javascripts/locomotive/models/content_type.js.coffee b/app/assets/javascripts/locomotive/models/content_type.js.coffee index 7a049279..5bfdd3dc 100644 --- a/app/assets/javascripts/locomotive/models/content_type.js.coffee +++ b/app/assets/javascripts/locomotive/models/content_type.js.coffee @@ -2,7 +2,7 @@ class Locomotive.Models.ContentType extends Backbone.Model paramRoot: 'content_type' - urlRoot: "#{Locomotive.mount_on}/content_types" + urlRoot: "#{Locomotive.mounted_on}/content_types" initialize: -> @_normalize() @@ -20,4 +20,4 @@ class Locomotive.Models.ContentTypesCollection extends Backbone.Collection model: Locomotive.Models.ContentType - url: "#{Locomotive.mount_on}/content_types" \ No newline at end of file + url: "#{Locomotive.mounted_on}/content_types" \ No newline at end of file diff --git a/app/assets/javascripts/locomotive/models/page.js.coffee b/app/assets/javascripts/locomotive/models/page.js.coffee index b60dbfbd..f833f93d 100644 --- a/app/assets/javascripts/locomotive/models/page.js.coffee +++ b/app/assets/javascripts/locomotive/models/page.js.coffee @@ -2,7 +2,7 @@ class Locomotive.Models.Page extends Backbone.Model paramRoot: 'page' - urlRoot: "#{Locomotive.mount_on}/pages" + urlRoot: "#{Locomotive.mounted_on}/pages" initialize: -> @_normalize() diff --git a/app/assets/javascripts/locomotive/models/site.js.coffee b/app/assets/javascripts/locomotive/models/site.js.coffee index 41bdb14a..b0af198f 100644 --- a/app/assets/javascripts/locomotive/models/site.js.coffee +++ b/app/assets/javascripts/locomotive/models/site.js.coffee @@ -2,7 +2,7 @@ class Locomotive.Models.Site extends Backbone.Model paramRoot: 'site' - urlRoot: "#{Locomotive.mount_on}/sites" + urlRoot: "#{Locomotive.mounted_on}/sites" initialize: -> # Be careful, domains_without_subdomain becomes domains @@ -26,6 +26,6 @@ class Locomotive.Models.Site extends Backbone.Model class Locomotive.Models.CurrentSite extends Locomotive.Models.Site - url: "#{Locomotive.mount_on}/current_site" + url: "#{Locomotive.mounted_on}/current_site" diff --git a/app/assets/javascripts/locomotive/models/snippet.js.coffee b/app/assets/javascripts/locomotive/models/snippet.js.coffee index 5cfe3766..4b41e5d1 100644 --- a/app/assets/javascripts/locomotive/models/snippet.js.coffee +++ b/app/assets/javascripts/locomotive/models/snippet.js.coffee @@ -2,10 +2,10 @@ class Locomotive.Models.Snippet extends Backbone.Model paramRoot: 'snippet' - urlRoot: "#{Locomotive.mount_on}/snippets" + urlRoot: "#{Locomotive.mounted_on}/snippets" class Locomotive.Models.SnippetsCollection extends Backbone.Collection model: Locomotive.Models.Snippet - url: "#{Locomotive.mount_on}/snippets" \ No newline at end of file + url: "#{Locomotive.mounted_on}/snippets" \ No newline at end of file diff --git a/app/assets/javascripts/locomotive/models/theme_asset.js.coffee b/app/assets/javascripts/locomotive/models/theme_asset.js.coffee index f4c7b8ad..9cfaf634 100644 --- a/app/assets/javascripts/locomotive/models/theme_asset.js.coffee +++ b/app/assets/javascripts/locomotive/models/theme_asset.js.coffee @@ -2,10 +2,10 @@ class Locomotive.Models.ThemeAsset extends Backbone.Model paramRoot: 'theme_asset' - urlRoot: "#{Locomotive.mount_on}/theme_assets" + urlRoot: "#{Locomotive.mounted_on}/theme_assets" class Locomotive.Models.ThemeAssetsCollection extends Backbone.Collection model: Locomotive.Models.ThemeAsset - url: "#{Locomotive.mount_on}/theme_assets" + url: "#{Locomotive.mounted_on}/theme_assets" diff --git a/app/models/locomotive/content_asset.rb b/app/models/locomotive/content_asset.rb index 0ea02737..84184dcc 100644 --- a/app/models/locomotive/content_asset.rb +++ b/app/models/locomotive/content_asset.rb @@ -9,12 +9,11 @@ module Locomotive include Extensions::Asset::Vignette ## fields ## - field :content_type, :type => String - field :width, :type => Integer - field :height, :type => Integer - field :size, :type => Integer - field :position, :type => Integer, :default => 0 - mount_uploader :source, ContentAssetUploader, :mount_on => :source_filename + field :content_type, :type => String + field :width, :type => Integer + field :height, :type => Integer + field :size, :type => Integer + field :position, :type => Integer, :default => 0 ## associations ## belongs_to :site, :class_name => 'Locomotive::Site' @@ -23,6 +22,7 @@ module Locomotive validates_presence_of :source ## behaviours ## + mount_uploader :source, ContentAssetUploader, :mount_on => :source_filename ## methods ## diff --git a/app/views/locomotive/shared/_head.html.haml b/app/views/locomotive/shared/_head.html.haml index 473a386f..b3498c2b 100644 --- a/app/views/locomotive/shared/_head.html.haml +++ b/app/views/locomotive/shared/_head.html.haml @@ -14,6 +14,7 @@ :plain window.locale = '#{I18n.locale}'; + Locomotive.mounted_on = '#{Locomotive.mounted_on}'; Locomotive.current_site = new Locomotive.Models.Site(#{current_site.to_json}); Locomotive.current_account = new Locomotive.Models.Account(#{current_locomotive_account.to_json}); diff --git a/lib/locomotive.rb b/lib/locomotive.rb index 7cad1332..4cb31700 100644 --- a/lib/locomotive.rb +++ b/lib/locomotive.rb @@ -123,6 +123,10 @@ module Locomotive self.config.rack_cache != false end + def self.mounted_on + Rails.application.routes.named_routes[:locomotive].path + end + protected def self.app_middleware diff --git a/lib/locomotive/middlewares/cache.rb b/lib/locomotive/middlewares/cache.rb index 3104ea95..c82f804a 100644 --- a/lib/locomotive/middlewares/cache.rb +++ b/lib/locomotive/middlewares/cache.rb @@ -5,13 +5,12 @@ module Locomotive class Cache def initialize(app, opts = {}, &block) - url_format = Locomotive::Dragonfly.app.configuration[:url_format] - + url_format = Locomotive::Dragonfly.app.configuration[:url_format] base_format = url_format.split('/:').first rescue '/images/dynamic' - @regexp = %r{^#{base_format}/} - @app = app - @context = ::Rack::Cache.new(app, opts, &block) + @app = app + @regexp = %r{^#{base_format}/} + @context = ::Rack::Cache.new(app, opts, &block) end def call(env) diff --git a/lib/locomotive/middlewares/fonts.rb b/lib/locomotive/middlewares/fonts.rb index 05c22e62..76e6c54a 100644 --- a/lib/locomotive/middlewares/fonts.rb +++ b/lib/locomotive/middlewares/fonts.rb @@ -3,9 +3,9 @@ module Locomotive class Fonts def initialize(app, opts = {}) - @app = app - @path_regexp = opts[:path] || %r{^/fonts/} - @expires_in = opts[:expires_in] || 24.hour # varnish + @app = app + @path_regexp = opts[:path] || %r{^/fonts/} + @expires_in = opts[:expires_in] || 24.hour # varnish end def call(env) diff --git a/lib/locomotive/middlewares/seo_trailing_slash.rb b/lib/locomotive/middlewares/seo_trailing_slash.rb index ec01afa6..b0cfcd0a 100644 --- a/lib/locomotive/middlewares/seo_trailing_slash.rb +++ b/lib/locomotive/middlewares/seo_trailing_slash.rb @@ -9,7 +9,7 @@ module Locomotive def call(env) path = env['PATH_INFO'] - if !path.starts_with?('/admin/') && (match = path.match(%r{(.+)/$})) + if !path.starts_with?("/#{Locomotive.mounted_on}/") && (match = path.match(%r{(.+)/$})) response = Rack::Response.new response.redirect(match[1], 301) # moved permanently response.finish