w2krepo redesign complete!
Posted in Site Updates, w2krepo March 27th, 2020 by dotcomboom

I started reworking w2krepo’s styling back when I switched subdomains in February; finally I’ve come back to it and finished it up.

That list you see is actually dynamically generated with some PHP code I pulled together from stuff off the net.

<table>
<?php
$fileList = glob('*');
foreach($fileList as $filename){
    //Use the is_dir function to make sure that it is a directory.
    if(is_dir($filename) and ($filename != 'icons') and ($filename != 'blurbs')){
	echo '<tr><td style="min-width: 32px;">';
        echo '<a href="', $filename, '/"><img src="icons/', $filename, '.gif" width="32" height="32"></a>';
	echo '</td><td>';
        echo '<a href="', $filename, '/">', $filename, '</a>';
	echo '<br>', file_get_contents('blurbs/' . $filename . '.txt');
	echo '</td></tr>'; 
    }   
}
?>
</table>
<?php
$fileList = glob('*.7z');
foreach($fileList as $filename){
    //Use the is_file function to make sure that it is not a directory.
    if(is_file($filename)){
        echo '<a href="', $filename, '">', $filename, '</a><br>'; 
    }   
}
?>

The small blurbs I use as category descriptions are all stored in this folder. Those get written out through the script.

As for styling the directory indices, it’s pretty basic. I use a .htaccess file so my web server uses header and footer .html files.

<IfModule mod_autoindex.c>
	Options +Indexes
    	IndexOptions IgnoreCase FancyIndexing FoldersFirst NameWidth=* DescriptionWidth=* SuppressHTMLPreamble
	IndexIgnore header.html footer.html .htaccess index.css vduheader.png
	HeaderName header.html
	ReadmeName footer.html
	
	AddDescription "<span>Executable</span>" .exe
</IfModule>

From there, each folder has a header.html and footer.html file. header.html goes like this:

<!doctype html>
<html>
	<head>
		<title>Productivity</title>
		<link rel="stylesheet" href="http://cdn.jsdelivr.net/gh/kognise/water.css@latest/dist/light.min.css">
	</head>
	<body>
		<h1>Productivity</h1>

And footer.html:

                (I could put a readme here if need be)
	</body>
</html>

Although I would have liked to use one header.html and one footer.html for all of them (using some kind of tags similar to my own project AutoSite) this will work, at least in the interim. Things I could do in the future are adding more file descriptions to the .htaccess or put more information in the footers (possibly contact and contributing information, though that could be a hassle to update for each folder so another time, maybe).

It all also degrades gracefully in older browsers.

Visit here, or here for HTTP.

w2krepo, now on a new subdomain!
Posted in Site Updates, w2krepo February 8th, 2020 by dotcomboom

Since its inception, w2krepo had lived on my personal dotcomboom.somnolescent.net domain. I’m excited to announce that it now resides at w2krepo.somnolescent.net.

Moving the files was fairly painless, as the subdomain had been set up under my current FTP account. What was next was redirecting the old URLs to match the new domain, also fairly simple when you get down to it: just this .htaccess file in the w2krepo folder:

RewriteEngine on
RewriteRule ^(.*)$ http://w2krepo.somnolescent.net/$1 [R=301,L]

That left one thing: trying to get my root directory on the subdomain to display the builtin Apache directory listing was a bit problematic, so I settled on using a basic PHP script scraped from what I could find online:

<?php
$fileList = glob('*');
foreach($fileList as $filename){
    if(is_dir($filename)){
        echo '<a href="', $filename, '/">', $filename, '</a><br>'; 
    }   
}
echo '<br>';
$fileList = glob('*.7z');
foreach($fileList as $filename){
    if(is_file($filename)){
        echo '<a href="', $filename, '">', $filename, '</a><br>'; 
    }   
}
?>

It’ll work as a root for now, and I intend on messing more with .htaccess to get the subdirectories’ listings all prettied up as well.

For the future, I intend to get some sort of system up for user submissions, whether that be by anonymous FTP or an upload form, as well as some more information on the indexes and homepage.