diff --git a/home.php b/home.php new file mode 100644 index 0000000..0bc30cc --- /dev/null +++ b/home.php @@ -0,0 +1,67 @@ +
+
+ + + + + + +
+ +
+
+
+ +' . $name .''; + if ($action == 'tags') + { + $tags = array(); + $hastags = preg_match_all('/tags:(.*)/i', $content, $tags, PREG_SET_ORDER); + if ($hastags) + { + $tagslist = explode(',', $tags[0][1]); + echo ' '; + foreach ($tagslist as $tag) + { + $tag = trim($tag); + echo('' . $tag . ' '); + } + echo ''; + } + } + else if ($action == 'search') + { + $pos = strpos(strtolower($content), strtolower($param)); + echo ' ' . $param . '' . substr($content, $pos + strlen($param), 42) . ''; + } + echo'
'; + } +} + +?> + + diff --git a/index.php b/index.php index 9769aa2..72405b9 100644 --- a/index.php +++ b/index.php @@ -14,7 +14,6 @@ - setBreaksEnabled(true); - echo $Parsedown->text('# ' . $title . "\r\n" . $content); + 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 (!$param) + if (!$title) { - $param = $now; + $title = $now; } - if (!file_exists($dir . '/' . $param)) + if (!file_exists($dir . '/' . $title)) { $content = "---\r\ndate: " . substr($now, 0, 10) . "\r\ntags: \r\n---\r\n"; - file_put_contents($dir . '/' . $param, $content); + file_put_contents($dir . '/' . $title, $content); } else if (!$content) { - $content = file_get_contents($dir . '/' . $param); + $content = file_get_contents($dir . '/' . $title); } - - $lines = substr_count($content, "\r\n") + 1; - $words = $lines + substr_count($content, " "); - $rows = max(20, $lines) + 10; - $length = strlen($content); - - echo '
-
- - - - -
-
-
- -
- -
'; - - $links = array(); - if (preg_match_all('/\[\[(.*)\]\]/', $content, $links, PREG_SET_ORDER)) - { - echo '
Internal links:
'; - foreach($links as $link) - { - echo '
- ' . $link[1] . ' -
'; - } - echo '
'; - } - $links = array(); - if (preg_match_all('/https:(.*)[ \r]/', $content, $links, PREG_SET_ORDER)) - { - echo '
External links:
'; - foreach($links as $link) - { - echo '
- https:' . $link[1] . ' -
'; - } - echo '
'; - } - - echo '' . $param . ' - ' . $now . ' - ' . $length . 'c - ' . $words . 'w - ' . $lines . 'l '; + require('note.php'); } else { - echo '
- - - -
'; - echo '
'; - - $files = glob($dir . '/*'); - usort($files, function($a, $b) + if (isset($_GET['param'])) { - return filemtime($b) - filemtime($a); - }); - - foreach($files as $path) - { - $tags = ''; - $name = basename($path); - if (!str_ends_with($name, '.del') && ($action != 'filter' || str_contains($name, $param))) - { - if ($action == 'search' || $action == 'tags') - { - $content = file_get_contents($path); - - if (($action == 'search' && !str_contains($content, $param)) || - ($action == 'tags' && !preg_match('/tags:.*' . $param . '/', $content))) - { - continue; - } - } - echo '
' . $name .''; - if ($action == 'tags') - { - $tags = array(); - $hastags = preg_match_all('/tags:(.*)/', $content, $tags, PREG_SET_ORDER); - if ($hastags) - { - $tagslist = explode(',', $tags[0][1]); - echo ' '; - foreach ($tagslist as $tag) - { - $tag = trim($tag); - echo('' . $tag . ' '); - } - echo ''; - } - } - else if ($action == 'search') - { - $pos = strpos($content, $param); - echo ' ' . $param . '' . substr($content, $pos + strlen($param), 42) . ''; - } - echo'
'; - } + $param = $_GET['param']; } - echo '
'; + require('home.php'); } ?> diff --git a/note.php b/note.php new file mode 100644 index 0000000..f600766 --- /dev/null +++ b/note.php @@ -0,0 +1,51 @@ + + +
+
+ + + + +
+ +
+
+ +
+ +
+ +Internal links:'; + foreach($links as $link) + { + echo '
+ ' . $link[1] . ' +
'; + } + echo '
'; +} +$links = array(); +if (preg_match_all('/https:(.*)[ \r]/', $content, $links, PREG_SET_ORDER)) +{ + echo '
External links:
'; + foreach($links as $link) + { + echo '
+ https:' . $link[1] . ' +
'; + } + echo '
'; +} + +echo '' . $title . ' - ' . $now . ' - ' . $length . 'c - ' . $words . 'w - ' . $lines . 'l '; + +?> diff --git a/style.css b/style.css index fb475d6..bbaa219 100644 --- a/style.css +++ b/style.css @@ -2,8 +2,10 @@ body { color: rgb(55, 53, 47); font-family: helvetica; line-height: 24px; - margin: 30px; font-size: 16px; + margin-left: 7%; + margin-right: 7%; + margin-top: 10px; } textarea { width: 100%; @@ -13,7 +15,6 @@ textarea { font-size: inherit; line-height: inherit; color: inherit; - font-size: inherit; } .grey { color: lightgrey; @@ -21,4 +22,29 @@ textarea { a { color: inherit; -} \ No newline at end of file +} + +.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; +}