diff --git a/main.go b/main.go
index 4195831..8970912 100644
--- a/main.go
+++ b/main.go
@@ -1,8 +1,10 @@
package main
import (
+ "bytes"
"encoding/json"
"fmt"
+ "html/template"
"io/ioutil"
"net/http"
)
@@ -12,6 +14,7 @@ type Package struct {
Repo string
Path string
Packages []string
+ Url string
}
func (p Package) GetRoutes() (ret []string) {
@@ -38,10 +41,17 @@ func writePageError(w http.ResponseWriter, message string, code int) error {
}
func writePageGo(w http.ResponseWriter, path string, pkg Package, code int) error {
- return writePage(w, fmt.Sprintf(`
-
%s
- %s
-`, "Package!", path, "git", pkg.Repo, "Package!"), code)
+ t, err := template.ParseFiles("template.html")
+ if err != nil {
+ return err
+ }
+ pkg.Path = path
+ var page bytes.Buffer
+ err = t.Execute(&page, pkg)
+ if err != nil {
+ return err
+ }
+ return writePage(w, page.String(), code)
}
// }}}
@@ -81,10 +91,14 @@ func main() {
mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
route := req.URL.Path
+ var err error
if val, ok := routes[route]; ok {
- writePageGo(w, "pault.ag"+val.Path, val, 200)
+ err = writePageGo(w, "pault.ag"+val.Path, val, 200)
} else {
- writePageError(w, ":(", 404)
+ err = writePageError(w, ":(", 404)
+ }
+ if err != nil {
+ writePageError(w, fmt.Sprintf("error: %v", err), 400)
}
})
http.ListenAndServe(":8000", mux)
diff --git a/packages.json b/packages.json
index 6114c80..a37e798 100644
--- a/packages.json
+++ b/packages.json
@@ -1,9 +1,11 @@
[
- {"Repo": "git://github.com/paultag/go-debian",
+ {"Repo": "https://github.com/paultag/go-debian.git",
"Path": "/go/debian",
- "Packages": ["control", "dependency", "version"]},
+ "Packages": ["control", "dependency", "version"],
+ "Url": "https://github.com/paultag/go-debian"},
- {"Repo": "git://github.com/paultag/go-topsort",
+ {"Repo": "https://github.com/paultag/go-topsort.git",
"Path": "/go/topsort",
- "Packages": []}
+ "Packages": [],
+ "Url": "https://github.com/paultag/go-topsort"}
]
diff --git a/template.html b/template.html
new file mode 100644
index 0000000..2f7de81
--- /dev/null
+++ b/template.html
@@ -0,0 +1,15 @@
+
+
+
+ {{ .Path }}
+
+
+
+ package: {{ .Path }}
+
+
+
+