diff --git a/libs/timeline.css b/libs/timeline.css index 912b5fc..542afef 100644 --- a/libs/timeline.css +++ b/libs/timeline.css @@ -190,7 +190,8 @@ article.post-entry { } article .twt-msg { - padding: 0.5rem 0; + padding: 0.5rem 0.5rem 0.5rem 0 ; + overflow-wrap: anywhere; } article .twt-msg > blockquote { diff --git a/partials/lists.php b/partials/lists.php index 1d2981f..32dca1b 100644 --- a/partials/lists.php +++ b/partials/lists.php @@ -13,7 +13,7 @@ // Private lists echo ""; foreach (glob("private/twtxt-*.txt") as $filename) { - if($filename == $_GET['lists']) $attr="selected"; + if($filename == $_GET['list']) $attr="selected"; else $attr = ""; $listName = $filename; $listName = str_replace("private/twtxt-", "", $listName); @@ -28,7 +28,7 @@ } foreach (glob("twtxt-*.txt") as $filename) { - if($filename == $_GET['lists']) $attr="selected"; + if($filename == $_GET['list']) $attr="selected"; else $attr = ""; $listName = $filename; $listName = str_replace("twtxt-", "", $listName); diff --git a/partials/webfinger_lookup.php b/partials/webfinger_lookup.php new file mode 100644 index 0000000..dd538e6 --- /dev/null +++ b/partials/webfinger_lookup.php @@ -0,0 +1,48 @@ + explode("@",$str)[0], "domain" => explode("@",$str)[1] ); + } else { + return FALSE; + } +} + +$wf_acct = ""; +$wf_nick = ""; +$wf_url = ""; +$wf_error = ""; + +if(isset($_POST['submit'])) { + $wf_request = $_POST["webfinger"]; + + $wf_acct = splitNickDomain($wf_request); + if($wf_acct === FALSE) { $wf_error = "ERROR: ".$wf_request." does not look like a valid webfinger handle"; } + + $wf_json = file_get_contents("https://".$wf_acct["domain"]."/.well-known/webfinger?resource=acct:".$wf_acct["nick"]."@".$wf_acct["domain"]); + //if($wf_json === FALSE) { $wf_error = "ERROR: Chould not find a twtxt feed at webfinger endpoint ".$wf_request; } + + $wf_array = json_decode($wf_json, true); + + $wf_domain = splitNickDomain($wf_array["subject"])["domain"]; + + foreach( $wf_array["links"] as $link ) { + + if ( $link["rel"] == "self" AND $link["type"] == "text/plain") { + + if ( filter_var($link["href"], FILTER_VALIDATE_URL) ) { + $wf_url = $link["href"]; + + $wf_nick = splitNickDomain($wf_array["subject"])["nick"]; + $wf_error = "URL to twtxt.txt found for ".$wf_nick ."@".$wf_domain; + break; + } + } else { $wf_error = "ERROR: Chould not find a twtxt feed at webfinger endpoint ".$wf_acct["domain"]; } + } +} + + +//else { $wf_error = "Chould not find webfinger endpoint at ".$wf_acct["domain"]; } diff --git a/views/add_feed.php b/views/add_feed.php index c0331ac..41f0e03 100644 --- a/views/add_feed.php +++ b/views/add_feed.php @@ -1,5 +1,6 @@ +

Webfinger lookup

+ +
+ + +
+
+
+ + +

Add a new feed to follow

- -
- -
-
- + + +
diff --git a/views/following.php b/views/following.php index c89d165..0522087 100644 --- a/views/following.php +++ b/views/following.php @@ -15,7 +15,9 @@ include 'partials/header.php'; Nick URL - Time ago + + Time ago + @@ -28,12 +30,13 @@ include 'partials/header.php'; + twts)) { - // Then test if latest twt is at top or bottom of file: + // Then test if latest twt is at start or end of file: $resetVar = reset(getTwtsFromTwtxtString($currentFollower[1])->twts); $endVar = end(getTwtsFromTwtxtString($currentFollower[1])->twts); if ($resetVar->timestamp < $endVar->timestamp) { // TODO: this can be swapped to get time of first twt @@ -45,6 +48,8 @@ include 'partials/header.php'; ?> + + diff --git a/views/new_twt.php b/views/new_twt.php index 1fafe3f..80260bb 100644 --- a/views/new_twt.php +++ b/views/new_twt.php @@ -55,16 +55,18 @@ if (isset($_POST['submit'])) { $contents = file_get_contents($txt_file_path); - if (!date_default_timezone_set($timezone)) { + /*if (!date_default_timezone_set($timezone)) { date_default_timezone_set('UTC'); - } + }*/ // Turned this off, so now the server need to have set the right timezone, seem to work for CET //$datetime = gmdate('Y-m-d\TH:i:s\Z', $date->format('U')); //$twt = $datetime . "\t$new_post\n"; - $twt = date('c') . "\t$new_post\n"; + //$twt = date('c') . "\t$new_post\n"; + $datetime = date('Y-m-d\TH:i:sp'); // abracting to be used for webmentions + $twt = "\n" . $datetime . "\t" .$new_post; // NB: only works with PHP 8 - - if (strpos($contents, NEW_TWT_MARKER) !== false) { + // TODO: Turn off append at top?! + /*if (strpos($contents, NEW_TWT_MARKER) !== false) { // Add the previous marker // Take note that doesn't not work if twtxt file has CRLF line ending // (which is wrong anyway) @@ -73,15 +75,20 @@ if (isset($_POST['submit'])) { } else { // Fall back if the marker is not found. $contents .= $twt; - } + }*/ + + // Append twt at the end of file + $contents .= $twt; + // TODO: Add error handling if write to the file fails // For example due to permissions problems // https://www.w3docs.com/snippets/php/how-can-i-handle-the-warning-of-file-get-contents-function-in-php.html $file_write_result = file_put_contents($txt_file_path, $contents); - header('Refresh:0; url=.'); - exit; + //header('Refresh:0; url=.'); + header("Location: refresh?url=".$public_txt_url); // Trying to fix issue with douple posting + exit; // } else { require_once("partials/base.php");