Giter Site home page Giter Site logo

kevinmwangi / enketo-express Goto Github PK

View Code? Open in Web Editor NEW

This project forked from enketo/enketo-express

0.0 2.0 0.0 4.41 MB

A modern, super-lightweight node.js version of Enketo for KoBoToolbox

License: Apache License 2.0

JavaScript 77.20% CSS 19.10% HTML 2.93% Shell 0.77%

enketo-express's Introduction

Enketo Express Build Status Dependency Status

Enketo Logo

A light-weight node.js version of Enketo Smart Paper. Chock-full of badass rockstar tech.

How to install a test/development server

Manually:

  1. Install JS prerequisites: Node.js 0.10.x (newer version not supported yet), Grunt Client, and Node-Gyp
  2. Install Redis
  3. Install build-essential and git (and libfontconfig to run tests) with (sudo) apt-get install build-essential git libfontconfig
  4. Clone this repository
  5. Install dependencies with npm install from the project root
  6. Create config/config.json to override values in the default config. Start with cp config/default-config.json config/config.json
  7. Build with grunt from the project root

Using vagrant:

This takes several shortcuts. Do not use for production!

  1. Install Vagrant and VirtualBox
  2. Run vagrant up from project folder and wait until it completes *
  3. Log in to the VM with vagrant ssh and run cd /vagrant && npm start

The app should now be running on localhost:8006. You can test the API in a different console window with: curl --user enketorules: -d "server_url=https://ona.io/enketo&form_id=widgets" http://localhost:8006/api/v2/survey.

* sometimes vagrant up fails for reasons beyond our control - e.g. if external resources are temporarily unavailable. Try running vagrant reload --provision to resolve this.

How to install a production server

See this tutorial for detailed instructions.

How to configure

All configuration is done in config/config.json. Strictly speaking, this file only has to contain the default properties that you'd like to override, but it might be safer to include all properties. The configuration items have self-explanatory names and helpful sample values. After editing the configuration, the app will need to be restarted.

The default production configuration includes 2 redis instances for the cache. You can greatly simplify installation by using 1 redis instance instead (for non-production usage). To do this set the redis.cache.port to 6379 (same as redis.main.port). To set up 2 instances properly for production, you'll find the vagrant setup steps in bootstrap.sh useful.

For detailed guidance on each configuration item, see this document.

To configure your own custom external authentication also see this section.

API

The API is accessible on /api/v2 and /api/v1. Only API v1 is properly documented at the moment. This temporary note describes the changes introduced by API v2.

How to run

Run with npm start from project root.

You can now check that the app is running by going to e.g. http://localhost:8005 (depending on your server and port set in config/config.json or the port forwarding set up in Vagrant (default is 8006))

For a production server, we recommend using pm2 or forever to manage the node app.

How to update

  • update git repository with git pull
  • update dependencies with npm update
  • re-build with grunt
  • restart app

Developer tools

Install nodemon to automatically restart the server when a file changes. Install gulp to automatically update the translation keys. Install mocha to run tests. Install nodemon to run app in development mode with autoreload.

The easiest way to start the app in development and debugging mode with livereload is with grunt develop.

Differences with enketo/enketo-legacy (and enketo.org)

  • ✅ this one is much easier to install
  • ✅ this one has cross-browser (media) file inputs
  • ✅ this one has a multi-language user interface
  • ✅ this one displays right-to-left scripts from right-to-left
  • ✅ this one has more text formatting (markdown syntax) support and across all labels and hints
  • ✅ this one has better security of user credentials
  • ✅ this one has support for multiple themes in all form views including previews
  • ✅ this one has an improved API (v2)
  • ✅ this one allows overriding a form-defined theme via the API (v2)
  • ✅ this one has the ability to override default form values on launch through the API (v2)
  • ✅ this one has a more advanced iframeable webform view that can communicate back to the parent window, enabled through the API (v2)
  • ✅ this one has external authentication support
  • ✅ this one will use the instanceName value defined in the XForm as the default local record name
  • ✅ this one will automatically save any unsaved record in the offline-capable views to avoid loosing data
  • 🔶 offline forms are still experimental - enable offline functionality only for testing and report bugs please
  • ❌ missing API endpoints and corresponding views: all endpoints containing "/single" (single submission views)
  • ❌ no export of queued records (yet)
  • ❌ no Formtester app (planning to integrate this functionality in the form previews)
  • ❌ no Forms app (you do not need this)
  • ✅ this one is 100% JavaScript
  • ✅ this one can be hosted on a local webserver
  • ✅ this one includes an analog scale widget

