This repository has been archived on 2022-11-26. You can view files and clone it, but cannot push or open issues or pull requests.
IcyNet.eu/views/news/article.pug

71 lines
2.1 KiB
Plaintext

extends ../layout.pug
block meta
if article
meta(name="description", content=article.description)
meta(name="og:title", content=article.title)
meta(name="og:description", content=article.description)
meta(name="og:image", content="https://icynet.eu/static/image/icynet-icon.png")
meta(name="og:type", content="article")
meta(name="og:updated_time", content=article.updated_at)
meta(name="twitter:card", content="summary")
meta(name="twitter:title", content=article.title)
meta(name="twitter:description", content=article.description)
link(rel="alternate", href="/news/atom.xml", title="Icy Network News", type="application/atom+xml")
block append links
if editing
script(src="//cdnjs.cloudflare.com/ajax/libs/ckeditor/4.7.2/ckeditor.js")
block title
if article
|Icy Network - News - #{article.title}
else
|Icy Network - News - 404
block body
.container.mt-4
if !article
span.error No such article
else
nav(aria-label="breadcrumb")
ol.breadcrumb
li.breadcrumb-item
a(href="/") Home
li.breadcrumb-item
a(href="/news") News
li.breadcrumb-item.active(aria-current="page")= article.title
.news-article
if user && user.privilege && user.privilege > 0 && !editing
a.btn.btn-primary.float-right(href="?edit=1") Edit
h1.news-title= article.title
p.news-meta Published by
span #{article.author.display_name}
|at #{new Date(article.created_at)}
if editing
.content(contenteditable="true" id="editor1")!= article.content
else
.content!= article.content
if editing
.btn.btn-success(id="done") Done editing
br
script.
CKEDITOR.disableAutoInline = true;
CKEDITOR.inline('editor1');
$('#done').click(function (e) {
let data = CKEDITOR.instances.editor1.getData();
$.post({
url: '/api/news/edit/#{article.id}',
data: {content: data},
success: function () {
window.location.href = '/news/#{article.id}-#{article.slug}'
},
error: function (e) {
if (e.responseJSON && e.responseJSON.error) {
alert(e.responseJSON.error);
}
}
});
});