Formatting

This commit is contained in:
Sarah Jamie Lewis 2019-11-11 19:07:25 -08:00
parent 37bebe271e
commit 6543f89843
4 changed files with 51 additions and 53 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
tmp.dot
tmp.png
tmp.svg
.idea/

View File

@ -8,6 +8,7 @@ import (
"os" "os"
"path" "path"
) )
func makeTorifiedClient() *http.Client { func makeTorifiedClient() *http.Client {
torDialer, err := proxy.SOCKS5("tcp", "127.0.0.1:9050", nil, proxy.Direct) torDialer, err := proxy.SOCKS5("tcp", "127.0.0.1:9050", nil, proxy.Direct)
if err != nil { if err != nil {
@ -45,5 +46,3 @@ func Fetch(url string, cacheid string) []byte {
log.Errorf("Error fetching: %v", err) log.Errorf("Error fetching: %v", err)
return []byte{} return []byte{}
} }

7
kdb.go
View File

@ -1,14 +1,13 @@
package main package main
import ( import (
"errors" "errors"
"fmt" "fmt"
"git.openprivacy.ca/openprivacy/libricochet-go/log"
"git.openprivacy.ca/sarah/kdb/citing" "git.openprivacy.ca/sarah/kdb/citing"
"github.com/nickng/bibtex" "github.com/nickng/bibtex"
"html/template" "html/template"
"io/ioutil" "io/ioutil"
"git.openprivacy.ca/openprivacy/libricochet-go/log"
"net/http" "net/http"
"os" "os"
"os/exec" "os/exec"
@ -124,7 +123,6 @@ func viewHandler(w http.ResponseWriter, r *http.Request) {
renderTemplate(w, "view", p) renderTemplate(w, "view", p)
} }
func saveHandler(w http.ResponseWriter, r *http.Request) { func saveHandler(w http.ResponseWriter, r *http.Request) {
title, err := getTitle(w, r) title, err := getTitle(w, r)
if err != nil { if err != nil {
@ -197,7 +195,6 @@ func construct_graph_sub(graph string, word string, seen map[string]bool, depth
graph += fmt.Sprintf("\"%v\" [href=\"/view/%v\"];\n", normalize(link), normalize(link)) graph += fmt.Sprintf("\"%v\" [href=\"/view/%v\"];\n", normalize(link), normalize(link))
} }
if normalize(word) != normalize(link) && (!seen[normalize(word)+"++"+normalize(link)] || !seen[normalize(link)+"++"+normalize(word)]) { if normalize(word) != normalize(link) && (!seen[normalize(word)+"++"+normalize(link)] || !seen[normalize(link)+"++"+normalize(word)]) {
if strings.HasPrefix(link, "typeof:") { if strings.HasPrefix(link, "typeof:") {
graph += fmt.Sprintf("\"%v\" -> \"%v\" [style=dotted]\n", link[7:], word) graph += fmt.Sprintf("\"%v\" -> \"%v\" [style=dotted]\n", link[7:], word)
@ -220,12 +217,10 @@ func construct_graph_sub(graph string, word string, seen map[string]bool, depth
} }
//} //}
if !seen[link] { if !seen[link] {
graph = construct_graph_sub(graph, link, seen, depth-1) graph = construct_graph_sub(graph, link, seen, depth-1)
} }
} }
return graph return graph