add url to places
This commit is contained in:
parent
409d1e9932
commit
0d0a5677a0
|
@ -700,6 +700,7 @@ func xonkxonk(user *WhatAbout, item junk.Junk, origin string) *Honk {
|
|||
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 @@ func jonkjonk(user *WhatAbout, h *Honk) (junk.Junk, junk.Junk) {
|
|||
t["name"] = p.Name
|
||||
t["latitude"] = p.Latitude
|
||||
t["longitude"] = p.Longitude
|
||||
t["url"] = p.Url
|
||||
tags = append(tags, t)
|
||||
}
|
||||
if len(tags) > 0 {
|
||||
|
|
12
database.go
12
database.go
|
@ -251,7 +251,7 @@ func donksforhonks(honks []*Honk) {
|
|||
}
|
||||
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 @@ func donksforhonks(honks []*Honk) {
|
|||
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 @@ func saveextras(h *Honk) error {
|
|||
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 @@ func prepareStatements(db *sql.DB) {
|
|||
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 = ?")
|
||||
|
|
1
honk.go
1
honk.go
|
@ -92,6 +92,7 @@ type Place struct {
|
|||
Name string
|
||||
Latitude float64
|
||||
Longitude float64
|
||||
Url string
|
||||
}
|
||||
|
||||
type Honker struct {
|
||||
|
|
|
@ -8,7 +8,7 @@ create table zonkers (zonkerid integer primary key, userid integer, name text, w
|
|||
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);
|
||||
|
|
|
@ -188,8 +188,11 @@ func upgradedb() {
|
|||
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)
|
||||
}
|
||||
|
|
2
util.go
2
util.go
|
@ -72,7 +72,7 @@ var dbtimeformat = "2006-01-02 15:04:05"
|
|||
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")
|
||||
|
|
|
@ -43,7 +43,7 @@ in reply to: <a href="{{ .RID }}" rel=noreferrer>{{ .RID }}</a>
|
|||
<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 }}
|
||||
|
|
|
@ -13,6 +13,7 @@ description: <input type="text" name="donkdesc" value="{{ .DonkDesc }}" autocomp
|
|||
<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>
|
||||
|
|
Loading…
Reference in New Issue