Talk:WikiArticleFeeds Extension

From Jimbojw.com

Jump to: navigation, search

Comments on WikiArticleFeeds Extension

Note: Due to a recent influx of spam messages on this page, comments are now being moderated. Your comment will appear once it has been approved.
Leave a comment
Sorry, comments are disabled.

Contents

Charlie said ...

Hey Jim... I have a few additions / changes I made to WikiArticleFeeds on charlie.huggardlee.net that I thought you would be interested in:

Removing parsing of articles on purge

class WikiArticleFeedsParser { 
...
    function itemTagsPurge( &$article ) {
        global $messageMemc,$wgDBname;
        $titleDBKey = $article->mTitle->getPrefixedDBkey();
        $keyPrefix = "{$wgDBname}:wikiarticlefeedsextension:{$titleDBKey}";
        $messageMemc->delete("{$keyPrefix}:atom:timestamp");
        $messageMemc->delete("{$keyPrefix}:atom"); 
        $messageMemc->delete("{$keyPrefix}:rss"); 
        $messageMemc->delete("{$keyPrefix}:rss:timestamp"); 
        return true;
    }
}
 
$wgHooks['ArticlePurge'][] = array($wgWikiArticleFeedsParser, 'itemTagsPurge');

As I'm generating my feed page using Semantic MediaWiki, adding new articles for me is an action=purge on the main Blog article as opposed to an edit. Unfortunately I haven't come up with a good solution yet for dealing with tag feeds. Possibly have a base item in objectcache that could hold a list all of the keys generated...

Parsing the attribution string

$isAttributable = preg_match(
    '/--<a.*>(.*?)<\\/a>\s*(\\d\\d:\\d\\d, \\d+ [A-z][a-z]+ \\d{4} \\([A-Z]+\\))/m',
    $seg,
    $matches
);
if ($isAttributable) {
    list($author,$date) = array_slice($matches,1);
    $date = wfTimestamp(TS_MW,strtotime($date));
}

Partially out of using Semantics, I'm avoiding the User namespace. So I added the requirement that the author string starts with a --. But the part I thought you would be interested in was the handling of the date part. By doing the strtotime, you can accept many forms of date strings, and it properly does the conversion to UTC time for the appropriate element within the feed item themselves.

Hope you're having a good one buddy!

--Charlie 20:33, 8 May 2007 (MST)

Jimbojw said ...

Hi Charlie,

Thanks for the suggestions - that ArticlePurge hook comes in really handy when testing (finally I have a way to clear out those feeds other than truncating the objectcache table!)

I added a method which hooks 'ArticlePurge' just like your snippet and it seems to be working great!

Additionally, I added processing for both the traditional ~~~~ and now --~~~~ where the user's page is not in the User namespace. This is to help out with Semantic integration.

Thanks for contributing back - and by all means let me know if these changes don't help. Thanks!

--Jimbojw 20:35, 9 May 2007 (MST)

Alain said ...

Hi,

I installed your extension but I am getting the following error: Warning: array_slice() [function.array-slice]: The first argument should be an array in /home/wikiguit/public_html/wikiguitarist/languages/Language.php on line 1083

and the layout is changed, seems that it impact the CSS rendering. I am running mediawiki 1.8.2.

Any idea on this bug?

thanks Alain algau@videotron.ca


--Alain 06:32, 20 May 2007 (MST)

Alain said ...

From the error log file, the problem seems to be du to: is not a valid magic thingie for "itemtags"

Therefore maybe the problem come from the purge feature lately added?

Any idea to fix this?

Thanks Alain algau@videotron.ca

--Alain 08:12, 20 May 2007 (MST)

Jimbojw said ...

Hi Alain,

When extensions register magic words (for parser functions or otherwise), they do so by hooking into 'LanguageGetMagic'.

Since wfRunHooks() is calling the magic functions, if any of those functions fail to return "true", any other functions registered later will not be executed.

I'm guessing that one of your other extensions which also registers parser functions is failing to return true, causing the itemTags magic function to never get called.

Check your other extensions, I bet if you comment out the require_once() line for others in your LocalSettings.php, you'll find the one which is choking the LanguageGetMagic stack.

One quick fix might be to move WikiArticleFeeds to the front of the require_once() pack in your LocalSettings - but this won't correct the overarching issue moving forward.

Hope this helps!

--Jimbojw 21:51, 20 May 2007 (MST)

Alain said ...

Hy Jim,

You were right! I moved the require_once for your extension to be the first one in my local setting and it work correctly now.

Nice and handy extension, great job!

Sincerely, Alain

--Alain 07:55, 21 May 2007 (MST)

Alain said ...

Hi Jim,

In fact it still not works correctly. The XML generated seems not to be valid, I am getting the following error when I click on the RSS icon:

<?xml version="1.0" encoding="utf-8"?>
^

You test it at: http://www.wikiguitarist.com/wikiguitarist/Gauthier%2C_Alain

Any idea? Is it something on my side?

Thanks in advance, Sincerely, Alain

--Alain 09:52, 21 May 2007 (MST)

Alain said ...

Hi Jim,

Me again, the problem seems to be due to the carriage return for the first two XML tags. We you save the XML locally, remove the carriage return (and add it or not) then the file is readable.

Can you fix your algorithm to remove the carriage returns for the first two XML tag?

thanks in advance. Alain

--Alain 20:40, 21 May 2007 (MST)

Jimbojw said ...

Hi Alain,

Regarding the XML - yes the leading whitespace is causing it to not be recognized properly as XML.

In my experience, this most often occurs when another extension' has trailing whitespace at the end of a file, after the final "?>" that closes the PHP block. Like this:

//some extension code
}
?>
     <-- extra lines!

Although this could happen on any extension, I've seen it personally in the DynamicPageList (DPL) extension's files when downloaded as a zip archive from the DPL demo site.

The solution is to identify which extensions have trailing whitespace and remove it. By the time WikiArticleFeeds runs and returns the feed, the whitespace has already been sent to the browser (it's too late). So I have no way to correct it from within the extension itself. :(

Also, check your Special:RecentChanges feed - you'll find that it also suffers from the leading whitespace problem (I've had that experience too).

Hope this helps!

--Jimbojw 20:40, 22 May 2007 (MST)

Alain said ...

Hi Jim, You rock! That was the exact issue, I had 3 extension ending with spaces/blank line. I removed them and now it works. Great job. Thanks again Alain

--Alain 21:37, 22 May 2007 (MST)

DarsVaeda said ...

hi,

i like to add a newsfeed to my page. works well but: if a feed contains a link (internal or external) clicking that feed will lead to that link, not to the feed itself! see http://www.terrapedia.org/Newsfeed

--DarsVaeda 08:44, 30 July 2007 (MST)

DarsVaeda said ...

ahh i forgot to purge *blush*

--DarsVaeda 09:03, 30 July 2007 (MST)

Onigami said ...

hey,

nice script! but i have some probs with it. i run a german wiki with short urls. it does not parse creation date and author to the feed-items. i think this is because my urls are not as i can see your script expects in line 499 and so on ("[...]/index.php?title=User:Name"). instead my urls are just "http://www.url.org/User:Name".

could you give me a hint how to solve that? also many feed-validators complain about a missing <guid>-element?! could you add that?

thank you!

--Onigami 04:51, 6 August 2007 (MST)

Lane said ...

I love this functionality; it's really fantastic, and it adds a lot to MediaWiki. I think I've run into a problem that likely has more to do with my own PHP setup.

Namely, that the pubdate is being published in the XML as GMT instead of the correct time zone (which is CDT).

So the pubdate is always five hours earlier than the actual.

I'm assuming this is an issue with MediaWiki's feed.php (I'm using v1.10, BTW), but I haven't found an obvious solution. Can you think what might be happening? I'm including a bit of the (snipped) XML, just so it's clear what I'm talking about.

Thanks! -Lane

--

<p>This server is down, and here's text that talks about what we're doing about it.
--WikiSysop 08:04, 14 August 2007 (CDT)
</p>

<pubDate>Tue, 14 Aug 2007 08:04:00 GMT</pubDate>

--Lane 08:07, 15 August 2007 (MST)

Dogsbody said ...

Hi,

I absolutely LOVE this extension and works exactly as I want... except! :-)

I think I have hit the maximum number of items in a feed!? Although it seems to be 162!?

If I add another entry to the article then all of the feeds return empty! :-/

This is a real shame as I would like to put many many more items in a feed! Any ideas how this could be fixed please?

Thank you again.

Dan

--Dogsbody 04:48, 12 October 2007 (MST)

Dogsbody said ...

Well I haven't so much fixed my issue but found a work around...

Instead of having one article with 300 news entries in (e.g. [[News]]) which doesn't work. I have created [[News Oct 07]], [[News Sep 07]], [[News Aug 07]] etc. and then included them into [[News]] with transcludes {{:News Oct 07}}

