3 Commits

Author SHA1 Message Date
6175c77478 Bump version 2022-06-10 11:24:29 +09:30
742f42115f Add error checking for URL validity 2022-06-10 11:23:55 +09:30
9e7914c9a1 Space cells so that tags do not go on a new row. 2022-06-10 11:14:21 +09:30
5 changed files with 21 additions and 6 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.26"
const Tag = "v0.0.27"
var versionInfo struct {
Local struct {

View File

@@ -6,19 +6,19 @@
<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>
<div class="grid-x grid-padding-x">
<div class="medium-6 cell">
<a href="#" class="button" hx-post="/add"
<a href="#" class="button" hx-post="/add"
hx-target="#add-url-form">add</a>
</div>
</div>

View File

@@ -1,6 +1,6 @@
<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 queue:first">
@@ -9,7 +9,7 @@
<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) {