fix search modifying in server
parent
9fe6381245
commit
7ee04bbe8e
|
|
@ -281,10 +281,11 @@ func (server *Server) urlFileId(id []string) string {
|
||||||
if len(id) == 0 {
|
if len(id) == 0 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
result := id[0]
|
||||||
for i := 1; i < len(id); i++ {
|
for i := 1; i < len(id); i++ {
|
||||||
id[0] = strings.Join([]string{id[0], url.PathEscape(id[i])}, "/")
|
result = strings.Join([]string{result, url.PathEscape(id[i])}, "/")
|
||||||
}
|
}
|
||||||
return id[0]
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
func (server *Server) fileId(r *http.Request) []string {
|
func (server *Server) fileId(r *http.Request) []string {
|
||||||
|
|
@ -350,7 +351,7 @@ func (server *Server) apiV0SearchHandler(w http.ResponseWriter, r *http.Request)
|
||||||
result := []string{}
|
result := []string{}
|
||||||
if err := tree.ForEach(func(id []string, leaf Leaf) error {
|
if err := tree.ForEach(func(id []string, leaf Leaf) error {
|
||||||
for _, pattern := range patterns {
|
for _, pattern := range patterns {
|
||||||
if !pattern.MatchString(leaf.Content) && !pattern.MatchString(fmt.Sprint(id)) {
|
if !pattern.MatchString(leaf.Content) && !pattern.MatchString(leaf.Title) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
<script src="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js"></script>
|
||||||
<script src="https://cdn.jsdelivr.net/highlight.js/latest/highlight.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/highlight.js/latest/highlight.min.js"></script>
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/highlight.js/latest/styles/github.min.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/highlight.js/latest/styles/github.min.css">
|
||||||
<!-- TODO
|
<!-- todo css
|
||||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/light.css">
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/light.css">
|
||||||
-->
|
-->
|
||||||
<style>
|
<style>
|
||||||
|
|
@ -88,6 +88,7 @@
|
||||||
function searchFilesFor(q) {
|
function searchFilesFor(q) {
|
||||||
http("GET", "/api/v0/search?q=" + q, (body, status) => {
|
http("GET", "/api/v0/search?q=" + q, (body, status) => {
|
||||||
var results = JSON.parse(body)
|
var results = JSON.parse(body)
|
||||||
|
console.log(q, results)
|
||||||
results.sort()
|
results.sort()
|
||||||
var innerHTML = "<ul>"
|
var innerHTML = "<ul>"
|
||||||
for (var result in results)
|
for (var result in results)
|
||||||
|
|
@ -231,7 +232,7 @@
|
||||||
<body style="width: 90%; max-width: 1024px; margin: auto;" onload="init(); return false;">
|
<body style="width: 90%; max-width: 1024px; margin: auto;" onload="init(); return false;">
|
||||||
<div style="width: 100%; display: flex; flex-direction: column;">
|
<div style="width: 100%; display: flex; flex-direction: column;">
|
||||||
<form action="return false;" style="margin: 1em; display: flex; flex-direction: row;">
|
<form action="return false;" style="margin: 1em; display: flex; flex-direction: row;">
|
||||||
<input type="text" id="searchbox" style="flex-grow: 1;" placeholder="todo"/>
|
<input type="text" id="searchbox" style="flex-grow: 1;" placeholder="search regexp"/>
|
||||||
<input type="submit" value="search" onclick="searchFiles(); return false;"/>
|
<input type="submit" value="search" onclick="searchFiles(); return false;"/>
|
||||||
</form>
|
</form>
|
||||||
<div style="width: 100%; display: flex; flex-direction: row; flex-grow: 1;">
|
<div style="width: 100%; display: flex; flex-direction: row; flex-grow: 1;">
|
||||||
|
|
@ -251,6 +252,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div id="saveFeedback" style="min-height: 1.2em; text-align: right;">
|
<div id="saveFeedback" style="min-height: 1.2em; text-align: right;">
|
||||||
</div>
|
</div>
|
||||||
|
<!-- todo: each line no is an anchor -->
|
||||||
<textarea id="my-text-area"></textarea>
|
<textarea id="my-text-area"></textarea>
|
||||||
</article>
|
</article>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue