Rozšíření:Page Forms/Průvodce pro rychlé seznámení

From mediawiki.org
This page is a translated version of the page Extension:Page Forms/Quick start guide and the translation is 29% complete.

Takže, nainstalovali jste na svůj web veškerý potřebný software. Co teď? Teď je ta správná chvíle vytvořit sadu stránek, přes kterou budete moct spravovat, zobrazovat, přidávat a upravovat svoje data; a jejím prostřednictví bude možné velice jednoduše generovat nejrůznější wiki stránky.

Nejprve si musíte ujasnit jak jsou strukturovaná vaše data, to je prvním krok, co musíte udělat. Jaké typy stránek budou zapotřebí? Jaká data budou obsahovat? To vše lze dodatečně změnit, ale už od počátku byste měli mít nějaký výchozí plán. Jakmile je budete takový plán mít (v ideálním případě je dobré si ho někam napsat), můžete přejít k vytvoření potřebných stránek wiki. Bude potřeba založit, nebo upravit stávající stránky pro šablony a formuláře, vymyslet pro ně vhodnou kategorii a (pokud používáte sémantickou MediaWiki) i jaké budou mít vlastnosti.

Klidně si je můžete vytvořit postupně sami, ale proč byste to dělali, když máte k dispozici pomocné formuláře, které vám s vytvořením těchto stránek pomohou? Jak na to jít, záleží také na tom, jaká další rozšíření používáte:

Používáte-li rozšíření Cargo

Special:CreateClass - nejjednodušší cesta

The page Special:CreateClass, defined by Page Forms, provides a single helper form to define everything about a data "class" in one place. If you fill out the fields and hit "submit", the page will create the necessary template, form and category pages automatically. Then you can go to the form page that was created, and start entering data.

If not all the pages seem to be getting created, it could be that your job queue lacks enough memory. See the job-queue-related item here for how to add more memory.

The more comprehensive way

You should take the following steps:

  • Create templates. Šablona zajišťuje zobrazení dat na stránce, obsahuje značky pro uložení dat v Cargo tabulkách a (obvykle) také kategorizuje stránku do určité kategorie, a určuje také jakého bude typu. Pro každý typ stránky obvykle existuje pouze jedna šablona, ale některé typy stránek mohou současně používat i několik šablon. Šablonu lze také použít k agregaci, kdy se zobrazí seznam všech ostatních stránek, které mají k této stránce určitý vztah. Pro vytvoření šablony (či šablon) použijte stránku Special:CreateTemplate.
  • Create forms. Teď můžete vytvářet formuláře, které uživatelům umožní snadno přidávat a upravovat obsah stránek nejrůznějšího typu. Pro každý typ stránky by měl existovat pouze jeden formulář; ten vloží data jako paramtery šablony (nebo šablon), které tento typ stránky bude obsahovat. Podobně jako v předchozím případě, i pro zakládání formulářů je k dispozici speciální stránka: Special:CreateForm.
  • Create categories. Alespoň jedna šablona v každém formuláři by měla zajišťovat kategorizaci každého nového článku, který se přes tento formulář vytvoří. Pro každou takovou kategorii byste měli vytvořit stránku a nastavit pro ni výchozí formulář, aby bylo možné každou stránku z této kategorie možné dodatečně editovat přes formulář, který ji vytvořil. Nejjednodušší způsob, jak to udělat, je použít stránku Special:CreateCategory.
  • Enable links to forms. Kromě vytvoření kategorie s výchozím formulářem byste měli podniknout i další kroky, abyste uživatelům umožnili přístup k vámi vytvořeným formulářům. Patří mezi ně i přidání odkazů pro přidání dat do postranního panelu a jinam, a také použití funkcionality #formredlink, aby červené odkazy na neexistující stránky volaly odpovídající formulář pro jejich vytvoření. To vše je vysvětleno v části Propojení formulářů.
  • Add links on sidebar and elsewhere. Obsah postranního panelu (je dán obsahem stránky "MediaWiki:Sidebar") můžete upravit tak, aby obsahoval odkazy pro přidání jednotlivých typů dat. Můžete přidat také odkaz na stránku Special:Drilldown, což je stránka kterou poskytuje Cargo, která umožňuje snadné zobrazení všech údajů wiki najednou. Tyto odkazy ale můžete umístit i na hlavní stránku a jinam.
  • Add data. A teď můžete začít vkládat data! Stačí přejít na formulář a začít se zakládáním stránek.
  • Customize. Jakmile už máte jednou tuhle sadu stránek vytvořenou, můžete si ji přizpůsobovat dle libosti - měnit vzhled celé wiki, různých šablon a formulářů, přidávat a měnit pole, či přidávat a upravovat dotazy.

Používáte-li rozšíření Semantic MediaWiki

Special:CreateClass - nejjednodušší cesta

The page Special:CreateClass, defined by Page Forms, provides a single helper form to define everything about a data "class" in one place. If you fill out the fields and hit "submit", the page will create all the necessary property, template, form and category pages automatically. Then you can go to the form page that was created, and start entering data.

If not all the pages seem to be getting created, it could be that your job queue lacks enough memory. See the job-queue-related item here for how to add more memory.

The more comprehensive way

You should take the following steps:

  • Create properties. The basic building blocks of any semantic site are the connections between data, which in Semantic MediaWiki are known as properties.

A property is used to specify a single piece of information about the topic of this page. Every property should be defined on your wiki, with a page in the "Property:" namespace. Create each property by going to the Special:CreateProperty page.

  • Create templates. A template sets the display of the data on a page, holds the markup to turn the data into actual semantic information, and (often) defines the page as being of a certain category, and thus of a certain page type.

There will generally be one template per page type, although sometimes a single page type will contain more than one template. A template can also be used for aggregation, by displaying a list of all other pages that have a certain relationship to this page (see the inline queries documentation for much more information on this). Create the template(s) by going to the Special:CreateTemplate page.

  • Create forms. Now you can create forms to allow users to easily add and edit pages of various types.

There should be one form per page type; the form will populate the template or templates that this page type contains. As before, there's a special page to create new forms: Special:CreateForm.

  • Create categories. One template in each form should tag each article that the form creates as being part of a certain category.

You should create a page for each such category, and specify a default form for it so that every article is automatically editable with the same form that created it. The easiest way to do that is by using the Special:CreateCategory page.

  • Enable links to forms. Besides creating categories that have a default form, there are other steps you should take to enable users to access the forms that you have created.

These include adding links to add data in the sidebar and elsewhere, and using #formredlink in order to have red-links to nonexistent pages point to a form for creating them. These actions are all explained in the section "Linking to forms".

  • Add links on sidebar and elsewhere. The sidebar (which, for English-language wikis, can be edited at the page "MediaWiki:Sidebar") should hold links to add each of the data types, and to the categories for each of these data types as well.

You can also include such links on the main page and elsewhere.

  • Add data. Now you can start entering data!

Just go to the form page(s), and start creating pages.

  • Customize. Once the structure is in place, you can customize all you want - changing the look-and-feel of the entire wiki, of the various templates, and of the forms, adding and changing fields and adding and changing inline queries.

Příklad

Projděme si konkrétní příklad nastavení wiki, používající rozšíření Page Forms, a to tím "komplexnějším způsobem", tj. od základu. Řekněme, že chcete vytvořit wiki, která bude zobrazovat všechny knihy, které máte doma. Ok. Projděme si tedy postupně všechny předchozí uvedené kroky, přičemž si ukážeme, jak se budou některé části v tomto postupu lišit v závisloti na tom, zda-li použijete Cargo nebo Semantic MediaWiki.

1. Rozhodněte si jak budete mít strukturovaná data. Na své wiki chcete mít dva typy stránek: jeden bude pro knihy a druhý pro autory. Každá stránka knihy by měla obsahovat její název, jméno autora (a spoluautorů), žánr (nebo žánry), rok vydání a počet stran. Na stránce každého autora by mělo být uvedeno jeho jméno, země původu a seznam všech knih, které napsal a které vlastníte.

2. Nastavte vlastnosti.

Používáte-li rozšíření Cargo Používáte-li Semantic MediaWiki
Cargo, s vlastnostmi nepracuje. Pro knihy není pro název potřeba žádnou vlastnost dělat, protože název stránky bude stejný jako název knihy.

Zbývají čtyři pole:

  • Author(s) - using the "Create a property" page (at Special:CreateProperty), you create a property called "Was written by", of type "Page" (since each author will have their own page).
  • Genre - you create a property called "Has genre", of type "Text", and give it allowed values such as: "Art, Cookbook, Fiction, History, Poetry, Science".
  • Year of publication - you create a property called "Was published in year", of type "Number".
  • Number of pages - you create a property called "Has number of pages", of type "Number".

For author pages, you only need to create one more property:

  • Country of origin - you create a property called "Is from country", of type "Text".

3. Create templates. You need to create two templates, one for books and one for authors, both at the "Create a template" page at Special:CreateTemplate.

First, books:

With Cargo With SMW
At Special:CreateTemplate, set the template name to be "Book", and set the category name to be "Books".

You add to it four fields, and for each field you specify at least three values: its field name in the template source code, its display label on each page, and its type. There are a few other values you can set, but they will not be necessary for most of these fields.

  1. For the first field, set the field name to be "Authors", the label to be "Author(s)" and the type to be "Page".
You also need to check the box indicating that this field can hold a list of values (since a book can have more than one author).
  1. Click Add field and then, for the second field, the three values to be "Genres", "Genre(s)" and "String".
