From ce2cfeaa5b503657cb782f864cb073e20f5a4758 Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Thu, 24 Mar 2016 09:52:19 +0000 Subject: [PATCH] don't show search bar in templates if its not configured --- services/web/app/views/wiki/page.jade | 47 ++++++++++--------- .../web/public/coffee/main/templates.coffee | 7 +-- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/services/web/app/views/wiki/page.jade b/services/web/app/views/wiki/page.jade index 77b938c465..53d4fad401 100644 --- a/services/web/app/views/wiki/page.jade +++ b/services/web/app/views/wiki/page.jade @@ -9,29 +9,32 @@ block content .row .col-xs-3.contents(ng-non-bindable) | !{contents.content} - .col-xs-9.page(ng-controller="SearchWikiController") - .row - form.project-search.form-horizontal.col-md-9(role="form") - .form-group.has-feedback.has-feedback-left.col-md-12 - input.form-control.col-md-12(type='text', ng-model='searchQueryText', ng-keyup='search()', placeholder="Search help library....") - i.fa.fa-search.form-control-feedback-left - i.fa.fa-times.form-control-feedback( - ng-click="clearSearchText()", - style="cursor: pointer;", - ng-show="searchQueryText.length > 0" - ) - .col-md-2 - a.btn.btn-primary(ng-click="showMissingTemplateModal()") #{translate("missing_page")} - .row - .col-md-12(ng-cloak) - ul.list-unstyled - li(ng-repeat='hit in hits') - .searchResult.thumbnail - .row - .col-md-12 - a(ng-href='{{hit.url}}') - span(ng-bind-html='hit.name') + .col-xs-9.page + - if(typeof(settings.algolia) != "undefined" && typeof(settings.algolia.indexes) != "undefined" && typeof(settings.algolia.indexes.wiki) != "undefined") + span(ng-controller="SearchWikiController") + .row + form.project-search.form-horizontal.col-md-9(role="form") + .form-group.has-feedback.has-feedback-left.col-md-12 + input.form-control.col-md-12(type='text', ng-model='searchQueryText', ng-keyup='search()', placeholder="Search help library....") + i.fa.fa-search.form-control-feedback-left + i.fa.fa-times.form-control-feedback( + ng-click="clearSearchText()", + style="cursor: pointer;", + ng-show="searchQueryText.length > 0" + ) + .col-md-2 + a.btn.btn-primary(ng-click="showMissingTemplateModal()") #{translate("missing_page")} + + .row + .col-md-12(ng-cloak) + ul.list-unstyled + li(ng-repeat='hit in hits') + .searchResult.thumbnail + .row + .col-md-12 + a(ng-href='{{hit.url}}') + span(ng-bind-html='hit.name') .card(ng-non-bindable) .page-header diff --git a/services/web/public/coffee/main/templates.coffee b/services/web/public/coffee/main/templates.coffee index 717f7fb954..b9a1d3bc5d 100644 --- a/services/web/public/coffee/main/templates.coffee +++ b/services/web/public/coffee/main/templates.coffee @@ -3,9 +3,10 @@ define [ ], (App) -> App.factory "algoliawiki", -> - client = new AlgoliaSearch("SK53GL4JLY", "e398f35d3074fde57ca6d6c88d8be37c") - index = client.initIndex("lean-wiki-index") - return index + if window.sharelatex?.algolia? and window.sharelatex.algolia?.indexes?.wiki? + client = new AlgoliaSearch(window.sharelatex.algolia?.app_id, window.sharelatex.algolia?.api_key) + index = client.initIndex(window.sharelatex.algolia?.indexes?.wiki) + return index App.controller "SearchWikiController", ($scope, algoliawiki, _) -> algolia = algoliawiki