BBCodetoHTML Plugin Channel

From AwasuWiki
Revision as of 21:33, 11 March 2007 by DiabloNL (talk | contribs) (Installation)
Jump to: navigation, search


  • Install Python
  • Create the two files listed below. It is recommended to put them into the `ChannelPlugins` directory under Awasu's installation directory.


AuthorName=Bobby van Dam
PluginNotes=This plug-in strips BB-Code from a RSS feed and tries to replace it so the content is shown in the correct way. Please understand that I'm no coding guru and this plugin was made and tested on one web site for my own use.

' --------------------------------------------------------------------------------

Name=Feed URL
Description=The URL of the feed to be stripped from it's BB-Code. -- Channel plug-in to strip BB-Code from a RSS feed and convert it to HTML
#2007 by Bobby van Dam
#Thanks to Allan B. Wilson who's ChannelFeedEncoding script helped me a lot with making this one
#This script works for the website I created it for. I can't guarantee that it will work for you.
#You are free to change it so it will work better for you. Or maybe you will get some ideas from
#this script to make your own. ^_^

import urllib, os, win32api, sys

progpath = os.path.abspath(os.path.dirname(sys.argv[0]))

feedurl = win32api.GetProfileVal("ChannelParameters", "Feed URL", "", os.path.join(progpath,sys.argv[1]))


	input = urllib.urlopen(feedurl)
	data =\
	  .replace("&lt;object","<a href='").replace("&lt;/object&gt;","'></a>")\
	  .replace("[img]","<br/><br/><img src='").replace("[/img]","'align='center'><br/><br/>")\
	  .replace("&lt;embed","<a href='").replace("&lt;/embed&gt;","'></a>")\
	  .replace("[email=","<a href='mailto:").replace("[/email**","</a>")\
	  .replace("**","'>").replace("[url=","<a href='") 
except IOError:
	print >>sys.stderr, "? Could not open URL: %s" % feedurl

print data


To use the BBCode plugin, select File -> New channel, then "Generated by a channel plugin", and browse to the file. Add the feed URL in the plugin's URL parameter, and you're done.

It will turn this:


Into this: