Commit 79e9b1d5 authored by Administrator's avatar Administrator 💬

chore: review lessons

parent 94e01286
...@@ -10,6 +10,7 @@ use Symfony\Component\EventDispatcher\Event; ...@@ -10,6 +10,7 @@ use Symfony\Component\EventDispatcher\Event;
/** /**
* Features: * Features:
* - /sync Cheap git-sync (did not knew about it at the time) * - /sync Cheap git-sync (did not knew about it at the time)
* - /lessons/<lesson-slug>
* *
* Class M3P2Plugin * Class M3P2Plugin
* @package Grav\Plugin * @package Grav\Plugin
...@@ -168,10 +169,6 @@ class M3P2Plugin extends Plugin ...@@ -168,10 +169,6 @@ class M3P2Plugin extends Plugin
$translation = new Page(); $translation = new Page();
$translation->init(new \SplFileInfo($translation_path), $language . '.md'); $translation->init(new \SplFileInfo($translation_path), $language . '.md');
// var_dump($route);
// die(var_dump($route));
// die(var_dump($translation));
if ($language == $current_language) { if ($language == $current_language) {
array_unshift($translations, $translation); array_unshift($translations, $translation);
} else { } else {
...@@ -179,8 +176,6 @@ class M3P2Plugin extends Plugin ...@@ -179,8 +176,6 @@ class M3P2Plugin extends Plugin
} }
} }
// die(var_dump($translations));
return $translations; return $translations;
} }
...@@ -238,15 +233,18 @@ class M3P2Plugin extends Plugin ...@@ -238,15 +233,18 @@ class M3P2Plugin extends Plugin
$lesson_slug = $uri->paths(1); $lesson_slug = $uri->paths(1);
// VERY inefficient : TODO: cache this
// $target_pages = $pages->all()->filter(function ($p) use ($lesson_slug) { // $target_pages = $pages->all()->filter(function ($p) use ($lesson_slug) {
$target_pages = array_filter($pages->instances(), function (Page $p) use ($lesson_slug) { $target_pages = array_filter($pages->instances(), function (Page $p) use ($lesson_slug) {
$h = $p->header(); $page_config = $p->header();
if ( ! isset($h->pedagogic_paths) || empty($h->pedagogic_paths)) { if ( ! isset($page_config->lessons) || empty($page_config->lessons)) {
return false; return false;
} }
foreach ($h->pedagogic_paths as $lesson) { foreach ($page_config->lessons as $lesson) {
// print("Checking lesson $lesson"."<br>\n");
// if ($lesson_slug == $lesson) {
if ($lesson_slug == $lesson['slug']) { if ($lesson_slug == $lesson['slug']) {
return true; // yay, this page is part of the lesson return true; // yay, this page is part of the lesson
} }
...@@ -267,8 +265,8 @@ class M3P2Plugin extends Plugin ...@@ -267,8 +265,8 @@ class M3P2Plugin extends Plugin
}; };
// We're assuming the config exists (it should) // We're assuming the config exists (it should)
$ma = array_filter($ha->pedagogic_paths, $fdp)[0]; $ma = array_filter($ha->lessons, $fdp)[0];
$mb = array_filter($hb->pedagogic_paths, $fdp)[0]; $mb = array_filter($hb->lessons, $fdp)[0];
if (isset($ma['level'])) { if (isset($ma['level'])) {
$la = floor($ma['level']); $la = floor($ma['level']);
......
> Looks like useless empty files in here! > Looks like useless empty files in here!
We do use them, though! See `m3-p2.php`. We actually use them! See `../m3-p2.php`.
They're a convenient way of leveraging Grav's page system They're a convenient way of leveraging Grav's page system
to make our custom pages. to make our custom pages.
We might override some Twig blocks in there, later on.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment