agregar migas de pan comunes y en cada accióñ

las migas que van dentro de cada acción son strings vacías porque no las
estamos vinculando a nada, así que nos ahorramos el proceso.
This commit is contained in:
f 2021-05-09 13:08:18 -03:00
parent 0a5908d02d
commit 88051425ae
3 changed files with 32 additions and 20 deletions

View file

@ -7,6 +7,11 @@ class PostsController < ApplicationController
before_action :authenticate_usuarie!
# TODO: Traer los comunes desde ApplicationController
breadcrumb -> { current_usuarie.email }, :edit_usuarie_registration_path
breadcrumb 'sites.index', :sites_path, match: :exact
breadcrumb -> { site.title }, -> { site_posts_path(site, locale: locale) }, match: :exact
# Las URLs siempre llevan el idioma actual o el de le usuarie
def default_url_options
{ locale: params[:locale] || current_usuarie&.lang || I18n.locale }
@ -43,44 +48,34 @@ class PostsController < ApplicationController
end
def show
@site = find_site
@post = @site.posts(lang: locale).find params[:id]
authorize @post
@locale = locale
fresh_when @post
authorize post
breadcrumb post.title.value, ''
fresh_when post
end
# Genera una previsualización del artículo.
#
# TODO: No todos los artículos tienen previsualización!
def preview
@site = find_site
@post = @site.posts(lang: locale).find params[:post_id]
authorize post
authorize @post
render html: @post.render
render html: post.render
end
def new
authorize Post
@site = find_site
@post = @site.posts.build(lang: locale, layout: params[:layout])
@locale = locale
@post = site.posts.build(lang: locale, layout: params[:layout])
breadcrumb I18n.t('loaf.breadcrumbs.posts.new', layout: @post.layout.humanized_name.downcase), ''
end
def create
authorize Post
@site = find_site
service = PostService.new(site: @site,
service = PostService.new(site: site,
usuarie: current_usuarie,
params: params)
@post = service.create
if @post.persisted?
@site.touch
site.touch
forget_content
redirect_to site_post_path(@site, @post)
@ -96,6 +91,7 @@ class PostsController < ApplicationController
authorize @post
@locale = locale
breadcrumb @post.title.value, site_post_path(@site, @post, locale: locale), match: :exact
end
def update

View file

@ -7,6 +7,9 @@ class SitesController < ApplicationController
before_action :authenticate_usuarie!
breadcrumb -> { current_usuarie.email }, :edit_usuarie_registration_path
breadcrumb 'sites.index', :sites_path, match: :exact
# Ver un listado de sitios
def index
authorize Site
@ -24,6 +27,8 @@ class SitesController < ApplicationController
end
def new
breadcrumb 'sites.new', :new_site_path
@site = Site.new
authorize @site
@ -43,6 +48,10 @@ class SitesController < ApplicationController
def edit
authorize site
breadcrumb site.title, site_posts_path(site), match: :exact
breadcrumb 'sites.edit', site_path(site)
SiteService.new(site: site).build_deploys
end

View file

@ -7,12 +7,19 @@ class UsuariesController < ApplicationController
include Pundit
before_action :authenticate_usuarie!
# TODO: Traer los comunes desde ApplicationController
breadcrumb -> { current_usuarie.email }, :edit_usuarie_registration_path
breadcrumb 'sites.index', :sites_path, match: :exact
breadcrumb -> { site.title }, -> { site_posts_path(site, locale: locale) }, match: :exact
# Mostrar todes les usuaries e invitades de un sitio
def index
@site = find_site
site_usuarie = SiteUsuarie.new(@site, current_usuarie)
authorize site_usuarie
breadcrumb 'usuaries.index', ''
@policy = policy(site_usuarie)
end