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)
|
||||
|
||||
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
|
||||
@model.get('entries_custom_fields').remove(custom_field)
|
||||
|
||||
@refresh_position_entries()
|
||||
|
||||
@$('> .empty').show() if @model.get('entries_custom_fields').length == 0
|
||||
@$('> .empty').show() if @_entry_views.length == 0
|
||||
|
||||
render_entries: ->
|
||||
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 Api
|
||||
|
||||
class SnippetsController < BaseController
|
||||
|
||||
include Locomotive::Routing::SiteDispatcher
|
||||
|
||||
def index
|
||||
@snippets = current_site.snippets.all
|
||||
respond_with(@snippets)
|
||||
@ -12,17 +9,16 @@ module Locomotive
|
||||
|
||||
def create
|
||||
@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
|
||||
|
||||
def update
|
||||
@snippet = current_site.snippets.find(params[:id])
|
||||
@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
|
||||
|
||||
|
@ -2,8 +2,6 @@ module Locomotive
|
||||
module Api
|
||||
class ThemeAssetsController < BaseController
|
||||
|
||||
include Locomotive::Routing::SiteDispatcher
|
||||
|
||||
def index
|
||||
@theme_assets = current_site.theme_assets.all
|
||||
respond_with(@theme_assets)
|
||||
@ -11,13 +9,13 @@ module Locomotive
|
||||
|
||||
def create
|
||||
@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
|
||||
|
||||
def update
|
||||
@theme_asset = current_site.theme_assets.find(params[:id])
|
||||
@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
|
||||
|
@ -23,9 +23,5 @@ module Locomotive
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# cAEERKkstnUya7UVxkqN
|
@ -41,6 +41,7 @@ Locomotive::Engine.routes.draw do
|
||||
put :sort, :on => :collection
|
||||
end
|
||||
|
||||
# TODO
|
||||
resources :custom_fields, :path => 'custom/:parent/:slug/fields'
|
||||
|
||||
resources :cross_domain_sessions, :only => [:new, :create]
|
||||
@ -57,18 +58,22 @@ end
|
||||
|
||||
Rails.application.routes.draw do
|
||||
|
||||
# api
|
||||
namespace :_locomotive, :module => 'locomotive' do
|
||||
namespace :api do
|
||||
# API
|
||||
namespace :locomotive, :module => 'locomotive' do
|
||||
namespace :api do
|
||||
|
||||
resources :tokens, :only => [:create, :destroy]
|
||||
|
||||
resources :theme_assets
|
||||
|
||||
resources :content_assets
|
||||
|
||||
resources :snippets
|
||||
|
||||
resources :pages
|
||||
|
||||
resources :content_types
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
25
doc/TODO
25
doc/TODO
@ -87,20 +87,29 @@ x deployment
|
||||
x fix integration problems
|
||||
x pre-compile assets
|
||||
- API
|
||||
- authentication from a token + controller to deliver a token
|
||||
- api routes
|
||||
- add a way to custom the as_json method within the presenters (by default as_json ?) + custom responder ?
|
||||
x authentication from a token + controller to deliver a token
|
||||
x api routes
|
||||
x change api location
|
||||
(- add a way to custom the as_json method within the presenters (by default as_json ?) + custom responder ?)
|
||||
- REST actions:
|
||||
- CRUD assets
|
||||
- CRUD pages
|
||||
- CRUD snippets
|
||||
- CRUD content types
|
||||
x CRUD theme assets
|
||||
x CRUD snippets
|
||||
x CRUD content assets
|
||||
x CRUD pages
|
||||
x CRUD content types
|
||||
- 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:
|
||||
x unable to toggle the "required" check_boxes for content types
|
||||
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 ?)
|
||||
- message to notify people if their browser is too old
|
||||
|
Loading…
Reference in New Issue
Block a user