Category Archives: Chisimba

How to add a Google +1 button to your Chisimba site

Reposted from old site – original date: Thursday 2 June 2011

There is nothing much to adding a +1 button to your Chisimba site. If you would like to add the button to individual articles on, say, your Chisimba blog,
then please read the docs at http://code.google.com/apis/+1button/ especially taking note of the URL section. Again, nothing too strenuous.

Basically you need two things. A piece of Javascript in either the head section of your page template, or else the same JS just before the closing body tag. I prefer the closing body tag as then the js loads from Google last and doesn’t interfere too much with your content loading.

Anyway, the line to add is:

<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>

(Skipping the spaces between the angle braces)

Then you simply need to add:

<g:plusone></g:plusone>

somewhere strategic that you want the button to render.

Very easy.

VLIR Mozambique mission

Reposted from old site – original date: Monday 28 March 2011

I have recently returned from Mozambique where I participated in a VLIR sponsored workshop about eLearning and Chisimba. The workshop was a culmination of the VLIR NSS project (North-South-South) between VUB (Brussels), UoN (Kenya) and UWC (South Africa). The NSS project was a 2 year project started to create a repository of resources for educators to use in eLearning. There are some specific docs available in the repository centred around Chisimba, but mostly they are purpose built documents on educational theory and best practice in eLearning.

The repository itself can be used as any other subversion repository at http://trac.uwc.ac.za/trac/VLIR

The first days of the workshop were spent on planning and finalising the budgets of the project. That left us with an intense 3 days of actual workshop with approximately 20 delegates from various faculties from the University of Eduardo Mondlane (UEM) including ditance learning, education and computer science.

The delegates were happy with the course materials and repository and even managed to produce some updated versions of some of the repoitory documents during the course of the three days!

A big thank you to Francisco Mabila and UEM for being a most gracious host!

Photographs are available at http://www.flickr.com/photos/paulscott56/sets/72157602346136749/

HOWTO set up and install a Sphinx Search system on top of a Chisimba database

Reposted from old site – original date: Saturday 14 August 2010

Sphinx is a full-text search engine, distributed under GPL version 2. It is not only fast in searching but it is also fast in indexing your data. Currently, Sphinx API has binding in PHP, Python, Perl, Ruby and Java.

