add: markdown preview
This commit is contained in:
parent
2ce4cbeef6
commit
f8b2ee3942
24
index.php
24
index.php
|
@ -41,6 +41,9 @@
|
|||
exit;
|
||||
}
|
||||
|
||||
require 'libs/Parsedown.php';
|
||||
$homelink = '<a accesskey="h" href="' . $root . '">home</a> ';
|
||||
|
||||
$action = '';
|
||||
if (isset($_POST['action'])) $action = $_POST['action'];
|
||||
else if (isset($_GET['action'])) $action = $_GET['action'];
|
||||
|
@ -70,7 +73,15 @@
|
|||
rename($dir . '/' . $title, $dir . '/' . $title . '.del');
|
||||
}
|
||||
|
||||
if ($action == 'open')
|
||||
if ($action == 'preview')
|
||||
{
|
||||
$title = $_POST['title'];
|
||||
$content = $_POST['content'];
|
||||
$Parsedown = new Parsedown();
|
||||
$Parsedown->setBreaksEnabled(true);
|
||||
echo $Parsedown->text('# ' . $title . "\r\n" . $content);
|
||||
}
|
||||
else if ($action == 'open')
|
||||
{
|
||||
$now = date("Y-m-d H.i.s", time());
|
||||
if (!$param)
|
||||
|
@ -94,11 +105,11 @@
|
|||
$length = strlen($content);
|
||||
|
||||
echo '<form action="index.php" method="POST">
|
||||
<div>
|
||||
<a accesskey="h" href="' . $root . '">home</a>
|
||||
<select name="action">
|
||||
<div>' . $homelink .
|
||||
'<select name="action">
|
||||
<option value="save">save</option>
|
||||
<option value="delete">delete</option>
|
||||
<option value="preview">preview</option>
|
||||
</select>
|
||||
<input class="title" name="title" value="' . $param . '">
|
||||
<input type="submit" name="go" value="go" accesskey="s">
|
||||
|
@ -139,9 +150,8 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
echo '<form action="index.php" method="GET">
|
||||
<a accesskey="h" href="' . $root . '">home</a>
|
||||
<select name="action">
|
||||
echo '<form action="index.php" method="GET">' .$homelink .
|
||||
'<select name="action">
|
||||
<option ' . ($action == 'open' ? 'selected' : '') . ' value="open">open</option>
|
||||
<option ' . ($action == 'filter' ? 'selected' : '') . ' value="filter">filter</option>
|
||||
<option ' . ($action == 'search' ? 'selected' : '') . ' value="search">search</option>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue