Skip to main content

A Python package for Hyperify Rune

Project description

Rune

Rune is a tool that combines different types of content (like YAML, HTML, Markdown, TSX, SVG, PNG, ZIP, JPG, and JSON) into one easy-to-use JSON format.

This output is designed to securely serve content through a REST API.

Rune is built for everyone on your team — developers, designers, and content creators. It simplifies collaboration by supporting familiar formats like HTML, YAML, Markdown, and TSX, making it easy to manage assets, translations, and views all in one place.

Metaphor: Rune and the Basket of Fruits

Think of Rune as a master basket weaver, skillfully crafting a basket to hold different kinds of fruits, each familiar to a specific audience:

  • HTML files are like apples — crisp, structured, and familiar to frontend developers.
  • YAML files are like oranges — layered, segmented, and a favorite of backend developers and system architects.
  • JSON translation files are like bananas—rich in meaning, easy to peel apart, and familiar for localization experts.
  • Markdown files are like grapes — small, simple, and versatile, perfect for documentation writers. Markdown is not yet implemented. See #22.
  • Assets (images, downloadable content, etc.) are like cherries — vibrant, eye-catching, and ready to be included.

Rune carefully weaves a basket — a JSON file — that organizes and holds all these fruits together in a portable and structured way. This basket isn't just static; it can be used as-is or handed to a backend, where more fruits (additional data or assets) can be added later to enrich its contents.

The result is an adaptable basket ready for any use case, whether it's for a simple picnic (a static web content) or a grand feast (a dynamic API-driven application).

Key Features

1. Dynamic Content Processing

  • Consolidates YAML (*.yml) and HTML (*.html) files into a single JSON output, embedding any referenced assets as Base64-encoded data URLs.
  • Supports reusable components, nested children, and parameterized elements.

2. Multilingual Support

  • Integrates translations from translations/*.LANG.json files.
  • Outputs a flat i18n structure compatible with popular localization libraries.

3. Embedded Assets

  • Automatically embeds image files and assets as Base64-encoded data URLs.
  • Supports SVG and other image formats with MIME type detection.

4. Portability

  • Outputs a self-contained JSON file that includes all views, translations, and assets.
  • Ideal for static or dynamic web applications.

5. Extensibility

  • Supports custom components and nested structures.
  • Allows easy addition of new file types, assets, or features.

Getting Started

Prerequisites

To use Rune, ensure you have the following installed:

  • Python 3.6 or later
  • Required Python libraries:
    pip install -r requirements.txt
    

Installation

You can install Rune using pip:

pip install hyperify-rune

Or clone the repository for development:

git clone https://github.com/hyperifyio/rune.git
cd rune

Usage

1. Using the Command Line Tool

After installing with pip, you can use the rune command directly:

rune <directory> <output_type>

For example:

rune views json

2. Prepare Your Project Directory

Structure your project directory as follows:

project/                 # Contains YAML and HTML files
├── translations/        # Contains translation JSON files
│   ├── HelloWorld.en.json
│   └── HelloWorld.fi.json
├── assets/              # May contain images or other assets (or anywhere else on your system)
└── Makefile             # Makefile for build automation. Optional, for easier rebuild.

3. Add YAML or HTML Views

Example YAML file (views/HelloWorld.yml):

- type: "View"
  name: "HelloWorld"
  body:
  - type: div
    classes:
    - "hello-world-container"
    body:
    - type: h1
      body:
      - "app.title"
  - type: p
    body:
    - "app.content"

Example HTML file (views/HelloWorld.html):

<View name="HelloWorld">
  <div class="hello-world-container">
    <h1>app.title</h1>
    <p>app.content</p>
  </div>
</View>

4. Add Translations

Create translation files in translations/ (e.g., HelloWorld.en.json):

{
  "app.title": "Hello, World!",
  "app.content": "Welcome to Rune!"
}

5. Build the Project

Run Rune to merge all YAML, HTML, and translation files into a single JSON:

python3 rune.py views json

The output will look like this:

[
  {
    "type": "View",
    "name": "HelloWorld",
    "body": [
      {
        "type": "div",
        "classes": ["hello-world-container"],
        "body": [
          {"type": "h1", "body": ["app.title"]},
          {"type": "p", "body": ["app.content"]}
        ]
      }
    ]
  },
  {
    "type": "i18n",
    "data": {
      "en": {
        "app.title": "Hello, World!",
        "app.content": "Welcome to Rune!"
      }
    }
  }
]

Advanced Features

Reusable Components

Define components with parameters and children:

Example (views/UsageCard.html):

<Component name="UsageCard">
  <div class="card">
    <UnfoldableCard title="usageCard.title">
      <Component.Children></Component.Children>
    </UnfoldableCard>
  </div>
</Component>

Embedded Assets

Embed files directly into the JSON output:

Example YAML asset (views/assets.yml):

- type: "Asset"
  name: "logo"
  body: "data:image/png;base64,xxxxx"

Image Handling

Automatically embed images referenced in properties like Image, src, or custom attributes.

Example HTML (views/Example.html):

<Foo heroImage="../assets/logo.png"></Foo>

CLI Options

python3 rune.py <directory> <output_type>
  • <directory>: The project directory containing *.yml, *.html, and translations/.
  • <output_type>: Either json or yml.

License

Rune is licensed under [./LICENSE.md](the Functional Source License, Version 1.1, MIT Future License).


Contact

For questions, feedback, or commercial inquiries, contact us at info@hyperify.io.

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

hyperify_rune-0.1.4.tar.gz (30.6 MB view details)

Uploaded Source

Built Distribution

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

hyperify_rune-0.1.4-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file hyperify_rune-0.1.4.tar.gz.

File metadata

  • Download URL: hyperify_rune-0.1.4.tar.gz
  • Upload date:
  • Size: 30.6 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for hyperify_rune-0.1.4.tar.gz
Algorithm Hash digest
SHA256 23efa47e0227a95e49b11880c6bdb5416b7c4f00ae3a151021b2e94f5dda5551
MD5 2605e17536edf06b7c08b21a4ac54180
BLAKE2b-256 57e08a99b3108ae8c080419889d3dfc349f5810955be30cb03da1208644784d0

See more details on using hashes here.

File details

Details for the file hyperify_rune-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: hyperify_rune-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for hyperify_rune-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 484a0a9e156ff1dfcc96f098568ef922242ec43ddaff7701fcec62e444bad7ca
MD5 2dc5bacfa4362b0f24a2a4eef0aa4ddd
BLAKE2b-256 329e06d1a8ead410d0fc573fcab57f97297d2f1391acc95165ee7c937c99aab6

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