Compare commits

..

3 Commits

Author SHA1 Message Date
Leo Vasanko
20a5c66e77 Point to Bun install instructions. 2025-08-13 10:49:23 -07:00
Leo Vasanko
05cc823e37 Support HDR image formats 2025-08-13 10:28:49 -07:00
Leo Vasanko
3a65277994 Build frontend using bun if found. 2025-08-13 10:28:30 -07:00
4 changed files with 24 additions and 10 deletions

View File

@ -17,6 +17,9 @@ from sanic.log import logger
from cista import config
from cista.util.filename import sanitize
import pillow_heif
pillow_heif.register_heif_opener()
bp = Blueprint("preview", url_prefix="/preview")

View File

@ -101,7 +101,7 @@ const video = () => ['mkv', 'mp4', 'webm', 'mov', 'avi'].includes(props.doc.ext)
const audio = () => ['mp3', 'flac', 'ogg', 'aac'].includes(props.doc.ext)
const archive = () => ['zip', 'tar', 'gz', 'bz2', 'xz', '7z', 'rar'].includes(props.doc.ext)
const preview = () => (
['bmp', 'ico', 'tif', 'tiff', 'pdf'].includes(props.doc.ext) ||
['bmp', 'ico', 'tif', 'tiff', 'heic', 'heif', 'pdf', 'epub', 'mobi'].includes(props.doc.ext) ||
props.doc.size > 500000 &&
['avif', 'webp', 'png', 'jpg', 'jpeg'].includes(props.doc.ext)
)

View File

@ -24,6 +24,7 @@ dependencies = [
"natsort",
"pathvalidate",
"pillow",
"pillow-heif>=1.1.0",
"pyjwt",
"pymupdf",
"sanic",

View File

@ -11,17 +11,27 @@ class CustomBuildHook(BuildHookInterface):
def initialize(self, version, build_data):
super().initialize(version, build_data)
stderr.write(">>> Building Cista frontend\n")
npm = None
bun = shutil.which("bun")
if bun is None:
npm = shutil.which("npm")
if npm is None:
raise RuntimeError(
"NodeJS `npm` is required for building Cista but it was not found"
"Bun or NodeJS `npm` is required for building but neither was found\n Visit https://bun.com/"
)
# npm --prefix doesn't work on Windows, so we chdir instead
os.chdir("frontend")
try:
if npm:
stderr.write("### npm install\n")
subprocess.run([npm, "install"], check=True) # noqa: S603
stderr.write("\n### npm run build\n")
subprocess.run([npm, "run", "build"], check=True) # noqa: S603
else:
assert bun
stderr.write("### bun install\n")
subprocess.run([bun, "install"], check=True) # noqa: S603
stderr.write("\n### bun run build\n")
subprocess.run([bun, "run", "build"], check=True) # noqa: S603
finally:
os.chdir("..")