all repos — honk @ 30e1f606f1c5ab61d146ccc14d44f7f7570f3f8b

my fork of honk

add url to places
Ted Unangst tedu@tedunangst.com
Sun, 29 Sep 2019 16:07:35 -0400
commit

30e1f606f1c5ab61d146ccc14d44f7f7570f3f8b

parent

669d5fd446365e7a0f90a7d3aca5d5b40a90920c

9 files changed, 18 insertions(+), 10 deletions(-)

jump to
M activity.goactivity.go

@@ -700,6 +700,7 @@ p := new(Place)

p.Name = name p.Latitude, _ = tag["latitude"].(float64) p.Longitude, _ = tag["longitude"].(float64) + p.Url, _ = tag.GetString("url") log.Printf("place: %v", p) xonk.Place = p }

@@ -931,6 +932,7 @@ t["type"] = "Place"

t["name"] = p.Name t["latitude"] = p.Latitude t["longitude"] = p.Longitude + t["url"] = p.Url tags = append(tags, t) } if len(tags) > 0 {
M database.godatabase.go

@@ -251,7 +251,7 @@ h.Onts = append(h.Onts, o)

} rows.Close() // grab places - q = fmt.Sprintf("select honkid, name, latitude, longitude from places where honkid in (%s)", strings.Join(ids, ",")) + q = fmt.Sprintf("select honkid, name, latitude, longitude, url from places where honkid in (%s)", strings.Join(ids, ",")) rows, err = db.Query(q) if err != nil { log.Printf("error querying places: %s", err)

@@ -261,7 +261,7 @@ defer rows.Close()

for rows.Next() { var hid int64 p := new(Place) - err = rows.Scan(&hid, &p.Name, &p.Latitude, &p.Longitude) + err = rows.Scan(&hid, &p.Name, &p.Latitude, &p.Longitude, &p.Url) if err != nil { log.Printf("error scanning place: %s", err) continue

@@ -303,10 +303,10 @@ log.Printf("error saving ont: %s", err)

return err } } - if h.Place != nil { - _, err := stmtSavePlace.Exec(h.ID, h.Place.Name, h.Place.Latitude, h.Place.Longitude) + if p := h.Place; p != nil { + _, err := stmtSavePlace.Exec(h.ID, p.Name, p.Latitude, p.Longitude, p.Url) if err != nil { - log.Printf("error saving ont: %s", err) + log.Printf("error saving place: %s", err) return err } }

@@ -419,7 +419,7 @@ stmtSaveOld = preparetodie(db, "insert into forsaken (honkid, precis, noise) values (?, ?, ?)")

stmtSaveHonk = preparetodie(db, "insert into honks (userid, what, honker, xid, rid, dt, url, audience, noise, convoy, whofore, format, precis, oonker, flags) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)") stmtDeleteHonk = preparetodie(db, "delete from honks where honkid = ?") stmtUpdateHonk = preparetodie(db, "update honks set precis = ?, noise = ?, format = ?, dt = ? where honkid = ?") - stmtSavePlace = preparetodie(db, "insert into places (honkid, name, latitude, longitude) values (?, ?, ?, ?)") + stmtSavePlace = preparetodie(db, "insert into places (honkid, name, latitude, longitude, url) values (?, ?, ?, ?, ?)") stmtDeletePlace = preparetodie(db, "delete from places where honkid = ?") stmtSaveOnt = preparetodie(db, "insert into onts (ontology, honkid) values (?, ?)") stmtDeleteOnts = preparetodie(db, "delete from onts where honkid = ?")
M honk.gohonk.go

@@ -92,6 +92,7 @@ type Place struct {

Name string Latitude float64 Longitude float64 + Url string } type Honker struct {
M schema.sqlschema.sql

@@ -8,7 +8,7 @@ create table zonkers (zonkerid integer primary key, userid integer, name text, wherefore text);

create table doovers(dooverid integer primary key, dt text, tries integer, username text, rcpt text, msg blob); create table onts (ontology text, honkid integer); create table forsaken (honkid integer, precis text, noise text); -create table places (honkid integer, name text, latitude real, longitude real); +create table places (honkid integer, name text, latitude real, longitude real, url text); create index idx_honksxid on honks(xid); create index idx_honksconvoy on honks(convoy);
M upgradedb.goupgradedb.go

@@ -188,8 +188,11 @@ doordie(db, "update config set value = 19 where key = 'dbversion'")

case 19: doordie(db, "create table places (honkid integer, name text, latitude real, longitude real)") doordie(db, "create index idx_placehonkid on places(honkid)") - doordie(db, "update config set value = 20 where key = 'dbversion'") case 20: + doordie(db, "alter table places add column url text") + doordie(db, "update places set url = ''") + doordie(db, "update config set value = 21 where key = 'dbversion'") + case 21: default: log.Fatalf("can't upgrade unknown version %d", dbversion) }
M util.goutil.go

@@ -72,7 +72,7 @@

var alreadyopendb *sql.DB var dbname = "honk.db" var stmtConfig *sql.Stmt -var myVersion = 20 +var myVersion = 21 func initdb() { schema, err := ioutil.ReadFile("schema.sql")
M views/honk.htmlviews/honk.html

@@ -43,7 +43,7 @@ <summary>{{ .HTPrecis }}</summary>

<p>{{ .HTPrecis }} <p>{{ .HTML }} {{ with .Place }} -<p>Location: {{ .Name }} <a href="https://www.openstreetmap.org/?mlat={{ .Latitude }}&mlon={{ .Longitude}}">{{ .Latitude }} {{ .Longitude }}</a> +<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 }} {{ range .Donks }} {{ if .Local }}
M views/honkform.htmlviews/honkform.html

@@ -13,6 +13,7 @@ description: <input type="text" name="donkdesc" value="{{ .DonkDesc }}" autocomplete=off>

<p><button id=checkinbutton type=button onclick="fillcheckin()">checkin</button> <div id=placedescriptor style="display: none"> <p>name: <input type="text" name="placename" id=placenameinput value=""> +<p>url: <input type="text" name="placeurl" id=placeurlinput value=""> <p>latitude: <input type="text" name="placelat" id=placelatinput value=""> <p>longitude: <input type="text" name="placelong" id=placelonginput value=""> </div>
M web.goweb.go

@@ -1047,6 +1047,7 @@ p := new(Place)

p.Name = placename p.Latitude, _ = strconv.ParseFloat(placelat, 64) p.Longitude, _ = strconv.ParseFloat(placelong, 64) + p.Url = r.FormValue("placeurl") honk.Place = p }