diff options
author | KatolaZ <katolaz@freaknet.org> | 2018-06-03 23:43:27 +0100 |
---|---|---|
committer | KatolaZ <katolaz@freaknet.org> | 2018-06-03 23:43:27 +0100 |
commit | 41a5e148421ec6de2983af17a262ac3fb3afe32a (patch) | |
tree | a9fb76a86d052be9571e11abff6cb535d6f52401 /d1pkgweb-query.go | |
parent | 12e4b91241b095819e910cbf2bff07b14f7a83fc (diff) |
added Suite to the result set
Diffstat (limited to 'd1pkgweb-query.go')
-rw-r--r-- | d1pkgweb-query.go | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/d1pkgweb-query.go b/d1pkgweb-query.go index bfb36fe..8e04a08 100644 --- a/d1pkgweb-query.go +++ b/d1pkgweb-query.go @@ -16,10 +16,12 @@ type Result struct { Name string Version string URL string + Suite string } type ResultPage struct { Query string + Release string NumResults int Time string Results []Result @@ -34,21 +36,21 @@ var resTempl = ` 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="ascii" >Ascii 2.0.0</option> +<option value="ceres" >Ceres (unstable)</option> +<option value="experimental" >Experimental</option> <option value="any" >Any</option> </select> <input type="submit" value="Go!"/> </form> -<div class="title">{{.NumResults}} results for <b>"{{.Query}}"</b> (in {{.Time}}) </div> +<div class="title">{{.NumResults}} results for <b>"{{.Query}}"</b> in {{.Release}} (in {{.Time}}) </div> <ul class="res_list"> {{range .Results}} <li class="res_item"> - <a href="{{.URL}}">{{.Name}}-{{.Version}}</a> + <a href="{{.URL}}">[{{.Suite}}] {{.Name}}-{{.Version}}</a> </li> {{end}} </div> @@ -84,7 +86,8 @@ func parseLines(s string) []Result { pkgNameVer := strings.Split(URLParts[len(URLParts)-1], ".html")[0] Name := strings.Split(pkgNameVer, "_")[0] Version := strings.Split(pkgNameVer, "_")[1] - results = append(results, Result{URL: URL, Name: Name, Version: Version}) + Suite := URLParts[2] + results = append(results, Result{URL: URL, Name: Name, Version: Version, Suite: Suite}) } //fmt.Printf("len(results): %d\n", resSize) return results @@ -111,19 +114,26 @@ func pipeComands(commands []*exec.Cmd) ([]byte, error) { func getResults(req http.Request) (ResultPage, error) { var res ResultPage + var release string 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) } - res.Query = searchQuery[0] QueryTerms := strings.Split(res.Query, " ") + selectedRelease := req.Form["release"] + if len(selectedRelease) < 1 { + release = "any" + } else { + release = selectedRelease[0] + } + + res.Release = release fmt.Printf("QueryTerms: %s\n", QueryTerms) startTime := time.Now() |