news Plugin

Compatible with DokuWiki

  • 2012-01-25 "Angua" yes
  • 2011-05-25 "Rincewind" yes
  • 2010-11-07 "Anteater" yes

plugin News feed generator

Last updated on
2011-10-19
Provides
Syntax, Admin, Action
Repository
Source

Similar to feed, feedmod

Tagged with feed, news

Installation

Install the plugin using the Plugin Manager and the download URL above, which points to latest version of the plugin. Refer to Plugins on how to install plugins manually.

Examples/Usage

This plugin creates an RSS2 news feed from Dokuwiki pages that can be read in a standard news reader. It represents its news items rendered from Dokuwiki pages as HTML and should display images and media links correctly.

This plugin does not create diffs.

Sample Page: http://www.mturner.org/fckgLite/news_feed.xml

Syntax

There are two forms of markup. At the top of a page that holds new items, you must place one of the following:

~~NEWSFEED~~
~~NEWSFEED:<n>~~

First form

~~NEWSFEED~~

If you use the first form, then you bracket your news items with the following markup:

<news: item_title>
blah blah
</news>


<news: another_item>
blah blah
</news>

The news reader will use your title for the item. Please note that the colon after news is required.

You can omit the title:

<news>
blah blah
</news>

In this case the title will default to 'News Item'

Second form

  ~~NEWSFEED:<n>~~

In this form, the news items are generated from material which is preceded by Dokuwiki header markup, and the headers become the titles of the news items. The <n> designates the number of equal signs that mark up your headers. The plugin will create news items from all headers greater than or equal to n. For instance:

	~~NEWSFEED:3~~

will create items from all headers with with three or more equal signs:

    
    === header 1 ===	  
    ==== header 2 ====

This is particularly useful if you have a page which is dedicated to news items.

Per Page Refresh Button

  ~~NEWS_REFRESH~~

See below refresh button

Generating the feed

The primary script for generating news feeds is newsfeed.php, which is found in news/scripts. The news feed file is named news_feed.xml. Each of the following methods generates the xml news feed in your top level dokuwiki directory.

  1. place newsfeed.php in your top level dokuwiki directory and point your news read to that script This method adheres to the ttl (time-to-live) configuration setting (see Options below) and creates a new xml file only after the ttl has expired. Until the expiry time, it reads and outputs the previously created news_feed.xml. However, you can force a new feed to be created by method 2 or 3.
  2. place newsfeed.php in lib/exe and generate the feed from the command line: php newsfeed.php; if you have already generated a news feed using one of the other methods, then the generated news feed file (<dokuwiki>/news_feed.xml) will be owned by the web server and you will need permission to over-write it (if you own the directory you should be able to delete news_feed.xml).
  3. open the news admin panel and click on the Generate Feed button. This method by-passes the time-to-live setting and generates a new feed whenever activated.
  4. add a per-page refresh button

if You use method 1, then your news feed url is:

         http:/my_web_site.org/my_dokuwikinewsfeed.php
		

If you use method 2 or 3 and do not implement method 1, then your url must be:

         http:/my_web_site.org/my_dokuwiki/news_feed.xml
         

Per Page Refresh Button

You can generate a new feed by adding a refresh button to any page. To use this method newsfeed.php must be in your top level dokuwiki directory. Clicking this button causes newsfeed.php to run and works the same way as the Generate Feed button in the admin panel, i.e. it by-passes the time-to-live setting and immediately re-creates a new feed.

The syntax for this button is

 ~~NEWS_REFRESH~~

This syntax will be replaced on Save by the Feed Refresh button. When using this button, you should also include on your page the ~~NOCACHE~~ directive. Doing so insures that the button appears on the page only when a registered user is logged in.

 ~~NOCACHE~~
 
 ~~NEWS_REFRESH~~

When the per-page button is clicked, it runs newsfeed.php in the wiki's root directory and outputs a page to the browser which indicates whether or not the feed has been successfully re-generated. The page will display a return link to the page from which the feed generation originated.

The refresh button will only appear on pages where the user has edit permission.

Configuration and Settings

  1. ttl: Number of minutes before a new feed will be automatically generated. The default is 720 minutes (12 hours).
  2. title: Feed Title
  3. desc: Feed Description
  4. url: Site Url (This should be set if you are going to generate feeds from lib/exe/newsfeed.php)

For both the Feed Title and the Feed Desciption fields, the default is DokuWiki News Feed

Administration Panel

There is an Admin Panel where you can delete old entries and generate a new news feed. See the Admin Panel for explanations and instructions.

Development

Change Log

29 Aug 2011:

  1. Generating feed from admin panel did not pick up the feed title and feed description. This is now fixed.
  2. Return DOKU_URL from feedData::news_feed_url() when the server data is not available (the case for writing out the channel).

3 Sep 2011: Fixed incorrect time period calculation for feed expiry

10 Sept 2011: Fixed incorrect image links

14 Sep 2011: Set guid permalink attribute to true to help prevent duplication of items.

18 Oct 2011:

  1. Added a per-page news feed refresh button;
  2. Added German language support (with thanks to TaggicTaggic

    Bavaria in Germany
    )

19 Oct 2011:

  1. Removed newlines and spaces from button.php that caused premature header error in OS X
  2. Upgraded output from per-age refresh button as described above
  3. restricted per-page button to users with at least edit permission for the page where the refresh syntax appears

Known Bugs and Issues

FAQ

Discussion

If possible, please direct discussion to the forum.

plugin/news.txt · Last modified: 2012/03/09 03:31 by turnermm
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 3.0 Unported
Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsGitXRefTranslate