10 stable releases

1.0.10 Dec 13, 2021
1.0.9 Sep 15, 2021

#705 in Text processing

45 downloads per month

GPL-3.0 license

26KB
468 lines


OB - Oliver's Blog Script

A Blog and RSS system written in Rust.

Features

  • Converts blog entries written in Markdown into HTML.   ✍🏻
  • Keeps a rolling blog page.   🔎
  • Keeps an RSS feed which includes blog posts in full.   📰
  • Creates entries in the rolling blog page that are easily modifiable with CSS.   ⚡️
  • One command to delete, edit or regenerate entries from the RSS feed, rolling blog and standalone entry pages simultaneously.   🚀
  • Works on MacOS, Linux and Windows.   🖥
  • Less than 450 lines of code.   🏝
  • Blazingly fast.   🔥

Installation

Install Rust:

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Install OB:

cargo install ob

Setup

You will need to create four files:

  • A Rolling Blog File where the blog entries will be listed.
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Your Blog</title>
    <meta charset="utf-8"/>
  </head>
  <body>
    <h1>Blog Updates</h1>
    <ul>
      <!-- OB -->
    </ul>
  </body>
</html>
  • A Template to be filled out with the content of a blog post.
<!DOCTYPE html>
<html lang="en">
  <head>
    <title></title>
    <meta charset="utf-8"/>
  </head>
  <body>
    <!-- OB -->
  </body>
</html>
  • An RSS feed.
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="rss.css" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Blog Title</title>
    <description>Description</description>
    <language>en-us</language>
    <link>https://your_blog.com/rss.xml</link>
    <atom:link href="https://your_blog.com/rss.xml" rel="self" type="application/rss+xml" />

    <!-- OB -->
  </channel>
</rss>
  • A configuration file containing the paths to your blog index, template and rss files.
    It should also include the address of where the blog entries will be hosted, the maximum number of posts on the rss feed and whether to include images or not.
{
    "blog": "index.html",
    "template": "template.html",
    "rss": "rss.xml",
    "items": 4,
    "blog_address": "https://your_blog.com/blog/",
    "images": true
}

Markers

For the system to work, add the following comment line to the Rolling Blog File, Template and RSS feed (as above).

<!-- OB -->

When you publish a blog post, it will be added directly below that line in the proper format.

Usage

USAGE:
    ob <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

SUBCOMMANDS:
    delete     Deletes an entry
    edit       Edit a published entry
    help       Prints this message or the help of the given subcommand(s)
    new        Create a new draft
    publish    Publish a daft
    regen      Regenerates all blog entries

The first time ob is used it will create a folder at: /blog.

When you create a new draft it will be located at: /blog/drafts.
When you publish a new draft it will be located at: /blog/example.html.

Example usage:

ob new

You can see an example on my blog or OB's website located in the /docs folder.

Dependencies

~10MB
~176K SLoC