diff --git a/index.php b/index.php index 9311c79..48858dc 100644 --- a/index.php +++ b/index.php @@ -12,10 +12,16 @@ $viewDir = '/views/'; // Define your routes using regular expressions + +// TODO: re-add auto detection of files in /views as routes $routes = [ '/' => 'home.php', - '/admin' => 'admin.php', - '/about' => 'about.php', + '/new' => 'new_twt.php', + '/add' => 'add_feed.php', + '/following' => 'following.php', + '/refresh' => 'load_twt_files.php', + '/login' => 'login.php', + '/logout' => 'logout.php', '/profile/([a-zA-Z0-9_-]+)' => 'profile.php', '/conv/([a-zA-Z0-9]{7})' => 'conv.php', // matches only twtHash of exactly 7 alphanumeric characters '/post/([a-zA-Z0-9]{7})' => 'post.php', // matches only twtHash of exactly 7 alphanumeric characters diff --git a/libs/Slimdown.php b/libs/Slimdown.php index 81e26dd..6e2c8d2 100644 --- a/libs/Slimdown.php +++ b/libs/Slimdown.php @@ -24,10 +24,8 @@ class Slimdown { public static $rules = array ( '/```(.*?)```/s' => self::class .'::code_parse', // code blocks - //'/\n(#+)(.*)/' => self::class .'::header', // headers - '/\n(#\s+)(.*)/' => self::class .'::header', // headers - only with a space between # and text, to avoid matching with `#hashtags` - //'/\!\[([^\[]+)\]\(([^\)]+)\)/' => self::class .'::img', // images - '/\!\[(.*?)\]\(([^\)]+)\)/' => self::class .'::img', // images 2 + '/\n(#+)\s+(.*)/' => self::class .'::header', // headers + '/\!\[([^\[]*?)\]\(([^\)]+)\)/' => self::class .'::img', // images '/\[([^\[]+)\]\(([^\)]+)\)/' => self::class .'::link', // links '/(\*\*|__)(?=(?:(?:[^`]*`[^`\r\n]*`)*[^`]*$))(?![^\/<]*>.*<\/.+>)(.*?)\1/' => '\2', // bold '/(\*|_)(?=(?:(?:[^`]*`[^`\r\n]*`)*[^`]*$))(?![^\/<]*>.*<\/.+>)(.*?)\1/' => '\2', // emphasis @@ -79,6 +77,7 @@ class Slimdown { } if (! empty ($trimmed)) { //return sprintf ("\n

%s

\n", $trimmed); + return sprintf ("\n%s\n", $trimmed); } return $trimmed; } diff --git a/libs/session.php b/libs/session.php index 5407aab..28ffa4a 100644 --- a/libs/session.php +++ b/libs/session.php @@ -13,11 +13,6 @@ if(isset($_POST['submit_pass']) && $_POST['pass']) } else { - $error="Incorrect Pssword"; + $error="Incorrect Password"; } } - -if(isset($_POST['page_logout'])) -{ - unset($_SESSION['password']); -} \ No newline at end of file diff --git a/libs/twtxt.php b/libs/twtxt.php index e857f8e..8a1abfb 100644 --- a/libs/twtxt.php +++ b/libs/twtxt.php @@ -124,7 +124,8 @@ function replaceMentionsFromTwt(string $twtString): string { // Example output: Hello @eapl.mx@eapl.mx/twtxt.txt, how are you? @nick@server.com/something/twtxt.txt $pattern = '/@<([^ ]+)\s([^>]+)>/'; - $replacement = '@$1'; + //$replacement = '@$1'; + $replacement = '@$1'; #$twtString = '@'; #$pattern = '/@<([^ ]+) ([^>]+)>/'; #$replacement = '@$1'; @@ -137,6 +138,10 @@ function replaceMentionsFromTwt(string $twtString): string { } function replaceLinksFromTwt(string $twtString) { + + // TODO: Make this NOT match with `inline code` to avoid links in code-snippets + // 1. Look into how yarnd handles this + // Regular expression pattern to match URLs $pattern = '/(?\n", $twtContent); - $twtContent = replaceLinksFromTwt($twtContent); + //$twtContent = replaceMarkdownLinksFromTwt($twtContent); //$twtContent = replaceImagesFromTwt($twtContent); $twtContent = Slimdown::render($twtContent); + $twtContent = replaceLinksFromTwt($twtContent); // TODO: // Get and remote the hash $hash = getReplyHashFromTwt($twtContent); @@ -355,7 +361,7 @@ function getTwtsFromTwtxtString($url) { } // TODO: Make ?tag= filtering feature - $twtContent = replaceTagsFromTwt($twtContent); + //$twtContent = replaceTagsFromTwt($twtContent); // TODO: Get mentions $mentions = getMentionsFromTwt($twtContent); diff --git a/partials/base.php b/partials/base.php index 340698d..2a34dfd 100644 --- a/partials/base.php +++ b/partials/base.php @@ -17,7 +17,7 @@ declare(strict_types=1); # hash(string) = # -require_once("libs/session.php"); // TODO: Move all to base.php +require_once("libs/session.php"); require_once('libs/twtxt.php'); require_once('libs/hash.php'); require_once('libs/Slimdown.php'); @@ -29,6 +29,8 @@ const TWTS_PER_PAGE = 50; $config = parse_ini_file('private/config.ini'); //$url = $config['public_txt_url']; +// TODO: Take the title from the config.ini +$title = "Timeline"; // Fallback, should be set in all views // HACKED by sp@darch.dk if(!empty($_GET['list'])) { diff --git a/partials/footer.php b/partials/footer.php index 4bcf3b0..73bb2b2 100644 --- a/partials/footer.php +++ b/partials/footer.php @@ -1,3 +1,8 @@ + + \ No newline at end of file + + + + \ No newline at end of file diff --git a/partials/header.php b/partials/header.php index 027e7b2..2ec30f8 100644 --- a/partials/header.php +++ b/partials/header.php @@ -1,26 +1,38 @@ + + + + + + + <?= $title ?> + + +
+

+ 🧶 Timeline for + sorenpeter@darch.dk + (twtxt.txt) +

-
\ No newline at end of file + + +
\ No newline at end of file diff --git a/partials/profile.php b/partials/profile.php index 25cce40..b8a4448 100644 --- a/partials/profile.php +++ b/partials/profile.php @@ -14,28 +14,40 @@ $profile = getTwtsFromTwtxtString($url); -
+
nick ?>@mainURL, PHP_URL_HOST); ?> -
description ?>
+

description ?>

-
- - + Posts | + Replies | + Gallery | + + + Following | + twtxt.txt | + How to follow + + + + + -