Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2004-08-21 03:04:49

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

[plugin] [ORPHAN] ajw_wiki_today

<h4>v0.2 — Name changed to “ajw_wiki_today” in order to prevent confusion with on-this-day plugins used for inter-article linking.</h4>

Note: Currently (v0.2) international support is not fully functional due to a plugin encoding bug in TXP.

Download the plugin: ajw_wiki_today

This is pretty much a novelty plugin and it serves as my tribute to the coolest website in the world, Wikipedia. I initially saw an “On this day” link on plasticbag.org and thought, “I must steal that.” So I did. There are probably few people who would ever actually need this, but at least I got a bit of PHP practice out of making it.

So far it’s geared up to the standard stuff, take pre & post text, wraptag, label, and can be used to as a surrounding tag as well as standalone. I’ve added some common languages, English, French, Spanish, German, and Italian. Adding languages is easy so if you’re really wanting your language represented and Wikipedia has a date-based section for your language, lemme know & I’ll stick it in.

Examples
<p><code>&lt;txp:ajw_wiki_today /&gt;</code><br> Returns link to english wikipedia, anchor text reads date only.<p> <p><code>&lt;txp:ajw_wiki_today&gt;This Day in History&lt;/txp:ajw_wiki_today&gt;</code><br>Returns link to english wikipedia, anchor text reads “This Day in History”</p> <p><code>&lt;txp:ajw_wiki_today lang=“es” wraptag=“p” before=“Hoy: “ /&gt;</code><br> Returns link to spanish wikipedia, anchor text is preceded by “Hoy: “ and contained within &lt;p&gt;</p>

Attributes
<p><code>lang=”“</code><br>Sets a language (two chars) for output; see plugin source for supported languages and hints on how to add others. If not specified, “en” is assumed.</p> <p><code>noarticle=”“</code><br>By default, &lt;txp:ajw_wiki_today /&gt; uses the posted date of the currently viewed article, or today’s date if no article is being viewed. To turn off article-specific dates use <code>noarticle=“1”</code> (so that it always displays today’s date regardless of section).</p> <p><code>wraptag=”“</code><br>Wrapper tag for output, i.e. &lt;div&gt; will wrap anchor tag with a div.</p> <p><code>label=”“</code><br>Contents of this attribute will be placed in title=”“ for generated anchor tag.</p> <p><code>before=”“</code><br>Contents of this attribute will be placed before before anchor tag, but still inside wraptag. Example: &quot;On this day: <a href=”#”>25 August</a>&quot;</p> <p><code>after=”“</code><br>Identical to <code>before=”“</code> but placed after anchor tag.</p>

<strong>Version history:</strong><p><strong>v0.1</strong></p>
  • Initial release of <code>ajw_on_this_day</code>.
<strong>v0.2</strong>
  • Changed name to <code>ajw_wiki_today</code> to prevent confusion w/ other plugins.
  • Added article-specific posted date functionality.

Last edited by Andrew (2005-06-23 18:13:44)

Offline

#2 2004-11-10 18:12:49

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

Re: [plugin] [ORPHAN] ajw_wiki_today

Ok I’ve got a unique problem that perhaps one of you can solve for me. This is related to rss.php & atom.php currently not parsing plugin tags.

Any article that uses this plugin within the article body shows as ‘updated’ in feeds every single day (even after applying Johan’s quick-fix). Reason being, apparently the $id variable isn’t available when rss/atom is crunched. So instead of the link pointing to the date the article was posted, it always points to the current date. I can’t seem to think up a solution to this and perhaps it is just a weakness in this concept, but if anyone knows a way to access article-specific variables when during feed crunch-time let me know.

Offline

#3 2004-11-11 16:06:57

alicson
Member
Registered: 2004-05-26
Posts: 465
Website

Re: [plugin] [ORPHAN] ajw_wiki_today

compooter! fun plugin! is it in good working order as yet? shall i hold off for a little while? ‘looking forward to it…


textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation

Offline

#4 2004-11-11 17:06:23

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

Re: [plugin] [ORPHAN] ajw_wiki_today

Yep you can see it working on my personal site. It also (optionally) changes the date per article publish date. The only thing that behaves strangely is if you actually use the plugin within an article itself, and it will only behave strangely within you RSS/Atom version of that article.

This is due to two things: 1) as of 1.0RC2 rss.php and atom.php do not parse plugin tags and 2) if you make the small hack fix for that issue it’ll still not have access to the article-specific variables. I haven’t figured out entirely, but if you’re just going to be using the plugin in forms or pages – and not in an article, then it would never be an issue.

Btw, take note above that international support is a bit spotty due to TXP’s encoding bug.

Last edited by compooter (2004-11-11 17:11:25)

Offline

#5 2004-11-11 18:51:36

alicson
Member
Registered: 2004-05-26
Posts: 465
Website

Re: [plugin] [ORPHAN] ajw_wiki_today

sweet. this is a good one to know of, compooter.
what’s this ‘on this day’ plugin you speak of, though? i’ve not seen that anywhere (for textpattern)..


textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation

Offline

#6 2004-11-11 19:09:18

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

Re: [plugin] [ORPHAN] ajw_wiki_today

It may not exist (there was a request for historical article plugin and I may just start on that today), but there have been similar things created for WP and MT so I’m assuming at some point it will exist. It was basically to avoid confusion down the road. If I had moderator permissions, I’d just change the subject of this thread so I wouldn’t have to confuse you ;-) I have a tendency to over-explain my motives.

Offline

#7 2004-11-11 19:12:45

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

Re: [plugin] [ORPHAN] ajw_wiki_today

Is there a way to fetch the “On this day in history” content, rather than just provide a link to it?

Offline

#8 2004-11-11 19:27:50

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

Re: [plugin] [ORPHAN] ajw_wiki_today

From wikipedia? Not that I’m aware of. I don’t believe they offer any data feeds of any type outside of those needed for development updates.

I’ve lobbied for a Special:Today link, but my pleas have gone unheard with the massive influx of suggestions they constantly are receiving and amorphous development & feature request process. That one special link alone would make this plugin obsolete (something I’d love to have happen). They offer a Special:Current Events link, but as of now the only way to pull up the historical page for any specific date is to generate a languange-specific URL with that exact date. Very cumbersome, thus this plugin.

Offline

#9 2004-11-11 19:37:55

alicson
Member
Registered: 2004-05-26
Posts: 465
Website

Re: [plugin] [ORPHAN] ajw_wiki_today

:) i don’t mind being confused when people ultimately take the time to patiently unconfuse me.

i especially don’t mind if people feel a need to create new plugins, such as an “on this day” plugin that pulls up a site’s previous articles from years past.

nope, i wouldn’t mind at all.


textpattern.org :: find and share Textpattern resources
docs.textpattern.io :: Textpattern user documentation

Offline

#10 2004-11-11 19:46:48

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

Re: [plugin] [ORPHAN] ajw_wiki_today

I don’t think creating the link would be the hard part. I think the hard part would be grabbing the page, parsing the Events section, and selecting, say, 5 items at random. Maybe someone who is more expert with PHP could do that part easily. I’ll volunteer for creating something that makes http://language.wikipedia.org/wiki/Month_Day. :-) (Sure, sure, Rem. Take the easy jobs why don’t you? :) especially when it’s already done! :))

Actually looking at it, it’d probably be some regular expression magic, like TXP does scanning a page. Then the next nice trick would be to cache the “This Day in History” lines from the very first hit of the day (could very well be a search engine robot so no one would be too inconvenienced), do the random bit again, and display. Voila. (I know, easier said than done. And if people let me play with regular expressions… well you know the saying, “It’s all fun and games until someone loses an eye…”)

That might be over-engineering it though. It might be shorter to grab the front page, parse for the Selected anniversaries section and cut and paste that part. Save it off for the day in cache for future page hits.

I would have to go reread my Ruby tutorial to figure out regexp again , but it looks like you might just have to do a preg_match for the pattern: <code><h3>Selected anniversaries</h3> * </ul></div></code> to get the main string, and then preg_match against <code><li> * </li></code> to get each of the “This day in history” items. <code>fopen()</code> seems to take a url for a parameter as of PHP 4.3 or so, and <code>file_get_contents()</code> would pull the full html into a string. Might be tricky to get everything to play together though.

Last edited by Remillard (2004-11-11 20:15:38)

Offline

#11 2004-11-11 20:05:01

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

Re: [plugin] [ORPHAN] ajw_wiki_today

The problem w/ internationalization right now isn’t w/ building the links in the proper format, it’s to do w/ TXP’s encoding of months with special characters. Actually the plugin works fine and builds dynamic links in en/de/fr/it/sp in g1.19, but it’s limited right now in 1.0RC2 to only months that have no special characters.

Actually it’d probably be really easy to crawl their page & parse it with some of PHP5’s new features. As I understand it, there are some pretty powerful XML traversing tools built-in. It’s probably doable w/ PHP4 as well, not sure.

Offline

#12 2004-11-11 20:19:27

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

Re: [plugin] [ORPHAN] ajw_wiki_today

Sounds like an XML document crawl would be the elegant way to do it. The regular expression whack and crop method is more like the “Can you get this done by the status meeting this afternoon? Have a good lunch!” method :).

Offline

Board footer

Powered by FluxBB