From ada8e382b93f4b4c059c338a2a527210d9f58ded Mon Sep 17 00:00:00 2001 From: mappu Date: Sat, 21 Sep 2013 15:10:24 +1200 Subject: [PATCH] cosmetic overhaul --- rebuild.php | 283 ++++++++++++++++++++++++++++--------- static/no_image.png | Bin 0 -> 860 bytes static/overview.jpg | Bin 0 -> 3262 bytes static/pixel_weave.png | Bin 0 -> 233 bytes static/pixel_weave_@2X.png | Bin 0 -> 264 bytes static/projects.jpg | Bin 0 -> 3039 bytes static/style.css | 95 +++++++++++++ 7 files changed, 310 insertions(+), 68 deletions(-) create mode 100644 static/no_image.png create mode 100644 static/overview.jpg create mode 100644 static/pixel_weave.png create mode 100644 static/pixel_weave_@2X.png create mode 100644 static/projects.jpg create mode 100644 static/style.css diff --git a/rebuild.php b/rebuild.php index dc43caf..d3ab615 100644 --- a/rebuild.php +++ b/rebuild.php @@ -3,37 +3,19 @@ // Code-hosting website // ```````````````````` +// CONFIGURATION +// ````````````` + define('BASEDIR', __DIR__.'\\'); define('SITE_TITLE', 'code.ivysaur.me'); define('PAGE_THUMB_W', 60); define('PAGE_THUMB_H', 60); - -// clean up wwwroot - -if (file_exists(BASEDIR.'wwwroot')) { - rename(BASEDIR.'wwwroot', BASEDIR.'wwwroot.old.'.uniqid()); -} - -mkdir(BASEDIR.'wwwroot'); -mkdir(BASEDIR.'wwwroot/srv'); - -// List of projects - -$ls = scandir(BASEDIR.'data'); -sort($ls); -$projects = array(); -foreach($ls as $dirname) { - if ($dirname[0] == '.') continue; - $matches = array(); - - if (preg_match('~(?:\d+-)?(.+)~', $dirname, $matches)) { - $projects[$dirname] = $matches[1]; - } -} +define('INDEX_THUMB_W', 90); +define('INDEX_THUMB_H', 30); /** - * Create a thumbnail of an image. It overscales and crops to fit the target - * box. + * Create a thumbnail of an image. It overscales, centers, and crops to fit the + * target dimensions. * * @param string $src_file * @param string $dest_file @@ -50,21 +32,12 @@ function mkthumbnail($src_file, $dest_file, $width, $height) { $scale = max( $width/$src_width, $height/$src_height ); // overscale + crop - print_r($scale); - $box_w = $width/$scale; $box_h = $height/$scale; $box_xoff = floor(($src_width - $box_w)/2); $box_yoff = floor(($src_height - $box_h)/2); - print_r(array( - $dest, $im, - 0, 0, - $box_xoff, $box_yoff, - $width, $height, $box_w, $box_h - )); - imagecopyresampled( $dest, $im, 0, 0, @@ -75,6 +48,38 @@ function mkthumbnail($src_file, $dest_file, $width, $height) { return imagejpeg($dest, $dest_file); } +/** + * Remove a directory tree and all its contents. + * + * @author http://www.php.net/manual/en/function.rmdir.php#110489 + * @param string $dir + * @return boolean + */ +function rmdir_recursive($dir) { + $files = array_diff(scandir($dir), array('.','..')); + foreach ($files as $file) { + if (is_dir("$dir/$file")) { + rmdir_recursive("$dir/$file"); + } else { + unlink("$dir/$file"); + } + } + return rmdir($dir); +} + +function fbytes($size, $suffixes='B|KiB|MiB|GiB|TiB') { + $sxlist = explode('|', $suffixes); + if ($size < 1024) { + return $size.$sxlist[0]; + } + + while ($size > 1024 && count($sxlist) >= 2) { + array_shift($sxlist); + $size /= 1024; + } + return number_format($size, 2).array_shift($sxlist); +} + function str_ext($sz) { $dpos = strrpos($sz, '.'); return substr($sz, $dpos+1); @@ -88,15 +93,27 @@ function hesc($sz) { return @htmlentities($sz, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); } +function text2html($sz) { + $base = nl2br(hesc($sz)); + + preg_replace('~(https?://.+\b)~i', '\1', $base); + return $base; +} + +/** + * + */ class CProject { private $dir; - private $projname; - private $shortdesc = '(no description)'; + public $projname; + public $shortdesc = '(no description)'; private $longdesc = ''; private $images = array(); private $downloads = array(); + public $homeimage = 'no_image.png'; + public function __construct($dirname, $projname) { $this->dir = BASEDIR.'data/'.$dirname.'/'; $this->projname = $projname; @@ -132,6 +149,15 @@ class CProject { mkthumbnail($outfile.'.'.str_ext($image), $outfile.'_thumb.jpg', PAGE_THUMB_W, PAGE_THUMB_H); } + if (count($this->images)) { + mkthumbnail( + BASEDIR.'wwwroot/srv/'.$this->projname.'_0.'.str_ext($this->images[0]), + BASEDIR.'wwwroot/srv/'.$this->projname.'_headimg.jpg', + INDEX_THUMB_W, INDEX_THUMB_H + ); + $this->homeimage = 'srv/'.$this->projname.'_headimg.jpg'; + } + // Copy downloads to wwwroot foreach($this->downloads as $idx => $filename) { @@ -142,55 +168,176 @@ class CProject { ob_start(); $this->index(); - $idxfile = ob_get_clean(); + $idxfile = template($this->projname.' | '.SITE_TITLE, ob_get_clean()); file_put_contents(BASEDIR.'wwwroot/'.$this->projname.'.html', $idxfile); } public function index() { -?> - - - - - <?=hesc($this->projname)?> | <?=hesc(SITE_TITLE)?> - - -

