mirror of
https://github.com/sorenpeter/timeline.git
synced 2025-12-15 10:57:01 +00:00
Gallery + refresh progress bar
This commit is contained in:
parent
fdc513863d
commit
50851efcbb
3 changed files with 90 additions and 5 deletions
|
|
@ -30,7 +30,8 @@ $routes = [
|
|||
'/new' => 'new_twt.php',
|
||||
'/add' => 'add_feed.php',
|
||||
'/following' => 'following.php',
|
||||
'/refresh' => 'load_twt_files.php',
|
||||
#'/refresh' => 'load_twt_files.php',
|
||||
'/refresh' => 'refresh.php',
|
||||
'/login' => 'login.php',
|
||||
'/logout' => 'logout.php',
|
||||
'/profile' => 'profile.php',
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ if (!empty($_GET['profile'])) { // Show twts for some user
|
|||
include 'partials/profile.php';
|
||||
}
|
||||
} else {
|
||||
// code...
|
||||
//$filecontent = file('../twtxt.txt');
|
||||
$twtsURL = file($profile->mainURL);
|
||||
// TODO: default to rendering the local users gallery, if no profile specified
|
||||
//echo $profile->mainURL;;
|
||||
//$twtsURL = $profile->mainURL; // correct URL for twtxt.txt
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -39,7 +39,7 @@ foreach ($twts as $twt) {
|
|||
$img_array = getImagesFromTwt($twt->content);
|
||||
|
||||
foreach ($img_array as $img) {
|
||||
echo '<a href="'.$baseURL.'/post/'.$twt->hash.'">'.$img[0].'</a>';
|
||||
echo '<a href="'.$baseURL.'/conv/'.$twt->hash.'">'.$img[0].'</a>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
84
views/refresh.php
Normal file
84
views/refresh.php
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
<?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';
|
||||
|
||||
?>
|
||||
|
||||
<label id="refreshLabel" for="refreshProgress">Loading feeds followed by: <?=$url?></label><br>
|
||||
<progress id="refreshProgress" value=""></progress>
|
||||
|
||||
<?php
|
||||
|
||||
include 'partials/footer.php';
|
||||
//echo str_repeat(' ',1024*64);
|
||||
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("refreshLabel").innerHTML = "Updating: '.$following[1].' ('.$i.' of '.$total.')";
|
||||
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>';
|
||||
|
||||
Loading…
Reference in a new issue