1
0
mirror of https://github.com/typemill/typemill.git synced 2025-04-30 08:38:21 +02:00

editor version

This commit is contained in:
Sebastian 2018-06-03 18:34:33 +02:00
parent 6b7fac91a4
commit cea5fb1b02
8 changed files with 185 additions and 24 deletions

2
cache/lastCache.txt vendored
View File

@ -1 +1 @@
1527608103
1528043372

View File

@ -5,9 +5,14 @@ namespace Typemill\Controllers;
use Slim\Views\Twig;
use Slim\Http\Request;
use Slim\Http\Response;
use Typemill\Models\Folder;
use Typemill\Models\WriteYaml;
use \Symfony\Component\Yaml\Yaml;
use Typemill\Models\Helpers;
class ContentController extends Controller
{
{
/**
* Show Content
*
@ -16,8 +21,81 @@ class ContentController extends Controller
* @return obje $response with redirect to route
*/
public function showContent(Request $request, Response $response)
public function showContent(Request $request, Response $response, $args)
{
$this->render($response, 'content/content.twig', array('navigation' => true));
}
$settings = $this->c->get('settings');
$pathToContent = $settings['rootPath'] . $settings['contentFolder'];
$uri = $request->getUri();
/* scan the content of the folder */
$structure = Folder::scanFolder($pathToContent);
/* if there is no content, render an empty page */
if(count($structure) == 0)
{
return $this->render($response, 'content/content.twig', array( 'navigation' => true, 'content' => 'Nothing found in content folder.' ));
}
/* create an array of object with the whole content of the folder */
$structure = Folder::getFolderContentDetails($structure, $uri->getBaseUrl(), $uri->getBasePath());
/* if there is no structure at all, the content folder is probably empty */
if(!$structure)
{
return $this->render($response, 'content/content.twig', array( 'navigation' => true, 'content' => 'Nothing found in content folder.' ));
}
/* if it is the startpage */
if(empty($args))
{
/* check, if there is an index-file in the root of the content folder */
$contentMD = file_exists($pathToContent . DIRECTORY_SEPARATOR . 'index.md') ? file_get_contents($pathToContent . DIRECTORY_SEPARATOR . 'index.md') : NULL;
}
else
{
/* get the request url */
$urlRel = $uri->getBasePath() . '/' . $args['params'];
/* find the url in the content-item-tree and return the item-object for the file */
$item = Folder::getItemForUrl($structure, $urlRel);
/* if there is still no item, return a 404-page */
if(!$item)
{
return $this->render404($response, array( 'navigation' => $structure, 'settings' => $settings, 'base_url' => $base_url ));
}
/* add the paging to the item */
$item = Folder::getPagingForItem($structure, $item);
/* check if url is a folder. If so, check if there is an index-file in that folder */
if($item->elementType == 'folder' && $item->index)
{
$filePath = $pathToContent . $item->path . DIRECTORY_SEPARATOR . 'index.md';
}
elseif($item->elementType == 'file')
{
$filePath = $pathToContent . $item->path;
}
/* add the modified date for the file */
$item->modified = isset($filePath) ? filemtime($filePath) : false;
/* read the content of the file */
$contentMD = isset($filePath) ? file_get_contents($filePath) : false;
}
$title = false;
$content = $contentMD;
if($contentMD[0] == '#')
{
$contentParts = explode("\r\n", $contentMD, 2);
$title = trim($contentParts[0], "# \t\n\r\0\x0B");
$content = trim($contentParts[1]);
}
return $this->render($response, 'content/content.twig', array('navigation' => $structure, 'title' => $title, 'content' => $content, 'item' => $item, 'settings' => $settings ));
}
}

View File

@ -31,7 +31,6 @@ $app->get('/tm', AuthController::class . ':redirect');
$app->get('/tm/login', AuthController::class . ':show')->setName('auth.show')->add(new RedirectIfAuthenticated($container['router']));
$app->post('/tm/login', AuthController::class . ':login')->setName('auth.login')->add(new RedirectIfAuthenticated($container['router']));
$app->get('/tm/logout', AuthController::class . ':logout')->setName('auth.logout')->add(new RedirectIfUnauthenticated($container['router'], $container['flash']));
$app->get('/tm/content', ContentController::class . ':showContent')->setName('content.show')->add(new RedirectIfUnauthenticated($container['router'], $container['flash']));
$app->get('/tm/settings', SettingsController::class . ':showSettings')->setName('settings.show')->add(new RedirectIfNoAdmin($container['router'], $container['flash']));
$app->post('/tm/settings', SettingsController::class . ':saveSettings')->setName('settings.save')->add(new RedirectIfNoAdmin($container['router'], $container['flash']));
@ -45,9 +44,10 @@ $app->post('/tm/user/create', SettingsController::class . ':createUser')->setNam
$app->post('/tm/user/update', SettingsController::class . ':updateUser')->setName('user.update')->add(new RedirectIfUnauthenticated($container['router'], $container['flash']));
$app->post('/tm/user/delete', SettingsController::class . ':deleteUser')->setName('user.delete')->add(new RedirectIfUnauthenticated($container['router'], $container['flash']));
$app->get('/tm/user/{username}', SettingsController::class . ':showUser')->setName('user.show')->add(new RedirectIfUnauthenticated($container['router'], $container['flash']));
$app->get('/tm/user', SettingsController::class . ':listUser')->setName('user.list')->add(new RedirectIfNoAdmin($container['router'], $container['flash']));
$app->get('/tm/content/[{params:.*}]', ContentController::class . ':showContent')->setName('content.show')->add(new RedirectIfUnauthenticated($container['router'], $container['flash']));
foreach($routes as $pluginRoute)
{
$method = $pluginRoute['httpMethod'];

View File

@ -6,15 +6,19 @@
<div class="formWrapper">
<section>
<header>
<h1>Coming Soon!</h1>
</header>
<p>Yes, we are now working on a content area and you can edit your text online very soon!</p>
<p>For time beeing, please write your pages offline with markdown and upload your markdown-files to the content folder via ftp.</p>
<p>Stay updated, the content editor will be added in one of the next releases ...</p>
<p>Happy writing</p>
<p>TYPEMILL</p>
<form>
<fieldset>
<div class="large">
<label for="title">Title*</label>
<input name="title" type="text" value="{{ title }}" required />
</div>
<div class="large">
<label for="content">Text*</label>
<textarea name="content" rows="20" required>{{ content }}</textarea>
</div>
</fieldset>
</form>
</section>

View File

@ -1104,7 +1104,7 @@ label .help, .label .help{
}
.sidebar-menu{
max-height: 2000px;
padding: 0px 20px;
padding: 0px 20px 0 0;
overflow: hidden;
box-sizing: border-box;
font-size: 1em;
@ -1116,8 +1116,22 @@ label .help, .label .help{
height: 0px;
}
ul.menu-list{
margin:5px 0 50px;
margin: 5px 0 0 20px;
}
.level-1 > ul.menu-list{
margin-bottom: 30px;
}
.menu-list li{
font-weight: 300;
}
.sidebar-menu, .sidebar-menu--content{
font-size: 0.9em;
}
.sidebar-menu--content li.level-1{
font-weight: 700;
}
/*
.menu-item a, .menu-item a:link, .menu-item a:visited{
background: transparent;
width: auto;
@ -1134,6 +1148,31 @@ label .help, .label .help{
background: transparent;
border-left: 10px solid #e0474c;
}
*/
.menu-item a, .menu-item a:link, .menu-item a:visited{
position: relative;
width: auto;
padding: 1px 0px;
line-height: 1.2em;
border: 0px;
}
.menu-item a:hover, .menu-item a:focus, .menu-item a:active, .menu-item a.active, .active > a{
color: #fff;
color: #e0474c;
background: transparent;
}
.menu-item a::before{
position: absolute;
left: -15px;
content:"\A";
border-style: solid;
border-width: 8px 0px 8px 8px;
border-color: transparent transparent transparent #fff;
}
.menu-item a:hover:before, .menu-item a:focus:before, .menu-item a:active:before, .menu-item a.active:before{
border-left-color: #e0474c;
}
.card .medium{
padding: 0px 20px;
}

View File

@ -26,7 +26,13 @@
</header>
{% include 'partials/flash.twig' %}
<div class="main">
{% block content %}{% endblock %}
<aside class="sidebar">
{% include 'partials/contentNavi.twig' %}
</aside>
<article>
{% block content %}{% endblock %}
</article>
<footer></footer>
</div>
<script src="{{ base_url }}/system/author/js/author.js"></script>
</body>

View File

@ -1,5 +0,0 @@
<nav class="side-menu">
<h3>Contribute</h3>
<p>Are you a frontend developer and do you want to participate and contribute?</p>
<p>Contribute are welcome on <a href="https://github.com/trendschau/typemill">GITHUB</a>.</p>
</nav>

View File

@ -0,0 +1,39 @@
{% macro loop_over(navigation, base_url) %}
{% import _self as macros %}
{% for element in navigation %}
{% set depth = element.keyPathArray|length %}
{% if element.activeParent %}
<li class="menu-item {{ element.elementType }} level-{{ depth }} active parent">
{% elseif element.active %}
<li class="menu-item {{ element.elementType }} level-{{ depth }} active">
{% else %}
<li class="menu-item {{ element.elementType }} level-{{ depth }}">
{% endif %}
{% if element.activeParent %}
<a class="parent active" href="{{base_url}}/tm/content{{ element.urlRelWoF }}">{{ element.name|title }}</a>
{% elseif element.active %}
<a class="active" href="{{base_url}}/tm/content{{ element.urlRelWoF }}">{{ element.name|title }}</a>
{% else %}
<a href="{{base_url}}/tm/content{{ element.urlRelWoF }}">{{ element.name|title }}</a>
{% endif %}
{% if (element.elementType == 'folder') %}
<ul class="menu-list">
{{ macros.loop_over(element.folderContent, base_url) }}
</ul>
{% endif %}
</li>
{% endfor %}
{% endmacro %}
{% import _self as macros %}
<nav id="sidebar-menu" class="sidebar-menu--content">
<ul class="menu-list">
{{ macros.loop_over(navigation, base_url) }}
</ul>
</nav>