2019-03-22 19:51:36 +01:00
@use validator::ValidationErrors;
@use plume_models::blogs::Blog;
2019-08-21 00:42:04 +02:00
@use plume_models::instance::Instance;
2019-03-22 19:51:36 +01:00
@use plume_models::medias::Media;
2020-01-21 07:02:03 +01:00
@use crate::template_utils::*;
@use crate::templates::base;
@use crate::templates::partials::image_select;
@use crate::routes::blogs;
@use crate::routes::blogs::EditForm;
@use crate::routes::medias;
2019-03-22 19:51:36 +01:00
@(ctx: BaseContext, blog: & Blog, medias: Vec< Media > , form: & EditForm, errors: ValidationErrors)
@:base(ctx, i18n!(ctx.1, "Edit \"{}\""; & blog.title), {}, {
< a href = "@uri!(blogs::details: name = &blog.fqn, page = _)" > @blog.title< / a >
}, {
< h1 > @i18n!(ctx.1, "Edit \"{}\""; & blog.title)< / h1 >
< form method = "post" action = "@uri!(blogs::update: name = &blog.fqn)" >
<!-- Rocket hack to use various HTTP methods -->
< input type = hidden name = "_method" value = "put" >
2019-08-27 16:50:24 +02:00
@(Input::new("title", i18n!(ctx.1, "Title"))
.default(& form.title)
.error(& errors)
.set_prop("minlenght", 1)
.html(ctx.1))
2019-03-22 19:51:36 +01:00
< label for = "summary" > @i18n!(ctx.1, "Description")< small > @i18n!(ctx.1, "Markdown syntax is supported")< / small > < / label >
< textarea id = "summary" name = "summary" rows = "20" > @form.summary< / textarea >
< p >
2019-04-01 20:09:29 +02:00
@i18n!(ctx.1, "You can upload images to your gallery, to use them as blog icons, or banners.")
2019-03-22 19:51:36 +01:00
< a href = "@uri!(medias::new)" > @i18n!(ctx.1, "Upload images")< / a >
< / p >
@:image_select(ctx, "icon", i18n!(ctx.1, "Blog icon"), true, medias.clone(), form.icon)
@:image_select(ctx, "banner", i18n!(ctx.1, "Blog banner"), true, medias, form.banner)
2019-08-21 00:42:04 +02:00
@if let Ok(themes) = Instance::list_themes() {
< label for = "css" > @i18n!(ctx.1, "Custom theme")< / label >
< select name = "theme" id = "theme" >
< option value = "" @ if form . theme . is_none ( ) { selected } > @i18n!(ctx.1, "Default theme")< / option >
@for theme in themes {
< option value = "@theme" @ if Some ( theme . clone ( ) ) = = form . theme { selected } > @theme< / option >
}
< / select >
} else {
< p class = "error" > @i18n!(ctx.1, "Error while loading theme selector.")< / p >
}
2019-03-22 19:51:36 +01:00
< input type = "submit" value = "@i18n!(ctx.1, " Update blog " ) " / >
< / form >
< h2 > @i18n!(ctx.1, "Danger zone")< / h2 >
< p > @i18n!(ctx.1, "Be very careful, any action taken here can't be reversed.")< / p >
2019-05-29 14:51:53 +02:00
< form method = "post" action = "@uri!(blogs::delete: name = &blog.fqn)" onsubmit = "return confirm ( ' @ i18n ! ( ctx . 1 , " Are you sure that you want to permanently delete this blog ? " ) ' ) " >
2019-03-22 19:51:36 +01:00
< input type = "submit" class = "inline-block button destructive" value = "@i18n!(ctx.1, " Permanently delete this blog " ) " >
< / form >
2019-04-01 20:09:29 +02:00
})