hashdo

0.10.77 • Public • Published

#Do

#Do is framework for creating static or stateful interaction based cards that can be embedded in mobile applications or viewed in a browser. This is the base library that can be used in your own projects to generate, embed or serve #Do cards.

If you are looking for a way to create cards, get your hands on the #Do CLI which contains templates to quickly generate packs and cards as well as a test harness to easily test your card functionality.

Card examples can be found here: https://github.com/UXFoundry/hashdo-cards

Getting Started

Step 1

Install #Do into your project using NPM.

npm install hashdo --save

Step 2

Require it in your code.

var hashdo = require('hashdo');

Step 3

Generate the HTML, CSS and script necessary to render your card.

hashdo.card.generateCard({
  url: 'http://hashdo.com/restaurants/nearby',
  directory: '/Where/Your/Cards/Are/Located',
  packName: 'restaurants',
  cardName: 'nearby',
  inputValues: {
    latitude: -29.837795,
    longitude: 30.922539
  }
},
// Callback containing an error or the HTML you can render.
function (err, html) {
  if (!err) {
    // Do something with the HTML.
    console.log(html);
  }
  else {
    console.error(err);    
  }
});

Check out our open source #Do cards to test things out with or use the #Do CLI to create your own.

API

Packs

The packs module is accessible through hashdo.packs. This modules contains information about the packs and cards available.

Cards

The card module is accessible through hashdo.card. This module is used to secure inputs, generated card HTML and also perform the logic necessary for a web hook call.

Environment Variables

CARD_SECRET

Provide a value for this if you want to properly secure the URL and query parameters of a card.

LOCK_KEY

Provide a value for this if you want to properly secure input data in the database when using 'secureInputs'.

BASE_URL

Required if making use of client state. This will be the URL that cards will make HTTP calls to.

FIREBASE_URL

Use Firebase to update card state on the client when it changes. Without this the card will need to be refreshed manually to update it's client data.

Plugins

Modules can be replaced by your own implementations if necessary. Good examples of this are the data store or the analytics provider you wish to use.

The following plugins are available. If you have created your own plugins, let us know and we'll add links here.

Database

By default #Do uses an in-memory database. Card states and locks are lost when the application unloads but this is actually great for development and testing purposes.

MongoDB Plugin - Use this database plugin to persist your data to a MongoDB database.

Analytics

By default #Do has no analytics implementation. When an event is triggered it will output the details to the console.

Keen IO Analytics Plugin - Use this analytics plugin to send events to Keen IO.

To use a plugin, simply replace the exposed property with a new implementation. Each plugin's documentation will describe the requirements and the process of replacing the functionality.

View Engine Support

Currently #Do supports the following view engines.

Any view engine that Consolidate supports can be added as well if necessary. Using a view engine is not a requirement, you are welcome to use regular HTML.

CSS Preprocessor Support

Currently #Do supports the following CSS preprocessors.

Using a preprocessor is not a requirement, you are welcome to use regular CSS.

License

Copyright 2015 (c). All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Readme

Keywords

Package Sidebar

Install

npm i hashdo

Weekly Downloads

17

Version

0.10.77

License

Apache-2.0

Unpacked Size

193 kB

Total Files

38

Last publish

Collaborators

  • brutaldev
  • hashdo
  • shauntrennery