[cc-commits] [SCM] "Ahab" skin for CC Learn (based on the work of White Whale) (branch master) updated. 718cdf37d5c28fc907c88f16dfc7f6ea52a4eef4

git version control git at a7.creativecommons.org
Tue Apr 7 15:04:32 EDT 2009


The branch, master has been updated
       via  718cdf37d5c28fc907c88f16dfc7f6ea52a4eef4 (commit)
       via  b64f0b9fd884711e379d9d62e06139a3dbb893e5 (commit)
       via  439d563b7016e6975da78928a7cb56e45b4a8576 (commit)
       via  06ad182e874f308f9c418daf2f217ed5771debd6 (commit)
       via  c85882a514d0d4aae1129526685905f8a8c774f9 (commit)
       via  6b27ccc45b7ec3e84184a08617cf1baa7e237bfe (commit)
      from  b1374f070404fb83c2941a019f8a77814af42798 (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 718cdf37d5c28fc907c88f16dfc7f6ea52a4eef4
Author: Asheesh Laroia <asheesh at asheesh.org>
Date:   Tue Apr 7 12:04:11 2009 -0700

    Actually render and emit the sidebox we chose

commit b64f0b9fd884711e379d9d62e06139a3dbb893e5
Author: Asheesh Laroia <asheesh at asheesh.org>
Date:   Tue Apr 7 12:03:49 2009 -0700

    Always initialize chosen_sidebox

commit 439d563b7016e6975da78928a7cb56e45b4a8576
Author: Asheesh Laroia <asheesh at asheesh.org>
Date:   Tue Apr 7 11:21:09 2009 -0700

    use the FAQ sidebox as the "random" sidebox for now

commit 06ad182e874f308f9c418daf2f217ed5771debd6
Author: Asheesh Laroia <asheesh at asheesh.org>
Date:   Tue Apr 7 11:09:30 2009 -0700

    Add a comment with the name of the desired sidebox

commit c85882a514d0d4aae1129526685905f8a8c774f9
Author: Asheesh Laroia <asheesh at asheesh.org>
Date:   Mon Apr 6 18:06:33 2009 -0700

    Create a SMW Page in preparation for grabbing its properties

commit 6b27ccc45b7ec3e84184a08617cf1baa7e237bfe
Author: Asheesh Laroia <asheesh at asheesh.org>
Date:   Mon Apr 6 17:45:37 2009 -0700

    Detect landing page once, and store that

-----------------------------------------------------------------------

Summary of changes (followed by patch):
 ahab.php |   73 +++++++++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/ahab.php b/ahab.php
index 3b3be9e..d3eaee2 100644
--- a/ahab.php
+++ b/ahab.php
@@ -49,6 +49,43 @@ class AhabTemplate extends QuickTemplate {
 	function execute() {
 		global $wgRequest;
 		$this->skin = $skin = $this->data['skin'];
+
+		$chosen_sidebox = null;
+
+		/* Detect if we are in the landing page category */
+		$in_landing_page = (bool) (strpos($this->data['catlinks'], 'Landing_page'));
+		/* If we are, oh boy... */
+		if ($in_landing_page) {
+		  /* create a SMW Page */
+		  $smw_page = SMWWikiPageValue::makePageFromTitle($this->skin->mTitle);
+
+		  /* Create a Property for Preferred_sidebox */
+		  $property = SMWPropertyValue::makeUserProperty('Preferred sidebox');
+		  
+		  /* Gank the current SMW data store... */
+		  $store = &smwfGetStore();
+
+		  /* ...and ask it if this page has a sidebox preference. */
+		  $preferences = $store->getPropertyValues($smw_page, $property);
+
+		  /* if the count is >=1, grab the first one. */
+		  if (count($preferences) > 0) {
+		    $chosen_sidebox = $preferences[0]->getShortText(SMW_OUTPUT_HTML);
+		  }
+		}
+
+		if ($chosen_sidebox === null) {
+		    /* we ought to pick a random one */
+		    /* FIXME: Actually make this random */
+		    $chosen_sidebox = 'FAQ sidebox';
+		}
+		
+		
+		echo '<!-- ';
+		print('Chosen sidebox is: ' . $chosen_sidebox);
+		echo '-->';
+		  
+		  
 		$action = $wgRequest->getText( 'action' );
 
 		// Suppress warnings to prevent notices about missing indexes in $this->data
@@ -68,10 +105,7 @@ class AhabTemplate extends QuickTemplate {
 <?php
 /* This code sucks. Is there some other way to ask a page what categories it is in?
    I don't see it. */
-$categorylinks = $this->data['catlinks'];
-if (strpos($categorylinks, 'Landing_page') !== false) {
-    /* do nothing */
-} else { ?>
+    if (! $in_landing_page) { ?>
 			@import "<?php $this->text('stylepath') ?>/ahab/from_whitewhale/styles/opened_page.css?<?php echo $GLOBALS['wgStyleVersion'] ?>";
 <?php } ?>
 
@@ -152,10 +186,33 @@ if (strpos($categorylinks, 'Landing_page') !== false) {
 <!-- image panel -->
 
 			<div class="panel with_image">
-				<h2 class="purple">Projects</h2>
-				<img src="<?php $this->text('stylepath') ?>/ahab/from_whitewhale/images/homepage/strip/cambodia.jpg" alt="Faculty of a Cambodian public school" width="240" height="140"/>
-				<h3>Open Education in Cambodia</h3>
-				<p>Cambodia has become the first country in the world to teach only Free and Open Source application in its public schools. <a class="more_link" href="#">More &raquo;</a></p>
+			    <?php echo "<!-- I want to use $chosen_sidebox ";
+		$title = Title::newFromText($chosen_sidebox);
+		print_r($title);
+		global $wgParser;
+		global $wgUser;
+		$wgParser->startExternalParse( $title, new ParserOptions(), OT_HTML);
+		$articleObj = new Article($title);
+		// Try the parser cache first
+		$pcache = ParserCache::singleton();
+		$p_result = $pcache->get($articleObj, $wgUser);
+		if(!$p_result)
+		  {
+		    $p_result = $wgParser->parse($articleObj->getContent(), $titleObj, $popts);
+		    global $wgUseParserCache;
+		    if($wgUseParserCache)
+		      $pcache->save($p_result, $articleObj, $popts);
+		  }
+
+		//print_r($p_result);
+		echo '-->';
+
+		$rendered_text = $p_result->mText;
+		# evil evil hackery
+		$fixed_text = str_replace('class="mw-headline"', '', $rendered_text);
+		print($fixed_text);
+ ?>
+
 			</div> <!-- end image panel -->
 
 <?php $this->copyleft(); ?>


hooks/post-receive
-- 
"Ahab" skin for CC Learn (based on the work of White Whale)



More information about the cc-commits mailing list