For some reason the feed for News then works giving over 300 entries!

Thanks again for a great extension.

Dan

--Dogsbody 07:42, 15 October 2007 (MST)

Ianr said ...

I have just the same problem as DarsVaeda: if a feed contains a link (internal or external) clicking that feed will lead to that link, not to the feed itself! And more than one link causes my wiki to end up at a help page...

I'm not sure what he means by purging in his next message. If I could just find out what made him blush...

--Ianr 14:53, 18 December 2007 (MST)

ianr said ...

Ok now I'm blushing. Purge means that you delete the feed and resubscribe. Then the $wgForceArticleFeedSectionLinks = true starts to work.

--ianr 15:41, 18 December 2007 (MST)

Jimbojw said ...

Hi Ianr,

"Purge" can also mean action=purge for the page. Because rendering the feeds would be expensive to do on every request, they're cached using the same mechanism that MW uses to cache rendered articles.

If you go to a page and hit the "edit" or "view source" link, then change "edit" in the URL to "purge", you can expunge the cached rendered article and the Atom/RSS feeds at the same time.

Hope this helps!

--Jimbojw 09:54, 19 December 2007 (MST)

rigid said ...

in line 230 i changed the source to:

global $wgServer, $wgScript, $wgTitle;
 
        if($wgTitle->getNsText()) {
                $prefixUrl = $wgTitle->getNsText().':';
        }
        else {
                unset($prefixUrl);
        }
        $baseUrl = $wgServer.$wgScript.'?title='.$prefixUrl.$wgTitle->getDBkey().'&action=feed&feed=';

The embedded feed now also works for prefixed pages. I quickly fixed that, maybe you can do it cleaner. regards

--rigid 10:42, 3 January 2008 (MST)

Jimbojw said ...

Thanks rigid,

As it turns out, there is an easier way to do that. If you take line 232 and change it from this:

$baseUrl = $wgServer.$wgScript.'?title='.$wgTitle->getDBkey().'&action=feed&feed=';

To this:

$baseUrl = $wgServer.$wgScript.'?title='.$wgTitle->getPrefixedDBkey().'&action=feed&feed=';

That should achieve the same purpose. If that works for you, I'll be happy to add it to the core. Thanks!

--Jimbojw 10:59, 3 January 2008 (MST)

Muzz said ...

Just wanted to thank you for this extension, it's just what I needed. With Charlie's patch I got the timestamp working as well. Thanks to both of you.

--Muzz 01:02, 22 January 2008 (MST)

Adam said ...

I followed the installation instructions but when the require_once('extensions/WikiArticleFeeds.php'); line is inserted the wiki page will not load. Any idea why this might be happening?

--Adam 18:03, 8 February 2008 (MST)

Jimbojw said ...

Hi Adam,

> but when the require_once('extensions/WikiArticleFeeds.php'); line is inserted the wiki page will not load

Well, it could be any number of things. The first thing I'd recommend doing is enabling error output so you can see what the problem is. This can be done programatically by adding this to your LocalSettings.php file:

error_reporting(E_ERROR | E_WARNING | E_PARSE);

Once you're able to see the error output, it should be much easier to diagnose the root cause. Good luck!

--Jimbojw 10:56, 11 February 2008 (MST)

Adam said ...

I tried that but I can't find where the errors are reported. Is there a log file? The syntax in our PHP does not have the double quotation marks . It uses single quotation marks. I have no idea what version of Mediawiki we are running. The PHP version is 3.01 Could that be the issue?

--Adam 16:43, 11 February 2008 (MST)

Adam said ...

Disregard the PHP version in the last post. It is 5.0

--Adam 16:51, 11 February 2008 (MST)

scott said ...

Is it possible to force this to generate a feed for each page buy default? Without the users adding the tags?

--scott 12:11, 18 February 2008 (MST)

aeolist said ...

hello there,

i really like your plugin, good work :)

I think i have set it up correctly for our news page at http://foss.ntua.gr/wiki/index.php/%CE%9D%CE%AD%CE%B1

however i am having trouble with our latest articles list: tinyurl.com/2lqqp3

a(major). can the code be tweaked to enumerate lists (*Stuff1, *Stuff2) instead of headers/titles(the ==Title==)?

b(minor). all these articles have a section of the text inside <onlyinclude> tags, this is supposed to be the text showing up in the final xml, is this correct?

c(minor). is this plugin still accepting options like <startFeed / minoredit=no> etc?

thank you!

