summaryrefslogtreecommitdiff
path: root/d1pkgweb.go
blob: 60c761f50188ff274f80ea6814b336846ef4fad3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
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;
}

div.rec_list {
     margin-top:20px;
     margin-left: 20px;
}

li.rec_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>{{end}}
</ul>
</div>

<div class="rec_list">
Recommends:
<ul>
{{range .Recommends}}<li class="rec_item">{{ . }}</li>{{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/")
				}
			}
		}
	}
}