2
0
mirror of https://github.com/inventree/inventree-docs.git synced 2025-04-27 13:16:43 +00:00
inventree-docs/main.py
Oliver dfbf1293cb Simpler gallery
- use splide.js
- iterate though a directory automatically
2021-08-10 20:32:49 +10:00

29 lines
593 B
Python

import os
from posixpath import dirname
def define_env(env):
@env.macro
def listimages(subdir):
"""
Return a listing of all asset files in the provided subdir
"""
here = os.path.dirname(__file__)
directory = os.path.join(here, 'docs', 'assets', 'images', subdir)
assets = []
allowed = [
'.png',
'.jpg',
]
for asset in os.listdir(directory):
if any([asset.endswith(x) for x in allowed]):
assets.append(os.path.join(subdir, asset))
return assets