3 Commits
v1.1 ... v1.4

Author SHA1 Message Date
bel
f0a1c21678 Update wrapper for bigger font 2019-12-07 11:03:30 -07:00
bel
807072a77f Unittest and exec file proof on search 2019-12-01 14:16:45 -07:00
bel
081d50328f Fix no configured user 2019-12-01 13:25:49 -07:00
7 changed files with 37 additions and 10 deletions

4
TODO
View File

@@ -30,10 +30,10 @@ x main test -
x TOC levels x TOC levels
x delete pages x delete pages
x search x search
FTS x FTS
https://stackoverflow.com/questions/26709971/could-this-be-more-efficient-in-go https://stackoverflow.com/questions/26709971/could-this-be-more-efficient-in-go
x move auth as flag in router x move auth as flag in router
x . and ../** as roots cause bugs in listing and loading and linking 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 `create` at root is a 400, base= in URL (when `create` input is empty)
x versioning
delete top-level pages delete top-level pages
versioning

View File

@@ -8,7 +8,6 @@ import (
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
"strings"
) )
func (n *Notes) Search(phrase string) (string, error) { func (n *Notes) Search(phrase string) (string, error) {
@@ -21,10 +20,13 @@ func (n *Notes) Search(phrase string) (string, error) {
if info.IsDir() { if info.IsDir() {
return nil 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 return nil
} }
ok, err := grepFile(walked, []byte(phrase)) ok, err := grepFile(walked, []byte(phrase))
if err != nil && err.Error() == "bufio.Scanner: token too long" {
err = nil
}
if err == nil && ok { if err == nil && ok {
p := filetree.NewPathFromLocal(path.Dir(walked)) p := filetree.NewPathFromLocal(path.Dir(walked))
files.Push(p, info) files.Push(p, info)

View File

@@ -42,3 +42,13 @@ func TestSearch(t *testing.T) {
t.Fatal(v, result) 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)
}
}

View File

@@ -1,3 +0,0 @@
asdf
this contains my search string

View File

@@ -1,5 +1,18 @@
asdf # h1
searchString
hi
here is my new line ## h2
hi
### h3
hi
#### h4
hi
* bullet
* 1

View File

@@ -13,6 +13,8 @@ type Versions struct {
func New() (*Versions, error) { func New() (*Versions, error) {
v := &Versions{} v := &Versions{}
v.cmd("git", "init") v.cmd("git", "init")
v.cmd("git", "config", "user.email", "user@user.user")
v.cmd("git", "config", "user.name", "user")
return v, nil return v, nil
} }

View File

@@ -18,6 +18,9 @@
img { img {
max-height: 400px; max-height: 400px;
} }
body {
font-size: 125%;
}
</style> </style>
</header> </header>
<body height="100%"> <body height="100%">