From 6f65c06b325ca6008f03f79144a549c207f05461 Mon Sep 17 00:00:00 2001 From: marko Date: Wed, 22 Dec 2021 11:12:31 +0100 Subject: [PATCH] online version of the infoZettel --- homepage/participo/css/parsedownCard.css | 6 + homepage/participo/images/info.svg | 21 ++++ homepage/participo/index.php | 9 ++ homepage/participo/infoZettel.php | 104 ++++++++++++++++++ .../participo/lib/participoLib/participo.php | 56 +++++++++- homepage/wkParticipo/infoZettel.php | 2 +- ...ung2019.md => 2019-02-27-Kyupruefung2019.md} | 0 7 files changed, 194 insertions(+), 4 deletions(-) create mode 100644 homepage/participo/css/parsedownCard.css create mode 100644 homepage/participo/images/info.svg create mode 100644 homepage/participo/infoZettel.php rename infoZettelOrg/{2019-02-27-Kyuprüfung2019.md => 2019-02-27-Kyupruefung2019.md} (100%) diff --git a/homepage/participo/css/parsedownCard.css b/homepage/participo/css/parsedownCard.css new file mode 100644 index 0000000..99f4a47 --- /dev/null +++ b/homepage/participo/css/parsedownCard.css @@ -0,0 +1,6 @@ +.parsedownCard h1{ + font-size: 2.0rem; +} +.parsedownCard h2{ + font-size: 1.75rem; +} \ No newline at end of file diff --git a/homepage/participo/images/info.svg b/homepage/participo/images/info.svg new file mode 100644 index 0000000..2356748 --- /dev/null +++ b/homepage/participo/images/info.svg @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + i + + + + nfo + + diff --git a/homepage/participo/index.php b/homepage/participo/index.php index 21986b8..a30f3cd 100644 --- a/homepage/participo/index.php +++ b/homepage/participo/index.php @@ -118,6 +118,15 @@ echo( 'actions' => [ AppCardAction::fromArray(['caption'=>"Planer", 'link'=>"/pages/desktop/wkParticipo"]), ], + ])->htmlCode(). + AppCard::fromArray([ + 'link' => "infoZettel", + 'title' => "Infozettel", + 'description'=> "Online-Variante der Infozettel und Newsletter", + 'imgUrl' => "images/info.svg", + 'actions' => [ + AppCardAction::fromArray(['caption'=>"Info", 'link'=>"infoZettel"]), + ], ])->htmlCode() ); ?> diff --git a/homepage/participo/infoZettel.php b/homepage/participo/infoZettel.php new file mode 100644 index 0000000..8c74ea2 --- /dev/null +++ b/homepage/participo/infoZettel.php @@ -0,0 +1,104 @@ + + + + + + + + + + + + + + + + + + + + + + + + InfoZettel + + + + + + + + +
+ + +
+ + +
+ +
+ $infoZettel['yaml']['title'], + 'description'=> Parsedown::instance()->text( $infoZettel['mdText'] ), + ])->htmlCode(['extraClass'=>"parsedownCard"]) + ); +} +?> +
+
+ + + diff --git a/homepage/participo/lib/participoLib/participo.php b/homepage/participo/lib/participoLib/participo.php index 80d5e7b..b0eaa15 100644 --- a/homepage/participo/lib/participoLib/participo.php +++ b/homepage/participo/lib/participoLib/participo.php @@ -69,13 +69,14 @@ class AppCard{ * * @return string html code for the AppCard */ - public function htmlCode(){ + public function htmlCode($options=[]){ + $extraClass = $options['extraClass'] ?? ""; $actionListCode = ""; foreach($this->actionList as $a){ $actionListCode .= $a->htmlCode(); } return - "
". + "
". "
". (($this->link!=null)?("appLink."\">"):(""))."
". "".$this->title."". @@ -155,4 +156,53 @@ if( !empty($anRetMessage) ){ $retHtmlString .= "
"; } return $retHtmlString; -}?> \ No newline at end of file +} + +/** + * load a MarkdownFile with yaml header + * + * @param string $fileName filename of the markdown file + * @return array assocative array('yaml'=>array(..), 'mdText'=>string) containing the yamlHeader as associative array and the markdown text as string + */ +function loadMarkdownFile($fileName){ + // load the whole file + $fileText = file_get_contents($fileName); + // split at '---' to get ((),yamls,array) + $fileParts = preg_split('/[\n]*[-]{3}[\n]/', $fileText, 3); + // not all mdfiles have a yamlHeader, so the mdText can be at different indices + $yaml=[]; + $mdText = ""; + switch( count($fileParts) ){ + case 1:{ + $mdText = $fileParts[0]; + break; + } + case 3:{ + $yaml = Spyc::YAMLLoadString($fileParts[1]); + $mdText = $fileParts[2]; + break; + } + default:{ + $mdText = $fileText; + } + + } + // get a title, if none is in the markdown + if(!array_key_exists('title', $yaml)){ + // find the first heading, set it as header and remove it from the markdown + if( preg_match("/^#(.*)$/m", $mdText, $matches) ){ + $yaml['title'] = $matches[1]; + $mdText = preg_replace("/^#(.*)$/m", "", $mdText, 1); + } + else{ + // fallback for the title, if not even one heading is found + $yaml['title'] = ""; + } + } + + return array( + 'yaml' => $yaml + , 'mdText' => $mdText + ); +} +?> \ No newline at end of file diff --git a/homepage/wkParticipo/infoZettel.php b/homepage/wkParticipo/infoZettel.php index a310801..777443e 100644 --- a/homepage/wkParticipo/infoZettel.php +++ b/homepage/wkParticipo/infoZettel.php @@ -24,7 +24,7 @@ Infozettel der Judoka des CWSV - + diff --git a/infoZettelOrg/2019-02-27-Kyuprüfung2019.md b/infoZettelOrg/2019-02-27-Kyupruefung2019.md similarity index 100% rename from infoZettelOrg/2019-02-27-Kyuprüfung2019.md rename to infoZettelOrg/2019-02-27-Kyupruefung2019.md