Skip to content

asok-framework/asok-awesome

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

Asok Logo

Awesome Asok

Awesome

A curated list of awesome extensions, plugins, resources, templates, and tools for the Asok Framework.

Asok is a modern, ultra-lightweight, and lightning-fast web framework for Python.

Tip

Have you developed an Asok extension, tool, or template? Help the community grow! Please share your project here to assist other developers in building with Asok. Read the Contributing section below to submit your project.


Contents


Official Resources

Extensions & Integration

  • asok-auth-providers - OAuth2 providers pack (Google, GitHub, Microsoft, Apple, Discord, Facebook, GitLab, LinkedIn, Twitch) for the Asok framework, with drop-in routes, customizable buttons, and preconfigured CSS.
  • asok-lucide - Server-side Lucide Icons integration for Asok, rendering clean, customizable SVGs with zero client-side JS.

Tools & IDE Support

  • asok-vscode - VS Code extension for Asok, providing syntax highlighting, autocomplete, and code snippets.

Examples & Templates

  • asok-examples - Collection of starter templates and reference applications.

Tutorial: Building an Asok Extension

Asok features a highly modular architecture. You can easily bundle reusable controllers, views, assets, template helper functions, and CLI commands into standalone Python packages.

Standard Structure

An Asok extension package typically has the following layout:

my-extension/
├── pyproject.toml
├── README.md
├── my_extension/
│   ├── __init__.py
│   ├── cli.py
│   ├── templates/
│   │   └── my_component.html
│   └── static/
│       └── my_style.css
└── tests/
    └── test_extension.py

1. The Extension Class

Create your core extension by inheriting from AsokExtension. It receives the main Asok app instance inside init_app during registration.

# my_extension/__init__.py
import os
from typing import Any, Optional
from asok.core.extension import AsokExtension
from asok import Asok

class MyExtension(AsokExtension):
    def __init__(self, custom_setting: str = "default"):
        self.custom_setting = custom_setting

    def init_app(self, app: Asok) -> None:
        """Initialize the extension with the Asok application."""
        super().init_app(app)
        
        # Share functions or helpers with Jinja templates
        def greet_helper(name: str) -> str:
            return f"Hello {name}, setting is {self.custom_setting}!"
            
        # Register a template helper (lazy-loaded by Asok)
        app.share(greet=lambda request: greet_helper)

    def get_templates_path(self) -> Optional[str]:
        """Expose custom layout templates or components to the application."""
        return os.path.join(os.path.dirname(__file__), "templates")

    def get_static_path(self) -> Optional[str]:
        """Expose static assets (JS, CSS, images)."""
        return os.path.join(os.path.dirname(__file__), "static")

2. Sharing Template Helpers Correctly

When using app.share(), Asok wraps the helper dynamically to pass the current request context. To prevent premature evaluation, always wrap your template functions in a factory helper:

# Wrap the function in a helper that receives request and returns the actual function
app.share(my_helper=lambda request: actual_helper_function)

In Jinja templates, it can now be called directly:

<div>{{ my_helper("World") }}</div>

3. Exposing Custom CLI Commands

You can register custom CLI commands using Python's standard entry_points.

Add the entry point to your pyproject.toml:

[project.entry-points."asok.commands"]
my_extension_cmd = "my_extension.cli:register_commands"

Implement register_commands in my_extension/cli.py to register custom parsers on Asok's CLI parser:

# my_extension/cli.py
import argparse

def register_commands(subparsers: argparse._SubParsersAction) -> None:
    parser = subparsers.add_parser(
        "my-cmd", 
        help="Run custom commands from my extension"
    )
    parser.add_argument("--name", type=str, default="Guest")
    parser.set_defaults(func=handle_command)

def handle_command(args: argparse.Namespace) -> None:
    print(f"Executing command for: {args.name}")

Once installed, running asok my-cmd --name Alice will execute your handler automatically.

4. Registering the Extension in a Project

Your users can register the extension in their wsgi.py (or bootstrapper file):

from asok import Asok
from my_extension import MyExtension

app = Asok()
app.register_extension(MyExtension(custom_setting="active"))

Contributing

Contributions are very welcome! If you have built an Asok extension, a boilerplate template, a helper library, or a tool, please share it here to help other developers find it.

Please read the Awesome List Guidelines before submitting a pull request.

How to add your project:

  1. Fork this repository.
  2. Add your extension or resource to the appropriate category in alphabetical order.
  3. Provide a short, clear description of what your resource does.
  4. Submit a Pull Request!

About

A curated list of awesome extensions, plugins, resources, templates, and tools for the Asok Framework

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors