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
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.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
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(
data-main=jsPath+'list.js?fingerprint='+fingerprint(jsPath + 'list.js'),
baseurl=jsPath,

View file

@ -3,7 +3,7 @@ define ["libs/algolia", "libs/angular", "libs/angular-autocomplete/angular-autoc
app = angular.module("userProfileInformationApp", ["autocomplete"])
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) ->
return (scope, element, attr) ->