summaryrefslogtreecommitdiff
path: root/d1pkgweb.go
diff options
context:
space:
mode:
Diffstat (limited to 'd1pkgweb.go')
-rw-r--r--d1pkgweb.go108
1 files changed, 108 insertions, 0 deletions
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 = `<html>
+<body>
+<title>{{.Name}}-{{.Version}}</title>
+<style type="text/css">
+body {
+ margin-top: 10px;
+ line-height:1.6;
+ font-size:20px;
+}
+
+div.pkgname{
+ font-size: 150%;
+ margin-top: 40px;
+ margin-left: 40px;
+ border-bottom: 2px solid #444444;
+}
+
+div.description{
+ font-size: 100%;
+ margin-left: 20px;
+ margin-top: 20px;
+ margin-bottom: 20px;
+ border-bottom: 2px solid #aaaaaa;
+}
+
+div.long_description{
+ font-size: 100%;
+ width: 600px;
+ margin-left: 40px;
+}
+
+div.dep_list{
+ margin-top:20px;
+ margin-left: 20px;
+
+}
+
+li.dep_item{
+ margin-left: 35px;
+}
+
+</style>
+<div class="pkgname">{{.Name}} {{.Version}}</div>
+<div class="description">
+{{.Description}}
+</div>
+<div class="long_description">
+{{.LongDescription}}
+</div>
+
+<hr>
+<div class="dep_list">
+Depends:
+<ul>
+{{range .Depends}}<li class="dep_item">{{ . }}</li>
+{{else}}<div>No depends</div>{{end}}
+</ul>
+</div>
+<div class="maintainer">
+Maintainer: {{.Maintainer}}
+</div>
+</body>
+</html>
+`
+
+func main() {
+
+ args := os.Args
+
+ if len(args) < 2 {
+ fmt.Printf("Usage: %s <filein>\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/")
+ }
+ }
+ }
+ }
+}