Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
les
gancio
Commits
a743281e
Commit
a743281e
authored
Oct 02, 2019
by
les
Browse files
[fix] ~
#38
parent
1a62db59
Changes
6
Hide whitespace changes
Inline
Side-by-side
pages/add/_edit.vue
View file @
a743281e
...
...
@@ -114,7 +114,7 @@
import
{
mapActions
,
mapState
,
mapGetters
}
from
'
vuex
'
import
uniq
from
'
lodash/uniq
'
import
map
from
'
lodash/map
'
import
moment
from
'
dayjs
'
import
moment
from
'
moment
'
import
List
from
'
@/components/List
'
import
{
Message
}
from
'
element-ui
'
...
...
@@ -252,7 +252,7 @@ export default {
return
this
.
events
.
filter
(
e
=>
!
e
.
multidate
?
date_start
.
isSame
(
moment
.
unix
(
e
.
start_datetime
),
'
day
'
)
||
date_start
.
isBefore
(
moment
.
unix
(
e
.
start_datime
))
&&
date_end
.
isAfter
(
moment
.
unix
(
e
.
start_datetime
))
date_start
.
isBefore
(
moment
.
unix
(
e
.
start_dat
e
ime
))
&&
date_end
.
isAfter
(
moment
.
unix
(
e
.
start_datetime
))
:
date_start
.
isSame
(
moment
.
unix
(
e
.
start_datetime
),
'
day
'
)
||
date_start
.
isSame
(
moment
.
unix
(
e
.
end_datetime
))
||
date_start
.
isAfter
(
moment
.
unix
(
e
.
start_datetime
))
&&
date_start
.
isBefore
(
moment
.
unix
(
e
.
end_datetime
)))
}
else
if
(
this
.
event
.
type
===
'
recurrent
'
)
{
...
...
@@ -268,6 +268,7 @@ export default {
}
}
,
...
mapGetters
([
'
filteredEvents
'
]),
// TOFIX
attributes
()
{
let
attributes
=
[]
attributes
.
push
({
key
:
'
today
'
,
dates
:
new
Date
(),
highlight
:
{
color
:
'
yellow
'
}
}
)
...
...
@@ -389,8 +390,8 @@ export default {
formData
.
append
(
'
place_address
'
,
this
.
event
.
place
.
address
)
formData
.
append
(
'
description
'
,
this
.
event
.
description
)
formData
.
append
(
'
multidate
'
,
this
.
event
.
type
===
'
multidate
'
)
formData
.
append
(
'
start_datetime
'
,
start_datetime
.
unix
())
formData
.
append
(
'
end_datetime
'
,
end_datetime
.
unix
())
formData
.
append
(
'
start_datetime
'
,
start_datetime
.
utc
(
true
).
unix
())
formData
.
append
(
'
end_datetime
'
,
end_datetime
.
utc
(
true
).
unix
())
if
(
this
.
edit
)
{
formData
.
append
(
'
id
'
,
this
.
event
.
id
)
...
...
plugins/filters.js
View file @
a743281e
import
Vue
from
'
vue
'
import
moment
from
'
dayjs
'
import
'
dayjs/locale/it
'
import
'
dayjs/locale/es
'
import
moment
from
'
moment
'
//
import 'dayjs/locale/it'
//
import 'dayjs/locale/es'
export
default
({
app
,
store
})
=>
{
// replace links with anchors
// TODO: remove fb tracking id
Vue
.
filter
(
'
linkify
'
,
value
=>
value
.
replace
(
/
(
https
?
:
\/\/[^\s]
+
)
/g
,
'
<a href="$1">$1</a>
'
))
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
).
utc
(
false
).
locale
(
store
.
state
.
locale
).
format
(
'
ddd, D MMMM HH:mm
'
))
// Vue.filter('short_datetime', value => moment(value).locale(store.state.locale).format('D/MM HH:mm'))
// Vue.filter('hour', value => moment(value).locale(store.state.locale).format('HH:mm'))
// 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
).
utc
(
false
).
locale
(
store
.
state
.
locale
).
format
(
'
dddd, D MMM
'
))
// Vue.filter('month', value => moment(value).locale(store.state.locale).format('MMM'))
// format event start/end datetime based on page
Vue
.
filter
(
'
when
'
,
(
event
,
where
)
=>
{
moment
.
locale
(
store
.
state
.
locale
)
// {start,end}_datetime are unix timestamp
const
start
=
moment
.
unix
(
event
.
start_datetime
)
const
end
=
moment
.
unix
(
event
.
end_datetime
)
// show local time relative to event's place
// (not where in the worlds I'm looking at the page from)
const
start
=
moment
.
unix
(
event
.
start_datetime
).
utc
(
false
)
const
end
=
moment
.
unix
(
event
.
end_datetime
).
utc
(
false
)
const
normal
=
`
${
start
.
format
(
'
dddd, D MMMM (HH:mm-
'
)}${
end
.
format
(
'
HH:mm)
'
)}
`
// recurrent event
...
...
server/api/controller/event.js
View file @
a743281e
...
...
@@ -188,11 +188,13 @@ const eventController = {
.
month
(
req
.
params
.
month
)
.
startOf
(
'
month
'
)
.
startOf
(
'
week
'
)
.
utc
(
false
)
let
end
=
moment
()
.
year
(
req
.
params
.
year
)
.
month
(
req
.
params
.
month
)
.
endOf
(
'
month
'
)
.
utc
(
false
)
const
shownDays
=
end
.
diff
(
start
,
'
days
'
)
if
(
shownDays
<=
35
)
{
end
=
end
.
add
(
1
,
'
week
'
)
}
...
...
@@ -231,7 +233,7 @@ const eventController = {
if
(
!
recurrent
.
frequency
)
{
return
false
}
let
cursor
=
moment
(
start
).
startOf
(
'
week
'
)
const
start_date
=
moment
.
unix
(
e
.
start_datetime
)
const
start_date
=
moment
.
unix
(
e
.
start_datetime
)
.
utc
(
false
)
const
duration
=
moment
.
unix
(
e
.
end_datetime
).
diff
(
start_date
,
'
s
'
)
const
frequency
=
recurrent
.
frequency
const
days
=
recurrent
.
days
...
...
@@ -239,7 +241,6 @@ const eventController = {
// default frequency is '1d' => each day
const
toAdd
=
{
n
:
1
,
unit
:
'
day
'
}
cursor
.
set
(
'
hour
'
,
start_date
.
hour
()).
set
(
'
minute
'
,
start_date
.
minutes
())
// each week or 2 (search for the first specified day)
if
(
frequency
===
'
1w
'
||
frequency
===
'
2w
'
)
{
...
...
@@ -253,6 +254,8 @@ const eventController = {
// cursor.set('hour', start_date.hour()).set('minute', start_date.minutes())
}
cursor
.
set
(
'
hour
'
,
start_date
.
hour
()).
set
(
'
minute
'
,
start_date
.
minutes
())
// each month or 2
if
(
frequency
===
'
1m
'
||
frequency
===
'
2m
'
)
{
// find first match
...
...
@@ -275,12 +278,13 @@ const eventController = {
cursor
.
day
(
d
-
1
)
}
if
(
cursor
.
isAfter
(
dueTo
)
||
cursor
.
isBefore
(
start
))
{
return
}
e
.
start_datetime
=
cursor
.
unix
()
e
.
start_datetime
=
cursor
.
utc
(
true
).
unix
()
e
.
end_datetime
=
e
.
start_datetime
+
duration
events
.
push
(
Object
.
assign
({},
e
))
})
if
(
cursor
.
isAfter
(
dueTo
))
{
break
}
cursor
=
first_event_of_week
.
add
(
toAdd
.
n
,
toAdd
.
unit
)
cursor
.
set
(
'
hour
'
,
start_date
.
hour
()).
set
(
'
minute
'
,
start_date
.
minutes
())
}
return
events
...
...
server/api/controller/export.js
View file @
a743281e
...
...
@@ -51,8 +51,8 @@ const exportController = {
ics
(
res
,
events
)
{
const
eventsMap
=
events
.
map
(
e
=>
{
const
tmpStart
=
moment
.
unix
(
e
.
start_datetime
)
const
tmpEnd
=
moment
.
unix
(
e
.
end_datetime
)
const
tmpStart
=
moment
.
unix
(
e
.
start_datetime
)
.
utc
(
false
)
const
tmpEnd
=
moment
.
unix
(
e
.
end_datetime
)
.
utc
(
false
)
const
start
=
[
tmpStart
.
year
(),
tmpStart
.
month
()
+
1
,
tmpStart
.
date
(),
tmpStart
.
hour
(),
tmpStart
.
minute
()]
const
end
=
[
tmpEnd
.
year
(),
tmpEnd
.
month
()
+
1
,
tmpEnd
.
date
(),
tmpEnd
.
hour
(),
tmpEnd
.
minute
()]
return
{
...
...
server/api/models/event.js
View file @
a743281e
...
...
@@ -36,13 +36,12 @@ module.exports = (sequelize, DataTypes) => {
event
.
hasMany
(
models
.
comment
)
}
//
event
.
prototype
.
toAP
=
function
(
username
,
follower
=
[])
{
const
tags
=
this
.
tags
&&
this
.
tags
.
map
(
t
=>
`<a href='/tags/
${
t
.
tag
}
' class='mention hashtag' rel='tag'>#
${
t
.
tag
}
</a>`
).
join
(
'
'
)
const
content
=
`<a href='
${
config
.
baseurl
}
/event/
${
this
.
id
}
'>
${
this
.
title
}
</a><br/>
📍
${
this
.
place
.
name
}
<br/>
⏰
${
moment
.
unix
(
this
.
start_datetime
).
format
(
'
dddd, D MMMM (HH:mm)
'
)}
<br/><br/>
⏰
${
moment
.
unix
(
this
.
start_datetime
).
utc
(
false
).
format
(
'
dddd, D MMMM (HH:mm)
'
)}
<br/><br/>
${
this
.
description
.
length
>
200
?
this
.
description
.
substr
(
0
,
200
)
+
'
...
'
:
this
.
description
}
<br/>
${
tags
}
<br/>`
...
...
@@ -74,12 +73,6 @@ module.exports = (sequelize, DataTypes) => {
content
,
summary
:
null
,
sensitive
:
false
,
startTime
:
moment
.
unix
(
this
.
start_datetime
),
location
:
{
type
:
'
Place
'
,
name
:
this
.
place
.
name
,
address
:
this
.
place
.
address
}
}
}
...
...
views/feed/rss.pug
View file @
a743281e
...
...
@@ -7,13 +7,13 @@ rss(version='2.0')
language #{config.locale}
each event in events
item
title [#{moment.unix(event.start_datetime).format("YY-MM-DD")}] #{event.title} @#{event.place.name}
title [#{moment.unix(event.start_datetime).
utc(false).
format("YY-MM-DD")}] #{event.title} @#{event.place.name}
link #{config.baseurl}/event/#{event.id}
description
| <![CDATA[
| <h4>#{event.title}</h4>
| <strong>#{event.place.name} - #{event.place.address}</strong>
| <small>(#{moment.unix(event.start_datetime).format("dddd, D MMMM HH:mm")})</small><br/>
| <small>(#{moment.unix(event.start_datetime).
utc(false).
format("dddd, D MMMM HH:mm")})</small><br/>
if (event.image_path)
| <img src="#{config.apiurl}/media/#{event.image_path}"/>
| <pre>!{event.description}</pre>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment