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();
}
$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>
<html>
<head>
<title>bbn</title>
<title>
<?php
if ($nextpage != 'home' && isset($title))
{
echo $title;
}
else
{
echo 'bbn';
}
?>
</title>
<link rel="manifest" href="manifest.json" />
<meta name="theme-color" content="white" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
@ -132,58 +194,11 @@
<body>
<?php
if (isset($_GET['clip']) && $_GET['param'])
if ($nextpage == 'preview')
{
$content = $_GET['param'] . "\r\n" . file_get_contents($dir . '/todo.md');
savenote('todo', $content);
$_GET['param'] = '';
echo $preview;
}
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);
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))
)
{