Metadata-Version: 2.4
Name: sgen-tool
Version: 1.0.1
Summary: Simple Python-based static site generator
Home-page: https://github.com/timomono/sgen
Author: timomono
License: BSD-3-Clause
Project-URL: Bug Tracker, https://github.com/timomono/sgen/issues
Project-URL: Source Code, https://github.com/timomono/sgen
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11,<3.15
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license
Dynamic: license-file
Dynamic: project-url
Dynamic: requires-python
Dynamic: summary

# 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
1. Make virtual env: `python3 -m venv env`
2. Activate virtual env: `source env/bin/activate` for linux/macos or `.\env\Scripts\activate` for windows
3. Run `(python3 -m )pip install git+https://github.com/timomono/sgen.git`

### Create project
```shell
(python3 -m )sgen create example_project
cd example_project
```
### Listen
If you're using VSCode, press Cmd/Ctrl + Shift + B, otherwise
```shell
(python3 -m )sgen listen
```
It will be built automatically when the file changes.

### Run development server
```shell
(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**
```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**
```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**
```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.
