5 Commits
Author SHA1 Message Date
Shaun Kruger 23218b15f5 Replace readme
Build and publish / cleanup (pull_request) Successful in 1m4s
Build and publish / test (pull_request) Skipped
Build and publish / build (pull_request) Skipped
Build and publish / pypi (pull_request) Skipped
2026-12-03 09:48:36 -07:00
Shaun KrugerandClaude Opus 5.5 5d7d03a0a6 Use setup-uv instead of setup-python in CI
Build and publish / test (pull_request) Successful in 36s
Build and publish / cleanup (pull_request) Skipped
Build and publish / build (pull_request) Successful in 3m32s
Build and publish / pypi (pull_request) Skipped
actions/setup-python only ships binaries for Ubuntu releases, so it fails
on the Debian-based Gitea act_runner image. setup-uv installs portable
Python builds that work on any glibc Linux.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-02 14:11:03 -07:00
Shaun KrugerandClaude Opus 5.5 38f3a0da2f Add Docker image, Gitea CI, PyPI publishing and BSD-3-Clause license
Build and publish / test (pull_request) Failing after 40s
Build and publish / cleanup (pull_request) Skipped
Build and publish / build (pull_request) Skipped
Build and publish / pypi (pull_request) Skipped
- Dockerfile builds the npm bundle and serves the app with gunicorn
- Gitea workflow runs tests, tags releases on main, pushes the image to
  the Gitea registry, and publishes to PyPI when PYPI_TOKEN is set
