Started visual gallery, expanded fetch-script
This commit is contained in:
parent
fb5b66f12b
commit
a500b5eecc
|
@ -5,6 +5,3 @@
|
||||||
/vendor/
|
/vendor/
|
||||||
/www/simplesaml
|
/www/simplesaml
|
||||||
composer.phar
|
composer.phar
|
||||||
/www/galleri/bilder/slideshow/*.*
|
|
||||||
!/www/galleri/bilder/slideshow/.gitkeep
|
|
||||||
/www/galleri/bilder/pvv-photos/*.*
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,35 @@
|
||||||
|
body, main {
|
||||||
|
width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
.gallery-container {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(3, 1fr);
|
||||||
|
grid-gap: 10px;
|
||||||
|
width: 95%;
|
||||||
|
margin: 15px auto;
|
||||||
|
}
|
||||||
|
figure {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
.card-image {
|
||||||
|
margin: auto 0;
|
||||||
|
object-fit: scale-down;
|
||||||
|
object-position: 0 50%;
|
||||||
|
object-position: center;
|
||||||
|
object-fit: cover;
|
||||||
|
max-height: 45vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (min-width:320px) {
|
||||||
|
.gallery-container {grid-template-columns: 1fr !important; }
|
||||||
|
}
|
||||||
|
@media only screen and (min-width: 641px) {
|
||||||
|
.gallery-container { grid-template-columns: repeat(2, 1fr) !important;}
|
||||||
|
}
|
||||||
|
@media only screen and (min-width: 961px) {
|
||||||
|
.gallery-container { grid-template-columns: repeat(3, 1fr) !important;}
|
||||||
|
}
|
||||||
|
@media only screen and (min-width: 1281px) {
|
||||||
|
.gallery-container { grid-template-columns: repeat(4, 1fr) !important;}
|
||||||
|
}
|
|
@ -0,0 +1,4 @@
|
||||||
|
bilder/slideshow/*.*
|
||||||
|
!/bilder/slideshow/.gitkeep
|
||||||
|
bilder/pvv-photos
|
||||||
|
usernames.txt
|
|
@ -1,10 +1,14 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
outfolder="bilder/pvv-photos"
|
outfolder="bilder/pvv-photos"
|
||||||
folders=$(find /home/pvv -maxdepth 3 -name 'pvv-photos' 2>/dev/null)
|
folders=$(find /home/pvv -maxdepth 3 -name 'pvv-photos' 2>/dev/null)
|
||||||
|
unamefile="usernames.txt"
|
||||||
|
> $unamefile # Empty the file
|
||||||
|
|
||||||
for imgfolder in $folders; do
|
for imgfolder in $folders; do
|
||||||
user=$(echo $imgfolder | cut -d "/" -f5)
|
user=$(echo $imgfolder | cut -d "/" -f5)
|
||||||
|
realname="$(getent passwd $user | cut -d ':' -f 5)"
|
||||||
|
echo "$user:$realname" >> $unamefile
|
||||||
destination="$outfolder/$user"
|
destination="$outfolder/$user"
|
||||||
mkdir -p $destination
|
mkdir -p $destination
|
||||||
rsync -rvz --delete "$imgfolder/" "$destination"
|
rsync -rtvz --delete "$imgfolder/" "$destination" # Copy and keep timestamps
|
||||||
done
|
done
|
|
@ -0,0 +1,121 @@
|
||||||
|
<?php
|
||||||
|
require_once dirname(dirname(__DIR__)) . implode(DIRECTORY_SEPARATOR, ['', 'inc', 'include.php']);
|
||||||
|
|
||||||
|
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||||
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||||
|
|
||||||
|
$userManager = new \pvv\admin\UserManager($pdo);
|
||||||
|
|
||||||
|
$as = new SimpleSAML_Auth_Simple('default-sp');
|
||||||
|
$as->requireAuth();
|
||||||
|
$attrs = $as->getAttributes();
|
||||||
|
$uname = $attrs['uid'][0];
|
||||||
|
|
||||||
|
if(!$uname){
|
||||||
|
header('Content-Type: text/plain', true, 403);
|
||||||
|
echo "Du må være logget inn for å se bildegalleriet.\r\n";
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$unamefile = __DIR__ . '/usernames.txt';
|
||||||
|
$unamepairs = file($unamefile);
|
||||||
|
|
||||||
|
$relativePath = "/bilder/pvv-photos/";
|
||||||
|
$fullPath = getcwd() . $relativePath;
|
||||||
|
|
||||||
|
function getDirContents($dir, &$results = array()) {
|
||||||
|
$files = scandir($dir);
|
||||||
|
foreach ($files as $key => $value) {
|
||||||
|
$path = realpath($dir . DIRECTORY_SEPARATOR . $value);
|
||||||
|
if (!is_dir($path)) {
|
||||||
|
//$results[] = str_replace($GLOBALS["fullPath"], "", $path); // Works, but breaks if the image path contains the path to the gallery on the server
|
||||||
|
//Remove the full path to the gallery from the image path. Keep username and path to image.
|
||||||
|
$pos = strpos($path, $GLOBALS["fullPath"]);
|
||||||
|
if ($pos !== false) {
|
||||||
|
$cleanPath = substr_replace($path, "", $pos, strlen($GLOBALS["fullPath"]));
|
||||||
|
}
|
||||||
|
$results[] = $cleanPath;
|
||||||
|
} else if ($value != "." && $value != "..") {
|
||||||
|
//recursively scan directories
|
||||||
|
getDirContents($path, $results);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $results;
|
||||||
|
}
|
||||||
|
$images = getDirContents($fullPath);
|
||||||
|
|
||||||
|
$imageTemplate = '
|
||||||
|
<div class="card is-flex is-flex-direction-column is-justify-content-space-between gallery-img-card">
|
||||||
|
<div class="card-image">
|
||||||
|
<figure class="image">
|
||||||
|
<img src="%path" alt="%name" class="card-image">
|
||||||
|
</figure>
|
||||||
|
</div>
|
||||||
|
<div class="card-content">
|
||||||
|
<div class="media">
|
||||||
|
<div class="media-content">
|
||||||
|
<p class="title is-4">%realname</p>
|
||||||
|
<p class="subtitle is-6">%user</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="content">
|
||||||
|
%name
|
||||||
|
<br>
|
||||||
|
<time datetime="%time">%time</time>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="no">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
||||||
|
<link rel="shortcut icon" href="favicon.ico">
|
||||||
|
<link rel="stylesheet" href="../css/normalize.css">
|
||||||
|
<link rel="stylesheet" href="../css/style.css">
|
||||||
|
<link rel="stylesheet" href="../css/events.css">
|
||||||
|
<link rel="stylesheet" href="../css/gallery.css">
|
||||||
|
<link rel="stylesheet" href="../css/bulma.min.css">
|
||||||
|
<meta name="theme-color" content="#024" />
|
||||||
|
<title>Fotoverkstedet</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>Fotoverkstedet</header>
|
||||||
|
<nav id="navbar" class="">
|
||||||
|
<?php echo navbar(0, ''); ?>
|
||||||
|
<?php echo loginbar(null, $pdo); ?>
|
||||||
|
</nav>
|
||||||
|
<main class="card gallery-container">
|
||||||
|
<?php
|
||||||
|
foreach ($images as $key => $value) {
|
||||||
|
$modTime = date("d.m.Y H:i", filemtime($fullPath . $value));
|
||||||
|
$imguser = explode("/", $value)[0];
|
||||||
|
$displaypath = substr($value, strpos($value, "/")+1);
|
||||||
|
$realname = "Ukjent";
|
||||||
|
foreach ($unamepairs as $unamepair) {
|
||||||
|
$unamepair = explode(":", $unamepair);
|
||||||
|
if ($unamepair[0] == $imguser) {
|
||||||
|
$realname = $unamepair[1];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$vars = [
|
||||||
|
"%user" => $imguser,
|
||||||
|
"%time" => $modTime,
|
||||||
|
"%name" => $displaypath,
|
||||||
|
"%path" => "/galleri/" . $relativePath .$value,
|
||||||
|
"%realname" => $realname
|
||||||
|
];
|
||||||
|
echo strtr($imageTemplate, $vars);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</main>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue