7 Commits

Author SHA1 Message Date
1904bfd265 Provide indicator when editing bookmarks 2022-08-21 09:45:27 +09:30
2d488ffdcc Clean up logging 2022-08-21 09:45:10 +09:30
f4c5834f0c Bump version 2022-08-21 09:39:41 +09:30
db72e8fb7d Show database statstics on the info page. 2022-08-21 09:38:44 +09:30
6f93f2ff50 Clean up release notes 2022-08-21 09:37:49 +09:30
2913d510bd Clean up logging 2022-08-21 09:36:50 +09:30
8bd2c87fc6 Add documentation for docker upgrades 2022-08-21 09:15:34 +09:30
9 changed files with 50 additions and 13 deletions

View File

@@ -90,3 +90,4 @@ changelog:
- '^docs:' - '^docs:'
- '^test:' - '^test:'
- '^[Bb]ump' - '^[Bb]ump'
- '^[Cc]lean'

View File

@@ -32,6 +32,11 @@ A self-hosted bookmark database with full-text page content search.
mountpoint. mountpoint.
* Run `docker-compose up -d` * Run `docker-compose up -d`
To upgrade:
* `docker-compose pull`
* `docker-compose up -d`
## Packages (deb/rpm) ## Packages (deb/rpm)
* Download the .deb or .rpm from the releases * Download the .deb or .rpm from the releases

View File

@@ -100,7 +100,6 @@ func (m *BookmarkManager) SaveBookmark(bm *entity.Bookmark) error {
func (m *BookmarkManager) LoadBookmarkByID(id uint64) entity.Bookmark { func (m *BookmarkManager) LoadBookmarkByID(id uint64) entity.Bookmark {
// log.Printf("loading %v", ids) // log.Printf("loading %v", ids)
ret := entity.Bookmark{} ret := entity.Bookmark{}
log.Printf("loading id %d", id)
err := m.db.store.Get(id, &ret) err := m.db.store.Get(id, &ret)
if err != nil { if err != nil {
panic(err) panic(err)
@@ -207,7 +206,6 @@ func (m *BookmarkManager) ScrapeAndIndex(bm *entity.Bookmark) error {
func (m *BookmarkManager) UpdateIndexForBookmark(bm *entity.Bookmark) { func (m *BookmarkManager) UpdateIndexForBookmark(bm *entity.Bookmark) {
words := content.Words(bm) words := content.Words(bm)
words = append(words, bm.Tags...) words = append(words, bm.Tags...)
log.Printf("index for %d %s (%d words)", bm.ID, bm.URL, len(words))
m.db.UpdateIndexForWordsByID(words, bm.ID) m.db.UpdateIndexForWordsByID(words, bm.ID)
} }
@@ -281,3 +279,12 @@ func (m *BookmarkManager) UpdateContent() {
time.Sleep(time.Second * 5) time.Sleep(time.Second * 5)
} }
} }
func (m *BookmarkManager) Stats() (entity.DBStats, error) {
stats := entity.DBStats{}
err := m.db.store.Get("stats", &stats)
if err != nil && err != bolthold.ErrNotFound {
return stats, fmt.Errorf("could not load stats: %s", err)
}
return stats, nil
}

View File

@@ -32,3 +32,16 @@ func (stats DBStats) String() string {
} }
return out return out
} }
func (stats DBStats) MostRecentBookmarkInfo() BookmarkInfo {
mostRecent := time.Time{}
for k := range stats.History {
if k.After(mostRecent) {
mostRecent = k
}
}
if !mostRecent.IsZero() {
return stats.History[mostRecent]
}
return BookmarkInfo{}
}

View File

