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

phnq_widgets

v1.0.47

Published

Embedded JavaScript templating tool

Downloads

132

Readme

phnq_widgets

Phnq_widgets is a framework for buliding Rich JavaScript Applications by organizing UI code along functional instead of technological lines. Instead of, for example, putting all the JS files into one folder, CSS files into another folder, and the HTML files into yet another folder, phnq_widgets enncourages the grouping together of code that is functionally related, regardless of file type, into widgets. I call this "functional code organization".

A widget is a self-contained chunk of application functionality that may include any or all of HTML markup, CSS, JavaScript or static resources such as images, all in a single folder.

Carving a UI into widgets has many benefits:

  • intuitive modularization of UI functionality
  • prevents (or at least discourages) monolithic JS and CSS files
  • facilitates the reuse of UI functionality
  • etc.

Features

In addition to providing the substrate for functional code organization, phnq_widgets also provides several advanced web framework features:

  • implicit and explicit dependency management
  • lazy loading and deployment of client-side functionality
  • compilation of templates into JS object code, executable on server or client
  • automatic static file aggregation/minification/compression
  • pluggable interface for auto-publishing to CDNs

The details of these features will be discussed below.

Everything's a Widget

One of the benefits of functional code organization is that it is very amenable to modularization. Remember that a widget is self-contained and can contain everything that it needs (HTML, CSS, JS, images, etc.). Perhaps most important is that widgets particiapte in dependency management. Examples of things that can be widgets:

  • chunk of rich application functionality (i.e. toolbar, fancy select box, etc.)
  • 3rd party library (i.e. Twitter Bootstrap, jQuery UI, Isotope, etc.)
  • JS API for accessing some remote web service

Getting Started

Requirements: node.js, npm

First create an application folder and change into it.

mkdir my-app
cd my-app

Install phnq_widgets into your application.

npm install phnq_widgets

Generate your first widget called com.example.HelloWorld.

node_modules/.bin/phnq_widgets -g com.example.HelloWorld

Start up a minimal server.

node_modules/.bin/phnq_widgets -s

Now point your browser to:

http://localhost:7777/widgets/com.example.HelloWorld

You should see an extremely basic page.

Add some style. Edit the generated file widgets/com/example/HelloWorld/HelloWorld.css and make it look like this:

.__CLASS__ h1
{
	padding: 10px;
	border: 1px solid #999;
	background: #ccc;
	color: #fff;
	font-family: sans-serif;
}

Refresh your browser and and you should see the effect of the above CSS stylings.

Add some behaviour. Edit the generated file widgets/com/example/HelloWorld/HelloWorld.js and make it look like this:

var widget =
{
	ready: function($$)
	{
		$$("h1").click(function()
		{
			alert("Hi!");
		});
	}
};

Refresh your browser. Click on the text HelloWorld and you should trigger the alert box to open.

Putting the phnq_widgets utility in your PATH

In the Getting Started section we used the phnq_widgets utility a few times, but the relative path to the utility is a bit cumbersome to type, so putting it in your PATH helps:

export PATH=$PATH:./node_modules/.bin

Put that in your shell startup script, relaunch your shell and then phnq_widgets will be in your PATH whenever you're in a directory that has the phnq_widgets module installed.

Now, starting your minimal server is a bit more concise:

phnq_widgets -s

More documentation soon...