Skip to content

Commit

Permalink
Merge pull request #568 from flibbertigibbet/feature/oct-28-2016-deploy
Browse files Browse the repository at this point in the history
Feature/oct 28 2016 deploy
  • Loading branch information
flibbertigibbet authored Oct 28, 2016
2 parents 7e0c6ab + 3eba986 commit a4ec201
Show file tree
Hide file tree
Showing 102 changed files with 6,016 additions and 200 deletions.
4 changes: 4 additions & 0 deletions deployment/ansible/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ app_username: "vagrant"

packer_version: "0.7.5"

nodejs_version: 4.6.0

otp_router: "default"

# used by nginx and gunicorn to set timeouts; OTP defaults to 30s
otp_session_timeout_s: 30

Expand Down
4 changes: 2 additions & 2 deletions deployment/ansible/roles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
version: 0.2.6

- src: azavea.opentripplanner
version: 1.0.1
version: 1.0.3

- src: azavea.nginx
version: 0.2.2
Expand All @@ -29,4 +29,4 @@
version: 0.1.0

- src: azavea.postgresql-support
version: 0.3.0
version: 0.3.1
14 changes: 11 additions & 3 deletions deployment/ansible/roles/cac-tripplanner.app/tasks/jslibs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,16 @@
when: production

- name: Install NPM dependencies
command: npm install chdir="{{ root_src_dir }}"
command: npm install
become: no
args:
chdir: "{{ root_src_dir }}"

- name: Rebuild SASS bindings
command: npm rebuild node-sass
become: no
args:
chdir: "{{ root_src_dir }}"

- name: Create Static Directory
file: path="{{ root_static_dir }}" state=directory mode=0755 owner="{{ app_username }}"
Expand All @@ -18,14 +26,14 @@
args:
chdir: "{{ root_src_dir }}"

- name: Create static files -- development
- name: Build javascript assets -- development
command: npm run gulp-development
become: no
args:
chdir: "{{ root_src_dir }}"
when: not production and not test

- name: Create static files -- production
- name: Build javascript assets -- production
command: npm run gulp-production
become: no
args:
Expand Down
11 changes: 11 additions & 0 deletions deployment/ansible/roles/cac-tripplanner.app/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@
notify: Restart cac-tripplanner-app
when: develop or test

- name: Run collectstatic
django_manage: command=collectstatic
app_path=/opt/app/python/cac_tripplanner

- name: Copy media assets
copy: src=../../python/cac_tripplanner/default_media
dest=/media/cac
owner={{ app_username }}
group={{ app_username }}
when: develop or test

- name: Copy nginx config
template: src=nginx-default.j2 dest=/etc/nginx/sites-available/default
notify: Restart nginx
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
---
dependencies:
- { role: "azavea.postgresql-support", postgresql_support_libpq_version: 9.5.* }
- { role: "azavea.postgresql-support" }

This file was deleted.

19 changes: 9 additions & 10 deletions python/cac_tripplanner/cac_tripplanner/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@

USE_TZ = True

# Directory for default featured destinations added in destinations 0012
# subdir of MEDIA_ROOT
# used in migration destinations 0016, DO NOT put any other files in this media folder
# they will be deleted on a backwards migration from 0016 -> 0015
# NOTE: If the images placed here are to be used in production as well, they will need to be copied
# to the bucket specified in AWS_STORAGE_BUCKET_NAME
DEFAULT_MEDIA_PATH = 'default_media'
# src directory for default media images
DEFAULT_MEDIA_SRC_PATH = os.path.join(BASE_DIR, DEFAULT_MEDIA_PATH)

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
Expand Down Expand Up @@ -238,16 +247,6 @@
#
MAX_IMAGE_SIZE_MB = 1

# Directory for default featured destinations added in destinations 0012
# subdir of MEDIA_ROOT
# used in migration destinations 0016, DO NOT put any other files in this media folder
# they will be deleted on a backwards migration from 0016 -> 0015
# NOTE: If the images placed here are to be used in production as well, they will need to be copied
# to the bucket specified in AWS_STORAGE_BUCKET_NAME
DEFAULT_MEDIA_PATH = 'default_media'
# src directory for default media images
DEFAULT_MEDIA_SRC_PATH = os.path.join(BASE_DIR, DEFAULT_MEDIA_PATH)

# limit the number of featured destinations/articles returned by "view all" to this amount
# TODO: paginate instead?
HOMEPAGE_RESULTS_LIMIT = 20
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('shortlinks', '0003_auto_20150513_1039'),
]

