Giter Club home page Giter Club logo

appie2's Introduction

appie.py

A minimal, lightweight static website/blog generator. Just a single file which you can modify to your liking.

TL;DR

  • Clone or download this repository to your computer
  • Modify/add static files to the static dir
  • Modify/add content in the content dir
  • Run python3 appie.py, the site is generated in the _site dir
  • Upload to some webhosting platform

See the example here Contents

Introduction

In this repository you will find an example website with a MarkDown blog and some static .html pages. You can generate this into a functioning website using the provided appie.py python script.

The idea behind this stems from Permacomputing in which we aim for minimal systems. You can do what you want with Appie but the example is a very minimal HTML site without any Javascript and other bloat.

The name Appie comes from the initial website generator which was in use at z25.org. This second version is a complete minimalized rewrite.

Usage

1: Clone the repository using git (you can also download the .zip)

git clone https://github.com/sphaero/appie2

2: Install the dependencies (only jinja2, pillow and markdown). Might be best to do in a virtual env From appie2's root directory run:

pip install -r requirements.txt

3: Do a first run:

python3 appie.py

You will now have the full website in the '_site' directory.

You can host a webserver using python to preview the site:

cd _site
python3 -m http.server

Now open a browser and go to http://localhost:8000

4: Upload the _site directory to a website hosting platform.

The files and directories

The Code

If you managed to generate the provided example site you can now modify it to your liking.

The code is quite simple. From the main() function we first prepare the '_site' directory and copy the contents of the static dir into it.

We then setup some global parameters (params) and try add parameters from a saved .json file if it exists.

We then walk the contents af the 'content' directory to a tree dictionary containing all meta data of the content directory. For example the dictionary looks like this:

{
    ".": {
        "_path": ".",
        "_srcpath": "./test",
        "_type": "dir",
        "bla.md": {
            "_ext": ".md",
            "_filename": "bla",
            "_mtime": 1703251224.8210585,
            "_sitedir": ".",
            "_sitepath": "./bla.md",
            "_srcpath": "./test/bla.md",
            "_type": "file",
        },
        "test.png": {
            "_ext": ".png",
            "_filename": "test",
            "_mtime": 1703254450.232499,
            "_sitedir": ".",
            "_sitepath": "./test.png",
            "_srcpath": "./test/test.png",
            "_type": "file",
        },
    },
    "testdir": {
        "_path": "testdir",
        "_srcpath": "./test/testdir",
        "_type": "dir",
        "test.jpg": {
            "_ext": ".jpg",
            "_filename": "test",
            "_mtime": 1703254472.9648764,
            "_sitedir": "testdir",
            "_sitepath": "testdir/test.jpg",
            "_srcpath": "./test/testdir/test.jpg",
            "_type": "file",
        },
        "test.md": {
            "_ext": ".md",
            "_filename": "test",
            "_mtime": 1703251351.642544,
            "_sitedir": "testdir",
            "_sitepath": "testdir/test.md",
            "_srcpath": "./test/testdir/test.md",
            "_type": "file",
        },
    },
}

We then extract the root directories of the content dir which we will use to generate the nav entries for the navigation menu.

Finally we recursively run the parse_dir() method on the tree dictionary. So parse_dir() is called for every directory entry in the tree. If an entry is not a directory but a file then parse_path() is called on the entry. Finally for every dir we call generate_index() which will generate an index.html page for the directory.

parse_path() parses markdown, plain html, and images. It will parse them through jinja2 and finally copies to the '_site' dir. All meta data and params are passed to jinja2. If it can't match a file to parse it will just copy it to the '_site' dir.

appie2's People

Contributors

sphaero avatar

Watchers

 avatar  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.