or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

assets.mdattachments.mdconfiguration.mdcore-notifications.mdindex.mdlocalization.mdplugin-system.mdstorage.md
tile.json

assets.mddocs/

Assets and Theming

Asset management for customizable themes, icons, branding, and visual elements used in notifications. AppriseAsset provides comprehensive control over the visual appearance and branding of notifications across different services.

Capabilities

AppriseAsset Class

Manages application assets including themes, icons, colors, and branding elements used in notifications.

class AppriseAsset:
    def __init__(self, **kwargs):
        """
        Initialize asset configuration.
        
        Parameters:
        - theme_dir (str, optional): Custom theme directory path
        - image_path_mask (str, optional): Path template for images
        - image_url_mask (str, optional): URL template for hosted images
        - default_html_color (str, optional): Default HTML color code
        - default_extension (str, optional): Default image file extension
        - app_id (str, optional): Application identifier
        - app_desc (str, optional): Application description
        - app_url (str, optional): Application homepage URL
        - image_size (NotifyImageSize, optional): Default image size
        """

    def color(self, notify_type, color_tuple=True):
        """
        Get color for notification type.
        
        Parameters:
        - notify_type (NotifyType): Notification type (INFO, SUCCESS, WARNING, FAILURE)
        - color_tuple (bool): Return as RGB tuple if True, hex string if False
        
        Returns:
        tuple|str: RGB color tuple (r, g, b) or hex color string
        """

    def image_url(self, notify_type, image_size, logo=False, extension=None):
        """
        Get image URL for notification type.
        
        Parameters:
        - notify_type (NotifyType): Notification type
        - image_size (NotifyImageSize): Image size (XY_72, XY_128, XY_256)
        - logo (bool): Get logo image instead of notification icon
        - extension (str, optional): Image file extension
        
        Returns:
        str: URL to the appropriate image
        """

    def image_path(self, notify_type, image_size, must_exist=True, extension=None):
        """
        Get local file path for notification image.
        
        Parameters:
        - notify_type (NotifyType): Notification type
        - image_size (NotifyImageSize): Image size
        - must_exist (bool): Only return path if file exists
        - extension (str, optional): Image file extension
        
        Returns:
        str: Local file path to image or None if not found
        """

    def image_raw(self, notify_type, image_size, extension=None):
        """
        Get raw image data for notification type.
        
        Parameters:
        - notify_type (NotifyType): Notification type
        - image_size (NotifyImageSize): Image size
        - extension (str, optional): Image file extension
        
        Returns:
        bytes: Raw image data or None if not found
        """

    @property
    def theme(self):
        """
        Current theme name.
        
        Returns:
        str: Name of the active theme
        """

    @property
    def image_size(self):
        """
        Default image size for notifications.
        
        Returns:
        NotifyImageSize: Default image size setting
        """

    @property
    def app_id(self):
        """
        Application identifier.
        
        Returns:
        str: Application ID used in notifications
        """

    @property
    def app_desc(self):
        """
        Application description.
        
        Returns:
        str: Application description used in notifications
        """

    @property
    def app_url(self):
        """
        Application homepage URL.
        
        Returns:
        str: Application URL used in notifications
        """

Asset Configuration Options

Theme Settings

  • theme_dir: Directory containing custom theme assets
  • default_extension: Default image file extension (.png, .jpg, etc.)
  • image_path_mask: Template for local image file paths
  • image_url_mask: Template for hosted image URLs

Application Branding

  • app_id: Unique application identifier
  • app_desc: Application description for notifications
  • app_url: Application homepage or documentation URL

Visual Settings

  • default_html_color: Default color for HTML notifications
  • image_size: Default image size for notifications

Built-in Themes

Default Theme

Apprise includes a default theme with standard notification icons:

  • INFO: Blue information icon
  • SUCCESS: Green success/checkmark icon
  • WARNING: Yellow warning/alert icon
  • FAILURE: Red error/X icon

Custom Themes

Custom themes can be created by providing:

  • Theme directory with organized icon files
  • Proper naming convention for notification types
  • Multiple image sizes (72x72, 128x128, 256x256)

Usage Examples

Basic Asset Configuration

import apprise

