From 7842c480cf0f8566dd261601565d6e159bbd7457 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Mon, 18 Feb 2019 16:09:15 +0100 Subject: [PATCH 1/5] retain old search pattern in web ui Fixes: https://pagure.io/koji/issue/1130 --- www/kojiweb/includes/header.chtml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/www/kojiweb/includes/header.chtml b/www/kojiweb/includes/header.chtml index 0e086e65..adc519f7 100644 --- a/www/kojiweb/includes/header.chtml +++ b/www/kojiweb/includes/header.chtml @@ -1,4 +1,5 @@ #encoding UTF-8 +#import cgi #import koji #from kojiweb import util #from koji_cli.lib import greetings @@ -49,7 +50,12 @@ $localnav #end if - + #try + #set $old_terms = cgi.escape($terms) + #except + #set $old_terms = "" + #end try + From f9758e25727c4cd89253d5bdf2385ad3d00cd2b2 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Thu, 23 May 2019 11:21:15 +0200 Subject: [PATCH 2/5] retain search type --- www/kojiweb/includes/header.chtml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/www/kojiweb/includes/header.chtml b/www/kojiweb/includes/header.chtml index adc519f7..d008f4e3 100644 --- a/www/kojiweb/includes/header.chtml +++ b/www/kojiweb/includes/header.chtml @@ -36,18 +36,18 @@ $localnav
#try From 7a5c9130bc4308cb7d8299e7a9b12fd7d14857d0 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Thu, 23 May 2019 11:42:31 +0200 Subject: [PATCH 3/5] retain form values in search page --- www/kojiweb/search.chtml | 36 ++++++++++++++++++++++-------------- www/lib/kojiweb/util.py | 12 ++++++++---- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/www/kojiweb/search.chtml b/www/kojiweb/search.chtml index 8749dad1..0b9a67fc 100644 --- a/www/kojiweb/search.chtml +++ b/www/kojiweb/search.chtml @@ -1,9 +1,9 @@ +#import cgi #from kojiweb import util #include "includes/header.chtml"

Search

- @@ -11,21 +11,26 @@ #end if - + #try + #set $old_terms = cgi.escape($terms) + #except + #set $old_terms = "" + #end try + @@ -33,9 +38,12 @@ diff --git a/www/lib/kojiweb/util.py b/www/lib/kojiweb/util.py index abca32de..d5b5cbb0 100644 --- a/www/lib/kojiweb/util.py +++ b/www/lib/kojiweb/util.py @@ -189,14 +189,18 @@ def toggleOrder(template, sortKey, orderVar='order'): else: return sortKey -def toggleSelected(template, var, option): +def toggleSelected(template, var, option, checked=False): """ If the passed in variable var equals the literal value in option, - return 'selected="selected"', otherwise return ''. - Used for setting the selected option in select boxes. + return 'selected="selected"', otherwise return ''. If checked is True, + '"checked="checked"' string is returned + Used for setting the selected option in select and radio boxes. """ if var == option: - return 'selected="selected"' + if checked: + return 'checked="checked"' + else: + return 'selected="selected"' else: return '' From 08fd56a5aa04705475a950e45395ccdb11f0b6ee Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Wed, 12 Jun 2019 15:36:12 -0400 Subject: [PATCH 4/5] combine search and searchresults templates --- www/kojiweb/index.py | 2 +- www/kojiweb/search.chtml | 71 ++++++++++++++++++++++++++++++++ www/kojiweb/searchresults.chtml | 73 --------------------------------- 3 files changed, 72 insertions(+), 74 deletions(-) delete mode 100644 www/kojiweb/searchresults.chtml diff --git a/www/kojiweb/index.py b/www/kojiweb/index.py index 8e9d9eb2..7cf6658e 100644 --- a/www/kojiweb/index.py +++ b/www/kojiweb/index.py @@ -2273,7 +2273,7 @@ def search(environ, start=None, order=None): else: typeLabel = '%ss' % type values['typeLabel'] = typeLabel - return _genHTML(environ, 'searchresults.chtml') + return _genHTML(environ, 'search.chtml') else: return _genHTML(environ, 'search.chtml') diff --git a/www/kojiweb/search.chtml b/www/kojiweb/search.chtml index 0b9a67fc..9207c01b 100644 --- a/www/kojiweb/search.chtml +++ b/www/kojiweb/search.chtml @@ -1,8 +1,10 @@ #import cgi #from kojiweb import util +#from six.moves.urllib.parse import quote #include "includes/header.chtml" +