@@ -10,7 +10,7 @@ import (
"golang.org/x/mod/semver" "golang.org/x/mod/semver"
) )
const Tag = "v0.0.30" const Tag = "v0.0.31"
type Info struct { type Info struct {
Local struct { Local struct {

View File

@@ -35,7 +35,7 @@
<div class="top-bar-right"> <div class="top-bar-right">
<ul class="menu"> <ul class="menu">
<li> <li>
<a href="/releaseinfo">{{ version.Local.Tag }} <a href="/info">{{ version.Local.Tag }}
{{ if version.UpgradeAvailable }} {{ if version.UpgradeAvailable }}
{{ end }} {{ end }}
@@ -63,8 +63,8 @@
{{ template "config.html" . }} {{ template "config.html" . }}
{{ else if eq .page "edit" }} {{ else if eq .page "edit" }}
{{ template "edit.html" . }} {{ template "edit.html" . }}
{{ else if eq .page "releaseinfo" }} {{ else if eq .page "info" }}
{{ template "release_info.html" . }} {{ template "info.html" . }}
{{ end }} {{ end }}
{{/* template "foundation_sample.html" . */}} {{/* template "foundation_sample.html" . */}}
</div> </div>

View File

@@ -30,7 +30,10 @@
</tr> </tr>
</table> </table>
<p> <p>
<button type="button" hx-confirm="Delete this bookmark permanently?" hx-delete="/edit/{{.bookmark.ID}}" class="alert button">delete</button> <button type="button" hx-confirm="Delete this bookmark permanently?" hx-delete="/edit/{{.bookmark.ID}}" class="alert button">Delete</button>
<button type="button" class="button" hx-post="/edit/{{.bookmark.ID}}">save</button> <button type="button" class="button" hx-indicator="#saving" hx-post="/edit/{{.bookmark.ID}}"> {{ if .saved }} Saved {{ else }} Save {{ end }}</button>
<span id="saving" class="htmx-indicator">
<img style="height:1em;" src="/assets/image/beating.gif" /> Saving...
</span>
</p> </p>
</form> </form>

View File

@@ -1,8 +1,12 @@
<div class="grid-x grid-padding-x"> <div class="grid-x grid-padding-x">
<div class="large-12 cell"> <div class="large-12 cell">
<h5>Memory Usage</h5> <h5>System information</h5>
<p>{{ meminfo }}</p> <table>
<tr><th>Memory in use</th><td>{{ meminfo }}</td></tr>
<tr><th>Bookmarks</th><td>{{ .stats.MostRecentBookmarkInfo.Bookmarks }}</td></tr>
<tr><th>Words Indexed</th><td>{{ .stats.MostRecentBookmarkInfo.IndexedWords }}</td></tr>
</table>
<h5>Release info</h5> <h5>Release info</h5>
{{ if not version.Remote.Valid }} {{ if not version.Remote.Valid }}

View File

@@ -371,7 +371,7 @@ func Create(bmm *db.BookmarkManager, cmm *db.ConfigManager) *Server {
bmm.SaveBookmark(&bookmark) bmm.SaveBookmark(&bookmark)
bmm.UpdateIndexForBookmark(&bookmark) // because title may have changed bmm.UpdateIndexForBookmark(&bookmark) // because title may have changed
meta := gin.H{"page": "edit", "bookmark": bookmark, "tw": gin.H{"tags": bookmark.Tags, "tags_hidden": strings.Join(bookmark.Tags, "|")}} meta := gin.H{"page": "edit", "bookmark": bookmark, "saved": true, "tw": gin.H{"tags": bookmark.Tags, "tags_hidden": strings.Join(bookmark.Tags, "|")}}
c.HTML(http.StatusOK, c.HTML(http.StatusOK,
"edit_form.html", meta, "edit_form.html", meta,
@@ -396,8 +396,12 @@ func Create(bmm *db.BookmarkManager, cmm *db.ConfigManager) *Server {
) )
}) })
r.GET("/releaseinfo", func(c *gin.Context) { r.GET("/info", func(c *gin.Context) {
meta := gin.H{"page": "releaseinfo", "config": config} dbStats, err := bmm.Stats()
if err != nil {
panic("could not load stats for info page")
}
meta := gin.H{"page": "info", "stats": dbStats, "config": config}
c.HTML(http.StatusOK, c.HTML(http.StatusOK,
"_layout.html", meta, "_layout.html", meta,
) )