Class: Scribo::Admin::SitesController
- Inherits:
-
Scribo::ApplicationAdminController
- Object
- Scribo::ApplicationController
- Scribo::ApplicationAdminController
- Scribo::Admin::SitesController
- Defined in:
- app/controllers/scribo/admin/sites_controller.rb
Instance Method Summary collapse
Methods included from MaintenanceStandards
Instance Method Details
#create ⇒ Object
27 28 29 30 |
# File 'app/controllers/scribo/admin/sites_controller.rb', line 27 def create flash_and_redirect @site.save, admin_site_contents_path(@site), 'Site created successfully', 'There were problems creating the site' end |
#destroy ⇒ Object
36 37 38 39 |
# File 'app/controllers/scribo/admin/sites_controller.rb', line 36 def destroy flash_and_redirect @site.destroy, admin_sites_url, 'Site deleted successfully', 'There were problems deleting the site' end |
#export ⇒ Object
48 49 50 51 |
# File 'app/controllers/scribo/admin/sites_controller.rb', line 48 def export name, data = Scribo::SiteExportService.new(@site).call send_data data, type: 'application/zip', filename: name end |
#import ⇒ Object
41 42 43 44 45 46 |
# File 'app/controllers/scribo/admin/sites_controller.rb', line 41 def import @sites = Site.adminable params[:files].each do |file| Scribo::SiteImportService.new(file.path, scribable: Scribo.config.scribable_for_request(request)).call end end |
#index ⇒ Object
32 33 34 |
# File 'app/controllers/scribo/admin/sites_controller.rb', line 32 def index @sites = Site.adminable end |
#new ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controllers/scribo/admin/sites_controller.rb', line 10 def new if params[:template_id] url = Scribo.config.templates.find { |t| t[:id] == params[:template_id] }&.[](:url) redirect_to(admin_sites_path) && return unless url file = Down.download(url) @site = Scribo::SiteImportService.new(file.path, scribable: Scribo.config.scribable_for_request(request)).call redirect_to(admin_site_contents_path(@site)) nil else @site = Scribo::Site.create!(scribable: Scribo.config.scribable_for_request(request)) Scribo.config.after_site_create(@site) redirect_to(admin_site_contents_path(@site)) nil end end |