Bücher online kostenlos Kostenlos Online Lesen
Working With MediaWiki

Working With MediaWiki

Titel: Working With MediaWiki
Autoren: Yaron Koren
Vom Netzwerk:
content like RSS viewers, can’t be added by default into MediaWiki. To get around this problem, a staggering array of extensions have been created, tasked with embedding specific players and widgets. Of the around 1,000 extensions listed on mediawiki.org, 44 are in the "Video player extensions" category; and around 12 exist for YouTube alone. Each one embeds into the wiki page some variation of the required HTML and JavaScript. The need for all of these ended, however, in 2008, when the Widgets extension was released.
    The Widgets extension is simple in concept: it allows for creating bits of custom HTML and JavaScript that can be embedded on a page. Each snippet of HTML and JavaScript, representing a single "widget", is stored directly within the wiki, in a page in the "Widget:" namespace.
    Widgets can also store code, in the Smarty language — a PHP-based “template engine”. This lets widgets modify the output with parameters, and use “if” calls and the like.
    Due to the obvious security danger of allowing free HTML and JavaScript in pages, editing in the “Widget:” namespace is restricted to users in the ’mediawikiwidgets’ group.
    There is no need to “re-invent the wheel”, and a large number of pre-defined widget pages already exist for the Widgets extension, and can be viewed at mediawikiwidgets.org. These represent video players, audio players, RSS readers, displays of information from individual websites like Facebook and Amazon, and others.
    To display YouTube videos, for instance, you just have to go to this page:
http://mediawikiwidgets.org/Widget:YouTube
    There, click on “View source”, copy the entire contents, and paste it to the page “Widget:YouTube” on your wiki. After that, embedding a video in a page is just a matter of adding something like:
{{#widget:YouTube|id= video ID }}
    ...to the page, where "video ID" is YouTube’s own ID for the video, viewable in the URL. Each widget can define as many parameters as it wants; the YouTube defines only one, for the ID. There are other parameters that this widget could have had, though: YouTube allows for settings for its embedded videos such as the color of a border rectangle, for example. Part of the beauty of the Widgets extension is that you can modify a widget yourself, once it’s on your wiki, in order to, among other things, add more parameters to it.
    Widgets don’t necessarily have to involve embedded media of any kind -- after all, they’re simply a mechanism for creating text based on a set of parameters. One interesting widget, which is already pre-defined on mediawikiwidgets.org, is “Short link”, which takes in a URL and produces a link showing only the domain of that URL. So passing in “http://123.com/abc” would display a link to that URL that read simply “123.com” — a convenient way of shortening long links.

21  Importing and exporting
    There are two ways of using one system’s data in another: you can either query system A’s data in system B, or you can import the data from A into B. The right answer depends on where you want the data to “live” in the future. Ideally, any piece of data shouldn’t be stored in more than one place, because data redundancy can quickly lead to inconsistent data, since the data can get modified anywhere it resides. So if you import data from one system to another, presumably the data will at the same time go away in the old one.
    (There are exceptions to that rule, and one extension, “Push”, lets you dynamically move content between two wikis; we’ll get to that later.)
    We covered both the querying of data within MediaWiki, and the querying of MediaWiki’s data in other systems, in the last chapter. This chapter is instead focused on actually moving content into, out of or between wikis. There are essentially three kinds of possible moves: moving contents between two MediaWiki wikis; moving contents from another system, wiki or otherwise, into MediaWiki; and moving contents from MediaWiki into another system. Let’s go through these one at a time.

Moving content between two MediaWiki systems
    This is conceptually the simplest of the three kinds of moves. If you’re just trying to move a wiki to a different location, then the best approach is to zip up all the MediaWiki files, PHP and otherwise (going with the top directory will get them all), do a dump of the wiki’s database, and then un-archive them both in the new location. Give or take a few
Vom Netzwerk:

Weitere Kostenlose Bücher