Added Time-ago column to following-page

This commit is contained in:
sørenpeter 2024-02-25 15:59:52 +01:00
parent 34a52988e0
commit a65727ccd4
7 changed files with 34 additions and 11 deletions

View file

@ -1,3 +1,5 @@
/* Copy this file to custom.css and edit the styling as you like */
/* === Custom CSS based on: https://github.com/ilyadzh/plain-css */ /* === Custom CSS based on: https://github.com/ilyadzh/plain-css */
:root { :root {

View file

@ -396,6 +396,7 @@ function getTwtsFromTwtxtString($url) {
$twt->originalTwtStr = $currentLine; $twt->originalTwtStr = $currentLine;
$twt->hash = getHashFromTwt($currentLine, $twtxtData->mainURL); $twt->hash = getHashFromTwt($currentLine, $twtxtData->mainURL);
$twt->timestamp = $timestamp;
$twt->fullDate = date('j F Y h:i:s A', $timestamp) . ' (UTC)'; $twt->fullDate = date('j F Y h:i:s A', $timestamp) . ' (UTC)';
$twt->displayDate = $displayDate; $twt->displayDate = $displayDate;
$twt->content = $twtContent; $twt->content = $twtContent;

View file

@ -33,7 +33,8 @@ $title = "Timeline"; // Fallback, should be set in all views
// HACKED by sp@darch.dk // HACKED by sp@darch.dk
if(!empty($_GET['list'])) { if(!empty($_GET['list'])) {
$url = "https://darch.dk/twtxt-lists/".$_GET['list']; $url = $baseURL.$_GET['list'];
//$url = "https://darch.dk/".$_GET['list'];
} }
else { else {
$url = $config['public_txt_url']; $url = $config['public_txt_url'];

View file

@ -21,15 +21,15 @@ $profile = getTwtsFromTwtxtString($config['public_txt_url']);
<header> <header>
<p> <p>
<a href="/"> <a href="/">
<!-- <img class="logo" src="<?= $baseURL ?>/media/logo.png"> --> <img class="logo" src="<?= $baseURL ?>/media/logo.png">
<?= $config['site_title']; ?> <?= $config['site_title']; ?>
</a> </a>
<!-- <a href="/"> <!-- <a href="/">
<img class="avatar" src="<?= $profile->avatar ?>" alt="" loading="lazy"> <img class="logo" src="<?= $profile->avatar ?>" alt="" loading="lazy">
<?= parse_url($profile->mainURL, PHP_URL_HOST); ?> <?= parse_url($profile->mainURL, PHP_URL_HOST); ?>
</a> </a>
<a href="/"> <a href="/">
<img class="avatar" src="<?= $profile->avatar ?>" alt="" loading="lazy"> <img class="logo" src="<?= $profile->avatar ?>" alt="" loading="lazy">
<?= $profile->nick ?>@<?= parse_url($profile->mainURL, PHP_URL_HOST); ?> <?= $profile->nick ?>@<?= parse_url($profile->mainURL, PHP_URL_HOST); ?>
</a> --> </a> -->
</p> </p>

View file

@ -34,9 +34,9 @@
$listName = str_replace("twtxt-", "", $listName); $listName = str_replace("twtxt-", "", $listName);
$listName = str_replace("_", " ", $listName); $listName = str_replace("_", " ", $listName);
$listName = str_replace(".txt", "", $listName); $listName = str_replace(".txt", "", $listName);
//$filename = "TODO".$baseURL."/".$filename;
echo "<option value='{$filename}' {$attr}>$listName</option>"; echo "<option value='{$filename}' {$attr}>$listName</option>";
} }
?> ?>
</select> </select>
<noscript><button type="submit">View list</button></noscript> <noscript><button type="submit">View list</button></noscript>

View file

@ -11,7 +11,7 @@ $profileURL = $baseURL . '/?profile=' . $profile->mainURL;
<div class="profile"> <div class="profile">
<a href="<?=$profileURL?>"> <a href="<?=$profile->avatar?>">
<img class="avatar" src="<?=$profile->avatar?>" onerror="this.onerror=null;this.src='<?= $baseURL ?>/media/default.png';"> <img class="avatar" src="<?=$profile->avatar?>" onerror="this.onerror=null;this.src='<?= $baseURL ?>/media/default.png';">
</a> </a>

View file

@ -14,7 +14,9 @@ include 'partials/header.php';
<tr> <tr>
<!-- <th></th> --> <!-- <th></th> -->
<th>Nick</th> <th>Nick</th>
<th>URL</th></tr> <th>URL</th>
<th>Time ago</th>
</tr>
<?php foreach ($twtFollowingList as $currentFollower) { ?> <?php foreach ($twtFollowingList as $currentFollower) { ?>
<tr> <tr>
@ -22,9 +24,26 @@ include 'partials/header.php';
<td><a href="<?= $baseURL ?>/?profile=<?= $currentFollower[1] ?>"><?= $currentFollower[0] ?></a></td> <td><a href="<?= $baseURL ?>/?profile=<?= $currentFollower[1] ?>"><?= $currentFollower[0] ?></a></td>
<!-- <td><a href="/?twt=<?= $currentFollower[1] ?>"><?= $currentFollower[0] ?></a></td> --> <!-- <td><a href="/?twt=<?= $currentFollower[1] ?>"><?= $currentFollower[0] ?></a></td> -->
<td><?= $currentFollower[1] ?> <td><?= $currentFollower[1] ?>
<!-- <?php if ($validSession) { ?> --> <!-- <?php //if ($validSession) { ?> -->
<!-- <a href="?remove_url=<?= $currentFollower[1] ?>">Remove</a> --> <!-- <a href="?remove_url=<?= $currentFollower[1] ?>">Remove</a> -->
<!-- <?php } ?> --> <!-- <?php // } ?> -->
</td>
<td>
<?php
// Test first if URL is a valid feed:
if (is_array(getTwtsFromTwtxtString($currentFollower[1])->twts)) {
// Then test if latest twt is at top or bottom 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
echo $endVar->displayDate;
} else {
echo $resetVar->displayDate;
}
}
?>
</td> </td>
</tr> </tr>
<?php } ?> <?php } ?>