Compare commits

..

No commits in common. "9d636c7b2c47497348c86937f84b7896c263e56f" and "8693e3c8ad3c5663e8e2465f992db53a1af176fe" have entirely different histories.

9 changed files with 88 additions and 1994 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -1,67 +0,0 @@
<form action="index.php" method="GET">
<div>
<input type="submit" name="home" value="home" accesskey="h">
<input type="submit" name="open" value="open">
<input type="submit" name="filter" value="filter">
<input type="submit" name="search" value="search">
<input type="submit" name="tags" value="tags">
<input type="submit" name="clip" value="clip">
<br>
<input autocomplete="off" class="title" name="param" value="<?php echo $param; ?>">
</div>
</form>
<div class="editor">
<?php
$files = glob($dir . '/*');
usort($files, function($a, $b)
{
return filemtime($b) - filemtime($a);
});
foreach($files as $path)
{
$tags = '';
$name = basename($path);
if (!str_ends_with($name, '.del') && ($action != 'filter' || str_contains(strtolower($name), strtolower($param))))
{
if ($action == 'search' || $action == 'tags')
{
$content = file_get_contents($path);
if (($action == 'search' && !str_contains(strtolower($content), strtolower($param))) ||
($action == 'tags' && !preg_match('/tags:.*' . $param . '/i', $content)))
{
continue;
}
}
echo '<div><a href=index.php?open=true&param=' . urlencode($name) . '>' . $name .'</a>';
if ($action == '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 ($action == 'search')
{
$pos = strpos(strtolower($content), strtolower($param));
echo '<span class="grey"> <b>' . $param . '</b>' . substr($content, $pos + strlen($param), 42) . '</span>';
}
echo'</div>';
}
}
?>
</div>

189
index.php
View File

@ -3,17 +3,35 @@
<head>
<title>
<?php
if (isset($_GET['action']) && $_GET['action'] == 'open')
if (isset($_GET['openaction']))
{
echo $_GET['param'];
echo $_GET['userdata'];
}
?>
</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">
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="style.css">
<style type="text/css">
body {
font-family: helvetica;
}
textarea {
width: 100%;
border: none;
outline: none;
font-family: inherit;
font-size: inherit;
}
.title {
width: 100%;
border: none;
outline: none;
font-family: inherit;
font-size: inherit;
font-weight: bold;
}
</style>
</head>
<body>
<?php
@ -26,75 +44,22 @@
exit;
}
$action = '';
echo '<div><a accesskey="h" href="' . $root . '">home</a></div><br>';
if (isset($_GET['open']))
{
$action = 'open';
}
else if (isset($_GET['filter']))
{
$action = 'filter';
}
else if (isset($_GET['search']))
{
$action = 'search';
}
else if (isset($_GET['tags']))
{
$action = 'tags';
}
else if (isset($_GET['clip']))
{
$action = 'clip';
}
else if (isset($_POST['save']))
{
$action = 'save';
}
else if (isset($_POST['delete']))
{
$action = 'delete';
}
else if (isset($_POST['home']))
{
$action = 'save';
}
else if(isset($_GET['home']))
{
$action = '';
}
else if (isset($_POST['preview']))
{
$action = 'preview';
}
if (isset($_POST['action'])) $action = $_POST['action'];
else if (isset($_GET['action'])) $action = $_GET['action'];
$param = '';
if (isset($_GET['param'])) $param = $_GET['param'];
$content = '';
if ($action == 'clip' && $_GET['param'])
{
$content = $_GET['param'] . "\r\n" . file_get_contents($dir . '/clip');
file_put_contents($dir . '/clip', $content);
$_GET['param'] = '';
}
if ($action == 'save')
{
$title = $_POST['title'];
$content = $_POST['content'];
file_put_contents($dir . '/' . $title, $content);
$previoustitle = $_POST['previoustitle'];
if ($title != $previoustitle)
{
rename($dir . '/' . $previoustitle, $dir . '/' . $previoustitle . '.del');
}
$action = 'open';
$_GET['param'] = $title;
if (isset($_POST['home']))
{
header('Location: index.php');
}
$param = $title;
}
else if ($action == 'delete')
{
@ -102,47 +67,79 @@
rename($dir . '/' . $title, $dir . '/' . $title . '.del');
}
if ($action == 'preview')
if ($action == 'open')
{
require 'libs/Parsedown.php';
$title = $_POST['title'];
$content = $_POST['content'];
$pos = 0;
if (str_starts_with($content, '---'))
{
$pos = strpos($content, '---', 3);
}
$Parsedown = new Parsedown();
$Parsedown->setBreaksEnabled(true);
echo $Parsedown->text('# ' . $title . "\r\n" . substr($content, $pos + 3));
}
else if ($action == 'open')
{
$title = $_GET['param'];
$now = date("Y-m-d H.i.s", time());
if (!$title)
{
$title = $now;
}
$title = $param;
$content = '';
if (!file_exists($dir . '/' . $title))
{
$content = "---\r\ndate: " . substr($now, 0, 10) . "\r\ntags: \r\n---\r\n";
file_put_contents($dir . '/' . $title, $content);
}
else if (!$content)
{
$content = file_get_contents($dir . '/' . $title);
}
require('note.php');
}
else
{
if (isset($_GET['param']))
{
$param = $_GET['param'];
$content = file_get_contents($dir . '/' . $title);
}
require('home.php');
$nblines = max(20, substr_count($content, "\r\n") + 1) * 2;
echo '<form action="index.php" method="POST">
<div>
<select name="action">
<option value="save">save</option>
<option value="delete">delete</option>
</select>
<input type="submit" name="go" value="go" accesskey="s">
</div>
<br>
<div><input class="title" name="title" value="' . $title . '"></div><br>
<div>
<textarea rows="' . $nblines. '" autofocus name="content" spellcheck="false">' . $content . '</textarea>
</div>
</form>';
}
else
{
$defaulttitle = date("Y-m-d H.i.s", time());
if ($param)
{
$defaulttitle = $param;
}
echo '<form action="index.php" method="GET">
<input name="param" value="' . $defaulttitle . '">
<select name="action">
<option value="open">open</option>
<option value="filter">filter</option>
<option value="search">search</option>
</select>
<input accesskey="s" type="submit" value="go">
</form>';
echo '<br>';
$files = glob($dir . '/*');
usort($files, function($a, $b)
{
return filemtime($b) - filemtime($a);
});
foreach($files as $path)
{
$name = basename($path);
if (!str_ends_with($name, '.del')
&& ($action != 'filter' || str_contains($name, $param)))
{
if ($action == 'search')
{
$content = file_get_contents($path);
if (!str_contains($content, $param))
{
continue;
}
}
echo '<div><a href=index.php?action=open&param=' . urlencode($name) . '>' . $name .'</a></div>';
}
}
echo '<br>';
}
?>
</body>

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +0,0 @@
{
"name": "bbn",
"start_url": ".",
"display": "standalone",
"icons": [
{
"src": "favicon.ico",
"type": "image/vnd.microsoft.icon",
"sizes": "48x48"
},
{
"src": "bbn192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "bbn512.png",
"type": "image/png",
"sizes": "512x512"
}
]
}