projname)?>

+?> +

> projname)?>

+ +
+ +
-

longdesc))?>

+ ABOUT - images)) { ?> -

Images

- images as $idx => $origname) { ?> - - - +

longdesc)?>

+ +downloads)) { ?> + + DOWNLOAD - downloads)) { ?> -

Files

    - downloads as $filename) { ?> -
  • - -
+ downloads as $filename) { ?> +
  • + + + + +
  • - - + + +
    + +images)) { ?> +
    + images as $idx => $origname) { ?> + + +
    + + +
    + + + + + + + + <?=hesc($title)?> + + +
    +
    + +
    +
    + + + $projectname) { - $pr = new CProject($dirname, $projectname); - print_r($pr); +function buildall() { - $pr->write(); -} + // Clean up webroot + + if (file_exists(BASEDIR.'wwwroot')) { + rmdir_recursive(BASEDIR.'wwwroot'); + } -// Build index page + echo "Creating directories...\n"; + mkdir(BASEDIR.'wwwroot'); + mkdir(BASEDIR.'wwwroot/srv'); + // Copy in static files + + foreach(scandir(BASEDIR.'static') as $static) { + if ($static[0] == '.' || is_dir($static) /* fixme */) continue; + copy(BASEDIR.'static/'.$static, BASEDIR.'wwwroot/'.$static); + } + + // List projects + + $ls = scandir(BASEDIR.'data'); + sort($ls); + $projects = array(); + foreach($ls as $dirname) { + if ($dirname[0] == '.') continue; + $matches = array(); + + if (preg_match('~(?:\d+-)?(.+)~', $dirname, $matches)) { + $projects[$dirname] = $matches[1]; + } + } + + // Build all projects + + $plist = array(); + $count = 0; + + foreach($projects as $dirname => $projectname) { + + echo sprintf("[%2d/%2d] ".$projectname."...", ++$count, count($projects)); + + $pr = new CProject($dirname, $projectname); + $pr->write(); + $plist[] = $pr; + + echo " done\n"; + } + + // Build index page + + ob_start(); +?> +

    + + + +

    + This page contains several assorted projects, which no longer have any relation. They are listed in roughly chronological order (newest first). Unless specified otherwise, 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). +

    + +

    + Some of these projects formerly appeared on Google Code here, but were moved following the discontinuation of the Google Code binary download system. +

    + +

    + For bug reports, feature requests, or if you need any help, please + click here to email me. +

    + + + + + + + + + + +
    + + + projname)?>, + shortdesc)?> + more... +
    +_{{i(C%insk!Mww;~s_S@;S-HZ!z z63GMv0dxQzbg`BK*xXz>SQw6N%8sh+dBsG{QSIiwAg8G z)q*7Y==byU^S_inc73l@f@TnnM#EiRUb^9M7)?^ot>Szx3@Pp8jbvwdc9uvb*r@L zUfox%R=tfY^;WCp>lYUnzAoF{-JLIESN}vP<*Tc!=o!@IM;}0@Op4$>8z89#&C9X? zF%1Qbm)F4TVC~?)1Fa8YZPabQ{eIt-N+l0XAh|#3qgp>A7}%PD(tQ@alYnkEn|_d; zPRB>l{r$Zk40R2RcBw$ywzwZknYOr%y6qQWlwV$6yvpzW{oR)*oJp)M8DRbpRQwFN_Q{DzT z3$BRxF>Jv}1}?oPEdV3{Ktlrp0)c>E0@8qJAy6=k?%YPP0Dxd1 z=zIc(Kp1|m00A^0FfD}j0+fwiP#nf_5v4D5)57Tz2Jhz|%PFB8Q&MX1z|xrzn4XbY zzIBfH?HvA7zxd~jpNMnoD(g9o=KKW%{bK`JX)b^SH^Jf-Y(gmgn35)}H|U>YF650AP)WnBkD9R;HCbZP$?{&N4j3H++UXk(m0nsu1; z=)kJaYnE`ba|)DjC(t3T+Y(m=d$&)NwYA;C*#AQX37|}JVAr1e`X?I0u1XCsl?Qy~ zJx-&R9H&+Ma~?!sAV3BDoMBv!7m2RQ>}uvgLX)s^uj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B<rLFBoBS=1cVn$YC)lw(^8*=&9F zFGUryhx$ByyGXoe?P>HPkCqmdUnF~(vhg^wpzX`l3)HQVyL&yur#ZyLZGqIx#M;eb~+bEy&b+iyOA#4RIe68lUkbA{e~pz#~)a;cp6#?`JwUSBgzVHuqBk zSefCOH6Qtt(lbiPQuB7i6bf6);)07)>zyFJT!=Eyfd|2bIPe@*A@$UE=&>uI- zU_Z>573-lYD?<58%mvLUS(C!^@<|7W%xZMMubqf8UA>g3@|-h%fE4C7p(2syVq^J$ zZ@%S_&iap$-hCj6>#;)-QOjmZ&Acqm`9(7MiE~d}L0L7ZL-cY(%1g{0PF#4(4^NJvXZXz;Gya8<)f+BCJ|jx;Y?j~Tw)_*z-4+pm zCKdzWu?x@Uj8koq@VLIw9^E^8T6kCE3lY{f zGWv)!cVER7>L^!Ay7q9-;qcM*9FCIS)x-3x zCe@cwt&bvJGh7&p*g6O`<3YSw|R-AiK8 zAfab+J@&WhSX<6F{h@Qcb4}@W4T?8{AoaOk?~Z&z3S#m$xMB-lhnC#uAPc$jF;hlb zFp*rhrcd@!1*3bagEz{bK9%t1Y1tq1lh#v3&DQ%*GaT*r*$$od~%ek8*8Qj#X9C*tMyNj`` zLcO^a+rMc9ef}3oibR`?d0UzMRg$_#pTPM#E4G09SYH9d80gU0g65IlIlA5=!Tt4j zvZg-Ccu3vC*65|heV($-r8IfjWYN^%N6PJg7kUVHas{1DdZAA>$+YB9&d$0w(lC<(@I4Gz3_iQC^?AQr4l|70j#>-)sBR-OEU3`j;T?esU2B8=1KVXHp%F{e~9 z%2^O5hGo&UVgmSariEf)E^(U3tgQ4=%`3-ts?4JX18W~pdtVG9Nk#!{*&ts{xWC?Q zT2zaGr!pu+3CDsE@c0>yf5uF9XkwO0i=$|`(C+Yub I_|M4y1|V(z+W-In literal 0 HcmV?d00001 diff --git a/static/pixel_weave.png b/static/pixel_weave.png new file mode 100644 index 0000000000000000000000000000000000000000..af7d13a45dd36657903f7c2827e3c3599d6cb84d GIT binary patch literal 233 zcmeAS@N?(olHy`uVBq!ia0vp^4j|0L3?#3!&-4XSJOMr-u1Ag>dGO%D)2B~gym*na z=~zBce1@lsV@L&K@1%n(+Z=hAE*~-bIBNsf>>A%CCiT-4p4^@+*PiGnX5xI_YgQ>= zhySB1${GwRWldi>xEMUwu)G!&VVLx%xXIsn64L?eFR~?fCa`KUEK!~SVz4&!Ig}r7 zi`vW}T+PeLgI!No*&{Z d2ZfA2FiY=nYpGxJy8!4$22WQ%mvv4FO#qH~SV8~* literal 0 HcmV?d00001 diff --git a/static/pixel_weave_@2X.png b/static/pixel_weave_@2X.png new file mode 100644 index 0000000000000000000000000000000000000000..45aa857f508a543cd44b9825b8ad7561fd7602b9 GIT binary patch literal 264 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?K3?%mjbVdLvo&cW^*B38dJbn7~!Gi}!jvPtN znezrHzTMNsF{C2y>QzNPRz-p4#6F8Q?{6ih=NH6nQkh7ZOa|w zBA6OxpJ3xmX=Z0&&{JjvF%B5(DS;Ud_t*PPJa1C5J>vsI#c}=wP1}$r*W(7v3}+U; zS-^N9;m(~0j14lU_%kjj=$ltGv=vTqNULnh)$l*CO*!U(+LZK!%Yt?ZlBa?fD9loBNGIAOch}OAP59v z0E0n{Ouuh{fMW`QGoIvRI>RN4Hi8PHY(+fq+zMKDu@yX`a@xiipUmS=KHzWtClvtr zEBBb3haYD!02vsVLI0*eIKxR0SoTb;Fxto#pV8bmy^8WEI~oD7f{t(DAUHq+uuB3w z(?r6cU2+JXRd94E!1sZ*lE5X_%X$^0iL0o4lmH@`IL}X z{ariy#q47k57$7*MCULSE9)~ooRU(Y<1IoKXw&a=)W@#J2?#9TI!kvXkDi@QSgm)z zkGf2M^=)R|x_rSiyr8pN-i9{j_pvY1#K7Q=HIk!cDMzj@Gn6c~^zhS4rx5zvVx`=> zSG$JlZ~LvasLG+C5q^S2{P_hrSfg}qxN;_Pt|iJjHp~^0{Hxyg9_tP&+Vo2mv2v^1 zBU`4Z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=WSMllp=Km_4|J^P*j)wmMtHFDH literal 0 HcmV?d00001 diff --git a/static/style.css b/static/style.css new file mode 100644 index 0000000..0960e8f --- /dev/null +++ b/static/style.css @@ -0,0 +1,95 @@ +/* style.css */ + +img { + border:0; +} +a { + color:black; +} +a:hover { + color:blue; +} +h1,h2,h3 { + margin-top:0; +} + +/* */ + +html, body { + /* structural */ + height:100%; + margin:0; + border:0; + padding:0; + + /* cosmetic */ + background:#DDD url('pixel_weave.png'); /* thanks subtlepatterns.com ! */ + color:#333; +} + +#container { + margin:0 auto; + width:768px; + position:relative; + + height:auto !important; + height:100%; /* oldIE */ + min-height:100%; + + /* cosmetic */ + background:white; +} + +#content { + padding:14px; + background:white; +} + +/* */ + +.projtable { + +} +.projtable tr { + border-collapse: collapse; +} +.projtable td { + padding: 4px; +} + +.projinfo { + position:relative; +} +.projbody { + position:absolute; + left:0; + right: 64px; +} +.projimg { + position:absolute; + right:0; + + width:60px; +} + +/* */ + +.headimg { + width:310px; + height:62px; +} + +.homeimage { + width:90px; + height:30px; +} + +.thumbimage { + width:60px; + height:60px; + opacity: 0.8; + transition:0.2s opacity; +} +.thumbimage:hover { + opacity:1.0; +}