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

reporter-js

v0.0.2

Published

Make reports with markdown and Google Spreadsheets

Downloads

3

Readme

#Reporter.JS ##Node.JS + Markdown + Google Spreadsheet + Bootstrap

Making report web pages is a drag. I needed a way to quickly make a series of dynamic, data driven web pages that were all slightly different for Higher Ed Careers Canada and I didn't want to be stuck being the only one that could edit them.

This is a problem that has haunted me for years. Report pages are one of those weird tasks that falls between the abilities of web devs and other office-y types. Web devs end up making them and then you have the endless updates. Oh god, the updates. Wouldn't it be great if there was better a way?

Well, let's use some of the most conceptually accessible concepts around:

  • Markdown The purposefully limited styling language. So easy, but powerful. Dump in some HTML markup and you've got the full power of the web.
  • Google Spreadsheet It might not be the best format in the world to supply data to a webpage but everyone gets it conceptually- 'cells' in 2D addressing and ranges of cells from the upper left to the lower right. And because Google Drive is easily accessible from a JSON API we don't have to jump through too many hoops.
  • Bootstrap what front end dev hasn't used it? You can supply your own stylesheet (or no style sheet at all, if that is how you roll) and nothing will break - but throw in a theme from, say, Bootswatch and, hey presto, you've got a nice responsive report.
  • Node.JS makes it all possible, leveraging the Express framework, we have a fully working system for generating reports in a few hundred lines.

Take a look at the example.

##Super simple syntax

The markup for Reporter.JS is contained between =. Nothing successfully parsed will be visible in the final webpage.

###Associate a spreadsheet

Associating a spreadsheet is simple. The example uses the sheet published at:

https://docs.google.com/spreadsheets/d/19xwVCTzHJCM1cmjHbyJY25JtdaEU7_stkAdp_rm-D1w/pubhtml

The bit between /d/ and /pubhtml is the document key. The spreadsheet must be 'Published to the Web', to do this goto File then to Published to the Web.

Take the key and add this somewhere in the markdown document like this:

=dockey:19xwVCTzHJCM1cmjHbyJY25JtdaEU7_stkAdp_rm-D1w=

###Pulling in a cell value This will pull in cell A1:

=A1=

Simple, right? Just remember that cell values are always in caps - small caps won't work.

###Charts Adding a chart is similar to adding a cell value - just add in the chart-type first then the range of cells. Like this:

=linechart,A2:C6=

The valid chart-type values are:

  • linechart
  • areachart
  • columnchart
  • piechart
  • tablechart

Chart-type is case sensitive. The graphical charts are produced using the Google Charts API and are rendered client side, the 'tablechart' is rendered client side as well, but not with the Google Charts API.

##Served from RAM for speed Because we don't want to have to wait for a request to the Google Drive API on every serve, the first successful serve does all the heavy lifting (loading markdown, making the request, rendering the jade) and stows it in RAM for the next visitor.

If you want to refresh the content for next serve, just append /live to the end of the URL. It adds a 100-200ms, so it is still faster than serving PHP. Don't worry, you change /live to another string if you are worried about it.

##Install

Use NPM.

npm install reporter-js

Then create a small script that uses it. Something like this:

var
  reporterjs = require('reporter-js');

reporterjs.start({
  mdDirectory : __dirname+'/mdDirectory',
  port : 3005
});

Upload some markdown files to the directory in mdDirectory attribute. Just a note - you'll need to restart the process when you add new markdown files (not needed for updates, however)

###Options and customizations

Using the start function, you can pass in the following options:

  • mdDirectory - the directory where the markdown files are found (defaults to '/md')
  • prefix - specify a path to serve from (defaults to '/')
  • port - the port which the server will run (defaults to 3200)
  • staticDir - the server directory for the static files, e.g. CSS and client side JS (defaults to __dirname + '/public')
  • staticPath - the url path for the static files (defaults to '/public')

Most of the other functions in the reporter.node.js file is exported, so you can override these functions in your own node.js script.

If you already have a Express app and you want to add Reporter.JS to your app, don't use the start function. Try something like this:

var
  reporterjs = require('reporter-js'),
  app = express();
  
//other app stuff here, routes etc.
  
reporterjs.buildTemplate();  
reporterjs.routes(app,__dirName + '/md','/path/to/your/reports');

##License MIT