parent
e4632d36ba
commit
4e2b7b3c85
|
|
@ -1,11 +1,8 @@
|
|||
FROM frolvlad/alpine-glibc:alpine-3.9_glibc-2.29
|
||||
RUN apk update && apk add --no-cache ca-certificates git
|
||||
|
||||
FROM golang:1.13-alpine as certs
|
||||
RUN apk update && apk add --no-cache ca-certificates
|
||||
|
||||
FROM busybox:glibc
|
||||
RUN mkdir -p /var/log
|
||||
WORKDIR /main
|
||||
COPY --from=certs /etc/ssl/certs /etc/ssl/certs
|
||||
|
||||
COPY . .
|
||||
|
||||
|
|
@ -13,4 +10,3 @@ ENV GOPATH=""
|
|||
ENV MNT="/mnt/"
|
||||
ENTRYPOINT ["/main/exec-notes-server"]
|
||||
CMD []
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,9 @@ type Paths []Path
|
|||
func (p Paths) List(full ...bool) string {
|
||||
content := "<ul>\n"
|
||||
for _, path := range p {
|
||||
if len(path.Base) > 0 && path.Base[0] == '.' {
|
||||
continue
|
||||
}
|
||||
if len(full) > 0 && full[0] {
|
||||
content += path.FullLI() + "\n"
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -4,9 +4,11 @@ import (
|
|||
"bufio"
|
||||
"bytes"
|
||||
"local/notes-server/filetree"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (n *Notes) Search(phrase string) (string, error) {
|
||||
|
|
@ -19,11 +21,17 @@ 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")) {
|
||||
return nil
|
||||
}
|
||||
ok, err := grepFile(walked, []byte(phrase))
|
||||
if err == nil && ok {
|
||||
p := filetree.NewPathFromLocal(path.Dir(walked))
|
||||
files.Push(p, info)
|
||||
}
|
||||
if err != nil {
|
||||
log.Printf("failed to scan %v: %v", walked, err)
|
||||
}
|
||||
return err
|
||||
},
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in New Issue