Skip to content

Commit

Permalink
Merge pull request #235 from SEL-Columbia/staging
Browse files Browse the repository at this point in the history
0.2.9 Release
  • Loading branch information
vr2262 committed Jan 25, 2016
2 parents 7bc5df4 + 8b86826 commit 35b73b5
Show file tree
Hide file tree
Showing 19 changed files with 217 additions and 53 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,9 @@ RUN cp -a /tmp/node_modules /dokomo/
ADD . /dokomo/
RUN pip install -r requirements.txt
RUN nodejs node_modules/gulp/bin/gulp.js build
RUN mkdir -p /var/www/static/dist
RUN cp -r /dokomo/dokomoforms/static/dist /var/www/static
RUN cp /dokomo/dokomoforms/static/robots.txt /var/www/static/robots.txt
RUN cp /dokomo/dokomoforms/static/manifest.json /var/www/static/manifest.json
RUN cp /dokomo/dokomoforms/static/src/common/img/favicon.png /var/www/static/favicon.png
EXPOSE 8888
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Several solutions exist to handle offline mobile data collection. While this typ

**Dokomo strives to simplify the process by integrating the elements of a data collection effort into a unified system, from creation of mobile-ready surveys to quick analysis and visualization of the collected data.**

The latest install script is here: https://raw.githubusercontent.com/SEL-Columbia/dokomoforms/v0.2.8/installer.sh
The latest install script is here: https://raw.githubusercontent.com/SEL-Columbia/dokomoforms/v0.2.9/installer.sh

## Features

Expand Down
5 changes: 4 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ nginx:
- ./nginx.conf:/etc/nginx/nginx.conf
- /etc/letsencrypt:/etc/letsencrypt
- /tmp:/tmp
volumes_from:
- webapp
webapp:
image: "selcolumbia/dokomoforms:0.2.8"
image: "selcolumbia/dokomoforms:0.2.9"
command: bash -c "./docker-wait-for-postgres.sh db && head -c 24 /dev/urandom > cookie_secret && python webapp.py"
links:
- "db:db"
volumes:
- ./local_config.py:/dokomo/local_config.py
- /var/www
db:
image: "mdillon/postgis:9.4"
environment:
Expand Down
1 change: 1 addition & 0 deletions dokomoforms/static/src/common/js/service-worker.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// Nothing to see here
// Eventually this should end up in /dist as well...
2 changes: 1 addition & 1 deletion dokomoforms/templates/admin_homepage.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ <h4>Surveys</h4>

{% block extra_scripts %}

<script type="text/javascript" src="/static/dist/admin/js/account-overview.bundle.js"></script>
<script type="text/javascript" src="{{ static_url('dist/admin/js/account-overview.bundle.js') }}"></script>

{% end %}

Expand Down
8 changes: 4 additions & 4 deletions dokomoforms/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
<!-- TODO: consider not loading this from CDN-->
<link href='https://fonts.googleapis.com/css?family=Roboto:100,300,500,700' rel='stylesheet' type='text/css'>

<link href="/static/dist/admin/css/admin.css" rel="stylesheet" type="text/css">
<link href="{{ static_url('dist/admin/css/admin.css') }}" rel="stylesheet" type="text/css">

<link rel="icon" href="/static/dist/admin/img/favicon.png">
<link rel="manifest" href="/static/manifest.json">
<link rel="icon" href="{{ static_url('dist/admin/img/favicon.png') }}">
<link rel="manifest" href="{{ static_url('manifest.json') }}">

<title>{{ options.organization }} Surveys -- Powered by DokomoData</title>
</head>
Expand Down Expand Up @@ -98,7 +98,7 @@
<!-- <script src="http://cdn.datatables.net/plug-ins/1.10.6/integration/bootstrap/3/dataTables.bootstrap.js"></script> -->

<!-- VENDOR bundled -->
<script type="text/javascript" src="/static/dist/admin/js/vendor.js"></script>
<script type="text/javascript" src="{{ static_url('dist/admin/js/vendor.js') }}"></script>

