npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

derbygap

v2.0.2

Published

A tool to help setup a phonegap project with DerbyJS.

Downloads

14

Readme

derbygap

A simple tool to create a PhoneGap app with Derby.

Installation

$ npm install derbygap --save

Client Usage

Creating a derbygap app is similar to creating a standard derby app.

In addition to creating the app's script bundle, you must also create the app's html by calling derbygap.writeHtml.

The following example assumes the following:

  1. You've initialized a phonegap project named phonegap.

  2. Your app has the route /phonegap.

    var derbyApp = require('…'); var expressApp = require('…'); var store = require('…'); var derby = require('derby'); var derbygap = require('derbygap'); var path = require('path');

    derby.run(function () { var dir = path.join(__dirname, 'phonegap/www'); var sourceUrl = 'http://localhost:3000/phonegap'; var opts = {serverUrl: 'http://foo.bar.com'}; expressApp.listen(3000);

    // will write your app bundle to "phonegap/www/derby/….js" derbygap.writeScripts(derbyApp, store, dir, opts, function () { // will write your app html to "phonegap/www/index.html" derbygap.writeHtml(dir, sourceUrl); }); });

Derbygap generates your app html by making a request to the running app.

Ensure that the route handling the url derbygap requests does NOT have redirects and does NOT render differently based on session information. Any redirect logic on the route should be run client side only.

Make sure to include cordova.js:

<Head:>
  {{if $phonegap.enabled}}
  <script src="cordova.js"></script>
  {{/}}
  <base href="{{$phonegap.baseUrl}}">
  <script src="some/other/file.js"></script>  

Server Usage

You may optionally include the derbygap middleware in your express app to add $phonegap data to your model.

var derbygap = require('derbygap');

expressApp
  ...
  .use(store.modelMiddleware())
  .use(derbygap.middleware())
  ...

Middleware

Adds the following model data:

$phonegap.baseUrl - Blank if phonegap is enabled and "/" otherwise.

$phonegap.enabled - True if phonegap is enabled.

Options:

enabled - Manually enable/disable the middleware.

env - Environment variable that will enable the middleware. Defaults to PHONEGAP.

reqHeader - Request header that will enable the middleware. Defaults to X-PHONEGAP.

Notes

  • Make sure the url you generate the html from does not contain server side specific logic, redirects, or change html/data based upon session information.

  • Linked files should use relative rather than absolute urls. You can use $phonegap.baseUrl in your views as a url prefix for linking to files.