mirror of
https://github.com/flextype/flextype.git
synced 2025-08-13 00:24:15 +02:00
Admin: General updates, pages list, page editing, adding new page
This commit is contained in:
@@ -96,7 +96,56 @@ class Admin {
|
||||
|
||||
protected static function getPagesManagerPage()
|
||||
{
|
||||
include 'views/pages.php';
|
||||
switch (Http::getUriSegment(2)) {
|
||||
case 'delete':
|
||||
|
||||
break;
|
||||
case 'add':
|
||||
|
||||
$create_page = Http::post('create_page');
|
||||
|
||||
if (isset($create_page)) {
|
||||
if (Filesystem::setFileContent(PAGES_PATH . '/' . Http::post('slug') . '/index.md',
|
||||
'---'."\n".
|
||||
'title: '.Http::post('title')."\n".
|
||||
'---'."\n")) {
|
||||
|
||||
Http::redirect('admin/views/pages/');
|
||||
}
|
||||
}
|
||||
|
||||
View::factory('admin/views/pages/add')
|
||||
->display();
|
||||
break;
|
||||
case 'edit':
|
||||
|
||||
$save_page = Http::post('save_page');
|
||||
|
||||
if (isset($save_page)) {
|
||||
Filesystem::setFileContent(PAGES_PATH . '/' . Http::post('slug') . '/index.md',
|
||||
'---'."\n".
|
||||
Http::post('frontmatter').
|
||||
'---'."\n".
|
||||
Http::post('editor'));
|
||||
}
|
||||
|
||||
$page = trim(Filesystem::getFileContent(PAGES_PATH . '/' . Http::get('page') . '/index.md'));
|
||||
$page = explode('---', $page, 3);
|
||||
|
||||
View::factory('admin/views/pages/editor')
|
||||
->assign('page_slug', Http::get('page'))
|
||||
->assign('page_frontmatter', $page[1])
|
||||
->assign('page_content', $page[2])
|
||||
->display();
|
||||
break;
|
||||
default:
|
||||
$pages_list = Pages::getPages('', false , 'title');
|
||||
|
||||
View::factory('admin/views/pages/index')
|
||||
->assign('pages_list', $pages_list)
|
||||
->display();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected static function getSettingsPage()
|
||||
|
33
site/plugins/admin/package-lock.json
generated
33
site/plugins/admin/package-lock.json
generated
@@ -10,11 +10,44 @@
|
||||
"integrity": "sha512-gulJE5dGFo6Q61V/whS6VM4WIyrlydXfCgkE+Gxe5hjrJ8rXLLZlALq7zq2RPhOc45PSwQpJkrTnc2KgD6cvmA==",
|
||||
"dev": true
|
||||
},
|
||||
"codemirror": {
|
||||
"version": "5.36.0",
|
||||
"resolved": "https://registry.npmjs.org/codemirror/-/codemirror-5.36.0.tgz",
|
||||
"integrity": "sha512-XGR+ic+9DSMSE4mD2XLinGrMcIO4xbHpNrPzAFpCW5bjy+Em8fUOTCpagVP/+LLtTQsAROqrq1f55KyRxDcokA=="
|
||||
},
|
||||
"codemirror-spell-checker": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/codemirror-spell-checker/-/codemirror-spell-checker-1.1.2.tgz",
|
||||
"integrity": "sha1-HGYPkIlIPMtRE7m6nKGcP0mTNx4=",
|
||||
"requires": {
|
||||
"typo-js": "1.0.3"
|
||||
}
|
||||
},
|
||||
"jquery": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/jquery/-/jquery-3.3.1.tgz",
|
||||
"integrity": "sha512-Ubldcmxp5np52/ENotGxlLe6aGMvmF4R8S6tZjsP6Knsaxd/xp3Zrh50cG93lR6nPXyUFwzN3ZSOQI0wRJNdGg==",
|
||||
"dev": true
|
||||
},
|
||||
"marked": {
|
||||
"version": "0.3.19",
|
||||
"resolved": "https://registry.npmjs.org/marked/-/marked-0.3.19.tgz",
|
||||
"integrity": "sha512-ea2eGWOqNxPcXv8dyERdSr/6FmzvWwzjMxpfGB/sbMccXoct+xY+YukPD+QTUZwyvK7BZwcr4m21WBOW41pAkg=="
|
||||
},
|
||||
"simplemde": {
|
||||
"version": "1.11.2",
|
||||
"resolved": "https://registry.npmjs.org/simplemde/-/simplemde-1.11.2.tgz",
|
||||
"integrity": "sha1-ojo12XjSxA7wfewAjJLwcNjggOM=",
|
||||
"requires": {
|
||||
"codemirror": "5.36.0",
|
||||
"codemirror-spell-checker": "1.1.2",
|
||||
"marked": "0.3.19"
|
||||
}
|
||||
},
|
||||
"typo-js": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/typo-js/-/typo-js-1.0.3.tgz",
|
||||
"integrity": "sha1-VNjrx5SfGngQkItgAsaEFSbJnVo="
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,5 +4,9 @@
|
||||
"devDependencies": {
|
||||
"bootstrap": "^4.0.0",
|
||||
"jquery": "^3.3.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"codemirror": "^5.36.0",
|
||||
"simplemde": "^1.11.2"
|
||||
}
|
||||
}
|
||||
|
@@ -1,3 +0,0 @@
|
||||
<?php Flextype\View::factory('admin/views/partials/head')->display(); ?>
|
||||
pages
|
||||
<?php Flextype\View::factory('admin/views/partials/footer')->display(); ?>
|
24
site/plugins/admin/views/pages/add.php
Normal file
24
site/plugins/admin/views/pages/add.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php Flextype\View::factory('admin/views/partials/head')->display(); ?>
|
||||
|
||||
<h2 class="page-heading">
|
||||
Create New Page
|
||||
</h2>
|
||||
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="form-group">
|
||||
<label for="formGroupPageTitleInput">Page title</label>
|
||||
<input type="text" name="title" class="form-control" id="formGroupPageTitleInput" placeholder="">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="formGroupPageTitleInput">Page slug (url)</label>
|
||||
<input type="text" name="slug" class="form-control" id="formGroupPageTitleInput" placeholder="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br>
|
||||
<button class="btn btn-lg btn-dark" name="create_page" type="submit"><?php echo Flextype\I18n::find('admin_save', 'admin', Flextype\Config::get('site.locale')); ?></button>
|
||||
</form>
|
||||
|
||||
<?php Flextype\View::factory('admin/views/partials/footer')->display(); ?>
|
10
site/plugins/admin/views/pages/editor.php
Normal file
10
site/plugins/admin/views/pages/editor.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php Flextype\View::factory('admin/views/partials/head')->display(); ?>
|
||||
|
||||
<form method="post">
|
||||
<input id="slug" name="slug" type="hidden" value="<?php echo $page_slug; ?>">
|
||||
<textarea id="frontmatter" name="frontmatter" rows="0" cols="0"><?php echo $page_frontmatter; ?></textarea>
|
||||
<textarea id="editor" name="editor" rows="8" cols="80"><?php echo $page_content; ?></textarea>
|
||||
<button class="btn btn-lg btn-dark" name="save_page" type="submit"><?php echo Flextype\I18n::find('admin_save', 'admin', Flextype\Config::get('site.locale')); ?></button>
|
||||
</form>
|
||||
|
||||
<?php Flextype\View::factory('admin/views/partials/footer')->display(); ?>
|
26
site/plugins/admin/views/pages/index.php
Normal file
26
site/plugins/admin/views/pages/index.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php Flextype\View::factory('admin/views/partials/head')->display(); ?>
|
||||
|
||||
<h2 class="page-heading">
|
||||
Pages
|
||||
<a class="btn pull-right btn-black" href="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>/admin/pages/add" role="button">Create New Page</a>
|
||||
</h2>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">Name</th>
|
||||
<th scope="col">Url</th>
|
||||
<th scope="col"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($pages_list as $page) { ?>
|
||||
<tr>
|
||||
<td scope="row"><a href="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>/admin/pages/edit?page=<?php echo $page['slug']; ?>"><?php echo $page['title']; ?></a></td>
|
||||
<td scope="row"><a href="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>/<?php echo $page['slug']; ?>">/<?php echo $page['slug']; ?></a></td>
|
||||
<td scope="row" class="text-right"><a href="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>/admin/pages/delete?page=<?php echo $page['slug']; ?>">Delete</a></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php Flextype\View::factory('admin/views/partials/footer')->display(); ?>
|
@@ -1,8 +1,8 @@
|
||||
|
||||
<?php Flextype\View::factory('admin/views/partials/tail')->display(); ?>
|
||||
|
||||
<div class="powered">
|
||||
Powered by <a href="http://flextype.org">Flextype</a>
|
||||
<div class="powered pull-right">
|
||||
Official Support Forum / Documentation / © 2018 Flextype – Version 0.3.0
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
|
@@ -3,21 +3,29 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="description" content="<?php echo Flextype\Config::get('site.description'); ?>">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
<?php Flextype\Events::dispatch('onThemeMeta'); ?>
|
||||
<?php Flextype\Events::dispatch('onAdminThemeMeta'); ?>
|
||||
|
||||
<title><?php echo $page['title']; ?> | <?php echo Flextype\Config::get('site.title'); ?></title>
|
||||
<title>FLEXTYPE</title>
|
||||
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,700' rel='stylesheet' type='text/css'>
|
||||
|
||||
|
||||
<style media="screen">
|
||||
.CodeMirror {
|
||||
height: auto!important;
|
||||
min-height: 10px!important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link href="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>/site/themes/<?php echo Flextype\Config::get('site.theme'); ?>/node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>/site/plugins/admin/node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
|
||||
<!-- Custom styles for this template -->
|
||||
<link href="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>/site/themes/<?php echo Flextype\Config::get('site.theme'); ?>/assets/css/theme.css" rel="stylesheet">
|
||||
<?php Flextype\Events::dispatch('onThemeHeader'); ?>
|
||||
<link href="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>/site/plugins/admin/css/theme.css" rel="stylesheet">
|
||||
<?php Flextype\Events::dispatch('onAdminThemeHeader'); ?>
|
||||
</head>
|
||||
<body>
|
||||
<?php Flextype\View::factory('admin/views/partials/navigation')->display(); ?>
|
||||
|
@@ -12,6 +12,12 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php if (Flextype\Component\Http\Http::getUriSegment(1) == 'settings') echo 'active'; ?>" href="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>/admin/settings">Settings</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>/admin/pages">View Site</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>/admin/pages">Logout</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -1,3 +1,24 @@
|
||||
<script src="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>/site/themes/<?php echo Flextype\Config::get('site.theme'); ?>/node_modules/jquery/dist/jquery.slim.min.js"></script>
|
||||
<script src="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>/site/themes/<?php echo Flextype\Config::get('site.theme'); ?>/node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
|
||||
<?php Flextype\Events::dispatch('onThemeFooter'); ?>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
|
||||
<script src="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>/site/plugins/admin/node_modules/codemirror/lib/codemirror.js"></script>
|
||||
<link rel="stylesheet" href="<?php echo Flextype\Component\Http\Http::getBaseUrl(); ?>/site/plugins/admin/node_modules/codemirror/lib/codemirror.css">
|
||||
<script>
|
||||
var simplemde = new SimpleMDE({ element: $("#editor")[0] });
|
||||
|
||||
$(document).ready(function() {
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("frontmatter"), {
|
||||
lineNumbers: false,
|
||||
styleActiveLine: true,
|
||||
matchBrackets: true,
|
||||
viewportMargin: Infinity,
|
||||
indentUnit: 4,
|
||||
mode: "'.$mode.'",
|
||||
indentWithTabs: true,
|
||||
theme: "'.CodeMirror::$theme.'"
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
<?php Flextype\Events::dispatch('onAdminThemeFooter'); ?>
|
||||
|
@@ -1 +1,3 @@
|
||||
Settings
|
||||
<?php Flextype\View::factory('admin/views/partials/head')->display(); ?>
|
||||
settings
|
||||
<?php Flextype\View::factory('admin/views/partials/footer')->display(); ?>
|
||||
|
Reference in New Issue
Block a user