--aeolist 02:32, 25 February 2008 (MST)

Knauszi said ...

Hi Jim,

thank you for this extension! I've installed it, and it seems to work... partly. But I can't see the RSS and ATOM links in my sidebar. What should I try out?

--Knauszi 03:37, 8 April 2008 (MST)

Wikiquest said ...

Hi Jimbojw! Can the feed tags be embedded into the skin so that one does not have to manually add them to each wiki article?

--Wikiquest 00:54, 4 June 2008 (MST)

Wikiquest said ...

Also, how did you configure your wiki so it is moderated?

--Wikiquest 00:55, 4 June 2008 (MST)

Jimbojw said ...

Hi Wikiquest,

> Can the feed tags be embedded into the skin so that one does not have to manually add them to each wiki article?

I've been asked for that feature before, and if I ever get around to it, I'll probably make it easy to do. Right now though, it'd probably require changing the extension code.

> Also, how did you configure your wiki so it is moderated?

It's really a hack solution. All I do is add an unclosed HTML comment at the bottom of the talk page so that new comments aren't rendered (MediaWiki treats them as part of the HTML comment). For example, this page contains the following line at the bottom:

<!-- Unapproved comments will appear below this line 

Then, when I approve comments, I just copy and paste them above the line. See also Talk:ArticleComments Extension.

--Jimbojw 10:04, 4 June 2008 (MST)

Wikiquest said ...

XML Parsing Error: junk after document element Location: http://wiki.arcs.com/index.php?title=Talk:%D8%B3%D9%85%D8%B1%D8%A7%D8%A1.com&action=feed&feed=atom Hi Jim,

I am running into a mysterious problem while using WikiArticleFeeds.

I have created a wiki page with feed tags embedded into the Talk page at http://wiki.arcs.com/index.php?title=Talk:%D8%B3%D9%85%D8%B1%D8%A7%D8%A1.com

I am trying to retrieve the content of the wiki Talk page into the website http://xn--ggbl3ah4g.com/; however, this has failed.

Upon calling the feeds URL in my browser, I got the following error:

Line Number 2, Column 1:Notice: Undefined offset: 2 in /home/arcscom/public_html/wiki/extensions/WikiArticleFeeds.php on line 545
^

How can this be resolved?

Cheers, WikiQuest

--Wikiquest 01:44, 9 June 2008 (MST)

Dan Bolser said ...

Hey Jibo...

Nice extension!

I had a go at integrating your extension with the excellent DPL Extension http://semeb.com/dpldemo/index.php?title=Dynamic_Page_List

It seems to be working... http://biodatabase.org/index.php/Template:New_Database_List/Feed

Not sure if the 'author' is being picked up or not, but the code is there for you to play with.

Dan.


--Dan Bolser 13:00, 12 June 2008 (MST)

Roger said ...

anyone can help me?? I keep getting this error when I try to see the XML feed.

The XML page cannot be displayed 
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. 


--------------------------------------------------------------------------------

Only one top level element is allowed in an XML document. Error processing resource 'http://localhost/2/mediawiki/index.php...

<b>Notice</b>:  Undefined offset:  2 in <b>C:\Program Files...

BTW im using mediawiki 1.11

Thanks

--Roger 15:59, 29 December 2008 (MST)

David Buchan said ...

Everything is working nicely except when I pull my feed into FeedDemon the dates are backwards. The feed doesn't seem to have date information for each entry and so they display correctly in the feed but not when read by a reader.

http://feeds.feedburner.com/quantumgardener

David

--David Buchan 18:39, 2 April 2009 (MST)

Joel said ...

First, Thanks for a nice extension!

I'm fairly new to wikis and extensions and have a small problem with ArticleFeeds v0.6.3 over MediaWiki 1.14.0.

I got the extension working. I am setting $wgForceArticleFeedSectionLinks to true because i want by RSS readers to go through the feed page before going to the link in the article, when there is one.

My problem is this: My RSS feed is on sandbox and I have "Third Item". I would Expect the created link to be "Sandbox#Third_Item". However, what i am getting this (withoput angle brackets):

<Sandbox#Third_Item" id="Third_Item>

I don't know where the <" id="Third_Item> part comes from and this has the unfortunate side effect that the link opens my feed page, but does not scroll down the browser directly on the article itself.

I have not setup feedburner as I understand this is not necessary -- For now our Feed is stritly an internal one at my company.

Any hints would be appreciated.

Thanks & Regards, Joel

--Joel 07:13, 6 April 2009 (MST)