add url to places
Ted Unangst tedu@tedunangst.com
Sun, 29 Sep 2019 16:07:35 -0400
9 files changed,
18 insertions(+),
10 deletions(-)
M
activity.go
→
activity.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.go
→
database.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
schema.sql
→
schema.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.go
→
upgradedb.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
views/honk.html
→
views/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.html
→
views/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>