Extension:EmbedNews

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
Crystal Clear action run.svg
EmbedNews
Release status: stable
Description Displays current event from a news page
Author(s) Thomas Lorentsen (matxtalk)
Latest version 1.3.6 (2008-6-11)
MediaWiki 1.11
License GPL
Download tar zip
Translate the EmbedNews extension if it is available at translatewiki.net
Check usage and version matrix.

What can this extension do?[edit]

Embed News allows the most current news to be displayed. A page is created to contain all the news that is to be displayed and on which dates it is to be displayed on. The extensions tag is placed on the page you wish the most current news to be displayed on. The extension will search the page for most current news it can find and display it on the page. This is helpful if you have a lot of news of future events but only want visitors to see the current event.

A Calendar can be displayed on the side to show events. Links are provided to events and highlighted. The calendar has been updated to display a window of dates, so the current week is in the middle, and the previous and next 2 weeks are displayed. This allows people to see events in the next month which where not displayed in the original implementation.

  • You can have news for any day.
  • Only the event happening today or about to happen is displayed.
  • Events must be in order of happening.
  • Titles are picked up as well, not just subheadings
  • Empty sections are ignored
  • Calendar to display a current events happening
  • News can be displayed in tabular form
  • Backlogging to show past events
    • Can show a set number of past events and/or up to certain amount of days ago.

Need help or request features, edit my discussion page.

Usage[edit]

To start displaying news on the page:

__NOCACHE__
<embednews>news</embednews>

Where news inside the tags is the news page. If the page does not exist yet, the extension will provide a link to create the page.

The news page is structured with the date as the title and the news for that date is written below. Example below


==23 November 2007==

Longer dates work

==2007-11-15==

Short dates are picked up

==[[2007-11-10]]==

Wiki links work as well

=2007-11-15=

titles work fine

= 2008-01-08 =

Titles and sub headings work as well

Quite a few date representations can be detected by the extension.

For the regex minded person the following is used to find dates in a wiki page:

/[=]*=[\[]*([^\]\n=\"]*)[\]]*=*=/

News Table[edit]

You can display news in a table.

__NOCACHE__
past five events and up to 14 days ago: <embednews>news|table backlog=5 daystail=14</embednews>
past five events: <embednews>news|table backlog=5</embednews>
past 14 days: <embednews>news|table daystail=14</embednews>

The | character is used to insert attributes where the wiki page is entered first then pipe then the attributes.

The table attribute tells the extension to display news in a table formatted as |date|event|.

The backlog attribute tells how many events to display.

The daystail attribute tells will only show news in the previous amount of days.

A daysahead attribute can be used similarly to days tail to set the current day 'n' number of days if you wish to see more future events.

The event column is designed to only show an excerpt of the text. If only a excerpt is shown, a ... is added to the end of the line. Also unfinished words are removed. This may have trouble displaying embedded templates, do not use table view if embedding templates.

Table styling can be applied by using the style and border param. For example:

<embednews>news|backlog=3 table style="width:90%;color:green;" border=1</embednews>

The | symbol splits the wiki page to the parameters.


Download instructions[edit]

I have provided the sources in a zip and tar file.

Unpack the files with the appropriate command.

$ tar -xjvf embednews.tar.bz2
$ unzip embednews.zip

The following files will be unpacked:

  • CHANGELOG Changes that I have made, read before installing
  • COPYING GNU License
  • MonoBook.php Patched MonoBook file
  • README Installation and usage documentation
  • embednews.css Calendar Styling file
  • embednews.php Main extension

Installation[edit]

To install you need to place the following files into the following locations. From mediawiki root directory.

$ cp embednews.php extensions/
$ mkdir skins/embednews/
$ cp embednews.css skins/embednews/

To your LocalSettings.php file append the following:

include_once("extensions/embednews.php");
$embednewsfeed = 'news';

Where $embednewsfeed is optional if you wish to see the calendar explained below.

Calendar Install[edit]

To install the calendar you need to make a patch to your skin. Currently Monobook for version 1.11.0 is provided. Replace your old version with this new version and make a backup of the original.

$ cp -b MonoBook.php skins/MonoBook.php

Or you can make a manual patch by inserting the following lines into your skin files where you wish the calendar to be displayed.

<? 
   global $embednewsfeed;
   if ($embednewsfeed) {
     echo createCalendar("$embednewsfeed"); 
   }
?>

This will create a new portlet.

Once installed set $embednewsfeed in your LocalSettings to the name of the page containing your news.

Required[edit]

Required Extensions[edit]

You will need magic no cache extension provided here to allow the page to be updated automatically.

Extension:MagicNoCache

This extension has been tested to work on mediawiki 1.11.0 with little changes

Customization[edit]

A css file for the calendar styling is provided. The calendar html code is found within the extension file.

Feature Requests[edit]

  • Embedding events from multiple pages (see discussion)
    • Half implemented.
  • Allow multiple news feeds
  • Allow calendar to be added without touching Local Settings file
    • Make it easier for people to set up calendar when they have no access to the local settings file.
  • BUG Backlogging in default view has a glitch when reaching end of the news page


See also[edit]

For standard date representation see ISO_8601.