Introduction
============
This is a set of scripts that can be used to do a semi-automatic
migration from WordPress to haunt, a static website generator.

Dependencies
============

To generate this website you will need Guix. The rest of the dependencies are
taken care of by Guix. Once you installed Guix you need to run 'guix pull' to
have the latest revision.

To run the tests (with make check) you will also need html2text and
ShellCheck.

Posting an article
==================

To post an article, add a new markdown file in posts/. You need the following
metadata in it:

* author: Your name / nickname. Can be multiple people like 'dllud, GNUtoo'.

* email: set it to replicant@osuosl.org

* date: the approximate date of the publication of the article.

* title: the post title.

* licenses: one or more licenses for the post.

Both author and email are needed to generate <author> fields in the RSS. This
is then picked up by www.replicant.us.

The blog post should start directly with text as otherwise, the following
Markdown code:

    Reducing the maintenance costs
    ==============================
    
    A lot of work was done to migrate from WordPress

Will result in the following on www.replicant.us:

    Reducing the maintenance costsA lot of work was done [...]

Then once everything is done you can test the blog locally with:

    $ make serve

The website will then be available on the http://localhost:1968 URL.

You will then either need to send a patch or the markdown for review on the
Replicant mailing list, or if you can push your changes yourself, push them in
git and then publish the post with the following command:

    $ make publish

It should also generate the site/rss/last-10-articles.xml file along the
way. To update the blog post lists on https://www.replicant.us you will also
need to copy this file inside the www.replicant.us repository
(https://git.replicant.us/infrastructure/www.replicant.us/) and push it.

Once done, code at OSUOSL periodically fetches that repository and updates the
www.replicant.us website. Note that it can take a bit between when the code is
pushed and when the changes appear online, but it should take less than one
hour (it takes several minutes).

Once everything is done you can post the Markdown to the mailing list, simply
by copy-pasting its content in a mail.

You then need to wait more until the mail arrives on the mailing list
archives, and when it is there, add a link to the the mailing list thread in
the article.

To do that you need to add the following metadata to the Markdown file:

* thread-link: The link to the post on the mailing list archive.

* thread-name: The content of the mail Subject.

You can then push the new commits and update the blog again with 'make
publish'.

Regenerating files
==================

The code that regenerates files is a bit fragile and parses untrusted data so
a human is required to review if there are any suspicious data at several
steps in the migration process. This is also one of the reasons why the
generated files are included in git: they were reviewed by a human.

This also requires the curl dependency and maybe Guix, depending on the
distribution you use (this will be detailed later on below).

So to regenerate everything, first remove all the files that are not tracked by
git. Do make sure to be in the top directory of the git repository before
doing that. This can be done with the following commands:

    git clean -dfx
    rm -rf external/vendor_replicant_artwork

Then we can remove the generated files:

    rm -rf links.txt posts

At this point we need to recreate links.txt. To do that you acn run the
following command:

    make links.txt

You then need to manually inspect it to see if it contains dangerous or
problematic characters / text.

Since that file is tracked by git, the following command can show if there are
any differences with the file that is in git:

    git diff -- links.txt

Once done, you then need to run run 'make posts' to download all the blog
posts in wordpress/articles and convert them to markdown (and store them in
posts/).

This requires a make that has guile support. You can simply type 'make posts'
if you are in Guix. If you are in a distribution where make is built without
guile support, the 'make post' command will fail and print the following:

    Make is missing Guile support.
    Guix's make has guile support.
    make: *** [Makefile:54: dependencies] Error 69

If you have this error, you can install Guix and run the following command
instead:

    guix shell make -- make posts

At this stage the website is then ready to used with haunt. You can
then build it with 'make build' or 'make serve'.

Reimporting articles in WordPress
=================================

If for some reasons you then need to import back some of the markdown
articles in WordPress, after modifying the Makefile to add the html of
your article below the 'generate-wordpress-articles' part, you can use
the 'make generate-wordpress-articles' command. It will print out the
article title and the HTML code that you will need to copy-paste into
WordPress.

By default, when creating an article in WordPress, you are presented
with a visual editor that is intended for people to create articles
without needing to write any HTML code.

Since here we need to paste HTML code here you will need to switch to
the "code editor" to be able to do that. The [WordPress official
documentation](https://wordpress.com/support/editors/) has more
details on where to find that "code editor".

License
=======

This file is free software: you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.

This file is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.  See the GNU General Public License (and the blog
post licenses) for more details.

You should have received a copy of the GNU General Public License along with
this project.  If not, see <https://www.gnu.org/licenses/>.