Compare commits

...

5 Commits

Author SHA1 Message Date
quenousimporte 84baa60a2b drop open by name 2024-10-07 09:08:38 +02:00
quenousimporte 959a68a4bb drop open if search match 2024-10-07 09:05:27 +02:00
quenousimporte cd8d52249c always show links and stats at the bottom 2024-10-07 09:01:50 +02:00
quenousimporte fb84c7f4ea drop clip feature 2024-10-07 08:58:59 +02:00
quenousimporte ffc90cf9fa drop tags feature 2024-10-07 08:57:16 +02:00
4 changed files with 14 additions and 62 deletions

View File

@ -1,9 +1,7 @@
<form action="index.php" method="GET"> <form action="index.php" method="GET">
<div> <div>
<input hidden type="submit" name="search" value="search" accesskey="s"> <input hidden type="submit" name="search" value="search" accesskey="s">
<input type="submit" name="open" value="open" accesskey="o"> <input type="submit" name="new" value="new" accesskey="o">
<input type="submit" name="tags" value="tags" accesskey="t">
<input type="submit" name="clip" value="clip" accesskey="c">
<input type="submit" name="download" value="download" accesskey="d"> <input type="submit" name="download" value="download" accesskey="d">
<br> <br>
<input placeholder="search..." autofocus autocomplete="off" class="title" name="param" value="<?php if (!isset($_GET['home']) && !isset($_POST['home'])) echo $param; ?>"> <input placeholder="search..." autofocus autocomplete="off" class="title" name="param" value="<?php if (!isset($_GET['home']) && !isset($_POST['home'])) echo $param; ?>">

View File

