An SDK for authoring Popcorn projects.
We're writing Butter so that it runs in modern, HTML5 compatible browsers. For version 1.0, we're targeting modern HTML5 desktop browsers. In the current version we are supporting:
- Chrome stable
- Firefox stable
- Internet Explorer 9+
- Safari stable
- node v0.8 or higher
- npm (comes with node v0.8 installer)
- A working build environment:
- Mac OS X - Xcode or Command Line Tools package
- Windows - Python 2.5+ and Visual Studio 2010; specifically:
- uninstall any and all "Microsoft Visual C++ 2010 x86/64 Redistributable" copies
- install Microsoft Visual C++ 2010 (Express edition is fine)
- install Microsoft Visual Studio 2010 SP1
- install Microsoft Windows SDK v7.1
- install Microsoft Visual C++ 2010 SP1 Compiler Update for Windows SDK v7.1
 
- Linux - build-essential package on Debian/Ubuntu, or the equivalent for your distro
 
- git clone --recursive https://github.com/mozilla/butter.git
- cd butter
- npm install
- Run node make server.
- Navigate to http://localhost:8888/ in your favourite browser.
If you want to change the bind IP or port check the Configuration section below.
Running node make deploy will compile all the necessary files into the dist/ folder.
Run NODE_ENV=production node app.js in the dist/cornfield directory in order to run the server in production mode.
Cornfield is PopcornMaker's back-end server system, designed to serve content to users, store their ongoing work, and publish what they've done.
There are two types of storage Cornfield needs to run:
- 
A database: To store user project data, a database is required. Cornfield uses the Sequelizemiddleware, so multiple database options are available. You are responsible for setting up and maintaining a PostgreSQL or MySQL database enrivonment if you choose to use either, so make sure a user has access to a database calledpopcornfor cornfield to run correctly.
- 
A data-blob store: To store published projects, Cornfield can use the filesystem, or Amazon's S3. See the configuration options below for setting up this feature for your environment. 
There are several configuration files in cornfield/config/ that control how cornfield works. They are applied in order from most general to most specific to present one configuration to the server:
- default.json
- hostname.json
- environment.json
- hostname-environment.json
- runtime.json
hostname and environment are variable:
- hostname - The hostname of the machine. Defaults to the output of hostnameon the cli.
- environment - The value of the NODE_ENVenvironment variable. Defaults todevelopment.
To change the cornfield configuration for your deployment of Butter, it's best to create a new file called hostname-environment.json that overrides the cornfield defaults.
- 
serversettings for the cornfield server- bindIPthe IP or hostname to use for the server (e.g., localhost).
- bindPortthe Port number to use for the server (e.g., 8888). If using a port number lower than 1024, the server will have to be run as root.
 
- 
sentrysettings for sentry error reporting- dsnthe DSN to send events to. Look at your sentry client configuration page for this value.
- optionspass any additional options to raven
 
- 
loggersettings for server logging- formatthe logging format to use. Possible values include: default, short, tiny, dev.
 
- 
sessionsettings for user sessions- secretthe sessions secret (i.e., some long string)
- durationthe session's duration (e.g., 2419200000)
 
- 
staticMiddlewaresettings for cornfield Connect middleware- maxAgethe max age of static assests
 
