⌈⌋ ⎇ branch:  freshcode


Artifact [9a04382e93]

Artifact 9a04382e9309acf801f66d545ba4a22522e4f8d5:

  • File cron.daily/spotlight.php — part of check-in [f5ea6d4058] at 2014-08-02 20:51:33 on branch trunk — Added "Project Spotlight" to page footer, and a cron-job for rotating 3 random projects in there. (user: mario size: 1016)

<?php
/**
 * api: cron
 * title: Create random picks for project spotlight
 * description: Randomly picks out a few projects for the footer
 * version: 0.1
 *
 *
 */

chdir(dirname(__DIR__)); 
include("config.php");


/**
 * Scan each project,
 * pick random three.
 *
 */
$r = db("
     SELECT name, title, SUBSTR(description, 0, 150) AS description,
     MAX(t_changed) AS t FROM release
     GROUP BY name
     ORDER BY random() 
     LIMIT 3;
"); 

// combine into HTML blob
$html = ""; 
foreach ($r as $entry) {

    $entry = array_map("input::_html", $entry);
#    $entry["description"] = preg_replace("/\.[^.]*$|[,;][^,;]*$|\S*$/", "", $entry["description"]);
    $html .= <<<EOF
   <a class=project-spotlight href="projects/$entry[name]">
      <img src="img/screenshot/$entry[name].jpeg" width=120 height=90 alt=$entry[name]>
      <b> $entry[title] </b>
      <small class=description>$entry[description]</small> 
   </a>

EOF;
}

// store as template
file_put_contents("./template/spotlight.htm", $html);