forked from HPR/hpr_generator
		
	Update search page to include tag index
This commit is contained in:
		| @@ -436,7 +436,7 @@ fieldset > table { | |||||||
| 	width: calc(100vw + -16vw + -1rem); | 	width: calc(100vw + -16vw + -1rem); | ||||||
| 	max-width: 100%; | 	max-width: 100%; | ||||||
| } | } | ||||||
|  | fieldset > input, | ||||||
| fieldset > table td input, | fieldset > table td input, | ||||||
| fieldset > table td textarea { | fieldset > table td textarea { | ||||||
| 	width: calc(100vw + -16vw + -1.5rem); | 	width: calc(100vw + -16vw + -1.5rem); | ||||||
| @@ -471,18 +471,37 @@ fieldset > table td input[type="radio"] { | |||||||
| 	width: initial; | 	width: initial; | ||||||
| 	margin-bottom: 0.5rem; | 	margin-bottom: 0.5rem; | ||||||
| } | } | ||||||
|  | #search form { | ||||||
| fieldset > input { | 	flex: 1 1 auto | ||||||
| 	background: var(--background-secondary); | } | ||||||
| 	color: white; | #search fieldset > input { | ||||||
| 	font-weight: 600; | 	width: initial; | ||||||
| 	padding: 0.5rem; | } | ||||||
| 	border: thin solid var(--input-border-primary); | #search fieldset > input[type="submit"] { | ||||||
| 	border-radius: 0.2rem; | 	background-color: var(--background-secondary); | ||||||
|  | 	color: var(--text-secondary); | ||||||
|  | } | ||||||
|  | #search fieldset > input[type="submit"]:hover { | ||||||
|  | 	background-color: var(--link-secondary); | ||||||
|  | 	color: var(--background-secondary); | ||||||
| } | } | ||||||
| .no-css { | .no-css { | ||||||
| 	display: none; | 	display: none; | ||||||
| } | } | ||||||
|  | #tags #tag_initial_letter_index { | ||||||
|  | 	columns: 3 auto; | ||||||
|  | } | ||||||
|  | #tags #tag_initial_letter_index  li { | ||||||
|  | 	font-weight: bold; | ||||||
|  | 	list-style: none; | ||||||
|  | } | ||||||
|  | #tags .tag-index { | ||||||
|  | 	columns: 3 calc(var(--for-tablet-landscape-up) /3 ); | ||||||
|  | 	column-gap: 1rem; | ||||||
|  | } | ||||||
|  | #tags .index-link { | ||||||
|  | 	text-align: right; | ||||||
|  | } | ||||||
| .sr-only { | .sr-only { | ||||||
| 	position: absolute; | 	position: absolute; | ||||||
| 	width: 1px; | 	width: 1px; | ||||||
|   | |||||||
| @@ -1,45 +1,123 @@ | |||||||
|  <article> | <section id="search"> | ||||||
|     <header> | 	<header> | ||||||
|         <h1>Search HPR.</h1> | 		<h1>Search HPR.</h1> | ||||||
|     </header> | 	</header> | ||||||
| <hr /> | 	<div class="lane"> | ||||||
| <h2>Search Show Tags</h2> | 		<form name="google-search" method="get" action="https://www.google.com/search"> | ||||||
| <p> | 			<fieldset><legend>Google</legend> | ||||||
| <a href="<!--% absolute_path(baseurl) %-->tags.html">Complete list of all the Tags</a></p> | 				<input type="hidden" name="sitesearch" value="https://www.hackerpublicradio.org/" /> | ||||||
| <hr /> | 				<input name="q" type="text" placeholder="Search HPR with Google"/> | ||||||
| <h2>Google</h2> | 				<input type="submit" name="sa" value="Search HPR with Google" /> | ||||||
| <form name="google-search" method="get" action="https://www.google.com/search"> | 				<p> | ||||||
|   <input type="hidden" name="sitesearch" value="https://www.hackerpublicradio.org/" /> | 				<a href="https://www.google.com/policies/privacy/">privacy policy</a> | ||||||
|   <input name="q" type="text" placeholder="Search HPR with Google"/> | 				</p> | ||||||
|   <input type="submit" name="sa" value="Search HPR with Google" /> | 			</fieldset> | ||||||
| </form> | 		</form> | ||||||
| <br /> | 		<form method="get" id="search" action="https://duckduckgo.com/"> | ||||||
| <a href="https://www.google.com/policies/privacy/">privacy policy</a> | 			<fieldset><legend>DuckDuckGo</legend> | ||||||
| </p> | 			<input type="hidden" name="sites" value="https://www.hackerpublicradio.org/"/> | ||||||
| <hr /> | 			<input type="hidden" name="k8" value="#444444"/> | ||||||
| <h2>DuckDuckGo</h2> | 			<input type="hidden" name="k9" value="#D51920"/> | ||||||
| <form method="get" id="search" action="https://duckduckgo.com/"> | 			<input type="hidden" name="kt" value="h"/> | ||||||
|   <input type="hidden" name="sites" value="https://www.hackerpublicradio.org/"/> | 			<input type="text" name="q" maxlength="255" placeholder="Search HPR with DuckDuckGo"/> | ||||||
|   <input type="hidden" name="k8" value="#444444"/> | 			<input type="submit" value="Search HPR with DuckDuckGo" /> | ||||||
|   <input type="hidden" name="k9" value="#D51920"/> | 			<p> | ||||||
|   <input type="hidden" name="kt" value="h"/> | 			<a href="https://duckduckgo.com/privacy">privacy policy</a> | ||||||
|   <input type="text" name="q" maxlength="255" placeholder="Search HPR with DuckDuckGo"/> | 			</p> | ||||||
|   <input type="submit" value="Search HPR with DuckDuckGo" /> | 			</fieldset> | ||||||
| </form> | 		</form> | ||||||
| <br /> | 		<form method="get" action="https://www.bing.com/search"> | ||||||
| <a href="https://duckduckgo.com/privacy">privacy policy</a> | 			<fieldset><legend>Bing</legend> | ||||||
| </p> | 				<input type="hidden" name="cp" value="utf-8" /> | ||||||
| <hr /> | 				<input type="hidden" name="FORM" value="FREESS" /> | ||||||
| <h2>Bing</h2> | 				<input type="text" name="q" size="30" placeholder="Search HPR with Bing"/> | ||||||
| <p> | 				<input type="submit" value="Search HPR with Bing" /> | ||||||
| <form method="get" action="https://www.bing.com/search"> | 				<input type="hidden" name="q1" value="site:www.hackerpublicradio.org" /> | ||||||
| <input type="hidden" name="cp" value="utf-8" /> | 				<p> | ||||||
| <input type="hidden" name="FORM" value="FREESS" /> | 				<a href="https://www.microsoft.com/privacystatement/en-us/bing/default.aspx">privacy policy</a> | ||||||
| <input type="text" name="q" size="30" placeholder="Search HPR with Bing"/> | 				</p> | ||||||
| <input type="submit" value="Search HPR with Bing" /> | 			</fieldset> | ||||||
| <input type="hidden" name="q1" value="site:www.hackerpublicradio.org" /> | 		</form> | ||||||
| </form> | 	</div> | ||||||
| <br /> | </section> | ||||||
| <a href="https://www.microsoft.com/privacystatement/en-us/bing/default.aspx">privacy policy</a> | <section id="tags"> | ||||||
| </p> | <!--% PROCESS 'shared-utils.tpl.html' %--> | ||||||
|   </article> | <!--% PROCESS "queries-tags.tpl.html" %--> | ||||||
|  | <!--% USE DBI(constants.driver) %--> | ||||||
|  | <!--% PERL %--> | ||||||
|  | $Template::Stash::PRIVATE = undef; # Allow . in tag | ||||||
|  | <!--% END %--> | ||||||
|  | <!--% USE String %--> | ||||||
|  | <!--% uniq_tag_count = 0 %--> | ||||||
|  | <!--% FOREACH episode IN DBI.query(query_tags); | ||||||
|  |     ep_id = episode.id; | ||||||
|  |     ep_tags = episode.tags; | ||||||
|  |     FOREACH tag_str IN ep_tags.csv_parse; | ||||||
|  |         NEXT UNLESS tag_str; | ||||||
|  |         NEXT IF tag_str == ''; | ||||||
|  |         tag = tag_str.lower; | ||||||
|  | 		tag_index = String.new(tag).push('_'); | ||||||
|  |         first_char = tag.substr(0,1); | ||||||
|  |         IF first_char == '.'; | ||||||
|  |             first_char = '.'; # Unicode . | ||||||
|  |         END; | ||||||
|  |         IF all_tags.${first_char}.exists(tag_index); | ||||||
|  |             all_tags.${first_char}.${tag_index}.count = all_tags.${first_char}.${tag_index}.count + 1; | ||||||
|  |             all_tags.${first_char}.${tag_index}.urls.push(ep_id); | ||||||
|  |         ELSE; | ||||||
|  |             all_tags.${first_char}.${tag_index}.count = 1; | ||||||
|  |             uniq_tag_count = uniq_tag_count + 1; | ||||||
|  |             all_tags.${first_char}.${tag_index}.urls = [ep_id]; | ||||||
|  |         END; | ||||||
|  |     END; | ||||||
|  | END %--> | ||||||
|  | <!--% USE date %--> | ||||||
|  | <!--% all_first = ['#','.','/','0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] %--> | ||||||
|  | <header> | ||||||
|  | 	<hgroup> | ||||||
|  | 	<h1 class="title"><a id="TOP">Search by Tag</a></h1> | ||||||
|  | 	<p class="date">Page generated on <!--% date.format(date.now, format => '%Y-%m-%d at %H:%M:%S UTC', gmt => 1) %--></p> | ||||||
|  | 	</hgroup> | ||||||
|  | </header> | ||||||
|  | 	<p>This section summarises all of the tags currently used throughout the | ||||||
|  | 	database. The tags are in alphabetical order and each is followed by links to | ||||||
|  | 	the show numbers where it is used so you can see the context the author used | ||||||
|  | 	it in. There are currently <!--% uniq_tag_count %--> unique tags in the system.</p> | ||||||
|  | 	<h4>Alphabetical index</h4> | ||||||
|  | 	<p>This is an index to the initial letters of the tags below.</p> | ||||||
|  | 	<ul id="tag_initial_letter_index"> | ||||||
|  |     <!--% FOREACH first_char IN all_first %--> | ||||||
|  |         <!--% IF all_tags.${first_char} %--> | ||||||
|  |             <li><a href="<!--% absolute_path(baseurl) %-->search.html#<!--% tag_to_id(String.new(all_tags.${first_char}.keys.sort.first).chop) %-->"><strong><!--% first_char %--></strong></a></li> | ||||||
|  |         <!--% END %--> | ||||||
|  |     <!--% END %--> | ||||||
|  | 	</ul> | ||||||
|  | 	<hr class="no-css"> | ||||||
|  |     <!--% FOREACH first_char IN all_first %--> | ||||||
|  |         <!--% IF all_tags.${first_char} %--> | ||||||
|  | 		<p class="index-link"><a href="<!--% absolute_path(baseurl) %-->search.html#TOP">↑ Go to index</a></p> | ||||||
|  | 	        <h3>Tags beginning with '<!--% first_char %-->'</h3> | ||||||
|  | 	        <ul class="tag-index"> | ||||||
|  |                 <!--% FOREACH tag_index IN all_tags.${first_char}.keys.sort %--> | ||||||
|  | 				<!--% tag = String.new(tag_index).chop; tag_id = String.new(tag_index).chop; %--> | ||||||
|  |     	        	<li> | ||||||
|  |     	        		<a id="<!--% tag_to_id(tag_id) %-->"><strong><!--% tag %--></strong></a>:  | ||||||
|  |                         <!--% ep_links = [] %--> | ||||||
|  |                         <!--% FOREACH ep_id IN all_tags.${first_char}.${tag_index}.urls.nsort; | ||||||
|  | 							ep_links.push("<a href=\"${absolute_path(baseurl)}eps/hpr" _ zero_pad_left(ep_id) _ '/index.html"' | ||||||
|  |                                 ' target="_blank" aria-label="' _ tag _ | ||||||
|  |                                 ' - show ' _ ep_id _ '">' _ ep_id _ '</a>'); | ||||||
|  |                         END %--> | ||||||
|  |                         <!--% ep_links.join(', ') %--> | ||||||
|  |     	        	</li> | ||||||
|  |                 <!--% END %--> | ||||||
|  | 	        </ul> | ||||||
|  |         <!--% END %--> | ||||||
|  |     <!--% END %--> | ||||||
|  | 	<p><a href="#TOP">Go to TOP of page</a></p> | ||||||
|  | </article> | ||||||
|  | <!--% PERL %--> | ||||||
|  | $Template::Stash::PRIVATE = 1; | ||||||
|  | <!--% END %--> | ||||||
|  |  | ||||||
|  | </section> | ||||||
|   | |||||||
| @@ -1,3 +1,4 @@ | |||||||
|  | <section id="tags"> | ||||||
| <!--% PROCESS 'shared-utils.tpl.html' %--> | <!--% PROCESS 'shared-utils.tpl.html' %--> | ||||||
| <!--% PROCESS "queries-tags.tpl.html" %--> | <!--% PROCESS "queries-tags.tpl.html" %--> | ||||||
| <!--% USE DBI(constants.driver) %--> | <!--% USE DBI(constants.driver) %--> | ||||||
| @@ -30,39 +31,31 @@ $Template::Stash::PRIVATE = undef; # Allow . in tag | |||||||
| END %--> | END %--> | ||||||
| <!--% USE date %--> | <!--% USE date %--> | ||||||
| <!--% all_first = ['#','.','/','0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] %--> | <!--% all_first = ['#','.','/','0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] %--> | ||||||
|  | <header> | ||||||
| <style> | 	<hgroup> | ||||||
|     .columns3 { columns: 3 auto; list-style-type: none } | 	<h1 class="title"><a id="TOP">Search by Tag</a></h1> | ||||||
|     hr.thin { | 	<p class="date">Page generated on <!--% date.format(date.now, format => '%Y-%m-%d at %H:%M:%S UTC', gmt => 1) %--></p> | ||||||
|         border: 0; | 	</hgroup> | ||||||
|         height: 0; | </header> | ||||||
|         border-top: 1px solid rgba(0, 0, 0, 0.1); |  | ||||||
|         border-bottom: 1px solid rgba(255, 255, 255, 0.3); |  | ||||||
|     } |  | ||||||
|     p.ralign { text-align: right } |  | ||||||
| </style> |  | ||||||
| <article> |  | ||||||
| 	<a id="TOP"><h1 class="title">Tag summary</h1></a> |  | ||||||
| 	<h4 class="date">Page generated on <!--% date.format(date.now, format => '%Y-%m-%d at %H:%M:%S UTC', gmt => 1) %--></h4> |  | ||||||
| 	<p>This section summarises all of the tags currently used throughout the | 	<p>This section summarises all of the tags currently used throughout the | ||||||
| 	database. The tags are in alphabetical order and each is followed by links to | 	database. The tags are in alphabetical order and each is followed by links to | ||||||
| 	the show numbers where it is used so you can see the context the author used | 	the show numbers where it is used so you can see the context the author used | ||||||
| 	it in. There are currently <!--% uniq_tag_count %--> unique tags in the system.</p> | 	it in. There are currently <!--% uniq_tag_count %--> unique tags in the system.</p> | ||||||
| 	<h4>Alphabetical index</h4> | 	<h4>Alphabetical index</h4> | ||||||
| 	<p>This is an index to the initial letters of the tags below.</p> | 	<p>This is an index to the initial letters of the tags below.</p> | ||||||
| 	<ul class="columns3"> | 	<ul id="tag_initial_letter_index"> | ||||||
|     <!--% FOREACH first_char IN all_first %--> |     <!--% FOREACH first_char IN all_first %--> | ||||||
|         <!--% IF all_tags.${first_char} %--> |         <!--% IF all_tags.${first_char} %--> | ||||||
|             <li><a href="<!--% absolute_path(baseurl) %-->tags.html#<!--% tag_to_id(String.new(all_tags.${first_char}.keys.sort.first).chop) %-->"><strong><!--% first_char %--></strong></a></li> |             <li><a href="<!--% absolute_path(baseurl) %-->search.html#<!--% tag_to_id(String.new(all_tags.${first_char}.keys.sort.first).chop) %-->"><strong><!--% first_char %--></strong></a></li> | ||||||
|         <!--% END %--> |         <!--% END %--> | ||||||
|     <!--% END %--> |     <!--% END %--> | ||||||
| 	</ul> | 	</ul> | ||||||
| 	<hr> | 	<hr class="no-css"> | ||||||
|     <!--% FOREACH first_char IN all_first %--> |     <!--% FOREACH first_char IN all_first %--> | ||||||
|         <!--% IF all_tags.${first_char} %--> |         <!--% IF all_tags.${first_char} %--> | ||||||
| 		<p class="ralign"><a href="<!--% absolute_path(baseurl) %-->tags.html#TOP">↑ Go to index</a></p> | 		<p class="index-link"><a href="<!--% absolute_path(baseurl) %-->search.html#TOP">↑ Go to index</a></p> | ||||||
| 	        <h3>Tags beginning with '<!--% first_char %-->'</h3> | 	        <h3>Tags beginning with '<!--% first_char %-->'</h3> | ||||||
| 	        <ul> | 	        <ul class="tag-index"> | ||||||
|                 <!--% FOREACH tag_index IN all_tags.${first_char}.keys.sort %--> |                 <!--% FOREACH tag_index IN all_tags.${first_char}.keys.sort %--> | ||||||
| 				<!--% tag = String.new(tag_index).chop; tag_id = String.new(tag_index).chop; %--> | 				<!--% tag = String.new(tag_index).chop; tag_id = String.new(tag_index).chop; %--> | ||||||
|     	        	<li> |     	        	<li> | ||||||
| @@ -84,3 +77,5 @@ END %--> | |||||||
| <!--% PERL %--> | <!--% PERL %--> | ||||||
| $Template::Stash::PRIVATE = 1; | $Template::Stash::PRIVATE = 1; | ||||||
| <!--% END %--> | <!--% END %--> | ||||||
|  |  | ||||||
|  | </section> | ||||||
		Reference in New Issue
	
	Block a user