Simple Python-based static site generator
Project description
S-Gen
This is a simple yet powerful static site generator that is easy to migrate from html.
Environments
Python 3.11.x/3.12.x (Recommended)
Get started
Install
- Make virtual env:
python3 -m venv env - Activate virtual env:
source env/bin/activatefor linux/macos or.\env\Scripts\activatefor windows - Run
(python3 -m )pip install git+https://github.com/timomono/sgen.git
Create project
(python3 -m )sgen create example_project
cd example_project
Listen
If you're using VSCode, press Cmd/Ctrl + Shift + B, otherwise
(python3 -m )sgen listen
It will be built automatically when the file changes.
Run development server
(python3 -m )sgen runserver
Please note that it won't work unless you build it.
Now that the developing server’s running, visit localhost:8282 with your web browser.
You'll see a simple Hello world! page. It worked!
Create checklist app
Let's create a simple checklist app.
Create project
Follow the steps above to create an app named "simple_checklist" and build it, and start the server.
Write template
Open simple_checklist/src/(file name) in your favorite editor and copy and paste the following:
src/base.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{title}} | S-Gen Example</title>
<style>
body {
margin: 0;
}
.navbar {
background-color: brown;
display: flex;
align-items: center;
}
.navbar * {
color: white;
}
</style>
</head>
<body>
<div class="navbar">
<h1 style="margin:0;padding: 1rem;">
{{heading}}
</h1>
<ul>
<li>
<a href="/">Color</a>
<a href="/animal.html">Animal</a>
</li>
</ul>
</div>
<div style="padding: 1rem;">
{{body}}
</div>
</body>
</html>
src/index.html
{% from sgen.stdlib.pyrender.avoid_escape import AvoidEscape %}
{{ include("base.html",
title="Favorite color",
heading="Color",
body=AvoidEscape(f"""
<label for="favorite-color">What color do you like?</label>
<select id="favorite-color">
{
"".join([
f'<option value="{color}">{{color}}</option>'
for color in ["red","green","blue"]
])
}
</select>
""")
) }}
src/animal.html
{% from sgen.stdlib.pyrender.avoid_escape import AvoidEscape %}
{{ include("base.html",
```
title="Favorite animal",
heading="Animal",
body=AvoidEscape(f"""
<label for="favorite-animal">What animal do you like?</label>
<select id="favorite-animal">
{
"".join([
f'<option value="{animal}">{{animal}}</option>'
for animal in ["zebra","lion","cat"]
])
}
</select>
""")
) }}
```
A dropdown menu will appear.
This is as short as it gets. If we were to write raw HTML, it would be much longer.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sgen_tool-1.0.0.tar.gz.
File metadata
- Download URL: sgen_tool-1.0.0.tar.gz
- Upload date:
- Size: 12.7 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b7ab0ccd872909d4a25706cf80e50756878640bc0160eb3093376315785c3d6
|
|
| MD5 |
63453fec306572af3cb1ca9724f6ca16
|
|
| BLAKE2b-256 |
d3d0690902c33e0ce9e4fcb6f0f551450080251ef269be641bdee94ffdfa5aaa
|
File details
Details for the file sgen_tool-1.0.0-py3-none-any.whl.
File metadata
- Download URL: sgen_tool-1.0.0-py3-none-any.whl
- Upload date:
- Size: 12.7 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ed824331f91ad2b835bd799466542e46e5085a786dd0d3663047cbeb9c1beb0
|
|
| MD5 |
9dfa78a34a924f974a2c4115c6ce4dba
|
|
| BLAKE2b-256 |
e6daf9afa256c79d1e3b55c012f13e5903affb710edfa5d5283ea5569d9760ae
|