get algolia to pull app id and api key from settings file

This commit is contained in:
Henry Oswald 2014-06-17 12:25:49 +01:00
parent cc1b9472b2
commit 2d55f080d6
3 changed files with 17 additions and 2 deletions

View file

@ -99,7 +99,12 @@ module.exports =
return res.send 500 return res.send 500
logger.log results:results, user_id:user_id, "rendering project list" logger.log results:results, user_id:user_id, "rendering project list"
viewModel = _buildListViewModel results.projects[0], results.projects[1], results.projects[2], results.tags[0], results.tags[1] viewModel = _buildListViewModel results.projects[0], results.projects[1], results.projects[2], results.tags[0], results.tags[1]
viewModel.showUserDetailsArea = Settings?.algolia?.institutions?.app_id? and Settings?.algolia?.institutions?.api_key? if Settings?.algolia?.institutions?.app_id? and Settings?.algolia?.institutions?.api_key?
viewModel.showUserDetailsArea = true
viewModel.algolia_api_key = Settings.algolia.institutions.api_key
viewModel.algolia_app_id = Settings.algolia.institutions.app_id
else
viewModel.showUserDetailsArea = false
res.render 'project/list', viewModel res.render 'project/list', viewModel
timer.done() timer.done()

View file

@ -172,6 +172,16 @@ block content
] ]
}; };
- if (showUserDetailsArea)
script
window.algolia = {
institutions:{
app_id:'#{algolia_app_id}',
api_key:'#{algolia_api_key}'
}
}
script( script(
data-main=jsPath+'list.js?fingerprint='+fingerprint(jsPath + 'list.js'), data-main=jsPath+'list.js?fingerprint='+fingerprint(jsPath + 'list.js'),
baseurl=jsPath, baseurl=jsPath,

View file

@ -3,7 +3,7 @@ define ["libs/algolia", "libs/angular", "libs/angular-autocomplete/angular-autoc
app = angular.module("userProfileInformationApp", ["autocomplete"]) app = angular.module("userProfileInformationApp", ["autocomplete"])
app.factory "Institutions", -> app.factory "Institutions", ->
new AlgoliaSearch("SK53GL4JLY", "1606ccef5b70ac44680b61e6b0285126").initIndex("institutions") new AlgoliaSearch(window.algolia.institutions.app_id, window.algolia.institutions.api_key).initIndex("institutions")
app.directive "focusInput", ($timeout) -> app.directive "focusInput", ($timeout) ->
return (scope, element, attr) -> return (scope, element, attr) ->