add note name in title

This commit is contained in:
quenousimporte 2024-10-01 10:51:28 +02:00
parent 6d87adb4d5
commit a0ade9fb74
1 changed files with 67 additions and 52 deletions

119
index.php
View File

@ -117,12 +117,74 @@
download(); 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'];
}
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<title>bbn</title> <title>
<?php
if ($nextpage != 'home' && isset($title))
{
echo $title;
}
else
{
echo 'bbn';
}
?>
</title>
<link rel="manifest" href="manifest.json" /> <link rel="manifest" href="manifest.json" />
<meta name="theme-color" content="white" /> <meta name="theme-color" content="white" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
@ -132,58 +194,11 @@
<body> <body>
<?php <?php
if ($nextpage == 'preview')
if (isset($_GET['clip']) && $_GET['param'])
{ {
$content = $_GET['param'] . "\r\n" . file_get_contents($dir . '/todo.md'); echo $preview;
savenote('todo', $content);
$_GET['param'] = '';
} }
else if (isset($_POST['save']) || isset($_POST['home']) || isset($_POST['links']) || isset($_POST['stats'])) else if ($nextpage == 'note')
{
$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);
echo $Parsedown->text('# ' . $title . "\r\n" . substr($content, $pos));
$nextpage = '';
}
else if (isset($_GET['open']))
{
$nextpage = 'note';
$title = $_GET['param'];
}
if ($nextpage == 'note')
{ {
$now = date("Y-m-d H.i.s", time()); $now = date("Y-m-d H.i.s", time());
if (!$title) if (!$title)
@ -234,7 +249,7 @@
if ( if (
// param does not match content or title // param does not match content or title
(isset($_GET['search']) && !str_contains(strtolower($content), strtolower($param)) && !str_contains(strtolower($name), strtolower($param))) || (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)) (isset($_GET['tags']) && !preg_match('/tags:.*' . $param . '/i', $content))
) )
{ {