10 Commits
v3 ... v13

Author SHA1 Message Date
3073231d38 remove homepage blurb for publication
--HG--
branch : sanitise-paths
2013-09-28 13:35:43 +12:00
0d522e1cd1 remove all branding for publication
--HG--
branch : sanitise-paths
2013-09-28 13:33:47 +12:00
eefefef0d9 fix shorttags 2013-09-28 13:27:42 +12:00
cf1ffd6b1e tweak style, remove images from homepage 2013-09-28 13:21:01 +12:00
a169383fda support code tags + header formatting, 3-wide progress status, isolate homepage blurb 2013-09-28 13:07:52 +12:00
1968bb7ad9 header image 2013-09-21 19:24:33 +12:00
2ec4eadabe index page build spritesheet of images 2013-09-21 19:01:49 +12:00
16bdbab1ab temporary favicon 2013-09-21 17:48:43 +12:00
092f8f0950 cosmetic fix linkification, 'written in' subtitles 2013-09-21 16:52:48 +12:00
a4262f8f8f cosmetic tweaks: lowercase first character, image alignment css, newest projects first 2013-09-21 16:24:52 +12:00
10 changed files with 131 additions and 49 deletions

View File

@@ -1,3 +0,0 @@
assorted old projects
A longer description goes here.

View File

@@ -1,3 +1,3 @@
@echo off @echo off
start C:\bin\cygwin\bin\mintty.exe /bin/bash -l -c "rsync -avz -e ""ssh -i /cygdrive/c/www/ms1_deploy_key -p 2222"" --progress /cygdrive/c/www/m6/code/wwwroot www-data@ms1.ivysaur.me:~/code.ivysaur.me/" start C:\path\to\cygwin\bin\mintty.exe /bin/bash -l -c "rsync -avz -e ""ssh -i /cygdrive/c/path/to/deploy_key"" --progress /cygdrive/c/path/to/code/wwwroot www-data@your-web-server:/var/www/path/to/code-site/"

8
homepage_blurb.htm Normal file
View File

@@ -0,0 +1,8 @@
<p>
Homepage blurb goes here.
</p>
<p>
<strong>PROJECTS</strong>
</p>

View File

@@ -1,3 +1,3 @@
@echo off @echo off
C:\bin\php54\php.exe rebuild.php C:\path\to\php_54\php.exe rebuild.php
pause pause

View File

