Pubwich 1.0

  1. Required components
  2. Installation
  3. Services configuration
  4. Theme configuration

1. Required components

The following components must be installed so Pubwich can work:


2. Installation

  1. Duplicate cfg/config.sample.php to cfg/config.php

    (optional: if you want to use a custom theme, duplicate themes/default to themes/your_theme_name and edit the PUBWICH_THEME constant in cfg/config.php to "your_theme_name".

  2. Edit the newly created config.php to fill the blank spaces with your informations (API keys, usernames, site’s URL, etc.) and to modify the arguments passed to Pubwich::setServices(). See the Services configuration section of this file.

  3. Modify your crontab file (by running crontab -e) and add the following line:

    */<N> * * * * <PHP> -f <ABSOLUTE_PATH>/cron/cron.php

    Then replace the following elements:

    <N>Cache expiration (in minutes)
    <PHP>The path to PHP executable binary (usually /usr/bin/php or /usr/local/bin/php, use which php to find it)
    <ABSOLUTE_PATH>Absolute path to Pubwich directory

    Example:

    */10 * * * * /usr/bin/php -f /home/myusername/public_html/pubwich/trunk/cron/cron.php

  4. Change the permissions on the cache directory to make it writeable for all ($ chmod -R 0777 cache).

  5. Everything should be working now (when browsing to the index.php!).


3. Services configuration

The Pubwich object has a setServices method which take an array as its only parameter. Each element of this array is a column (defined by an array). Each column element is a service box (see the cfg/config.sample.php file for more examples). The order of the boxes within the column array will be the same order used for the template. To configure a box, you must use the following syntax:

array( <service>, <variable>, <config> )

Where:

<service>the service name ('Flickr', 'Twitter', etc.)
<variable>the box’s unique name ('photos', 'statues', etc.)
<config>an array of configuration elements

Common configuration elements

These elements can be used in any box configuration:

titleThe box’s main title
descriptionThe box’s short description (usually dsplayed near the title)
totalTotal of elements to show for this box

Atom service configuration elements

urlAtom feed URL
linkMain website URL

Delicious service configuration elements

usernameYour username

Facebook service configuration elements

To find some informations, you will have to go to the following page, and extract the &id and &key query variables from the "Your alerts" link.

idYour user id
keyYour personal API key
usernameYour username

Flickr service configuration elements

keyYour API key
useridYour user id (you will have to use http://idgettr.com to find it easily)
usernameYour username
rowThe number of photos by row. Pubwich will add the class derniere to each end-of-row photo.

Lastfm service configuration elements

keyYour API key (get an API key)
usernameYour username
sizeThe width of the album covers

Readernaut service configuration elements

usernameYour username
sizeThe width of the book covers

RSS service configuration elements

urlThe feed URL
linkThe website URL

Text service configuration elements

textThe text to put in the box

Twitter service configuration elements

idYour user id
usernameYour username

Vimeo service configuration elements

usernameYour username

Youtube service configuration elements

usernameYour username
sizeThe width of the video thumbnails

4. Theme configuration

A theme can be customized by using the functions.php file in the theme folder.

Item template

Each service has a default item template. For example, the default item template for Twitter is this:

<li class="clearfix"><span class="date"><a href="{%link%}">{%date%}</a></span>{%text%}</li>

However, it is possible to modify each service's item template, or even for a single instance of a service. To do so, you must edit the functions.php file and add the following function (and replacing Service by the actual service name):

function Service_itemTemplate() {
	return '<li><a href="{%link%}">{%title%}</a></li>';
}

To only modify the item template of a particular service instance, you must add the following line (and replacing Service by the service name, and variable by the variable name defined in your configuration file)

function Service_variable_itemTemplate() {
	return '<li><a href="{%link%}">{%title%}</a></li>';
}

The tags ({%link%}, {%title%}, etc.) are different for each service. To get a list of available tags for a service, you must open the service file (in lib/Services/) and look for the populateItemTemplate method

Box template

Each theme must specify a default box template. The default theme's one is this:

<div class="boite {%class%}" id="{%id%}">
	<h2><a rel="me" href="{%url%}">{%title%}</a> <span>{%description%}</span></h2>
	<div class="boite-inner">
		<ul class="clearfix">
			{%items%}
		</ul>
	</div>
</div>

You can modify this function in the theme’s functions.php file.

It is also possible to modify a service box template with a function like this: (by replacing Service with the service name)

function Service_boxTemplate() {
	return '<div class="boite {%class%}" id="{%id%}">
			<h2><a rel="me" href="{%url%}">{%title%}</a> <span>{%description%}</span></h2>
			<div class="boite-inner">
				<ul class="clearfix">
					{%items%}
				</ul>
			</div>
		</div>';
}

To modify the box template of a particular service instance, you can use the same method as the item templates.

Available box template tags

classThe box class HTML attribute
idThe box title HTML attribute
urlThe service profile URL (eg. http://www.twitter.com/remi/)
titleThe box title, as defined in the configuration file
descriptionThe box description, defined in the configuration file
itemsThe items HTML code generated by Pubwich

The tags must be used with this syntax: {%tag%}