Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
72894cd5cc | ||
|
|
f0a1c21678 | ||
|
|
807072a77f |
4
TODO
4
TODO
@@ -30,10 +30,10 @@ x main test -
|
||||
x TOC levels
|
||||
x delete pages
|
||||
x search
|
||||
FTS
|
||||
x FTS
|
||||
https://stackoverflow.com/questions/26709971/could-this-be-more-efficient-in-go
|
||||
x move auth as flag in router
|
||||
x . and ../** as roots cause bugs in listing and loading and linking
|
||||
x `create` at root is a 400, base= in URL (when `create` input is empty)
|
||||
x versioning
|
||||
delete top-level pages
|
||||
versioning
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (n *Notes) Search(phrase string) (string, error) {
|
||||
@@ -21,10 +20,13 @@ func (n *Notes) Search(phrase string) (string, error) {
|
||||
if info.IsDir() {
|
||||
return nil
|
||||
}
|
||||
if splits := strings.Split(info.Name(), "."); len(splits) > 1 && !(strings.HasSuffix(info.Name(), ".md") || strings.HasSuffix(info.Name(), ".txt")) {
|
||||
if size := info.Size(); size < 1 || size > (5*1024*1024) {
|
||||
return nil
|
||||
}
|
||||
ok, err := grepFile(walked, []byte(phrase))
|
||||
if err != nil && err.Error() == "bufio.Scanner: token too long" {
|
||||
err = nil
|
||||
}
|
||||
if err == nil && ok {
|
||||
p := filetree.NewPathFromLocal(path.Dir(walked))
|
||||
files.Push(p, info)
|
||||
|
||||
@@ -42,3 +42,13 @@ func TestSearch(t *testing.T) {
|
||||
t.Fatal(v, result)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSearchBigFiles(t *testing.T) {
|
||||
n := New()
|
||||
n.root = "/usr/local/bin"
|
||||
|
||||
_, err := n.Search("this file")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
asdf
|
||||
|
||||
this contains my search string
|
||||
@@ -1,5 +1,18 @@
|
||||
asdf
|
||||
searchString
|
||||
# h1
|
||||
|
||||
hi
|
||||
|
||||
here is my new line
|
||||
## h2
|
||||
|
||||
hi
|
||||
|
||||
### h3
|
||||
|
||||
hi
|
||||
|
||||
#### h4
|
||||
|
||||
hi
|
||||
|
||||
* bullet
|
||||
* 1
|
||||
@@ -22,8 +22,8 @@ func h1(content string) string {
|
||||
return h("1", content)
|
||||
}
|
||||
|
||||
func h2(content string) string {
|
||||
return h("2", content)
|
||||
func h2(content string, style ...string) string {
|
||||
return h("2", content, style...)
|
||||
}
|
||||
|
||||
func h3(content string) string {
|
||||
@@ -38,6 +38,10 @@ func h5(content string) string {
|
||||
return h("5", content)
|
||||
}
|
||||
|
||||
func h(level, content string) string {
|
||||
return fmt.Sprintf("\n<h%s>\n%s\n</h%s>\n", level, content, level)
|
||||
func h(level, content string, style ...string) string {
|
||||
s := ""
|
||||
if len(style) > 0 {
|
||||
s = fmt.Sprintf("style=%q", style[0])
|
||||
}
|
||||
return fmt.Sprintf("\n<h%s %s>\n%s\n</h%s>\n", level, s, content, level)
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func TestBlock(t *testing.T) {
|
||||
|
||||
func TestH(t *testing.T) {
|
||||
s := strings.ReplaceAll(strings.TrimSpace(h2("hi")), "\n", ".")
|
||||
if ok, err := regexp.MatchString("<h2>.*hi.*<.h2>", s); err != nil {
|
||||
if ok, err := regexp.MatchString("<h2[ ]*>.*hi.*<.h2>", s); err != nil {
|
||||
t.Fatal(err, s)
|
||||
} else if !ok {
|
||||
t.Fatal(ok, s)
|
||||
|
||||
@@ -22,9 +22,9 @@ func (s *Server) notes(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
func notesHead(w http.ResponseWriter, p filetree.Path) {
|
||||
fmt.Fprintln(w, h2(p.MultiLink()))
|
||||
fmt.Fprintln(w, h2(p.MultiLink(), "margin: 0; position: fixed; padding: .25em; background-color: #202b38; width: 100%; top: 0;"))
|
||||
fmt.Fprintf(w, `
|
||||
<form action=%q method="post">
|
||||
<form action=%q method="post" style="padding-top: 2.5em">
|
||||
<input type="text" name="keywords"></input>
|
||||
<button type="submit">Search</button>
|
||||
</form>
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
img {
|
||||
max-height: 400px;
|
||||
}
|
||||
body {
|
||||
font-size: 125%;
|
||||
}
|
||||
</style>
|
||||
</header>
|
||||
<body height="100%">
|
||||
|
||||
Reference in New Issue
Block a user