fix #66 - support h-event microformats

This commit is contained in:
les
2020-02-11 11:53:32 +01:00
parent cb02c5ff1a
commit dfb95e15d8
6 changed files with 46 additions and 39 deletions

View File

@@ -1,19 +1,19 @@
<template lang="pug"> <template lang="pug">
.card.event.mt-1.text-white(body-style='padding: 0px;') .card.event.h-event.mt-1.text-white(body-style='padding: 0px;')
nuxt-link(:to='`/event/${event.id}`') nuxt-link(:to='`/event/${event.id}`')
img(v-if='showImage && event.image_path' :src='`/media/thumb/${event.image_path}`') img(v-if='showImage && event.image_path' :src='`/media/thumb/${event.image_path}`')
.float-right .float-right
i.text-danger.el-icon-refresh(v-if='event.parentId') i.text-danger.el-icon-refresh(v-if='event.parentId')
.badge.text-info(v-if='settings.enable_resources && event.resources && event.resources.length') {{event.resources.length}} .badge.text-info(v-if='settings.enable_resources && event.resources && event.resources.length') {{event.resources.length}}
.title {{event.title}} .p-name.p-summary.title {{event.title}}
.card-body .card-body
div div
i.el-icon-date i.el-icon-date
span {{event|when('home')}} time.dt-start(:datetime='event.start_datetime|unixFormat("YYYY-MM-DD HH:mm")') {{event|when}}
el-button.mt-1.bg-dark.text-warning.float-right(plain size='mini' round type='text' icon='el-icon-location-outline' @click='addPlace') {{event.place.name}} el-button.p-location.mt-1.bg-dark.text-warning.float-right(plain size='mini' round type='text' icon='el-icon-location-outline' @click='addPlace') {{event.place.name}}
//- date / place //- date / place
.description.mt-3(v-if='!event.image_path || !event.tags.length' v-html='description') .description.p-description.mt-3(v-if='!event.image_path || !event.tags.length' v-html='description')
.card-footer(v-if='event.tags.length') .card-footer(v-if='event.tags.length')
el-button.ml-1.bg-dark(type='text' plain round size='mini' v-for='tag in event.tags' :key='tag' @click='addTag(tag)') {{tag}} el-button.ml-1.bg-dark(type='text' plain round size='mini' v-for='tag in event.tags' :key='tag' @click='addTag(tag)') {{tag}}

View File

@@ -55,7 +55,7 @@
"set_password": "Imposta password", "set_password": "Imposta password",
"copy_link": "Copia link", "copy_link": "Copia link",
"send_via_mail": "Invia mail", "send_via_mail": "Invia mail",
"add_to_calendar": "Aggiungi al tuo calendario", "add_to_calendar": "Aggiungi al calendario",
"instances": "Istanze", "instances": "Istanze",
"copied": "Copiato", "copied": "Copiato",
"embed": "Incorpora", "embed": "Incorpora",

View File

@@ -6,7 +6,7 @@
.event-info .event-info
//- title //- title
.date {{event|when('home')}}<br/> .date {{event|when}}<br/>
h4 {{event.title}} h4 {{event.title}}
//- date / place //- date / place

View File

