Class: Sites::ContentsController
- Inherits:
-
ApplicationAdminController
- Object
- ApplicationAdminController
- Sites::ContentsController
- Defined in:
- app/controllers/scribo/admin/sites/contents_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
-
#index ⇒ Object
Render the IDE.
- #move ⇒ Object
- #rename ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
- #upload ⇒ Object
Instance Method Details
#create ⇒ Object
44 45 46 47 48 49 |
# File 'app/controllers/scribo/admin/sites/contents_controller.rb', line 44 def create parent = params[:parent] ? @site.contents.find(params[:parent]) : nil @content = @site.contents.create!(path: params[:path], kind: params[:kind], parent: parent) rescue Signum.error(Current.user, text: t('.create_fail', kind: params[:kind])) end |
#destroy ⇒ Object
24 25 26 27 |
# File 'app/controllers/scribo/admin/sites/contents_controller.rb', line 24 def destroy @content.destroy head 200 end |
#edit ⇒ Object
13 |
# File 'app/controllers/scribo/admin/sites/contents_controller.rb', line 13 def edit; end |
#index ⇒ Object
Render the IDE
11 |
# File 'app/controllers/scribo/admin/sites/contents_controller.rb', line 11 def index; end |
#move ⇒ Object
29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/scribo/admin/sites/contents_controller.rb', line 29 def move if params[:to] new_parent = @site.contents.find(params[:to]) @content.update!(parent: new_parent) else @content.update!(parent_id: nil) end rescue Signum.error(Current.user, text: t('.move_fail')) end |
#rename ⇒ Object
40 41 42 |
# File 'app/controllers/scribo/admin/sites/contents_controller.rb', line 40 def rename @content.update(path: params[:to]) if params[:to] end |
#show ⇒ Object
20 21 22 |
# File 'app/controllers/scribo/admin/sites/contents_controller.rb', line 20 def show render :edit end |
#update ⇒ Object
15 16 17 18 |
# File 'app/controllers/scribo/admin/sites/contents_controller.rb', line 15 def update @content.update(content_params) render :edit end |
#upload ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'app/controllers/scribo/admin/sites/contents_controller.rb', line 51 def upload @parent = Scribo::Content.find(params[:content][:parent_id]) if params[:content][:parent_id] params[:content][:files]&.each do |file| content = @site.contents.create!(kind: Scribo::Utility.kind_for_path(file.original_filename), path: file.original_filename, data_with_frontmatter: file.read) content.update!(parent: @parent) if @parent rescue Signum.error(Current.user, text:t('.upload_fail')) end @contents = @site.contents.roots.reorder(:path) # unless params[:content][:parent_id] end |