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 'mongoid', '~> 2.4.2'
|
||||
gem 'locomotive_mongoid_acts_as_tree', '~> 0.1.5.8'
|
||||
# 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', :path => '../gems/custom_fields' # DEV
|
||||
# gem 'custom_fields', :git => 'git://github.com/locomotivecms/custom_fields.git', :branch => '2.0.0.rc'
|
||||
gem 'kaminari'
|
||||
|
||||
gem 'haml', '~> 3.1.3'
|
||||
|
@ -1,7 +1,5 @@
|
||||
GIT
|
||||
remote: git://github.com/locomotivecms/custom_fields.git
|
||||
revision: 65c451abfc849dd665a556c68c8976c405e57b10
|
||||
branch: 2.0.0.rc
|
||||
PATH
|
||||
remote: ../gems/custom_fields
|
||||
specs:
|
||||
custom_fields (2.0.0.rc2)
|
||||
activesupport (~> 3.1.3)
|
||||
|
@ -9,13 +9,13 @@ module Locomotive
|
||||
|
||||
def create
|
||||
@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
|
||||
|
||||
def update
|
||||
@content_asset = current_site.content_assets.find(params[:id])
|
||||
@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
|
||||
|
@ -11,19 +11,19 @@ module Locomotive
|
||||
|
||||
def create
|
||||
@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
|
||||
|
||||
def update
|
||||
@content_entry = @content_type.entries.find(params[:id])
|
||||
@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
|
||||
|
||||
def destroy
|
||||
@content_entry = @content_type.entries.find(params[:id])
|
||||
@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
|
||||
|
||||
protected
|
||||
|
@ -9,18 +9,13 @@ module Locomotive
|
||||
|
||||
def create
|
||||
@content_type = current_site.content_types.create(params[:content_type])
|
||||
respond_with @content_type, :location => edit_locomotive_api_content_type_url(@content_type._id)
|
||||
end
|
||||
|
||||
def edit
|
||||
@content_type = current_site.content_types.find(params[:id])
|
||||
respond_with @content_type
|
||||
respond_with @content_type, :location => main_app.locomotive_api_content_types_url
|
||||
end
|
||||
|
||||
def update
|
||||
@content_type = current_site.content_types.find(params[:id])
|
||||
@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
|
||||
|
@ -9,13 +9,13 @@ module Locomotive
|
||||
|
||||
def create
|
||||
@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
|
||||
|
||||
def update
|
||||
@page = current_site.pages.find(params[:id])
|
||||
@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
|
||||
|
@ -9,13 +9,13 @@ module Locomotive
|
||||
|
||||
def create
|
||||
@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
|
||||
|
||||
def update
|
||||
@snippet = current_site.snippets.find(params[:id])
|
||||
@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
|
||||
|
@ -9,13 +9,13 @@ module Locomotive
|
||||
|
||||
def create
|
||||
@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
|
||||
|
||||
def update
|
||||
@theme_asset = current_site.theme_assets.find(params[:id])
|
||||
@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
|
||||
|
@ -3,6 +3,8 @@ module Locomotive
|
||||
|
||||
sections 'contents'
|
||||
|
||||
before_filter :back_to_default_site_locale, :only => %w(new create)
|
||||
|
||||
before_filter :set_content_type
|
||||
|
||||
respond_to :json, :only => [:edit, :create, :update, :sort]
|
||||
|
@ -3,6 +3,8 @@ module Locomotive
|
||||
|
||||
sections 'contents'
|
||||
|
||||
before_filter :back_to_default_site_locale, :only => %w(new create)
|
||||
|
||||
respond_to :json, :only => [:create, :update, :destroy]
|
||||
|
||||
helper 'Locomotive::Accounts', 'Locomotive::CustomFields'
|
||||
|
@ -29,9 +29,9 @@ module Locomotive
|
||||
if account = Account.find_using_switch_site_token(params[:token])
|
||||
account.reset_switch_site_token!
|
||||
sign_in(account)
|
||||
redirect_to admin_pages_path
|
||||
redirect_to pages_path
|
||||
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
|
||||
|
||||
|
@ -3,6 +3,8 @@ module Locomotive
|
||||
|
||||
sections 'contents'
|
||||
|
||||
before_filter :back_to_default_site_locale, :only => %w(new create)
|
||||
|
||||
respond_to :json, :only => [:show, :create, :update, :sort, :get_path]
|
||||
|
||||
def index
|
||||
|
@ -7,6 +7,8 @@ module Locomotive
|
||||
|
||||
before_filter :require_site
|
||||
|
||||
before_filter :set_locale
|
||||
|
||||
helper 'locomotive/base'
|
||||
|
||||
protected
|
||||
@ -19,5 +21,9 @@ module Locomotive
|
||||
request.protocol + request.host_with_port
|
||||
end
|
||||
|
||||
def set_locale
|
||||
I18n.locale = current_site.accounts.first.locale
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -1,9 +1,9 @@
|
||||
module Locomotive
|
||||
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
|
||||
self.source? ? self.source.url : self.default_content
|
||||
|
@ -61,13 +61,15 @@ module Locomotive
|
||||
# namespaced ::I18n should be changed to just I18n when the t()
|
||||
# method is available
|
||||
def create_default_pages!
|
||||
%w{index 404}.each do |slug|
|
||||
self.pages.create({
|
||||
:slug => slug,
|
||||
:title => ::I18n.t("attributes.defaults.pages.#{slug}.title"),
|
||||
:raw_template => ::I18n.t("attributes.defaults.pages.#{slug}.body"),
|
||||
:published => true
|
||||
})
|
||||
::Mongoid::Fields::I18n.with_locale(self.default_locale) do
|
||||
%w{index 404}.each do |slug|
|
||||
self.pages.create({
|
||||
:slug => slug,
|
||||
:title => ::I18n.t("attributes.defaults.pages.#{slug}.title"),
|
||||
:raw_template => ::I18n.t("attributes.defaults.pages.#{slug}.body"),
|
||||
:published => true
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
5
doc/TODO
5
doc/TODO
@ -103,17 +103,18 @@ x deployment
|
||||
x data ?
|
||||
x script to migrate existing site
|
||||
x i18n
|
||||
- heroku module for locomotive
|
||||
- refactoring
|
||||
- remove the import / export scripts
|
||||
- remove the cross domain authentication (use auth_token instead)
|
||||
- upgrade to rails 3.2 (https://github.com/locomotivecms/engine/pull/281/files)
|
||||
- heroku module for locomotive
|
||||
|
||||
- bugs:
|
||||
x unable to toggle the "required" check_boxes for content types
|
||||
x unable to sign out
|
||||
x unable to remove a field
|
||||
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 ?)
|
||||
- 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 ?
|
||||
|
||||
|
||||
|
||||
|
||||
BACKLOG:
|
||||
|
||||
- custom_fields:
|
||||
|
@ -14,7 +14,8 @@
|
||||
- api_contents:
|
||||
- url => entry_submissions
|
||||
- params[:content] => params[:entries]
|
||||
|
||||
- editable_file:
|
||||
- source_filename => source
|
||||
|
||||
collection, selector = Locomotive::ContentType.collection, Locomotive::ContentType.criteria.selector
|
||||
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
|
||||
end
|
||||
|
||||
def back_to_default_site_locale
|
||||
session[:content_locale] = ::Mongoid::Fields::I18n.locale = current_site.default_locale
|
||||
end
|
||||
|
||||
def setup_i18n_fallbacks
|
||||
(current_site.locales || []).each do |locale|
|
||||
::Mongoid::Fields::I18n.fallbacks_for(locale, current_site.locale_fallbacks(locale))
|
||||
|
Loading…
Reference in New Issue
Block a user