Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2004-11-24 23:56:47

Remillard
Plugin Author
From: Lenexa, KS
Registered: 2004-05-16
Posts: 169

[plugin] [ORPHAN] mdn_wikitoday

Well as if web pages weren’t busy enough already. Compooter suggested several threads ago that it might not be too hard to parse the HTML page from Wikipedia (which is what I had asked if it were possible). So, I decided to take it up myself as a little challenge to see if I could do it.

He was right. It was surprisingly easy.

So, here for general consumption and breakage is mdn_wikitoday. This plugin will pull several line item historical events from the Wikipedia for the day in question and display them. It also includes a link to the day in the Wikipedia. It also converts all the relative links to absolute links, so the wiki links will go to the right page. (God help me, I just love <code>str_replace()</code>)

==<code>
Usage:
<txp:mdn_wikitoday [limit=”“] [style=”“] />

Both parameters are optional. Limit defaults to 5. Style is applied to a div block that surrounds the text. Applicable elements inside to define are h3, ul, li, and a.
</code>==

Version: 1.0
Download: mdn_wikitoday.txt

There you have it.

One caveat, it’s not terribly internationalized (read: not internationalized at all). This basically works for the english version of Wikipedia only right now. I’m open to expanding it, I simply don’t know much about unicode characters for URLs.

Regards,
Remillard

Last edited by Remillard (2004-11-25 00:02:39)

Offline

#2 2004-11-25 00:26:34

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: [plugin] [ORPHAN] mdn_wikitoday

Man, you’re on a roll. Getting out much lately? ;-)

Offline

#3 2004-11-25 00:29:28

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: [plugin] [ORPHAN] mdn_wikitoday

So this version doesn’t cache, correct? Have you thought about an optional version using Cache_Lite? It’s an incredibly easy & useful Pear package. Im just thinking that this might create a lot of requests from wikipedia’s servers if you get lots of traffic on your site.

Offline

#4 2004-11-25 00:43:29

Remillard
Plugin Author
From: Lenexa, KS
Registered: 2004-05-16
Posts: 169

Re: [plugin] [ORPHAN] mdn_wikitoday

Yep, it doesn’t cache. I tried to get that bit working but I had an argument with file_put_somethingortheother() and we broke it off and decided to see other functions.

I’m not sure what a Pear package is, but I’ll go looking for it. Only computer Pear I know is Pear PC (Mac emulator).

Basically I strip out the Events part of the page, and then pop in delimiters at every <li> and explode it into an array. What I wanted to do was write it out to a file at this point. Then (theoretically) it would be very fast to just read the file, and do the little random action thing and whack it into the page. (As well as ease the load on Wikipedia.)

Maybe it’s a good project for the weekend… the Pear PHP thing. Thanks!

Last edited by Remillard (2004-11-25 00:43:45)

Offline

#5 2004-11-25 00:48:14

Andrew
Plugin Author
Registered: 2004-02-23
Posts: 730

Re: [plugin] [ORPHAN] mdn_wikitoday

Cache_Lite is a fairly common package to be installed with PHP. The quickest example of code I could give you off the top of my head would be Hivelogic’s hurricane parser (source code). It might give you some other ideas, too.

Offline

#6 2004-11-25 00:54:19

Remillard
Plugin Author
From: Lenexa, KS
Registered: 2004-05-16
Posts: 169

Re: [plugin] [ORPHAN] mdn_wikitoday

Yeah, I just looked at it, and then sifted through the server’s php.ini file. It doesn’t appear to be installed.

Frankly I just need to get the file things working. This isn’t nearly as complicated as what Cache-lite is doing (though if it did work, it would be SO easy to manage it.)

Offline

#7 2006-06-17 02:03:59

mhulse
Plugin Author
From: Eugene Oregon
Registered: 2005-01-21
Posts: 200

Re: [plugin] [ORPHAN] mdn_wikitoday

Just a note… after installing this plugin it really slowed-down my site. Other than that, great plugin! Nice to have in a footer or something for a news site.

Maybe something like this would work best in conjunction with a daily cron job and a flat-file…

Offline

#8 2006-06-20 17:15:15

Remillard
Plugin Author
From: Lenexa, KS
Registered: 2004-05-16
Posts: 169

Re: [plugin] [ORPHAN] mdn_wikitoday

Yes, this one never really got out of beta testing. I always intended to implement some cacheing so that the slowdown would only happen on the first transfer of the day, but never got to it. I’m kind of glad someone found this useful. I actually shocked too that it still works (i.e. nothing in Textpattern or Wikipedia changed substantially to make it break.) It’s not terribly robust as I recall. It depends a lot on the format of the “Today’s Events” page on Wikipedia.)

Last edited by Remillard (2006-06-20 17:17:57)

Offline

#9 2006-06-20 21:36:48

mhulse
Plugin Author
From: Eugene Oregon
Registered: 2005-01-21
Posts: 200

Re: [plugin] [ORPHAN] mdn_wikitoday

Yeah, still works… I like it a lot actually. Fits-in on the site I am working on very well. :)

I am sure it is faster some days/times… depends on Wikipedia possibly? I know what you mean though, I have wrote a couple of PHP scripts that pulled specific content from a site that had horrible coding… I just wanted some links… it kinda worked, but in the end I just grabbed the links manually.

Have you done other plugins?

Thanks for sharing btw! :)
Cheers,
Micky

Last edited by mhulse (2006-06-20 21:45:39)

Offline

#10 2006-06-20 22:23:30

Remillard
Plugin Author
From: Lenexa, KS
Registered: 2004-05-16
Posts: 169

Re: [plugin] [ORPHAN] mdn_wikitoday

I’ve done a few, though anymore I think many are standard equipment in Textpattern (things like if_section and conditionals with else). There used to be a post around here called Central Plugin something-or-the-other and it had a list of everything I’d done, good, bad, and indifferent.

Very glad you’re enjoying it.

Offline

#11 2008-03-10 09:55:29

Ruhh
Member
From: dakota dunes
Registered: 2008-01-20
Posts: 305

Re: [plugin] [ORPHAN] mdn_wikitoday

Is there a way this plugin can be modified according to the article’s date? So if my article was posted say February 14, the link would go to Wiki page according to February 14.


<txp:Ruhh />

Offline

#12 2008-03-10 16:43:02

Remillard
Plugin Author
From: Lenexa, KS
Registered: 2004-05-16
Posts: 169

Re: [plugin] [ORPHAN] mdn_wikitoday

At this point, I wouldn’t know how to go about doing it. I’m shocked it still works enough for someone to be interested in some modifications. It hasn’t been supported in… 2-3 years I think at this point, unless someone else has taken over and tweaked it. It used to be a real time hog too as I never worked out a good caching method.

I’m afraid you may have to scramble the PHP code yourself on this one and I apologize for that. I haven’t had any time for development projects in quite awhile.

Good luck.

Remillard

Offline

Board footer

Powered by FluxBB