# Create asset configuration with custom branding
asset = apprise.AppriseAsset(
    app_id='MyApplication',
    app_desc='My Custom Application',
    app_url='https://myapp.example.com',
    default_html_color='#3498db'
)

# Use asset with Apprise
apobj = apprise.Apprise(asset=asset)
apobj.add('mailto://user:pass@gmail.com')

apobj.notify(
    body='Notification with custom branding',
    title='Custom App Alert',
    notify_type=apprise.NotifyType.INFO
)

Color Management

import apprise

asset = apprise.AppriseAsset()

# Get colors for different notification types
info_color = asset.color(apprise.NotifyType.INFO, color_tuple=False)
success_color = asset.color(apprise.NotifyType.SUCCESS, color_tuple=False)
warning_color = asset.color(apprise.NotifyType.WARNING, color_tuple=False)
failure_color = asset.color(apprise.NotifyType.FAILURE, color_tuple=False)

print(f"Info color: {info_color}")        # e.g., "#3498db"
print(f"Success color: {success_color}")  # e.g., "#2ecc71"
print(f"Warning color: {warning_color}")  # e.g., "#f39c12"
print(f"Failure color: {failure_color}")  # e.g., "#e74c3c"

# Get color as RGB tuple
info_rgb = asset.color(apprise.NotifyType.INFO, color_tuple=True)
print(f"Info RGB: {info_rgb}")  # e.g., (52, 152, 219)

Image Management

import apprise

asset = apprise.AppriseAsset()

# Get image URLs for different sizes
small_icon = asset.image_url(
    apprise.NotifyType.SUCCESS,
    apprise.NotifyImageSize.XY_72
)
large_icon = asset.image_url(
    apprise.NotifyType.SUCCESS,
    apprise.NotifyImageSize.XY_256
)

print(f"Small icon URL: {small_icon}")
print(f"Large icon URL: {large_icon}")

# Get local image paths
icon_path = asset.image_path(
    apprise.NotifyType.WARNING,
    apprise.NotifyImageSize.XY_128
)

if icon_path:
    print(f"Warning icon path: {icon_path}")
else:
    print("Warning icon not found locally")

# Get raw image data
icon_data = asset.image_raw(
    apprise.NotifyType.FAILURE,
    apprise.NotifyImageSize.XY_128
)

if icon_data:
    print(f"Icon data size: {len(icon_data)} bytes")
    # Could save to file, embed in email, etc.

Custom Theme Setup

import apprise
import os

# Set up custom theme directory
custom_theme_dir = '/path/to/custom/theme'

# Create asset with custom theme
asset = apprise.AppriseAsset(
    theme_dir=custom_theme_dir,
    default_extension='png',
    app_id='CustomApp',
    app_desc='Application with Custom Icons'
)

# Custom theme should have structure like:
# /path/to/custom/theme/
#   ├── 72x72/
#   │   ├── info.png
#   │   ├── success.png
#   │   ├── warning.png
#   │   └── failure.png
#   ├── 128x128/
#   │   ├── info.png
#   │   ├── success.png
#   │   ├── warning.png
#   │   └── failure.png
#   └── 256x256/
#       ├── info.png
#       ├── success.png
#       ├── warning.png
#       └── failure.png

print(f"Using theme: {asset.theme}")
print(f"Theme directory: {custom_theme_dir}")

# Use custom themed asset
apobj = apprise.Apprise(asset=asset)
apobj.add('slack://token/channel')

apobj.notify(
    body='Message with custom themed icons',
    title='Custom Theme Demo',
    notify_type=apprise.NotifyType.SUCCESS
)

Asset Templates and URL Patterns

import apprise

# Custom asset with URL templates for hosted images
asset = apprise.AppriseAsset(
    image_url_mask='https://cdn.example.com/icons/{THEME}/{TYPE}-{SIZE}.{EXTENSION}',
    image_path_mask='/local/themes/{THEME}/{SIZE}/{TYPE}.{EXTENSION}',
    default_extension='svg',
    app_id='WebApp',
    app_desc='Web Application Notifications'
)

