"Nobility is a graceful ornament to the civil order. It is the Corinthian capital of polished society." - Edmund Burke

Table of Contents [Hide/Show]


   Download
   Overview
   Installation
      Worker thread recycling
   Usage
   Example


Edit

Download

QuoteDB.zip

Full source is included in this file as well as the compiled dll. Source is released to the public domain and may be used in any way you like. No support is offered or implied.

Edit

Overview

At first, I tried to pull in the javascript from this page: http://www.quotedb.com/random_quotes_generator. The problem I found was that it caused a noticeable delay in the drawing of the page as it went out to the QuoteDb site to get the quote each time.

This plugin runs a single background thread that downloads and caches random quotes from one of 2 sites. The URL's it supports are the random quote RSS url from one of these two pages:

http://www.quotedb.com/random_quotes_generator
http://www.quoteworld.org/add_quotes2your_site

The RSS url's available on these sites can include parameters that allow you to limit the quotes to certain categories or authors. Since the xml returned is the same either way, this plugin will support any of those alternate URL's. Just generate the one you like using one of the pages above and enter it into your configuration string.

It's possible there are other quote sites that could be supported; if you would like me to look at one, send me an email at codenotes@oudknoei.net and, if I have the time, I'll take a look at whether it's similar enough to add support for it.

This is a phase 3 plugin, so it will return a new value each time the a page is refreshed.

Edit

Installation

Upload the QuoteDB.dll file to your plugin directory.

There are a couple of configuration options available. To use those, select the RandomQuote plugin from the list and select Configure. Enter each configuration item on a separate line:

url=http://www.quoteworld.org/quote/quote.php?action=random_quote_rss
exclude=Mark Twain;Frank Luntz

The default url is the one from quoteworld.org. The default exclude list is a blank list.

Once it's installed, the background thread will begin downloading quotes. During the first 10 quotes, it will download them once every 2 minutes. After that, the delay between downloads will steadily increase (up to 1 hour between downloads). The maximum number of quotes it will hold in memory is 100. The reason for this design was to limit the number of downloads from the quote site. If your wiki gets 2 users a month or 1000 a day, the number of downloads from the quote site will remain the same.

Each time a new quote is downloaded, the in-memory list will be saved to Public/Plugins/Quotedb.xml so it can be reloaded when the plugin is restarted. Each attempted to download a quote is logged in the wiki log. If you wish to delete this file and start fresh, first stop the wiki web site and then delete this file. Otherwise, it will just replace it the next time a quote is downloaded.

Edit

Worker thread recycling

One caveat: IIS loves to recycle idle worker threads. When that happens, the background thread will be aborted. This doesn't cause any harm, but it does stop the plugin from getting new quotes until someone views another page. Basically, on active web sites, it will do what I documented above. On lower systems, it will collect fresh quotes a lot less frequency.

Edit

Usage

To use this, put the {RandomQuote} tag in a page or in the header/footer. It will select one of the quotes in the cache and display it. The format of the returned quote will be "Quote - Author" and the author will be linked to the quoteworld.org page for that author. Other than the <a> tag used to link to the author page, there are no other html or wiki tags returned by this plugin. Feel free to surround your instance of the tag with italics or other formatting tags.

Edit

Example

"A thankful heart is not only the greatest virtue, but the parent of all other virtues." - Marcus Tullius Cicero

ScrewTurn Wiki version 2.0.33. Current Page Count: 23. Some of the icons created by FamFamFam.