use the right path to the back-office in the js components as well as in the middlewares

This commit is contained in:
did 2012-01-14 14:54:01 +01:00
parent 531017ab62
commit 4060b1859f
16 changed files with 46 additions and 44 deletions

View File

@ -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 GIT
remote: git@github.com:locomotivecms/mongoid_acts_as_tree.git remote: git@github.com:locomotivecms/mongoid_acts_as_tree.git
revision: ca494d22c3d7946385aba1153c017d9c30e9f9d3 revision: ca494d22c3d7946385aba1153c017d9c30e9f9d3
specs: specs:
locomotive_mongoid_acts_as_tree (0.1.5.7) 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 GEM
remote: http://rubygems.org/ remote: http://rubygems.org/
specs: specs:

View File

@ -5,9 +5,9 @@
#= require_tree ./views #= require_tree ./views
window.Locomotive = window.Locomotive =
mount_on: '/locomotive' mounted_on: '/locomotive' # default path
Models: {} Models: {}
Collections: {} Collections: {}
Views: {} Views: {}
window.Locomotive.Views.Memberships = {} window.Locomotive.Views.Memberships = {}

View File

@ -2,10 +2,10 @@ class Locomotive.Models.Account extends Backbone.Model
paramRoot: 'account' paramRoot: 'account'
urlRoot: "#{Locomotive.mount_on}/accounts" urlRoot: "#{Locomotive.mounted_on}/accounts"
class Locomotive.Models.CurrentAccount extends Locomotive.Models.Account class Locomotive.Models.CurrentAccount extends Locomotive.Models.Account
url: "#{Locomotive.mount_on}/my_account" url: "#{Locomotive.mounted_on}/my_account"

View File

@ -2,7 +2,7 @@ class Locomotive.Models.ContentAsset extends Backbone.Model
paramRoot: 'content_asset' paramRoot: 'content_asset'
urlRoot: "#{Locomotive.mount_on}/content_assets" urlRoot: "#{Locomotive.mounted_on}/content_assets"
initialize: -> initialize: ->
@prepare() @prepare()
@ -17,4 +17,4 @@ class Locomotive.Models.ContentAssetsCollection extends Backbone.Collection
model: Locomotive.Models.ContentAsset model: Locomotive.Models.ContentAsset
url: "#{Locomotive.mount_on}/content_assets" url: "#{Locomotive.mounted_on}/content_assets"

View File

@ -2,7 +2,7 @@ class Locomotive.Models.ContentEntry extends Backbone.Model
paramRoot: 'content_entry' paramRoot: 'content_entry'
urlRoot: "#{Locomotive.mount_on}/content_types/:slug/entries" urlRoot: "#{Locomotive.mounted_on}/content_types/:slug/entries"
initialize: -> initialize: ->
@urlRoot = @urlRoot.replace(':slug', @get('content_type_slug')) @urlRoot = @urlRoot.replace(':slug', @get('content_type_slug'))
@ -29,4 +29,4 @@ class Locomotive.Models.ContentEntriesCollection extends Backbone.Collection
model: Locomotive.Models.ContentEntry model: Locomotive.Models.ContentEntry
url: "#{Locomotive.mount_on}/content_types/:slug/entries" url: "#{Locomotive.mounted_on}/content_types/:slug/entries"

View File

@ -2,7 +2,7 @@ class Locomotive.Models.ContentType extends Backbone.Model
paramRoot: 'content_type' paramRoot: 'content_type'
urlRoot: "#{Locomotive.mount_on}/content_types" urlRoot: "#{Locomotive.mounted_on}/content_types"
initialize: -> initialize: ->
@_normalize() @_normalize()
@ -20,4 +20,4 @@ class Locomotive.Models.ContentTypesCollection extends Backbone.Collection
model: Locomotive.Models.ContentType model: Locomotive.Models.ContentType
url: "#{Locomotive.mount_on}/content_types" url: "#{Locomotive.mounted_on}/content_types"

View File

@ -2,7 +2,7 @@ class Locomotive.Models.Page extends Backbone.Model
paramRoot: 'page' paramRoot: 'page'
urlRoot: "#{Locomotive.mount_on}/pages" urlRoot: "#{Locomotive.mounted_on}/pages"
initialize: -> initialize: ->
@_normalize() @_normalize()

View File

@ -2,7 +2,7 @@ class Locomotive.Models.Site extends Backbone.Model
paramRoot: 'site' paramRoot: 'site'
urlRoot: "#{Locomotive.mount_on}/sites" urlRoot: "#{Locomotive.mounted_on}/sites"
initialize: -> initialize: ->
# Be careful, domains_without_subdomain becomes domains # 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 class Locomotive.Models.CurrentSite extends Locomotive.Models.Site
url: "#{Locomotive.mount_on}/current_site" url: "#{Locomotive.mounted_on}/current_site"

