events with start times. because... because.

Ted Unangst 5 years ago
parent 4516b74ac7
commit dc56ed5aa2

@ -541,6 +541,9 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
case "Page":
obj = item
what = "honk"
case "Event":
obj = item
what = "event"
default:
log.Printf("unknown activity: %s", what)
fd, _ := os.OpenFile("savedinbox.json", os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
@ -710,6 +713,16 @@ func xonksaver(user *WhatAbout, item junk.Junk, origin string) *Honk {
xonk.Place = p
}
}
starttime, ok := obj.GetString("startTime")
if ok {
start, err := time.Parse(time.RFC3339, starttime)
if err == nil {
t := new(Time)
t.StartTime = start
xonk.Time = t
}
}
xonk.Onts = oneofakind(xonk.Onts)
replyobj, ok := obj.GetMap("replies")
if ok {
@ -878,16 +891,20 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
fallthrough
case "tonk":
fallthrough
case "event":
fallthrough
case "honk":
j["type"] = "Create"
if h.What == "update" {
j["type"] = "Update"
} else {
j["type"] = "Create"
}
jo = junk.New()
jo["id"] = h.XID
jo["type"] = "Note"
if h.What == "event" {
jo["type"] = "Event"
}
jo["published"] = dt
jo["url"] = h.XID
jo["attributedTo"] = user.URL
@ -967,6 +984,9 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
if len(tags) > 0 {
jo["tag"] = tags
}
if t := h.Time; t != nil {
jo["startTime"] = t.StartTime.Format(time.RFC3339)
}
var atts []junk.Junk
for _, d := range h.Donks {
if re_emus.MatchString(d.Name) {

@ -278,6 +278,14 @@ func donksforhonks(honks []*Honk) {
continue
}
h.Place = p
case "time":
t := new(Time)
err = unjsonify(j, t)
if err != nil {
log.Printf("error parsing time: %s", err)
continue
}
h.Time = t
case "oldrev":
default:
log.Printf("unknown meta genus: %s", genus)
@ -334,7 +342,7 @@ func saveextras(h *Honk) error {
}
if p := h.Place; p != nil {
j, err := jsonify(p)
if err != nil {
if err == nil {
_, err = stmtSaveMeta.Exec(h.ID, "place", j)
}
if err != nil {
@ -342,9 +350,9 @@ func saveextras(h *Honk) error {
return err
}
}
if p := h.Time; p != nil {
j, err := jsonify(p)
if err != nil {
if t := h.Time; t != nil {
j, err := jsonify(t)
if err == nil {
_, err = stmtSaveMeta.Exec(h.ID, "time", j)
}
if err != nil {

@ -2,6 +2,8 @@ changelog
-- next
+ Times for events.
+ Split media database into separate blob.db.
+ Location checkin. Welcome to the... danger zone!

@ -42,6 +42,9 @@ in reply to: <a href="{{ .RID }}" rel=noreferrer>{{ .RID }}</a>
<summary>{{ .HTPrecis }}<p></summary>
<p>{{ .HTPrecis }}
<p>{{ .HTML }}
{{ with .Time }}
<p>Time: {{ .StartTime.Local }}
{{ end }}
{{ with .Place }}
<p>Location: {{ with .Url }}<a href="{{ . }}" rel=noreferrer>{{ end }}{{ .Name }}{{ if .Url }}</a>{{ end }} <a href="https://www.openstreetmap.org/?mlat={{ .Latitude }}&mlon={{ .Longitude}}" rel=noreferrer>{{ .Latitude }} {{ .Longitude }}</a>
{{ end }}

@ -5,6 +5,9 @@
<input type="hidden" name="updatexid" value = "{{ .UpdateXID }}">
<input type="hidden" name="rid" id="ridinput" value="{{ .InReplyTo }}">
<p>
<details>
<summary>more options</summary>
<p>
<label id="donker">attach: {{ if .SavedFile }} {{ .SavedFile }} {{ else }} <input onchange="updatedonker();" type="file" name="donk"><span></span> {{ end }}</label>
<input type="hidden" name="donkxid" value="{{ .SavedFile }}">
<p id="donkdescriptor">
@ -16,6 +19,12 @@ desc: <input type="text" name="donkdesc" value="{{ .DonkDesc }}" autocomplete=of
<p>lat: <input type="text" size=9 name="placelat" id=placelatinput value="">
lon: <input type="text" size=9 name="placelong" id=placelonginput value="">
</div>
<p><button id=addtimebutton type=button onclick="showelement('timedescriptor')">add time</button>
<div id=timedescriptor style="display: none">
<p>start: <input type="text" name="timestart" value="">
<p>end: <input type="text" name="timeend" value="">
</div>
</details>
<p>
<textarea name="noise" id="honknoise">{{ .Noise }}</textarea>
<p>

@ -207,6 +207,10 @@ function showhonkform(elem, rid, hname) {
}
document.getElementById("honknoise").focus()
}
function showelement(id) {
var el = document.getElementById(id)
el.style.display = "block"
}
function updatedonker() {
var el = document.getElementById("donker")
el.children[1].textContent = el.children[0].value.slice(-20)
@ -217,16 +221,14 @@ var checkinprec = 500.0
function fillcheckin() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(function(pos) {
var el = document.getElementById("placedescriptor")
el.style.display = "block"
el = document.getElementById("placelatinput")
showelement("placedescriptor")
var el = document.getElementById("placelatinput")
el.value = Math.round(pos.coords.latitude * checkinprec) / checkinprec
el = document.getElementById("placelonginput")
el.value = Math.round(pos.coords.longitude * checkinprec) / checkinprec
checkinprec = 10000.0
}, function(err) {
var el = document.getElementById("placedescriptor")
el.style.display = "block"
showelement("placedescriptor")
el = document.getElementById("placenameinput")
el.value = err.message
})

@ -1052,6 +1052,25 @@ func submithonk(w http.ResponseWriter, r *http.Request) {
p.Url = r.FormValue("placeurl")
honk.Place = p
}
timestart := r.FormValue("timestart")
if timestart != "" {
t := new(Time)
now := time.Now().Local()
for _, layout := range []string{"3:04pm", "15:04"} {
start, err := time.Parse(layout, timestart)
if err == nil {
if start.Year() == 0 {
start = time.Date(now.Year(), now.Month(), now.Day(), start.Hour(), start.Minute(), 0, 0, now.Location())
}
t.StartTime = start
break
}
}
if !t.StartTime.IsZero() {
honk.What = "event"
honk.Time = t
}
}
if honk.Public {
honk.Whofore = 2

Loading…
Cancel
Save