This commit is contained in:
2025-11-27 19:13:42 +01:00
parent 9ce21b7242
commit 63ad5e807b
5 changed files with 40 additions and 26 deletions

View File

@@ -1,8 +1,8 @@
features:
matomo: true
css: true
desktop: true
logout: false
css: true
matomo: true
desktop: true
logout: false
server:
csp:

View File

@@ -0,0 +1,30 @@
def littlejs_href(example, protocol, domain):
"""
Build correct LittleJS example URL based on whether it is a full project
or a single-file example.
:param example: dict with keys 'is_project' and 'file'
:param protocol: http or https
:param domain: the domain to use (e.g. littlejs.example.com)
:return: string URL
"""
file = example.get("file")
is_project = example.get("is_project", False)
if not file:
return "#"
# Full examples: always absolute URL
if is_project:
return f"{protocol}://{domain}/examples/{file}/"
# Short examples: internal wrapper
return f"{protocol}://{domain}/examples/shorts/base.html?file={file}"
class FilterModule(object):
def filters(self):
return {
"littlejs_href": littlejs_href
}

View File

@@ -11,12 +11,7 @@
{% for key, cat in littlejs_examples|dictsort %}
{% for ex in cat['items'] %}
{% if ex.is_project %}
{% set href = "/examples/" ~ ex.file ~ "/" %}
{% else %}
{% set href = "/examples/shorts/base.html?file=" ~ ex.file %}
{% endif %}
{% set href = ex | littlejs_href(WEB_PROTOCOL, domain) %}
<div class="col-12 col-md-6 col-lg-4 col-xl-3">
<div class="card app-card h-100">
<div class="card-body d-flex flex-column">

View File

@@ -30,15 +30,9 @@
</a>
<ul class="dropdown-menu dropdown-menu-dark">
{# FIXED: cat['items'] #}
{% for ex in cat['items'] %}
{% if ex.is_project %}
{% set href = "/examples/" ~ ex.file ~ "/" %}
{% else %}
{% set href = "/examples/shorts/base.html?file=" ~ ex.file %}
{% endif %}
{% set href = ex | littlejs_href(WEB_PROTOCOL, domain) %}
<li>
<a class="dropdown-item d-flex align-items-center" href="{{ href }}">
<i class="{{ ex.icon }} me-2"></i>{{ ex.name }}

View File

@@ -1,16 +1,11 @@
# General
application_id: "web-app-littlejs"
entity_name: "{{ application_id | get_entity_name }}"
domain: "{{ domains | get_domain(application_id) }}"
# Features
features:
css: true
matomo: true
desktop: true
LITTLEJS_HEADLINE: "LittleJS Playground"
LITTLEJS_HEADLINE: ""
LITTLEJS_TITLE: "LittleJS Playground {{ PRIMARY_DOMAIN | upper }}"
LITTLEJS_TITLE: "{{ LITTLEJS_HEADLINE }} {{ PRIMARY_DOMAIN | upper }}"
# Base repository URL for LittleJS
LITTLEJS_REPOSITORY_BASE: "https://github.com/KilledByAPixel/LittleJS"