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

wordpress.js

v1.12.0

Published

**Wordpress.js** is an in-memory (read-only) front-end to Wordpress.

Downloads

35

Readme

Wordpress.js is an in-memory (read-only) front-end to Wordpress.

Usage

Create a connection to the database. The library uses the non-blocking mariasql driver.

var connection = new wordpress.Connection({
    host: 'localhost'
  , user: 'root'
  , password: ''
})

Create a blog instance

var blog = new wordpress.Blog(connection, options);

Multisite installations are also supported

var multisite = new wordpress.Multisite(connection, options);
multisite.getBlogs(function (err, blogs) {
    //...
});

Load the blog

blog.on('load', function (posts, metadata) {
    //
});

The posts array contains published posts, sorted by date descending. Each post object contains id, title, content, excerpt, date, modified, slug, image, tags, categories.

The metadata object contains key/value pairs from the options table. The metadata.terms object contains the entire category/tag tree, while the metadata.archive array contains an index of post year/month combinations.

Live updates

The Blog instance will poll the database and emit events when something changes.

blog.on('new_post', function (post) {
    //...
});

The following events are available

  • load - called once when the blog is loaded - receives (posts, metadata)
  • new_post - when a new post is published - receives (post)
  • updated_post - when a published post is modified - receives (post)
  • removed_post - when a published post is removed - receives (post)
  • scheduled_post - when a post has been scheduled - receives (post_id)
  • updated_terms - when the category/tag tree changes - receives (terms)
  • updated_metadata - when the metadata changes - receives (metadata)
  • updated_archive - when the blog archive index changes - receives (archive)
  • error - when any sort of error occurs - receives (err)

Custom types

The wrapper class for posts, metadata, tags, and categories can be overridden

var blog = new wordpress.Blog(connection, {
    Post: MyCustomPostType
  , Tag: MyCustomTagType
  , Category: MyCustomCategoryType
  , Metadata: MyCustomMetadataType
});

See the current types for more information.

Tests

$ make check

Test verbosity can be increased by using V=1, e.g. V=1 make check

Code coverage analysis can be run with

$ make coverage-html

License (MIT)

Copyright (c) 2012 Sydney Stockholm [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.