8 Commits

6 changed files with 32 additions and 15 deletions

View File

@@ -1,9 +1,11 @@
package db
import (
"errors"
"fmt"
"io"
"log"
"strings"
"sync"
"time"
@@ -32,6 +34,12 @@ func NewBookmarkManager(db *DB) *BookmarkManager {
// if this bookmark already exists (based on URL match).
// The entity.Bookmark ID field will be updated.
func (m *BookmarkManager) AddBookmark(bm *entity.Bookmark) error {
if strings.Index(bm.URL, "https://") != 0 &&
strings.Index(bm.URL, "http://") != 0 {
return errors.New("URL must begin with http:// or https://")
}
existing := entity.Bookmark{}
err := m.db.store.FindOne(&existing, bolthold.Where("URL").Eq(bm.URL))
if err != bolthold.ErrNotFound {

View File

@@ -8,7 +8,7 @@ import (
"golang.org/x/mod/semver"
)
const Tag = "v0.0.24"
const Tag = "v0.0.27"
var versionInfo struct {
Local struct {
@@ -55,7 +55,7 @@ func UpdateVersionInfo() {
rels, _, err := client.Repositories.ListReleases(context.Background(), "tardisx", "linkwallet", nil)
if err != nil {
panic(err)
return
}
if len(rels) == 0 {
return

View File

@@ -1,18 +1,18 @@
<div class="large-8 medium-8 cell" id="add-url-form" >
<div>
<h5 style="display:inline-block;">Add a new URL</h5>
<p style="display:inline-block;">[<a hx-get="/bulk_add" hx-target="#add-url-form" href="#">bulk add</a>]</h5>
<div style="display:inline-block;">[<a hx-get="/bulk_add" hx-swap="outerHTML" hx-target="#add-url-form" href="#">bulk add</a>]</div></h5>
</div>
<form onsubmit="return false">
<div class="grid-x grid-padding-x">
<div class="large-6 cell">
<div class="medium-6 cell">
<label>URL</label>
<input type="text" name="url" value="{{ .url }}"
hx-trigger=""
/>
</div>
<div class="large-6 cell">
<div class="medium-6 cell">
{{ template "tags_widget.html" . }}
</div>
</div>

View File

@@ -1,14 +1,13 @@
<div class="large-8 medium-8 cell" id="add-url-form" >
<div>
<h5 style="display:inline-block;">Add bulk URLs</h5>
<p style="display:inline-block;">[<a hx-get="/single_add" hx-target="#add-url-form" href="#">single add</a>]</h5>
</div> <form onsubmit="return false">
<p style="display:inline-block;">[<a hx-get="/single_add" hx-swap="outerHTML" hx-target="#add-url-form" href="#">single add</a>]</h5>
</div>
<form onsubmit="return false">
<div class="grid-x grid-padding-x">
<div class="large-12 cell">
<label>Paste URL's, one per line</label>
<textarea type="text" name="urls" rows="10"
></textarea>
<textarea type="text" name="urls" rows="10"></textarea>
</div>
</div>
<button

View File

@@ -1,15 +1,15 @@
<div id="label-widget" >
<div class="grid-x grid-padding-x">
<div class="small-9 medium-10 large-5 cell"
<div class="small-6 cell"
hx-post="/tags"
hx-target="#label-widget"
hx-trigger="change">
hx-trigger="change queue:first">
<label for="tag-entry"
class="">Tags</label>
<input id="tag-entry" type="text" name="tag" placeholder="enter tags" />
</div>
<div class="small-12 large-6 cell" id="tags-list">
<div class="small-6 cell" id="tags-list">
{{ range .tags }}
<a href="#"
class=""

View File

@@ -205,6 +205,13 @@ func Create(bmm *db.BookmarkManager, cmm *db.ConfigManager) *Server {
"bm": bm,
"error": err,
}
if err != nil {
data["url"] = url
data["tags"] = tags
data["tags_hidden"] = c.PostForm("tags_hidden")
}
c.HTML(http.StatusOK, "add_url_form.html", data)
})
r.POST("/add_bulk", func(c *gin.Context) {
@@ -402,7 +409,10 @@ func cleanupTags(tags []string) []string {
keys := make(map[string]struct{})
for _, k := range tags {
if k != "" && k != "|" {
keys[strings.ToLower(k)] = struct{}{}
for _, subKey := range strings.Split(k, ",") {
subKey := strings.Trim(subKey, " ")
keys[strings.ToLower(subKey)] = struct{}{}
}
}
}
out := []string{}