[cc-commits] [SCM] "Ahab" skin for CC Learn (based on the work of White Whale) (branch master) updated. ea5d535ed792b5860fabb0d8bc19e12947bae41d
git version control
git at a7.creativecommons.org
Tue Apr 7 16:00:38 EDT 2009
The branch, master has been updated
via ea5d535ed792b5860fabb0d8bc19e12947bae41d (commit)
via 85ec298f7ad4bffb05c35c70c883f97ed27c449f (commit)
from 9d09883fbf87e4ec90976e59678dba78cbfc1b0f (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ea5d535ed792b5860fabb0d8bc19e12947bae41d
Author: Asheesh Laroia <asheesh at asheesh.org>
Date: Tue Apr 7 13:00:34 2009 -0700
Remove a commented-out print
commit 85ec298f7ad4bffb05c35c70c883f97ed27c449f
Author: Asheesh Laroia <asheesh at asheesh.org>
Date: Tue Apr 7 12:59:53 2009 -0700
Horrifically choose a random member of the category
-----------------------------------------------------------------------
Summary of changes (followed by patch):
ahab.php | 26 ++++++++++++++++++++------
1 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/ahab.php b/ahab.php
index aecab07..24f535b 100644
--- a/ahab.php
+++ b/ahab.php
@@ -75,12 +75,28 @@ class AhabTemplate extends QuickTemplate {
}
if ($chosen_sidebox === null) {
- /* we ought to pick a random one */
- /* FIXME: Actually make this random */
- $chosen_sidebox = 'FAQ sidebox';
+ /* we ought to pick a random one */
+ $catview = new CategoryViewer(Title::newFromText('Category:Sidebox'));
+ /* FIXME: Currently this ignores the disabled/enabled property */
+ $catview->doCategoryQuery();
+ /* The ->article property on $catview gives us generated HTML, and
+ * there is no way to avoid this; the HTMLification happens inside
+ * the CategoryViewer object.
+ *
+ * FIXME: Replace this with an SMW query (which will have its own problems).
+ */
+ function catlink2catstring($catlink) {
+ return preg_replace('/.*title="(.*?)".*/', '$1', $catlink);
+ }
+ $articles = array();
+ foreach ($catview->articles as $catviewed) {
+ $articles[] = catlink2catstring($catviewed);
+ }
+
+ $random_index = mt_rand(0, count($articles) - 1);
+ $chosen_sidebox = $articles[$random_index];
}
-
echo '<!-- ';
print('Chosen sidebox is: ' . $chosen_sidebox);
echo '-->';
@@ -203,8 +219,6 @@ class AhabTemplate extends QuickTemplate {
$pcache->save($p_result, $articleObj, $popts);
}
- //print_r($p_result);
-
$rendered_text = $p_result->mText;
# evil evil hackery
$fixed_text = str_replace('class="mw-headline"', '', $rendered_text);
hooks/post-receive
--
"Ahab" skin for CC Learn (based on the work of White Whale)
More information about the cc-commits
mailing list