Spotter-VM/doc/applications/taarifa.rst

92 lines
3.8 KiB
ReStructuredText

Taarifa Waterpoints
===================
Overview
--------
Taarifa Waterpoints is a mapping application for waterpoint management system for Tanzania. It has frontend written in JavaScript and backed in python. Uses TaarifaAPI as a framefork and MongoDB as a document storage.
Upstream URL: https://github.com/taarifa/TaarifaWaterpoints
API URL: https://github.com/taarifa/TaarifaAPI
Fork URL: https://github.com/trendspotter/TaarifaWaterpoints - the fork contains fixes for python3 compatibility and ready-to-use release package with frontent build using the method below.
MongoDB
-------
Application uses MongoDB NoSQL database as a data storage, currently running as unsecured instance without any admin user.
Data need to be prepopulated before the application can be used for the first time. Prepopulation is done as part of installation script as follows
.. code-block:: bash
cd /srv/taarifa
export MONGO_URI=mongodb://taarifa-mongodb/taarifa
python manage.py create_facility
python manage.py create_service
python manage.py upload_waterpoints demodata.csv
Frontend build
--------------
Frontend requires Node.js 8, ancient verions of packages, and a bunch of patches to work correctly. Following sequence produces usable dist directory on Debian 10.
.. code-block:: bash
# Install build packages
apt-get update
apt-get -y install build-essential git libpng-dev xz-utils wget
# Install Node.js 8
mkdir /usr/local/lib/nodejs ~/.npm-global
wget https://nodejs.org/dist/latest-v8.x/node-v8.17.0-linux-x64.tar.xz -O - | tar -xJf - -C /usr/local/lib/nodejs
export PATH=~/.npm-global/bin:/usr/local/lib/nodejs/node-v8.17.0-linux-x64/bin:${PATH}
npm config set prefix '~/.npm-global'
# Clone Taarifa Waterpoints
git clone https://github.com/trendspotter/TaarifaWaterpoints.git /tmp/taarifa
cd /tmp/taarifa
git cherry-pick -n 0650b76314133bee8f2a7421ecacfb1c1c572aa8 # Install leaflet-maskcanvas which still supports L.TileLayer.MaskCanvas
git cherry-pick -n 8576a9d038baf9fd959a948501d1ccf6b3acfaad # Fail gracefully when geolocation fails
git cherry-pick -n 219814faaa9bfd1ec4edb0afc2580ce8d1bc5dfd # Add Czech translation
# Install NPM packages
export HOME=/root
npm install
./node_modules/.bin/grunt build --verbose
Should some problems occur using this approach, there is a possibility to revert to the once-working codebase from ~2015 and build frontend using Node.js 4.
.. code-block:: bash
# Install build packages
apt-get update
apt-get -y install build-essential git libpng-dev xz-utils wget
# Install Node.js 4
wget https://nodejs.org/dist/latest-v4.x/node-v4.9.1-linux-x64.tar.xz
mkdir -p /usr/local/lib/nodejs
tar -xJvf node-v4.9.1-linux-x64.tar.xz -C /usr/local/lib/nodejs
export PATH=/usr/local/lib/nodejs/node-v4.9.1-linux-x64/bin:${PATH}
# Clone Taarifa Waterpoints
git clone https://github.com/trendspotter/TaarifaWaterpoints.git /tmp/taarifa
cd /tmp/taarifa
git checkout 7d0c784eb01b811e65c829796c88d9367f8fa5f7
git cherry-pick -n 984a6353f8b50e9f7f643d22e5c77ad0eb352bcb # Load tiles via https
git cherry-pick -n 0650b76314133bee8f2a7421ecacfb1c1c572aa8 # Install leaflet-maskcanvas which still supports L.TileLayer.MaskCanvas
git cherry-pick -n 8576a9d038baf9fd959a948501d1ccf6b3acfaad # Fail gracefully when geolocation fails
git cherry-pick -n 219814faaa9bfd1ec4edb0afc2580ce8d1bc5dfd # Add Czech translation
# Install NPM packages
export HOME=/root
npm install
npm install -g grunt-cli bower
bower install --allow-root
# Hackfix grunt task and build dist
sed -i "s/'bower',//" Gruntfile.js
grunt build