We'll present a quick example of how to write a plugin to demonstrate just how simple it is. Plugins can be written in any language you choose but we'll use Python here since it's easy to understand what's happening, even if you don't know the language.
A channel plugin is simply a script or program that Awasu will run when it's time to update a channel. All the plugin has to do is print out the RSS feed to the console, so a very basic plugin might look like this:
print "<RSS>" print "<CHANNEL>" print "<TITLE> My Sample Plugin </TITLE>" print "<ITEM>" print " <TITLE> Item 1 </TITLE>" print " <DESCRIPTION> Description for item 1. </DESCRIPTION>" print "</ITEM>" print "<ITEM>" print " <TITLE> Item 2 </TITLE>" print " <DESCRIPTION> Description for item 2. </DESCRIPTION>" print "</ITEM>" print "<ITEM>" print " <TITLE> Item 3 </TITLE>" print " <DESCRIPTION> Description for item 3. </DESCRIPTION>" print "</ITEM>" print "</CHANNEL>" print "</RSS>"
That's it! When Awasu runs this plugin, it will collect the output the script produces and process it as an RSS feed. In this example, there will be three items in the feed and so this is what the user will see:
# print the RSS feed header
print "<RSS>"
print "<CHANNEL>"
print "<TITLE> Sales Data </TITLE>"
# connect to the database
connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=SalesData.mdb;"
conn = adodbapi.connect( connString )
# execute a query
cursor = conn.cursor()
cursor.execute( "SELECT * FROM tblCustomerSales" )
rows = cursor.fetchall()
# print out each row as an RSS feed item
for row in rows :
id = row[0]
customerName = row[1]
itemName = row[2]
itemCount = row[3]
amount = row[4]
comments = row[5]
print "<ITEM>"
print " <LINK>http://intranet/sales/" + id + "</LINK>"
print " <TITLE>" + customerName + " - " + itemName + "</TITLE>"
print " <DESCRIPTION>" + itemCount + " x " + itemName + " $" + amount + " " + comments + "</DESCRIPTION>"
print "</ITEM>"
# print the RSS feed footer
print "</CHANNEL>"
print "</RSS>"
Now, when this channel is updated, it will return whatever happens to be in the database at the time. And when the information in the database is updated, Awasu will notify you of the changes!
These are some very simple examples of what Awasu plugins can do for you. Application plugins can also be written that extend the functionality of Awasu itself. More information and samples are provided in the documentation.