node package manager
Easy collaboration. Discover, share, and reuse code in your team. Create a free org »

elections

elections

A nodejs app for tracking candidates' campaign offers and for serving as an information repository for voters.

Description

This module installs a site that allows users to input candidate's offers which other users can validate as trustworthy information. Users can then vote if they like the offer or not, and after voting the system would show who offered it and more information about the offer itself. This would then serve as an information repository for voters. In addition, after the elections, the voters will be able to track the progress of the offers made by the winning candidate.

Installation

npm install elections

Features

  • Track the campaign offers of candidates for certain election
  • Can track more than one election in the same site
  • The app can suggest the user a candidate based on his votes so they can research more about him
  • Easy to install and customize

Quick Start

On your app file, include the module, configure it, and use it with your Express app:

var express = require('express'),
    app = exports = module.exports = express(),
    elections = require('elections');
 
app.configure(function(){
  // Set these if you want to override the default views (which you probably should) 
  app.set('views', path.join(__dirname, 'views'));
  app.use(express.static(path.join(__dirname, 'public')));
});
 
// Configure the module and use it 
elections(app, {
  site: {
    urlPrefix: '/elections',
    name: 'My Site Name',
    author: 'Your Name',
    lang: 'en',
    description: 'Your site description',
    copyright: '© ' + new Date().getFullYear(),
    // If you are overriding the default views, you probably want to group them in a folder under your views directory 
    overrideViews: true,
    viewsPrefix: 'elections/'
  },
  
  i18n: {
    // If you are using i18n already, you don't need this, but we can configure it for you 
    langs: ['en','es','fr'],
  },
 
  // nodemailer configuration so we can email your users 
  nodemailer: {
    // transport configuration 
    transport: {
      method: 'SMTP',
      service: 'Gmail',
      auth: {
        user: 'you@gmail.com',
        pass: 'yourpassword'
      }
    },
 
    // configuration for mails 
    mail: {
      from: '"Staff at Elections Site" <noreply@local.host>'
    }
  }
});
 
app.listen(9999)

Overriding views

If you want to override the default views (probably you want to integrate elections into a current site, or just give it a unique style), you can do so by setting the configuration option site.overrideViews to true and, optionally, set also set site.viewsPrefix to something of your preference (eg: elections/). Don't forget the trailing slash.

Then, you can take the default views as a reference. These are located in the module's views directory. Copy those over to your app's views directory, inside a folder called as the viewsPrefix parameter (in our example, yourViewsDir/elections/). You can then modify those templates as you wish, and the app will use them.

Credits

License

(The MIT License)

Copyright (c) 2012 Diego Luces me@dluces.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.