1
0
mirror of https://github.com/typemill/typemill.git synced 2025-08-06 14:16:46 +02:00

Version 1.2.15: Beautiful Math Refactored

This commit is contained in:
Trendschau
2019-06-04 17:07:11 +02:00
parent 3bcc03e5fb
commit 3fce3a5c61
36 changed files with 727 additions and 253 deletions

View File

@@ -502,7 +502,28 @@ class ContentApiController extends ContentController
return $response->withJson(array('data' => $this->structure, 'errors' => false, 'url' => $url));
}
public function getNavigation(Request $request, Response $response, $args)
{
# get params from call
$this->params = $request->getParams();
$this->uri = $request->getUri();
# set structure
if(!$this->setStructure($draft = true, $cache = false)){ return $response->withJson(array('data' => false, 'errors' => $this->errors, 'url' => $url), 404); }
# set information for homepage
$this->setHomepage();
# get item for url and set it active again
if(isset($this->params['url']))
{
$activeItem = Folder::getItemForUrl($this->structure, $this->params['url']);
}
return $response->withJson(array('data' => $this->structure, 'homepage' => $this->homepage, 'errors' => false));
}
public function getArticleMarkdown(Request $request, Response $response, $args)
{
/* get params from call */

View File

@@ -23,10 +23,13 @@ class ContentBackendController extends ContentController
# get params from call
$this->uri = $request->getUri();
$this->params = isset($args['params']) ? ['url' => $this->uri->getBasePath() . '/' . $args['params']] : ['url' => $this->uri->getBasePath()];
# set structure
if(!$this->setStructure($draft = true)){ return $this->renderIntern404($response, array( 'navigation' => true, 'content' => $this->errors )); }
# set information for homepage
$this->setHomepage();
# set item
if(!$this->setItem()){ return $this->renderIntern404($response, array( 'navigation' => $this->structure, 'settings' => $this->settings, 'content' => $this->errors )); }
@@ -72,11 +75,11 @@ class ContentBackendController extends ContentController
}
}
return $this->render($response, 'editor/editor-raw.twig', array('navigation' => $this->structure, 'title' => $title, 'content' => $content, 'item' => $this->item, 'settings' => $this->settings ));
return $this->render($response, 'editor/editor-raw.twig', array('navigation' => $this->structure, 'homepage' => $this->homepage, 'title' => $title, 'content' => $content, 'item' => $this->item, 'settings' => $this->settings ));
}
/**
* Show Content for raw editor
* Show Content for blox editor
*
* @param obj $request the slim request object
* @param obj $response the slim response object
@@ -85,20 +88,19 @@ class ContentBackendController extends ContentController
public function showBlox(Request $request, Response $response, $args)
{
# get params from call
$this->uri = $request->getUri();
$this->params = isset($args['params']) ? ['url' => $this->uri->getBasePath() . '/' . $args['params']] : ['url' => $this->uri->getBasePath()];
# set structure
if(!$this->setStructure($draft = true)){ return $this->renderIntern404($response, array( 'navigation' => true, 'content' => $this->errors )); }
# set information for homepage
$this->setHomepage();
# set item
if(!$this->setItem()){ return $this->renderIntern404($response, array( 'navigation' => $this->structure, 'settings' => $this->settings, 'content' => $this->errors )); }
# get the breadcrumb (here we need it only to mark the actual item active in navigation)
$breadcrumb = isset($this->item->keyPathArray) ? Folder::getBreadcrumb($this->structure, $this->item->keyPathArray) : false;
# set the status for published and drafted
$this->setPublishStatus();
@@ -148,7 +150,7 @@ class ContentBackendController extends ContentController
unset($content[0]);
}
return $this->render($response, 'editor/editor-blox.twig', array('navigation' => $this->structure, 'title' => $title, 'content' => $content, 'item' => $this->item, 'settings' => $this->settings ));
return $this->render($response, 'editor/editor-blox.twig', array('navigation' => $this->structure, 'homepage' => $this->homepage, 'title' => $title, 'content' => $content, 'item' => $this->item, 'settings' => $this->settings ));
}
public function showEmpty(Request $request, Response $response, $args)

View File

@@ -36,6 +36,9 @@ abstract class ContentController
# holds the name of the structure-file without drafts for live site
protected $structureLiveName;
# holds informations about the homepage
protected $homepage;
# hold the page-item as an object
protected $item;
@@ -188,6 +191,34 @@ abstract class ContentController
return true;
}
protected function setHomepage()
{
$contentFolder = Folder::scanFolderFlat($this->settings['rootPath'] . $this->settings['contentFolder']);
if(array_search('index.md', $contentFolder))
{
$md = true;
$status = 'published';
}
if(array_search('index.txt', $contentFolder))
{
$txt = true;
$status = 'unpublished';
}
if(isset($txt) && isset($md))
{
$status = 'modified';
}
$active = false;
if($this->params['url'] == '/' || $this->params['url'] == $this->uri->getBasePath() )
{
$active = 'active';
}
$this->homepage = ['status' => $status, 'active' => $active];
}
protected function setItem()
{
# if it is the homepage

View File

@@ -103,7 +103,7 @@ class PageController extends Controller
$item = $this->c->dispatcher->dispatch('onItemLoaded', new OnItemLoaded($item))->getData();
/* check if url is a folder. If so, check if there is an index-file in that folder */
if($item->elementType == 'folder' && $item->index)
if($item->elementType == 'folder')
{
$filePath = $pathToContent . $item->path . DIRECTORY_SEPARATOR . 'index.md';
}
@@ -126,7 +126,7 @@ class PageController extends Controller
/* initialize parsedown */
$parsedown = new ParsedownExtension();
/* set safe mode to escape javascript and html in markdown */
$parsedown->setSafeMode(true);
@@ -136,7 +136,7 @@ class PageController extends Controller
/* 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 */
@@ -175,7 +175,7 @@ class PageController extends Controller
}
$route = empty($args) && $settings['startpage'] ? '/cover.twig' : '/index.twig';
return $this->render($response, $route, array('navigation' => $structure, 'content' => $contentHTML, 'item' => $item, 'breadcrumb' => $breadcrumb, 'settings' => $settings, 'title' => $title, 'description' => $description, 'base_url' => $base_url, 'image' => $firstImage ));
}

View File

@@ -216,7 +216,7 @@ class SettingsController extends Controller
$uri = $request->getUri();
$base_url = $uri->getBaseUrl();
# security, users should not be able to fake post with settings from other typemill pages.
# users should not be able to fake post with settings from other typemill pages.
if(!isset($referer[0]) OR $referer[0] !== $base_url . '/tm/themes' )
{
$this->c->flash->addMessage('error', 'illegal referer');
@@ -232,7 +232,11 @@ class SettingsController extends Controller
if(isset($themeSettings['settings']['images']))
{
$userSettings = ['images' => $themeSettings['settings']['images']];
# get the default settings
$defaultSettings = \Typemill\Settings::getDefaultSettings();
# merge the default image settings with the theme image settings, delete all others (image settings from old theme)
$userSettings['images'] = array_merge($defaultSettings['images'], $themeSettings['settings']['images']);
}
/* set theme name and delete theme settings from user settings for the case, that the new theme has no settings */

View File

@@ -54,8 +54,8 @@ class SetupController extends Controller
/* login user */
$user->login($username);
/* store updated settings */
\Typemill\Settings::createSettings(array('setup' => false));
# create initial settings file
\Typemill\Settings::createSettings();
return $response->withRedirect($this->c->router->pathFor('setup.welcome'));
}