From bf7b18fd1f7d4bd3f6097d430823663c410d9645 Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 10 May 2014 11:12:14 +1200 Subject: [PATCH] tag support 1/X: parse tags from readme, add classes to html --- rebuild.php | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/rebuild.php b/rebuild.php index b980b8c..09753e1 100644 --- a/rebuild.php +++ b/rebuild.php @@ -124,6 +124,7 @@ class CProject { private $longdesc = ''; private $images = array(); private $downloads = array(); + public $tags = array(); public $homeimage = null; @@ -144,6 +145,10 @@ class CProject { $this->subtag = rtrim($matches[1], ' .'); } + if (preg_match('~Tags: ([^\\r\\n]+)~', $this->longdesc, $matches)) { + $this->tags = array_map('trim', explode(',', $matches[1])); + } + $this->shortdesc = array_shift(explode("\n", $this->longdesc)); $this->shortdesc[0] = strtolower($this->shortdesc[0]); // cosmetic lowercase continue; @@ -190,6 +195,14 @@ class CProject { file_put_contents(BASEDIR.'wwwroot/'.$this->projname.'.html', $idxfile); } + public function getClassAttr() { + if (count($this->tags)) { + return 'taggedWith-'.implode(' taggedWith-', $this->tags); + } else { + return ''; + } + } + public function index() { ?>

projname)?>

@@ -322,7 +335,7 @@ function buildall() { - + @@ -330,9 +343,17 @@ function buildall() { projname)?>, shortdesc)?> more... - subtag)) { ?> + subtag) || count($pr->tags)) { ?>
- subtag)?> + + subtag)?> + subtag) && count($pr->tags)) { ?> + :: + + tags as $tag) { ?> + + +
projname]) ? '
' : '
')?>