Coder Social home page Coder Social logo

indiekit's Introduction

Indiekit

Build status

Indiekit is a small but powerful server that acts as the go-between your website and the wider independent web. Using IndieWeb protocols and standards, Indiekit lets you:

  • publish content to your website using applications like iAWriter, Micro.blog, Icro, Indigenous and other tools that support the Micropub API
  • accept likes, comments and other feedback on your content using Webmentions
  • syndicate content to social networks like Twitter, Mastodon and LinkedIn

Quick start

The easiest way to get started is to deploy this application to Heroku.

This assumes you’ll be saving files to GitHub and publishing to a Jekyll (or similar) static site generator.

Clicking the button below will guide you through the process.

Deploy

You’ll be asked to provide the following values:

  • GITHUB_TOKEN - A GitHub personal access token
  • GITHUB_USER - Your username on GitHub
  • GITHUB_REPO - Name of the repository where you want to save files
  • PUBLICATION_URL - URL of the website you want to publish to

Contents

Requirements

  • Node.js v12+

Features

  • Create, update and delete posts
  • Upload files
  • Configure different post types
  • Accept post status and visibility
  • Review previously published posts and files
  • Bookmarklet to save and share bookmarks
  • Publish to different content stores (GitHub and GitLab)
  • Support for popular static site generators (Jekyll, Hugo, 11ty)
  • Localised to different languages
  • Plug-in API

Install

npm install @indiekit/indiekit

Usage

Set up your server

Create a configuration file, indiekit.config.js, setup Indiekit and export its server:

import {Indiekit} from '@indiekit/indiekit';

// Create a new indiekit instance
const indiekit = new Indiekit();

// Create a server
const server = indiekit.server();

// Export server
export default server;

Start the server with node indiekit.config.js.

Indiekit can now listen for Micropub requests, but a few bits of information are needed before it can publish content to your website.

Configure your publication

Indiekit needs to know your website’s URL. You can provide this information using Indiekit’s configuration API, like so:

indiekit.set('publication.me', 'https://paulrobertlloyd.com');

Add a publication preset

Indiekit needs to know what post types you want to publish (for example notes and photos) and in which format. This information can be provided by setting publication.postTypes and publication.postTemplate. See Configuring post types and Creating a post template.

A publication preset plug-in can provide default values for these options (which you can override in your configuration file).

If you use the Jekyll static site generator, you can install the Jekyll plug-in:

npm install @indiekit/preset-jekyll

Then add it to your configuration file:

import {JekyllPreset} from '@indiekit/preset-jekyll';
const jekyll = new JekyllPreset();
indiekit.set('publication.preset', jekyll);

Add a content store

Indiekit needs to know where to store your posts and media files. A content store plug-in provides this functionality.

If you are saving your files to GitHub, install the GitHub plug-in:

npm install @indiekit/store-github

Then add it to your configuration file:

import {GithubStore} from '@indiekit/store-github';
const github = new GithubStore({
  user: 'username', // Your username on GitHub
  repo: 'reponame', // Repository files will be saved to
  branch: 'main', // Branch to publish to
  token: 'token' // GitHub personal access token
});
indiekit.set('publication.store', github);

Example configuration

With all these settings in place, your configuration file will look something like this:

import {Indiekit} from '@indiekit/indiekit';
import {JekyllPreset} from '@indiekit/preset-jekyll';
import {GithubStore} from '@indiekit/store-github';

// Create a new indiekit instance
const indiekit = new Indiekit();

// Configure GitHub content store
const github = new GithubStore({
  user: 'username', // Your username on GitHub
  repo: 'reponame', // Repository files will be saved to
  branch: 'main', // Branch to publish to
  token: 'token' // GitHub personal access token
});

// Configure Jekyll publication preset
const jekyll = new JekyllPreset();

// Configure publication
indiekit.set('publication.me', 'https://paulrobertlloyd.com');
indiekit.set('publication.preset', jekyll);
indiekit.set('publication.store', github);

// Create a server
const server = indiekit.server();

// Export server
export default server;

Enable automatic discovery

To ensure Indiekit’s endpoint can be discovered by Micropub clients (and have permission to post to your website), you need to add the follow values to your website’s <head>:

<link rel="micropub" href="[INDIEKIT_URL]/micropub">
<link rel="authorization_endpoint" href="https://indieauth.com/auth">
<link rel="token_endpoint" href="https://tokens.indieauth.com/token">

Options

application.locale

The language used in the application interface. See the list of supported languages.

Type: string
Optional, defaults to system language if supported, else en (English)

application.mongodbUrl

To cache files and save information about previously posts and files, you will need to connect Indiekit to a MongoDB database. You can host one on MongoDB Atlas.

Type: URL
Optional

application.name

The name of your server.

Type: string
Optional, defaults to Indiekit

application.themeColor

Accent colour used in the application interface.

Type: string
Optional, defaults to #0000ee

publication.categories

A list of categories or tags used on your website. Can be an array of values, or the location of a JSON file providing an array of values.

Type: Array | URL
Optional

publication.locale

Your publication’s locale. Currently used to format dates.

Type: string
Optional, defaults to en (English)

publication.me

Your website’s URL.

Type: URL
Required

publication.mediaEndpoint

Indiekit provides a media endpoint, but you can use a third-party endpoint by setting a value for this option.

Type: URL
Optional

publication.postTemplate

A post template is a function that takes post properties received and parsed by the Micropub endpoint and renders them in a given file format, for example, a Markdown file with YAML frontmatter.

Type: Function
Optional, defaults to MF2 JSON

publication.postTypes

A set of default paths and templates for different post types. See Configuring post types.

Type: Array
Optional if using a preset

publication.preset

A publication preset plug-in.

Type: Function
Optional

publication.slugSeparator

The character used to replace spaces when creating a slug.

Type: string
Optional, defaults to -

publication.store

A content store plug-in.

Type: Function
Required

publication.storeMessageTemplate

Function used to customise message format. See Customising commit messages.

Type: Function
Optional, defaults to [action] [postType] [fileType]

publication.sydnicationTargets

An array of syndication targets. Example:

[{
  uid: 'https://twitter.com/paulrobertlloyd/',
  name: 'Paul Robert Lloyd on Twitter'
}, {
  uid: 'https://mastodon.social/@paulrobertlloyd',
  name: 'Paul Robert Lloyd on Mastodon'
}, {
  uid: 'https://micro.blog/paulrobertlloyd',
  name: 'Paul Robert Lloyd on Micro.blog'
}]

Type: Array
Optional

publication.timeZone

The time zone for your publication. By default this is set to UTC, however if you want to offset dates according to your time zone you can provide a time zone name, for example, Europe/London:

indiekit.set('publication.timeZone', 'Europe/London');

This option also accepts a number of other values. See Setting a time zone.

Type: string
Optional, defaults to UTC

publication.tokenEndpoint

An IndieAuth token endpoint.

Type: URL
Optional, defaults to https://tokens.indieauth.com/token

Local development

npm start

If you’re developing a new feature, and want the application to automatically restart whenever a file change is detected, use npm run dev.

Testing

npm test

The following environment variables need to be set before running tests:

  • TEST_PUBLICATION_URL
  • TEST_BEARER_TOKEN
  • TEST_BEARER_TOKEN_NOSCOPE

TEST_BEARER_TOKEN and TEST_BEARER_TOKEN_NOSCOPE provide IndieAuth access tokens whose me value matches that set in TEST_PUBLICATION_URL.TEST_BEARER_TOKEN should provide scoped permissions create update delete, whereas TEST_BEARER_TOKEN_NOSCOPE should provide no permissions at all.

Homebrew Access Token is a useful tool for creating access tokens for this purpose.

Credits

Developed by Paul Robert Lloyd.

Thank-you to Aron Carroll for mentoring me during the development of this project. Indiekit is a much better project for his feedback and advice.

Similar projects

Indiekit is inspired by similar projects made by members of the IndieWeb community, all of which you are encouraged to try:

indiekit's People

Contributors

paulrobertlloyd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.