2011-10-30 23:02:41 +00:00
|
|
|
module Locomotive
|
2010-05-10 22:39:52 +00:00
|
|
|
class SnippetsController < BaseController
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-09-22 12:50:01 +00:00
|
|
|
sections 'settings', 'theme_assets'
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2012-02-09 10:36:10 +00:00
|
|
|
localized
|
|
|
|
|
|
|
|
before_filter :back_to_default_site_locale, :only => %w(new create)
|
|
|
|
|
2011-12-06 11:39:32 +00:00
|
|
|
respond_to :json, :only => [:create, :update, :destroy]
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2011-11-28 14:40:25 +00:00
|
|
|
def new
|
|
|
|
@snippet = current_site.snippets.new
|
|
|
|
respond_with @snippet
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@snippet = current_site.snippets.create(params[:snippet])
|
2011-12-05 10:31:34 +00:00
|
|
|
respond_with @snippet, :location => edit_snippet_url(@snippet._id)
|
2011-11-28 14:40:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@snippet = current_site.snippets.find(params[:id])
|
|
|
|
respond_with @snippet
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@snippet = current_site.snippets.find(params[:id])
|
2011-12-05 12:29:58 +00:00
|
|
|
@snippet.update_attributes(params[:snippet])
|
2011-12-05 10:31:34 +00:00
|
|
|
respond_with @snippet, :location => edit_snippet_url(@snippet._id)
|
2011-11-28 14:40:25 +00:00
|
|
|
end
|
|
|
|
|
2010-09-22 12:50:01 +00:00
|
|
|
def destroy
|
2011-11-28 14:40:25 +00:00
|
|
|
@snippet = current_site.snippets.find(params[:id])
|
2011-12-07 01:09:13 +00:00
|
|
|
@snippet.destroy
|
2011-11-28 14:40:25 +00:00
|
|
|
respond_with @snippet, :location => theme_assets_url
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
|
2010-05-10 22:39:52 +00:00
|
|
|
end
|
2010-07-23 20:09:54 +00:00
|
|
|
end
|