diff options
-rw-r--r-- | app/class/media.php | 6 | ||||
-rw-r--r-- | app/class/modelrender.php | 53 | ||||
-rw-r--r-- | app/view/templates/admin.php | 2 | ||||
-rw-r--r-- | app/view/templates/info.php | 42 | ||||
-rw-r--r-- | assets/css/home.css | 2 | ||||
-rw-r--r-- | assets/global/global.css | 11 |
6 files changed, 108 insertions, 8 deletions
diff --git a/app/class/media.php b/app/class/media.php index 2d27be7..0cbbd89 100644 --- a/app/class/media.php +++ b/app/class/media.php @@ -54,6 +54,12 @@ class Media } + public function getfullpath() + { + return '/' . Config::basepath() . '/' . $this->path() . $this->id() . '.' . $this->extension(); + } + + // _________________________________________________ G E T ____________________________________________________ diff --git a/app/class/modelrender.php b/app/class/modelrender.php index c36417d..7ef7e45 100644 --- a/app/class/modelrender.php +++ b/app/class/modelrender.php @@ -56,21 +56,24 @@ class Modelrender extends Modelart } else { $templatebody = $templateart->body(); } - $body = $templatebody . PHP_EOL . $this->art->body(); + $body = $templatebody; } else { $body = $this->art->body(); } + $body = $this->article($body); + $body = $this->automedialist($body); + $body = $this->autotaglistupdate($body); return $body; } public function getbody(string $body) { $rend = $this; - $body = preg_replace_callback('~\%(SECTION|ASIDE|NAV|HEADER|FOOTER)((\.([a-z0-9-_]+|!))*|!)?\%~', function ($match) use ($rend) { + $body = preg_replace_callback('~\%(SECTION|ASIDE|NAV|HEADER|FOOTER)((:[a-z0-9-_]+|!)(\+([a-z0-9-_]+|!))*)?\%~', function ($match) use ($rend) { $element = strtolower($match[1]); $getelement = ''; if (isset($match[2]) && !empty($match[2])) { - $templatelist = str_replace('!', $this->art->id(), explode('.', ltrim($match[2], '.'))); + $templatelist = str_replace('!', $this->art->id(), explode('+', ltrim($match[2], ':'))); foreach ($templatelist as $template) { if ($template === $rend->art->id()) { $templateelement = $rend->art->$element(); @@ -94,6 +97,7 @@ class Modelrender extends Modelart public function elementparser($element) { $element = $this->article($element); + $element = $this->automedialist($element); $element = $this->autotaglistupdate($element); $element = $this->markdown($element); @@ -200,7 +204,7 @@ class Modelrender extends Modelart public function media(string $text): string { $rend = $this; - $text = preg_replace('%(src|target)="((\/?[\w-_]+)+\.[a-z0-9]{1,5})"%', '$1="'.Model::mediapath() . '$2"', $text); + $text = preg_replace('%(src|href)="((\/?[\w-_]+)+\.[a-z0-9]{1,5})"%', '$1="'.Model::mediapath() . '$2" target="_blank" class="media"', $text); return $text; } @@ -299,6 +303,47 @@ class Modelrender extends Modelart return $text; } + public function automedialist(string $text): string + { + $text = preg_replace_callback('~\%MEDIA:(([a-z0-9-_]+(\/([a-z0-9-_])+)*))\%~', + function($matches) { + $dir = trim($matches[1], '/'); + $mediamanager = new Modelmedia(); + + + + if(is_dir(Model::MEDIA_DIR . $dir)) { + $medialist = $mediamanager->getlistermedia(Model::MEDIA_DIR . $dir . '/'); + + $dirid = str_replace('/', '-', $dir); + + $ul = '<ul class="medialist" id="'.$dirid.'">' . PHP_EOL; + + foreach ($medialist as $media) { + $ul .= '<li>'; + if($media->type() == 'image') { + $ul .= '<img alt="'.$media->id().'" id="'.$media->id().'" src="'.$media->getfullpath().'" >'; + } elseif ($media->type() == 'sound') { + $ul .= '<audio id="'.$media->id().'" controls src="'.$media->getfullpath().'" </audio>'; + } elseif ($media->type() == 'video') { + $ul .= '<video controls><source src="'.$media->getfullpath().'" type="video/'.$media->extension().'"></video>'; + } elseif ($media->type() == 'other') { + $ul .= '<a href="'.$media->getfullpath().'" target="_blank" class="media" >'.$media->id().'.'.$media->extension().'</a>'; + } + $ul .= '</li>' . PHP_EOL; + } + + $ul .= '</ul>' . PHP_EOL; + + return $ul; + } else { + return 'directory not founded'; + } + }, $text); + + return $text; + } + function sumparser($text) diff --git a/app/view/templates/admin.php b/app/view/templates/admin.php index bff83c5..8de9bb1 100644 --- a/app/view/templates/admin.php +++ b/app/view/templates/admin.php @@ -10,6 +10,8 @@ <section class="admin"> + <h1>Administration</h1> + <form action="<?= $this->url('adminupdate') ?>" method="post"> <input type="submit" value="Update configuration"> diff --git a/app/view/templates/info.php b/app/view/templates/info.php index 638e2b5..97ee198 100644 --- a/app/view/templates/info.php +++ b/app/view/templates/info.php @@ -233,6 +233,42 @@ You can use any of them, only one or all at the same time, as you prefer. <p>The list is ordered by the <code>date</code> attribute, that you can set manualy for each page. You may have noticed that the actual page (page 3), has been specified using <code>.actualpage</code> class. This can be usefull to create a menu and highlight the current page.</p> +<h5>Article separator</h5> + +<p>You can use the <code>article</code> html element, by separating text using at least <code>====</code>. It is of course possible to use Markdown synthax inside those articles separators</p> + +<blockquote> +====</br></br> +<i>some text</i></br></br> +======<i>important</i></br></br> +<i>this is a longer text</i></br></br> +======</br></br> +</blockquote> + +<p>This will ouptut :</p> + +<blockquote> +<article></br> +<i>some text</i></br> +</article></br> +<article id="<i>important</i>"></br> +<i>this is a longer textt</i></br> +</article></br> +</blockquote> + + +<p>As you may have noticed, there is also the possibility to add a custom <code>id</code> to any of the articles created that way</p> + + +<h5>Media list</h5> + +<p>As it is too long adding all media of a folder one by one, you can just print the content of an entire folder using this method.</p> + +<blockquote> +%MEDIA:<i>__repository__</i> +</blockquote> + +<p>Just point to the good directory inside the media folder. This will output html list, creating image elements, audio players, video players, or just basic link, depending on the media type.</p> @@ -286,19 +322,19 @@ __the content of your section__ <h5>Advanced includings</h5> <blockquote> - %<i>HTML_ELEMENT</i>.<i>page_id</i>% + %<i>HTML_ELEMENT</i>:<i>page_id</i>% </blockquote> <p>By doing this, you can include the <code>HTML_ELEMENT</code> of the page using this <code>page_id</code> id. You can even nest differents pages source by adding <code>page_id</code> separated by a dot, this would be like :</p> <blockquote> - %<i>HTML_ELEMENT</i>.<i>page1_id</i>.<i>page2_id</i>% + %<i>HTML_ELEMENT</i>:<i>page1_id</i>+<i>page2_id</i>% </blockquote> <p>And you can mix it with the original page content using <code>!</code> identifier</p> <blockquote> - %<i>HTML_ELEMENT</i>%<i>page3_id</i>.<i>!</i>% + %<i>HTML_ELEMENT</i>:<i>page3_id</i>+<i>!</i>% </blockquote> <p>This will output :</p> diff --git a/assets/css/home.css b/assets/css/home.css index c430b87..8ea7cc5 100644 --- a/assets/css/home.css +++ b/assets/css/home.css @@ -94,7 +94,7 @@ span#search { margin: 0 1%; } -input#id {width: 100px;} +#topbar input[type="text"], #topbar input[type="password"] {width: 100px;} section.font table#fontlist { diff --git a/assets/global/global.css b/assets/global/global.css index e96050d..42b91c5 100644 --- a/assets/global/global.css +++ b/assets/global/global.css @@ -5,4 +5,15 @@ body { a.external::before { content: "⧉ "; +} + +ul.medialist { + max-width: 400px; + width: 100%; + list-style: none; + padding: 0; +} + +.medialist img { + width: 100%; }
\ No newline at end of file |