drop tags feature

This commit is contained in:
quenousimporte 2024-10-07 08:57:16 +02:00
parent 084c27653b
commit ffc90cf9fa
3 changed files with 3 additions and 32 deletions

View File

@ -2,7 +2,6 @@
<div>
<input hidden type="submit" name="search" value="search" accesskey="s">
<input type="submit" name="open" value="open" 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">
<br>

View File

@ -255,19 +255,13 @@
foreach($_SESSION['index'] as $path)
{
$tags = '';
$name = basename($path);
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');
if (
// 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))
)
if (isset($_GET['search']) && !str_contains(cleanstring($content), cleanstring($param)) && !str_contains(cleanstring($name), cleanstring($param)))
{
continue;
}
@ -278,23 +272,7 @@
}
}
echo '<div><a href=index.php?open=true&param=' . urlencode($name) . '>' . $name .'</a>';
if (isset($content) && isset($_GET['tags']))
{
$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)))
if (isset($_GET['search']) && str_contains(cleanstring($content), cleanstring($param)))
{
$pos = strpos(cleanstring($content), cleanstring($param));
echo '<span class="grey"> ' . $param . substr($content, $pos + strlen($param), 42) . '</span>';

View File

@ -14,7 +14,6 @@ No javascript.
|------------------------|----------------------------------|-------------------------------|--------|
| search (default action)| full text search | reload home | alt-s |
| 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 |
@ -27,14 +26,9 @@ No javascript.
| stats | save and show stats | alt-i |
| delete | delete (rename as .del) | alt-d |
| On list | action |
|------------------------|--------------------------|
| clic on tag | filter list by tag (home with tags+param) |
| Url params | action |
|------------------------|--------------------------|
| reindex | force notes reindex |
| clip+param | same as button |
| open+param | same as button |
| tags+param | same as button |
| search+param | same as button |