summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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...))