From b3ca06d08f4bba7af522a085e942d523c697a684 Mon Sep 17 00:00:00 2001 From: KatolaZ Date: Wed, 10 Jan 2018 02:49:20 +0000 Subject: first commit --- d1pkgweb.go | 108 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 d1pkgweb.go (limited to 'd1pkgweb.go') diff --git a/d1pkgweb.go b/d1pkgweb.go new file mode 100644 index 0000000..d416e27 --- /dev/null +++ b/d1pkgweb.go @@ -0,0 +1,108 @@ +package main + +import ( + "bufio" + "d1pkgweb/deb822" + "fmt" + "os" +) + +var templ = ` + +{{.Name}}-{{.Version}} + +
{{.Name}} {{.Version}}
+
+{{.Description}} +
+
+{{.LongDescription}} +
+ +
+
+Depends: + +
+
+Maintainer: {{.Maintainer}} +
+ + +` + +func main() { + + args := os.Args + + if len(args) < 2 { + fmt.Printf("Usage: %s \n", args[0]) + return + } + + fnames := args[1:] + for _, fname := range fnames { + f, err := os.Open(fname) + if err != nil { + defer f.Close() + } + if err != nil { + fmt.Printf("Error opening file %s\n", fname) + + } else { + r := bufio.NewScanner(f) + + if r != nil { + for s, err := deb822.ScanStanza(r); s["Package"] != ""; s, err = deb822.ScanStanza(r) { + if err == nil { + deb822.Stanza2HtmlPage(s, templ, ".") + } else { + fmt.Printf("error: %s\n", err) + } + //WriteFiles(s, num, "./files/") + } + } + } + } +} -- cgit v1.2.3