View File

@ -2,10 +2,10 @@ class Locomotive.Models.Snippet extends Backbone.Model
paramRoot: 'snippet' paramRoot: 'snippet'
urlRoot: "#{Locomotive.mount_on}/snippets" urlRoot: "#{Locomotive.mounted_on}/snippets"
class Locomotive.Models.SnippetsCollection extends Backbone.Collection class Locomotive.Models.SnippetsCollection extends Backbone.Collection
model: Locomotive.Models.Snippet model: Locomotive.Models.Snippet
url: "#{Locomotive.mount_on}/snippets" url: "#{Locomotive.mounted_on}/snippets"

View File

@ -2,10 +2,10 @@ class Locomotive.Models.ThemeAsset extends Backbone.Model
paramRoot: 'theme_asset' paramRoot: 'theme_asset'
urlRoot: "#{Locomotive.mount_on}/theme_assets" urlRoot: "#{Locomotive.mounted_on}/theme_assets"
class Locomotive.Models.ThemeAssetsCollection extends Backbone.Collection class Locomotive.Models.ThemeAssetsCollection extends Backbone.Collection
model: Locomotive.Models.ThemeAsset model: Locomotive.Models.ThemeAsset
url: "#{Locomotive.mount_on}/theme_assets" url: "#{Locomotive.mounted_on}/theme_assets"

View File

@ -9,12 +9,11 @@ module Locomotive
include Extensions::Asset::Vignette include Extensions::Asset::Vignette
## fields ## ## fields ##
field :content_type, :type => String field :content_type, :type => String
field :width, :type => Integer field :width, :type => Integer
field :height, :type => Integer field :height, :type => Integer
field :size, :type => Integer field :size, :type => Integer
field :position, :type => Integer, :default => 0 field :position, :type => Integer, :default => 0
mount_uploader :source, ContentAssetUploader, :mount_on => :source_filename
## associations ## ## associations ##
belongs_to :site, :class_name => 'Locomotive::Site' belongs_to :site, :class_name => 'Locomotive::Site'
@ -23,6 +22,7 @@ module Locomotive
validates_presence_of :source validates_presence_of :source
## behaviours ## ## behaviours ##
mount_uploader :source, ContentAssetUploader, :mount_on => :source_filename
## methods ## ## methods ##

View File

@ -14,6 +14,7 @@
:plain :plain
window.locale = '#{I18n.locale}'; window.locale = '#{I18n.locale}';
Locomotive.mounted_on = '#{Locomotive.mounted_on}';
Locomotive.current_site = new Locomotive.Models.Site(#{current_site.to_json}); Locomotive.current_site = new Locomotive.Models.Site(#{current_site.to_json});
Locomotive.current_account = new Locomotive.Models.Account(#{current_locomotive_account.to_json}); Locomotive.current_account = new Locomotive.Models.Account(#{current_locomotive_account.to_json});

View File

@ -123,6 +123,10 @@ module Locomotive
self.config.rack_cache != false self.config.rack_cache != false
end end
def self.mounted_on
Rails.application.routes.named_routes[:locomotive].path
end
protected protected
def self.app_middleware def self.app_middleware

View File

@ -5,13 +5,12 @@ module Locomotive
class Cache class Cache
def initialize(app, opts = {}, &block) 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' base_format = url_format.split('/:').first rescue '/images/dynamic'
@regexp = %r{^#{base_format}/} @app = app
@app = app @regexp = %r{^#{base_format}/}
@context = ::Rack::Cache.new(app, opts, &block) @context = ::Rack::Cache.new(app, opts, &block)
end end
def call(env) def call(env)

View File

@ -3,9 +3,9 @@ module Locomotive
class Fonts class Fonts
def initialize(app, opts = {}) def initialize(app, opts = {})
@app = app @app = app
@path_regexp = opts[:path] || %r{^/fonts/} @path_regexp = opts[:path] || %r{^/fonts/}
@expires_in = opts[:expires_in] || 24.hour # varnish @expires_in = opts[:expires_in] || 24.hour # varnish
end end
def call(env) def call(env)

View File

@ -9,7 +9,7 @@ module Locomotive
def call(env) def call(env)
path = env['PATH_INFO'] 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 = Rack::Response.new
response.redirect(match[1], 301) # moved permanently response.redirect(match[1], 301) # moved permanently
response.finish response.finish