# Templates will resolve placeholders:
# {THEME} -> theme name
# {TYPE} -> notification type (info, success, warning, failure)
# {SIZE} -> image size (72x72, 128x128, 256x256)
# {EXTENSION} -> file extension

# Get templated URL
icon_url = asset.image_url(
    apprise.NotifyType.INFO,
    apprise.NotifyImageSize.XY_128
)
print(f"Templated URL: {icon_url}")
# Result: https://cdn.example.com/icons/default/info-128x128.svg

Dynamic Asset Configuration

import apprise

def create_branded_asset(brand_config):
    """Create asset configuration based on brand settings."""
    return apprise.AppriseAsset(
        app_id=brand_config.get('app_name', 'Application'),
        app_desc=brand_config.get('description', 'Notification System'),
        app_url=brand_config.get('website', ''),
        default_html_color=brand_config.get('primary_color', '#007bff'),
        theme_dir=brand_config.get('theme_path'),
        image_size=getattr(apprise.NotifyImageSize, 
                          brand_config.get('icon_size', 'XY_128'))
    )

# Brand configurations for different environments
dev_brand = {
    'app_name': 'MyApp (Development)',
    'description': 'Development Environment Notifications',
    'primary_color': '#ffc107',
    'icon_size': 'XY_72'
}

prod_brand = {
    'app_name': 'MyApp',
    'description': 'Production Application',
    'website': 'https://myapp.com',
    'primary_color': '#28a745',
    'icon_size': 'XY_128',
    'theme_path': '/opt/myapp/themes'
}

# Create environment-specific assets
dev_asset = create_branded_asset(dev_brand)
prod_asset = create_branded_asset(prod_brand)

# Use appropriate asset based on environment
import os
environment = os.getenv('ENVIRONMENT', 'development')

if environment == 'production':
    asset = prod_asset
else:
    asset = dev_asset

print(f"Using asset for {environment}:")
print(f"  App ID: {asset.app_id}")
print(f"  Description: {asset.app_desc}")
print(f"  Default size: {asset.image_size}")

Asset Integration with Services

import apprise

# Different services may use assets differently
asset = apprise.AppriseAsset(
    app_id='MultiService App',
    app_desc='Cross-platform Notifications',
    default_html_color='#663399'
)

# Email services can use full branding
email_obj = apprise.Apprise(asset=asset)
email_obj.add('mailto://user:pass@gmail.com')

# Slack may use app name and colors
slack_obj = apprise.Apprise(asset=asset)
slack_obj.add('slack://token/channel')

# Discord may use different aspects of assets
discord_obj = apprise.Apprise(asset=asset)
discord_obj.add('discord://webhook_id/webhook_token')

# Each service will utilize asset information appropriately
for obj, service in [(email_obj, 'Email'), (slack_obj, 'Slack'), (discord_obj, 'Discord')]:
    obj.notify(
        body=f'Asset test for {service}',
        title='Asset Integration Test',
        notify_type=apprise.NotifyType.INFO
    )

Asset Validation and Debugging

import apprise

asset = apprise.AppriseAsset(
    theme_dir='/path/to/theme',
    app_id='TestApp'
)

# Validate theme assets exist
for notify_type in [apprise.NotifyType.INFO, apprise.NotifyType.SUCCESS, 
                   apprise.NotifyType.WARNING, apprise.NotifyType.FAILURE]:
    for size in [apprise.NotifyImageSize.XY_72, apprise.NotifyImageSize.XY_128, 
                apprise.NotifyImageSize.XY_256]:
        
        # Check if local image exists
        local_path = asset.image_path(notify_type, size, must_exist=True)
        
        # Get URL whether or not local exists
        image_url = asset.image_url(notify_type, size)
        
        print(f"{notify_type.upper()} {size}:")
        print(f"  Local: {local_path or 'Not found'}")
        print(f"  URL: {image_url}")
        print(f"  Color: {asset.color(notify_type, color_tuple=False)}")
        print()

# Asset properties
print("Asset Configuration:")
print(f"  Theme: {asset.theme}")
print(f"  App ID: {asset.app_id}")
print(f"  App Description: {asset.app_desc}")
print(f"  App URL: {asset.app_url}")
print(f"  Default Image Size: {asset.image_size}")