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

sodawiki

v0.0.1

Published

helper for using the socrata and localwiki apis to import content into a localwiki site.

Downloads

3

Readme

SodaWiki

First pass at creating a socrata2localwiki data sync tool with javascript. Socrata's open data api is called SODA. So, SodaWiki. Because soda.

This module is super messy still. You can see in the code and in the usage example below a bunch of notes I took while writing it. Have ideas for fixing some of the problems? Fork this thing.

This will work for really simple situations, but for complex datasets hosted by socrata you might need to fork this project and make changes to the SodaWiki.sync method. Go for it. Feel free to submit pull requests for general improvements.

Tested with node v0.10.0.

This module depends on node-localwiki-client and sodajs-socrata.

It could probably work in the browser using browserify, but then you'd be sending your localwiki api key around in the open. That could be a bummer.

TODO:

  • create maps
  • create tags
  • move table generation stuff to node-localwiki-client
  • rework crazy attribute-mapping
  • general cleanup.

Usage:

var SodaWiki = require('SodaWiki');

var sodawiki = new SodaWiki({
  // localwiki options
  localwiki: {
    url: "some.localwiki.url", // like: http://seattlewiki.net
    user: process.env.LOCALWIKI_USER,
    apikey: process.env.LOCALWIKI_API_KEY
  },

  // socrata options
  socrata: {
    url: "https://data.seattle.gov"
  }
});

var options = {
  // the id of the data set on socrata. 
  // find it in the url: https://data.seattle.gov/Community/beaches-in-seattle/9mk3-vhgr
  resource: '9mk3-vhgr',

  // Tell localwiki which data attributes
  // to use for generating the page and related resources.
  // Put the key of the data set attribute as the value in this object.
  // This is confusing, right? is there a better solution?
  // I got it smart enough to grab the first value from nested objects,
  // but it assumes a really simple, flat data structure. not ideal.
  attributesMap: {
    pageTitle: "common_name",
    content: "common_name",
    table: {
      address: "address",
      website: "website"
    },
    lat_lon: {
      latitude: "location",
      longitude: "location"
    },
    tags: ["city_feature"]
  },

  // add custom attributes in addition to what's available from the socrata dataset
  customAttributes: {
    content: "<p>Beaches are really super fun and you're just going to have to deal with that.</p>",
    tags: ["fun", "recreation", "sand", "water access"],
    titleSuffix: " (Beach)" 
  }
}

// all that config just for one tiny method! lame? useful?
// the attributesMap stuff could potentially be rolled in to the localwiki api client
// what do other people do in this situation? of mapping attributes to other attributes?

sodawiki.sync(options);

Delete the pages you've created using the same options object:

sodawiki.rollback(options)

This helps with experimenting.