all repos — honk @ 2adbd7b9611e3365446a5f705207c315e629bddd

my fork of honk

events with start times. because... because.
Ted Unangst tedu@tedunangst.com
Wed, 02 Oct 2019 18:20:14 -0400
commit

2adbd7b9611e3365446a5f705207c315e629bddd

parent

8dadee71f96f6f7be168a4ba624b3c6c5bd3f199

7 files changed, 74 insertions(+), 11 deletions(-)

jump to
M activity.goactivity.go

@@ -541,6 +541,9 @@ fallthrough

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 @@ p.Url, _ = tag.GetString("url")

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 @@ case "update":

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

@@ -966,6 +983,9 @@ tags = append(tags, t)

} 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 {
M database.godatabase.go

@@ -278,6 +278,14 @@ log.Printf("error parsing place: %s", err)

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 @@ }

} 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 @@ log.Printf("error saving place: %s", err)

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 {
M docs/changelog.txtdocs/changelog.txt

@@ -2,6 +2,8 @@ changelog

-- next ++ Times for events. + + Split media database into separate blob.db. + Location checkin. Welcome to the... danger zone!
M views/honk.htmlviews/honk.html

@@ -42,6 +42,9 @@ <details class="noise" {{ .Open }} >

<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 }}
M views/honkform.htmlviews/honkform.html

@@ -5,6 +5,9 @@ <input type="hidden" name="CSRF" value="{{ .HonkCSRF }}">

<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 @@ <p>url: <input type="text" name="placeurl" id=placeurlinput value="">

<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>
M views/honkpage.jsviews/honkpage.js

@@ -207,6 +207,10 @@ honknoise.value = "@" + 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 })
M web.goweb.go

@@ -1052,6 +1052,25 @@ p.Longitude, _ = strconv.ParseFloat(placelong, 64)

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