Skip to content
This repository has been archived by the owner on Dec 23, 2017. It is now read-only.

giving the front end api_location #60

Merged
merged 1 commit into from
Mar 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from openfecwebapp.local_config import port, debug, host
from openfecwebapp.local_config import port, debug, host, api_location
from flask import Flask, render_template, request
from openfecwebapp.views import (render_search_results, render_table,
render_page)
Expand All @@ -11,6 +11,8 @@

app = Flask(__name__)

app.jinja_env.globals['api_location'] = api_location

def _convert_to_dict(params):
# move from immutablemultidict -> multidict -> dict
params = params.copy().to_dict()
Expand Down
13 changes: 9 additions & 4 deletions static/js/modules/typeahead.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,18 @@ module.exports = {
committeeSuggestion,
headerTpl,
glossaryEngine,
glossarySuggestion;

glossarySuggestion,
url = "/rest/names?q=%QUERY";

if (typeof API_LOCATION !== 'undefined') {
url = API_LOCATION.concat(url);
}

// Creating a candidate suggestion engine
candidateEngine = new Bloodhound({
name: 'Candidates',
remote: {
url: "/rest/names?q=%QUERY",
url: url,
filter: function(response) {
var results = $.map(response.results, function(result){
if ( result.candidate_id !== null ) {
Expand All @@ -71,7 +76,7 @@ module.exports = {
committeeEngine = new Bloodhound({
name: 'Committees',
remote: {
url: "/rest/names?q=%QUERY",
url: url,
filter: function(response) {
var results = $.map(response.results, function(result) {
if ( result.committee_id !== null ) {
Expand Down
5 changes: 5 additions & 0 deletions templates/layouts/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
<link href="/static/styles/styles.css" rel="stylesheet" type="text/css"/>
<link href='https://fonts.googleapis.com/css?family=Raleway:300,400,600,700|Open+Sans:300,400,600,700|Source+Code+Pro:400' rel='stylesheet' type='text/css'>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
{% if api_location %}
<script>
API_LOCATION = "{{api_location}}"
</script>
{% endif %}
</head>
<body>
<div class="page-wrap">
Expand Down