<!-- Persona for login stuff -->
<script src="https://login.persona.org/include.js"></script>
Expand Down
52 changes: 51 additions & 1 deletion dokomoforms/templates/enumerate_homepage.html
Original file line number Diff line number Diff line change
@@ -1 +1,51 @@
Hi you are an enumerator.
{% from dokomoforms.options import options %}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{{ options.organization }} Surveys -- Powered by DokomoData</title>

<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1, maximum-scale=1">

<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">

<meta name="mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-status-bar-style" content="black">

<link href='https://fonts.googleapis.com/css?family=Roboto:400,300,500,700,100' rel='stylesheet' type='text/css'>
<link rel="icon" href="{{ static_url('dist/survey/img/favicon.png') }}">
<link rel="manifest" href="{{ static_url('manifest.json') }}">
<script>
// From https://github.com/GoogleChrome/samples/blob/cbc8098c3ebda4dda0ff894673d3847eae31648f/app-install-banner/basic-banner/index.html
window.addEventListener('load', function() {
if ('serviceWorker' in navigator) {
// I have no idea if this should use static_url...
navigator.serviceWorker.register('/static/src/common/js/service-worker.js')
.then(function(r) {
console.log('registered service worker');
})
.catch(function(error) {
console.error(error);
});
};
});
</script>
</head>

<body>
<div id="wrapper">
Enumerator home page.
</div>
<!-- Bootstrapped Variables -->
<script type="text/javascript">
window.CURRENT_USER_ID = '{{ current_user_id }}';
window.CURRENT_USER_PREFS = {% raw current_user_prefs %};
</script>
<!-- Vendor libs (jquery, react, lodash, etc.) -->
<script src="{{ static_url('dist/survey/js/vendor.js') }}"></script>
<!-- Persona for login stuff -->
<script src="https://login.persona.org/include.js"></script>
</body>

</html>
2 changes: 1 addition & 1 deletion dokomoforms/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h3 class="welcome-title">Dokomo<strong>Data</strong></h3>

{% block extra_scripts %}

<script type="text/javascript" src="/static/dist/admin/js/login-page.bundle.js"></script>
<script type="text/javascript" src="{{ static_url('dist/admin/js/login-page.bundle.js') }}"></script>

{% if message %}
<script>
Expand Down
2 changes: 1 addition & 1 deletion dokomoforms/templates/view_data.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ <h3>Survey Data</h3>

{% block extra_scripts %}

<script type="text/javascript" src="/static/dist/admin/js/view-data.bundle.js"></script>
<script type="text/javascript" src="{{ static_url('dist/admin/js/view-data.bundle.js') }}"></script>

<script type="text/javascript">
// This page gets bootstraped with map data from the server...
Expand Down
13 changes: 7 additions & 6 deletions dokomoforms/templates/view_enumerate.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@
<meta name="mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-status-bar-style" content="black">

<link href="/static/dist/survey/css/survey.css" rel="stylesheet" type="text/css">
<link href="{{ static_url('dist/survey/css/survey.css') }}" rel="stylesheet" type="text/css">

