From 6432a7e414fe8c61fb76aba639bb3ce604014936 Mon Sep 17 00:00:00 2001 From: Rafael Ferreira da Silva Date: Sun, 3 Jul 2022 15:13:57 -0400 Subject: [PATCH] adding search capability --- _includes/search_form.html | 26 ++++++++++++++++++++++---- _includes/sidebar.html | 3 +++ assets/css/main.css | 7 +++++-- search.json | 26 +++++++++++++++++++++++++- 4 files changed, 55 insertions(+), 7 deletions(-) diff --git a/_includes/search_form.html b/_includes/search_form.html index bd0c3bef86..af63eb6cd5 100644 --- a/_includes/search_form.html +++ b/_includes/search_form.html @@ -16,16 +16,34 @@ json: "/search.json", searchResultTemplate: ` + {category} {title}
- {description} + {description}
-
{category}
`, templateMiddleware: function (prop, value, template) { if (prop == "description") { - return value.substring(0,50) + "..."; + if (value.length > 0) { + value = '' + value + '' + if (value.length > 75) { + return value.substring(0, 75) + "..."; + } + } else { + return "" + } + } + if (prop == "category") { + let color = "f2b3a2" + if (value == "story") { + color = "D89398" + } else if (value == "event") { + color = "85BCC2" + } else if (value == "job") { + color = "6689BA" + } + return '' + value + '' } }, - noResultsText: 'No results found' + noResultsText: 'No results found' }) \ No newline at end of file diff --git a/_includes/sidebar.html b/_includes/sidebar.html index c56a711e07..94e155d4d2 100644 --- a/_includes/sidebar.html +++ b/_includes/sidebar.html @@ -33,6 +33,9 @@ + + {% include search_form.html %} + diff --git a/assets/css/main.css b/assets/css/main.css index 1daa35c785..15cd982ef5 100644 --- a/assets/css/main.css +++ b/assets/css/main.css @@ -5088,9 +5088,12 @@ main a { } .search-cat { - position: absolute; + float: right; top: 0; right: 0; z-index: 1000; - color: red; + font-size: 0.7em; + color: #fff; + padding: 0.1em 1em; + border-radius: 0.5em; } diff --git a/search.json b/search.json index 5f5c0fbca8..0dc2e8c314 100644 --- a/search.json +++ b/search.json @@ -6,8 +6,32 @@ "title" : "{{ system.title }}", "url" : "{{ site.baseurl }}{{ system.url }}", "description" : "{{ system.description | strip_html | strip_newlines | escape }}", - "tags" : "{{ system.tags | strip_html | strip_newlines | escape }}", + "tags" : "{{ system.tags | array_to_sentence_string: '' }}", "category" : "system" + }, + {% endfor %} + {% for job in site.jobs %} + { + "title" : "{{ job.title }}", + "url" : "{{ site.baseurl }}{{ job.url }}", + "description" : "{{ job.content | strip_html | strip_newlines | escape }}", + "category" : "job" + }, + {% endfor %} + {% for story in site.stories %} + { + "title" : "{{ story.title }}", + "url" : "{{ site.baseurl }}{{ story.url }}", + "description" : "{{ story.content | strip_html | strip_newlines | escape }}", + "category" : "story" + }, + {% endfor %} + {% for event in site.data.events %} + { + "title" : "{{ event.series }} ({{ event.type }})", + "url" : "{{ event.url }}", + "description" : "{{ event.name }}", + "category" : "event" } {% unless forloop.last %},{% endunless %} {% endfor %} ]