summaryrefslogtreecommitdiff
path: root/d1pkgweb-query.go
diff options
context:
space:
mode:
authorKatolaZ <katolaz@freaknet.org>2018-01-14 00:10:03 +0000
committerKatolaZ <katolaz@freaknet.org>2018-01-14 00:10:03 +0000
commit12e4b91241b095819e910cbf2bff07b14f7a83fc (patch)
tree466a452451708fe516288dfbf47baa1cbcfd2e8e /d1pkgweb-query.go
parent3d3245599e656f67b2cb1677507e3c26c73ef6c4 (diff)
added release selection
Diffstat (limited to 'd1pkgweb-query.go')
-rw-r--r--d1pkgweb-query.go19
1 files changed, 17 insertions, 2 deletions
diff --git a/d1pkgweb-query.go b/d1pkgweb-query.go
index fe2d099..bfb36fe 100644
--- a/d1pkgweb-query.go
+++ b/d1pkgweb-query.go
@@ -31,7 +31,14 @@ var resTempl = `
<body>
<form method="GET" action="/cgi-bin/d1pkgweb-query">
-Search Devuan Packages for: <input type="text" name="search"/>
+Search Devuan Packages for: <input type="text" name="search"/> in release
+<select name="release">
+<option value="jessie" selected>Jessie 1.0.0</option>
+<option value="ascii" >Ascii</option>
+<option value="ceres" >Ceres (unstable) 1.0.0</option>
+<option value="experimental" >Experimental 1.0.0</option>
+<option value="any" >Any</option>
+</select>
<input type="submit" value="Go!"/>
</form>
@@ -52,6 +59,13 @@ Search Devuan Packages for: <input type="text" name="search"/>
`
+var releaseMap = map[string]string{
+ "jessie": "index_jessie.txt",
+ "ascii": "index_ascii.txt",
+ "ceres": "index_ceres.txt",
+ "experimental": "index_experimental.txt",
+ "any": "index.txt"}
+
func printError(errCode int, errMsg string) {
fmt.Printf("Status:%d %s\r\n", errCode, errMsg)
@@ -101,6 +115,7 @@ func getResults(req http.Request) (ResultPage, error) {
req.ParseForm()
searchQuery := req.Form["search"]
+ release := req.Form["release"]
if len(searchQuery) < 1 {
printError(503, fmt.Sprintf("Something went wrong in parsing query...\r\n%s\r\n", req.Form))
os.Exit(0)
@@ -116,7 +131,7 @@ func getResults(req http.Request) (ResultPage, error) {
commands := make([]*exec.Cmd, 0)
cmd := "grep"
- args := []string{QueryTerms[0], "index.txt"}
+ args := []string{QueryTerms[0], releaseMap[release]}
commands = append(commands, exec.Command(cmd, args...))