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

@neonwilderness/twoday

v0.5.6

Published

Module to help interact with the most relevant functions of the Twoday blogger platform

Downloads

79

Readme

This is a Node module to help interact with the most relevant functions of the twoday.net blogger platform

It helps you with

  • reading/creating/updating/deleting skins
  • listing/creating/updating/deleting files
  • listing/creating/updating/deleting images
  • listing/reading/creating/updating/deleting stories
  • managing available layouts (e.g. add a skin to a non-active layout) or download a zipped layout file
  • get general infos about a specific blog alias

Installation

$ npm install @neonwilderness/twoday

Twoday Credentials

For utilizing most of the API functions you will require a valid twoday.net User and Password which you need to specify in an .env file.

  1. Copy the .env.example file into your Node project directory
  2. Create an .env copy of the file and modify/save your Twoday credentials

Definitions

Term | Meaning --- | --- Platform | "prod" or "dev" whereas prod is the production (end-user) platform and dev is the development/playground space for platform maintainers. Alias | A blog alias is the name of a Twoday blog. Twoday blog urls are assembled as https://{alias}.twoday.net, e.g. in https://neonwilderness.twoday.net, "neonwilderness" is the blog alias. Administrator | Crucial API functions such as updating skins or deleting files of an alias require Administrator authorization. The blog owner/creator is always an Administrator but may also appoint additional users to the "Adminstrator" role. Hence, you can only manage aliases (blogs) for which your specific user has been authorized as Admin or if you are its owner. Skins | Twoday skins are template files which may contain HTML, CSS, JavaScript, partial layouts, miscelleaneous data and comprise the basis of the blog's frontend. They often embed macros such as <% username %> which are resolved/replaced server-side before sent to the browser. Layouts | Each blog can have multiple layouts, yet only one of them is active and defines the look & feel of the blog. Layouts consist of a number of predefined (but editable) system skins or user defined skins. Files | An alias can hold and upload own files, e.g. PDF, documents, script files, all kinds of data files to embed them either in stories or skins. Images | An alias can store and upload images of different mime types which can then be used/embedded in stories with the <% image name="..." %> macro. Stories | The blog's articles with data items such as title, createDate, content (HTML).

Documentation

Class Constructor

new Twoday.Twoday(platform: string, options: object)

Param | Type | Value/s --- | --- | --- platform | string | prod or dev options | tUserOptions | object

tUserOptions Property | Type | Default | Text --- | --- | --- | --- delay? | number | 100 | Delay in ms between http calls agreed? | string | '20240210a' | Current "Agreed terms of usage" version silent? | boolean | false | Suppress console messages

The options field may even be empty or completely omitted.

Example: Create a prod instance / no output messages

const Twoday = require('@neonwilderness/twoday');
const td = new Twoday.Twoday('prod', { silent: true });

Login

.login() : Promise<Response>

  • returns: http-response from login

Example: Create a prod instance with a general 50ms delay and login

const td = new Twoday.Twoday('prod', { delay: 50 });
await td.login();

Logout

.logout() : Promise<Response>

  • returns: http-response from logout

Example: Create a prod instance, login, get infos about an alias, then logout

const td = new Twoday.Twoday('prod');
await td.login();
const alias = 'neonwilderness';
const { stories } = await td.getInfos(alias);
console.log(`${alias} has written a total of ${stories} stories!`);
await td.logout();

In principle, the final logout is non-essential, however it's a best practice to immediately clean up Twoday's sessions list.

Get all memberships with Administrator authorization

.getMemberships() : Promise<string[]>

  • requires: successful login
  • returns: array of aliases

Blog owners (the creator of a blog) are also categorized as "Administrator".

The user's authorization to access/modify a specific blog alias is always checked on the server side. To avoid authorization errors it hence makes sense to verify if the desired blog alias is included in the getMemberships response.

Example: Create prod instance, login, get all admin memberships

const td = new Twoday.Twoday('prod');
await td.login();
const adminBlogs = await td.getMemberships();
console.log(`My user has ${adminBlogs.length} admin auths.`);
await td.logout();

Topic related class functions

Please refer to the following sub-pages for topic related documentation:

  • [x] Skins :: Functions related to Twoday Skins
  • [x] Stories :: Functions related to Twoday Stories
  • [x] Files :: Functions related to Twoday Files
  • [x] Images :: Functions related to Twoday Images
  • [x] Layouts :: Functions related to Twoday Layouts
  • [x] Special :: Special purpose functions
  • [x] Helper :: Useful helper functions