From a0ade9fb74001db028c7eae78d48c077143203c3 Mon Sep 17 00:00:00 2001 From: quenousimporte Date: Tue, 1 Oct 2024 10:51:28 +0200 Subject: [PATCH] add note name in title --- index.php | 119 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 67 insertions(+), 52 deletions(-) diff --git a/index.php b/index.php index d53cce9..09505a9 100644 --- a/index.php +++ b/index.php @@ -117,12 +117,74 @@ download(); } + $preview = ''; + if (isset($_GET['clip']) && $_GET['param']) + { + $content = $_GET['param'] . "\r\n" . file_get_contents($dir . '/todo.md'); + savenote('todo', $content); + $_GET['param'] = ''; + } + else if (isset($_POST['save']) || isset($_POST['home']) || isset($_POST['links']) || isset($_POST['stats'])) + { + $title = $_POST['title']; + $content = $_POST['content']; + savenote($title, $content); + + $previoustitle = $_POST['previoustitle']; + if ($title != $previoustitle) + { + rename($dir . '/' . $previoustitle . '.md', $dir . '/' . $previoustitle . '.md.del'); + removefromindex($previoustitle); + } + + if (!isset($_POST['home'])) + { + $nextpage = 'note'; + } + } + else if (isset($_POST['delete'])) + { + $title = $_POST['title']; + rename($dir . '/' . $title . '.md', $dir . '/' . $title . '.md.del'); + removefromindex($title); + } + else if (isset($_POST['preview'])) + { + require 'libs/Parsedown.php'; + $title = $_POST['title']; + $content = $_POST['content']; + $pos = 0; + if (str_starts_with($content, '---')) + { + $pos = strpos($content, '---', 3) + 3; + } + $Parsedown = new Parsedown(); + $Parsedown->setBreaksEnabled(true); + $preview = $Parsedown->text('# ' . $title . "\r\n" . substr($content, $pos)); + $nextpage = 'preview'; + } + else if (isset($_GET['open'])) + { + $nextpage = 'note'; + $title = $_GET['param']; + } ?> - bbn + + <?php + if ($nextpage != 'home' && isset($title)) + { + echo $title; + } + else + { + echo 'bbn'; + } + ?> + @@ -132,58 +194,11 @@ setBreaksEnabled(true); - echo $Parsedown->text('# ' . $title . "\r\n" . substr($content, $pos)); - $nextpage = ''; - } - else if (isset($_GET['open'])) - { - $nextpage = 'note'; - $title = $_GET['param']; - } - if ($nextpage == 'note') + else if ($nextpage == 'note') { $now = date("Y-m-d H.i.s", time()); if (!$title) @@ -234,7 +249,7 @@ if ( // param does not match content or title (isset($_GET['search']) && !str_contains(strtolower($content), strtolower($param)) && !str_contains(strtolower($name), strtolower($param))) || - // param does not match tags + // param does not match tags (isset($_GET['tags']) && !preg_match('/tags:.*' . $param . '/i', $content)) ) {