diff --git a/bookmark.go b/bookmark.go
index dd8aa35..b47abe0 100644
--- a/bookmark.go
+++ b/bookmark.go
@@ -88,6 +88,7 @@ type Bookmark struct {
Link string `json:"link"`
HideBorder bool `json:"hide_border"`
Order int `json:"order"`
+ Hide bool `json:"hide"`
}
func (b *Bookmark) GetColor() string {
diff --git a/db.go b/db.go
index 3e178ef..035c762 100644
--- a/db.go
+++ b/db.go
@@ -14,11 +14,12 @@ var (
GetSessionByID = advsql.QueryOne(Database, "SELECT * FROM sessions WHERE id = ?", ScanSessionPkFirst)
DeleteSessionsByExpirationDateBefore = advsql.Delete(Database, "DELETE FROM sessions WHERE expiration_date <= ?")
- InsertBookmark = advsql.Insert(Database, "INSERT INTO bookmarks VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", ScanBookmarkPkFirst)
- UpdateBookmark = advsql.Update(Database, "UPDATE bookmarks SET link = ?, image = ?, color = ?, image_size = ?, icon_padding = ?, hide_border = ?, order_priority = ? WHERE session_id = ? AND title = ?", ScanBookmarkPkLast)
- GetBookmarkBySessionIDAndTitle = advsql.QueryOne(Database, "SELECT * FROM bookmarks WHERE session_id = ? AND title = ?", ScanBookmarkPkFirst)
- GetBookmarksBySessionIdOrdered = advsql.QueryMany(Database, "SELECT * FROM bookmarks WHERE session_id = ? ORDER BY order_priority", ScanBookmarkPkFirst)
- DeleteBookmarksBySessionID = advsql.Delete(Database, "DELETE FROM bookmarks WHERE session_id = ?")
+ InsertBookmark = advsql.Insert(Database, "INSERT INTO bookmarks VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", ScanBookmarkPkFirst)
+ UpdateBookmark = advsql.Update(Database, "UPDATE bookmarks SET link = ?, image = ?, color = ?, image_size = ?, icon_padding = ?, hide_border = ?, order_priority = ? WHERE session_id = ? AND title = ?", ScanBookmarkPkLast)
+ GetBookmarkBySessionIDAndTitle = advsql.QueryOne(Database, "SELECT * FROM bookmarks WHERE session_id = ? AND title = ?", ScanBookmarkPkFirst)
+ GetBookmarksBySessionIdOrdered = advsql.QueryMany(Database, "SELECT * FROM bookmarks WHERE session_id = ? ORDER BY order_priority", ScanBookmarkPkFirst)
+ GetVisibleBookmarksBySessionIdOrdered = advsql.QueryMany(Database, "SELECT * FROM bookmarks WHERE session_id = ? AND hide = 0 ORDER BY order_priority", ScanBookmarkPkFirst)
+ DeleteBookmarksBySessionID = advsql.Delete(Database, "DELETE FROM bookmarks WHERE session_id = ?")
InsertSettings = advsql.Insert(Database, "INSERT INTO settings VALUES (?, ?, ?, ?, ?, ?)", ScanSettingsPkFirst)
UpdateSettings = advsql.Update(Database, "UPDATE settings SET background_color = ?, foreground_color = ?, search_query = ?, border_radius = ?, bookmark_size = ? WHERE session_id = ?", ScanSettingsPkLast)
@@ -65,6 +66,7 @@ func ScanBookmarkPkFirst(u *Bookmark, encode advsql.ScanFunc) error {
&u.IconPadding,
&u.HideBorder,
&u.Order,
+ &u.Hide,
)
}
@@ -77,6 +79,7 @@ func ScanBookmarkPkLast(u *Bookmark, encode advsql.ScanFunc) error {
&u.IconPadding,
&u.HideBorder,
&u.Order,
+ &u.Hide,
&u.SessionID,
&u.Title,
)
diff --git a/main.go b/main.go
index b679591..8872ae1 100644
--- a/main.go
+++ b/main.go
@@ -74,7 +74,7 @@ func handler(w http.ResponseWriter, r *http.Request) {
data := &TmplData{
text: GetText(r),
- Bookmarks: channel.ToSliceDeref(GetBookmarksBySessionIdOrdered(session.ID)),
+ Bookmarks: channel.ToSliceDeref(GetVisibleBookmarksBySessionIdOrdered(session.ID)),
Settings: GetSettingsBySessionID(session.ID),
}
@@ -178,6 +178,7 @@ func saveChanges(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusInternalServerError)
return
}
+
for _, bookmark := range sessionData.Bookmarks {
bookmark.SessionID = session.ID
if err := InsertBookmark(&bookmark); err != nil {
diff --git a/static/customize.js b/static/customize.js
index 9b57224..e164c00 100644
--- a/static/customize.js
+++ b/static/customize.js
@@ -37,7 +37,7 @@ function main() {
function saveChanges() {
const bookmarks = [];
document.querySelectorAll(".customizer").forEach(element => bookmarks.push(buildDataForBoomark(element)));
-
+
const settings = {
background_color: document.querySelector("#bg-color").value,
foreground_color: document.querySelector("#fg-color").value,
@@ -68,6 +68,7 @@ function buildDataForBoomark(element) {
const color = form.querySelector("#bookmark-color");
const hideBorder = form.querySelector("#bookmark-border");
const order = form.querySelector("#bookmark-order");
+ const hide = form.querySelector("#bookmark-hide");
return {
title: title.value,
@@ -77,7 +78,8 @@ function buildDataForBoomark(element) {
color: color.value,
link: link.value,
hide_border: hideBorder.checked,
- order: parseInt(order.value)
+ order: parseInt(order.value),
+ hide: hide.checked
};
}
diff --git a/templates/customize-bookmark.html b/templates/customize-bookmark.html
index 32960e5..6db4ed4 100644
--- a/templates/customize-bookmark.html
+++ b/templates/customize-bookmark.html
@@ -27,6 +27,9 @@
+
+
+
diff --git a/text.go b/text.go
index 6a53f5d..e342394 100644
--- a/text.go
+++ b/text.go
@@ -30,6 +30,7 @@ var (
"Foreground color": "Foreground color",
"Border radius": "Border radius",
"Bookmark size": "Size",
+ "Hide bookmark": "Hide bookmark",
},
},
@@ -43,6 +44,7 @@ var (
"Foreground color": "Textfarbe",
"Border radius": "Randradius",
"Bookmark size": "Größe",
+ "Hide bookmark": "Verstecken",
},
},
@@ -56,6 +58,7 @@ var (
"Foreground color": "描画色",
"Border radius": "境界半径",
"Bookmark size": "大小",
+ "Hide bookmark": "非表示",
},
},
}