252 lines
6.8 KiB
PHP
252 lines
6.8 KiB
PHP
<?php
|
|
require_once("./auth.php");
|
|
|
|
require("lib/Parsedown.php");
|
|
require("lib/Spyc.php");
|
|
|
|
$mdRoot = "markdown/".(array_key_exists('kyu', $_GET)?$_GET['kyu']:"8")."terKyu";
|
|
|
|
$Parsedown = new Parsedown();
|
|
|
|
//! loading a markdownfile with yaml-header
|
|
//! returns an assocative array('yaml'=>array(..), 'mdText'=>string)
|
|
function loadMarkdownFile($fileName){
|
|
$fileText = file_get_contents($fileName);
|
|
|
|
$fileParts = preg_split('/[\n]*[-]{3}[\n]/', $fileText, 3);
|
|
|
|
return array(
|
|
'yaml' => Spyc::YAMLLoadString($fileParts[1])
|
|
, 'mdText' => preg_replace("/^#(.*)$/m", "", $fileParts[2])
|
|
);
|
|
}
|
|
|
|
/// @brief Gibt die URL der gerade aufgerufenen Seite zurück
|
|
function getCurPagesUrl(){
|
|
$pageURL = 'http';
|
|
if ($_SERVER["HTTPS"] == "on"){
|
|
$pageURL .= "s";
|
|
}
|
|
$pageURL .= "://";
|
|
if($_SERVER["SERVER_PORT"] != "80"){
|
|
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
|
|
}
|
|
else{
|
|
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
|
|
}
|
|
return $pageURL;
|
|
}
|
|
|
|
function htmlCardCode($article, $Parsedown){
|
|
if(
|
|
empty($article['yaml'])
|
|
&& empty($article['mdText'])
|
|
) return "";
|
|
$videoFrame = (
|
|
array_key_exists('yaml', $article)
|
|
?(
|
|
array_key_exists('video', $article['yaml'])
|
|
?(
|
|
"<div style=\"text-align: center;width=100%;height=auto;\">".html5VideoFrame($article['yaml']['video'])."</div>"
|
|
)
|
|
:""
|
|
)
|
|
:""
|
|
);
|
|
$ytVideoFrame = (
|
|
array_key_exists('yaml', $article)
|
|
?(
|
|
array_key_exists('youtube', $article['yaml'])
|
|
?(
|
|
ytLightEmbed($article['yaml']['youtube'])
|
|
)
|
|
:""
|
|
)
|
|
:""
|
|
);
|
|
return
|
|
"<div class=\"col s12 m6\">"
|
|
."<div class=\"card blue-grey darken-1\">"
|
|
."<div class=\"card-image\">"
|
|
.(!empty($videoFrame)?$videoFrame:$ytVideoFrame)
|
|
."</div>"
|
|
."<div class=\"card-content white-text\">"
|
|
."<span class=\"card-title activator\">"
|
|
.$article['yaml']['title']
|
|
."<i class=\"material-icons right\">more_vert</i>"
|
|
."</span>"
|
|
."</div>"
|
|
."<div class=\"card-reveal\">"
|
|
."<span class=\"card-title\">"
|
|
.$article['yaml']['title']
|
|
."<i class=\"material-icons right\">close</i>"
|
|
."</span>"
|
|
.$Parsedown->text($article['mdText'])
|
|
."</div>"
|
|
."</div>"
|
|
."</div>";
|
|
}
|
|
|
|
//! create the <video>Tag for videoJs
|
|
function videoJsFrame($item){
|
|
return "<video "
|
|
."id=\"".str_replace("/", "-", $item['url'])."\" "
|
|
."class=\"video-js\" "
|
|
."controls "
|
|
."preload=\"auto\" "
|
|
// ."poster=\"//vjs.zencdn.net/v/oceans.png\""
|
|
."data-setup='{}' "
|
|
.">"
|
|
."<source src=\"".$item['url']."\" type=\"video/webm\">"//</source>"
|
|
."<p class=\"vjs-no-js\">"
|
|
."To view this video please enable JavaScript, and consider upgrading to a web browser that "
|
|
."<a href=\"https://videojs.com/html5-video-support/\" target=\"_blank\">"
|
|
."supports HTML5 video"
|
|
."</a>"
|
|
."</p>"
|
|
."</video>";
|
|
}
|
|
|
|
function html5VideoFrame($item){
|
|
return "<video "
|
|
."style=\"max-width:100%;height: auto;\""
|
|
." src=\"".$item['url']."\""
|
|
." width=\"".$item['width']."\""
|
|
." height=\"".$item['height']."\""
|
|
." controls"
|
|
."></video>";
|
|
}
|
|
|
|
//! embed youtube
|
|
function ytLightEmbed($item){
|
|
return "<lite-youtube "
|
|
."videoid=\"".$item['videoid']."\" "
|
|
// ."playlabel=\"".$title."\""
|
|
."params=\""
|
|
."start=".$item['from']
|
|
."&end=".$item['to']
|
|
."&modestbranding=1"
|
|
."&playsinline=0"
|
|
."&loop=1"
|
|
."\" "
|
|
."></lite-youtube>";
|
|
}
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="de">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Gürtelprüfungsordnung</title>
|
|
|
|
<?php readfile("./shared/imports.php");?>
|
|
|
|
<!-- unpkg : use the latest version of Video.js -->
|
|
<link href="https://unpkg.com/video.js/dist/video-js.min.css" rel="stylesheet">
|
|
<script src="https://unpkg.com/video.js/dist/video.min.js"></script>
|
|
|
|
<!-- Include the CSS & JS.. (This could be direct from the package or bundled) -->
|
|
<link rel="stylesheet" href="lib/lite-youtube-embed/lite-yt-embed.css" />
|
|
<script src="lib/lite-youtube-embed/lite-yt-embed.js"></script>
|
|
|
|
<!--- AutoInit -->
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
var materialboxElements = document.querySelectorAll('.materialboxed');
|
|
var materialboxInstances = M.Materialbox.init(materialboxElements, {
|
|
// specify options here
|
|
});
|
|
});
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
var elems = document.querySelectorAll('.sidenav');
|
|
var instances = M.Sidenav.init(elems, {
|
|
// specify options here
|
|
});
|
|
});
|
|
</script>
|
|
<style>
|
|
h1{
|
|
font-size: 2.5rem;
|
|
}
|
|
h2{
|
|
font-size: 2.25rem;
|
|
}
|
|
h3{
|
|
font-size: 2.0rem;
|
|
}
|
|
</style>
|
|
|
|
<!--Let browser know website is optimized for mobile-->
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
|
<style>
|
|
ul:not(.browser-default) > li{
|
|
list-style-type: circle;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<ul id="slide-out" class="sidenav">
|
|
<?php require_once("sidenav/loginStatus.php");?>
|
|
<li><div class="divider"></div></li>
|
|
<?php require_once("sidenav/kyu.php"); ?>
|
|
<li><div class="divider"></div></li>
|
|
<?php require_once("sidenav/backToMain.php"); ?>
|
|
</ul>
|
|
<a href="#" data-target="slide-out" class="sidenav-trigger"><i class="material-icons">menu</i></a>
|
|
<?php
|
|
$kyuMetadata = Spyc::YAMLLoad( $mdRoot."/meta.yaml" );
|
|
echo("<h1>".$kyuMetadata['title']."</h1>");
|
|
|
|
$dirNames = [];
|
|
$dirIterator = new DirectoryIterator( $mdRoot );
|
|
foreach ( $dirIterator as $dirInfo ) {
|
|
if(!$dirInfo->isDir() || $dirInfo->isDot()) continue;
|
|
$dirNames[] = $dirInfo->__toString();
|
|
}
|
|
sort($dirNames);
|
|
foreach($dirNames as $dirName){
|
|
$fullDirName = $mdRoot."/".$dirName;
|
|
$sectionMetadata = Spyc::YAMLLoad( $fullDirName."/meta.yaml" );
|
|
echo("<div class=\"row\">");
|
|
echo("<h2>".$sectionMetadata['title']."</h2>");
|
|
|
|
$fileIterator = new DirectoryIterator($fullDirName);
|
|
$fileNames = [];
|
|
foreach($fileIterator as $fileInfo){
|
|
if(!$fileInfo->isFile()) continue;
|
|
if( $fileInfo->getExtension() != "md") continue;
|
|
$fileNames[] = $fileInfo->__toString();
|
|
}
|
|
sort($fileNames);
|
|
foreach( $fileNames as $fileName){
|
|
$fullFileName = $fullDirName."/".$fileName;
|
|
$article = loadMarkdownFile( $fullFileName );
|
|
echo( htmlCardCode($article, $Parsedown) );
|
|
}
|
|
echo("</div>");
|
|
};
|
|
?>
|
|
|
|
<footer class="page-footer blue-grey darken-1">
|
|
<div class="container">
|
|
<div class="col l4 offset-l2 s12">
|
|
<ul>
|
|
<li>
|
|
<a
|
|
title="Seite auf HTML 5 Konformität prüfen"
|
|
href="http://validator.w3.org/check?uri=<?php echo(urlencode(getCurPagesUrl()));?>"
|
|
rel="nofollow"
|
|
>Valid <img
|
|
src="/ressourcen/graphiken/icons/HTML5_1Color_Black.svg"
|
|
alt="HTML 5"
|
|
title="HTML 5 Logo"
|
|
style="height:1em;display:inline;vertical-align:middle;">
|
|
</a>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
|
|
</body>
|
|
</html>
|