- MANIFEST.in includes the built static bundle in distributions
- License the project under BSD-3-Clause

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-01 23:42:20 -07:00
skruger ba76671795 Merge pull request 'Add content assets for cataloging uploaded files' (#3) from asset_catalog into main
Reviewed-on: #3
2026-12-01 21:11:53 -07:00
Shaun Kruger 7231f69014 Fix italics in html editor 2026-12-01 21:00:59 -07:00
12 changed files with 411 additions and 4 deletions
+21
View File
@@ -0,0 +1,21 @@
.git/
.gitea/
.github/
.idea/
.vscode/
.venv/
venv/
.pytest_cache/
node_modules/
storage/
static/
dist/
build/
*.egg-info/
**/__pycache__
*.pyc
*.sqlite3
*.db
privatestudio/_version.py
privatestudio/settings/local.py
privatestudio/static/bundle/
+215
View File
@@ -0,0 +1,215 @@
name: Build and publish
on:
push:
branches: [ main ]
pull_request:
types: [opened, synchronize, reopened, closed]
workflow_dispatch: {}
permissions:
contents: write
packages: write
env:
REGISTRY: git.krugerprojects.com
IMAGE_NAME: skruger/privatestudio
jobs:
test:
if: github.event.action != 'closed'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: astral-sh/setup-uv@v6
with:
python-version: "3.13"
activate-environment: true
- name: Install package
run: uv pip install -e ".[dev]"
- name: Run tests
run: pytest
build:
if: github.event.action != 'closed'
needs: test
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
version: ${{ steps.tag.outputs.version }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine image tags
id: tag
run: |
set -euo pipefail
git fetch --tags
current_tag=$(git tag --points-at HEAD | head -n1)
if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then
PR_NUMBER=$(echo "$GITHUB_REF" | cut -d'/' -f3)
TAG="pr-${PR_NUMBER}"
VERSION="0.0.0.dev${PR_NUMBER}"
tags="${TAG} ${GITHUB_SHA::7}"
elif [ -n "$current_tag" ]; then
echo "Head already tagged: $current_tag"
TAG="$current_tag"
VERSION=${TAG#v}
tags="latest ${VERSION} ${GITHUB_SHA::7}"
else
latest_tag=$(git tag --sort=-v:refname | head -n1 || true)
if [ -z "$latest_tag" ]; then
latest_tag="v0.0.0"
fi
sem=${latest_tag#v}
IFS='.' read -r major minor patch <<< "${sem}"
major=${major:-0}
minor=${minor:-0}
patch=${patch:-0}
patch=$((patch+1))
TAG="v${major}.${minor}.${patch}"
git config user.name "gitea-actions"
git config user.email "gitea-actions@git.krugerprojects.com"
git tag -a "$TAG" -m "Release $TAG"
git push origin "$TAG"
VERSION=${TAG#v}
tags="latest ${VERSION} ${GITHUB_SHA::7}"
fi
echo "Determined tag: $TAG, version: $VERSION, image tags: $tags"
echo "tag=$TAG" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tags=$tags" >> $GITHUB_OUTPUT
- name: Install dependencies
run: apt-get update && apt-get install -y podman
- name: Login to registry
run: |
echo -e "${{ secrets.PACKAGE_ACCESS_TOKEN }}" | \
podman login ${REGISTRY} -u "${{ vars.PACKAGE_USERNAME }}" --password-stdin
- name: Build image
run: |
set -euo pipefail
IMAGE="${REGISTRY}/${IMAGE_NAME}"
buildah bud --userns=host -f Dockerfile \
--build-arg VERSION="${{ steps.tag.outputs.version }}" \
-t "${IMAGE}:build" .
for t in ${{ steps.tag.outputs.tags }}; do
echo "Tag: ${IMAGE}:${t}"
buildah tag "${IMAGE}:build" "${IMAGE}:${t}"
done
- name: Push image
run: |
set -euo pipefail
IMAGE="${REGISTRY}/${IMAGE_NAME}"
for t in ${{ steps.tag.outputs.tags }}; do
echo "Push: ${IMAGE}:${t}"
buildah push "${IMAGE}:${t}"
done
pypi:
# Only publish releases from main, and only when a PyPI token is configured.
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
env:
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
steps:
- name: Check for PyPI token
run: |
if [ -z "$PYPI_TOKEN" ]; then
echo "PYPI_TOKEN secret is not set; skipping PyPI publish."
fi
- name: Checkout repository
if: env.PYPI_TOKEN != ''
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node
if: env.PYPI_TOKEN != ''
uses: actions/setup-node@v4
with:
node-version: "24"
- name: Build static bundle
if: env.PYPI_TOKEN != ''
run: |
mkdir -p privatestudio/static/bundle
npm ci
npm run build
- name: Set up Python
if: env.PYPI_TOKEN != ''
uses: astral-sh/setup-uv@v6
with:
python-version: "3.13"
activate-environment: true
- name: Build distributions
if: env.PYPI_TOKEN != ''
env:
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ needs.build.outputs.version }}
run: |
uv pip install build twine
python -m build
twine check dist/*
- name: Publish to PyPI
if: env.PYPI_TOKEN != ''
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
run: twine upload --non-interactive dist/*
cleanup:
# Only run when a pull request is closed and merged
if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Install jq
run: |
apt-get update && apt-get install -y jq
- name: Delete PR images from Gitea package registry
env:
GITEA_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SERVER: ${{ gitea.server_url }}
OWNER: skruger
PACKAGE: privatestudio
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
set -euo pipefail
echo "Cleaning up Gitea registry images for PR #$PR_NUMBER"
AUTH_HEADER="Authorization: token ${GITEA_TOKEN}"
LIST_URL="${SERVER}/api/v1/packages/${OWNER}?type=container&q=${PACKAGE}&limit=50"
VERSIONS_JSON=$(curl -s -H "$AUTH_HEADER" "$LIST_URL")
MATCHES=$(echo "$VERSIONS_JSON" | jq -r --arg pr "pr-$PR_NUMBER" \
'.[] | select(.version == $pr) | .version')
if [ -z "$(echo "$MATCHES" | tr -d '\n')" ]; then
echo "No image versions found for PR #$PR_NUMBER"
exit 0
fi
for VERSION in $MATCHES; do
echo "Deleting package version $VERSION"
curl -s -X DELETE -H "$AUTH_HEADER" \
"${SERVER}/api/v1/packages/${OWNER}/container/${PACKAGE}/${VERSION}" \
|| echo "Failed to delete package version $VERSION"
done
echo "Cleanup complete."
+50
View File
@@ -0,0 +1,50 @@
FROM node:24 AS nodebuild
WORKDIR /build
COPY package.json package-lock.json ./
RUN npm ci
COPY webpack.config.js ./
COPY src ./src
COPY privatestudio ./privatestudio
RUN mkdir -p privatestudio/static/bundle && npm run build
FROM python:3.13-slim-trixie
# Version used by setuptools_scm, since .git is not copied into the image.
ARG VERSION=0.0.0
RUN useradd --create-home privatestudio
EXPOSE 8000
ENV PYTHONUNBUFFERED=1 \
PORT=8000 \
DJANGO_SETTINGS_MODULE=privatestudio.settings.production \
STORAGE_PATH=/data/storage
RUN pip install --no-cache-dir "gunicorn~=23.0" "psycopg2-binary~=2.9.11"
WORKDIR /app
COPY --chown=privatestudio:privatestudio . .
COPY --from=nodebuild --chown=privatestudio:privatestudio /build/privatestudio/static/bundle ./privatestudio/static/bundle
RUN SETUPTOOLS_SCM_PRETEND_VERSION="${VERSION}" pip install --no-cache-dir . \
&& mkdir -p /data/storage && chown -R privatestudio:privatestudio /data /app
USER privatestudio
RUN python manage.py collectstatic --noinput --clear
VOLUME ["/data"]
# Migrating at startup keeps "docker run" simple. Use a release step instead if
# you run more than one container against the same database.
CMD set -xe; \
python manage.py migrate --noinput; \
exec gunicorn privatestudio.wsgi:application \
--bind 0.0.0.0:${PORT} \
-k gthread --workers 2 --threads 8 --timeout 600
+28
View File
@@ -0,0 +1,28 @@
BSD 3-Clause License
Copyright (c) 2026, Shaun Kruger
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+3
View File
@@ -0,0 +1,3 @@
# The JS/CSS bundle is built by npm and is not tracked in git, so
# setuptools_scm will not pick it up on its own.
graft privatestudio/static/bundle
+1 -1
View File
@@ -14,7 +14,7 @@
"build:digitalocean": "npm install --production=false && npm run build" "build:digitalocean": "npm install --production=false && npm run build"
}, },
"author": "Shaun Kruger", "author": "Shaun Kruger",
"license": "ISC", "license": "BSD-3-Clause",
"private": true, "private": true,
"engines": { "engines": {
"node": "v24.22.x", "node": "v24.22.x",
+2
View File
@@ -14,6 +14,8 @@ NH3_TAGS = {
"b", "b",
"s", "s",
"u", "u",
"i",
"em",
} }
NH3_ATTR = { NH3_ATTR = {
+7
View File
@@ -14,6 +14,13 @@ if os.environ.get("DATABASE_URL"):
DATABASES = { DATABASES = {
"default": dj_database_url.config(), "default": dj_database_url.config(),
} }
else:
DATABASES = {
"default": {
"ENGINE": "django.db.backends.sqlite3",
"NAME": os.path.join("/data", "db.sqlite3"),
}
}
CORS_ALLOWED_ORIGINS = [o for o in os.environ.get("CORS_ALLOWED_ORIGINS", "").split(",") if o] CORS_ALLOWED_ORIGINS = [o for o in os.environ.get("CORS_ALLOWED_ORIGINS", "").split(",") if o]
@@ -1,4 +1,4 @@
<nav class="studio-navbar navbar navbar-expand-lg navbar-dark bg-dark navbar-fixed-top justify-content-between"> <nav class="studio-navbar navbar navbar-expand-lg navbar-light bg-light navbar-fixed-top justify-content-between">
<div class="container"> <div class="container">
<a class="navbar-brand" href="/">Private Studio</a> <a class="navbar-brand" href="/">Private Studio</a>
<button class="navbar-toggler" data-bs-toggle="collapse" data-bs-target="#navbarContainer" aria-expanded="false" aria-controls="navbarContainer" aria-label="Toggle Navigation"> <button class="navbar-toggler" data-bs-toggle="collapse" data-bs-target="#navbarContainer" aria-expanded="false" aria-controls="navbarContainer" aria-label="Toggle Navigation">
+64
View File
@@ -0,0 +1,64 @@
import re
from django.contrib.auth.models import User
from django.urls import reverse
from privatestudio.studio.auth import hash_api_key, user_for_api_key
from privatestudio.studio.models import APIKey
from privatestudio.studio.tests.base import StudioTestCase
ADD_URL = reverse("admin:studio_apikey_add")
LIST_URL = reverse("admin:studio_apikey_changelist")
TOKEN_RE = re.compile(r"<code>([^<]+)</code>")
class APIKeyAdminTests(StudioTestCase):
def setUp(self):
super().setUp()
self.client.force_login(User.objects.create_superuser("admin"))
self.existing = APIKey.objects.get()
self.change_url = reverse("admin:studio_apikey_change", args=[self.existing.pk])
def form_data(self, **extra):
return {
"user": self.user.pk,
"created_at_0": "2026-01-01",
"created_at_1": "12:00:00",
"is_active": "on",
**extra,
}
def add_key(self):
"""Submit the add form and return the token shown to the admin."""
response = self.client.post(ADD_URL, self.form_data(), follow=True)
self.assertRedirects(response, LIST_URL)
return TOKEN_RE.search(response.content.decode()).group(1)
def test_add_shows_working_token_once(self):
token = self.add_key()
self.assertEqual(APIKey.objects.get(key_hash=hash_api_key(token)).user, self.user)
self.assertEqual(user_for_api_key(token), self.user)
self.assertNotContains(self.client.get(LIST_URL), token)
def test_each_key_is_unique(self):
self.assertNotEqual(self.add_key(), self.add_key())
self.assertEqual(APIKey.objects.count(), 3)
def test_submitted_key_hash_is_ignored(self):
self.client.post(ADD_URL, self.form_data(key_hash=hash_api_key("chosen")))
self.assertIsNone(user_for_api_key("chosen"))
def test_change_keeps_hash_and_shows_no_token(self):
data = self.form_data()
del data["is_active"]
response = self.client.post(self.change_url, data, follow=True)
self.assertRedirects(response, LIST_URL)
self.assertIsNone(TOKEN_RE.search(response.content.decode()))
original_hash = self.existing.key_hash
self.existing.refresh_from_db()
self.assertEqual(self.existing.key_hash, original_hash)
self.assertFalse(self.existing.is_active)
def test_key_hash_only_on_change_form(self):
self.assertNotContains(self.client.get(ADD_URL), "field-key_hash")
self.assertContains(self.client.get(self.change_url), self.existing.key_hash)
+5 -2
View File
@@ -1,11 +1,13 @@
[build-system] [build-system]
requires = ["setuptools>=68", "setuptools_scm[toml]>=8", "wheel"] requires = ["setuptools>=77", "setuptools_scm[toml]>=8", "wheel"]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[project] [project]
name = "privatestudio" name = "privatestudio"
description = "Video transcoding tools with multi-profile H.264 encoding support" description = "Video transcoding tools with multi-profile H.264 encoding support"
readme = "notes.md" readme = "README.md"
license = "BSD-3-Clause"
license-files = ["LICENSE"]
requires-python = ">=3.12" requires-python = ">=3.12"
dependencies = [ dependencies = [
"PyYAML>=6.0", "PyYAML>=6.0",
@@ -26,6 +28,7 @@ dev = [
"pytest-cov>=4.0", "pytest-cov>=4.0",
"pytest-django>=4.14", "pytest-django>=4.14",
"boto3", "boto3",
"build",
] ]
[project.scripts] [project.scripts]
+14
View File
@@ -6,6 +6,20 @@ $h4-font-size: $font-size-base * 1.25 !default;
$h5-font-size: $font-size-base * 1.15 !default; $h5-font-size: $font-size-base * 1.15 !default;
$h6-font-size: $font-size-base !default; $h6-font-size: $font-size-base !default;
$white: #ffffff;
$theme-colors: (
"light": #fdc8b2,
"dark": #e4440f,
"primary": #18499b,
"secondary": #a65d66,
"info": #da9a37,
"success": #17a762,
"warning": #e3cc17,
"danger": #f31b0a,
);
@import "bootstrap/scss/bootstrap"; @import "bootstrap/scss/bootstrap";
form.simpleform input[type=text], form.simpleform textarea { form.simpleform input[type=text], form.simpleform textarea {