Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a03baca498 | |||
| 1904bfd265 | |||
| 2d488ffdcc | |||
| f4c5834f0c | |||
| db72e8fb7d | |||
| 6f93f2ff50 | |||
| 2913d510bd | |||
| 8bd2c87fc6 |
@@ -90,3 +90,4 @@ changelog:
|
|||||||
- '^docs:'
|
- '^docs:'
|
||||||
- '^test:'
|
- '^test:'
|
||||||
- '^[Bb]ump'
|
- '^[Bb]ump'
|
||||||
|
- '^[Cc]lean'
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
}
|
||||||
|
|||||||
@@ -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{}
|
||||||
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import (
|
|||||||
"golang.org/x/mod/semver"
|
"golang.org/x/mod/semver"
|
||||||
)
|
)
|
||||||
|
|
||||||
const Tag = "v0.0.30"
|
const Tag = "v0.0.32"
|
||||||
|
|
||||||
type Info struct {
|
type Info struct {
|
||||||
Local struct {
|
Local struct {
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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>
|
||||||
@@ -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 }}
|
||||||
17
web/web.go
17
web/web.go
@@ -187,6 +187,13 @@ func Create(bmm *db.BookmarkManager, cmm *db.ConfigManager) *Server {
|
|||||||
r.POST("/search", func(c *gin.Context) {
|
r.POST("/search", func(c *gin.Context) {
|
||||||
query := c.PostForm("query")
|
query := c.PostForm("query")
|
||||||
|
|
||||||
|
// no query, return an empty response
|
||||||
|
if len(query) == 0 {
|
||||||
|
c.Status(http.StatusNoContent)
|
||||||
|
c.Writer.Write([]byte{})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
sr, err := bmm.Search(db.SearchOptions{Query: query})
|
sr, err := bmm.Search(db.SearchOptions{Query: query})
|
||||||
data := gin.H{
|
data := gin.H{
|
||||||
"results": sr,
|
"results": sr,
|
||||||
@@ -371,7 +378,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 +403,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,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user