fixed merge isseu

This commit is contained in:
sørenpeter 2025-01-22 21:32:59 +01:00
commit d4df383f4d
5 changed files with 34 additions and 39 deletions

View file

@ -15,13 +15,15 @@ It then gives you an interface for posting words, links (and images too, soon),
For the social features timeline are using the [twtxt](https://twtxt.readthedocs.io) format and most of the twtxt Extensions developed in the context of Yarn.social](https://yarn.social/). For the social features timeline are using the [twtxt](https://twtxt.readthedocs.io) format and most of the twtxt Extensions developed in the context of Yarn.social](https://yarn.social/).
timeline also support its own flavor of WebMentions, so it is possible to be notified about `@mentions` from feeds you are not currently/yet following. You can also search for others feeds using WebFinger, if they got that set up on their server , like it's the case for most yarn.social pods. timeline also support its own flavor of WebMentions, so it is possible to be notified about `@mentions` from feeds you are not currently/yet following.
You can also search for others feeds using [WebFinger](https://webfinger.net/), if they got that set up on their servser, like it's the case for most yarn.social pods. You can also search for others feeds using [WebFinger](https://webfinger.net/), if they got that set up on their servser, like it's the case for most yarn.social pods.
My visions for timeline is to bring back the fun and quirkiness of bygone sites such as Geocities of the 1990s and Myspace of the 2000s, that enables creating a personalized place for you to express yourself online and also being able to follow others who inspire you. My visions for timeline is to bring back the fun and quirkiness of bygone sites such as Geocities of the 1990s and Myspace of the 2000s, that enables creating a personalized place for you to express yourself online and also being able to follow others who inspire you.
At the same time providing a good looking basic design with the help of [Simple.css](https://simplecss.org), which allows you to customize the look and feel. Even to the level where timeline aligns with the design of your excsing webpage, like I did on: [darch.dk/timeline](https://darch.dk/timeline). At the same time providing a good looking basic design with the help of [Simple.css](https://simplecss.org), which allows you to customize the look and feel. Even to the level where timeline aligns with the design of your excsing webpage, like I did on: [darch.dk/timeline](https://darch.dk/timeline).
See my talk about twtxt and timeline at Piksel Festival 2024: https://www.darch.dk/twtxtalk-piksel
![](media/screenshot.png) ![](media/screenshot.png)
_Conversation view with replies / Profile view / Gallery View_ _Conversation view with replies / Profile view / Gallery View_

6
libs/load_timezone.php Normal file
View file

@ -0,0 +1,6 @@
<?php
$config = parse_ini_file('private/config.ini');
if (!date_default_timezone_set($config['timezone'])) {
die('Not a valid timezone - Check your config.ini file');
}

View file

@ -17,31 +17,20 @@ declare (strict_types = 1);
# #
# hash(string) = # hash(string) =
require_once('libs/session.php'); require_once 'libs/session.php';
require_once('libs/twtxt.php'); require_once 'libs/twtxt.php';
require_once('libs/hash.php'); require_once 'libs/hash.php';
require_once('libs/Parsedown.php'); require_once 'libs/Parsedown.php';
require_once 'libs/load_timezone.php';
const TWTS_PER_PAGE = 20;
// TODO: Move twts per page to config.ini // TODO: Move twts per page to config.ini
// Add a fallback if the number is invalid (it should be between 1 and 999) // Add a fallback if the number is invalid (it should be between 1 and 999)
const TWTS_PER_PAGE = 50;
$config = parse_ini_file('private/config.ini'); $title = $config['site_title'] ?? "Timeline";
// TODO: Take the title from the config.ini
$title = "Timeline"; // Fallback, should be set in all views
if (isset($config['site_title'])) {
$title = $config['site_title'];
}
// HACKED by sp@darch.dk // HACKED by sp@darch.dk
if(!empty($_GET['list'])) { $url = !empty($_GET['list']) ? $baseURL.$_GET['list'] : $config['public_txt_url'];
$url = $baseURL.$_GET['list'];
}
else {
$url = $config['public_txt_url'];
}
/* /*
if(isset($_GET['selectList'])){ if(isset($_GET['selectList'])){
@ -57,11 +46,7 @@ if(isset($_GET['selectList'])){
} }
*/ */
date_default_timezone_set('UTC'); $url = !empty($_GET['url']) ? filter_var($_GET['url'], FILTER_SANITIZE_URL) : $url;
if (!empty($_GET['url'])) {
$url = $_GET['url'];
}
if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) { if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
die('Not a valid URL'); die('Not a valid URL');

View file

@ -31,9 +31,14 @@ public_txt_url = "https://example.com/timeline/twtxt.txt"
public_avatar = "https://example.com/timeline/avatar.png" public_avatar = "https://example.com/timeline/avatar.png"
public_nick = "Timeline" public_nick = "Timeline"
; Timezone for twts in your twtxt.txt
; If you use "UTC", the time will be shown as "2024-12-13T21:39:32Z"
; Otherwise, a time offset will be show as in "2024-12-13T16:51:20-05:00"
; Check available timezones here: ; Check available timezones here:
; https://www.php.net/manual/en/timezones.php ; https://www.php.net/manual/en/timezones.php
timezone = "Europe/Copenhagen" timezone = "UTC"
;timezone = "Europe/Copenhagen"
twts_per_page = 50 twts_per_page = 50
@ -57,6 +62,9 @@ password = "change_me"
totp_digits = 10 totp_digits = 10
totp_secret = "1234567890" totp_secret = "1234567890"
; Simple password for unnamed user
password = "123"
; It's recommended that your site is hosted on HTTPS ; It's recommended that your site is hosted on HTTPS
; In case it's in HTTP (not secure), set this to false ; In case it's in HTTP (not secure), set this to false
secure_cookies = true secure_cookies = true

View file

@ -1,6 +1,5 @@
<?php <?php
require_once 'libs/session.php'; require_once 'libs/session.php';
checkValidSessionOrRedirectToLogin(); checkValidSessionOrRedirectToLogin();
// TODO: Give a warning if the file is not found // TODO: Give a warning if the file is not found
@ -14,8 +13,9 @@ if ($config['debug_mode']) {
$txt_file_path = $config['txt_file_path']; $txt_file_path = $config['txt_file_path'];
$public_txt_url = $config['public_txt_url']; $public_txt_url = $config['public_txt_url'];
$timezone = $config['timezone'];
$timezone = $config['timezone'];
require_once 'libs/load_timezone.php';
if (isset($_POST['submit'])) { if (isset($_POST['submit'])) {
$new_post = filter_input(INPUT_POST, 'new_post'); $new_post = filter_input(INPUT_POST, 'new_post');
@ -26,11 +26,7 @@ if (isset($_POST['submit'])) {
// Remove Carriage return if needed // Remove Carriage return if needed
$new_post = str_replace("\r", '', $new_post); $new_post = str_replace("\r", '', $new_post);
// TODO: If twt is emply, show an error // TODO: If twt is empty, show an error
/*
if ($new_post) {
}
*/
// Check if we have a point to insert the next Twt // Check if we have a point to insert the next Twt
define('NEW_TWT_MARKER', "#~~~#\n"); define('NEW_TWT_MARKER', "#~~~#\n");
@ -50,7 +46,7 @@ if (isset($_POST['submit'])) {
//$twt = $datetime . "\t$new_post\n"; //$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 $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 $twt = "\n$datetime\t$new_post"; // NB: only works with PHP 8
// TODO: Delete? // TODO: Delete?
/*if (strpos($contents, NEW_TWT_MARKER) !== false) { /*if (strpos($contents, NEW_TWT_MARKER) !== false) {
@ -67,7 +63,7 @@ if (isset($_POST['submit'])) {
// Append twt at the end of file // Append twt at the end of file
$contents .= $twt; $contents .= $twt;
// TODO: Add error handling if write to the file fails // TODO: Add error handling if write to the file fails
// For example due to permissions problems // 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 // https://www.w3docs.com/snippets/php/how-can-i-handle-the-warning-of-file-get-contents-function-in-php.html
@ -83,12 +79,10 @@ if (isset($_POST['submit'])) {
} else { } else {
require_once "partials/base.php"; require_once "partials/base.php";
$title = "New post - ".$title; $title = "New post - $title";
include_once 'partials/header.php'; include_once 'partials/header.php';
if (!isset($textareaValue)) { $textareaValue = $textareaValue ?? '';
$textareaValue = '';
}
if (isset($_GET['hash'])) { if (isset($_GET['hash'])) {
$hash = $_GET['hash']; $hash = $_GET['hash'];