Check out my
new book!
HTML5 Games book
Wiki Summary Box 0.1.2 update A few updates to the Wiki Summary Box.

The first change is that it now uses the proper Mediawiki API to retrieve the article text instead of relying on the AppJet gateway. Of course now the user's browser has to download and parse the entire article text instead of just getting the small summary bit, but this way still feels a lot better.


Second, there is now a list of Wiki sources that the script checks against, making it more a general Wiki box rather than something tied to Wikipedia. Any links that match this list will get the summary box. Sources supported out of the box include Wikipedia, Wikiquote, Wikispecies, Wikinews, Wikisource, Wikibooks, Wiktionary and Wikiversity. It's relatively easy to add more sources, just be sure that the Wiki is a Mediawiki and that the API is available. There is more info in the JavaScript file about this. And do note that if the Wiki is very different from Wikipedia, the script might not be able to extract anything and/or look odd. The Wiki text can of course be styled with CSS like anything else, but you'll have to find the class names / element id's yourself. This has already been done to hide some elements from Wiktionary and Wikispecies.

If you know of any other Wikis that would be interesting to add, please leave a comment!

An 'loading' indicator has been added. As it is now, it's just a simple text that says "Loading..." but it's easily changed and styled in the CSS file if that's not good enough.

I've also added a small delay before showing and hiding the box, default is 200 and 300 ms, respectively. You can find these at the very top of the script if you want to alter them.

Also, I had to make an ugly workaround to deal with IE's inability to handle relative paths in the href attribute on links. I hope I can find a better way..

Test links:

Wikiquote test: Albert Einstein
Wikinews test: Scientology vs. Anonymous
Wikisource test: Obama saves the day
Wikispecies test: Tyrannosaurus rex, Eukaryota
Wiktionary test: consequently
Wikiversity test: Quantum mechanics study guide
Wikibooks test: Linear algebra

Thanks for the feedback in the earlier post!

Current version: 0.1.2
Files: sumbox.js and sumbox.css

⇓ 7 comments Beben Koben

its not work in blog bro ? hiks ... ?

January 18, 2010 at 1:48 PM
Beben Koben

its woooooooooooooooooorkkkkk...
by the way, with the css can't put eksternal link must add in html css ... aw aw aw
thanks....

January 19, 2010 at 3:33 AM
Unknown

Nice work ! I'm actually trying to write the same thing in PHP but I dont see how you manage to have only the summary.
I was not able to find a rule to extract only the summary.
Could you give me some pointers ?

April 14, 2010 at 3:27 AM
Jacob Seidelin

@djpate: It actually just assumes that the first section (up until the second header) is a summary. So it just takes everything until it meets a H1 or H2 tag and uses that content.

April 14, 2010 at 6:17 AM
Unknown

Is this script inactive, or does it only work in IE? I do not get any reaction from the links....

May 17, 2011 at 11:53 AM
pixar

doesn't work

March 10, 2012 at 2:34 AM
J

Its not working

August 18, 2012 at 5:07 AM
Post a Comment