Extension:BedellPenDragon

From MediaWiki.org
Jump to navigation Jump to search
MediaWiki extensions manual
Crystal Clear action run.svg
BedellPenDragon
Release status: unmaintained
BedellPenDragon glossary.png
Implementation Tag, Parser function, Special page
Description Adds <randompageincategory> tag and {{#setbpdprop}} and {{#getbpdprop}} metadata parser functions and special pages for glossary, essay list, miscellany list, quote list and video list.
Author(s) Nathan Larson (Leucostictetalk)
Latest version 1.0.12 (2013-11-29)
MediaWiki 1.22+
PHP 5.3+
Database changes No
License GNU General Public License 2.0 or later
Download
Parameters
  • $wgBedellPenDragonGlossaryIntros
  • $wgBedellPenDragonGlossaryTitlePropnames
  • $wgBedellPenDragonGlossarySummaryPropnames
  • $wgBedellPenDragonGlossaryWikifyTitles
  • $wgBedellPenDragonGlossaryStripFromFront
  • $wgBedellPenDragonGlossaryReplace
  • $wgBedellPenDragonGlossaryAuthor
Tags
randompageincategory
Hooks used
ParserFirstCallInit
RefCallback
Translate the BedellPenDragon extension if it is available at translatewiki.net
Check usage and version matrix.

The BedellPenDragon extension is like a combination of Extension:Random In Category and the example page_props metadata extension, with glossary, essay, miscellany, quote and video list special pages added on. The extension makes available a <randompageincategory> tag and parser functions to allow pages to add or remove metadata to/from the page_props table. It is designed to be used in conjunction with Extension:CategoryGallery and Extension:RecentChanges, if you want additional functionality. Perhaps the best way to explain it is by example. All of these features you can see either displayed or available from the PolyWiki main page.

  • Articles:
  • Essays:
  • Quotes:

Examples of how this is done:

This data can be queried by sites external to your wiki using the API. Also, you can create sidebars similar to RationalWiki's Template:Sex that display a random list of x articles in a given category. So, for example, an article on fractional reserve banking could have a {{banking}} sidebar with a list of 12 randomly selected banking articles. This way, users who revisit the article will be exposed to new content each time.

Another advantage is that vandals and spammers almost certainly won't know to use the templates that will cause content to be seen on the main page and on other pages that use the data. There's other stuff that could be done with this extension too, such as creating "Did you know?" tidbits of information for display on the main page; it would be easy to add another special page to display a master list of those items. In case anyone was curious, this extension was named after w:User:JPatrickBedell and Vlad Draconis PenDragon (aka Matthew Mercer-Kinser).

Contents

Installation and configuration[edit]

Installation[edit]

  • Download and place the file(s) in a directory called BedellPenDragon in your extensions/ folder.
  • Add the following code at the bottom of your LocalSettings.php:
    require_once "$IP/extensions/BedellPenDragon/BedellPenDragon.php";
    
  • Yes Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.

Creating more special pages[edit]

By default, this extension implements a Glossary, an EssayList, a QuoteList, a MiscellanyList, and a VideoList. You don't need to create more special pages if you don't want them, but here's how to do it if you're so inclined. Let's say you want to create a Special:ReasonList. Create SpecialReasonList.php:

<?php
if ( !defined( 'MEDIAWIKI' ) ) {
   die( 'This file is a MediaWiki extension. It is not a valid entry point' );
}

class SpecialReasonList extends SpecialGlossary {
   function __construct() {
       parent::__construct( 'ReasonList' );
   }
}

Now put in LocalSettings.php:

$wgAutoloadClasses['SpecialReasonList'] = __DIR__ . '/SpecialReasonList.php';
$wgSpecialPages['ReasonList'] = 'SpecialReasonList';
$wgBedellPenDragonGlossaryIntros[] = '{{MediaWiki:Reasonlist-intro}}';
$wgBedellPenDragonGlossaryTitlePropnames['ReasonList'] = 'bpd_reason_title';
$wgBedellPenDragonGlossarySummaryPropnames['ReasonList'] = 'bpd_reason_summary';
$wgBedellPenDragonGlossaryWikifyTitles['ReasonList'] = true;
$wgBedellPenDragonGlossaryStripFromFront['ReasonList'] = 'Reason:';
$wgBedellPenDragonGlossaryReplace['ReasonList'] = array ( "\n\n" => "\n\n:" );
$wgBedellPenDragonGlossaryAuthor['ReasonList'] = false; // or 'bpd_reason_author' if you prefer

Configuration[edit]

$wgBedellPenDragonGlossaryIntros[edit]

The page that will be transcluded into the beginning of the special page out.

$wgBedellPenDragonGlossaryTitlePropnames[edit]

The property names for the page titles.

$wgBedellPenDragonGlossarySummaryPropnames[edit]

The property names for the summaries.

$wgBedellPenDragonGlossaryWikifyTitles[edit]

Wikify the titles that are displayed in the special page?

$wgBedellPenDragonGlossaryStripFromFront[edit]

Strip this (usually a colon-suffixed namespace) from the front of displayed page titles.

$wgBedellPenDragonGlossaryReplace[edit]

Do a search and replace on this. It's in the form of an array.

$wgBedellPenDragonGlossaryAuthor[edit]

Is this special page a two-level hierarchy of author (top-level) and title (bottom-level)?

Usage[edit]

The most obvious uses of this extension are as follows:

Random page in category[edit]

To get the page title of a random page in Category:Aubry, use, e.g.:

<randompageincategory cat="Aubry"/>

Or to get a bulleted, wikified, sorted list of 12 random page titles from Category:Nathan Larson essays:

<randompageincat cat="Nathan Larson essays" number="12" parse="yes" sort="true" firstitem="*[[" lastitem="]]">]]<br>
*[[</randompageincat>

Load that into a wikipedia:Template:Sidebar like this (although ideally you'll find a way to make the page titles wrap if they get too long, rather than making the sidebar expand to fit them on one line apiece; please improve upon this example if you can):

{{sidebar |title=[http://nathania.org/wiki/Special:CategoryTree/Nathan_Larson_essays Nathan Larson's essays] |heading1=A random selection |content1= <randompageincat cat="Nathan Larson essays" number="12" parse="yes" sort="true" firstitem="*[[" lastitem="]]">]] *[[</randompageincat> |content1style=text-align:left; |style=width: 20%; }}

It'll give you something like this:

BedellPendragon random selection of pages example.png

Or to get the content of a randomly-chosen page from Category:Featured quotes with page.page_ids 1 and 26 excluded:

<randompageincategory cat="Featured quotes" content="true" parse="true" exclude="1,26"/>

Parameters[edit]

Parameter Allowed values Default Description
content Anything (it's boolean; either set or not set) Not set Provide the content of the page rather than the page title
delimiter Any string Not set What to print before items after the first item
exclude Comma-delimited list of page.page_ids Not set What category element(s) to exclude from the result
firstitem Any string Not set What to print before the first item
lastitem Any string Not set What to print after the last item
number Any number 1 Number of category members to return
parse Anything (it's boolean) Not set Parse the results before returning them
propreplace Any string Not set Replace this content with propreplacewith property
propreplacewith Any property Not set Replaced propreplace with this
replace Any string Not set Replace this with the page title
sort Anything (it's boolean) Not set Sort the results before returning them
stripreftags Anything (it's boolean) Not set Strip ref tags from the result
template Template page title Not set Use this template
type "file", "subcat", "page" "page" Value of categorylinks.cl_type
urlencode Any string Not set Replace this with the url-encoded page title after parsing the output

The input, i.e. the text between the opening and closing tags, overrides the delimiter parameter.

Today's featured article[edit]

After importing the templates mentioned above, and adjusting your Template:Today's featured article to exclude the appropriate page IDs (they'll be different on your wiki than what they are on PolyWiki), start your featured article (e.g. polyamory) like this:

{{FASummary|Poly Mainpage Silhouette.jpg|A polyamorous quad.|'''[[Polyamory]]''' (from Greek {{lang|el|πολύ}} [''{{lang|el-Latn|poly}}''], meaning "many" or "several", and Latin ''{{lang|la|amor}}'', "[[love]]") is the practice, desire, or acceptance of having more than one intimate relationship at a time with the knowledge and [[consent]] of everyone involved. |It is distinct from [[swinging]] (which emphasizes sex with others as merely recreational) and may or may not include [[polysexuality]] (attraction towards multiple [[genders]] and/or [[sexes]]).<ref>Morning Glory Zell-Ravenheart. ''A Bouquet of Lovers'' (1990)</ref><ref>"swinger." Definitions.net. STANDS4 LLC, 2013. Web. 25 Apr. 2013. <http://www.definitions.net/definition/swinger>.</ref><ref>"polysexuality." Definitions.net. STANDS4 LLC, 2013. Web. 25 Apr. 2013. <http://www.definitions.net/definition/polysexuality>.</ref> Polyamory, often abbreviated as ''poly'', is often described as "consensual, ethical, and responsible non-monogamy." The word is sometimes used in a broader sense to refer to sexual or romantic relationships that are not sexually exclusive, though there is disagreement on how broadly it applies; an emphasis on ethics, honesty, and transparency all around is widely regarded as the crucial defining characteristic.}}

Transclude Template:Randomly featured article to your main page and you'll get something like this:

BedellPenDragon TFA example.png

"New Pages" or "Did You Know" descriptions via metadata from the pages themselves (requires RecentPages extension)[edit]

You'll need Extension:RecentChanges for this.

PageSummary template and New Pages display of pages with that template[edit]

Write your wiki pages like this:

{{PageSummary|'''[[Polyamory]]''' (from Greek {{lang|el|πολύ}} [''{{lang|el-Latn|poly}}''], meaning "many" or "several", and Latin ''{{lang|la|amor}}'', "[[love]]") is the practice, desire, or acceptance of having more than one intimate relationship at a time with the knowledge and [[consent]] of everyone involved.|It is distinct from [[swinging]] (which emphasizes sex with others as merely recreational) and may or may not include [[polysexuality]] (attraction towards multiple [[genders]] and/or [[sexes]]). Polyamory, often abbreviated as ''poly'', is often described as "consensual, ethical, and responsible non-monogamy." The word is sometimes used in a broader sense to refer to sexual or romantic relationships that are not sexually exclusive, though there is disagreement on how broadly it applies; an emphasis on ethics, honesty, and transparency all around is widely regarded as the crucial defining characteristic.}}

Notice how this creates two summaries separated by a pipe; the short summary is the first sentence, while the long summary is the first sentence followed by the rest of the summary. You can then use the Recent Pages extension to create something like this, which you'll put in, e.g. Template:New articles at PolyWiki‎:

<recent prop="short_summary" limit="1000" maxresults="36" minimum="1"/>

This will produce a result like this, when inserted into the appropriate main page template (e.g. one you can borrow from wikipedia:Main page):

New articles at PolyWiki.png

(See Extension:RecentChanges#Parameters for an explanation of the <recent> tag parameters used above.)

You can create wikitext like this, that uses a different page summary than what you put for the article lead. E.g., in this case it was necessary because the article lead had wikified words in the page title:

{{InvisiblePageSummary|The '''[[distinction between polyamory and swinging]]''' is that at the core, polyamory is about multiple, consensual, sexual, loving relationships while swinging is multiple, consensual, sexual relationships.}}The '''distinction between [[polyamory]] and [[swinging]]''' is that at the core, polyamory is about multiple, consensual, sexual, loving relationships while swinging is multiple, consensual, sexual relationships.

List of new unsummarized articles[edit]

Template:New articles without summaries will give you a result like this:

New articles needing summaries.png

CategoryGallery with captions generated from image description files (requires CategoryGallery extension)[edit]

You'll need Extension:CategoryGallery for this. Place image descriptions on your image file pages (e.g. File:Popsicle stick Eiffel Tower.jpg) using the same PageSummary template as before. Now, on the page where you're putting the gallery, use e.g.:

<catgallery cat="Aubry" bpdcaption="short_summary" />

The result is as follows (note how the captions are generated using the metadata you saved on each image page):

BedellPenDragon gallery.png

Troubleshooting[edit]

When I use <randompageincategory> in a nested table I get a bunch of repeating nested tables.[edit]

Yeah, the problem there is that the pages that are transcluding the category are being included in the pool of pages from which one is randomly selected. When one of those transcluding pages gets picked, you end up with those repeating nested tables. There are two possible solutions, the first of which is probably superior.

  1. Put in the template that adds your data to the page_props table something like {{#ifeq: {{NAMESPACE}}|Template||{{#ifeq: {{FULLPAGENAME}}|Main Page||[[Category:Featured articles]]}}}} to prevent it from adding adding templates and the main page to the category.
  2. Find out the page IDs of those transcluding pages and then use the "exclude" parameter. E.g., exclude="1,26" if you're trying to exclude pages 1 and 26. It's an awkward solution and it'll mess up if, for instance, you delete one of those pages and undelete it, giving it a new page ID. See Special:MyLanguage/Extension:BedellPenDragon#With_reference_to_.3Crandompageincategory.3E.2C_why_does_the_.22exclude.22_parameter_have_users_specify_page_IDs_rather_than_page_titles.2C_and_why_isn.27t_there_a_.22namespace.22_parameter.3F.

The main page or templates are appearing in Special:Glossary, Special:EssayList, Special:MiscellanyList, Special:QuoteList or Special:VideoList.[edit]

You need to add to the template that's transcluded to the main page or the templates, {{#ifeq: {{FULLPAGENAME}}|Main Page||{{#ifeq: {{NAMESPACE}}|Template||{{#setbpdprop: ... }}}}}} to exclude the main page and templates from being added to the glossary, essay list, or quote list.

These templates aren't categorizing anything properly and as a result nothing is being picked by <randompageincategory>.[edit]

This issue sometimes comes up when you have a template on the page (e.g. Template:FESummary, the template that adds pages to Category:Featured essays) that only puts it in the category if the page is in a certain namespace (e.g. the Essay: namespace). The purpose of this is to avoid putting the Template:FESummary page in the category If this is the situation, did you remember to create the namespace using $wgExtraNamespaces? E.g. if it's a featured essay, did you create an Essay: namespace or did you accidentally create your essay in mainspace?

This stuff is not behaving the way I'd expect.[edit]

When in doubt, purge your caches.

I deleted a page and now it's showing up in these "new x" RecentPages feeds. How do I get rid of it?[edit]

This is tricky. A workaround would be to do some sort of SQL query to find out what item in page_props has a pp_page that doesn't match up with any page.page_id, and then delete that row from page_props. But I don't know how to construct that query.

FAQ[edit]

I want to have a random article or an excerpt thereof (if it's a long article) display on the main page, sort of like wikipedia:Wikipedia:Today's featured article. Is this the right extension to use?[edit]

It depends on exactly what you're trying to accomplish:

  • Do you want to have any article on the wiki, regardless of quality, be eligible to appear on the main page, with the only standard being (perhaps) that it's of a certain minimum length? E.g., do you have such a large selection of articles you want to be eligible to be displayed as featured articles that it would be impracticable to maintain a centralized list or to add them as members of a Category:Featured articles? Then Extension:Blurb might be the extension you want.
  • Do you have a pretty short list of articles that you want to have be eligible to appear on the main page, and you don't mind editing a page containing a centralized list every time you want to add or remove articles from the list? Then Extension:RandomSelection might be the one you want. See http://wiki.mises.org/wiki/Template:Featured_article for an example of RandomSelection in action.
  • Do you want to have articles be displayed as featured articles if and only if those articles are members of, say, Category:Featured articles? Then BedellPenDragon is the extension you want.

With reference to <randompageincategory>, why does the "exclude" parameter have users specify page IDs rather than page titles, and why isn't there a "namespace" parameter?[edit]

Developer laziness, and also the fact that categorylinks does not have the necessary fields to make it as simple a matter as just adding another condition to a SELECT database query. This extension was mostly designed for small wikis with only a few users, at most, who would need to know how to use that tag. Make good use of the PAGEID magic word to find out page IDs, if you need to. Then of course there's the API; see e.g. https://www.mediawiki.org/w/api.php?action=query&prop=pageprops&titles=Extension:BedellPenDragon . In the long run, page metadata features, perhaps involving Wikidata, are supposed to be developed that are better and more scalable.

Should this extension be rewritten to use a Summary: or Metadata: namespace instead of the page_props table?[edit]

It's an interesting idea (and Extension:ExplicitDescription does something like that), but then you'd need to make more than one edit, to more than one page, if you're changing both the page content and the page metadata. This isn't unheard of; for example, when you move a page, you already often have to make more than one change (i.e. (1) actually moving the page and (2) changing the page content to reflect the new title).

The fact that there might be other metadata besides just the page summary suggests that you might want to call it a Metadata: namespace. However, RationalWiki does have a Summary: namespace, mostly for discussion threads.

Unlike Extension:Advanced Meta, this extension doesn't have a separate description inputbox in the edit screen, but rather it uses description templates that are part of the page contents. Nor does it have a separate ext_meta table; instead, you clog up the page_props table. Why is that?[edit]

If you store the description stuff separately from the page content, then it complicates the process of importing it into another wiki, if you ever wanted to do that. It would be necessary to add new API functionality and/or modify the code implementing Special:Import and Special:Export. The way it is now, you can just transfer over the templates and page content and it works. I'm not saying that's the best solution, but any other solution would be more complicated and require further development.

This extension was mostly designed for small wikis, so it wasn't deemed necessary to create a new table. Certainly that might be a good idea if, say, this extension were to be used on Wikipedia, but I would hope WMF would come up with a more elegant metadata solution, since they've already decided to go the Wikidata route.

Why is there not a special page similar to Special:AllPages, except that it lets you list all the pages with their summaries or other metadata?[edit]

I've never been able to successfully do a JOIN in MediaWiki, except this one time when I hardcoded a raw SQL query into Extension:Chat (see the code that starts with if ( !empty ( $wgChatAdminGroups ) ) {). If I could figure out how to do the necessary JOIN or UNION or whatever it is that's necessary to implement this, I would do that. I'm really not all that skilled with that intermediate SQL stuff. If you can come up with the query, and better yet, show me how to use the database wrappers to implement the query, then I'll get crackalackin on that right away. See bugzilla:56604, by the way.

Should this extension be regarded as fixing bug 23016?[edit]

Sort of, but there are many possible ways to fix that bug, and it's not clear that this is the best way.

Why use this instead of Semantic MediaWiki?[edit]

Because SMW is buggy and its support website blows. SMW might be more powerful and easier to use, though, until you run into something that it's not capable of handling.

Why do I keep making typos when I type "bpdprop"?[edit]

It has a series of four very similar letters in a row. It's a finger-twister — like a tongue-twister, except that it plays out on your the keyboard. When the eye looks at it, it just sees a bunch of gobbledygook and doesn't realize when there's an error.

How do I call the glossary something else (e.g. "dictionary") and make the link Special:Dictionary instead of Special:Glossary?[edit]

Add this to LocalSettings.php:

$wgHooks['LanguageGetSpecialPageAliases'][] = 'onLanguageGetSpecialPageAliases';
function onLanguageGetSpecialPageAliases( &$specialPageAliases, $langCode ) {
        $specialPageAliases['Glossary'] = array( 'Dictionary' );
}

Known issues[edit]

  • If you include an inline external link, it won't work properly for some reason.

See also[edit]

References[edit]