- 
dirssettings for various directories, paths, hostnames- wwwRootthe server's WWW root directory (e.g.,- ../)
- templatesthe location of templates (e.g.,- ../templates)
- appHostnamethe hostname URL for the application, usually the same as- server.bindIPand- server.bindPort(e.g.,- http://localhost:8888)
- embedHostname[optional] the hostname URL where published embed documents are stored, if different from- dirs.appHostname(e.g.,- http://s3.amazonaws.com/your-bucket)
 
- 
templateslist of templates to serve. The format is as follows:<template-name>:{{templateBase}}<path/to/template/config.json>. The{{templateBase}}string will be replaced by the value indirs.templates(e.g., "basic": "{{templateBase}}basic/config.json")
- 
exportedAssetslist of scripts to include in exported assets. These are things like popcorn.js or other scripts that your exported projects depend upon in order to run.
- 
additionalStaticRootslist of additional roots to use.
- 
databasedatabase configuration options- databasethe database name. Used by mysql and postgresql
- usernamethe username to use when connecting to the database. Used by mysql and postgresql
- passwordthe password for the username. Used by mysql and postgresql
- optionsadditional sequelize options. Please see the sequelize manual for the complete listing.- dialectthe sql dialect of the database. Default is- mysql, must be one of- mysql,- sqlite, or- postgresql
- storagethe storage engine for sqlite. Default is- :memory:, an in-memory db, must be a string representing a file path or- :memory:
- loggingfunction to print sql queries to console. Default is- console.log, must be a function or- false
- hosthostname of the mysql or postgresql server. Default is- localhost
- portport of the mysql or postgresql server. Default is- 3306
- poolconnection pooling options for mysql and postgresql. Default is none- maxConnections- maximum number of connections open in the pool
- maxIdleTime- maximum time in seconds to leave an idle connection open in the pool
 
 
 
- 
publishStoreafileStoreused to publish project HTML files (seefileStorebelow for details)
- 
feedbackStoreafileStoreused to publish feedback from the user as JSON (seefileStorebelow for details)
- 
crashStoreafileStoreused to publish crash reports from the user as JSON (seefileStorebelow for details)
- 
imageStoreafileStoreused to retain converted data-uri images for published projects (see theImageStoresection below for details)
The fileStore type is used to setup a backend for storing data:
- typethe type of file store to use. Possible values include- local(i.e., local file system) and- s3(i.e., Amazon S3)
- optionsoptions for the file store, which depends on the type chosen.- hostnamethe hostname to use for constructing urls if different than- embedHostname
- local options
- rootthe root directory under which all exported files are placed (e.g.,- ./view)
- namePrefix[optional] the path prefix to add to any filenames passed to the local file store. For example, if using "v" all filenames will become "v/"
- nameSuffix[optional] the filename suffix to use for all filenames (e.g., ".html")
 
- s3 options
- keythe AWS S3 key to use for authentication
- secretthe AWS S3 secret to use for authentication
- bucketthe AWS S3 bucket name to use for storing key/value pairs
- namePrefix[optional] the prefix to add to any key names passed to the s3 file store. For example, if using "v" all keys will become "v/"
- nameSuffix[optional] the suffix to add to any key names passed to the s3 file store. For example, if using ".json" all keys will end in ".json"
- contentType[optional] the mime type to use for data written to S3. If none given- text/plainis used.
- headers[optional] any additional headers to use for data written to S3. For example, setting cache control headers with- { 'Cache-Control': 'max-age=1800' }.
 
As part of the configuration, an imageStore should be specified to store converted data-uri images for published projects. When a project is saved, the project data is scanned for data-uris which are converted into binary blobs and stored on the server in the imageStore. Currently, there are no special checks or functionality for image store content-types. However, the only images which will be converted are jpegs and pngs. Everything else is ignored. See below for an example imageStore configuration.
alice-production.json:
This sample config uses a mix of the local file system as well as Amazon S3 for storage.
{
  "server" : {
    "bindIP" : "0.0.0.0",
    "bindPort" : "80"
  },
  "logger" : {
    "format" : "default"
  },
  "session" : {
    "secret": "1721f7a15316469fa4a9-5117d0d20e9f"
  },
  "staticMiddleware": {
    "maxAge": "3600000"
  },
  "dirs": {
    "appHostname": "http://example.org",
    "embedHostname": "http://s3.amazonaws.com/my-bucket"
  },
  "publishStore": {
    "type": "s3",
    "options": {
      "namePrefix": "v",
      "bucket": "my-bucket",
      "key": "my-s3-key",
      "secret": "my-s3-secret",
      "contentType": "text/html"
    }
  },
  "feedbackStore": {
    "type": "local",
    "options": {
      "root": "./view",
      "namePrefix": "feedback",
      "nameSuffix": ".json"
    }
  },
  "crashStore": {
    "type": "local",
    "options": {
      "root": "./view",
      "namePrefix": "crash",
      "nameSuffix": ".json"
    }
  },
  "imageStore": {
    "type": "local",
    "options": {
      "root": "./view",
      "namePrefix": "images",
      "nameSuffix": ".png",
    }
  }
}- Chat with the Popcorn community on irc.mozilla.org in the #popcorn channel. The developers hang out here on a daily basis.
- We also have a mailing list that you can subscribe to.
- File bugs and feature requests on our issue tracker.
- The latest code can be found on our Github repository.
- If you'd like to contribute code, file a ticket on our issue tracker, and link to it from your Github pull request.