Themes

The default theme can be set in config/config.json. The default theme can be overridden in the form definition.

The recommended way to customize themes is to either:

  • Create an issue (and fund or send a pull request) for changes to the existing themes, or
  • Create your own theme in your own enketo-express port and add your custom theme in its own folder here. No other changes are required. A succesful rebuild with grunt, and your theme will become active when the app starts. The advantage of using this method instead of editing the existing themes, is that you will not have any merge conflicts when you update your port! Add a print-specific version of your theme and use the same filenaming convention as the built-in themes.

See also this further guidance

Authentication

This app can manage OpenRosa form authentication for protected forms, i.e. it is possible to log in to forms with credentials set in your OpenRosa Server (e.g. Aggregate/KoBo/Ona), just like in ODK Collect.

To make use of OpenRosa form authentication, set the following in config/config.json:

  • linked form and data server -> authentication -> managed by enketo -> true

Alternatively, you could make use of external authentication, i.e. the authentication management of your form and data server. Whenever a request (form, formlist, submission) requires authentication, enketo-express re-directs the user to a login page on the form and data server and simply passes any cookies back to that server whenever it makes any subsequent request. It is up to the form and data server to authenticate based on the cookie content. This mechanism requires any enketo-express webform to have access to these browser cookies so the form/data server and Enketo Express would have to be on the same domain (a different subdomain is possible when setting cross-domain cookies). It also requires the login page to have a mechanism for redirecting the authenticated user back, via a query string parameter.

To make use of external authentication set the following in config/config.json:

  • linked form and data server -> authentication -> managed by enketo -> false
  • linked form and data server -> authentication -> external login url that sets cookie -> e.g. http://example.com/login?return={RETURNURL}, where {RETURNURL} will be set by enketo.

Security

There are two major security considerations to be aware of. Both of these result in the need to run this application on https with a valid SSL certificate.

API security is mainly arranged by the secret API key set up in config/config.json. This API key is sent in cleartext to Enketo by the form/data server (such as ODK Aggregate) and can easily be intercepted and read if the transport is not secure. Somebody could start using your Enketo Express installation for their own form/data server, or obtain the URLs of your forms. Using secure (https) transport mitigates against this hazard. Security increases as well by populating the server url in config/config.json. Also, don't forget to change your API key when you start running Enketo Express in production.

Form authentication is only secure when Enketo is running on https. To avoid leaking form server credentials, authentication is automatically disabled when the app is accessed in a 'production' environment on 'http'. If you have to to run the app on http in a production environment, you can bypass this security by setting "allow insecure transport": true in config/config.json. The only use case this would be acceptable in is when running the app on a local protected network (e.g. in the KoBo VM).

Translation

The user interface was translated by: Robert Michael Lundin (Norwegian), Margaret Ndisha, Charles Mutisya (Swahili), Panzero Mauro (Italian), Gabriel Kreindler (Romanian), Jason Reeder, Omar Nazar, Sara Sameer, David Gessel (Arabic), Tino Kreutzer (German), Wasilis Mandratzis-Walz (German, Greek), Luis Molina (Spanish), Martijn van de Rijdt (Dutch).

Send a message if you'd like to contribute! We use an easy web interface provided by Transifex.

Funding

The development of this application was funded by KoBo Toolbox (Harvard Humanitarian Initiative), iMMAP, OpenClinica, and Enketo LLC. The Enketo-core library (the form engine + themes) used in this application obtained significant funding from SEL (Columbia University), the Santa Fe Institute, and the HRP project.

License

See the license document for this application's license.

Note that some of the libraries used in this app have different license. In particular note this one.

The Enketo logo and Icons are trademarked by Enketo LLC. They can be used in the KoBoCAT VM only. If you are using this app to build your own web application, you are encouraged to maintain the 'powered by Enketo' form footer with the Enketo logo, but replace other images in /public/images with your own or contact Enketo LLC to discuss the use inside your app.

Change log

See change log

enketo-express's People

Contributors

martijnr avatar edrex avatar kevinmwangi avatar tinok avatar ukanga avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.