Initiales Karate-Wiki Setup (Docker, LocalSettings, KarateMedia Video-Extension)
This commit is contained in:
commit
53aec82f7d
17 files changed
+763
No files matched your search
@@ -0,0 +1,30 @@
|
||||
# ============================================================================
|
||||
# Karate-Wiki (Goju-Kai Dojo) - Umgebungsvariablen (Vorlage)
|
||||
# Kopiere diese Datei nach .env und trage die echten Zugangsdaten ein.
|
||||
# Die .env Datei wird durch .gitignore NIEMALS in Gitea hochgeladen!
|
||||
# ============================================================================
|
||||
|
||||
# --- MediaWiki Basis-URL ---
|
||||
# Fuer lokalen Docker-Test z.B. http://localhost:8080
|
||||
# Fuer Produktion: https://www.gojukai-dojo.de
|
||||
MW_SERVER=http://localhost:8080
|
||||
MW_SITENAME=Karate
|
||||
|
||||
# --- Datenbank-Einstellungen (im Docker: Container "db") ---
|
||||
MW_DB_HOST=db
|
||||
MW_DB_NAME=dbs1754262
|
||||
MW_DB_USER=dbu1061679
|
||||
MW_DB_PASSWORD=hier_sicheres_passwort_eintragen
|
||||
MW_DB_ROOT_PASSWORD=hier_root_passwort_eintragen
|
||||
MW_DB_PREFIX=Karate_
|
||||
|
||||
# --- MediaWiki Sicherheitsschluessel (aus bestehender LocalSettings.php) ---
|
||||
MW_SECRET_KEY=hier_wgSecretKey_eintragen
|
||||
MW_UPGRADE_KEY=hier_wgUpgradeKey_eintragen
|
||||
|
||||
# --- Strato SSH-Zugang (fuer Backup-/Sync-Skripte, rein lesend) ---
|
||||
STRATO_SSH_HOST=51539426.ssh.w1.strato.hosting
|
||||
STRATO_SSH_USER=stu100093250
|
||||
STRATO_SSH_KEY=~/.ssh/strato_fewo
|
||||
STRATO_WIKI_PATH=Karate_Wiki_135
|
||||
STRATO_PHP_CLI=/opt/RZphp84/bin/php-cli
|
||||
@@ -0,0 +1,6 @@
|
||||
* text=auto eol=lf
|
||||
*.ps1 text eol=crlf
|
||||
*.bat text eol=crlf
|
||||
*.png binary
|
||||
*.jpg binary
|
||||
*.gif binary
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
# Secrets & lokale Umgebungsvariablen
|
||||
.env
|
||||
.env.local
|
||||
|
||||
# Medien-Dateien (Videos/Bilder aus dem Wiki - nicht ins Git!)
|
||||
data/
|
||||
images/
|
||||
backups/
|
||||
*.sql
|
||||
*.sql.gz
|
||||
*.tar.gz
|
||||
|
||||
# Editor / OS
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
.vscode/
|
||||
.idea/
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
# ============================================================================
|
||||
# Karate-Wiki Dockerfile
|
||||
# Standardmaessig auf MediaWiki 1.43 LTS (kompatibel mit PHP 8.3 / 8.4)
|
||||
# Kann zum Testen des Altsystems auch mit --build-arg MW_VERSION=1.39 gebaut werden
|
||||
# ============================================================================
|
||||
ARG MW_VERSION=1.43
|
||||
FROM mediawiki:${MW_VERSION}
|
||||
|
||||
# Pakete fuer Video-Vorschaubilder (ffmpeg) & Bildverarbeitung installieren
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
ffmpeg \
|
||||
imagemagick \
|
||||
unzip \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# PHP Upload-Limits fuer grosse Karate-Videos (500 MB)
|
||||
COPY config/php-uploads.ini /usr/local/etc/php/conf.d/zz-karate-uploads.ini
|
||||
|
||||
# Vereins-Logo ins Image kopieren
|
||||
COPY assets/logo_goju-kai_Bleistift.png /var/www/html/resources/assets/logo_goju-kai_Bleistift.png
|
||||
|
||||
# Unsere eigene, wartungsfreie Video-Extension (ersetzt Html5mediator & EmbedVideo)
|
||||
COPY extensions-custom/KarateMedia /var/www/html/extensions/KarateMedia
|
||||
@@ -0,0 +1,64 @@
|
||||
# Karate-Wiki (Goju-Kai Dojo) – Infrastruktur & Eigene Erweiterungen
|
||||
|
||||
Dieses Repository enthält **ausschließlich** die Konfiguration, das Docker-Setup und unsere selbst entwickelten Erweiterungen für das Karate-Wiki (`https://www.gojukai-dojo.de`).
|
||||
Der MediaWiki-Core (~20.000 Dateien), Passwörter (`.env`) und die Mediendateien (`images/`, ca. 8,3 GB Videos) werden bewusst **nicht** im Git gespeichert.
|
||||
|
||||
---
|
||||
|
||||
## 📁 Verzeichnisstruktur
|
||||
|
||||
```text
|
||||
C:\dev\Karatewiki\
|
||||
├── .env.example # Vorlage für Datenbank-Zugangsdaten & Keys (nach .env kopieren)
|
||||
├── .gitignore # Schützt Passwörter (.env), DB-Dumps & Videos vor Git-Upload
|
||||
├── Dockerfile # Baut MediaWiki 1.43 LTS (PHP 8.3/8.4) + KarateMedia Extension
|
||||
├── docker-compose.yml # Startet MediaWiki + MariaDB 10.11
|
||||
├── assets/
|
||||
│ └── logo_goju-kai_Bleistift.png # Vereinslogo
|
||||
├── config/
|
||||
│ ├── LocalSettings.php # Bereinigte Wiki-Konfiguration (für Docker UND Strato nutzbar)
|
||||
│ └── php-uploads.ini # Erhöht Upload-Limit auf 500 MB für Karate-Videos
|
||||
├── extensions-custom/
|
||||
│ └── KarateMedia/ # Eigene HTML5-Video-Extension (inkl. Zeitlupe 0.5x/0.25x & Loop)
|
||||
└── scripts/
|
||||
├── sync-from-strato.ps1 # Holt DB-Dump (rein lesend) unter Windows
|
||||
└── sync-from-strato.sh # Holt DB-Dump & Videos (per rsync) unter Linux
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🥋 Die eigene Extension: `KarateMedia`
|
||||
|
||||
Im bisherigen Produktiv-Wiki waren zwei veraltete Plugins gleichzeitig aktiv (`Html5mediator` und `EmbedVideo v2.9.0`), die unter PHP 8.3/8.4 und neuen MediaWiki-Versionen Fehler verursachen.
|
||||
Unsere eigene Extension **`KarateMedia`** ([`extension.json`](extensions-custom/KarateMedia/extension.json)) ersetzt **beide** komplett wartungsfrei:
|
||||
|
||||
1. **Abwärtskompatibel für alle 87 Seiten mit `<html5media>`:**
|
||||
```xml
|
||||
<html5media height="200">File:SeienchinOsaeUke.mp4</html5media>
|
||||
```
|
||||
2. **Abwärtskompatibel für alle ~71 Seiten mit Standard-Datei-Links:**
|
||||
```wikitext
|
||||
[[Datei:Seienchin2.mp4|mini|Seienchin von vorne]]
|
||||
[[File:Shisoshin_Funsako_Sensei.mp4|300x169px]]
|
||||
```
|
||||
3. **Trainings-Features direkt integriert:**
|
||||
Unter jedem Video befindet sich eine kompakte Steuerleiste mit **`1x` | `0.5x` | `0.25x` | `Loop`**, um Kata- und Bunkai-Sequenzen direkt in Zeitlupe oder Endlosschleife zu studieren.
|
||||
|
||||
---
|
||||
|
||||
## 🚀 Schnellstart (Docker-Umgebung / Failover-Server)
|
||||
|
||||
1. **`.env` anlegen:**
|
||||
Kopiere `.env.example` nach `.env` und trage die gewünschten Passwörter ein.
|
||||
2. **Datenbank-Dump von Strato holen (rein lesend):**
|
||||
* Windows: `.\scripts\sync-from-strato.ps1`
|
||||
* Linux: `./scripts/sync-from-strato.sh`
|
||||
3. **Container starten:**
|
||||
```bash
|
||||
docker compose up -d --build
|
||||
```
|
||||
4. **Datenbank-Schema auf die neue MediaWiki-Version aktualisieren (im Container):**
|
||||
```bash
|
||||
docker compose exec mediawiki php maintenance/run.php update --quick
|
||||
```
|
||||
Danach ist das Wiki unter `http://localhost:8080` erreichbar!
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
/**
|
||||
* Bereinigte & modernisierte LocalSettings.php fuer das Karate-Wiki (Goju-Kai Dojo)
|
||||
* Funktioniert sowohl in der Docker-Umgebung (ueber .env Umgebungsvariablen)
|
||||
* als auch auf dem Strato-Server (ueber LocalSettings.secrets.php).
|
||||
*/
|
||||
|
||||
if ( !defined( 'MEDIAWIKI' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
// Optional lokale Secrets-Datei laden (fuer Strato-Server ohne Docker, nicht im Git!)
|
||||
if ( file_exists( __DIR__ . '/LocalSettings.secrets.php' ) ) {
|
||||
require_once __DIR__ . '/LocalSettings.secrets.php';
|
||||
} elseif ( file_exists( "$IP/LocalSettings.secrets.php" ) ) {
|
||||
require_once "$IP/LocalSettings.secrets.php";
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 1. Upload-Limits & iOS/Safari Video-Streaming Fix
|
||||
// ----------------------------------------------------------------------------
|
||||
$wgUploadSizeWarning = 2147483647;
|
||||
$wgMaxUploadSize = 2147483647;
|
||||
|
||||
// Wichtig fuer iOS/Safari MP4 Byte-Range Video-Streaming (Phabricator T235554)
|
||||
$wgDisableOutputCompression = true;
|
||||
setlocale( LC_NUMERIC, 'C' );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 2. Basis-Einstellungen & URLs
|
||||
// ----------------------------------------------------------------------------
|
||||
$wgSitename = getenv( 'MW_SITENAME' ) ?: 'Karate';
|
||||
$wgMetaNamespace = 'Karate';
|
||||
$wgLanguageCode = 'de';
|
||||
|
||||
$wgScriptPath = '';
|
||||
$wgScriptExtension = '.php';
|
||||
$wgServer = getenv( 'MW_SERVER' ) ?: ( $wgServer ?? 'https://www.gojukai-dojo.de' );
|
||||
|
||||
$wgStylePath = "$wgScriptPath/skins";
|
||||
$wgResourceBasePath = $wgScriptPath;
|
||||
$wgLogo = "$wgResourceBasePath/resources/assets/logo_goju-kai_Bleistift.png";
|
||||
$wgLogos = [
|
||||
'1x' => $wgLogo,
|
||||
'icon' => $wgLogo,
|
||||
];
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 3. E-Mail-Konfiguration
|
||||
// ----------------------------------------------------------------------------
|
||||
$wgEnableEmail = true;
|
||||
$wgEnableUserEmail = true;
|
||||
$wgEmergencyContact = 'Wiki@gojukai-dojo.de';
|
||||
$wgPasswordSender = 'Wiki@gojukai-dojo.de';
|
||||
$wgEnotifUserTalk = false;
|
||||
$wgEnotifWatchlist = false;
|
||||
$wgEmailAuthentication = true;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 4. Datenbank-Konfiguration (aus Env oder LocalSettings.secrets.php)
|
||||
// ----------------------------------------------------------------------------
|
||||
$wgDBtype = 'mysql';
|
||||
$wgDBserver = getenv( 'MW_DB_HOST' ) ?: ( $wgDBserver ?? 'rdbms.strato.de' );
|
||||
$wgDBname = getenv( 'MW_DB_NAME' ) ?: ( $wgDBname ?? 'dbs1754262' );
|
||||
$wgDBuser = getenv( 'MW_DB_USER' ) ?: ( $wgDBuser ?? 'dbu1061679' );
|
||||
$wgDBpassword = getenv( 'MW_DB_PASSWORD' ) ?: ( $wgDBpassword ?? '' );
|
||||
$wgDBprefix = getenv( 'MW_DB_PREFIX' ) ?: 'Karate_';
|
||||
$wgDBTableOptions = 'ENGINE=InnoDB, DEFAULT CHARSET=binary';
|
||||
|
||||
$wgSecretKey = getenv( 'MW_SECRET_KEY' ) ?: ( $wgSecretKey ?? '' );
|
||||
$wgUpgradeKey = getenv( 'MW_UPGRADE_KEY' ) ?: ( $wgUpgradeKey ?? '' );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 5. Cache & Uploads / Mediendateien
|
||||
// ----------------------------------------------------------------------------
|
||||
$wgMainCacheType = CACHE_NONE;
|
||||
$wgMemCachedServers = [];
|
||||
|
||||
$wgEnableUploads = true;
|
||||
$wgUseImageMagick = true;
|
||||
$wgImageMagickConvertCommand = '/usr/bin/convert';
|
||||
$wgUseInstantCommons = true;
|
||||
$wgShellLocale = 'en_US.utf8';
|
||||
|
||||
$wgFileExtensions = [
|
||||
'png', 'gif', 'jpg', 'jpeg', 'webp', 'svg',
|
||||
'doc', 'xls', 'mpp', 'pdf', 'ppt', 'tiff', 'bmp',
|
||||
'docx', 'xlsx', 'pptx', 'ps', 'odt', 'ods', 'odp', 'odg',
|
||||
'ogg', 'mp3', 'mp4', 'webm', 'mov'
|
||||
];
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 6. Berechtigungen & Benutzergruppen (Geschlossenes Vereins-Wiki)
|
||||
// ----------------------------------------------------------------------------
|
||||
$wgGroupPermissions['*']['createaccount'] = false;
|
||||
$wgGroupPermissions['*']['edit'] = false;
|
||||
$wgGroupPermissions['*']['read'] = false;
|
||||
|
||||
// Öffentlich lesbare Seiten (ohne Login)
|
||||
$wgWhitelistRead = [
|
||||
'Spezial:Userlogin',
|
||||
'Spezial:Anmelden',
|
||||
'Karate:Datenschutz',
|
||||
'Karate:Impressum',
|
||||
'Spezial:Benutzerkonto_beantragen',
|
||||
'Karate:Nutzungsbedingungen',
|
||||
];
|
||||
|
||||
$wgBlockDisablesLogin = true;
|
||||
|
||||
// Eigene Vereins-Gruppe "Trustworthy"
|
||||
$wgGroupPermissions['Trustworthy'] = $wgGroupPermissions['user'];
|
||||
$wgGroupPermissions['Trustworthy']['delete'] = true;
|
||||
$wgGroupPermissions['Trustworthy']['protect'] = true;
|
||||
$wgGroupPermissions['Trustworthy']['patrol'] = true;
|
||||
$wgGroupPermissions['Trustworthy']['purge'] = true;
|
||||
$wgGroupPermissions['Trustworthy']['createaccount'] = true;
|
||||
$wgGroupPermissions['Trustworthy']['block'] = true;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 7. Skins
|
||||
// ----------------------------------------------------------------------------
|
||||
wfLoadSkin( 'Vector' );
|
||||
wfLoadSkin( 'MonoBook' );
|
||||
wfLoadSkin( 'Timeless' );
|
||||
if ( is_dir( "$IP/skins/MinervaNeue" ) ) {
|
||||
wfLoadSkin( 'MinervaNeue' );
|
||||
}
|
||||
$wgDefaultSkin = 'vector';
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// 8. Extensions (Absturzsicher geladen)
|
||||
// ----------------------------------------------------------------------------
|
||||
$karateCoreExtensions = [
|
||||
'Cite',
|
||||
'Gadgets',
|
||||
'ImageMap',
|
||||
'InputBox',
|
||||
'Interwiki',
|
||||
'Nuke',
|
||||
'ParserFunctions',
|
||||
'PdfHandler',
|
||||
'SpamBlacklist',
|
||||
'SyntaxHighlight_GeSHi',
|
||||
'TitleBlacklist',
|
||||
'WikiEditor',
|
||||
];
|
||||
|
||||
foreach ( $karateCoreExtensions as $extName ) {
|
||||
if ( file_exists( "$IP/extensions/$extName/extension.json" ) ) {
|
||||
wfLoadExtension( $extName );
|
||||
}
|
||||
}
|
||||
|
||||
// Unsere eigene, wartungsfreie Video-Extension (ersetzt Html5mediator & EmbedVideo!)
|
||||
if ( file_exists( "$IP/extensions/KarateMedia/extension.json" ) ) {
|
||||
wfLoadExtension( 'KarateMedia' );
|
||||
}
|
||||
|
||||
// Optionale Zusatz-Extensions (werden nur geladen, wenn im Image/Ordner installiert)
|
||||
$karateOptionalExtensions = [
|
||||
'UploadWizard',
|
||||
'MobileFrontend',
|
||||
'MsUpload',
|
||||
'LinkTitles',
|
||||
'CookieWarning',
|
||||
'EditUser',
|
||||
'EmailPage',
|
||||
];
|
||||
|
||||
foreach ( $karateOptionalExtensions as $extName ) {
|
||||
if ( file_exists( "$IP/extensions/$extName/extension.json" ) ) {
|
||||
wfLoadExtension( $extName );
|
||||
}
|
||||
}
|
||||
|
||||
// WikiEditor Standard-Optionen
|
||||
$wgDefaultUserOptions['usebetatoolbar'] = 1;
|
||||
$wgDefaultUserOptions['usebetatoolbar-cgd'] = 1;
|
||||
$wgDefaultUserOptions['wikieditor-preview'] = 1;
|
||||
$wgDefaultUserOptions['wikieditor-publish'] = 1;
|
||||
|
||||
// CookieWarning & EditUser Berechtigungen
|
||||
$wgCookieWarningEnabled = true;
|
||||
$wgGroupPermissions['bureaucrat']['edituser'] = true;
|
||||
$wgGroupPermissions['sysop']['edituser-exempt'] = true;
|
||||
@@ -0,0 +1,6 @@
|
||||
; PHP-Konfiguration fuer grosse Karate-Videos (MP4)
|
||||
upload_max_filesize = 500M
|
||||
post_max_size = 500M
|
||||
memory_limit = 512M
|
||||
max_execution_time = 600
|
||||
max_input_time = 600
|
||||
@@ -0,0 +1,34 @@
|
||||
services:
|
||||
mediawiki:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
args:
|
||||
MW_VERSION: "1.43"
|
||||
container_name: karatewiki-web
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "${MW_PORT:-8080}:80"
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- ./config/LocalSettings.php:/var/www/html/LocalSettings.php:ro
|
||||
- ./config/php-uploads.ini:/usr/local/etc/php/conf.d/zz-karate-uploads.ini:ro
|
||||
- ./assets/logo_goju-kai_Bleistift.png:/var/www/html/resources/assets/logo_goju-kai_Bleistift.png:ro
|
||||
- ./extensions-custom/KarateMedia:/var/www/html/extensions/KarateMedia:ro
|
||||
- ./data/images:/var/www/html/images
|
||||
depends_on:
|
||||
- db
|
||||
|
||||
db:
|
||||
image: mariadb:10.11
|
||||
container_name: karatewiki-db
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
MYSQL_DATABASE: ${MW_DB_NAME:-dbs1754262}
|
||||
MYSQL_USER: ${MW_DB_USER:-dbu1061679}
|
||||
MYSQL_PASSWORD: ${MW_DB_PASSWORD}
|
||||
MYSQL_ROOT_PASSWORD: ${MW_DB_ROOT_PASSWORD}
|
||||
volumes:
|
||||
- ./data/mariadb:/var/lib/mysql
|
||||
- ./backups/db-init:/docker-entrypoint-initdb.d:ro
|
||||
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "KarateMedia",
|
||||
"version": "1.0.0",
|
||||
"author": [
|
||||
"Goju-Kai Dojo"
|
||||
],
|
||||
"url": "https://www.gojukai-dojo.de",
|
||||
"description": "Schlanke, wartungsfreie HTML5-Video- und Audio-Erweiterung fuer das Karate-Wiki (unterstuetzt <html5media> und [[Datei:*.mp4]])",
|
||||
"license-name": "GPL-2.0-or-later",
|
||||
"type": "media",
|
||||
"requires": {
|
||||
"MediaWiki": ">= 1.35.0"
|
||||
},
|
||||
"AutoloadNamespaces": {
|
||||
"MediaWiki\\Extension\\KarateMedia\\": "src/"
|
||||
},
|
||||
"Hooks": {
|
||||
"ParserFirstCallInit": "MediaWiki\\Extension\\KarateMedia\\KarateMediaHooks::onParserFirstCallInit",
|
||||
"BeforePageDisplay": "MediaWiki\\Extension\\KarateMedia\\KarateMediaHooks::onBeforePageDisplay"
|
||||
},
|
||||
"MediaHandlers": {
|
||||
"video/mp4": "MediaWiki\\Extension\\KarateMedia\\KarateVideoHandler",
|
||||
"video/webm": "MediaWiki\\Extension\\KarateMedia\\KarateVideoHandler",
|
||||
"video/ogg": "MediaWiki\\Extension\\KarateMedia\\KarateVideoHandler",
|
||||
"application/ogg": "MediaWiki\\Extension\\KarateMedia\\KarateVideoHandler",
|
||||
"audio/mpeg": "MediaWiki\\Extension\\KarateMedia\\KarateVideoHandler",
|
||||
"audio/mp3": "MediaWiki\\Extension\\KarateMedia\\KarateVideoHandler"
|
||||
},
|
||||
"ResourceModules": {
|
||||
"ext.karateMedia": {
|
||||
"styles": [
|
||||
"resources/karatemedia.css"
|
||||
],
|
||||
"scripts": [
|
||||
"resources/karatemedia.js"
|
||||
],
|
||||
"targets": [
|
||||
"desktop",
|
||||
"mobile"
|
||||
]
|
||||
}
|
||||
},
|
||||
"ResourceFileModulePaths": {
|
||||
"localBasePath": "",
|
||||
"remoteExtPath": "KarateMedia"
|
||||
},
|
||||
"manifest_version": 2
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
.karate-media-wrapper {
|
||||
display: inline-block;
|
||||
max-width: 100%;
|
||||
margin: 4px 0;
|
||||
background: #1a1a1a;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
.karate-video-player {
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
background: #000;
|
||||
}
|
||||
|
||||
.karate-video-controls {
|
||||
display: flex;
|
||||
gap: 4px;
|
||||
padding: 4px 8px;
|
||||
background: #262626;
|
||||
border-top: 1px solid #3a3a3a;
|
||||
justify-content: flex-end;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.karate-video-controls button {
|
||||
background: #3a3a3a;
|
||||
color: #e0e0e0;
|
||||
border: 1px solid #505050;
|
||||
border-radius: 3px;
|
||||
padding: 2px 7px;
|
||||
font-size: 11px;
|
||||
cursor: pointer;
|
||||
line-height: 1.3;
|
||||
}
|
||||
|
||||
.karate-video-controls button:hover {
|
||||
background: #505050;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.karate-video-controls button.active {
|
||||
background: #b71c1c;
|
||||
border-color: #d32f2f;
|
||||
color: #fff;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.karate-media-missing {
|
||||
display: inline-block;
|
||||
padding: 4px 8px;
|
||||
background: #ffebee;
|
||||
border: 1px solid #ef9a9a;
|
||||
border-radius: 4px;
|
||||
color: #b71c1c;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
( function () {
|
||||
'use strict';
|
||||
|
||||
document.addEventListener( 'click', function ( ev ) {
|
||||
var speedBtn = ev.target.closest( '.km-speed-btn' );
|
||||
if ( speedBtn ) {
|
||||
var wrapper = speedBtn.closest( '.karate-media-wrapper' );
|
||||
var video = wrapper && wrapper.querySelector( 'video' );
|
||||
if ( video ) {
|
||||
var speed = parseFloat( speedBtn.getAttribute( 'data-speed' ) || '1' );
|
||||
video.playbackRate = speed;
|
||||
wrapper.querySelectorAll( '.km-speed-btn' ).forEach( function ( btn ) {
|
||||
btn.classList.toggle( 'active', btn === speedBtn );
|
||||
} );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var loopBtn = ev.target.closest( '.km-loop-btn' );
|
||||
if ( loopBtn ) {
|
||||
var loopWrapper = loopBtn.closest( '.karate-media-wrapper' );
|
||||
var loopVideo = loopWrapper && loopWrapper.querySelector( 'video' );
|
||||
if ( loopVideo ) {
|
||||
loopVideo.loop = !loopVideo.loop;
|
||||
loopBtn.classList.toggle( 'active', loopVideo.loop );
|
||||
}
|
||||
}
|
||||
} );
|
||||
}() );
|
||||
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\KarateMedia;
|
||||
|
||||
use Html;
|
||||
use MediaWiki\MediaWikiServices;
|
||||
use OutputPage;
|
||||
use Parser;
|
||||
use PPFrame;
|
||||
use Skin;
|
||||
use Title;
|
||||
|
||||
class KarateMediaHooks {
|
||||
|
||||
/**
|
||||
* Registriert das <html5media>-Tag fuer Abwaertskompatibilitaet mit bestehenden Wiki-Seiten.
|
||||
*/
|
||||
public static function onParserFirstCallInit( Parser $parser ): bool {
|
||||
$parser->setHook( 'html5media', [ self::class, 'renderHtml5MediaTag' ] );
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Laedt CSS und JS fuer die Video-Steuerung (z.B. Zeitlupe fuer Kata/Bunkai).
|
||||
*/
|
||||
public static function onBeforePageDisplay( OutputPage $out, Skin $skin ): void {
|
||||
$out->addModules( [ 'ext.karateMedia' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Rendert <html5media height="200" width="300">File:Beispiel.mp4</html5media>
|
||||
*/
|
||||
public static function renderHtml5MediaTag( ?string $input, array $args, Parser $parser, PPFrame $frame ): string {
|
||||
if ( $input === null || trim( $input ) === '' ) {
|
||||
return Html::element( 'span', [ 'class' => 'error' ], 'KarateMedia: Keine Mediendatei angegeben.' );
|
||||
}
|
||||
|
||||
$rawTarget = trim( $input );
|
||||
|
||||
// Entferne vorangestelltes "File:" oder "Datei:" falls vorhanden
|
||||
$cleanFileName = preg_replace( '/^(file|datei|image|bild)\s*:\s*/i', '', $rawTarget );
|
||||
|
||||
$services = MediaWikiServices::getInstance();
|
||||
$repoGroup = $services->getRepoGroup();
|
||||
|
||||
$title = Title::makeTitleSafe( NS_FILE, $cleanFileName );
|
||||
$file = $title ? $repoGroup->findFile( $title ) : false;
|
||||
|
||||
if ( !$file || !$file->exists() ) {
|
||||
return Html::element(
|
||||
'span',
|
||||
[ 'class' => 'error karate-media-missing' ],
|
||||
'Video nicht gefunden: ' . $cleanFileName
|
||||
);
|
||||
}
|
||||
|
||||
$url = $file->getUrl();
|
||||
$ext = strtolower( pathinfo( $file->getName(), PATHINFO_EXTENSION ) );
|
||||
|
||||
$attrs = [
|
||||
'src' => $url,
|
||||
'controls' => true,
|
||||
'preload' => 'metadata',
|
||||
'playsinline' => true,
|
||||
'class' => 'karate-video-player',
|
||||
];
|
||||
|
||||
if ( isset( $args['width'] ) && is_numeric( $args['width'] ) ) {
|
||||
$attrs['width'] = (int)$args['width'];
|
||||
}
|
||||
if ( isset( $args['height'] ) && is_numeric( $args['height'] ) ) {
|
||||
$attrs['height'] = (int)$args['height'];
|
||||
}
|
||||
|
||||
if ( in_array( $ext, [ 'mp3', 'ogg' ], true ) && strpos( $file->getMimeType(), 'audio/' ) === 0 ) {
|
||||
$attrs['class'] = 'karate-audio-player';
|
||||
return Html::rawElement( 'div', [ 'class' => 'karate-media-wrapper' ],
|
||||
Html::element( 'audio', $attrs )
|
||||
);
|
||||
}
|
||||
|
||||
return self::buildVideoHtml( $attrs );
|
||||
}
|
||||
|
||||
/**
|
||||
* Erzeugt das HTML fuer den Videoplayer inklusive Karate-Zeitlupen-Leiste.
|
||||
*/
|
||||
public static function buildVideoHtml( array $videoAttrs ): string {
|
||||
$videoTag = Html::element( 'video', $videoAttrs );
|
||||
|
||||
$controls = Html::rawElement(
|
||||
'div',
|
||||
[ 'class' => 'karate-video-controls', 'title' => 'Abspielgeschwindigkeit fuer Kata/Bunkai-Studium' ],
|
||||
Html::element( 'button', [ 'type' => 'button', 'class' => 'km-speed-btn active', 'data-speed' => '1' ], '1x' ) .
|
||||
Html::element( 'button', [ 'type' => 'button', 'class' => 'km-speed-btn', 'data-speed' => '0.5' ], '0.5x' ) .
|
||||
Html::element( 'button', [ 'type' => 'button', 'class' => 'km-speed-btn', 'data-speed' => '0.25' ], '0.25x' ) .
|
||||
Html::element( 'button', [ 'type' => 'button', 'class' => 'km-loop-btn', 'data-loop' => '0' ], 'Loop' )
|
||||
);
|
||||
|
||||
return Html::rawElement(
|
||||
'div',
|
||||
[ 'class' => 'karate-media-wrapper' ],
|
||||
$videoTag . $controls
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\KarateMedia;
|
||||
|
||||
use File;
|
||||
use MediaHandler;
|
||||
use MediaTransformOutput;
|
||||
|
||||
/**
|
||||
* MediaHandler fuer [[Datei:Beispiel.mp4|mini|Beschreibung]] und [[File:Beispiel.mp4|300x169px]]
|
||||
*/
|
||||
class KarateVideoHandler extends MediaHandler {
|
||||
|
||||
public function getParamMap(): array {
|
||||
return [
|
||||
'img_width' => 'width',
|
||||
];
|
||||
}
|
||||
|
||||
public function validateParam( $name, $value ): bool {
|
||||
if ( in_array( $name, [ 'width', 'height' ], true ) ) {
|
||||
return $value > 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function makeParamString( $params ): string {
|
||||
$width = $params['width'] ?? 320;
|
||||
return "{$width}px";
|
||||
}
|
||||
|
||||
public function parseParamString( $str ) {
|
||||
if ( preg_match( '/^(\d+)px$/', $str, $m ) ) {
|
||||
return [ 'width' => (int)$m[1] ];
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function normaliseParams( $image, &$params ): bool {
|
||||
if ( !isset( $params['width'] ) || $params['width'] <= 0 ) {
|
||||
$params['width'] = 320;
|
||||
}
|
||||
if ( !isset( $params['height'] ) || $params['height'] <= 0 ) {
|
||||
$params['height'] = (int)round( $params['width'] * 9 / 16 );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getImageSize( $image, $path ) {
|
||||
// Standard 16:9 Fallback-Dimensionen fuer den MediaWiki-Layout-Berechner
|
||||
return [ 640, 360 ];
|
||||
}
|
||||
|
||||
public function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ): MediaTransformOutput {
|
||||
$this->normaliseParams( $image, $params );
|
||||
return new KarateVideoTransformOutput(
|
||||
$image,
|
||||
$image->getUrl(),
|
||||
(int)$params['width'],
|
||||
(int)$params['height']
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace MediaWiki\Extension\KarateMedia;
|
||||
|
||||
use File;
|
||||
use MediaTransformOutput;
|
||||
|
||||
class KarateVideoTransformOutput extends MediaTransformOutput {
|
||||
|
||||
public function __construct( File $file, string $url, int $width, int $height ) {
|
||||
$this->file = $file;
|
||||
$this->url = $url;
|
||||
$this->width = $width;
|
||||
$this->height = $height;
|
||||
}
|
||||
|
||||
public function toHtml( $options = [] ): string {
|
||||
$attrs = [
|
||||
'src' => $this->url,
|
||||
'width' => $this->width,
|
||||
'height' => $this->height,
|
||||
'controls' => true,
|
||||
'preload' => 'metadata',
|
||||
'playsinline' => true,
|
||||
'class' => 'karate-video-player',
|
||||
];
|
||||
|
||||
return KarateMediaHooks::buildVideoHtml( $attrs );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
# ============================================================================
|
||||
# Rein lesendes Sync-Skript (Windows PowerShell)
|
||||
# Holt einen aktuellen Datenbank-Abzug (mysqldump) und das Vereins-Logo
|
||||
# vom Strato-Produktivserver nach C:\dev\Karatewiki\backups\
|
||||
# ============================================================================
|
||||
param(
|
||||
[switch]$IncludeSampleVideos
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
$SshKey = "$env:USERPROFILE\.ssh\strato_fewo"
|
||||
$SshTarget = "stu100093250@51539426.ssh.w1.strato.hosting"
|
||||
$WikiDir = "Karate_Wiki_135"
|
||||
|
||||
$BackupDir = Join-Path $PSScriptRoot "..\backups\db-init"
|
||||
New-Item -ItemType Directory -Force -Path $BackupDir | Out-Null
|
||||
|
||||
Write-Host "1. Erstelle rein lesenden Datenbank-Dump von Strato nach backups\db-init\01-karatewiki.sql ..." -ForegroundColor Cyan
|
||||
$RemoteDumpCmd = @'
|
||||
/opt/RZphp84/bin/php-cli -r '
|
||||
$c = file_get_contents("Karate_Wiki_135/LocalSettings.php");
|
||||
preg_match("/wgDBpassword\s*=\s*\"([^\"]+)\"/", $c, $m);
|
||||
$cmd = sprintf("mysqldump --single-transaction --no-tablespaces -h rdbms.strato.de -u dbu1061679 -p%s dbs1754262", escapeshellarg($m[1]));
|
||||
passthru($cmd);
|
||||
'
|
||||
'@
|
||||
|
||||
ssh -i $SshKey -o BatchMode=yes $SshTarget $RemoteDumpCmd > (Join-Path $BackupDir "01-karatewiki.sql")
|
||||
Write-Host " Datenbank-Dump erfolgreich gespeichert!" -ForegroundColor Green
|
||||
|
||||
if ($IncludeSampleVideos) {
|
||||
$ImagesDir = Join-Path $PSScriptRoot "..\data\images"
|
||||
New-Item -ItemType Directory -Force -Path $ImagesDir | Out-Null
|
||||
Write-Host "2. Kopiere images/ Verzeichnis (oder Beispiel-Videos) ..." -ForegroundColor Cyan
|
||||
scp -i $SshKey -r "${SshTarget}:${WikiDir}/images/.htaccess" $ImagesDir
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
# ============================================================================
|
||||
# Rein lesendes Sync-Skript (Linux / Docker-Host)
|
||||
# Spiegelt Datenbank und (optional) den 8.3 GB images/-Ordner per rsync von Strato
|
||||
# ============================================================================
|
||||
set -euo pipefail
|
||||
|
||||
SSH_KEY="${STRATO_SSH_KEY:-$HOME/.ssh/strato_fewo}"
|
||||
SSH_TARGET="stu100093250@51539426.ssh.w1.strato.hosting"
|
||||
WIKI_DIR="Karate_Wiki_135"
|
||||
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
|
||||
mkdir -p "$ROOT_DIR/backups/db-init" "$ROOT_DIR/data/images"
|
||||
|
||||
echo "[1/2] Ziehe aktuellen Datenbank-Dump (rein lesend) von Strato..."
|
||||
ssh -i "$SSH_KEY" -o BatchMode=yes "$SSH_TARGET" \
|
||||
'/opt/RZphp84/bin/php-cli -r '\''$c=file_get_contents("Karate_Wiki_135/LocalSettings.php");preg_match("/wgDBpassword\s*=\s*\"([^\"]+)\"/",$c,$m);passthru(sprintf("mysqldump --single-transaction --no-tablespaces -h rdbms.strato.de -u dbu1061679 -p%s dbs1754262",escapeshellarg($m[1])));'\''' \
|
||||
> "$ROOT_DIR/backups/db-init/01-karatewiki.sql"
|
||||
|
||||
echo "[2/2] Synchronisiere images/ Verzeichnis inkrementell per rsync (rein lesend auf Quelle)..."
|
||||
if [[ "${SYNC_IMAGES:-false}" == "true" ]]; then
|
||||
rsync -avz --e "ssh -i $SSH_KEY" "${SSH_TARGET}:${WIKI_DIR}/images/" "$ROOT_DIR/data/images/"
|
||||
else
|
||||
echo " (Uebersprungen. Starte mit SYNC_IMAGES=true ./scripts/sync-from-strato.sh um alle 8.3 GB Videos zu spiegeln)"
|
||||
fi
|
||||
|
||||
echo "Fertig!"
|
||||
Reference in new issue
Block a user