diff --git a/header.php b/header.php index 4c15962..234e164 100644 --- a/header.php +++ b/header.php @@ -4,7 +4,7 @@ <?=isset($title) ? $title : "Welcome to ~tilde.club~"?> - + diff --git a/wiki/index.php b/wiki/index.php index ea85ef8..ec362df 100644 --- a/wiki/index.php +++ b/wiki/index.php @@ -2,50 +2,59 @@ $title = "tilde.club wiki"; include __DIR__."/../header.php"; ?> -

the tilde.club wiki

-
-
- -

here's the articles on our wiki:

-
    - - $articles) { ?> -
  • +

    Here's the articles on our wiki:

      - $title) { ?> -
    • - -
    + -
+ $category_to_articles = []; + + // get articles + foreach (glob("source/*.md") as $file) + { + $article = basename($file, ".md"); + $title = preg_match("/title: (.*)/i", file_get_contents($file), $matches) ? $matches[1] : $article; + $title = ucfirst($title); + $category = preg_match("/category: (.*)/i", file_get_contents($file), $matches) ? $matches[1] : 'default'; + + if (array_key_exists($category, $category_to_articles)) + array_push($category_to_articles[$category], [$article, $title]); + else + $category_to_articles[$category] = [[$article, $title]]; + + ksort($category_to_articles); + } + + foreach ($order as $category) + { + echo '
  • '.ucwords($category).'
  • '; + echo '
      '; + + $article_titles = []; + $article_names = []; + + foreach ($category_to_articles[$category] as $article) + { + array_push($article_names, $article[0]); + array_push($article_titles, $article[1]); + } + + $name_to_title = array_combine($article_names, $article_titles); + asort($name_to_title); + + foreach ($name_to_title as $name => $title) + echo '
    • '.$title.'
    • '; + + echo '

    '; + + } + ?> +
    - - + $endif$ $if(title-prefix)$$title-prefix$ – $endif$$pagetitle$ - + +