diff --git a/build/index.php b/build/index.php index 3be46ed..7844eaf 100644 --- a/build/index.php +++ b/build/index.php @@ -349,6 +349,10 @@ textarea ~ input[type=submit] { margin: 0.5rem 0.8rem; padding: 0.5rem; font-wei .editform input[type=text] { width: calc(100% - 0.3rem); box-sizing: border-box; } .editing_message { margin: 0.8rem; } +.file-gallery { margin: 0.5em; padding: 0.5em; list-style-type: none; } +.file-gallery > li { display: inline-block; min-width: attr(data-gallery-width); padding: 1em; text-align: center; } +.file-gallery > li img, .file-gallery > li video, .file-gallery > li audio { display: block; margin: 0 auto; background-color: white; } + .page-tags-display { margin: 0.5rem 0 0 0; padding: 0; list-style-type: none; } .page-tags-display li { display: inline-block; margin: 0.5rem; padding: 0.5rem; background: #D2C3DD; white-space: nowrap; } .page-tags-display li a { color: #FB701A; text-decoration: none; } @@ -2767,7 +2771,7 @@ register_module([ default: http_response_code(501); - $preview = errorimage("Unrecognised file type '$mime_type'."); + $preview = errorimage("Unrecognised file type '$mime_type'.", $target_size); header("content-type: image/png"); imagepng($preview); exit(); @@ -2904,10 +2908,17 @@ function parse_size($size) { } } -function errorimage($text) +function errorimage($text, $target_size) { $width = 640; $height = 480; + + if(!empty($target_size)) + { + $width = $target_size; + $height = $target_size * (2 / 3); + } + $image = imagecreatetruecolor($width, $height); imagefill($image, 0, 0, imagecolorallocate($image, 238, 232, 242)); // Set the background to #eee8f2 $fontwidth = imagefontwidth(3); @@ -3495,7 +3506,7 @@ register_module([ register_module([ "name" => "Help page", - "version" => "0.9.1", + "version" => "0.9.2", "author" => "Starbeamrainbowlabs", "description" => "Adds a rather useful help page. Access through the 'help' action. This module also exposes help content added to Pepperminty Wiki's inbuilt invisible help section system.", "id" => "page-help", @@ -3510,7 +3521,7 @@ register_module([ * ██ ██ ███████ ███████ ██ */ add_action("help", function() { - global $settings, $version, $help_sections, $actions; + global $paths, $settings, $version, $help_sections, $actions; // Sort the help sections by key ksort($help_sections, SORT_NATURAL); @@ -3538,6 +3549,7 @@ register_module([ $content .= "

" . implode(", ", array_keys(get_object_vars($actions))) . "

"; $content .= "

Environment

\n"; $content .= "

$settings->sitename's root directory is " . (!is_writeable(__DIR__) ? "not " : "") . "writeable.

"; + $content .= "

The page index is currently " . human_filesize(filesize($paths->pageindex)) . " in size.

"; } else { @@ -3547,7 +3559,7 @@ register_module([

Welcome to $settings->sitename!

$settings->sitename is powered by Pepperminty Wiki, a complete wiki in a box you can drop into your server and expect it to just work.

"; - // todo Insert a table of contents here? + // Todo Insert a table of contents here? foreach($help_sections as $index => $section) { @@ -4147,7 +4159,7 @@ register_module([ register_module([ "name" => "Parsedown", - "version" => "0.6.2", + "version" => "0.7", "author" => "Emanuil Rusev & Starbeamrainbowlabs", "description" => "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https://github.com/erusev/parsedown-extra), which is licensed MIT. Please be careful, as this module adds a some weight to your installation, and also *requires* write access to the disk on first load.", "id" => "parser-parsedown", @@ -4295,6 +4307,50 @@ class PeppermintParsedown extends ParsedownExtra if(strlen($variableValue) === 0) $variableValue = "(none yet!)"; break; + case "+": + // If the upload module isn't present, then there's no point + // in checking for uploaded files + if(!module_exists("feature-upload")) + break; + + $variableValue = []; + $subpages = get_subpages($pageindex, $env->page); + foreach($subpages as $pagename => $depth) + { + // Make sure that this is an uploaded file + if(!$pageindex->$pagename->uploadedfile) + continue; + + $mime_type = $pageindex->$pagename->uploadedfilemime; + + $previewSize = 300; + $previewUrl = "?action=preview&size=$previewSize&page=" . rawurlencode($pagename); + + $previewHtml = ""; + switch(substr($mime_type, 0, strpos($mime_type, "/"))) + { + case "video": + $previewHtml .= "\n"; + break; + case "audio": + $previewHtml .= "\n"; + break; + case "application": + case "image": + default: + $previewHtml .= "\n"; + break; + } + $previewHtml = "$previewHtml$pagename"; + + $variableValue[$pagename] = "
  • $previewHtml
  • "; + } + + if(count($variableValue) === 0) + $variableValue["default"] = "
  • (No files found)
  • \n"; + $variableValue = implode("\n", $variableValue); + $variableValue = ""; + break; } if(isset($params[$variableKey])) { diff --git a/module_index.json b/module_index.json index d0cf8c8..015071f 100644 --- a/module_index.json +++ b/module_index.json @@ -68,7 +68,7 @@ "author": "Starbeamrainbowlabs", "description": "Adds the ability to upload files to Pepperminty Wiki. Uploaded files act as pages and have the special 'File:' prefix.", "id": "feature-upload", - "lastupdate": 1460185045, + "lastupdate": 1460189726, "optional": false }, { @@ -118,11 +118,11 @@ }, { "name": "Help page", - "version": "0.9.1", + "version": "0.9.2", "author": "Starbeamrainbowlabs", "description": "Adds a rather useful help page. Access through the 'help' action. This module also exposes help content added to Pepperminty Wiki's inbuilt invisible help section system.", "id": "page-help", - "lastupdate": 1459002158, + "lastupdate": 1460186049, "optional": false }, { @@ -190,11 +190,11 @@ }, { "name": "Parsedown", - "version": "0.6.2", + "version": "0.7", "author": "Emanuil Rusev & Starbeamrainbowlabs", "description": "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https:\/\/github.com\/erusev\/parsedown-extra), which is licensed MIT. Please be careful, as this module adds a some weight to your installation, and also *requires* write access to the disk on first load.", "id": "parser-parsedown", - "lastupdate": 1460184701, + "lastupdate": 1460190367, "optional": false } ] \ No newline at end of file diff --git a/modules/feature-upload.php b/modules/feature-upload.php index 64f12b3..e2b8245 100644 --- a/modules/feature-upload.php +++ b/modules/feature-upload.php @@ -279,7 +279,7 @@ register_module([ default: http_response_code(501); - $preview = errorimage("Unrecognised file type '$mime_type'."); + $preview = errorimage("Unrecognised file type '$mime_type'.", $target_size); header("content-type: image/png"); imagepng($preview); exit(); @@ -416,10 +416,17 @@ function parse_size($size) { } } -function errorimage($text) +function errorimage($text, $target_size) { $width = 640; $height = 480; + + if(!empty($target_size)) + { + $width = $target_size; + $height = $target_size * (2 / 3); + } + $image = imagecreatetruecolor($width, $height); imagefill($image, 0, 0, imagecolorallocate($image, 238, 232, 242)); // Set the background to #eee8f2 $fontwidth = imagefontwidth(3); diff --git a/modules/parser-parsedown.php b/modules/parser-parsedown.php index f3772c1..97cfaad 100644 --- a/modules/parser-parsedown.php +++ b/modules/parser-parsedown.php @@ -1,7 +1,7 @@ "Parsedown", - "version" => "0.6.2", + "version" => "0.7", "author" => "Emanuil Rusev & Starbeamrainbowlabs", "description" => "An upgraded (now default!) parser based on Emanuil Rusev's Parsedown Extra PHP library (https://github.com/erusev/parsedown-extra), which is licensed MIT. Please be careful, as this module adds a some weight to your installation, and also *requires* write access to the disk on first load.", "id" => "parser-parsedown", @@ -149,6 +149,50 @@ class PeppermintParsedown extends ParsedownExtra if(strlen($variableValue) === 0) $variableValue = "(none yet!)"; break; + case "+": + // If the upload module isn't present, then there's no point + // in checking for uploaded files + if(!module_exists("feature-upload")) + break; + + $variableValue = []; + $subpages = get_subpages($pageindex, $env->page); + foreach($subpages as $pagename => $depth) + { + // Make sure that this is an uploaded file + if(!$pageindex->$pagename->uploadedfile) + continue; + + $mime_type = $pageindex->$pagename->uploadedfilemime; + + $previewSize = 300; + $previewUrl = "?action=preview&size=$previewSize&page=" . rawurlencode($pagename); + + $previewHtml = ""; + switch(substr($mime_type, 0, strpos($mime_type, "/"))) + { + case "video": + $previewHtml .= "\n"; + break; + case "audio": + $previewHtml .= "\n"; + break; + case "application": + case "image": + default: + $previewHtml .= "\n"; + break; + } + $previewHtml = "$previewHtml$pagename"; + + $variableValue[$pagename] = "
  • $previewHtml
  • "; + } + + if(count($variableValue) === 0) + $variableValue["default"] = "
  • (No files found)
  • \n"; + $variableValue = implode("\n", $variableValue); + $variableValue = ""; + break; } if(isset($params[$variableKey])) { diff --git a/settings.fragment.php b/settings.fragment.php index 1641da7..2389ef1 100644 --- a/settings.fragment.php +++ b/settings.fragment.php @@ -346,6 +346,10 @@ textarea ~ input[type=submit] { margin: 0.5rem 0.8rem; padding: 0.5rem; font-wei .editform input[type=text] { width: calc(100% - 0.3rem); box-sizing: border-box; } .editing_message { margin: 0.8rem; } +.file-gallery { margin: 0.5em; padding: 0.5em; list-style-type: none; } +.file-gallery > li { display: inline-block; min-width: attr(data-gallery-width); padding: 1em; text-align: center; } +.file-gallery > li img, .file-gallery > li video, .file-gallery > li audio { display: block; margin: 0 auto; background-color: white; } + .page-tags-display { margin: 0.5rem 0 0 0; padding: 0; list-style-type: none; } .page-tags-display li { display: inline-block; margin: 0.5rem; padding: 0.5rem; background: #D2C3DD; white-space: nowrap; } .page-tags-display li a { color: #FB701A; text-decoration: none; }