@@ -1,8 +1,8 @@
<template lang="pug"> <template lang="pug">
el-container#eventDetail el-container#eventDetail.h-event
el-header el-header
span.title {{event.title}} span.title.p-summary.p-name {{event.title}}
#arrow #arrow
nuxt-link.mr-1(:to='`/event/${prev}`') nuxt-link.mr-1(:to='`/event/${prev}`')
@@ -23,14 +23,17 @@
div.loading(slot='placeholder') div.loading(slot='placeholder')
el-icon(name='loading') el-icon(name='loading')
pre(v-html='event.description') pre.p-description(v-html='event.description')
el-button.ml-1.text-primary(plain round size='mini' v-for='tag in event.tags' :key='tag') {{tag}} el-button.p-category.ml-1.text-primary(plain round size='mini' v-for='tag in event.tags' :key='tag') {{tag}}
//- info & actions //- info & actions
el-col.menu(:sm='6' :xs='24') el-col.menu(:sm='6' :xs='24')
el-menu.menu.mt-2(router) el-menu.menu(router)
p <i class='el-icon-date'></i> <b>{{event|when}}</b> <br/><small>{{event|to}}</small> time.dt-start(:datetime='event.start_datetime|unixFormat("YYYY-MM-DD HH:mm")') <i class='el-icon-date'></i> <b>{{event|when}}</b> <br/><small>{{event.start_datetime|to}}</small>
p <i class='el-icon-location-outline'></i> <b>{{event.place.name}}</b> - {{event.place.address}} p
i.el-icon-location-outline
b.p-location {{event.place.name}}
span - {{event.place.address}}
el-divider {{$t('common.actions')}} el-divider {{$t('common.actions')}}
el-menu-item( el-menu-item(
v-clipboard:success='copyLink' v-clipboard:success='copyLink'
@@ -77,7 +80,7 @@
el-dropdown-item(icon='el-icon-delete' @click.native='deleteResource(resource)') {{$t('admin.delete_resource')}} el-dropdown-item(icon='el-icon-delete' @click.native='deleteResource(resource)') {{$t('admin.delete_resource')}}
el-dropdown-item(icon='el-icon-lock' @click.native='blockUser(resource)') {{$t('admin.block_user')}} el-dropdown-item(icon='el-icon-lock' @click.native='blockUser(resource)') {{$t('admin.block_user')}}
a(:href='resource.data.url || resource.data.context') a(:href='resource.data.url || resource.data.context')
small {{resource.data.published|datetime}} small {{resource.data.published|dateFormat('ddd, D MMMM HH:mm')}}
div.mt-1(v-html='resource_filter(resource.data.content)') div.mt-1(v-html='resource_filter(resource.data.content)')
span.previewImage(@click='showResource(resource)') span.previewImage(@click='showResource(resource)')
@@ -127,7 +130,7 @@ export default {
rel: 'alternate', rel: 'alternate',
type: 'application/rss+xml', type: 'application/rss+xml',
title: `${this.settings.title} events @${this.event.place.name}`, title: `${this.settings.title} events @${this.event.place.name}`,
href: this.settings.baseurl + `/feed/rss?places=${this.event.placeId}` href: this.settings.baseurl + `/feed/rss?places=${this.event.place.id}`
} }
return { return {
@@ -325,6 +328,10 @@ export default {
</script> </script>
<style lang='less'> <style lang='less'>
#eventDetail { #eventDetail {
time {
margin: 0rem 0rem 0rem 1rem;
display: inline-block;
}
#arrow { #arrow {
position: absolute; position: absolute;
@@ -377,7 +384,7 @@ export default {
div.menu { div.menu {
border-left: 1px solid #e6e6e6; border-left: 1px solid #e6e6e6;
p { p {
margin-left: 10px; margin: 1rem 0rem 1rem 1rem;
} }
} }

View File

@@ -13,40 +13,40 @@ export default ({ app, store }) => {
Vue.filter('linkify', value => value.replace(/(https?:\/\/([^\s]+))/g, '<a href="$1">$2</a>')) Vue.filter('linkify', value => value.replace(/(https?:\/\/([^\s]+))/g, '<a href="$1">$2</a>'))
Vue.filter('url2host', url => url.match(/^https?:\/\/(.[^/:]+)/i)[1]) Vue.filter('url2host', url => url.match(/^https?:\/\/(.[^/:]+)/i)[1])
Vue.filter('datetime', value => moment(value).locale(store.state.locale).format('ddd, D MMMM HH:mm')) Vue.filter('datetime', value => moment(value).locale(store.state.locale).format('ddd, D MMMM HH:mm'))
Vue.filter('dateFormat', (value, format) => moment(value).format(format))
Vue.filter('unixFormat', (timestamp, format) => moment.unix(timestamp).format(format))
// shown in mobile homepage // shown in mobile homepage
Vue.filter('day', value => moment.unix(value).locale(store.state.locale).format('dddd, D MMM')) Vue.filter('day', value => moment.unix(value).locale(store.state.locale).format('dddd, D MMM'))
Vue.filter('to', value => moment().to(value.start_datetime * 1000)) Vue.filter('to', timestamp => moment.unix(timestamp).to())
// format event start/end datetime based on page // format event start/end datetime based on page
Vue.filter('when', (event, where) => {
Vue.filter('when', (event) => {
const start = moment.unix(event.start_datetime) const start = moment.unix(event.start_datetime)
const end = moment.unix(event.end_datetime) const end = moment.unix(event.end_datetime)
const normal = `${start.format('dddd, D MMMM (HH:mm-')}${end.format('HH:mm) ')}` // const normal = `${start.format('dddd, D MMMM (HH:mm-')}${end.format('HH:mm) ')}`
// recurrent event // // recurrent event
if (event.parent && where !== 'home') { // if (event.parent && where !== 'home') {
const { frequency, days, type } = event.parent.recurrent // const { frequency, days, type } = event.parent.recurrent
if (frequency === '1w' || frequency === '2w') { // if (frequency === '1w' || frequency === '2w') {
const recurrent = app.i18n.tc(`event.recurrent_${frequency}_days`, days.length, { days: days.map(d => moment().day(d - 1).format('dddd')) }) // const recurrent = app.i18n.tc(`event.recurrent_${frequency}_days`, days.length, { days: days.map(d => moment().day(d - 1).format('dddd')) })
return `${normal} - ${recurrent}` // return `${normal} - ${recurrent}`
} else if (frequency === '1m' || frequency === '2m') { // } else if (frequency === '1m' || frequency === '2m') {
const d = type === 'ordinal' ? days : days.map(d => moment().day(d - 1).format('dddd')) // const d = type === 'ordinal' ? days : days.map(d => moment().day(d - 1).format('dddd'))
const recurrent = app.i18n.tc(`event.recurrent_${frequency}_${type}`, days.length, { days: d }) // const recurrent = app.i18n.tc(`event.recurrent_${frequency}_${type}`, days.length, { days: d })
return `${normal} - ${recurrent}` // return `${normal} - ${recurrent}`
} // }
return 'recurrent ' // return 'recurrent '
} // }
// multidate // multidate
if (event.multidate) { if (event.multidate) {
return `${start.format('ddd, D MMMM (HH:mm)')} - ${end.format('ddd, D MMMM')}` return `${start.format('ddd, D MMMM HH:mm')} - ${end.format('ddd, D MMMM')}`
} }
// normal event // normal event
if (event.end_datetime && event.end_datetime !== event.start_datetime) { return start.format('ddd, D MMMM HH:mm')
return `${start.format('ddd, D MMMM HH:mm')}`
}
return start.format('dddd, D MMMM (HH:mm)')
}) })
} }

View File

@@ -97,7 +97,7 @@ const eventController = {
}, },
include: [ include: [
{ model: Tag, required: false, attributes: ['tag', 'weigth'], through: { attributes: [] } }, { model: Tag, required: false, attributes: ['tag', 'weigth'], through: { attributes: [] } },
{ model: Place, attributes: ['name', 'address'] }, { model: Place, attributes: ['name', 'address', 'id'] },
{ {
model: Resource, model: Resource,
where: !is_admin && { hidden: false }, where: !is_admin && { hidden: false },