Improve styling of wiki search

This commit is contained in:
James Allen 2016-03-24 11:38:56 +00:00
parent ce2cfeaa5b
commit 9b84e1b164
3 changed files with 39 additions and 13 deletions

View file

@ -23,20 +23,16 @@ block content
style="cursor: pointer;", style="cursor: pointer;",
ng-show="searchQueryText.length > 0" ng-show="searchQueryText.length > 0"
) )
.col-md-2 .col-md-3.text-right
a.btn.btn-primary(ng-click="showMissingTemplateModal()") #{translate("missing_page")} a.btn.btn-primary(ng-click="showMissingTemplateModal()") #{translate("missing_page")}
.row .row
.col-md-12(ng-cloak) .col-md-12(ng-cloak)
ul.list-unstyled a(ng-href='{{hit.url}}',ng-repeat='hit in hits').search-result.card.card-thin
li(ng-repeat='hit in hits') span(ng-bind-html='hit.name')
.searchResult.thumbnail div.search-result-content(ng-show="hit.content != ''", ng-bind-html='hit.content')
.row
.col-md-12
a(ng-href='{{hit.url}}')
span(ng-bind-html='hit.name')
.card(ng-non-bindable) .card.row-spaced(ng-non-bindable)
.page-header .page-header
h1 #{title} h1 #{title}

View file

@ -26,10 +26,22 @@ define [
buildHitViewModel = (hit)-> buildHitViewModel = (hit)->
page_underscored = hit.pageName.replace(/\s/g,'_') page_underscored = hit.pageName.replace(/\s/g,'_')
section_underscored = hit.sectionName.replace(/\s/g,'_') section_underscored = hit.sectionName.replace(/\s/g,'_')
content = hit._highlightResult.content.value
# Replace many new lines
content = content.replace(/\n\n+/g, "\n\n")
lines = content.split("\n")
# Only show the lines that have a highlighted match
matching_lines = []
for line in lines
if !line.match(/^\[edit\]/)
content += line + "\n"
if line.match(/<em>/)
matching_lines.push line
content = matching_lines.join("\n...\n")
result = result =
name : hit._highlightResult.pageName.value + " - " + hit._highlightResult.sectionName.value name : hit._highlightResult.pageName.value + " - " + hit._highlightResult.sectionName.value
url :"/learn/#{page_underscored}##{section_underscored}" url :"/learn/#{page_underscored}##{section_underscored}"
console.log result content: content
return result return result
updateHits = (hits)-> updateHits = (hits)->

View file

@ -104,9 +104,27 @@
/*]]>*/ /*]]>*/
.thumbnail { a.search-result {
margin-bottom:0px; display: block;
margin-top:5px; margin-top: @line-height-computed / 2;
.search-result-content {
margin-top: @line-height-computed / 4;
white-space: pre-wrap;
font-size: 0.8em;
color: @gray-dark;
em {
font-weight: bold;
}
}
&:hover {
text-decoration: none;
.search-result-content {
color: @gray-darker;
}
box-shadow: 0 2px 4px rgba(0,0,0,0.35);
}
} }
} }