Add bookmarklet support, show tags in manage list.
This commit is contained in:
parent
be10f5238e
commit
adbf2ef450
@ -25,6 +25,8 @@
|
|||||||
<li><a href="/export">Export all URLs</a></li>
|
<li><a href="/export">Export all URLs</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
<li><a href="javascript:void(window.open('http://localhost:8080/bookmarklet?url=' +encodeURIComponent(window.location), 'windowName', 'width=640,height=480'))">Bookmarklet</a></li>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="top-bar-right">
|
<div class="top-bar-right">
|
||||||
@ -39,6 +41,8 @@
|
|||||||
<div class="grid-container">
|
<div class="grid-container">
|
||||||
{{ if eq .page "root" }}
|
{{ if eq .page "root" }}
|
||||||
{{ template "search.html" . }}
|
{{ template "search.html" . }}
|
||||||
|
{{ else if eq .page "bookmarklet_click" }}
|
||||||
|
{{ template "bookmarklet.html" . }}
|
||||||
{{ else if eq .page "manage" }}
|
{{ else if eq .page "manage" }}
|
||||||
{{ template "manage.html" . }}
|
{{ template "manage.html" . }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@ -1,19 +1,27 @@
|
|||||||
<div class="large-8 medium-8 cell" id="add-url-form" >
|
<div class="large-8 medium-8 cell" id="add-url-form" >
|
||||||
<h5>Add a new URL</h5>
|
<div>
|
||||||
<span>[<a hx-get="/bulk_add" hx-target="#add-url-form" href="#">bulk</a>]</span>
|
<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>
|
||||||
|
|
||||||
<form onsubmit="return false">
|
<form onsubmit="return false">
|
||||||
<div class="grid-x grid-padding-x">
|
<div class="grid-x grid-padding-x">
|
||||||
<div class="large-6 cell">
|
<div class="large-6 cell">
|
||||||
<label>Paste a URL</label>
|
<label>Paste a URL</label>
|
||||||
<input type="text" name="url"
|
<input type="text" name="url" value="{{ .url }}"
|
||||||
hx-post="/add"
|
hx-trigger=""
|
||||||
hx-target="#add-url-form" hx-trigger=""
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="large-6 cell">
|
<div class="large-6 cell">
|
||||||
{{ template "tags_widget.html" . }}
|
{{ template "tags_widget.html" . }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="grid-x grid-padding-x">
|
||||||
|
<div class="medium-6 cell">
|
||||||
|
<a href="#" class="button" hx-post="/add"
|
||||||
|
hx-target="#add-url-form">add</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
{{ if .error }}
|
{{ if .error }}
|
||||||
<p class="error">{{ .error }}</p>
|
<p class="error">{{ .error }}</p>
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<div class="large-8 medium-8 cell" id="add-url-form" >
|
<div class="large-8 medium-8 cell" id="add-url-form" >
|
||||||
<h5>Add URLs in bulk</h5>
|
<div>
|
||||||
<span>[<a hx-get="/single_add" hx-target="#add-url-form" href="#">single</a>]</span>
|
<h5 style="display:inline-block;">Add bulk URLs</h5>
|
||||||
<form onsubmit="return false">
|
<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">
|
||||||
<div class="grid-x grid-padding-x">
|
<div class="grid-x grid-padding-x">
|
||||||
<div class="large-12 cell">
|
<div class="large-12 cell">
|
||||||
<label>Paste URL's, one per line</label>
|
<label>Paste URL's, one per line</label>
|
||||||
|
7
web/templates/bookmarklet.html
Normal file
7
web/templates/bookmarklet.html
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<div class="grid-x grid-padding-x">
|
||||||
|
<div class="large-12 cell">
|
||||||
|
|
||||||
|
{{ template "add_url_form.html" .}}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
@ -1,12 +1,16 @@
|
|||||||
<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>Manage:
|
<h5>Manage links</h5>
|
||||||
|
|
||||||
</h5>
|
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<tr><th>id</th><th>url</th><th>created</th><th>scraped</th></tr>
|
<tr>
|
||||||
|
<th>id</th>
|
||||||
|
<th>title/url</th>
|
||||||
|
<th>tags</th>
|
||||||
|
<th class="show-for-large">created</th>
|
||||||
|
<th class="show-for-large">scraped</th>
|
||||||
|
</tr>
|
||||||
{{ range .bookmarks }}
|
{{ range .bookmarks }}
|
||||||
<tr>
|
<tr>
|
||||||
<th>{{ .ID }}</th>
|
<th>{{ .ID }}</th>
|
||||||
@ -15,11 +19,14 @@
|
|||||||
<br>
|
<br>
|
||||||
<a href="{{ .URL }}">{{ niceURL .URL }}</a>
|
<a href="{{ .URL }}">{{ niceURL .URL }}</a>
|
||||||
</td>
|
</td>
|
||||||
<td>{{ (nicetime .TimestampCreated).HumanDuration }} ago</td>
|
<td>
|
||||||
<td>{{ (nicetime .TimestampLastScraped).HumanDuration }} ago</td>
|
{{ join .Tags ", " }}
|
||||||
|
</td>
|
||||||
|
<td class="show-for-large">{{ (nicetime .TimestampCreated).HumanDuration }} ago</td>
|
||||||
|
<td class="show-for-large">{{ (nicetime .TimestampLastScraped).HumanDuration }} ago</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<button class="button" hx-post="/scrape/{{ .ID }}">scrape</button>
|
<a class="button" hx-swap="outerHTML" hx-post="/scrape/{{ .ID }}">scrape</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<div class="grid-x grid-padding-x">
|
<div class="grid-x grid-padding-x">
|
||||||
<div class="large-8 medium-8 cell">
|
<div class="large-6 medium-12 cell">
|
||||||
|
|
||||||
<h5>Search:
|
<h5>Search
|
||||||
<span id="htmx-indicator-search" class="htmx-indicator">
|
<span id="htmx-indicator-search" class="htmx-indicator">
|
||||||
<img src="/assets/image/beating.gif" /> Searching...
|
<img style="height:1em;" src="/assets/image/beating.gif" /> Searching...
|
||||||
</span>
|
</span>
|
||||||
</h5>
|
</h5>
|
||||||
<form onsubmit="return false">
|
<form onsubmit="return false">
|
||||||
@ -19,9 +19,9 @@
|
|||||||
<div id="search-results">
|
<div id="search-results">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="large-6 medium-12 cell">
|
||||||
{{ template "add_url_form.html" . }}
|
{{ template "add_url_form.html" . }}
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- <div class="large-4 medium-4 cell">
|
<!-- <div class="large-4 medium-4 cell">
|
||||||
<h5>Try one of these buttons:</h5>
|
<h5>Try one of these buttons:</h5>
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
<div id="label-widget">
|
<div id="label-widget">
|
||||||
<div class="grid-x grid-padding-x">
|
<div class="grid-x grid-padding-x">
|
||||||
<div class="small-3 medium-2 large-1 cell">
|
|
||||||
</div>
|
|
||||||
<div class="small-9 medium-10 large-5 cell"
|
<div class="small-9 medium-10 large-5 cell"
|
||||||
hx-post="/tags"
|
hx-post="/tags"
|
||||||
hx-target="#label-widget"
|
hx-target="#label-widget"
|
||||||
@ -17,12 +15,11 @@
|
|||||||
title="remove {{ . }}"
|
title="remove {{ . }}"
|
||||||
hx-trigger="click"
|
hx-trigger="click"
|
||||||
hx-target="#label-widget"
|
hx-target="#label-widget"
|
||||||
hx-post="/tags?remove={{ . }}">
|
hx-post="/tags?remove={{ . }}">[-]</a>
|
||||||
{{ . }}
|
{{ . }}
|
||||||
</a>
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<input type="hidden" name="tags_hidden" value="{{ .tags_hidden }}">
|
<input type="hidden" name="tags_hidden" value="{{ .tags_hidden }}">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
13
web/web.go
13
web/web.go
@ -50,7 +50,7 @@ func Create(bmm *db.BookmarkManager) *Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// templ := template.Must(template.New("").Funcs(template.FuncMap{"dict": dictHelper}).ParseFS(templateFiles, "templates/*.html"))
|
// templ := template.Must(template.New("").Funcs(template.FuncMap{"dict": dictHelper}).ParseFS(templateFiles, "templates/*.html"))
|
||||||
templ := template.Must(template.New("").Funcs(template.FuncMap{"nicetime": niceTime, "niceURL": niceURL}).ParseFS(templateFiles, "templates/*.html"))
|
templ := template.Must(template.New("").Funcs(template.FuncMap{"nicetime": niceTime, "niceURL": niceURL, "join": strings.Join}).ParseFS(templateFiles, "templates/*.html"))
|
||||||
|
|
||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ func Create(bmm *db.BookmarkManager) *Server {
|
|||||||
idNum, _ := strconv.ParseInt(id, 10, 32)
|
idNum, _ := strconv.ParseInt(id, 10, 32)
|
||||||
bm := bmm.LoadBookmarkByID(uint64(idNum))
|
bm := bmm.LoadBookmarkByID(uint64(idNum))
|
||||||
bmm.QueueScrape(&bm)
|
bmm.QueueScrape(&bm)
|
||||||
c.String(http.StatusOK, "queued")
|
c.String(http.StatusOK, "<p>scrape queued</p>")
|
||||||
})
|
})
|
||||||
|
|
||||||
r.GET("/export", func(c *gin.Context) {
|
r.GET("/export", func(c *gin.Context) {
|
||||||
@ -199,6 +199,15 @@ func Create(bmm *db.BookmarkManager) *Server {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
r.GET("/bookmarklet", func(c *gin.Context) {
|
||||||
|
url := c.Query("url")
|
||||||
|
log.Printf(url)
|
||||||
|
meta := gin.H{"page": "bookmarklet_click", "url": url}
|
||||||
|
c.HTML(http.StatusOK,
|
||||||
|
"_layout.html", meta,
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
return server
|
return server
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user