diff options
-rw-r--r-- | MANUAL.md | 116 | ||||
-rw-r--r-- | app/class/Controllerinfo.php | 16 | ||||
-rw-r--r-- | app/class/Model.php | 3 | ||||
-rw-r--r-- | app/class/Modelrender.php | 46 | ||||
-rw-r--r-- | app/view/templates/info.php | 48 | ||||
-rw-r--r-- | assets/css/home.css | 13 | ||||
-rw-r--r-- | old_manual.html (renamed from app/view/templates/man.php) | 21 |
7 files changed, 202 insertions, 61 deletions
diff --git a/MANUAL.md b/MANUAL.md new file mode 100644 index 0000000..a689802 --- /dev/null +++ b/MANUAL.md @@ -0,0 +1,116 @@ +USER MANUAL +=========== + +Introduction +------------ + +Welcome to __W__, this manual is here to help you get the best of this tool. + + + +Startup +------- + +Welcome to __W__ + +- des infos +- les composants de W + + +- des infos +- les composants de W + + +- des infos +- les composants de W + + +- des infos +- les composants de W + + +- des infos +- les composants de W + + +- des infos +- les composants de W + + +- des infos +- les composants de W + + +Structure +--------- + +W use Markdown +W use Markdown + +W use Markdown +W use Markdown + +### Pays + +#### France + +Le pays de la France +Le pays de la France +Le pays de la France +Le pays de la France +Le pays de la France + + +Le pays de la France +Le pays de la France + +#### USA + +##### BELGIQUE + +LA BIERE + + + + +W use Markdown + + +Editor +------ + +W use Markdown +W use Markdown + + +### Ideas + +W use Markdown + +W use Markdown +W use Markdown +W use Markdown + + +W use Markdown +W use Markdown + + +The editor is fine + +### New ideas + +- get adress +- edit + +W use Markdown +W use Markdown +W use Markdown +W use Markdown + + +W use Markdown + + + +It's OK
\ No newline at end of file diff --git a/app/class/Controllerinfo.php b/app/class/Controllerinfo.php index af81caf..856d065 100644 --- a/app/class/Controllerinfo.php +++ b/app/class/Controllerinfo.php @@ -1,6 +1,7 @@ <?php namespace Wcms; +use Michelf\MarkdownExtra; class Controllerinfo extends Controller { @@ -12,7 +13,20 @@ class Controllerinfo extends Controller public function desktop() { if($this->user->iseditor()) { - $this->showtemplate('info', ['version' => getversion()]); + + if(file_exists(Model::MAN_FILE)) { + + $render = new Modelrender($this->router); + $htmlman = file_get_contents(Model::MAN_FILE); + $htmlman = $render->rendermanual($htmlman); + + $summary = $render->sumparser($htmlman, 3); + + + $this->showtemplate('info', ['version' => getversion(), 'manual' => $htmlman, 'summary' => $summary]); + + } + } } diff --git a/app/class/Model.php b/app/class/Model.php index bb07fea..913dc34 100644 --- a/app/class/Model.php +++ b/app/class/Model.php @@ -5,7 +5,8 @@ namespace Wcms; abstract class Model { - const CONFIG_FILE = 'config.json'; + const CONFIG_FILE = 'config.json'; + const MAN_FILE = 'MANUAL.md'; const CSS_DIR = 'assets' . DIRECTORY_SEPARATOR .'css' . DIRECTORY_SEPARATOR; const JS_DIR = 'assets' . DIRECTORY_SEPARATOR .'js' . DIRECTORY_SEPARATOR; const ICONS_DIR = 'assets' . DIRECTORY_SEPARATOR .'icons' . DIRECTORY_SEPARATOR; diff --git a/app/class/Modelrender.php b/app/class/Modelrender.php index 593a420..fe491f1 100644 --- a/app/class/Modelrender.php +++ b/app/class/Modelrender.php @@ -36,6 +36,21 @@ class Modelrender extends Modelpage } } + /** + * Used to convert the markdown user manual to html document + * + * @param string $text Input text in markdown + * @return string html formated text + */ + public function rendermanual(string $text) : string + { + $text = $this->markdown($text); + $text = $this->headerid($text, 3); + return $text; + + } + + public function upage($id) { return $this->router->generate('pageread/', ['page' => $id]); @@ -384,11 +399,25 @@ class Modelrender extends Modelpage return $text; } - public function headerid($text) + /** + * Add Id to hrml header elements and store the titles in the `sum` parameter + * + * @param string $text Input html document to scan + * @param int $maxdeepness Maximum header deepness to look for. Min = 1 Max = 6 Default = 6 + * + * @return string text with id in header + */ + + public function headerid($text, int $maxdeepness = 6) { + if($maxdeepness > 6 || $maxdeepness < 1) { + $maxdeepness = 6; + } + + $sum = []; $text = preg_replace_callback( - '/<h([1-6])(\s+(\s*\w+="\w+")*)?\s*>(.+)<\/h[1-6]>/mU', + '/<h([1-' . $maxdeepness . '])(\s+(\s*\w+="\w+")*)?\s*>(.+)<\/h[1-' . $maxdeepness . ']>/mU', function ($matches) use (&$sum) { $cleanid = idclean($matches[4]); $sum[$cleanid][$matches[1]] = $matches[4]; @@ -453,16 +482,15 @@ class Modelrender extends Modelpage return $text; } - - function sumparser($text) + /** + * Generate a Summary based on header ids. Need to use `$this->headerid` before to scan text + * + * @return string html list with anchor link + */ + function sumparser() : string { - preg_match_all('#<h([1-6]) id="(\w+)">(.+)</h[1-6]>#iU', $text, $out); - - $sum = $this->sum; - - $sumstring = ''; $last = 0; foreach ($sum as $title => $list) { diff --git a/app/view/templates/info.php b/app/view/templates/info.php index 8f6377b..bcfc2c8 100644 --- a/app/view/templates/info.php +++ b/app/view/templates/info.php @@ -12,25 +12,24 @@ <nav> <div class="block"> - <h2>Manual Summary</h2> - <div class="scroll"> + + <h2>Version</h2> + + <?= $version ?> + + + + <h2>Links</h2> + <ul> - <li><a href="#startup">Startup</a></li> - <ul> - - </ul> - <li><a href="#structure">Structure</a></li> - <ul> - <li><a href="#attributes">Page attributes</a></li> - <li><a href="#database">Database</a></li> - </ul> - <li><a href="#editor">Editor</a></li> - <ul> - <li><a href="#elementsyntax">Elements syntax</a></li> - <li><a href="#bodysyntax">Body syntax</a></li> - </ul> + <li><a href="https://github.com/vincent-peugnet/wcms" target="_blank">🐱👤 Github</a></li> + <li><a href="https://w-cms.top" target="_blank">🌵 Website</a></li> </ul> + <h2>Manual Summary</h2> + + <?= $summary ?> + </div> </div> </nav> @@ -38,22 +37,12 @@ <section class="info"> <div class="block"> + <h1>Info</h1> <div class="scroll"> <article> - <h1>Info</h1> - - <h2>Version</h2> - - <?= $version ?> - <h2>Links</h2> - <ul> - <li><a href="https://github.com/vincent-peugnet/wcms" target="_blank">🐱👤 Github</a></li> - <li><a href="#manual">📕 Manual</a></li> - <li><a href="https://w-cms.top" target="_blank">🌵 Website</a></li> - </ul> <h2>About</h2> @@ -72,7 +61,10 @@ </article> - <?php $this->insert('man') ?> + <article id="manual"> + <?= $manual ?> + </article> + </div> </div> diff --git a/assets/css/home.css b/assets/css/home.css index f23affc..b3edc49 100644 --- a/assets/css/home.css +++ b/assets/css/home.css @@ -273,8 +273,19 @@ main.info blockquote i { color: #7b97b9; } +main.info article#manual h1 { + text-align: center; + font-size: 50px; + color: black; + background-color: transparent; + font-weight: lighter; + margin: 6%; + border-top: solid; + border-bottom: solid; +} + -main.info article h2#manual { +main.info article#manual h2 { text-align: center; font-size: 40px; } diff --git a/app/view/templates/man.php b/old_manual.html index deb81ee..215326c 100644 --- a/app/view/templates/man.php +++ b/old_manual.html @@ -1,26 +1,5 @@ -<nav> -<h2>Manual Summary</h2> -<ul> - <li><a href="#startup">Startup</a></li> - <ul> - - </ul> - <li><a href="#structure">Structure</a></li> - <ul> - <li><a href="#attributes">Page attributes</a></li> - <li><a href="#database">Database</a></li> - </ul> - <li><a href="#editor">Editor</a></li> - <ul> - <li><a href="#elementsyntax">Elements syntax</a></li> - <li><a href="#bodysyntax">Body syntax</a></li> - </ul> -</ul> - -</nav> - <article id="manual"> |