0.5.6 • Published 11 days ago

@neonwilderness/twoday v0.5.6

Weekly downloads
-
License
MIT
Repository
github
Last release
11 days ago

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

TermMeaning
Platform"prod" or "dev" whereas prod is the production (end-user) platform and dev is the development/playground space for platform maintainers.
AliasA 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.
AdministratorCrucial 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.
SkinsTwoday 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.
LayoutsEach 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.
FilesAn 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.
ImagesAn alias can store and upload images of different mime types which can then be used/embedded in stories with the <% image name="..." %> macro.
StoriesThe blog's articles with data items such as title, createDate, content (HTML).

Documentation

Class Constructor

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

ParamTypeValue/s
platformstringprod or dev
optionstUserOptionsobject
tUserOptions PropertyTypeDefaultText
delay?number100Delay in ms between http calls
agreed?string'20240210a'Current "Agreed terms of usage" version
silent?booleanfalseSuppress 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:

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

11 days ago

0.5.5

14 days ago

0.5.4

2 months ago

0.5.3

3 months ago

0.5.2

3 months ago

0.5.0

3 months ago

0.5.1

3 months ago

0.4.6

4 months ago

0.4.5

5 months ago

0.4.4

6 months ago

0.4.3

11 months ago

0.4.2

11 months ago

0.3.31

1 year ago

0.3.30

1 year ago

0.3.29

1 year ago

0.3.28

1 year ago

0.3.27

1 year ago

0.3.26

1 year ago

0.3.25

1 year ago

0.3.24

1 year ago

0.4.1

1 year ago

0.4.0

1 year ago

0.3.23

2 years ago

0.3.22

2 years ago

0.3.17

3 years ago

0.3.20

2 years ago

0.3.21

2 years ago

0.3.19

3 years ago

0.3.18

3 years ago

0.3.16

3 years ago

0.3.15

3 years ago

0.3.14

3 years ago

0.3.13

3 years ago

0.3.12

3 years ago

0.3.11

3 years ago

0.3.10

3 years ago

0.3.9

3 years ago

0.3.6

3 years ago

0.3.8

3 years ago

0.3.7

3 years ago

0.3.5

3 years ago

0.3.4

3 years ago

0.3.2

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.3

3 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.2.0

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago