Git Product home page Git Product logo

drags's Introduction

This is how you do things with DRAGS

Sorry, a bit in the works and looking to open source a couple of modules, at the moment.

Surveys:

A survey is just a module that exposes a single export:

function(request, response) { ... }

This is just like an http server request handler.

Note, though, that the received response will be http-enhanced, and has a few additional fields already added to it.

Basic nginx configuration, if you must have nginx

server {
    listen 80;
    server_name drags.henrian.com;
    gzip on;

    proxy_set_header X-Real-IP $remote_addr;
    proxy_pass http://127.0.0.1:1301;
}

Supervisor.d

[program:drags]
directory=/www/drags
command=node drags.js --default /basic/ --admin superuser --password OKCAfdt0SQr7
autorestart=true
user=chbrown

Outtakes

select total_time, responses.value, name, stimuli.value from responses inner join stimuli on stimuli.id = stimulus_id;

<script>
  function submit() {
    var response = $('#form').objectifyForm();
    console.log(response);
    window.data = response;
    next('admin_login');
  }
  $('#form').bind('keypress', function(e) {
    if (e.keyCode==13){
      submit();
    }
  });
  $('#submit').one('click', submit);
</script>


var zz_design = {};
['ptct-a', 'ptct-b', 'ptct-c'].forEach(function(survey_name) {
  var design_csv_path = path.join(__dirname, 'surveys', survey_name, 'design.csv');
  fs.exists(design_csv_path, function(exists) {
    if (exists) {
      csv().from.path(design_csv_path, {columns: true}).on('data', function(row, index) {
        // some row might be 'a10','Question 8','wi-c1','c-wi0','c-wo135','wo-c270','wi-c225','d'
        zz_design[row.id] = row;
      });
    }
  });
});


logger.info('Loading survey "%s" from path "%s"', name, survey_path);
var survey = require(survey_path);
R.any(new RegExp('^/' + name + '(/.*)?$'), function(req, res, m) {
  survey(req, res, m[1] || '/');
});

var module = path.join(argv.surveys_path, survey_name);
var survey_path = package_json.surveys[name].replace(/^~/, process.env.HOME);

"ptct-audio": "~/work/ptct/audio",
"ptct-image": "~/work/ptct/image",
"ptso-video": "~/work/ptso/video"

Development comments

To handle serving static files from various sub-packages, we don't reverse-proxy through nginx and set up nginx to handle certain subpaths. Instead, I'm using visionmedia's send package. If that doesn't pan out, we could try node-static.

Database setup

If you run drags as the user chbrown, for example, you would want to create a PostgreSQL role like:

CREATE ROLE chbrown LOGIN;

And create the database like this:

CREATE DATABASE drags OWNER chbrown ENCODING 'UTF8';

License

Copyright © 2013 Christopher Brown. MIT Licensed.

drags's People

Contributors

chbrown avatar

Stargazers

 avatar

Watchers

James Cloos avatar Frank Hereford 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.