mirror of
https://github.com/typemill/typemill.git
synced 2025-08-04 21:27:41 +02:00
Version 1.3.5 Consolidation
This commit is contained in:
@@ -7,6 +7,7 @@ use Slim\Http\Response;
|
||||
use Typemill\Models\Folder;
|
||||
use Typemill\Models\Write;
|
||||
use Typemill\Models\WriteYaml;
|
||||
use Typemill\Models\WriteMeta;
|
||||
use Typemill\Extensions\ParsedownExtension;
|
||||
use Typemill\Events\OnPagePublished;
|
||||
use Typemill\Events\OnPageUnpublished;
|
||||
@@ -77,10 +78,15 @@ class ArticleApiController extends ContentController
|
||||
# update the public structure
|
||||
$this->setStructure($draft = false, $cache = false);
|
||||
|
||||
# dispatch event
|
||||
$this->c->dispatcher->dispatch('onPagePublished', new OnPagePublished($this->item));
|
||||
# complete the page meta if title or description not set
|
||||
$writeMeta = new WriteMeta();
|
||||
$meta = $writeMeta->completePageMeta($this->content, $this->settings, $this->item);
|
||||
|
||||
return $response->withJson(['success'], 200);
|
||||
# dispatch event
|
||||
$page = ['content' => $this->content, 'meta' => $meta, 'item' => $this->item];
|
||||
$this->c->dispatcher->dispatch('onPagePublished', new OnPagePublished($page));
|
||||
|
||||
return $response->withJson(['success' => true, 'meta' => $meta], 200);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -260,7 +266,7 @@ class ArticleApiController extends ContentController
|
||||
}
|
||||
else
|
||||
{
|
||||
return $response->withJson(array('data' => $this->structure, 'errors' => $this->errors), 404);
|
||||
return $response->withJson(array('data' => $this->structure, 'errors' => $this->errors), 422);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,13 +471,12 @@ class ArticleApiController extends ContentController
|
||||
# create the url for the item
|
||||
$urlWoF = $folder->urlRelWoF . '/' . $slug;
|
||||
|
||||
# add the navigation name to the item htmlspecialchars needed for frensh language
|
||||
# add the navigation name to the item htmlspecialchars needed for french language
|
||||
$extended[$urlWoF] = ['hide' => false, 'navtitle' => $name];
|
||||
|
||||
# store the extended structure
|
||||
$write->updateYaml('cache', 'structure-extended.yaml', $extended);
|
||||
|
||||
|
||||
# update the structure for editor
|
||||
$this->setStructure($draft = true, $cache = false);
|
||||
|
||||
@@ -482,7 +487,6 @@ class ArticleApiController extends ContentController
|
||||
|
||||
return $response->withJson(array('posts' => $folder, $this->structure, 'errors' => false, 'url' => $url));
|
||||
}
|
||||
|
||||
|
||||
public function createArticle(Request $request, Response $response, $args)
|
||||
{
|
||||
@@ -546,14 +550,10 @@ class ArticleApiController extends ContentController
|
||||
if($writeError){ return $response->withJson(array('data' => $this->structure, 'errors' => 'Something went wrong. Please refresh the page and check, if all folders and files are writable.', 'url' => $url), 404); }
|
||||
|
||||
# add prefix number to the name
|
||||
# $namePath = $index > 9 ? $index . '-' . $name : '0' . $index . '-' . $name;
|
||||
$namePath = $index > 9 ? $index . '-' . $slug : '0' . $index . '-' . $slug;
|
||||
$folderPath = 'content' . $folder->path;
|
||||
|
||||
# $title = implode(" ", $nameParts);
|
||||
|
||||
# create default content
|
||||
# $content = json_encode(['# ' . $title, 'Content']);
|
||||
$content = json_encode(['# ' . $name, 'Content']);
|
||||
|
||||
if($this->params['type'] == 'file')
|
||||
@@ -576,21 +576,18 @@ class ArticleApiController extends ContentController
|
||||
|
||||
}
|
||||
|
||||
|
||||
# get extended structure
|
||||
$extended = $write->getYaml('cache', 'structure-extended.yaml');
|
||||
|
||||
# create the url for the item
|
||||
$urlWoF = $folder->urlRelWoF . '/' . $slug;
|
||||
|
||||
# add the navigation name to the item htmlspecialchars needed for frensh language
|
||||
# add the navigation name to the item htmlspecialchars needed for french language
|
||||
$extended[$urlWoF] = ['hide' => false, 'navtitle' => $name];
|
||||
|
||||
# store the extended structure
|
||||
$write->updateYaml('cache', 'structure-extended.yaml', $extended);
|
||||
|
||||
|
||||
|
||||
# update the structure for editor
|
||||
$this->setStructure($draft = true, $cache = false);
|
||||
|
||||
@@ -643,7 +640,7 @@ class ArticleApiController extends ContentController
|
||||
# check, if the same name as new item, then return an error
|
||||
if($item->slug == $slug)
|
||||
{
|
||||
return $response->withJson(array('data' => $this->structure, 'errors' => 'There is already a page with this name. Please choose another name.', 'url' => $url), 404);
|
||||
return $response->withJson(array('data' => $this->structure, 'errors' => 'There is already a page with this name. Please choose another name.', 'url' => $url), 422);
|
||||
}
|
||||
|
||||
if(!$write->moveElement($item, '', $index))
|
||||
@@ -653,7 +650,7 @@ class ArticleApiController extends ContentController
|
||||
$index++;
|
||||
}
|
||||
|
||||
if($writeError){ return $response->withJson(array('data' => $this->structure, 'errors' => 'Something went wrong. Please refresh the page and check, if all folders and files are writable.', 'url' => $url), 404); }
|
||||
if($writeError){ return $response->withJson(array('data' => $this->structure, 'errors' => 'Something went wrong. Please refresh the page and check, if all folders and files are writable.', 'url' => $url), 422); }
|
||||
|
||||
# add prefix number to the name
|
||||
$namePath = $index > 9 ? $index . '-' . $slug : '0' . $index . '-' . $slug;
|
||||
@@ -667,14 +664,14 @@ class ArticleApiController extends ContentController
|
||||
{
|
||||
if(!$write->writeFile($folderPath, $namePath . '.txt', $content))
|
||||
{
|
||||
return $response->withJson(array('data' => $this->structure, 'errors' => 'We could not create the file. Please refresh the page and check, if all folders and files are writable.', 'url' => $url), 404);
|
||||
return $response->withJson(array('data' => $this->structure, 'errors' => 'We could not create the file. Please refresh the page and check, if all folders and files are writable.', 'url' => $url), 422);
|
||||
}
|
||||
}
|
||||
elseif($this->params['type'] == 'folder')
|
||||
{
|
||||
if(!$write->checkPath($folderPath . DIRECTORY_SEPARATOR . $namePath))
|
||||
{
|
||||
return $response->withJson(array('data' => $this->structure, 'errors' => 'We could not create the folder. Please refresh the page and check, if all folders and files are writable.', 'url' => $url), 404);
|
||||
return $response->withJson(array('data' => $this->structure, 'errors' => 'We could not create the folder. Please refresh the page and check, if all folders and files are writable.', 'url' => $url), 422);
|
||||
}
|
||||
$write->writeFile($folderPath . DIRECTORY_SEPARATOR . $namePath, 'index.txt', $content);
|
||||
|
||||
@@ -695,7 +692,6 @@ class ArticleApiController extends ContentController
|
||||
# store the extended structure
|
||||
$write->updateYaml('cache', 'structure-extended.yaml', $extended);
|
||||
|
||||
|
||||
# update the structure for editor
|
||||
$this->setStructure($draft = true, $cache = false);
|
||||
|
||||
|
@@ -24,7 +24,6 @@ class AuthController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* show login form
|
||||
*
|
||||
|
@@ -769,28 +769,29 @@ class BlockApiController extends ContentController
|
||||
$imageData = @file_get_contents($videoURL0, 0, $ctx);
|
||||
if($imageData === false)
|
||||
{
|
||||
return $response->withJson(array('errors' => 'could not get the video image'));
|
||||
return $response->withJson(['errors' => ['message' => 'We did not find that video or could not get a preview image.']], 500);
|
||||
}
|
||||
}
|
||||
|
||||
$imageData64 = 'data:image/jpeg;base64,' . base64_encode($imageData);
|
||||
$desiredSizes = ['live' => ['width' => 560, 'height' => 315]];
|
||||
$imageProcessor = new ProcessImage($this->settings['images']);
|
||||
if(!$imageProcessor->checkFolders())
|
||||
$imageData64 = 'data:image/jpeg;base64,' . base64_encode($imageData);
|
||||
$desiredSizes = $this->settings['images'];
|
||||
$desiredSizes['live'] = ['width' => 560, 'height' => 315];
|
||||
$imageProcessor = new ProcessImage($desiredSizes);
|
||||
|
||||
if(!$imageProcessor->checkFolders('images'))
|
||||
{
|
||||
return $response->withJson(['errors' => ['message' => 'Please check if your media-folder exists and all folders inside are writable.']], 500);
|
||||
}
|
||||
|
||||
$tmpImage = $imageProcessor->createImage($imageData64, $desiredSizes);
|
||||
|
||||
if(!$tmpImage)
|
||||
if(!$imageProcessor->createImage($imageData64, 'youtube-' . $videoID, $desiredSizes, $overwrite = true))
|
||||
{
|
||||
return $response->withJson(array('errors' => 'could not create temporary image'));
|
||||
return $response->withJson(['errors' => ['message' => 'We could not create the image.']], 500);
|
||||
}
|
||||
|
||||
$imageUrl = $imageProcessor->publishImage($desiredSizes, $videoID);
|
||||
|
||||
$imageUrl = $imageProcessor->publishImage();
|
||||
if($imageUrl)
|
||||
{
|
||||
|
||||
$this->params['markdown'] = '{#' . $videoID. ' .' . $class . '}';
|
||||
|
||||
$request = $request->withParsedBody($this->params);
|
||||
|
@@ -60,6 +60,7 @@ abstract class ContentController
|
||||
$this->structureDraftName = 'structure-draft.txt';
|
||||
}
|
||||
|
||||
# admin ui rendering
|
||||
protected function render($response, $route, $data)
|
||||
{
|
||||
if(isset($_SESSION['old']))
|
||||
@@ -68,7 +69,7 @@ abstract class ContentController
|
||||
}
|
||||
|
||||
$response = $response->withoutHeader('Server');
|
||||
$response = $response->withoutHeader('X-Powered-By');
|
||||
$response = $response->withoutHeader('X-Powered-By');
|
||||
|
||||
if($this->c->request->getUri()->getScheme() == 'https')
|
||||
{
|
||||
@@ -376,7 +377,7 @@ abstract class ContentController
|
||||
if(file_exists($path))
|
||||
{
|
||||
$files = array_diff(scandir($path), array('.', '..'));
|
||||
|
||||
|
||||
# check if there are published pages or folders inside, then stop the operation
|
||||
foreach ($files as $file)
|
||||
{
|
||||
@@ -385,9 +386,9 @@ abstract class ContentController
|
||||
$this->errors = ['message' => 'Please delete the sub-folder first.'];
|
||||
}
|
||||
|
||||
if(substr($file, -3) == '.md' )
|
||||
if(substr($file, -3) == '.md' && $file != 'index.md')
|
||||
{
|
||||
$this->errors = ['message' => 'Please unpublish all pages in the folder first.'];
|
||||
$this->errors = ['message' => 'Please unpublish all pages in the folder first.'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -18,6 +18,7 @@ abstract class Controller
|
||||
$this->c = $c;
|
||||
}
|
||||
|
||||
# frontend rendering
|
||||
protected function render($response, $route, $data)
|
||||
{
|
||||
# why commented this out??
|
||||
@@ -29,8 +30,6 @@ abstract class Controller
|
||||
}
|
||||
|
||||
$response = $response->withoutHeader('Server');
|
||||
$response = $response->withoutHeader('X-Powered-By');
|
||||
|
||||
if($this->c->request->getUri()->getScheme() == 'https')
|
||||
{
|
||||
$response = $response->withAddedHeader('Strict-Transport-Security', 'max-age=63072000');
|
||||
@@ -40,6 +39,8 @@ abstract class Controller
|
||||
$response = $response->withAddedHeader('X-Frame-Options', 'SAMEORIGIN');
|
||||
$response = $response->withAddedHeader('X-XSS-Protection', '1;mode=block');
|
||||
$response = $response->withAddedHeader('Referrer-Policy', 'no-referrer-when-downgrade');
|
||||
$response = $response->withAddedHeader('X-Powered-By', 'Typemill');
|
||||
|
||||
|
||||
return $this->c->view->render($response, $route, $data);
|
||||
}
|
||||
|
@@ -320,19 +320,34 @@ class MediaApiController extends ContentController
|
||||
return $response->withJson(array('errors' => 'could not store the preview image'));
|
||||
}
|
||||
|
||||
# https://www.sitepoint.com/mime-types-complete-list/
|
||||
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
|
||||
private function getAllowedMtypes()
|
||||
{
|
||||
return array(
|
||||
'application/zip',
|
||||
'application/gzip',
|
||||
'application/x-gzip',
|
||||
'application/x-compressed',
|
||||
'application/x-zip-compressed',
|
||||
'application/vnd.rar',
|
||||
'application/x-7z-compressed',
|
||||
'application/x-visio',
|
||||
'application/vnd.visio',
|
||||
'application/excel',
|
||||
'application/x-excel',
|
||||
'application/x-msexcel',
|
||||
'application/vnd.ms-excel',
|
||||
'application/vnd.ms-powerpoint',
|
||||
'application/vnd.ms-word.document.macroEnabled.12',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
'application/powerpoint',
|
||||
'application/mspowerpoint',
|
||||
'application/x-mspowerpoint',
|
||||
'application/vnd.ms-powerpoint',
|
||||
'application/vnd.openxmlformats-officedocument.presentationml.presentation',
|
||||
'application/msword',
|
||||
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
|
||||
'application/x-project',
|
||||
'application/vnd.ms-project',
|
||||
'application/vnd.apple.keynote',
|
||||
'application/vnd.apple.mpegurl',
|
||||
'application/vnd.apple.numbers',
|
||||
@@ -340,17 +355,31 @@ class MediaApiController extends ContentController
|
||||
'application/vnd.amazon.mobi8-ebook',
|
||||
'application/epub+zip',
|
||||
'application/pdf',
|
||||
'application/x-latex',
|
||||
'image/png',
|
||||
'image/jpeg',
|
||||
'image/gif',
|
||||
'image/tiff',
|
||||
'image/x-tiff',
|
||||
'image/svg+xml',
|
||||
'image/x-icon',
|
||||
'text/plain',
|
||||
'application/plain',
|
||||
'text/richtext',
|
||||
'text/vnd.rn-realtext',
|
||||
'application/rtf',
|
||||
'application/x-rtf',
|
||||
'font/*',
|
||||
'audio/mpeg',
|
||||
'audio/mp4',
|
||||
'audio/ogg',
|
||||
'audio/3gpp',
|
||||
'audio/3gpp2',
|
||||
'video/mpeg',
|
||||
'video/mp4',
|
||||
'video/ogg',
|
||||
'video/3gpp',
|
||||
'video/3gpp2',
|
||||
);
|
||||
}
|
||||
}
|
@@ -5,6 +5,7 @@ namespace Typemill\Controllers;
|
||||
use Slim\Http\Request;
|
||||
use Slim\Http\Response;
|
||||
use Typemill\Models\WriteYaml;
|
||||
use Typemill\Models\WriteMeta;
|
||||
use Typemill\Models\Folder;
|
||||
|
||||
class MetaApiController extends ContentController
|
||||
@@ -24,6 +25,7 @@ class MetaApiController extends ContentController
|
||||
|
||||
$metatabs = $writeYaml->getYaml('system' . DIRECTORY_SEPARATOR . 'author', 'metatabs.yaml');
|
||||
|
||||
# add radio buttons to choose posts or pages for folder.
|
||||
if($folder)
|
||||
{
|
||||
$metatabs['meta']['fields']['contains'] = [
|
||||
@@ -70,22 +72,22 @@ class MetaApiController extends ContentController
|
||||
# set item
|
||||
if(!$this->setItem()){ return $response->withJson($this->errors, 404); }
|
||||
|
||||
$writeYaml = new writeYaml();
|
||||
$writeMeta = new writeMeta();
|
||||
|
||||
$pagemeta = $writeYaml->getPageMeta($this->settings, $this->item);
|
||||
$pagemeta = $writeMeta->getPageMeta($this->settings, $this->item);
|
||||
|
||||
if(!$pagemeta)
|
||||
{
|
||||
# set the status for published and drafted
|
||||
$this->setPublishStatus();
|
||||
|
||||
|
||||
# set path
|
||||
$this->setItemPath($this->item->fileType);
|
||||
|
||||
# read content from file
|
||||
if(!$this->setContent()){ return $response->withJson(array('data' => false, 'errors' => $this->errors), 404); }
|
||||
|
||||
$pagemeta = $writeYaml->getPageMetaDefaults($this->content, $this->settings, $this->item);
|
||||
$pagemeta = $writeMeta->getPageMetaBlank($this->content, $this->settings, $this->item);
|
||||
}
|
||||
|
||||
# if item is a folder
|
||||
@@ -118,7 +120,7 @@ class MetaApiController extends ContentController
|
||||
}
|
||||
|
||||
# store the metascheme in cache for frontend
|
||||
$writeYaml->updateYaml('cache', 'metatabs.yaml', $metascheme);
|
||||
$writeMeta->updateYaml('cache', 'metatabs.yaml', $metascheme);
|
||||
|
||||
return $response->withJson(array('metadata' => $metadata, 'metadefinitions' => $metadefinitions, 'item' => $this->item, 'errors' => false));
|
||||
}
|
||||
@@ -187,13 +189,13 @@ class MetaApiController extends ContentController
|
||||
# return validation errors
|
||||
if($errors){ return $response->withJson(array('errors' => $errors),422); }
|
||||
|
||||
$writeYaml = new writeYaml();
|
||||
$writeMeta = new writeMeta();
|
||||
|
||||
# get existing metadata for page
|
||||
$metaPage = $writeYaml->getYaml($this->settings['contentFolder'], $this->item->pathWithoutType . '.yaml');
|
||||
$metaPage = $writeMeta->getYaml($this->settings['contentFolder'], $this->item->pathWithoutType . '.yaml');
|
||||
|
||||
# get extended structure
|
||||
$extended = $writeYaml->getYaml('cache', 'structure-extended.yaml');
|
||||
$extended = $writeMeta->getYaml('cache', 'structure-extended.yaml');
|
||||
|
||||
# flag for changed structure
|
||||
$structure = false;
|
||||
@@ -218,7 +220,7 @@ class MetaApiController extends ContentController
|
||||
$pathWithoutFile = str_replace($this->item->originalName, "", $this->item->path);
|
||||
$newPathWithoutType = $pathWithoutFile . $datetime . '-' . $this->item->slug;
|
||||
|
||||
$writeYaml->renamePost($this->item->pathWithoutType, $newPathWithoutType);
|
||||
$writeMeta->renamePost($this->item->pathWithoutType, $newPathWithoutType);
|
||||
|
||||
# recreate the draft structure
|
||||
$this->setStructure($draft = true, $cache = false);
|
||||
@@ -235,11 +237,11 @@ class MetaApiController extends ContentController
|
||||
|
||||
if($metaInput['contains'] == "posts")
|
||||
{
|
||||
$writeYaml->transformPagesToPosts($this->item);
|
||||
$writeMeta->transformPagesToPosts($this->item);
|
||||
}
|
||||
if($metaInput['contains'] == "pages")
|
||||
{
|
||||
$writeYaml->transformPostsToPages($this->item);
|
||||
$writeMeta->transformPostsToPages($this->item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -273,12 +275,12 @@ class MetaApiController extends ContentController
|
||||
$meta[$tab] = $metaInput;
|
||||
|
||||
# store the metadata
|
||||
$writeYaml->updateYaml($this->settings['contentFolder'], $this->item->pathWithoutType . '.yaml', $meta);
|
||||
$writeMeta->updateYaml($this->settings['contentFolder'], $this->item->pathWithoutType . '.yaml', $meta);
|
||||
|
||||
if($structure)
|
||||
{
|
||||
# store the extended file
|
||||
$writeYaml->updateYaml('cache', 'structure-extended.yaml', $extended);
|
||||
$writeMeta->updateYaml('cache', 'structure-extended.yaml', $extended);
|
||||
|
||||
# recreate the draft structure
|
||||
$this->setStructure($draft = true, $cache = false);
|
||||
@@ -309,6 +311,4 @@ class MetaApiController extends ContentController
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
# check models -> writeYaml for getPageMeta and getPageMetaDefaults.
|
||||
}
|
@@ -6,6 +6,7 @@ use Typemill\Models\Folder;
|
||||
use Typemill\Models\WriteCache;
|
||||
use Typemill\Models\WriteSitemap;
|
||||
use Typemill\Models\WriteYaml;
|
||||
use Typemill\Models\WriteMeta;
|
||||
use \Symfony\Component\Yaml\Yaml;
|
||||
use Typemill\Models\VersionCheck;
|
||||
use Typemill\Models\Helpers;
|
||||
@@ -30,7 +31,6 @@ class PageController extends Controller
|
||||
$item = false;
|
||||
$home = false;
|
||||
$breadcrumb = false;
|
||||
$description = '';
|
||||
$settings = $this->c->get('settings');
|
||||
$pathToContent = $settings['rootPath'] . $settings['contentFolder'];
|
||||
$cache = new WriteCache();
|
||||
@@ -61,10 +61,6 @@ class PageController extends Controller
|
||||
/* update sitemap */
|
||||
$sitemap = new WriteSitemap();
|
||||
$sitemap->updateSitemap('cache', 'sitemap.xml', 'lastSitemap.txt', $structure, $uri->getBaseUrl());
|
||||
|
||||
/* check and update the typemill-version in the user settings */
|
||||
# this version check is not needed
|
||||
# $this->updateVersion($uri->getBaseUrl());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +85,7 @@ class PageController extends Controller
|
||||
if(empty($args))
|
||||
{
|
||||
$home = true;
|
||||
$item = Folder::getItemForUrl($structure, $uri->getBasePath(), $uri->getBasePath());
|
||||
$item = Folder::getItemForUrl($navigation, $uri->getBasePath(), $uri->getBasePath());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -110,10 +106,10 @@ class PageController extends Controller
|
||||
$breadcrumb = $this->c->dispatcher->dispatch('onBreadcrumbLoaded', new OnBreadcrumbLoaded($breadcrumb))->getData();
|
||||
|
||||
# set pages active for navigation again
|
||||
Folder::getBreadcrumb($navigation, $item->keyPathArray);
|
||||
Folder::getBreadcrumb($structure, $item->keyPathArray);
|
||||
|
||||
/* add the paging to the item */
|
||||
$item = Folder::getPagingForItem($structure, $item);
|
||||
$item = Folder::getPagingForItem($navigation, $item);
|
||||
}
|
||||
|
||||
# dispatch the item
|
||||
@@ -126,6 +122,9 @@ class PageController extends Controller
|
||||
if($item->elementType == 'folder')
|
||||
{
|
||||
$filePath = $filePath . DIRECTORY_SEPARATOR . 'index.md';
|
||||
|
||||
# use navigation instead of structure to get
|
||||
$item = Folder::getItemForUrl($navigation, $urlRel, $uri->getBasePath());
|
||||
}
|
||||
|
||||
# read the content of the file
|
||||
@@ -135,13 +134,10 @@ class PageController extends Controller
|
||||
$this->c->dispatcher->dispatch('onOriginalLoaded', new OnOriginalLoaded($contentMD));
|
||||
|
||||
# get meta-Information
|
||||
$writeYaml = new WriteYaml();
|
||||
$metatabs = $writeYaml->getPageMeta($settings, $item);
|
||||
$writeMeta = new WriteMeta();
|
||||
|
||||
if(!$metatabs)
|
||||
{
|
||||
$metatabs = $writeYaml->getPageMetaDefaults($contentMD, $settings, $item);
|
||||
}
|
||||
# makes sure that you always have the full meta with title, description and all the rest.
|
||||
$metatabs = $writeMeta->completePageMeta($contentMD, $settings, $item);
|
||||
|
||||
# dispatch meta
|
||||
$metatabs = $this->c->dispatcher->dispatch('onMetaLoaded', new OnMetaLoaded($metatabs))->getData();
|
||||
@@ -149,20 +145,20 @@ class PageController extends Controller
|
||||
# dispatch content
|
||||
$contentMD = $this->c->dispatcher->dispatch('onMarkdownLoaded', new OnMarkdownLoaded($contentMD))->getData();
|
||||
|
||||
$itemUrl = isset($item->urlRel) ? $item->urlRel : false;
|
||||
|
||||
/* initialize parsedown */
|
||||
$parsedown = new ParsedownExtension();
|
||||
$parsedown = new ParsedownExtension($settings['headlineanchors']);
|
||||
|
||||
/* set safe mode to escape javascript and html in markdown */
|
||||
$parsedown->setSafeMode(true);
|
||||
|
||||
/* parse markdown-file to content-array */
|
||||
$contentArray = $parsedown->text($contentMD);
|
||||
$contentArray = $parsedown->text($contentMD, $itemUrl);
|
||||
$contentArray = $this->c->dispatcher->dispatch('onContentArrayLoaded', new OnContentArrayLoaded($contentArray))->getData();
|
||||
|
||||
/* get the first image from content array */
|
||||
$firstImage = $this->getFirstImage($contentArray);
|
||||
|
||||
$itemUrl = isset($item->urlRel) ? $item->urlRel : false;
|
||||
|
||||
/* parse markdown-content-array to content-string */
|
||||
$contentHTML = $parsedown->markup($contentArray, $itemUrl);
|
||||
@@ -172,25 +168,7 @@ class PageController extends Controller
|
||||
$contentParts = explode("</h1>", $contentHTML);
|
||||
$title = isset($contentParts[0]) ? strip_tags($contentParts[0]) : $settings['title'];
|
||||
|
||||
$contentHTML = isset($contentParts[1]) ? $contentParts[1] : $contentHTML;
|
||||
|
||||
# if there is not meta description
|
||||
if(!isset($metatabs['meta']['description']) or !$metatabs['meta']['description'])
|
||||
{
|
||||
# create excerpt from html
|
||||
$excerpt = substr($contentHTML,0,500);
|
||||
|
||||
# create description from excerpt
|
||||
$description = isset($excerpt) ? strip_tags($excerpt) : false;
|
||||
if($description)
|
||||
{
|
||||
$description = trim(preg_replace('/\s+/', ' ', $description));
|
||||
$description = substr($description, 0, 300);
|
||||
$lastSpace = strrpos($description, ' ');
|
||||
|
||||
$metatabs['meta']['description'] = substr($description, 0, $lastSpace);
|
||||
}
|
||||
}
|
||||
$contentHTML = isset($contentParts[1]) ? $contentParts[1] : $contentHTML;
|
||||
|
||||
/* get url and alt-tag for first image, if exists */
|
||||
if($firstImage)
|
||||
@@ -208,7 +186,7 @@ class PageController extends Controller
|
||||
$route = empty($args) && isset($settings['themes'][$theme]['cover']) ? '/cover.twig' : '/index.twig';
|
||||
|
||||
# check if there is a custom theme css
|
||||
$customcss = $writeYaml->checkFile('cache', $theme . '-custom.css');
|
||||
$customcss = $writeMeta->checkFile('cache', $theme . '-custom.css');
|
||||
if($customcss)
|
||||
{
|
||||
$this->c->assets->addCSS($base_url . '/cache/' . $theme . '-custom.css');
|
||||
@@ -262,10 +240,10 @@ class PageController extends Controller
|
||||
$yaml = new writeYaml();
|
||||
$extended = $yaml->getYaml('cache', 'structure-extended.yaml');
|
||||
|
||||
/* create an array of object with the whole content of the folder */
|
||||
# create an array of object with the whole content of the folder
|
||||
$structure = Folder::getFolderContentDetails($structure, $extended, $uri->getBaseUrl(), $uri->getBasePath());
|
||||
|
||||
/* cache structure */
|
||||
# cache structure
|
||||
$cache->updateCache('cache', 'structure.txt', 'lastCache.txt', $structure);
|
||||
|
||||
if($extended && $this->containsHiddenPages($extended))
|
||||
@@ -282,7 +260,8 @@ class PageController extends Controller
|
||||
$cache->deleteFileWithPath('cache' . DIRECTORY_SEPARATOR . 'navigation.txt');
|
||||
}
|
||||
|
||||
return $structure;
|
||||
# load and return the cached structure, because might be manipulated with navigation....
|
||||
return $this->getCachedStructure($cache);
|
||||
}
|
||||
|
||||
protected function containsHiddenPages($extended)
|
||||
|
@@ -57,15 +57,16 @@ class SettingsController extends Controller
|
||||
{
|
||||
/* make sure only allowed fields are stored */
|
||||
$newSettings = array(
|
||||
'title' => $newSettings['title'],
|
||||
'author' => $newSettings['author'],
|
||||
'copyright' => $newSettings['copyright'],
|
||||
'year' => $newSettings['year'],
|
||||
'language' => $newSettings['language'],
|
||||
'editor' => $newSettings['editor'],
|
||||
'formats' => $newSettings['formats'],
|
||||
'title' => $newSettings['title'],
|
||||
'author' => $newSettings['author'],
|
||||
'copyright' => $newSettings['copyright'],
|
||||
'year' => $newSettings['year'],
|
||||
'language' => $newSettings['language'],
|
||||
'editor' => $newSettings['editor'],
|
||||
'formats' => $newSettings['formats'],
|
||||
'headlineanchors' => isset($newSettings['headlineanchors']) ? $newSettings['headlineanchors'] : null,
|
||||
);
|
||||
|
||||
|
||||
# https://www.slimframework.com/docs/v3/cookbook/uploading-files.html;
|
||||
|
||||
$copyright = $this->getCopyright();
|
||||
|
@@ -52,7 +52,7 @@ class SetupController extends Controller
|
||||
$setuperrors = empty($systemcheck) ? false : 'Some system requirements for Typemill are missing.';
|
||||
$systemcheck = empty($systemcheck) ? false : $systemcheck;
|
||||
|
||||
return $this->render($response, 'auth/setup.twig', array( 'messages' => $setuperror, 'systemcheck' => $systemcheck ));
|
||||
return $this->render($response, 'auth/setup.twig', array( 'messages' => $setuperrors, 'systemcheck' => $systemcheck ));
|
||||
}
|
||||
|
||||
public function create($request, $response, $args)
|
||||
|
Reference in New Issue
Block a user