change the location url for the API responses + force the use of the default site locale when creating a new entry, content type or page
This commit is contained in:
parent
192518d258
commit
b5fa2c761a
4
Gemfile
4
Gemfile
@ -13,8 +13,8 @@ gem 'mongo', '~> 1.5.2'
|
|||||||
gem 'bson_ext', '~> 1.5.2'
|
gem 'bson_ext', '~> 1.5.2'
|
||||||
gem 'mongoid', '~> 2.4.2'
|
gem 'mongoid', '~> 2.4.2'
|
||||||
gem 'locomotive_mongoid_acts_as_tree', '~> 0.1.5.8'
|
gem 'locomotive_mongoid_acts_as_tree', '~> 0.1.5.8'
|
||||||
# gem 'custom_fields', :path => '../gems/custom_fields' # DEV
|
gem 'custom_fields', :path => '../gems/custom_fields' # DEV
|
||||||
gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git', :branch => '2.0.0.rc'
|
# gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git', :branch => '2.0.0.rc'
|
||||||
gem 'kaminari'
|
gem 'kaminari'
|
||||||
|
|
||||||
gem 'haml', '~> 3.1.3'
|
gem 'haml', '~> 3.1.3'
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
GIT
|
PATH
|
||||||
remote: git://github.com/locomotivecms/custom_fields.git
|
remote: ../gems/custom_fields
|
||||||
revision: 65c451abfc849dd665a556c68c8976c405e57b10
|
|
||||||
branch: 2.0.0.rc
|
|
||||||
specs:
|
specs:
|
||||||
custom_fields (2.0.0.rc2)
|
custom_fields (2.0.0.rc2)
|
||||||
activesupport (~> 3.1.3)
|
activesupport (~> 3.1.3)
|
||||||
|
@ -9,13 +9,13 @@ module Locomotive
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@content_asset = current_site.content_assets.create(params[:content_asset])
|
@content_asset = current_site.content_assets.create(params[:content_asset])
|
||||||
respond_with @content_asset, :location => locomotive_api_content_asset_url(@content_asset._id)
|
respond_with @content_asset, :location => main_app.locomotive_api_content_assets_url
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@content_asset = current_site.content_assets.find(params[:id])
|
@content_asset = current_site.content_assets.find(params[:id])
|
||||||
@content_asset.update_attributes(params[:content_asset])
|
@content_asset.update_attributes(params[:content_asset])
|
||||||
respond_with @content_asset, :location => locomotive_api_content_asset_url(@content_asset._id)
|
respond_with @content_asset, :location => main_app.locomotive_api_content_assets_url
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -11,19 +11,19 @@ module Locomotive
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@content_entry = @content_type.entries.create(params[:content_entry])
|
@content_entry = @content_type.entries.create(params[:content_entry])
|
||||||
respond_with @content_entry, :location => edit_locomotive_api_content_entry_url(@content_type.slug, @content_entry._id)
|
respond_with @content_entry, :location => main_app.locomotive_api_content_entries_url(@content_type.slug)
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@content_entry = @content_type.entries.find(params[:id])
|
@content_entry = @content_type.entries.find(params[:id])
|
||||||
@content_entry.update_attributes(params[:content_entry])
|
@content_entry.update_attributes(params[:content_entry])
|
||||||
respond_with @content_entry, :location => edit_locomotive_api_content_entry_url(@content_type.slug, @content_entry._id)
|
respond_with @content_entry, :location => main_app.locomotive_api_content_entries_url(@content_type.slug)
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@content_entry = @content_type.entries.find(params[:id])
|
@content_entry = @content_type.entries.find(params[:id])
|
||||||
@content_entry.destroy
|
@content_entry.destroy
|
||||||
respond_with @content_entry, :location => locomotive_api_content_entries_url(@content_type.slug)
|
respond_with @content_entry, :location => main_app.locomotive_api_content_entries_url(@content_type.slug)
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
@ -9,18 +9,13 @@ module Locomotive
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@content_type = current_site.content_types.create(params[:content_type])
|
@content_type = current_site.content_types.create(params[:content_type])
|
||||||
respond_with @content_type, :location => edit_locomotive_api_content_type_url(@content_type._id)
|
respond_with @content_type, :location => main_app.locomotive_api_content_types_url
|
||||||
end
|
|
||||||
|
|
||||||
def edit
|
|
||||||
@content_type = current_site.content_types.find(params[:id])
|
|
||||||
respond_with @content_type
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@content_type = current_site.content_types.find(params[:id])
|
@content_type = current_site.content_types.find(params[:id])
|
||||||
@content_type.update_attributes(params[:content_type])
|
@content_type.update_attributes(params[:content_type])
|
||||||
respond_with @content_type, :location => edit_locomotive_api_content_type_url(@content_type._id)
|
respond_with @content_type, :location => main_app.locomotive_api_content_types_url
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -9,13 +9,13 @@ module Locomotive
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@page = current_site.pages.create(params[:page])
|
@page = current_site.pages.create(params[:page])
|
||||||
respond_with @page, :location => edit_locomotive_api_page_url(@page._id)
|
respond_with @page, :location => main_app.locomotive_api_pages_url
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@page = current_site.pages.find(params[:id])
|
@page = current_site.pages.find(params[:id])
|
||||||
@page.update_attributes(params[:page])
|
@page.update_attributes(params[:page])
|
||||||
respond_with @page, :location => edit_locomotive_api_page_url(@page._id)
|
respond_with @page, :location => main_app.locomotive_api_pages_url
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -9,13 +9,13 @@ module Locomotive
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@snippet = current_site.snippets.create(params[:snippet])
|
@snippet = current_site.snippets.create(params[:snippet])
|
||||||
respond_with @snippet, :location => edit_locomotive_api_snippet_url(@snippet._id)
|
respond_with @snippet, :location => main_app.locomotive_api_snippets_url
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@snippet = current_site.snippets.find(params[:id])
|
@snippet = current_site.snippets.find(params[:id])
|
||||||
@snippet.update_attributes(params[:snippet])
|
@snippet.update_attributes(params[:snippet])
|
||||||
respond_with @snippet, :location => edit_locomotive_api_snippet_url(@snippet._id)
|
respond_with @snippet, :location => main_app.locomotive_api_snippets_url
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -9,13 +9,13 @@ module Locomotive
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
@theme_asset = current_site.theme_assets.create(params[:theme_asset])
|
@theme_asset = current_site.theme_assets.create(params[:theme_asset])
|
||||||
respond_with @theme_asset, :location => edit_locomotive_api_theme_asset_url(@theme_asset._id)
|
respond_with @theme_asset, :location => main_app.locomotive_api_theme_assets_url
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@theme_asset = current_site.theme_assets.find(params[:id])
|
@theme_asset = current_site.theme_assets.find(params[:id])
|
||||||
@theme_asset.update_attributes(params[:theme_asset])
|
@theme_asset.update_attributes(params[:theme_asset])
|
||||||
respond_with @theme_asset, :location => edit_locomotive_api_theme_asset_url(@theme_asset._id)
|
respond_with @theme_asset, :location => main_app.locomotive_api_theme_assets_url
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -3,6 +3,8 @@ module Locomotive
|
|||||||
|
|
||||||
sections 'contents'
|
sections 'contents'
|
||||||
|
|
||||||
|
before_filter :back_to_default_site_locale, :only => %w(new create)
|
||||||
|
|
||||||
before_filter :set_content_type
|
before_filter :set_content_type
|
||||||
|
|
||||||
respond_to :json, :only => [:edit, :create, :update, :sort]
|
respond_to :json, :only => [:edit, :create, :update, :sort]
|
||||||
|
@ -3,6 +3,8 @@ module Locomotive
|
|||||||
|
|
||||||
sections 'contents'
|
sections 'contents'
|
||||||
|
|
||||||
|
before_filter :back_to_default_site_locale, :only => %w(new create)
|
||||||
|
|
||||||
respond_to :json, :only => [:create, :update, :destroy]
|
respond_to :json, :only => [:create, :update, :destroy]
|
||||||
|
|
||||||
helper 'Locomotive::Accounts', 'Locomotive::CustomFields'
|
helper 'Locomotive::Accounts', 'Locomotive::CustomFields'
|
||||||
|
@ -29,9 +29,9 @@ module Locomotive
|
|||||||
if account = Account.find_using_switch_site_token(params[:token])
|
if account = Account.find_using_switch_site_token(params[:token])
|
||||||
account.reset_switch_site_token!
|
account.reset_switch_site_token!
|
||||||
sign_in(account)
|
sign_in(account)
|
||||||
redirect_to admin_pages_path
|
redirect_to pages_path
|
||||||
else
|
else
|
||||||
redirect_to new_admin_session_path, :alert => t('flash.locomotive.cross_domain_sessions.create.alert')
|
redirect_to new_locomotive_account_session_path, :alert => t('flash.locomotive.cross_domain_sessions.create.alert')
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -3,6 +3,8 @@ module Locomotive
|
|||||||
|
|
||||||
sections 'contents'
|
sections 'contents'
|
||||||
|
|
||||||
|
before_filter :back_to_default_site_locale, :only => %w(new create)
|
||||||
|
|
||||||
respond_to :json, :only => [:show, :create, :update, :sort, :get_path]
|
respond_to :json, :only => [:show, :create, :update, :sort, :get_path]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@ -7,6 +7,8 @@ module Locomotive
|
|||||||
|
|
||||||
before_filter :require_site
|
before_filter :require_site
|
||||||
|
|
||||||
|
before_filter :set_locale
|
||||||
|
|
||||||
helper 'locomotive/base'
|
helper 'locomotive/base'
|
||||||
|
|
||||||
protected
|
protected
|
||||||
@ -19,5 +21,9 @@ module Locomotive
|
|||||||
request.protocol + request.host_with_port
|
request.protocol + request.host_with_port
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_locale
|
||||||
|
I18n.locale = current_site.accounts.first.locale
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
module Locomotive
|
module Locomotive
|
||||||
class EditableFile < EditableElement
|
class EditableFile < EditableElement
|
||||||
|
|
||||||
mount_uploader :source, EditableFileUploader, :mount_on => :source_filename
|
mount_uploader :source, EditableFileUploader
|
||||||
|
|
||||||
replace_field :source_filename, ::String, true
|
replace_field :source, ::String, true
|
||||||
|
|
||||||
def content
|
def content
|
||||||
self.source? ? self.source.url : self.default_content
|
self.source? ? self.source.url : self.default_content
|
||||||
|
@ -61,6 +61,7 @@ module Locomotive
|
|||||||
# namespaced ::I18n should be changed to just I18n when the t()
|
# namespaced ::I18n should be changed to just I18n when the t()
|
||||||
# method is available
|
# method is available
|
||||||
def create_default_pages!
|
def create_default_pages!
|
||||||
|
::Mongoid::Fields::I18n.with_locale(self.default_locale) do
|
||||||
%w{index 404}.each do |slug|
|
%w{index 404}.each do |slug|
|
||||||
self.pages.create({
|
self.pages.create({
|
||||||
:slug => slug,
|
:slug => slug,
|
||||||
@ -70,6 +71,7 @@ module Locomotive
|
|||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def destroy_pages
|
def destroy_pages
|
||||||
# pages is a tree so we just need to delete the root (as well as the page not found page)
|
# pages is a tree so we just need to delete the root (as well as the page not found page)
|
||||||
|
5
doc/TODO
5
doc/TODO
@ -103,17 +103,18 @@ x deployment
|
|||||||
x data ?
|
x data ?
|
||||||
x script to migrate existing site
|
x script to migrate existing site
|
||||||
x i18n
|
x i18n
|
||||||
|
- heroku module for locomotive
|
||||||
- refactoring
|
- refactoring
|
||||||
- remove the import / export scripts
|
- remove the import / export scripts
|
||||||
- remove the cross domain authentication (use auth_token instead)
|
- remove the cross domain authentication (use auth_token instead)
|
||||||
- upgrade to rails 3.2 (https://github.com/locomotivecms/engine/pull/281/files)
|
- upgrade to rails 3.2 (https://github.com/locomotivecms/engine/pull/281/files)
|
||||||
- heroku module for locomotive
|
|
||||||
|
|
||||||
- bugs:
|
- bugs:
|
||||||
x unable to toggle the "required" check_boxes for content types
|
x unable to toggle the "required" check_boxes for content types
|
||||||
x unable to sign out
|
x unable to sign out
|
||||||
x unable to remove a field
|
x unable to remove a field
|
||||||
x "back to admin" link does not work if inline editor disabled
|
x "back to admin" link does not work if inline editor disabled
|
||||||
|
- display by categories does not work when localized
|
||||||
|
|
||||||
- disallow to click twice on the submit form button (spinner ?)
|
- disallow to click twice on the submit form button (spinner ?)
|
||||||
- message to notify people if their browser is too old
|
- message to notify people if their browser is too old
|
||||||
@ -121,8 +122,6 @@ x script to migrate existing site
|
|||||||
- where to put Locomotive::InlineEditorMiddleware ?
|
- where to put Locomotive::InlineEditorMiddleware ?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BACKLOG:
|
BACKLOG:
|
||||||
|
|
||||||
- custom_fields:
|
- custom_fields:
|
||||||
|
@ -14,7 +14,8 @@
|
|||||||
- api_contents:
|
- api_contents:
|
||||||
- url => entry_submissions
|
- url => entry_submissions
|
||||||
- params[:content] => params[:entries]
|
- params[:content] => params[:entries]
|
||||||
|
- editable_file:
|
||||||
|
- source_filename => source
|
||||||
|
|
||||||
collection, selector = Locomotive::ContentType.collection, Locomotive::ContentType.criteria.selector
|
collection, selector = Locomotive::ContentType.collection, Locomotive::ContentType.criteria.selector
|
||||||
collection.update selector, { '$rename' => { 'contents_custom_fields' => 'entries_custom_fields' } }
|
collection.update selector, { '$rename' => { 'contents_custom_fields' => 'entries_custom_fields' } }
|
||||||
|
@ -34,6 +34,10 @@ module Locomotive
|
|||||||
::I18n.locale = current_locomotive_account.locale rescue Locomotive.config.default_locale
|
::I18n.locale = current_locomotive_account.locale rescue Locomotive.config.default_locale
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def back_to_default_site_locale
|
||||||
|
session[:content_locale] = ::Mongoid::Fields::I18n.locale = current_site.default_locale
|
||||||
|
end
|
||||||
|
|
||||||
def setup_i18n_fallbacks
|
def setup_i18n_fallbacks
|
||||||
(current_site.locales || []).each do |locale|
|
(current_site.locales || []).each do |locale|
|
||||||
::Mongoid::Fields::I18n.fallbacks_for(locale, current_site.locale_fallbacks(locale))
|
::Mongoid::Fields::I18n.fallbacks_for(locale, current_site.locale_fallbacks(locale))
|
||||||
|
Loading…
Reference in New Issue
Block a user