2018-01-29 22:19:10 +00:00
|
|
|
# Controlador de sitios
|
2018-01-29 18:09:30 +00:00
|
|
|
class SitesController < ApplicationController
|
|
|
|
before_action :authenticate!
|
|
|
|
|
2018-01-29 22:19:10 +00:00
|
|
|
# Ver un listado de sitios
|
2018-01-29 18:09:30 +00:00
|
|
|
def index
|
2018-01-29 22:19:10 +00:00
|
|
|
@sites = current_user.sites
|
|
|
|
end
|
|
|
|
|
|
|
|
# No tenemos propiedades de un sitio aún, así que vamos al listado de
|
|
|
|
# artículos
|
|
|
|
def show
|
|
|
|
site = find_site
|
|
|
|
|
|
|
|
redirect_to site_posts_path(site)
|
2018-01-29 18:09:30 +00:00
|
|
|
end
|
2018-02-20 17:47:11 +00:00
|
|
|
|
|
|
|
def enqueue
|
|
|
|
@site = find_site
|
|
|
|
@site.enqueue!
|
|
|
|
|
|
|
|
redirect_to sites_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def build_log
|
|
|
|
@site = find_site
|
|
|
|
|
2018-04-30 18:51:39 +00:00
|
|
|
# TODO eliminar ANSI
|
2018-02-20 17:47:11 +00:00
|
|
|
render file: @site.build_log,
|
|
|
|
layout: false,
|
2018-04-30 17:22:31 +00:00
|
|
|
content_type: 'text/plain; charset=utf-8'
|
2018-02-20 17:47:11 +00:00
|
|
|
end
|
2018-04-30 18:51:39 +00:00
|
|
|
|
|
|
|
def reorder_posts
|
|
|
|
@site = find_site
|
|
|
|
lang = params.require(:posts).require(:lang)
|
|
|
|
|
|
|
|
if @site.reorder_collection(lang, params.require(:posts).require(:order))
|
|
|
|
flash[:info] = I18n.t('info.posts.reorder')
|
|
|
|
else
|
|
|
|
flash[:danger] = I18n.t('errors.posts.reorder')
|
|
|
|
end
|
|
|
|
|
|
|
|
redirect_to site_posts_path @site
|
|
|
|
end
|
2018-01-29 18:09:30 +00:00
|
|
|
end
|