From 41479e28497e950f55dd660176da0c6dd21d9f8e Mon Sep 17 00:00:00 2001 From: randogoth Date: Wed, 17 May 2023 00:24:52 +0300 Subject: [PATCH] readme and settings --- .gitignore | 1 + README.md | 61 +++++++++++++++++++++++++++++++++++++++++ example/pelicanconf.py | 2 +- example/publishconf.py | 1 + plugin/micron/micron.py | 3 +- requirements.txt | 4 +++ 6 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index 2c54b39..cd5a18e 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ example/output/ # Byte-compiled / optimized / DLL files __pycache__/ +*__pycache__ *.py[cod] *$py.class diff --git a/README.md b/README.md index 55b743d..60ee813 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,63 @@ # micron-blog + Pelican Plug-In and Theme for publishing a site in Micron markup format for Nomad Network Nodes + +## Installation + +Install dependencies + +``` +$ pip3 install -r requirements.txt +``` + +## Create a Static Site from Scratch + +Use the `example` folder as a starting point... + ++ Write your content in markdown formatted files and place them in the `content` folder ++ Edit the micron formatted Jinja2 templates in `theme/templates` to your liking ++ Generate the blog by running the following command in the `example` folder: + +``` +$ pelican content +``` + +## Use alongside an existing Pelican installation + ++ Copy the theme and plugin to your Pelican site's folder ++ Duplicate your `pelicanconf.py` file to something like `micronconf.py` ++ Edit the new file and make sure Pelican can find the new folders by adding them to the `PLUGIN_PATHS` and editing the `THEME` and `PLUGINS` variables respectively ++ If you want to place the micron .mu files in a different output folder than your generated HTML files, specify a path in a variable called `MICRON_PATH` ++ Make sure `RELATIVE_URLS` is set to `True` ++ Make sure all Links in your Markdown articles and pages are relative and local, since you will not be able to access http links inside Nomad Network + +Example Settings, vary depending on your setup: + +```Python +PLUGIN_PATHS = ["pelican-plugins"] +PLUGINS = ['micron'] +THEME = 'micron-theme' +MICRON_PATH = 'micron_out' +RELATIVE_URLS = True +``` + +Generate the Micron pages by pointing Pelican to the Micron config file: + +``` +$ pelican content -s micronconf.py +``` + +## Deployment + +If you have not run Nomad Network yet, initialize the needed folder by running `nomadnet` once + +``` +$ nomadnet +``` + +Copy the generated .mu files from the output folder to the NN node's `pages` folder: +``` +$ cp -R output/* ~/.nomadnetwork/storage/pages +``` + +Run your node and serve the pages.... \ No newline at end of file diff --git a/example/pelicanconf.py b/example/pelicanconf.py index 763f3c2..38e2101 100644 --- a/example/pelicanconf.py +++ b/example/pelicanconf.py @@ -24,4 +24,4 @@ RELATIVE_URLS = True PLUGIN_PATHS = ["../plugin"] PLUGINS = ['micron'] THEME = '../theme' -MICRON_PATH = 'output/micron' \ No newline at end of file +MICRON_PATH = 'output/micron' diff --git a/example/publishconf.py b/example/publishconf.py index be3909b..898a169 100644 --- a/example/publishconf.py +++ b/example/publishconf.py @@ -3,6 +3,7 @@ import os import sys +import shutil sys.path.append(os.curdir) from pelicanconf import * diff --git a/plugin/micron/micron.py b/plugin/micron/micron.py index 5bcb22c..a944c3b 100644 --- a/plugin/micron/micron.py +++ b/plugin/micron/micron.py @@ -223,7 +223,8 @@ class MicronWriter(Writer): def __init__(self, output_path, settings): super().__init__(output_path, settings) - self.output_path = settings.get('MICRON_PATH', 'micron/') + out = settings.get('OUTPUT_PATH', 'output/') + self.output_path = settings.get('MICRON_PATH', out) def write_file(self, name, template, context, relative_urls=False, paginated=None, template_name=None, override_output=False, diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..abac53a --- /dev/null +++ b/requirements.txt @@ -0,0 +1,4 @@ +Markdown==3.4.3 +mistune==3.0.0rc5 +pelican==4.8.0 +nomadnet==0.3.5 \ No newline at end of file