add parsedown for descriptions

This commit is contained in:
Tomáš Mládek 2017-03-08 10:02:55 +01:00
parent 26533a6bde
commit 5419bbf675
3 changed files with 13 additions and 4 deletions

5
.gitignore vendored
View file

@ -1,5 +1,8 @@
pile.db pile.db
vendor
docs docs
vendor
_lib
*.woff *.woff
error_log error_log

1
www/_lib/.htaccess Normal file
View file

@ -0,0 +1 @@
Deny from all

View file

@ -1,12 +1,15 @@
<?php <?php
require '_templates/Template.php'; require '_templates/Template.php';
require '_util/PileDB.php'; require '_util/PileDB.php';
require '_lib/Parsedown.php';
$db = new PileDB(); $db = new PileDB();
$pd = new Parsedown();
session_start(); session_start();
if (isset($_GET["item"])) { if (isset($_GET["item"])) {
$doc = $db->fetchDoc($_GET["item"]); $doc = $db->fetchDoc($_GET["item"]);
$doc["Description"] = $pd->text($doc["Description"]);
$doc_template = new Template(); $doc_template = new Template();
$doc_template->doc = $doc; $doc_template->doc = $doc;
@ -18,9 +21,11 @@ if (isset($_GET["item"])) {
} elseif ($_GET["tag"] == "_") { } elseif ($_GET["tag"] == "_") {
$docs = $db->listDocs(-1); $docs = $db->listDocs(-1);
} else { } else {
$tag = $db->findTag($_GET["tag"]); $tagObj = $db->findTag($_GET["tag"]);
$docs = $db->listDocs($tag["ID"]); $docs = $db->listDocs($tagObj["ID"]);
$doc_list_template->tag = $db->fetchTag($tag["ID"]); $tag = $db->fetchTag($tagObj["ID"]);
$tag["Description"] = $pd->text($tag["Description"]);
$doc_list_template->tag = $tag;
} }
$doc_list_template->docs = $docs; $doc_list_template->docs = $docs;
$content = $doc_list_template->render('front_doc_listing.php'); $content = $doc_list_template->render('front_doc_listing.php');