change the default API base path + implement the API for content_assets, content_types and pages resources
This commit is contained in:
parent
0534c5504f
commit
ab507dc165
@ -66,12 +66,16 @@ class Locomotive.Views.ContentTypes.CustomFieldsView extends Backbone.View
|
|||||||
@add_entry(event)
|
@add_entry(event)
|
||||||
|
|
||||||
remove_entry: (custom_field, view) ->
|
remove_entry: (custom_field, view) ->
|
||||||
|
if custom_field.isNew()
|
||||||
|
@model.get('entries_custom_fields').remove(custom_field)
|
||||||
|
else
|
||||||
|
custom_field.set _destroy: true
|
||||||
|
|
||||||
@_entry_views = _.reject @_entry_views, (_view) -> _view == view
|
@_entry_views = _.reject @_entry_views, (_view) -> _view == view
|
||||||
@model.get('entries_custom_fields').remove(custom_field)
|
|
||||||
|
|
||||||
@refresh_position_entries()
|
@refresh_position_entries()
|
||||||
|
|
||||||
@$('> .empty').show() if @model.get('entries_custom_fields').length == 0
|
@$('> .empty').show() if @_entry_views.length == 0
|
||||||
|
|
||||||
render_entries: ->
|
render_entries: ->
|
||||||
if @model.get('entries_custom_fields').length == 0
|
if @model.get('entries_custom_fields').length == 0
|
||||||
|
23
app/controllers/locomotive/api/content_assets_controller.rb
Normal file
23
app/controllers/locomotive/api/content_assets_controller.rb
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
module Locomotive
|
||||||
|
module Api
|
||||||
|
class ContentAssetsController < BaseController
|
||||||
|
|
||||||
|
def index
|
||||||
|
@content_assets = current_site.content_assets
|
||||||
|
respond_with(@content_assets)
|
||||||
|
end
|
||||||
|
|
||||||
|
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)
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
28
app/controllers/locomotive/api/content_types_controller.rb
Normal file
28
app/controllers/locomotive/api/content_types_controller.rb
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
module Locomotive
|
||||||
|
module Api
|
||||||
|
class ContentTypesController < BaseController
|
||||||
|
|
||||||
|
def index
|
||||||
|
@content_types = current_site.content_types
|
||||||
|
respond_with(@content_types)
|
||||||
|
end
|
||||||
|
|
||||||
|
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
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
25
app/controllers/locomotive/api/pages_controller.rb
Normal file
25
app/controllers/locomotive/api/pages_controller.rb
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
module Locomotive
|
||||||
|
module Api
|
||||||
|
class PagesController < BaseController
|
||||||
|
|
||||||
|
def index
|
||||||
|
@pages = current_site.pages.all
|
||||||
|
respond_with(@pages)
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@page = current_site.pages.create(params[:page])
|
||||||
|
respond_with @page, :location => edit_locomotive_api_page_url(@page._id)
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,10 +1,7 @@
|
|||||||
module Locomotive
|
module Locomotive
|
||||||
module Api
|
module Api
|
||||||
|
|
||||||
class SnippetsController < BaseController
|
class SnippetsController < BaseController
|
||||||
|
|
||||||
include Locomotive::Routing::SiteDispatcher
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@snippets = current_site.snippets.all
|
@snippets = current_site.snippets.all
|
||||||
respond_with(@snippets)
|
respond_with(@snippets)
|
||||||
@ -12,17 +9,16 @@ 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_snippet_url(@snippet._id)
|
respond_with @snippet, :location => edit_locomotive_api_snippet_url(@snippet._id)
|
||||||
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_snippet_url(@snippet._id)
|
respond_with @snippet, :location => edit_locomotive_api_snippet_url(@snippet._id)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -2,8 +2,6 @@ module Locomotive
|
|||||||
module Api
|
module Api
|
||||||
class ThemeAssetsController < BaseController
|
class ThemeAssetsController < BaseController
|
||||||
|
|
||||||
include Locomotive::Routing::SiteDispatcher
|
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@theme_assets = current_site.theme_assets.all
|
@theme_assets = current_site.theme_assets.all
|
||||||
respond_with(@theme_assets)
|
respond_with(@theme_assets)
|
||||||
@ -11,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_theme_asset_url(@theme_asset._id)
|
respond_with @theme_asset, :location => edit_locomotive_api_theme_asset_url(@theme_asset._id)
|
||||||
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_theme_asset_url(@theme_asset._id)
|
respond_with @theme_asset, :location => edit_locomotive_api_theme_asset_url(@theme_asset._id)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -23,9 +23,5 @@ module Locomotive
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# cAEERKkstnUya7UVxkqN
|
|
@ -41,6 +41,7 @@ Locomotive::Engine.routes.draw do
|
|||||||
put :sort, :on => :collection
|
put :sort, :on => :collection
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# TODO
|
||||||
resources :custom_fields, :path => 'custom/:parent/:slug/fields'
|
resources :custom_fields, :path => 'custom/:parent/:slug/fields'
|
||||||
|
|
||||||
resources :cross_domain_sessions, :only => [:new, :create]
|
resources :cross_domain_sessions, :only => [:new, :create]
|
||||||
@ -57,18 +58,22 @@ end
|
|||||||
|
|
||||||
Rails.application.routes.draw do
|
Rails.application.routes.draw do
|
||||||
|
|
||||||
# api
|
# API
|
||||||
namespace :_locomotive, :module => 'locomotive' do
|
namespace :locomotive, :module => 'locomotive' do
|
||||||
namespace :api do
|
namespace :api do
|
||||||
|
|
||||||
resources :tokens, :only => [:create, :destroy]
|
resources :tokens, :only => [:create, :destroy]
|
||||||
|
|
||||||
resources :theme_assets
|
resources :theme_assets
|
||||||
|
|
||||||
|
resources :content_assets
|
||||||
|
|
||||||
resources :snippets
|
resources :snippets
|
||||||
|
|
||||||
resources :pages
|
resources :pages
|
||||||
|
|
||||||
|
resources :content_types
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
25
doc/TODO
25
doc/TODO
@ -87,20 +87,29 @@ x deployment
|
|||||||
x fix integration problems
|
x fix integration problems
|
||||||
x pre-compile assets
|
x pre-compile assets
|
||||||
- API
|
- API
|
||||||
- authentication from a token + controller to deliver a token
|
x authentication from a token + controller to deliver a token
|
||||||
- api routes
|
x api routes
|
||||||
- add a way to custom the as_json method within the presenters (by default as_json ?) + custom responder ?
|
x change api location
|
||||||
|
(- add a way to custom the as_json method within the presenters (by default as_json ?) + custom responder ?)
|
||||||
- REST actions:
|
- REST actions:
|
||||||
- CRUD assets
|
x CRUD theme assets
|
||||||
- CRUD pages
|
x CRUD snippets
|
||||||
- CRUD snippets
|
x CRUD content assets
|
||||||
- CRUD content types
|
x CRUD pages
|
||||||
|
x CRUD content types
|
||||||
- data ?
|
- data ?
|
||||||
|
- 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)
|
||||||
|
|
||||||
- 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
|
||||||
- https://github.com/locomotivecms/engine/pull/281/files
|
x unable to remove a field
|
||||||
|
|
||||||
|
- "back to admin" link does not work if inline editor disabled
|
||||||
|
|
||||||
|
|
||||||
- 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
|
||||||
|
Loading…
Reference in New Issue
Block a user