<link href='https://fonts.googleapis.com/css?family=Roboto:400,300,500,700,100' rel='stylesheet' type='text/css'>
<link rel="icon" href="/static/dist/survey/img/favicon.png">
<link rel="manifest" href="/static/manifest.json">
<link rel="icon" href="{{ static_url('dist/survey/img/favicon.png') }}">
<link rel="manifest" href="{{ static_url('manifest.json') }}">
<script>
// From https://github.com/GoogleChrome/samples/blob/cbc8098c3ebda4dda0ff894673d3847eae31648f/app-install-banner/basic-banner/index.html
window.addEventListener('load', function() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/static/src/common/js/service-worker.js', { scope: '/static/src/common/js/' })
// I have no idea if this should use static_url...
navigator.serviceWorker.register('/static/src/common/js/service-worker.js')
.then(function(r) {
console.log('registered service worker');
})
Expand All @@ -48,9 +49,9 @@
{% end %}
</script>
<!-- Vendor libs (jquery, react, lodash, etc.) -->
<script src="/static/dist/survey/js/vendor.js"></script>
<script src="{{ static_url('dist/survey/js/vendor.js') }}"></script>
<!-- App -->
<script src="/static/dist/survey/js/build.bundle.js"></script>
<script src="{{ static_url('dist/survey/js/build.bundle.js') }}"></script>
<!-- pass in the revisit url -->
<script>
window.init({% raw survey %}, '{% raw revisit_url %}');
Expand Down
2 changes: 1 addition & 1 deletion dokomoforms/templates/view_survey.html
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ <h4>Submissions</h4>

{% block extra_scripts %}

<script type="text/javascript" src="/static/dist/admin/js/view-survey.bundle.js"></script>
<script type="text/javascript" src="{{ static_url('dist/admin/js/view-survey.bundle.js') }}"></script>

<script type="text/javascript">

Expand Down
2 changes: 1 addition & 1 deletion dokomoforms/templates/view_user_admin.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ <h4>Users</h4>

{% block extra_scripts %}

<script type="text/javascript" src="/static/dist/admin/js/user-admin.bundle.js"></script>
<script type="text/javascript" src="{{ static_url('dist/admin/js/user-admin.bundle.js') }}"></script>

{% end %}

Expand Down
11 changes: 7 additions & 4 deletions installer.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
# Dokomo Forms installer for version 0.2.8
# Dokomo Forms installer for version 0.2.9
set -e

# Do you have docker installed?
Expand Down Expand Up @@ -88,7 +88,10 @@ printf " Installing SSL certificate. Make sure \n"
printf " you have set up the DNS records for \n"
printf " your domain to point to this machine. \n"
printf "========================================\n"
$SUDO docker run -it --rm -p 443:443 -p 80:80 --name letsencrypt \
# for some reason these directories need to exist beforehand on Fedora...
$SUDO mkdir -p /etc/letsencrypt
$SUDO mkdir -p /var/lib/letsencrypt
$SUDO docker run -it --rm -p 443:443 -p 80:80 \
-v "/etc/letsencrypt:/etc/letsencrypt:Z" \
-v "/var/lib/letsencrypt:/var/lib/letsencrypt:Z" \
-v "/var/log:/var/log:Z" \
Expand All @@ -105,8 +108,8 @@ $SUDO openssl dhparam -out /etc/letsencrypt/live/$LETSENCRYPT_DIR/dhparam.pem 20
printf "========================================\n"
printf " Downloading configuration files \n"
printf "========================================\n"
$CURL -L https://raw.githubusercontent.com/SEL-Columbia/dokomoforms/v0.2.8/docker-compose.yml > docker-compose.yml
$CURL -L https://raw.githubusercontent.com/SEL-Columbia/dokomoforms/v0.2.8/nginx.conf > nginx.conf
$CURL -L https://raw.githubusercontent.com/SEL-Columbia/dokomoforms/v0.2.9/docker-compose.yml > docker-compose.yml
$CURL -L https://raw.githubusercontent.com/SEL-Columbia/dokomoforms/v0.2.9/nginx.conf > nginx.conf

# Edit the configuration files
printf "========================================\n"
Expand Down
26 changes: 26 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ http {
upstream dokomo {
server webapp:8888;
}
include /etc/nginx/mime.types;
server {
listen 80;
listen [::]:80;
Expand Down Expand Up @@ -35,6 +36,31 @@ http {
root /tmp/letsencrypt-auto;
}

location ^~ /static/dist/ {
root /var/www;
if ($query_string) {
expires max;
}
}

location = /favicon.png {
root /var/www/static;
if ($query_string) {
expires max;
}
}

location = /robots.txt {
root /var/www/static;
if ($query_string) {
expires max;
}
}

location = /static/manifest.json {
root /var/www;
}

location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
Expand Down
50 changes: 25 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
"bootstrap": "^3.3.6",
"datatables": "https://github.com/DataTables/DataTables/archive/1.10.9.tar.gz",
"es5-shim": "^4.3.1",
"highcharts-release": "^4.1.8",
"jquery": "^2.1.4",
"leaflet": "^0.7.5",
"highcharts-release": "^4.2.1",
"jquery": "^2.2.0",
"leaflet": "^0.7.7",
"lodash-compat": "^3.10.1",
"lz-string": "^1.4.4",
"moment": "^2.10.6",
"node-uuid": "^1.4.3",
"pouchdb": "^5.1.0",
"moment": "^2.11.1",
"node-uuid": "^1.4.7",
"pouchdb": "^5.2.0",
"pouchdb-upsert": "^2.0.0",
"ratchet": "https://github.com/twbs/ratchet/archive/v2.0.2.tar.gz",
"react": "^0.14.5",
"react": "^0.14.6",
"react-dom": "~0.14.2",
"screenfull": "^3.0.0"
},
Expand All @@ -32,39 +32,39 @@
"babel-preset-es2015": "^6.1.18",
"babel-preset-react": "^6.1.18",
"babelify": "^7.2.0",
"browserify": "^12.0.1",
"browserify-shim": "^3.8.7",
"browserify": "^13.0.0",
"browserify-shim": "^3.8.12",
"del": "^2.0.2",
"eslint-plugin-react": "^3.3.0",
"event-stream": "^3.3.1",
"gulp": "^3.8.11",
"gulp-concat": "^2.5.2",
"gulp-html-replace": "^1.4.5",
"eslint-plugin-react": "^3.15.0",
"event-stream": "^3.3.2",
"gulp": "^3.9.0",
"gulp-concat": "^2.6.0",
"gulp-html-replace": "^1.5.5",
"gulp-if": "^2.0.0",
"gulp-less": "^3.0.3",
"gulp-livereload": "^3.8.0",
"gulp-minify-css": "^1.2.1",
"gulp-less": "^3.0.5",
"gulp-livereload": "^3.8.1",
"gulp-minify-css": "^1.2.3",
"gulp-order": "^1.1.1",
"gulp-react": "^3.0.1",
"gulp-rename": "^1.2.2",
"gulp-replace": "^0.5.4",
"gulp-sourcemaps": "^1.5.2",
"gulp-sourcemaps": "^1.6.0",
"gulp-streamify": "^1.0.2",
"gulp-uglify": "1.4.2",
"istanbul": "^0.4.0",
"jest-cli": "^0.7.1",
"jsdom": "^7.0.2",
"jshint": "^2.7.0",
"gulp-uglify": "1.5.1",
"istanbul": "^0.4.2",
"jest-cli": "^0.8.2",
"jsdom": "^7.2.2",
"jshint": "^2.8.0",
"mocha": "^2.2.4",
"mocha-istanbul": "^0.2.0",
"node-underscorify": "0.0.14",
"react-addons-test-utils": "~0.14.2",
"reactify": "^1.1.1",
"should": "^7.1.1",
"should": "^8.1.1",
"supertest": "^1.1.0",
"vinyl-buffer": "^1.0.0",
"vinyl-source-stream": "^1.1.0",
"watchify": "^3.2.1"
"watchify": "^3.7.0"
},
"browserify": {
"transform": [
Expand Down
22 changes: 21 additions & 1 deletion tests/python/test_demo_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

utils = (setUpModule, tearDownModule)

import dokomoforms.handlers
from dokomoforms.models import Administrator
from dokomoforms.options import options

Expand All @@ -20,7 +21,26 @@ def get_app(self):
self.app = Application(self.session, options=options)
return self.app

def test_logging_in_creates_user(self):
def test_logging_in_creates_user_no_https(self):
dokomoforms.handlers.demo.options.https = False
no_user = (
self.session
.query(count(Administrator.id))
.filter_by(name='demo_user')
.scalar()
)
self.assertEqual(no_user, 0)
self.fetch('/demo/login', _logged_in_user=None)
user = (
self.session
.query(count(Administrator.id))
.filter_by(name='demo_user')
.scalar()
)
self.assertEqual(user, 1)

def test_logging_in_creates_user_https(self):
dokomoforms.handlers.demo.options.https = True
no_user = (
self.session
.query(count(Administrator.id))
Expand Down
Loading

0 comments on commit 35b73b5

Please sign in to comment.