View File

@ -1,51 +0,0 @@
<?
$lines = substr_count($content, "\r\n") + 1;
$words = $lines + substr_count($content, " ");
$rows = max(20, $lines) * 2;
$length = strlen($content);
?>
<form action="index.php" method="POST">
<div>
<input type="submit" name="home" value="home" accesskey="h">
<input type="submit" name="save" value="save" accesskey="s">
<input type="submit" name="delete" value="delete">
<input type="submit" name="preview" value="preview">
<br>
<input autocomplete="off" class="title" name="title" value="<? echo $title; ?>">
</div>
<div class="editor">
<textarea rows="<? echo $rows; ?>" autofocus name="content" spellcheck="false"><? echo $content; ?></textarea>
</div>
<input hidden name="previoustitle" value="<? echo $title; ?>">
</form>
<?
$links = array();
if (preg_match_all('/\[\[(.*)\]\]/', $content, $links, PREG_SET_ORDER))
{
echo '<div>Internal links:</div>';
foreach($links as $link)
{
echo '<div>
<a href="index.php?open=true&param=' . urlencode($link[1]) . '">' . $link[1] . '</a>
</div>';
}
echo '<br>';
}
$links = array();
if (preg_match_all('/https:(.*)[ \r]/', $content, $links, PREG_SET_ORDER))
{
echo '<div>External links:</div>';
foreach($links as $link)
{
echo '<div>
<a target="_blank" href="https:' . $link[1] . '">https:' . $link[1] . '</a>
</div>';
}
echo '<br>';
}
echo '<span class="grey">' . $title . ' - ' . $now . ' - ' . $length . 'c - ' . $words . 'w - ' . $lines . 'l </span>';
?>

View File

@ -1,50 +0,0 @@
body {
color: rgb(55, 53, 47);
font-family: helvetica;
line-height: 24px;
font-size: 16px;
margin-left: 7%;
margin-right: 7%;
margin-top: 10px;
}
textarea {
width: 100%;
border: none;
outline: none;
font-family: inherit;
font-size: inherit;
line-height: inherit;
color: inherit;
}
.grey {
color: lightgrey;
}
a {
color: inherit;
}
.editor {
margin-top: 10px;
}
.title {
font: inherit;
border: none;
outline: none;
font-weight: bold;
margin-top: 10px;
color: inherit;
}
form input[type="submit"] {
background: none;
border: none;
color: lightgrey;
font: inherit;
text-decoration: underline;
cursor: pointer;
padding: 0;
border: 0;
}