Search

$error
Search
  - glob - regexp - exact + #if not $varExists('match') + #set $match='glob' + #end if + glob + regexp + exact
@@ -53,4 +55,73 @@
+ +#if $varExists('results') + + + + + + + + + + #if $len($results) > 0 + #for $result in $results + + + + + #end for + #else + + + + #end if + + + +
+ #if $len($resultPages) > 1 +
+ Page: + +
+ #end if + #if $resultStart > 0 + <<< + #end if + #if $totalResults != 0 + Results #echo $resultStart + 1 # through #echo $resultStart + $resultCount # of $totalResults + #end if + #if $resultStart + $resultCount < $totalResults + >>> + #end if +
ID $util.sortImage($self, 'id')Name $util.sortImage($self, 'name')
$result.id$result.name
No search results
+ #if $len($resultPages) > 1 +
+ Page: + +
+ #end if + #if $resultStart > 0 + <<< + #end if + #if $totalResults != 0 + Results #echo $resultStart + 1 # through #echo $resultStart + $resultCount # of $totalResults + #end if + #if $resultStart + $resultCount < $totalResults + >>> + #end if +
+#end if + #include "includes/footer.chtml" diff --git a/www/kojiweb/searchresults.chtml b/www/kojiweb/searchresults.chtml deleted file mode 100644 index 509b2025..00000000 --- a/www/kojiweb/searchresults.chtml +++ /dev/null @@ -1,73 +0,0 @@ -#from kojiweb import util -#from six.moves.urllib.parse import quote - -#include "includes/header.chtml" - -

Search Results for $typeLabel matching "$terms"

- - - - - - - - - - #if $len($results) > 0 - #for $result in $results - - - - - #end for - #else - - - - #end if - - - -
- #if $len($resultPages) > 1 -
- Page: - -
- #end if - #if $resultStart > 0 - <<< - #end if - #if $totalResults != 0 - Results #echo $resultStart + 1 # through #echo $resultStart + $resultCount # of $totalResults - #end if - #if $resultStart + $resultCount < $totalResults - >>> - #end if -
ID $util.sortImage($self, 'id')Name $util.sortImage($self, 'name')
$result.id$result.name
No search results
- #if $len($resultPages) > 1 -
- Page: - -
- #end if - #if $resultStart > 0 - <<< - #end if - #if $totalResults != 0 - Results #echo $resultStart + 1 # through #echo $resultStart + $resultCount # of $totalResults - #end if - #if $resultStart + $resultCount < $totalResults - >>> - #end if -
- -#include "includes/footer.chtml" From fdc2bdaef903de5df7bc93618ad3fd2021717e34 Mon Sep 17 00:00:00 2001 From: Mike McLean Date: Thu, 13 Jun 2019 15:59:45 -0400 Subject: [PATCH 5/5] search form on one line --- www/kojiweb/search.chtml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/www/kojiweb/search.chtml b/www/kojiweb/search.chtml index 9207c01b..9d838533 100644 --- a/www/kojiweb/search.chtml +++ b/www/kojiweb/search.chtml @@ -10,7 +10,7 @@ #if $error - + #end if #try @@ -36,10 +36,7 @@ #end if - - - - + - - +
$error
$error
Search
  + #if not $varExists('match') #set $match='glob' #end if @@ -47,10 +44,10 @@ regexp exact