Add quick bookmarklet

This commit is contained in:
James Mills
2021-02-02 17:25:01 +10:00
parent e34e331101
commit 867b7b141d
4 changed files with 421 additions and 39 deletions

View File

@@ -110,12 +110,13 @@ func (s *Server) AddHandler() httprouter.Handle {
return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) {
ctx := NewContext(s.config, s.db, r)
if r.Method == http.MethodGet {
url := NormalizeURL(strings.TrimSpace(r.FormValue("url")))
if url == "" && r.Method == http.MethodGet {
s.render("add", w, ctx)
return
}
url := NormalizeURL(strings.TrimSpace(r.FormValue("url")))
if url == "" {
ctx.Error = true
ctx.Message = "Invalid URL"

380
internal/rice-box.go Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,38 +1,39 @@
{{define "content"}}
<article class="grid">
<div>
<hgroup>
<h2>Add site</h2>
<h3>Add a new site to be indexed</h3>
</hgroup>
<form action="/add" method="POST">
<input type="hidden" name="csrf_token" value="{{ $.CSRFToken }}">
<input type="url" name="url" placeholder="Website's URL" aria-label="URL" autocomplete="url" autofocus required>
<button type="submit" class="primary">
<i class="icss-plus"></i>
Add
</button>
</form>
</div>
<div>
<hgroup>
<h2>How to add new sites</h2>
</hgroup>
<p>
Spyda relies on users to contribute and add websites or URLs to be
considered for crawling and indexing. Without this there is no way
to increase the number of website indexed and crawled by Spyda.
</p>
<p>
To add a website to Spyda's crawler for consideration, just enter the
website's address or URl in the box and click "Add". Spyda will then
start to crawl the website, index it and it will become available for
future search queries.
</p>
<p>
If you are the author or maintainer of a website that you wish <b>NOT</b>
to be indexed by Spyda, please contact <a href="/support">support</a>.
</p>
</div>
</article>
<article class="grid">
<div>
<hgroup>
<h2>Add site</h2>
<h3>Add a new site to be indexed</h3>
</hgroup>
<form action="/add" method="POST">
<input type="hidden" name="csrf_token" value="{{ $.CSRFToken }}">
<input type="url" name="url" placeholder="Website's URL" aria-label="URL" autocomplete="url" autofocus required>
<button type="submit" class="primary">
<i class="icss-plus"></i>
Add
</button>
</form>
<small>Want a faster way to add urls? Add the <a href="javascript:(function()%7Bvar%20url%20%3D%20document.URL%20%3B%0A%0Awindow.location.href%20%3D%20%22https%3A%2F%2Fspyda.dev%2Fadd%3Furl%3D%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2B%20url%20%3B%7D)()%3B">Add to Spyda</a> bookmarklet to your bookmarks bar (<i>by dragging it to your bookmarks bar</i>)</small>
</div>
<div>
<hgroup>
<h2>How to add new sites</h2>
</hgroup>
<p>
Spyda relies on users to contribute and add websites or URLs to be
considered for crawling and indexing. Without this there is no way
to increase the number of website indexed and crawled by Spyda.
</p>
<p>
To add a website to Spyda's crawler for consideration, just enter the
website's address or URl in the box and click "Add". Spyda will then
start to crawl the website, index it and it will become available for
future search queries.
</p>
<p>
If you are the author or maintainer of a website that you wish <b>NOT</b>
to be indexed by Spyda, please contact <a href="/support">support</a>.
</p>
</div>
</article>
{{end}}