@ -80,7 +80,7 @@
$path = $dir . '/' . $title; $path = $dir . '/' . $title;
$lastchanged = filemtime($path); $lastchanged = filemtime($path);
$previous = $_POST['lastchanged']; $previous = $_POST['lastchanged'];
if (!isset($_GET['clip']) && (int)$lastchanged > (int)$previous) if ((int)$lastchanged > (int)$previous)
{ {
$tempcontent = file_get_contents($path . '.md'); $tempcontent = file_get_contents($path . '.md');
if ($tempcontent != $content) if ($tempcontent != $content)
@ -130,13 +130,7 @@
{ {
downloadall(); downloadall();
} }
else if (isset($_GET['clip']) && $_GET['param']) else if (isset($_POST['save']) || isset($_POST['home']) || isset($_POST['download']))
{
$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']) || isset($_POST['download']))
{ {
$title = $_POST['title']; $title = $_POST['title'];
$content = $_POST['content']; $content = $_POST['content'];
@ -184,6 +178,10 @@
$nextpage = 'note'; $nextpage = 'note';
$title = $_GET['param']; $title = $_GET['param'];
} }
else if (isset($_GET['new']))
{
$nextpage = 'note';
}
?> ?>
<!DOCTYPE html> <!DOCTYPE html>
@ -255,46 +253,19 @@
foreach($_SESSION['index'] as $path) foreach($_SESSION['index'] as $path)
{ {
$tags = '';
$name = basename($path); $name = basename($path);
if (!str_ends_with($name, '.del')) if (!str_ends_with($name, '.del'))
{ {
if (($_GET['param'] && isset($_GET['search'])) || isset($_GET['tags'])) if (($_GET['param'] && isset($_GET['search'])))
{ {
$content = file_get_contents($path . '.md'); $content = file_get_contents($path . '.md');
if ( if (isset($_GET['search']) && !str_contains(cleanstring($content), cleanstring($param)) && !str_contains(cleanstring($name), cleanstring($param)))
// param does not match content or title
(isset($_GET['search']) && !str_contains(cleanstring($content), cleanstring($param)) && !str_contains(cleanstring($name), cleanstring($param))) ||
// param does not match tags
(isset($_GET['tags']) && !preg_match('/tags:.*' . $param . '/i', $content))
)
{ {
continue; continue;
} }
else if (isset($_GET['search']) && $param == $name)
{
header('Location: index.php?open=true&param=' . urlencode($name));
die();
}
} }
echo '<div><a href=index.php?open=true&param=' . urlencode($name) . '>' . $name .'</a>'; echo '<div><a href=index.php?open=true&param=' . urlencode($name) . '>' . $name .'</a>';
if (isset($content) && isset($_GET['tags'])) if (isset($_GET['search']) && str_contains(cleanstring($content), cleanstring($param)))
{
$tags = array();
$hastags = preg_match_all('/tags:(.*)/i', $content, $tags, PREG_SET_ORDER);
if ($hastags)
{
$tagslist = explode(',', $tags[0][1]);
echo '<span class="grey"> ';
foreach ($tagslist as $tag)
{
$tag = trim($tag);
echo('<a class="grey" href="index.php?tags=true&param=' . $tag . '">' . $tag . '</a> ');
}
echo '</span>';
}
}
else if (isset($_GET['search']) && str_contains(cleanstring($content), cleanstring($param)))
{ {
$pos = strpos(cleanstring($content), cleanstring($param)); $pos = strpos(cleanstring($content), cleanstring($param));
echo '<span class="grey"> ' . $param . substr($content, $pos + strlen($param), 42) . '</span>'; echo '<span class="grey"> ' . $param . substr($content, $pos + strlen($param), 42) . '</span>';

View File

@ -3,24 +3,17 @@
<input type="submit" name="home" value="home" accesskey="h"> <input type="submit" name="home" value="home" accesskey="h">
<input type="submit" name="save" value="save" accesskey="s"> <input type="submit" name="save" value="save" accesskey="s">
<input type="submit" name="preview" value="preview" accesskey="p" formtarget="_blank"> <input type="submit" name="preview" value="preview" accesskey="p" formtarget="_blank">
<input type="submit" name="links" value="links" accesskey="l">
<input type="submit" name="stats" value="stats" accesskey="i">
<input type="submit" name="download" value="download" accesskey="d"> <input type="submit" name="download" value="download" accesskey="d">
<input type="submit" name="delete" value="delete"> <input type="submit" name="delete" value="delete">
<input hidden name="lastchanged" value="<? echo $lastchanged; ?>"> <input hidden name="lastchanged" value="<? echo $lastchanged; ?>">
<?php
if (isset($_POST['stats']))
{
echo '<div class="grey">' . $lines . '&nbsp;' . $words . '&nbsp;' . $chars . '&nbsp;' . $title . '.md</div>';
}
else if (isset($_POST['links']))
{
echo linksdiv($content);
}?>
<div><input autocomplete="off" class="title" name="title" value="<? echo $title; ?>"></div> <div><input autocomplete="off" class="title" name="title" value="<? echo $title; ?>"></div>
</div> </div>
<div class="editor"> <div class="editor">
<textarea rows="<? echo $rows; ?>" autofocus name="content" spellcheck="false"><? echo $content; ?></textarea> <textarea rows="<? echo $rows; ?>" autofocus name="content" spellcheck="false"><? echo $content; ?></textarea>
</div> </div>
<input hidden name="previoustitle" value="<? echo $title; ?>"> <input hidden name="previoustitle" value="<? echo $title; ?>">
<?php
echo '<div class="grey">' . $lines . '&nbsp;' . $words . '&nbsp;' . $chars . '&nbsp;' . $title . '.md</div>';
echo linksdiv($content);
?>
</form> </form>

View File

@ -14,8 +14,6 @@ No javascript.
|------------------------|----------------------------------|-------------------------------|--------| |------------------------|----------------------------------|-------------------------------|--------|
| search (default action)| full text search | reload home | alt-s | | search (default action)| full text search | reload home | alt-s |
| open | open if exists, or create | create with timestamp as title| alt-o | | open | open if exists, or create | create with timestamp as title| alt-o |
| tag | filter list by tag | show all tags in list | alt-t |
| clip | insert in todo | | alt-c |
| download | download all notes in a zip file | | alt-d | | download | download all notes in a zip file | | alt-d |
| Note page | action with param | hotkey | | Note page | action with param | hotkey |
@ -23,18 +21,10 @@ No javascript.
| home (default action) | save and back to home | alt-h | | home (default action) | save and back to home | alt-h |
| save | save | alt-s | | save | save | alt-s |
| preview | save and show markdown preview | alt-p | | preview | save and show markdown preview | alt-p |
| links | save and show links | alt-l |
| stats | save and show stats | alt-i |
| delete | delete (rename as .del) | alt-d | | delete | delete (rename as .del) | alt-d |
| On list | action |
|------------------------|--------------------------|
| clic on tag | filter list by tag (home with tags+param) |
| Url params | action | | Url params | action |
|------------------------|--------------------------| |------------------------|--------------------------|
| reindex | force notes reindex | | reindex | force notes reindex |
| clip+param | same as button |
| open+param | same as button | | open+param | same as button |
| tags+param | same as button |
| search+param | same as button | | search+param | same as button |