You again need to check the box indicating that this field can hold a list of values. You should then specify the set of allowed values; this can be done as either a simple list, or a hierarchy. You could set a simple list like "Art, Cookbook, Fiction, History, Poetry, Science", and so on; or you could set a complete hierarchy, which could look like:
* Fiction
** Science fiction
*** Cyberpunk
** Historical fiction
...and so on.
3. Click Add field and then, for the third field, set the values to be "Year", "Year of publication" and "Date" (a better choice than "Integer").
4. Click Add field and then, for the fourth field, set them to be "Number of pages", "Number of pages" and "Integer".
5. Click the Save page button.
At Special:CreateTemplate, set the template name to be "Book", and set the category name to be "Books".

You add to it four fields, and for each field you specify three values: its field name in the template source code, its display label on each page, and the semantic property it populates.

  1. For the first field, set the field name to be "Authors", the label to be "Author(s)" and the semantic property to be "Was written by", and check the box indicating that this field can hold a list of values (since a book can have more than one author);
  1. Click Add field and then, for the second field, set the three values to be "Genres", "Genre(s)" and "Has genre", and also check the box for a list of values;
  1. Click Add field and then, for the third field, set the values to be "Year", "Year of publication" and "Was published in year";
  1. Click Add field and then, for the fourth field, set the values to be "Number of pages", "Number of pages" and "Has number of pages".
  1. Click the Create button.

Next, create the template for Authors - using the "Create a template" page, you create a template called "Author", and set it to define the category "Authors".

With Cargo With SMW
  1. Just add to this template one field, for which you set the three values to be "Country", "Country of origin" and "Page".
  2. Click the Save page button.
  1. Just add to this template one field, for which you set the three values to be "Country", "Country of origin" and "Is from country".
  2. For this template, you also fill out the "Aggregation" fields in the form, since you want each author page to list all the books the author has written. Under "Semantic property", you select "Was written by", and for "Title for list" you put "Books by this author".
  3. Click the Save page button.

4. Create forms. You need to create two forms, one for books and one for authors:

  • Books - using the "Create a form" page (at Special:CreateForm), you make a form called "Book", select the template "Book" and click the Add button. You could also optionally add a section for the plot of the book - to do that, add a section (not a template) called "Plot". You do not do any further customizations on this form, but just save the form once you have created it.
  • Authors - using the "Create a form" page, you make a form called "Author", and add to it the template "Author". As before, you do not do any further customizations - you just save the page.

5. Create categories. You need to create two categories, one for books and one for authors; you have already specified these categories' names before:

  • Books - using the "Create a category" page (at Special:CreateCategory), you make a category called "Books", and give it the default form "Book".
  • Authors - using the "Create a category" page, you make a category called "Authors", and give it the default form "Author".

6. Enable links to forms.

With Cargo With SMW
In the text for the Book template (at Template:Book) find the portion of the display containing the tag:
{{{Authors|}}}

Replace this with something like:

{{#arraymap:{{{Authors|}}}|,|x|{{#formredlink:target=x|form=Author}} }}
The text for the Book template (at Template:Book) most likely has a portion that looks like
{{#arraymap:{{{Authors|}}}|,|x|[[Was written by::x]]}}

Replace this with something like

{{#arraymap:{{{Authors|}}}|,|x|{{#formredlink:target=x|form=Author}}{{#set:Was written by=x}}}}

This will make links to author pages that don't exist yet point to the form for creating those pages.

7. Add data. Using the new "Book" form (at Form:Book), you create pages for some books; you check to make sure that both the form and the resulting pages look alright. Each book page will now have a red link to its author, that should point to the "Author" form for adding that author (you may need to refresh the page for the right link to show up). You can then add a few authors, either through these links or from the form page directly, to make sure that this setup works correctly too. Each created author's page should show a list of the books you've saved that have that person as the author.

8. Add links on sidebar and elsewhere. Your structures are now all set up, and you can add links to the sidebar for easy adding and viewing, by modifying the page MediaWiki:Sidebar (or its equivalent if you're using a language other than English). You can add links to the "Book" and "Author" forms to make it easy to add new ones. You could also link to Special:Drilldown (if you have Cargo installed), or Special:BrowseData (if you have the Semantic Drilldown extension installed), to let users view all the data at a glance.

Using Page Schemas

The Page Schemas extension is specifically intended for the automated creation of data structures, including forms. Its big advantage over the standard PF helper forms is that it can be used to create and modify these data structure pages many times, not just create them one time. It can be used with either Cargo or Semantic MediaWiki installed, or with neither one installed. If Cargo and/or SMW are installed, the Page Schemas form will include many additional form fields in order to create the additional tags needed. To create a page schema, you need to go to the category page (whether or not it has been created yet), go to the tab action for creating that page's schema, fill out the form, then go the tab action for generating pages based on that schema. See the Page Schemas documentation for more information.

Quick reference guides

There are two quick reference guides, or "cheat sheets", suitable for printing, that contain helpful information about Page Forms (though in both cases they still refer to it as "Semantic Forms"), among other extensions:

  • The Cargo quick reference guide - in PNG and PDF formats
  • The Semantic MediaWiki quick reference guide - can be found here, in PNG (image), PDF and SVG formats