@@ -7,18 +7,18 @@
// ````````````` // `````````````
define('BASEDIR', __DIR__.'\\'); define('BASEDIR', __DIR__.'\\');
define('SITE_TITLE', 'code.ivysaur.me'); define('SITE_TITLE', 'codesite');
define('PAGE_THUMB_W', 60); define('PAGE_THUMB_W', 60);
define('PAGE_THUMB_H', 60); define('PAGE_THUMB_H', 60);
define('INDEX_THUMB_W', 90); define('INDEX_THUMB_W', 90);
define('INDEX_THUMB_H', 30); define('INDEX_THUMB_H', 32); // recommend a multiple of the jpg iDCT block size
/** /**
* Create a thumbnail of an image. It overscales, centers, and crops to fit the * Create a thumbnail of an image. It overscales, centers, and crops to fit the
* target dimensions. * target dimensions.
* *
* @param string $src_file * @param string $src_file
* @param string $dest_file * @param string $dest_file Null to return an image handle
* @param int $width * @param int $width
* @param int $height * @param int $height
* @return boolean * @return boolean
@@ -45,7 +45,27 @@ function mkthumbnail($src_file, $dest_file, $width, $height) {
$width, $height, $box_w, $box_h $width, $height, $box_w, $box_h
); );
return imagejpeg($dest, $dest_file); imagedestroy($im);
if (is_null($dest_file)) {
return $dest;
} else {
return imagejpeg($dest, $dest_file);
}
}
function mkspritesheet(array $handles, $dest_file, $width, $height) {
$im = imagecreatetruecolor($width, $height * count($handles));
for($i = 0, $e = count($handles); $i != $e; ++$i) {
imagecopy($im, $handles[$i], 0, $i * $height, 0, 0, $width, $height);
}
if (is_null($dest_file)) {
return $dest_file;
} else {
return imagejpeg($im, $dest_file);
}
} }
/** /**
@@ -94,10 +114,20 @@ function hesc($sz) {
} }
function text2html($sz) { function text2html($sz) {
$base = nl2br(hesc($sz)); $base = hesc($sz);
$base = preg_replace('~(https?://[^ \\r\\n\\t]+)~i', '<a href="\\1">\\1</a>', $base);
preg_replace('~(https?://.+\b)~i', '<a href="\1">\1</a>', $base); $base = preg_replace('~=+(.+)=+~', '<strong>\\1</strong>', $base);
return $base;
$btparts = explode('`', $base);
if (count($btparts) > 1 && (count($btparts) % 2)) {
for ($i = 1, $e = count($btparts); $i < $e; $i += 2) {
$btparts[$i] = '<span class="code">'.$btparts[$i].'</span>';
}
$base = implode('', $btparts);
}
return nl2br($base);
} }
/** /**
@@ -108,11 +138,12 @@ class CProject {
private $dir; private $dir;
public $projname; public $projname;
public $shortdesc = '(no description)'; public $shortdesc = '(no description)';
public $subtag = '';
private $longdesc = ''; private $longdesc = '';
private $images = array(); private $images = array();
private $downloads = array(); private $downloads = array();
public $homeimage = 'no_image.png'; public $homeimage = null;
public function __construct($dirname, $projname) { public function __construct($dirname, $projname) {
$this->dir = BASEDIR.'data/'.$dirname.'/'; $this->dir = BASEDIR.'data/'.$dirname.'/';
@@ -126,7 +157,13 @@ class CProject {
if ($file == 'README.txt') { if ($file == 'README.txt') {
$this->longdesc = file_get_contents($this->dir.'README.txt'); $this->longdesc = file_get_contents($this->dir.'README.txt');
$matches = array();
if (preg_match('~Written in ([^\\r\\n]+)~', $this->longdesc, $matches)) {
$this->subtag = rtrim($matches[1], ' .');
}
$this->shortdesc = array_shift(explode("\n", $this->longdesc)); $this->shortdesc = array_shift(explode("\n", $this->longdesc));
$this->shortdesc[0] = strtolower($this->shortdesc[0]); // cosmetic lowercase
continue; continue;
} }
@@ -150,12 +187,11 @@ class CProject {
} }
if (count($this->images)) { if (count($this->images)) {
mkthumbnail( $this->homeimage = mkthumbnail(
BASEDIR.'wwwroot/srv/'.$this->projname.'_0.'.str_ext($this->images[0]), BASEDIR.'wwwroot/srv/'.$this->projname.'_0.'.str_ext($this->images[0]),
BASEDIR.'wwwroot/srv/'.$this->projname.'_headimg.jpg', null, // raw handle
INDEX_THUMB_W, INDEX_THUMB_H INDEX_THUMB_W, INDEX_THUMB_H
); );
$this->homeimage = 'srv/'.$this->projname.'_headimg.jpg';
} }
// Copy downloads to wwwroot // Copy downloads to wwwroot
@@ -174,11 +210,11 @@ class CProject {
public function index() { public function index() {
?> ?>
<h2><a href="index.html"><?=hesc(SITE_TITLE)?></a> &gt; <?=hesc($this->projname)?></h2> <h2><?=hesc($this->projname)?></h2>
<div class="projinfo"> <div class="projinfo">
<div class="projbody"> <div class="projbody projbody_<?=(count($this->images) ? 'half' : 'full')?>w">
<strong>ABOUT</strong> <strong>ABOUT</strong>
@@ -231,6 +267,7 @@ function template($title, $content) {
<body> <body>
<div id="container"> <div id="container">
<div id="content"> <div id="content">
<a href="index.html"><div id="bannerlogo"></div></a>
<?=$content?> <?=$content?>
</div> </div>
</div> </div>
@@ -263,7 +300,7 @@ function buildall() {
// List projects // List projects
$ls = scandir(BASEDIR.'data'); $ls = scandir(BASEDIR.'data');
sort($ls); rsort($ls);
$projects = array(); $projects = array();
foreach($ls as $dirname) { foreach($ls as $dirname) {
if ($dirname[0] == '.') continue; if ($dirname[0] == '.') continue;
@@ -279,54 +316,57 @@ function buildall() {
$plist = array(); $plist = array();
$count = 0; $count = 0;
$handles = array();
$handle_lookup = array();
foreach($projects as $dirname => $projectname) { foreach($projects as $dirname => $projectname) {
echo sprintf("[%2d/%2d] ".$projectname."...", ++$count, count($projects)); echo sprintf("[%3d/%3d] ".$projectname."...", ++$count, count($projects));
$pr = new CProject($dirname, $projectname); $pr = new CProject($dirname, $projectname);
$pr->write(); $pr->write();
$plist[] = $pr; $plist[] = $pr;
if (is_null($pr->homeimage)) {
$handle_lookup[$projectname] = null;
} else {
$handle_lookup[$projectname] = count($handles);
$handles[] = $pr->homeimage;
}
echo " done\n"; echo " done\n";
} }
// Build homepage spritesheet
mkspritesheet($handles, BASEDIR.'wwwroot/logos.jpg', INDEX_THUMB_W, INDEX_THUMB_H);
array_map('imagedestroy', $handles); // free
// Build index page // Build index page
ob_start(); ob_start();
?> ?>
<h2><?=hesc(SITE_TITLE)?></h2>
<img src="overview.jpg" class="headimg">
<p>
This page contains several assorted projects, which no longer have any relation. They are listed in roughly chronological order (newest first). <strong>Unless specified otherwise</strong>, you may feel free to use and modify both the binaries and any source code, for any purpose, on the general condition you do not misrepresent who the author is (BSD license).
</p>
<p>
Some of these projects formerly appeared on Google Code <a href="https://code.google.com/p/mappy/">here</a>, but were moved following the discontinuation of the Google Code binary download system.
</p>
<p> <?php if (file_exists(BASEDIR.'homepage_blurb.htm')) { ?>
For bug reports, feature requests, or if you need any help, please <!-- homepage blurb {{ -->
<a <?=file_get_contents(BASEDIR.'homepage_blurb.htm')?>
href="http://www.google.com/recaptcha/mailhide/d?k=01GuAWzMc9JjSdooo-2KCMQA==&amp;c=kgR3dBrP39yhPIy8FvLFbuBLmWqorQBDc_Zjbw6NAmU=" <!-- }} -->
onclick="window.open('http://www.google.com/recaptcha/mailhide/d?k\07501GuAWzMc9JjSdooo-2KCMQA\75\75\46c\75kgR3dBrP39yhPIy8FvLFbuBLmWqorQBDc_Zjbw6NAmU\075', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;" <?php } ?>
title="Reveal this e-mail address"
>click here</a> to email me.
</p>
<img src="projects.jpg" class="headimg">
<table class="projtable"> <table class="projtable">
<?php foreach ($plist as $pr) { ?> <?php foreach ($plist as $pr) { ?>
<tr> <tr>
<td> <td>
<a href="<?=hesc(urlencode($pr->projname))?>.html"><img src="<?=hesc($pr->homeimage)?>" class="homeimage"></a> <a href="<?=hesc(urlencode($pr->projname))?>.html"><?=(is_null($handle_lookup[$pr->projname]) ? '<div class="no-image"></div>' : '<div class="homeimage homeimage-sprite" style="background-position:0 -'.($handle_lookup[$pr->projname]*INDEX_THUMB_H).'px"></div>')?></a>
</td> </td>
<td> <td>
<strong><?=hesc($pr->projname)?></strong>, <strong><?=hesc($pr->projname)?></strong>,
<?=hesc($pr->shortdesc)?> <?=hesc($pr->shortdesc)?>
<a href="<?=hesc(urlencode($pr->projname))?>.html">more...</a> <a href="<?=hesc(urlencode($pr->projname))?>.html">more...</a>
<?php if (strlen($pr->subtag)) { ?>
<br>
<small><?=hesc($pr->subtag)?></small>
<?php } ?>
</td> </td>
</tr> </tr>
<?php } ?> <?php } ?>

BIN
static/header.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 860 B

After

Width:  |  Height:  |  Size: 436 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -12,6 +12,10 @@ a:hover {
h1,h2,h3 { h1,h2,h3 {
margin-top:0; margin-top:0;
} }
.code {
background: #F8F8F8;
font-family:Consolas,monospace;
}
/* */ /* */
@@ -48,13 +52,21 @@ html, body {
/* */ /* */
.projtable { .projtable {
}
.projtable tr {
border-collapse: collapse; border-collapse: collapse;
width:100%;
}
.projtable tr {
transition:0.2s linear;
}
.projtable tr:hover {
background:#F8F8F8;
} }
.projtable td { .projtable td {
padding: 4px; padding: 2px 4px;
}
.projtable small {
color:grey;
font-style:italic;
} }
.projinfo { .projinfo {
@@ -63,17 +75,30 @@ html, body {
.projbody { .projbody {
position:absolute; position:absolute;
left:0; left:0;
right: 64px; }
.projbody_halfw {
right: 74px;
}
.projbody_fullw {
right:0;
} }
.projimg { .projimg {
position:absolute; position:absolute;
right:0; right:0;
width:60px; width:62px; /* 60px + 2px border */
} }
/* */ /* */
#bannerlogo {
width:631px;
height:35px;
margin:0 auto;
background: white url('header.png') no-repeat 0 0;
padding:8px;
}
.headimg { .headimg {
width:310px; width:310px;
height:62px; height:62px;
@@ -81,7 +106,11 @@ html, body {
.homeimage { .homeimage {
width:90px; width:90px;
height:30px; height:32px;
}
.homeimage-sprite {
background: white url('logos.jpg') no-repeat 0 0;
} }
.thumbimage { .thumbimage {
@@ -89,7 +118,15 @@ html, body {
height:60px; height:60px;
opacity: 0.8; opacity: 0.8;
transition:0.2s opacity; transition:0.2s opacity;
border:1px solid lightgrey;
} }
.thumbimage:hover { .thumbimage:hover {
opacity:1.0; opacity:1.0;
} }
.no-image {
width:90px;
height:32px;
display:block;
background: white url('no_image.png') no-repeat 0 0;
}