Skip to main content

SWEB is a static website generator that processes templates, styles, and assets

Project description

SWEB - Static Website Generator

TL;DR

SWEB is a static website generator that processes templates, styles, and assets.

It uses data from JSON files to generate a static website with HTML, CSS, and media files. The project is organized into several folders, each serving a specific role in the generation of the website.

A SWEB project overview

A sweb project is organized into several source folders, each serving a specific role in the generation of the static website. Below is an overview of the folders and their purposes:

sweb-project/
  app/         # Contains your SWEB project files.
    data/      # Contains JSON files with the data used to populate the templates.
    templates/ # Holds the handlebar template files used to generate the HTML pages of the website.
    styles/    # Stores CSS/SASS/SCSS files that define the visual appearance of the website.
    assets/    # Includes media files like images, videos, and other static files that need to be copied as-is.
  dist/      # The output directory where the generated website is saved.

Quick Start

# Step 1: Install SWEB using pip
pip install sweb

# Step 2: Create a new SWEB project named 'my-project'
sweb new my-project

# Step 3: Change directory to the newly created project
cd my-project

# Step 4: Generate the website using SWEB
sweb

# Step 5: Open the generated website's index page in the default web browser
open dist/index.html

Folders details

Data

Path

app/data/

Purpose

This directory stores JSON files which are essential for providing the content that gets inserted into the templates.

For Example: index.json, about.json, which might contain structured data for different parts of the site.

Data access

Data are accessible from the handlebar templates using the {{filename.key_path}} variable.

Example

If the data file is menu.json and the data is structured as follows:

{
  "items": [ "Home", "About", "Contact" ]
}

Then the data can be accessed in the template using {{menu.items}} which would output ["Home", "About", "Contact"]

Subdirectories

You can have subdirectories in the data/ folder, and the data will be accessible using the subdirectory name as the first part of the key path.

Example

If you have a file data/subdir/about.json with the following data:

{
  "title": "About Us",
  "description": "We are a team of developers passionate about creating amazing websites."
}

Then the data can be accessed in the template using {{subdir.about.title}} which would output About Us.

Templates

Path

app/templates/

Purpose

Contains handlebar template files which are the blueprints for the website. These templates are processed to insert data from the data directory and generate the HTML files in the dist directory.

Example

If you have a file data/index.json with the following content:

{
  "title": "my-project",
  "description": "A sweb project."
}

You could have a file templates/index.hbs with the following content:

<!DOCTYPE html>
<html>
  <head>
    <title>{{index.title}}</title>
    <link rel='stylesheet' href='styles/style.css'>
  </head>
  <body>
    <h1>Hello, world to {{index.description}}!</h1>
  </body>
</html>

it would generate the following HTML file in the dist/ folder: dist/index.html

<!DOCTYPE html>
<html>
  <head>
    <title>my-project</title>
    <link rel='stylesheet' href='styles/style.css'>
  </head>
  <body>
    <h1>Hello, world to A sweb project.!</h1>
  </body>
</html>

Styles

Path

app/styles/

Purpose

Stores CSS & SASS/SCSS style sheets that control the look and feel of the website. These stylesheets are compiled and saved in the dist/styles/ folder.

Example

The following style.scss file in the app/styles/ folder:

body {
  h1 {
    color: red;
  }
}

would generate the following CSS file dist/styles/style.css:

body h1 {
  color: red;
}

Assets

Path

app/assets/

Purpose

Holds static files like images, fonts, and other media which are copied directly into the output directory without modification.

Example

If you have an image app/assets/logo.png, it would be copied to dist/assets/logo.png without any changes.

How SWEB works?

To generate a website, SWEB:

  1. Load the JSON data from the app/data/ folder,
  2. Generate the html from the handlebar templates in the app/templates/ folder and save the result in the dist/ folder,
  3. Compile The CSS/SASS/SCSS files in the app/styles/ folder and save the result the dist/styles/ folder,
  4. The media files in the app/assets/ folder are copied as-is to the dist/assets/ folder.
  5. The dist/ folder now contains a fully functional static website.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sweb-0.7.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sweb-0.7-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file sweb-0.7.tar.gz.

File metadata

  • Download URL: sweb-0.7.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for sweb-0.7.tar.gz
Algorithm Hash digest
SHA256 240992eb1ecb929d69b6fd9f06d077332b55311e42cb0569c8f66f413ee76ee4
MD5 8454cc324c30338cd191d97e02a45b03
BLAKE2b-256 b0381677e01f90f01fa9e211bc4b1648a2329eccbe32033dc4dbb327d5a21352

See more details on using hashes here.

File details

Details for the file sweb-0.7-py3-none-any.whl.

File metadata

  • Download URL: sweb-0.7-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for sweb-0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 cad378fb11a6c65f6d8b551925297a509281bbb940e66a0b7a0db367561f0438
MD5 faf3e7fbac4e4636ce4b4fea93d27933
BLAKE2b-256 fb69e2413b417f227173c303cba91044ce1b907b18868eddf1557fb7becdb76f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page