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
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:

View File

@ -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 = {}

View File

@ -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"

View File

@ -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"
url: "#{Locomotive.mounted_on}/content_assets"

View File

@ -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"
url: "#{Locomotive.mounted_on}/content_types/:slug/entries"

View File

@ -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"
url: "#{Locomotive.mounted_on}/content_types"

View File

@ -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()

View File

@ -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"

View File

@ -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"
url: "#{Locomotive.mounted_on}/snippets"

View File

@ -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"

View File

@ -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 ##

View File

@ -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});

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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