From: Ruben Beltran del Rio Date: Sat, 10 Dec 2022 15:22:08 +0000 (+0100) Subject: Docs update X-Git-Tag: 5.0.0~8 X-Git-Url: https://git.r.bdr.sh/rbdr/blog/commitdiff_plain/2acbdb038ea9e9d61ce7ce070629e0187fe95718?hp=a5315f49f6b16c892f00509e2a27117ffd167936 Docs update --- diff --git a/README.md b/README.md index 41de942..a598cb0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # blog -Blog at unlimited.pizza -> Only 3 at a time.* +Blog at unlimited.pizza -> Only 3 at a time. The blog is no longer 100% ephemeral. Instead it now keeps an archive in a separate folder. The archive is intended to be used as a gemlog. @@ -11,36 +11,62 @@ in a separate folder. The archive is intended to be used as a gemlog. ## How to add a new entry -Create a directory with a `.gmi` gemini file, and an `/assets` -directory with anything you want in there. This can be in any directory. - -``` -. -└── this-is-an-example-post - ├── assets - │   └── example.wav - └── this-is-an-example-post.md -``` +Create a `.gmi` gemini file. You can add this to the blog using the following command, it will shift all entries and remove the oldest one if limit of posts is reached (defualts to 3): -`blog --add path/to/blog_post` +``` +blog --add path/to/blog_post.gmi +``` These commands will regenerate the static files. At that point you can preview your blog by serving the files on the `static` directory. If you need to make corrections use: -`blog --update path/to/blog_post` +``` +blog --update path/to/blog_post.gmi +``` This will replace the latest with the contents of the `path` without shifting the existing entries. -`blog --publish ` +You can always regenerate the static files by using -Will publish the blog to the mentioned s3 bucket. +``` +blog --generate +``` + +To publish the blog, you can select an s3 bucket and run it with: + +``` +blog --publish +``` + +You can also publish the archive of posts as a gemlog, by passing a valid +rsync target + +``` +blog --publish-archive +``` + +Blog supports saving snapshots of the blog in git, and you can add and remove +remotes with the following commands: + +``` +blog --add-remote +blog --remove-remote +``` + +If a remote is present, it will be pulled before adding or updating, and pushed +after it finishes. You can manually trigger this by calling + +``` +blog --sync-up +blog --sync-down +``` ## Configuring diff --git a/bin/blog.js b/bin/blog.js index dc256ee..a9e2d1e 100755 --- a/bin/blog.js +++ b/bin/blog.js @@ -121,8 +121,8 @@ const internals = { _printUsage() { console.error('\nUsage:\n'); - console.error('blog --add path/to/blog_post\t\t(creates new blog post)'); - console.error('blog --update path/to/blog_post\t\t(updates latest blog post)'); + console.error('blog --add \t\t(creates new blog post)'); + console.error('blog --update \t\t(updates latest blog post)'); console.error('blog --generate \t\t\t(generates the blog assets)'); console.error('blog --publish \t\t(publishes the blog to an S3 bucket)'); console.error('blog --publish-archive \t(publishes the archive to a remote host)'); diff --git a/example/test-blog-post/assets/example_image.png b/example/test-blog-post/assets/example_image.png deleted file mode 100644 index 672e3a1..0000000 Binary files a/example/test-blog-post/assets/example_image.png and /dev/null differ diff --git a/example/test-blog-post/assets/ok/ok.txt b/example/test-blog-post/assets/ok/ok.txt deleted file mode 100644 index e69de29..0000000 diff --git a/example/test-blog-post/test-blog-post.md b/example/test-blog-post/test-blog-post.md deleted file mode 100644 index 88209ea..0000000 --- a/example/test-blog-post/test-blog-post.md +++ /dev/null @@ -1,57 +0,0 @@ -# This is the title of another entry - -An entry will have paragraphs, these paragraphs will contain text. The -text should be formatted correctly: visitors will want to read whatever -is in the blog, so it should be readable. It should account for several -types of tags, like **strong**, or *emphasised*. It should even support -[links](/) - -An entry will have paragraphs, these paragraphs will contain text. The -text should be formatted correctly: visitors will want to read whatever -is in the blog, so it should be readable. It should account for several -types of tags, like **strong**, or *emphasised*. It -should even support [links](/) - -An entry will have paragraphs, these paragraphs will contain text. The -text should be formatted correctly: visitors will want to read whatever -is in the blog, so it should be readable. It should account for several -types of tags, like **strong**, or *emphasised*. It -should even support [links](/) - -## Subheading 1 (h2) - -An entry will have paragraphs, these paragraphs will contain text. The -text should be formatted correctly: visitors will want to read whatever -is in the blog, so it should be readable. It should account for several -types of tags, like **strong**, or *emphasised*. It -should even support [links](/) - -* There will be **lists** -* Lists will have *tags* -* And everything else [in the world](/) - -An entry will have paragraphs, these paragraphs will contain text. The -text should be formatted correctly: visitors will want to read whatever -is in the blog, so it should be readable. It should account for several -types of tags, like **strong**, or *emphasised*. It -should even support [links](/) - -![Picture: two persons in a ceremony][example-image] - -### Other types of subheadings, other types of lists (h3) - -1. There will be **lists** -2. Lists will have *tags* -3. And everything else [in the world](/) - -An entry will have paragraphs, these paragraphs will contain text. The -text should be formatted correctly: visitors will want to read whatever -is in the blog, so it should be readable. It should account for several -types of tags, like **strong**, or *emphasised*. It -should even support [links](/) - -#### Finally there are hfours (h4) - -And that's about it! - -[example-image]: /assets/example_image.png diff --git a/lib/blog.js b/lib/blog.js index fd5adaf..6923a10 100644 --- a/lib/blog.js +++ b/lib/blog.js @@ -59,13 +59,12 @@ module.exports = class Blog { } /** - * Shifts the blog posts, adds the passed path to slot 0, and + * Shifts the blog posts, adds the passed file to slot 0, and * generates files. * * @function add * @memberof Blog - * @param {string} postLocation the path to the directory containing - * the post structure + * @param {string} postLocation the path to the blog post file * @return {Promise} empty promise, returns no value * @instance */ @@ -84,12 +83,11 @@ module.exports = class Blog { } /** - * Adds the passed path to slot 0, and generates files. + * Update slot 0 with the passed gmi file, and generates files. * * @function update * @memberof Blog - * @param {string} postLocation the path to the directory containing - * the post structure + * @param {string} postLocation the path to the blog post file * @return {Promise} empty promise, returns no value * @instance */ @@ -380,18 +378,17 @@ module.exports = class Blog { await writeFile(metadataTarget, JSON.stringify(metadata, null, 2)); } - // Copies a post directory to the latest slot. + // Copies a post file to the latest slot. async _copyPost(postLocation) { + internals.debuglog(`Copying ${postLocation}`); const targetPath = join(this.postsDirectory, '0'); const postName = basename(postLocation); const targetPost = join(targetPath, postName); - internals.debuglog(`Removing ${targetPath}`); await rmIfExists(targetPath); await ensureDirectoryExists(targetPath); - internals.debuglog(`Adding ${postLocation} to ${targetPost}`); await cp(postLocation, targetPost, { recursive: true }); internals.debuglog(`Added ${postLocation} to ${targetPath}`); }