operations = [
migrations.AlterField(
model_name='shortenedlink',
name='destination',
field=models.CharField(max_length=2048),
),
]
2 changes: 1 addition & 1 deletion python/cac_tripplanner/shortlinks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class ShortenedLink(models.Model):
"""Represents a shortened URL used to share routes"""
key = models.CharField(max_length=30, db_index=True) # base-58-encoded UUID
destination = models.CharField(max_length=512)
destination = models.CharField(max_length=2048)
create_date = models.DateTimeField(auto_now_add=True)
is_public = models.BooleanField(default=True)

Expand Down
4 changes: 3 additions & 1 deletion python/cac_tripplanner/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{% block cssimports %}

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cartodb-libs.global.ssl.fastly.net/cartodb.js/v3/3.15/themes/css/cartodb.css" />
<link href="{% static 'styles/vendor.css' %}" rel="stylesheet">
<link href="{% static 'styles/main.css' %}" rel="stylesheet">
Expand Down Expand Up @@ -93,6 +93,8 @@
<script src="{% static 'scripts/vendor/Polyline.encoded.js' %}"></script>
<script src="{% static 'scripts/vendor/typeahead.bundle.js' %}"></script>
<script src="{% static 'scripts/vendor/leaflet.awesome-markers.js' %}"></script>
<script src="{% static 'scripts/vendor/turf-helpers.js' %}"></script>
<script src="{% static 'scripts/vendor/turf-nearest.js' %}"></script>
<script src="{% static 'scripts/vendor/moment.js' %}"></script>
<script src="{% static 'scripts/vendor/moment-duration-format.js' %}"></script>
<script src="{% static 'scripts/vendor/bootstrap-datetimepicker.min.js' %}"></script>
Expand Down
3 changes: 2 additions & 1 deletion src/.jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"CAC": true,
"L": true,
"_": true,
"moment": true
"moment": true,
"turf": true
}
}
24 changes: 17 additions & 7 deletions src/app/scripts/cac/control/cac-control-directions-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* View control for the sidebar directions list
*
*/
CAC.Control.DirectionsList = (function (_, $, MapTemplates, Social, UserPreferences, Utils) {
CAC.Control.DirectionsList = (function (_, $, MapTemplates, Social) {

'use strict';

Expand Down Expand Up @@ -31,7 +31,7 @@ CAC.Control.DirectionsList = (function (_, $, MapTemplates, Social, UserPreferen
var eventNames = {
backButtonClicked: 'cac:control:directionslist:backbutton',
listItemClicked: 'cac:control:directionslist:listitem',
directionHovered: 'cac:control:directionslist:directionhover'
directionHovered: 'cac:control:directionslist:directionhover',
};

var $container = null;
Expand Down Expand Up @@ -91,19 +91,29 @@ CAC.Control.DirectionsList = (function (_, $, MapTemplates, Social, UserPreferen
e.stopPropagation();
});


$container.empty();

// Show alert with link to transit agency bicycle policy for bike+transit itineraries
if (_.contains(itinerary.modes, 'BICYCLE') && itinerary.agencies.length) {
if (_.includes(itinerary.modes, 'BICYCLE') && itinerary.agencies.length) {
var $alert = MapTemplates.bicycleWarningAlert(itinerary.agencies);
$container.append($alert);
}

$container.append($html);

var params = $.extend({itineraryIndex: itinerary.id}, itinerary.requestParameters);
var directionsUrl = '/directions/?' + Utils.encodeUrlParams(params);

// Share link to directions list page, which is relative to the current URL,
// has all of the current URL's parameters,
// does *not* have the map path (just directions, with a trailing slash),
// and has an added parameter for the selected itinerary.
var href = window.location.href;
var directionsUrl = ['/directions/',
href.slice(href.indexOf('/map/directions') + '/map/directions'.length),
'&',
$.param({itineraryIndex: itinerary.id})
].join('');

// TODO: postpone shortening link until user chooses to share directions
socialSharing.shortenLink(directionsUrl).then(function(shortened) {
// set up click handlers for social sharing with shortened link
$(options.selectors.twitterShareButton).on('click',
Expand Down Expand Up @@ -158,4 +168,4 @@ CAC.Control.DirectionsList = (function (_, $, MapTemplates, Social, UserPreferen
}
}

})(_, jQuery, CAC.Map.Templates, CAC.Share.Social, CAC.User.Preferences, CAC.Utils);
})(_, jQuery, CAC.Map.Templates, CAC.Share.Social);
62 changes: 56 additions & 6 deletions src/app/scripts/cac/control/cac-control-sidebar-directions.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ CAC.Control.SidebarDirections = (function (_, $, Control, BikeModeOptions, Geoco
itineraryListControl.events.on(itineraryListControl.eventNames.itineraryHover,
onItineraryHover);

mapControl.events.on(mapControl.eventNames.waypointsSet, queryWithWaypoints);
mapControl.events.on(mapControl.eventNames.waypointMoved, liveUpdateItinerary);

typeaheadDest = new Typeahead(options.selectors.typeaheadDest);
typeaheadDest.events.on(typeaheadDest.eventNames.selected, onTypeaheadSelected);
typeaheadDest.events.on(typeaheadDest.eventNames.cleared, onTypeaheadCleared);
Expand Down Expand Up @@ -154,17 +157,20 @@ CAC.Control.SidebarDirections = (function (_, $, Control, BikeModeOptions, Geoco
var date = picker.date() || moment();

var mode = bikeModeOptions.getMode(options.selectors.modeSelectors);
var arriveBy = false; // depart at time by default
if ($(options.selectors.departAtSelect).val() === 'arriveBy') {
arriveBy = true;
}
var arriveBy = isArriveBy(); // depart at time by default

// options to pass to OTP as-is
var otpOptions = {
mode: mode,
arriveBy: arriveBy
};

// add intermediatePlaces if user edited route
var waypoints = UserPreferences.getPreference('waypoints');
if (waypoints && waypoints.length && !arriveBy) {
otpOptions.waypoints = waypoints;
}

if (mode.indexOf('BICYCLE') > -1) {
var bikeTriangleOpt = $('option:selected', options.selectors.bikeTriangleDiv);
var bikeTriangle = bikeTriangleOpt.val();
Expand Down Expand Up @@ -222,6 +228,14 @@ CAC.Control.SidebarDirections = (function (_, $, Control, BikeModeOptions, Geoco
}
});

// If there is only one itinerary, make it draggable.
// Only one itinerary is returned if there are waypoints, so this
// lets the user to continue to add or modify waypoints without
// having to select it in the list.
if (itineraries.length === 1 && !isArriveBy()) {
mapControl.draggableItinerary(currentItinerary);
}

// put markers at start and end
mapControl.setDirectionsMarkers(directions.origin, directions.destination);
itineraryListControl.setItineraries(itineraries);
Expand Down Expand Up @@ -250,6 +264,7 @@ CAC.Control.SidebarDirections = (function (_, $, Control, BikeModeOptions, Geoco
}

function clearItineraries() {
UserPreferences.setPreference('waypoints', undefined);
mapControl.clearItineraries();
itineraryListControl.hide();
directionsListControl.hide();
Expand All @@ -273,10 +288,13 @@ CAC.Control.SidebarDirections = (function (_, $, Control, BikeModeOptions, Geoco
itineraryListControl.showItineraries(false);
itinerary.show(true);
itinerary.highlight(true);
currentItinerary = itinerary;

directionsListControl.setItinerary(itinerary);
if (!isArriveBy()) {
mapControl.draggableItinerary(itinerary);
}

currentItinerary = itinerary;
directionsListControl.setItinerary(itinerary);
itineraryListControl.hide();
directionsListControl.show();
}
Expand All @@ -286,6 +304,19 @@ CAC.Control.SidebarDirections = (function (_, $, Control, BikeModeOptions, Geoco
return $(options.selectors.itineraryBlock + '[data-itinerary="' + id + '"]');
}

/**
* Helper to check if user has selected to route by arrive-by time
* rather than default depart-at time.
*
* @returns boolean True if user has selected arrive-by
*/
function isArriveBy() {
if ($(options.selectors.departAtSelect).val() === 'arriveBy') {
return true;
}
return false;
}

/**
* Handles hover events to highlight a given itinerary
*/
Expand All @@ -299,6 +330,25 @@ CAC.Control.SidebarDirections = (function (_, $, Control, BikeModeOptions, Geoco
}
}

function liveUpdateItinerary(event, itinerary) {
var oldLayer = itinerary.geojson;
Routing.planLiveUpdate(itinerary).then(function(newItinerary) {
mapControl.updateItineraryLayer(oldLayer, newItinerary);
}, function(error) {
console.error(error);
// occasionally cannot plan route if waypoint cannot be snapped to street grid
mapControl.errorLiveUpdatingLayer();
});
}

/**
* Initiate a trip plan when user finishes editing a route.
*/
function queryWithWaypoints(event, points) {
UserPreferences.setPreference('waypoints', points.waypoints);
planTrip();
}

function reverseOriginDestination() {
// read what they are now
var origin = UserPreferences.getPreference('origin');
Expand Down
Loading

0 comments on commit a4ec201

Please sign in to comment.