2019-03-22 18:51:36 +00:00
|
|
|
@use validator::ValidationErrors;
|
|
|
|
@use plume_models::blogs::Blog;
|
2019-08-20 22:42:04 +00:00
|
|
|
@use plume_models::instance::Instance;
|
2019-03-22 18:51:36 +00:00
|
|
|
@use plume_models::medias::Media;
|
|
|
|
@use routes::blogs;
|
|
|
|
@use routes::blogs::EditForm;
|
|
|
|
@use routes::medias;
|
|
|
|
@use template_utils::*;
|
|
|
|
@use templates::base;
|
|
|
|
@use templates::partials::image_select;
|
|
|
|
|
|
|
|
@(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 14:50:24 +00:00
|
|
|
@(Input::new("title", i18n!(ctx.1, "Title"))
|
|
|
|
.default(&form.title)
|
|
|
|
.error(&errors)
|
|
|
|
.set_prop("minlenght", 1)
|
|
|
|
.html(ctx.1))
|
2019-03-22 18:51:36 +00: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 18:09:29 +00:00
|
|
|
@i18n!(ctx.1, "You can upload images to your gallery, to use them as blog icons, or banners.")
|
2019-03-22 18:51:36 +00: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-20 22:42:04 +00: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 18:51:36 +00: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 12:51:53 +00: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 18:51:36 +00:00
|
|
|
<input type="submit" class="inline-block button destructive" value="@i18n!(ctx.1, "Permanently delete this blog")">
|
|
|
|
</form>
|
2019-04-01 18:09:29 +00:00
|
|
|
})
|