change layout

This commit is contained in:
quenousimporte 2024-02-14 14:23:00 +01:00
parent b35c6dfe51
commit 32bd95e372
1 changed files with 20 additions and 14 deletions

View File

@ -44,12 +44,6 @@
exit; exit;
} }
echo '<form action="index.php" method="GET">
<a accesskey="h" href="index.php">Home</a>&nbsp;
<input name="open" value="' . time() . '.md">&nbsp;
<input accesskey="n" type="submit" value="Create new">
</form>';
if (isset($_POST['savebutton'])) if (isset($_POST['savebutton']))
{ {
$title = $_POST['title']; $title = $_POST['title'];
@ -77,23 +71,34 @@
$content = file_get_contents($dir . '/' . $title); $content = file_get_contents($dir . '/' . $title);
} }
$nblines = substr_count($content, "\r\n"); $nblines = max(20, substr_count($content, "\r\n") + 1);
echo '<form action="index.php" method="POST"> echo '<form action="index.php" method="POST">
<br><div><input class="title" name="title" value="' . $title . '"></div><br> <div>
<input accesskey="h" type="submit" name="homebutton" value="home">
<input type="submit" name="savebutton" value="save" accesskey="s">
<input accesskey="d" type="submit" name="deletebutton" value="delete">
</div>
<br>
<div><input class="title" name="title" value="' . $title . '"></div><br>
<div> <div>
<textarea rows="' . $nblines. '" autofocus name="content" spellcheck="false">' . $content . '</textarea> <textarea rows="' . $nblines. '" autofocus name="content" spellcheck="false">' . $content . '</textarea>
</div> </div>
<input type="submit" name="savebutton" value="save" accesskey="s">
<input accesskey="d" type="submit" name="deletebutton" value="delete">
</form>'; </form>';
} }
else else
{ {
echo '<br><br>'; echo '<form action="index.php" method="GET">
if ($dh = opendir($dir)) { <input accesskey="n" type="submit" value="create new">
while (($file = readdir($dh)) !== false) { <input name="open" value="' . time() . '">
if (str_ends_with($file, '.md')) </form>';
echo '<br>';
if ($dh = opendir($dir))
{
while (($file = readdir($dh)) !== false)
{
if (!str_ends_with($file, '.del') && $file != '.' && $file != '..')
{ {
$mod = date("F d Y H:i:s", filemtime($dir . '/' . $file)); $mod = date("F d Y H:i:s", filemtime($dir . '/' . $file));
echo '<div>' . $mod . '&nbsp;<a href=index.php?open=' . urlencode($file) . '>' . $file .'</a></div>'; echo '<div>' . $mod . '&nbsp;<a href=index.php?open=' . urlencode($file) . '>' . $file .'</a></div>';
@ -101,6 +106,7 @@
} }
closedir($dh); closedir($dh);
} }
echo '<br>';
} }
?> ?>