cosmetic fix linkification, 'written in' subtitles

This commit is contained in:
mappu 2013-09-21 16:52:48 +12:00
parent a4262f8f8f
commit 092f8f0950
2 changed files with 19 additions and 4 deletions

View File

@ -94,10 +94,10 @@ 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); return nl2br($base);
return $base;
} }
/** /**
@ -108,6 +108,7 @@ 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();
@ -126,6 +127,11 @@ 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 $this->shortdesc[0] = strtolower($this->shortdesc[0]); // cosmetic lowercase
continue; continue;
@ -328,6 +334,10 @@ function buildall() {
<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 } ?>

View File

@ -56,6 +56,10 @@ html, body {
.projtable td { .projtable td {
padding: 4px; padding: 4px;
} }
.projtable small {
color:grey;
font-style:italic;
}
.projinfo { .projinfo {
position:relative; position:relative;
@ -74,7 +78,7 @@ html, body {
position:absolute; position:absolute;
right:0; right:0;
width:60px; width:62px; /* 60px + 2px border */
} }
/* */ /* */
@ -94,6 +98,7 @@ 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;