Recently, in order to improve search times and results in the Chisimba framework (http://www.chisimba.com) I had a look at the Sphinx Search code (http://www.sphinxsearch.com).

This is a quick HOWTO to get Sphinx search up and running on your Ubuntu system to take advantage of the remarkably fast and easy to use search capabilities of Sphinx.

NOTE: The Ubuntu packages for Lucid Lynx are not great IMO. It is actually easier to compile from source.

I installed everything in /opt but you are more than welcome to install it wherever makes sense to you.

1. Download Sphinx from sphinxsearch.com. For this tutorial I sed the latest version (1.10-beta)

wget http://www.sphinxsearch.com/downloads/sphinx-1.10-beta.tar.gz

Note that the “beta” bit does not refer to the stability of the overall package, just the new features, so this is a pretty safe bet.

2. Open up a terminal and extract Sphinx:

tar -xvf sphinx-1.10-beta.tar.gz

3. Sphinx needs the MySQL client headers to build against if you are going to be indexing MySQL databases (or PostgreSQL)

sudo aptitude install libmysqlclient15-dev

4. Install Sphinx:

cd /opt/sphinx-1.10-beta/
./configure --with-mysql --with-pgsql
make
make install

Note: the above assumes you are building for both MySQL and for PGSQL!

5. Test your installation!

search
Sphinx 1.10-beta (r2420)
Copyright (c) 2001-2010, Andrew Aksyonoff
Copyright (c) 2008-2010, Sphinx Technologies Inc (http://sphinxsearch.com)

Usage: search [OPTIONS] <word1 [word2 [word3 [...]>

Options are:
-c, --config <file>	use given config file instead of defaults
-i, --index <index>	search given index only (default: all indexes)
-a, --any		match any query word (default: match all words)
-b, --boolean		match in boolean mode
-p, --phrase		match exact phrase
-e, --extended		match in extended mode
-f, --filter <attr> <v>	only match if attribute attr value is v
-s, --sortby <CLAUSE>	sort matches by 'CLAUSE' in sort_extended mode
-S, --sortexpr <EXPR>	sort matches by 'EXPR' DESC in sort_expr mode
-o, --offset <offset>	print matches starting from this offset (default: 0)
-l, --limit <count>	print this many matches (default: 20)
-q, --noinfo		don't print document info from SQL database
-g, --group <attr>	group by attribute named attr
-gs,--groupsort <expr>	sort groups by <expr>
--sort=date		sort by date, descending
--rsort=date		sort by date, ascending
--sort=ts		sort by time segments
--stdin			read query from stdin

This program (CLI search) is for testing and debugging purposes only;
it is NOT intended for production use.

If you get the above, you are in business!

OK so you have Sphinx up and running. The next step is to get some data from your database to populate the index with.

As an aside, Sphinx installs 4 programmes to your environment which work off of a sphinx.conf file. Let us create a very basic conf file to work from in your sphinx-1.10-beta directory create a file called sphinx.conf:

source tweetgator
{
    type            = mysql
    sql_host        = localhost
    sql_user        = root
    sql_pass        = s3cr3t
    sql_db          = tweetgator
    sql_port        = 3306# optional, default is 3306
    sql_query       = SELECT puid, tweet, tstamp, screen_name, name, location, id from tbl_twitterizer
    sql_query_info  = SELECT * FROM tbl_twitterizer WHERE puid=$id
}

index tweet
{
    source          = tweetgator
    path            = data/tweetgator
    docinfo         = extern
    charset_type    = sbcs
}

indexer
{
    mem_limit       = 64M
}

searchd
{
    port            = 3312
    log             = log/searchd.log
    query_log       = log/query.log
    read_timeout    = 5
    max_children    = 30
    pid_file        = log/searchd.pid
    max_matches     = 1000
}

From the above, you can see that we are indexing the “Tweetgator” module running on our existing Chisimba database. Save that file and exit your editor.

Next up, we need to create some directories to hold our index data and log files:

mkdir log
mkdir data

We then run the indexer to go and grab all the data:

indexer --all

This will produce some informative output to tell you how many records have been indexed etc.

Sphinx 1.10-beta (r2420)
Copyright (c) 2001-2010, Andrew Aksyonoff
Copyright (c) 2008-2010, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file './sphinx.conf'...
indexing index 'tweet'...
collected 8673424 docs, 1405.1 MB
sorted 176.3 Mhits, 100.0% done
total 8673424 docs, 1405117673 bytes
total 168.080 sec, 8359780 bytes/sec, 51602.73 docs/sec
total 445 reads, 6.806 sec, 1979.5 kb/call avg, 15.2 msec/call avg
total 1741 writes, 3.157 sec, 1014.4 kb/call avg, 1.8 msec/call avg

The above will obviously be different according to the size of your tweetgator table!

You can now use the built in search program to go and query your spanking new index! Go on, give it a try!

I know that my tweetgator table has a bunch of World Cup references in it, so I tried:

search vuvuzela

and got back a bunch of results.

You are now ready to move onto the next step which I will outline later (installing and configuring the Chisimba Sphinx module)

Yesterday I conducted the Chisimba training at the Kofi Anan Centre of ICT excellence in Accra, Ghana

Reposted from old site – original date: Friday 14 May 2010.

There was an excellent turnout of delegates, with a full room of 30 people attending. We were forced to turn a few people away due to space requirements.

I decided to keep the training session as agile as possible, although the session was branded as coding and deploying Chisimba applications. It turned out that most delegates were interested in looking at eLearning as well as content managemant. It was for this reason that we started with eLearning, and then took a look at setting up and customizing the CMS module as well as the news module (the module running this site is the news module).

There were some interesting questions at the beginning in the form of “Drupal does x, can Chisimba do the same?”, but towards the end of the session those had changed to “Why doesn’t Drupal/Joomla! also do this? Chisimba is way more powerful!”

All in all it was a very successful day and it was enjoyed by all. Everything from installation to final deployment and customization was covered in a single intensive day (next time, I am sure that someone will remind me to break for lunch!)

Towards the end of the day, I was interviewed by Ghana National television as well on AVOIR and Chisimba, as well as the work that we are doing in Africa for the world.

Retweet button for the Chisimba blog

Reposted from old site – original date: Monday 12 April 2010

Yesterday, I was asked to do a quick retweet button for the Chisimba blog module. I thought that it should be relatively easy to do, and wanted the following characteristics:

1. It should increment the retweet number in an AJAXy style, so as not to reload the page
2. It should be configurable in style to match skins.
3. It should include an icon due to the multilingual capabilities of Chisimba, where the concept of “retweet” may be difficult to understand

So, I opened up a browser and did a quick search and came up with http://ejohn.org/

There is a great example there that did everything that I wanted. Within about 20 minutes, the blog had fully configurable retweet functionality. For those using the Chisimba blog, please take note of the new config options (found in sysconfig – blog):

1. Retweet_style – which is the style that you would like your retweet
button to look like. Valid styles are retweet and retweet vert. Retweet
makes a horizontal button with the number of retweets to the left of the
button, while retweet vert will make a vertical style button with the
number of retweets above the button.

2. Retweet_Status – this is the status that is automatically added to
your retweets. Can be anything as long as the URL + Status is less than
140 chars. Nice ones are along the lines of “Interesting read” and
“Check out this post” etc.

AVOIR and Chisimba in Cuba

Reposted from old site – original date: Tuesday 16 February 2010

AVOIR was recently invited to Universidad 2010 in Havana Cuba through the VLIR sponsored North South South project that was established between VUB (Vrije Universiteit Brussels), UWC (University of the Western Cape) and UoN (University of Nairobi). Elijah Omwenga respresented UoN and I attended as the UWC delegate. Georges Eisendrath was representing both VLIR and VUB at the conference.

The first day of the conference (after a very long trip!) was spent on a VLIR partners workshop. This was to enable all the VLIR sponsored projects in Latin America and elsewhere to meet each other and form possible connections and further collaborations. Each institution was given a short presentation slot to let everybody know what they were doing in this space. Elijah Omwenga presented the UWC/UoN/VUB NSS project and the Chisimba based repository system that the project entails, while I was given an opportunity to present AVOIR as a network for collaboration in Africa and beyond. Both presentations were very well received and much interest was sparked in AVOIR and what we do. We also were interesting in the fact that AVOIR could easily be used as a model in other places and a global network should be established, building on to what AVOIR has already achieved in Africa.

I was then given the opportunity on the Wednesday to present, with Frederick Questier from the VUB, an hour long workshop on Free and Open Source Software.

Many network collaborations were established and a number of new opportunities were created! Chisimba and AVOIR is now set to become a major player in Southeast Asia as well as some parts of Latin America.

Many thanks to VLIR, Georges Eisendrath and many others for this opportunity!

Images will be posted later to the AVOIR photo pool on Flickr

Collecta Widget in Chisimba

Reposted from old site – original date: Tuesday 26 January 2010

I saw from a tweet in the past 20 minutes that Collecta (http://www.collecta.com) has released a quick widget builder to get realtime results in pages. I decided that this was such a good idea that I would make a quick Chisimba filter to use the functionality so that any user could add any custom Collecta widget whenever they needed to. Think also of the eLearning implications here!

Anyway, to use the widget (I guess it is a widgetWidget) use the following syntax after updating the filters module:

[ COLLECTAWIDGET: term=searchterm,title=title_for_your_widget, width=width_in_px,height=height_in_px ]

[b](Remember to delete the spaces in the square brackets)[/b]

So a real example would be:

[ COLLECTAWIDGET: term=Chisimba,title=Chisimba,width=300,height=500 ]

Which renders like:


Enjoy!

The Chisimba blog

Reposted from old site – original date: Monday 4 January 2010

Having a somewhat anecdotal look at the download graphs from the Chisimba package servers, I see that the blog module is probably the most popular module of all. It is certainly one of the most downloaded and used modules, outside of UWC’s eLearning set up (where it is used too).

This, to me is somewhat interesting for the following reasons:

1. Blog was one of the first Chisimba modules that I wrote, right after releasing the basic Chisimba framework. This makes it one of the oldest still working and in use modules in the system

2. Blog has been hacked upon by almost everyone that has written a Chisimba module, therefore becoming one of the most “community oriented” modules in the system. Most of the senior develelopers have had a hand in some aspect of blog, as well as a number of junior devs, interns and other folks just interested in the way that things work. (This has created a little bit of code bloat, which will be factored out ASAP though)

3. Popularity of blog always surprises me, with the ubiquity of blogging platforms such as WordPress, LiveJournal and Blogger (both hosted and self hosted). I think that the difference is that the Chisimba blog makes use of interop filters that work with WordPress et al. as well as providing much content and an open API to interact further with all the platforms. Chisimba blog also has many more features than the others although not many people make full use of them all.

With the above in mind, what can we do to make things better? How can we make the Chisimba blog even better and more popular?

Some example of Chisimba blogs:

http://www.dkeats.com/

http://www.cazpix.co.za/

http://eteaching.uwc.ac.za/ (UWC eLearning)

and many more…

How to use the Activity Streamer module

Reposted from old site – original date: Thursday 24 December 2009

The activity streamer module allows for certain events to be recorded by the system in the background and then re-mixed into other forms and formats further upstream. This may mean that the activities are streamed to services such as Twitter or Facebook, or it could simply mean adding the activities to a database table for later analysis.

To use the Activity streamer, most of your code will reside in your module’s controller, as this is where your control functions exist within Chisimba.

The best way to demonstrate this will be to outline a basic example:

The first order of business is to get and instantiate the activity streamer module classes if the module is installed or exists:

if($this->objModuleCat->checkIfRegistered('activitystreamer'))
{
     $this->objActStream = $this-getObject('activityops','activitystreamer');
     $this->eventDispatcher->addObserver(array($this-objActStream, 'postmade' ));
     $this->eventsEnabled = TRUE;
 } else {
     $this->eventsEnabled = FALSE;
 } 

$this->eventsEnabled is simply a property to hold whether or not we will be using the streamer later on in the code, instead of re-doing the check. You will also notice that we have added an observer too to the event Dispatcher. This is a framework object, but it takes a callback function that you will set up. The postmade() function that has been set as the callback above, simply adds the data as an array to the global activitystreamer data table. You are free to override this, of course, but it is preferred that all data is also sent to the global data table for posterity. The next step is to actually update the activity streamer in your code. In a controller action, you need to add a few variables that must exist for a meaningful data entry:

// update the activity streamer
$title = $this->objLanguage-languageText("mod_events_newconnection", "events");
$link = $this->uri(array('action' = '#'));
$contextCode = NULL;
$author = $this-objUser->fullName($myid);
$message = $author." ".$this->objLanguage->languageText("mod_events_isnowfriendswith", "events")." ".$this-objUser->fullName($fid);

The above code was taken from the “events” module when a person adds another as a friend in the social network portion of the code. You will notice that there is a title to the activity, a link back to it, a context code (not used in this case), an author and a message. These are all required for a successful data entry. The next step is to actually create the entry via our controller code. To accomplish this, we use the event dispatcher’s post method:

$this-eventDispatcher->post($this-objActStream, 'events', array('title' = $title, 'link' = $link, 'contextcode' = $contextCode, 'author' = $author, 'description' = $message)); 

That will then create the entry and you can then carry on with life. Remember, that every time this event is fired, a data entry will be produced, so please ensure that you code for error conditions and fringe cases too (such as a user is logged out just before the activity is completed etc).