2019-09-14 19:03:38 +00:00
|
|
|
const Fileinfo = require('./fileinfo')
|
|
|
|
|
|
|
|
const Newsitem = {
|
|
|
|
view: function(vnode) {
|
2019-09-16 16:47:29 +00:00
|
|
|
var pixelRatio = window.devicePixelRatio || 1
|
2019-09-14 19:03:38 +00:00
|
|
|
return m('newsitem', [
|
|
|
|
m(m.route.Link,
|
|
|
|
{ href: '/article/' + vnode.attrs.path, class: 'title' },
|
|
|
|
m('h3', [vnode.attrs.name])
|
|
|
|
),
|
|
|
|
m('div.newsitemcontent', [
|
|
|
|
vnode.attrs.media
|
|
|
|
? m('a.cover', {
|
2019-09-15 01:53:38 +00:00
|
|
|
href: '/article/' + vnode.attrs.path,
|
2019-09-16 16:47:29 +00:00
|
|
|
}, m('img', { alt: 'Image for news item ' + vnode.attrs.name, src: pixelRatio > 1 ? vnode.attrs.media.medium_url : vnode.attrs.media.small_url }))
|
2019-10-01 03:45:44 +00:00
|
|
|
: null,
|
|
|
|
m('div.entrycontent', {
|
|
|
|
class: vnode.attrs.media ? '' : 'extrapadding',
|
|
|
|
}, [
|
2019-09-14 19:03:38 +00:00
|
|
|
(vnode.attrs.description
|
|
|
|
? m('.fr-view', m.trust(vnode.attrs.description))
|
|
|
|
: null),
|
|
|
|
(vnode.attrs.files && vnode.attrs.files.length
|
|
|
|
? vnode.attrs.files.map(function(file) {
|
2019-10-02 17:40:32 +00:00
|
|
|
return m(Fileinfo, { file: file, trim: true })
|
2019-09-14 19:03:38 +00:00
|
|
|
})
|
|
|
|
: null),
|
2019-10-02 17:40:32 +00:00
|
|
|
m('span.entrymeta', [
|
|
|
|
'Posted ',
|
|
|
|
(vnode.attrs.parent ? 'in' : ''),
|
|
|
|
(vnode.attrs.parent ? m(m.route.Link, { href: '/page/' + vnode.attrs.parent.path }, vnode.attrs.parent.name) : null),
|
|
|
|
'at ' + (vnode.attrs.published_at.replace('T', ' ').split('.')[0]).substr(0, 16),
|
2019-10-02 18:47:20 +00:00
|
|
|
' by ' + (vnode.attrs.staff && vnode.attrs.staff.fullname || 'Admin'),
|
2019-10-02 17:40:32 +00:00
|
|
|
]),
|
2019-09-14 19:03:38 +00:00
|
|
|
]),
|
|
|
|
]),
|
|
|
|
])
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Newsitem
|