mirror of
https://github.com/sorenpeter/timeline.git
synced 2025-12-15 19:07:01 +00:00
Profile as default if not logged in is working
This commit is contained in:
parent
69b2b9765f
commit
f6e9e9577b
5 changed files with 89 additions and 46 deletions
|
|
@ -81,7 +81,7 @@ $twtFollowingList = [];
|
||||||
|
|
||||||
// Show twts only for URL in query request, else show user timeline
|
// Show twts only for URL in query request, else show user timeline
|
||||||
|
|
||||||
if (!empty($_GET['twts'])) { // Show twts for some user
|
if (!empty($_GET['twts'])) { // Show twts for some user --> /profile
|
||||||
$twtsURL = $_GET['twts'];
|
$twtsURL = $_GET['twts'];
|
||||||
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');
|
||||||
|
|
@ -92,7 +92,7 @@ if (!empty($_GET['twts'])) { // Show twts for some user
|
||||||
$parsedTwtxtFiles[$parsedTwtxtFile->mainURL] = $parsedTwtxtFile;
|
$parsedTwtxtFiles[$parsedTwtxtFile->mainURL] = $parsedTwtxtFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { // Show timeline for the URL
|
} else { // Show timeline for the URL --> / (home)
|
||||||
$parsedTwtxtFiles = [];
|
$parsedTwtxtFiles = [];
|
||||||
foreach ($fileLines as $currentLine) {
|
foreach ($fileLines as $currentLine) {
|
||||||
if (str_starts_with($currentLine, '#')) {
|
if (str_starts_with($currentLine, '#')) {
|
||||||
|
|
@ -120,7 +120,7 @@ foreach ($parsedTwtxtFiles as $currentTwtFile) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Show individual posts
|
# Show individual posts
|
||||||
if (!empty($_GET['hash'])) {
|
if (!empty($_GET['hash'])) {
|
||||||
$hash = $_GET['hash'];
|
$hash = $_GET['hash'];
|
||||||
$twts = array_filter($twts, function($twt) use ($hash) {
|
$twts = array_filter($twts, function($twt) use ($hash) {
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,10 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
$profile = getTwtsFromTwtxtString($config['public_txt_url']);
|
||||||
|
$profile = getTwtsFromTwtxtString("http://darch.dk/twtxt.txt");
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||||
|
|
@ -10,18 +17,23 @@
|
||||||
|
|
||||||
<header>
|
<header>
|
||||||
<p>
|
<p>
|
||||||
🧶 <a href="/">Timeline</a> for
|
<a href="/">
|
||||||
<a href="http://localhost:8000/?twts=http://darch.dk/twtxt.txt">sorenpeter</a>@darch.dk
|
<img class="avatar" src="<?= $profile->avatar ?>" alt="" loading="lazy">
|
||||||
(<a href="http://localhost:8000/twtxt.txt">twtxt.txt</a>)
|
Timeline for <?= $profile->nick ?>@<?= parse_url($profile->mainURL, PHP_URL_HOST); ?>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<!-- <a href="/">🧶 Timeline for <?= $url ?> </a> -->
|
||||||
|
<!-- for <a href="http://localhost:8000/?twts=http://darch.dk/twtxt.txt">sorenpeter</a>@darch.dk -->
|
||||||
|
<!-- (<a href="http://localhost:8000/twtxt.txt">twtxt.txt</a>) -->
|
||||||
</p>
|
</p>
|
||||||
<nav>
|
<nav>
|
||||||
<!-- TODO: make automatic via PHP and show avatar as well -->
|
<!-- TODO: make automatic via PHP and show avatar as well -->
|
||||||
<ul class="secondary">
|
<ul class="secondary">
|
||||||
<li><a href="/refresh?url=<?= $url ?>">Refresh</a></li>
|
|
||||||
<li><a href="/following">Following <?php // echo count($twtFollowingList); ?></a></li>
|
|
||||||
<?php //if ($validSession) { // TODO: Make login seqcure ?>
|
<?php //if ($validSession) { // TODO: Make login seqcure ?>
|
||||||
<?php if( isset($_SESSION['password'])) { /*
|
<?php if( isset($_SESSION['password'])) { /*
|
||||||
if($_SESSION['password']=="$password") {*/ // Hacky login ?>
|
if($_SESSION['password']=="$password") {*/ // Hacky login ?>
|
||||||
|
<li><a href="/refresh?url=<?= $url ?>">Refresh</a></li>
|
||||||
|
<li><a href="/following">Following <?php // echo count($twtFollowingList); ?></a></li>
|
||||||
<!-- <li><a href="/new">New post</a></li> -->
|
<!-- <li><a href="/new">New post</a></li> -->
|
||||||
<li><a href="/add">Add feed</a></li>
|
<li><a href="/add">Add feed</a></li>
|
||||||
<!-- <li><a href="/admin">Settings</a></li> -->
|
<!-- <li><a href="/admin">Settings</a></li> -->
|
||||||
|
|
|
||||||
20
style.css
20
style.css
|
|
@ -68,7 +68,11 @@ header > nav a {
|
||||||
margin: 0.25rem 0rem;
|
margin: 0.25rem 0rem;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
|
header img.avatar {
|
||||||
|
height: 1.5rem;
|
||||||
|
width: 1.5rem;
|
||||||
|
vertical-align: sub;
|
||||||
|
}
|
||||||
|
|
||||||
header p a,
|
header p a,
|
||||||
header p a:visited {
|
header p a:visited {
|
||||||
|
|
@ -152,6 +156,16 @@ a.author {
|
||||||
color: var(--text-light);
|
color: var(--text-light);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.profile a,
|
||||||
|
.profile a:visited {
|
||||||
|
color: var(--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
.profile a:hover {
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* === TIMELINE === */
|
/* === TIMELINE === */
|
||||||
|
|
||||||
article {
|
article {
|
||||||
|
|
@ -204,6 +218,10 @@ article small a:visited {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
article small a:hover {
|
||||||
|
color: var(--accent);
|
||||||
|
}
|
||||||
|
|
||||||
/* === New Post Form === */
|
/* === New Post Form === */
|
||||||
|
|
||||||
#new_twt {
|
#new_twt {
|
||||||
|
|
|
||||||
|
|
@ -33,13 +33,44 @@ if (!empty($_GET['twts'])) { // Show profile for some user
|
||||||
if (isset($_SESSION['password'])) {
|
if (isset($_SESSION['password'])) {
|
||||||
include 'views/new_twt.php'; // TODO: Split up new_twt into a view and a partial
|
include 'views/new_twt.php'; // TODO: Split up new_twt into a view and a partial
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
else {
|
else {
|
||||||
$url = "Location: /?twts=".$config['public_txt_url'];
|
$twtsURL = $config['public_txt_url'];
|
||||||
//header($url);
|
// $twtsURL = "http://darch.dk/twtxt.txt";
|
||||||
|
header("Location: /profile?url=".$twtsURL);
|
||||||
|
// die();
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php // Load user timeline
|
||||||
|
|
||||||
|
$parsedTwtxtFiles = [];
|
||||||
|
|
||||||
|
foreach ($fileLines as $currentLine) {
|
||||||
|
if (str_starts_with($currentLine, '#')) {
|
||||||
|
if (!is_null(getDoubleParameter('follow', $currentLine))) {
|
||||||
|
$follow = getDoubleParameter('follow', $currentLine);
|
||||||
|
$twtFollowingList[] = $follow;
|
||||||
|
|
||||||
|
// Read the parsed files if in Cache
|
||||||
|
$followURL = $follow[1];
|
||||||
|
$parsedTwtxtFile = getTwtsFromTwtxtString($followURL);
|
||||||
|
if (!is_null($parsedTwtxtFile)) {
|
||||||
|
$parsedTwtxtFiles[$parsedTwtxtFile->mainURL] = $parsedTwtxtFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$twts = [];
|
||||||
|
|
||||||
|
# Combine all the followers twts
|
||||||
|
foreach ($parsedTwtxtFiles as $currentTwtFile) {
|
||||||
|
if (!is_null($currentTwtFile)) {
|
||||||
|
$twts += $currentTwtFile->twts;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,19 +9,19 @@ include('partials/header.php');
|
||||||
<!-- PHP: PROFILE CARD -->
|
<!-- PHP: PROFILE CARD -->
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$twtsURL = $config['public_txt_url'];
|
//$twtsURL = $config['public_txt_url'];
|
||||||
// $twtsURL = "http://darch.dk/twtxt.txt";
|
//$profile = getTwtsFromTwtxtString($twtsURL);
|
||||||
|
|
||||||
|
|
||||||
/* from base.php */
|
/* from base.php */
|
||||||
|
|
||||||
# Show twts only for URL in query request, else show user timeline
|
# Show twts only for URL in query request, else show user timeline
|
||||||
|
|
||||||
if (!empty($_GET['url'])) { // Show twts for some user
|
if (!empty($_GET['url'])) { // Show twts for some user
|
||||||
echo "before GET(url): ".$twtsURL."<br>";
|
|
||||||
$twtsURL = $_GET['url'];
|
$twtsURL = $_GET['url'];
|
||||||
echo "after GET(url): ".$twtsURL."<br>";
|
$profile = getTwtsFromTwtxtString($twtsURL);
|
||||||
|
|
||||||
if (filter_var($twtsurl, FILTER_VALIDATE_URL) === FALSE) {
|
if (filter_var($twtsURL, FILTER_VALIDATE_URL) === FALSE) {
|
||||||
die('Not a valid URL');
|
die('Not a valid URL');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,18 +30,22 @@ if (!empty($_GET['url'])) { // Show twts for some user
|
||||||
$parsedTwtxtFiles[$parsedTwtxtFile->mainURL] = $parsedTwtxtFile;
|
$parsedTwtxtFiles[$parsedTwtxtFile->mainURL] = $parsedTwtxtFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { // Show timeline for the URL
|
}
|
||||||
|
else { // Show timeline for the URL
|
||||||
$twtsURL = $config['public_txt_url'];
|
$twtsURL = $config['public_txt_url'];
|
||||||
//$twtsURL = "http://darch.dk/twtxt.txt";
|
// $twtsURL = "https://lyse.isobeef.org/twtxt.txt";
|
||||||
|
// $profile = getTwtsFromTwtxtString($twtsURL);
|
||||||
if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
|
header("Location: /profile?url=".$twtsURL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (filter_var($twtsURL, FILTER_VALIDATE_URL) === FALSE) {
|
||||||
die('Not a valid URL');
|
die('Not a valid URL');
|
||||||
}
|
}
|
||||||
|
|
||||||
$parsedTwtxtFile = getTwtsFromTwtxtString($twtsURL);
|
$parsedTwtxtFile = getTwtsFromTwtxtString($twtsURL);
|
||||||
if (!is_null($parsedTwtxtFile)) {
|
if (!is_null($parsedTwtxtFile)) {
|
||||||
$parsedTwtxtFiles[$parsedTwtxtFile->mainURL] = $parsedTwtxtFile;
|
$parsedTwtxtFiles[$parsedTwtxtFile->mainURL] = $parsedTwtxtFile;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
$twts = [];
|
$twts = [];
|
||||||
|
|
@ -55,28 +59,6 @@ foreach ($parsedTwtxtFiles as $currentTwtFile) {
|
||||||
|
|
||||||
krsort($twts, SORT_NUMERIC);
|
krsort($twts, SORT_NUMERIC);
|
||||||
|
|
||||||
|
|
||||||
/* Profile header
|
|
||||||
|
|
||||||
if (empty($_GET['url'])) { // Show twts for some user
|
|
||||||
$twtsURL = $config['txt_file_path'];
|
|
||||||
|
|
||||||
if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
|
|
||||||
die('Not a valid URL');
|
|
||||||
}
|
|
||||||
|
|
||||||
$parsedTwtxtFile = getTwtsFromTwtxtString($twtsURL);
|
|
||||||
if (!is_null($parsedTwtxtFile)) {
|
|
||||||
$parsedTwtxtFiles[$parsedTwtxtFile->mainURL] = $parsedTwtxtFile;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
echo $twtsURL;
|
|
||||||
|
|
||||||
$profile = getTwtsFromTwtxtString($twtsURL);
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="profile">
|
<div class="profile">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue