Some CSS work

This commit is contained in:
sorenpeter 2024-01-29 20:55:50 +01:00
parent c1579a27a6
commit 2d88c1b051
5 changed files with 130 additions and 8 deletions

View file

@ -30,7 +30,8 @@ $routes = [
'/new' => 'new_twt.php', '/new' => 'new_twt.php',
'/add' => 'add_feed.php', '/add' => 'add_feed.php',
'/following' => 'following.php', '/following' => 'following.php',
'/refresh' => 'load_twt_files.php', //'/refresh' => 'load_twt_files.php',
'/refresh' => 'refresh.php',
'/login' => 'login.php', '/login' => 'login.php',
'/logout' => 'logout.php', '/logout' => 'logout.php',
'/profile' => 'profile.php', '/profile' => 'profile.php',

View file

@ -238,6 +238,26 @@ nav.pagnation {
padding: 0.5rem 0; padding: 0.5rem 0;
} }
/* === REFRESH === */
#refreshLabel {
}
#refreshInfo {
font-weight: bold;
}
#refreshURL {
display: block;
}
#refreshCounter {
float: right;
}
/* === FOOTER === */
footer { footer {
border-top: thin solid grey; border-top: thin solid grey;
margin-top: 1rem; margin-top: 1rem;

View file

@ -4,12 +4,14 @@ $profile = getTwtsFromTwtxtString($config['public_txt_url']);
?> ?>
<!doctype html>
<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"/>
<meta name="viewport" content="width=device-width, initial-scale=1" /> <meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="<?= $baseURL ?>/libs/simple.css"> <link rel="stylesheet" type="text/css" href="<?= $baseURL ?>/libs/simple.css">
<link rel="stylesheet" type="text/css" href="<?= $baseURL ?>/style.css"> <link rel="stylesheet" type="text/css" href="<?= $baseURL ?>/libs/timeline.css">
<link rel="stylesheet" type="text/css" href="<?= $baseURL ?>/custom_style.css">
<title><?= $title ?></title> <title><?= $title ?></title>
</head> </head>
<body> <body>
@ -43,5 +45,3 @@ $profile = getTwtsFromTwtxtString($config['public_txt_url']);
</header> </header>
<main> <main>

View file

@ -2,9 +2,13 @@
# Gets the followers from an URL and then gets all the Followers twtxt.txt files # Gets the followers from an URL and then gets all the Followers twtxt.txt files
# Intended to be run in the background # Intended to be run in the background
/*
require_once("libs/session.php"); // TODO: Move all to base.php require_once("libs/session.php"); // TODO: Move all to base.php
require_once('libs/twtxt.php'); require_once('libs/twtxt.php');
require_once('libs/hash.php'); require_once('libs/hash.php');
*/
require_once("partials/base.php");
$config = parse_ini_file('private/config.ini'); $config = parse_ini_file('private/config.ini');
@ -13,6 +17,7 @@ if (!isset($_SESSION['password'])) {
exit(); exit();
} }
$max_execution_time = intval($config['max_execution_time']); $max_execution_time = intval($config['max_execution_time']);
if ($max_execution_time < 1) { if ($max_execution_time < 1) {
$max_execution_time = 1; $max_execution_time = 1;
@ -20,9 +25,13 @@ if ($max_execution_time < 1) {
ini_set('max_execution_time', $max_execution_time); ini_set('max_execution_time', $max_execution_time);
#ob_start(); //ob_start();
$config = parse_ini_file('private/config.ini'); //require_once 'partials/header.php';
//ob_flush();
//$config = parse_ini_file('private/config.ini');
$url = $config['public_txt_url']; $url = $config['public_txt_url'];
if (!empty($_GET['url'])) { if (!empty($_GET['url'])) {

92
views/refresh.php Normal file
View file

@ -0,0 +1,92 @@
<?php
require_once("partials/base.php");
if (!isset($_SESSION['password'])) {
header('Location: ./login');
exit();
}
//ob_start();
$title = "Refresh - ".$title;
ob_end_flush();
include 'partials/header.php';
?>
<p id="refreshLabel">
<span id=refreshInfo>Loading feeds followed by:</span>
<span id=refreshURL><?= preg_replace('(^https?://)', '', $url) ?><span>
<span id="refreshCounter">(1 of 10)</span>
</p>
<progress id="refreshProgress" value=""></progress>
<?php
include 'partials/footer.php';
ob_start();
flush();
// Get URL from query
$url = $config['public_txt_url'];
if (!empty($_GET['url'])) {
$url = $_GET['url'];
}
if (filter_var($url, FILTER_VALIDATE_URL) === FALSE) {
die('Not a valid URL');
}
// Build Following List
$twtFollowingList = [];
foreach ($fileLines as $currentLine) {
if (str_starts_with($currentLine, '#')) {
if (!is_null(getDoubleParameter('follow', $currentLine))) {
$twtFollowingList[] = getDoubleParameter('follow', $currentLine);
}
}
}
// Loop over feeds followed
/* Progress bar based on: https://github.com/w3shaman/php-progress-bar */
$i = 1;
$total = count($twtFollowingList);
foreach ($twtFollowingList as $following) {
//ob_start();
$float = $i/$total;
$percent = intval($float * 100)."%";
// Javascript for updating the progress bar and information
echo '<script language="javascript">
document.getElementById("refreshInfo").innerHTML = "
<span id=refreshInfo>Updating:</span>
<span id=refreshURL>'.preg_replace('(^https?://)', '', $following[1]).'<span>
<span id="refreshCounter">('.$i.' of '.$total.')</span>
";
document.getElementById("refreshProgress").value = "'.$float.'";
document.getElementById("refreshProgress").innerHTML = "'.$percent.'";
</script>';
updateCachedFile($following[1]);
ob_flush(); // Send output to browser immediately
flush();
$i++;
}
// Tell user that the process is completed
echo '<script language="javascript">
document.getElementById("refreshLabel").innerHTML="Refreshed '.$total.' feeds";
history.back();
</script>';