Merge the feature branch to introduce the bleve indexing.
commite8c2bc7e4aAuthor: Justin Hawkins <justin@hawkins.id.au> Date: Sat May 3 12:36:18 2025 +0930 Clean up menu/version commit1993533a46Author: Justin Hawkins <justin@hawkins.id.au> Date: Sat May 3 12:31:50 2025 +0930 Update README commit044cc830dcAuthor: Justin Hawkins <justin@hawkins.id.au> Date: Sat May 3 12:22:33 2025 +0930 No longer needed commita7c37ad7c5Author: Justin Hawkins <justin@hawkins.id.au> Date: Sat May 3 12:14:59 2025 +0930 Fixup version handling commitade0b748e9Author: Justin Hawkins <justin@hawkins.id.au> Date: Sat May 3 11:58:15 2025 +0930 Use the correct analyser for searches commite5a65cf5cfAuthor: Justin Hawkins <justin@hawkins.id.au> Date: Fri May 2 19:51:54 2025 +0930 Fix version in template commit0171be0ee4Author: Justin Hawkins <justin@hawkins.id.au> Date: Fri May 2 19:51:41 2025 +0930 Rescrape all links if needed on startup commitae654998f7Author: Justin Hawkins <justin@hawkins.id.au> Date: Fri May 2 19:51:25 2025 +0930 Spelling commitbfe9bbee02Author: Justin Hawkins <justin@hawkins.id.au> Date: Fri May 2 19:34:06 2025 +0930 Make goreleaser set the version commit4436313413Author: Justin Hawkins <justin@hawkins.id.au> Date: Fri May 2 11:43:58 2025 +0930 Make release matrix sane commit7b467ecee7Author: Justin Hawkins <justin@hawkins.id.au> Date: Fri May 2 11:40:07 2025 +0930 I hate YAML, so much. commitb578e0f044Author: Justin Hawkins <justin@hawkins.id.au> Date: Thu May 1 23:47:07 2025 +0930 Update goreleaser commitfba84f0827Author: Justin Hawkins <justin@hawkins.id.au> Date: Thu May 1 23:45:46 2025 +0930 Update version commite4edb08bd1Author: Justin Hawkins <justin@hawkins.id.au> Date: Thu May 1 23:42:59 2025 +0930 Deps commit58b6692d1bAuthor: Justin Hawkins <justin@hawkins.id.au> Date: Thu May 1 23:39:51 2025 +0930 Mostly done, first cut commitbadbe5e92fAuthor: Justin Hawkins <justin@hawkins.id.au> Date: Sun Apr 27 20:28:37 2025 +0930 Remove unused code commit903240dd18Author: Justin Hawkins <justin@hawkins.id.au> Date: Sun Apr 27 20:26:19 2025 +0930 Update deps commitde90b9951aAuthor: Justin Hawkins <justin@hawkins.id.au> Date: Sun Apr 27 20:21:33 2025 +0930 Keep on bleving commit9b15528510Author: Justin Hawkins <justin@hawkins.id.au> Date: Fri Apr 25 23:57:04 2025 +0930 Start of blevification
This commit is contained in:
@@ -23,6 +23,7 @@
|
||||
<li>
|
||||
<a href="#">Admin</a>
|
||||
<ul class="menu vertical">
|
||||
<li><a href="/info">System Info</a></li>
|
||||
<li><a href="/config">Configuration</a></li>
|
||||
<li><a href="/manage">Manage links</a></li>
|
||||
<li><a href="/export">Export all URLs</a></li>
|
||||
@@ -34,12 +35,11 @@
|
||||
</div>
|
||||
<div class="top-bar-right">
|
||||
<ul class="menu">
|
||||
<li>
|
||||
<a href="/info">{{ version.Local.Tag }}
|
||||
<li class="menu-text">
|
||||
{{ version.Local.Version }}
|
||||
{{ if version.UpgradeAvailable }}
|
||||
❗
|
||||
<a href="/info">❗</a>
|
||||
{{ end }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="https://github.com/tardisx/linkwallet">
|
||||
|
||||
@@ -4,15 +4,14 @@
|
||||
<h5>System information</h5>
|
||||
<table>
|
||||
<tr><th>Memory in use</th><td>{{ meminfo }}</td></tr>
|
||||
<tr><th>Database disk size</th><td>{{ niceSizeMB .stats.FileSize }}Mb</td></tr>
|
||||
<tr><th>Bookmarks DB size</th><td>{{ niceSizeMB .stats.FileSize }}Mb</td></tr>
|
||||
<tr><th>Bookmarks index size</th><td>{{ niceSizeMB .stats.IndexSize }}Mb</td></tr>
|
||||
<tr><th>Bookmarks</th><td>{{ .stats.MostRecentBookmarkInfo.Bookmarks }}</td></tr>
|
||||
<tr><th>Words in index</th><td>{{ .stats.MostRecentBookmarkInfo.IndexedWords }}</td></tr>
|
||||
<tr><th>Total searches</th><td>{{ .stats.Searches }}</td></tr>
|
||||
</table>
|
||||
|
||||
<h5>Database information</h5>
|
||||
<img src="/graph/bookmarks">
|
||||
<img src="/graph/indexed_words">
|
||||
|
||||
</div>
|
||||
<div class="large-6 medium-12 cell">
|
||||
@@ -27,7 +26,7 @@
|
||||
<a href="https://github.com/tardisx/linkwallet/releases/tag/{{ version.Remote.Tag }}">
|
||||
{{ version.Remote.Tag }}
|
||||
</a>
|
||||
(you have {{ version.Local.Tag }}).
|
||||
(you have {{ version.Local.Version }}).
|
||||
</p>
|
||||
|
||||
{{ markdown version.UpgradeReleaseNotes }}
|
||||
|
||||
@@ -12,9 +12,7 @@
|
||||
hx-indicator="#htmx-indicator-search" id="manage-search" />
|
||||
</div>
|
||||
</div>
|
||||
{{ template "tags_widget.html" . }}
|
||||
{{ template "manage_results.html" . }}
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -2,29 +2,29 @@
|
||||
<table id="manage-results">
|
||||
<tr>
|
||||
<th> </th>
|
||||
{{ template "manage_results_column_header.html" .column.title }}
|
||||
<th>title</th>
|
||||
<th>tags</th>
|
||||
{{ template "manage_results_column_header.html" .column.created }}
|
||||
{{ template "manage_results_column_header.html" .column.scraped }}
|
||||
<th>created</th>
|
||||
<th>scraped</th>
|
||||
</tr>
|
||||
{{ range .bookmarks }}
|
||||
{{ range .results }}
|
||||
<tr>
|
||||
<th><a class="button" href="/edit/{{ .ID }}">edit</a></th>
|
||||
<th><a class="button" href="/edit/{{ .Bookmark.ID }}">edit</a></th>
|
||||
<td>
|
||||
<a href="{{ .URL }}">{{ .Info.Title }}</a>
|
||||
<a href="{{ .Bookmark.URL }}">{{ .Bookmark.Info.Title }}</a>
|
||||
<br>
|
||||
<a href="{{ .URL }}">{{ niceURL .URL }}</a>
|
||||
<a href="{{ .Bookmark.URL }}">{{ niceURL .Bookmark.URL }}</a>
|
||||
</td>
|
||||
<td>
|
||||
{{ range .Tags }}
|
||||
{{ range .Bookmark.Tags }}
|
||||
<span class="label primary">{{ . }}</span>
|
||||
{{ end }}
|
||||
</td>
|
||||
<td class="show-for-large">{{ (nicetime .TimestampCreated).HumanDuration }} ago</td>
|
||||
<td class="show-for-large">{{ (nicetime .TimestampLastScraped).HumanDuration }} ago</td>
|
||||
<td class="show-for-large">{{ (nicetime .Bookmark.TimestampCreated).HumanDuration }} ago</td>
|
||||
<td class="show-for-large">{{ (nicetime .Bookmark.TimestampLastScraped).HumanDuration }} ago</td>
|
||||
|
||||
<td>
|
||||
<a class="button" hx-swap="outerHTML" hx-post="/scrape/{{ .ID }}">scrape</button>
|
||||
<a class="button" hx-swap="outerHTML" hx-post="/scrape/{{ .Bookmark.ID }}">scrape</button>
|
||||
</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
|
||||
<th class="{{ .Class }}" hx-post="/manage/results?sort={{ .URLString }}" hx-target="#manage-results">{{ .Name }} {{ .TitleArrow }}
|
||||
</th>
|
||||
@@ -1,5 +1,8 @@
|
||||
<ul>
|
||||
{{ range .results }}
|
||||
<li><a href="{{ .URL }}">{{ .Info.Title }}</a> - {{ .URL }}</li>
|
||||
<li>
|
||||
<a href="{{ .Bookmark.URL }}">{{ .Bookmark.Info.Title }}</a><br>
|
||||
{{ .Highlight }}
|
||||
</li>
|
||||
{{ end }}
|
||||
</ul>
|
||||
71
web/web.go
71
web/web.go
@@ -50,26 +50,9 @@ type Server struct {
|
||||
}
|
||||
|
||||
type ColumnInfo struct {
|
||||
Name string
|
||||
Param string
|
||||
Sorted string
|
||||
Class string
|
||||
}
|
||||
|
||||
func (c ColumnInfo) URLString() string {
|
||||
if c.Sorted == "asc" {
|
||||
return "-" + c.Param
|
||||
}
|
||||
return c.Param
|
||||
}
|
||||
|
||||
func (c ColumnInfo) TitleArrow() string {
|
||||
if c.Sorted == "asc" {
|
||||
return "↑"
|
||||
} else if c.Sorted == "desc" {
|
||||
return "↓"
|
||||
}
|
||||
return ""
|
||||
Name string
|
||||
Param string
|
||||
Class string
|
||||
}
|
||||
|
||||
// Create creates a new web server instance and sets up routing.
|
||||
@@ -126,9 +109,8 @@ func Create(bmm *db.BookmarkManager, cmm *db.ConfigManager) *Server {
|
||||
})
|
||||
|
||||
r.GET("/manage", func(c *gin.Context) {
|
||||
|
||||
allBookmarks, _ := bmm.ListBookmarks()
|
||||
meta := gin.H{"page": "manage", "config": config, "bookmarks": allBookmarks}
|
||||
results, _ := bmm.Search(db.SearchOptions{All: true})
|
||||
meta := gin.H{"page": "manage", "config": config, "results": results}
|
||||
c.HTML(http.StatusOK,
|
||||
"_layout.html", meta,
|
||||
)
|
||||
@@ -136,36 +118,18 @@ func Create(bmm *db.BookmarkManager, cmm *db.ConfigManager) *Server {
|
||||
|
||||
r.POST("/manage/results", func(c *gin.Context) {
|
||||
query := c.PostForm("query")
|
||||
tags := []string{}
|
||||
sort := c.Query("sort")
|
||||
|
||||
if c.PostForm("tags_hidden") != "" {
|
||||
tags = strings.Split(c.PostForm("tags_hidden"), "|")
|
||||
results := make([]entity.BookmarkSearchResult, 0)
|
||||
if query == "" {
|
||||
results, _ = bmm.Search(db.SearchOptions{All: true, Results: 100})
|
||||
} else {
|
||||
results, _ = bmm.Search(db.SearchOptions{Query: query})
|
||||
}
|
||||
allBookmarks, _ := bmm.Search(db.SearchOptions{Query: query, Tags: tags, Sort: sort})
|
||||
meta := gin.H{"config": config, "bookmarks": allBookmarks}
|
||||
meta := gin.H{"config": config, "results": results}
|
||||
|
||||
colTitle := &ColumnInfo{Name: "Title/URL", Param: "title"}
|
||||
colCreated := &ColumnInfo{Name: "Created", Param: "created", Class: "show-for-large"}
|
||||
colScraped := &ColumnInfo{Name: "Scraped", Param: "scraped", Class: "show-for-large"}
|
||||
if sort == "title" {
|
||||
colTitle.Sorted = "asc"
|
||||
}
|
||||
if sort == "-title" {
|
||||
colTitle.Sorted = "desc"
|
||||
}
|
||||
if sort == "scraped" {
|
||||
colScraped.Sorted = "asc"
|
||||
}
|
||||
if sort == "-scraped" {
|
||||
colScraped.Sorted = "desc"
|
||||
}
|
||||
if sort == "created" {
|
||||
colCreated.Sorted = "asc"
|
||||
}
|
||||
if sort == "-created" {
|
||||
colCreated.Sorted = "desc"
|
||||
}
|
||||
|
||||
cols := gin.H{
|
||||
"title": colTitle,
|
||||
@@ -174,9 +138,7 @@ func Create(bmm *db.BookmarkManager, cmm *db.ConfigManager) *Server {
|
||||
}
|
||||
meta["column"] = cols
|
||||
|
||||
c.HTML(http.StatusOK,
|
||||
"manage_results.html", meta,
|
||||
)
|
||||
c.HTML(http.StatusOK, "manage_results.html", meta)
|
||||
|
||||
})
|
||||
|
||||
@@ -465,10 +427,7 @@ func Create(bmm *db.BookmarkManager, cmm *db.ConfigManager) *Server {
|
||||
|
||||
func plotPoints(sortedKeys []time.Time, dbStats entity.DBStats, p *plot.Plot, k string) {
|
||||
|
||||
if k == "indexed_words" {
|
||||
p.Title.Text = "Indexed words over time"
|
||||
p.Y.Label.Text = "Words indexed"
|
||||
} else if k == "bookmarks" {
|
||||
if k == "bookmarks" {
|
||||
p.Title.Text = "Bookmarks over time"
|
||||
p.Y.Label.Text = "Bookmarks"
|
||||
} else {
|
||||
@@ -479,9 +438,7 @@ func plotPoints(sortedKeys []time.Time, dbStats entity.DBStats, p *plot.Plot, k
|
||||
pts := make(plotter.XYs, len(sortedKeys))
|
||||
for i := range sortedKeys {
|
||||
pts[i].X = float64(sortedKeys[i].Unix())
|
||||
if k == "indexed_words" {
|
||||
pts[i].Y = float64(dbStats.History[sortedKeys[i]].IndexedWords)
|
||||
} else if k == "bookmarks" {
|
||||
if k == "bookmarks" {
|
||||
pts[i].Y = float64(dbStats.History[sortedKeys[i]].Bookmarks)
|
||||
} else {
|
||||
panic("bad key")
|
||||
|
||||
Reference in New Issue
Block a user