Difference between revisions of "BattleTechWiki talk:SemanticMediaWiki"

m
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
==A lot of questions==
+
I'll try to spell out as simply as I can how to use Semantic Wiki to create a new sortable table or timeline. I'll try to be thorough without turning this page into a wall of text.  
Hy Revanche, greate to create this page for us, i make my first steps with the SemanticMediaWiki, but i have some questions, i talk to Seth and he fix some little thinks, but when i see the BattleMech Timetable created by himself, i have one critical view, we have the table and the 'Mech infobox is updated by the code, but not one link bring me directly to the Mech Timetable page, ok the tagged introduction, reintroced, ect. links bring my only to the year pages this is very good, but no link to BattleMech Timetable that use the semantic code there included today by Seth, i know the semantic is new, but i want to help to fix little thinks what i see or not see ;), this is not a critic but a point of view by myself, i think you know what i mean, greeting.--[[User:Doneve|Doneve]] 16:13, 15 February 2012 (PST)
 
:Ok, I fixed it so that all the years listed in the infobox will send people to the timetable page instead of the year page. They can still go to the year page by clicking the years on the time table.--[[User:Seth|Seth]] 19:40, 15 February 2012 (PST)
 
  
== Column size ==
+
==How does Semantic Wiki (results format) Work?==
 +
Semantic Wiki is much larger than just timelines and tables, but I'll just focus on those two things here. Basically how this works is that you have a inquiry on one page that searches the pages of a specific category for certain properties. For example, if I wanted to know the production year of every BattleMech listed on Sarna, I would tell the page to search the pages under the <nowiki>[[Category:BattleMechs]]</nowiki> category and to look for the property <nowiki>[[Production Year::]]</nowiki>. Here's what that would look like:
  
Seth, is there a way to restrict the column width? For example, the BM Timetable fills up the screen unnecessarily. How may that be adjusted?--[[User:Revanche|Revanche]] <sup>([[User_talk:Revanche|talk]]|[[Special:Contributions/Revanche|contribs]])</sup> 20:13, 15 February 2012 (PST)
+
<pre>{{#ask:[[Category:BattleMechs]]
:Ok, I changed the format from "broadtable" to just "table". --[[User:Seth|Seth]] 20:33, 15 February 2012 (PST)
+
|?Production Year
 
+
|format=table
==How to create a new results table==
+
|mainlabel=BattleMech Timetable
I'll try to explain how to create your own Semantic results table. If we take a look at one that's being used on the [[BattleMech Timetable]]:
+
|offset=0
<pre>
+
|limit=1
 +
}}</pre>
 +
which results in:
 
{{#ask:[[Category:BattleMechs]]
 
{{#ask:[[Category:BattleMechs]]
 
|?Production Year
 
|?Production Year
|?Extinction Era
 
|?Reintroduction Year
 
 
|format=table
 
|format=table
 
|mainlabel=BattleMech Timetable
 
|mainlabel=BattleMech Timetable
 
|offset=0
 
|offset=0
|limit=10
+
|limit=1
 
}}
 
}}
</pre>
+
 
That results in this:
+
Additionally, instead of searching the pages of a category, you can tell it to search a specific page for a property. I just have to replace <nowiki>[[Category:BattleMechs]]</nowiki> with <nowiki>[[Archer]]</nowiki> which results in:
{{#ask:[[Category:BattleMechs]]
+
 
 +
{{#ask:[[Archer]]
 
|?Production Year
 
|?Production Year
|?Extinction Era
 
|?Reintroduction Year
 
 
|format=table
 
|format=table
 
|mainlabel=BattleMech Timetable
 
|mainlabel=BattleMech Timetable
 
|offset=0
 
|offset=0
|limit=10
+
|limit=1
 
}}
 
}}
  
I'll explain line by line how this works:
+
==That's nice, but why is this useful?==
 +
A wiki like this is very large and a lot of information is repeated on many different pages. There are quite likely a number of pages that have been updated with current information while older information is still displayed on other pages. With this, you simply update the one page specific to the subject matter and that information is automatically updated on every other page that inquires about that property. Also, scrolling timelines are pretty cool.
  
This line tells the table what the overall topic will be. In this case this table will cover all pages that appear under the <nowiki>[[Category:BattleMechs]]</nowiki> category page. Other examples include <nowiki>[[Category:Assault BattleMechs]]</nowiki> or <nowiki>[[Category:Combat Vehicles]]</nowiki>. Additionally, you can try to limit results that are covered in two categories. For example, if you only wanted a table about Clan OmniMechs, then you would add two category tags to the #ask: line, <nowiki>[[Category:OmniMechs]]</nowiki> and <nowiki>[[Category:Clan General Battlemechs]]</nowiki>.
+
==Creating a Table From Scratch==
<nowiki>{{#ask:[[Category:BattleMechs]]</nowiki>
+
The first thing you will decide what information you want to display. I'll use the example of the list of Archons on the [[Archon]] pages as an example. The table there lists four main facts about them: Their name, when their reign began & ended, and which Archon they were descended from. Additionally, I will want to create a note column to define what the Lyran realm was called at the time since it has gone through several different changes. So I will need to create 4 properties for the table to look for. You don't create a property for their name. The names of the articles that you add the properties to (which is the same as the name of the Archon) is used to label the lists on the left hand column.
  
 +
===Creating a Property===
 +
To create a property, you simply type it into the search bar and press go. For example, I'll need to create two properties for the start and end of their reign, and a property for their descent. I'll call the first property "Reign Began", so I will type "Property:Reign Began" into the search bar and press go. I will be directed to a link to create a new page. Do so.
  
These three lines tell the table what specific properties it is looking for on the pages is the above category (categories). To add properties to a new page, use this tag <nowiki>[[property name::property]]</nowiki>, in this case I used <nowiki>[[Production Year::3010]]</nowiki> for the [[Adder]] page.
+
====Defining Your New Property====
<nowiki>|?Production Year</nowiki>
+
Now you should have a blank page called "Property:Reign Began". Now you need to tell that property what kind of property it is. Possible types include:
<nowiki>|?Extinction Era</nowiki>
+
*Page
<nowiki>|?Reintroduction Year</nowiki>
+
*Date
By default the results are displayed in alphabetical order of the page names in the left column, but it is possible to sort the table by using one of the following properties. To sort the table by production year, add these two lines:
+
*Text
<nowiki>|sort=Production Year</nowiki>
+
*Number
<nowiki>|order=descending (or ascending)</nowiki>
+
There are more examples, but these are the most useful ones. For additional property types, visit [http://semantic-mediawiki.org/wiki/Help:Properties_and_types this page about properties and types].
  
 +
For the property "Reign Began" I would probably choose to define it as a date. While it won't be a clickable link on the table to the year, I will be able to sort the table by the dates and display their reigns in a scrollable timeline. However, you may decide to to define it as a page so people can click it and go to the page for that given year. But since I am going to define it as a date, I add the following to the page and save it.
 +
<pre>[[Has type::date]]</pre>
 +
If I had decided to define it as a page instead, I would have added this instead:
 +
<pre>[[Has type::page]]</pre>
  
To display your results in a table, you would use either <nowiki>|format=table</nowiki> or <nowiki>|format=broadtable</nowiki> for a full page width table.
+
I'll repeat the process for the properties for their reign ending ("Property:Reign Ended"), their descent ("Property:Inherited From"), and notes ("Property:Notes"). I'll also define the "Reign Ended" property as a date (<nowiki>[[Has type::date]]</nowiki>) but I will define the "Inherited From" property as a page(<nowiki>[[Has type::Inherited From]]</nowiki>) and the "Name of the Realm" property as a text (<nowiki>[[Has type::Text]]</nowiki>).
<nowiki>|format=table</nowiki>
 
  
 +
===Inserting the Property Into the Page===
 +
Adding the properties to the page is fairly straight forward. To add the "Reign Began" property to an Archon page, you simply go to one, [[Robert Marsden]] for example and add this line to the page, "<nowiki>[[Reign Began::2340]]</nowiki>". The same is repeated for all the other properties you want to add, "<nowiki>[[Reign Ended::2375]]</nowiki>", "<nowiki>[[Inherited From::Nine Archons]]</nowiki>", and "<nowiki>[[Name of the Realm::Lyran Commonwealth]]</nowiki>.
  
This is the main label of the table.
+
====Inserting the Property Into the Page Cleanly and Quickly====
<nowiki>|mainlabel=BattleMech Timetable</nowiki>
+
If all you do is just type "<nowiki>[[Reign Began::2340]]</nowiki>", then you have done the minimum necessary to add the property to that page. But you have likely replaced an existing link to the page <nowiki>[[2340]]</nowiki> with the property, and now you can't click that number to go to the page for that year (because that property type is a date instead of a page). So a faster and cleaner way to add the properties to that page will be to use a template that uses hidden text. An example of this is what I did for the timeline on the [[Red Corsair]] article. For every planet the Red Corsair attacked, I added hidden text that added the properties I wanted to display on the timeline (check the page for [[Arc-Royal]] for example. What I did was use a template.
 +
 
 +
=====Using a Template to Add Hidden Properties=====
 +
In the interest of keeping you from falling asleep, I won't go into depth about how to create a template. Instead I'll just provide one and people can use it and adjust it to their needs.
 +
 
 +
======On the Template Page======
 +
 
 +
First I create a template by typing "Template:Archon Timeline" into the search bar and pressing "Go". I'm prompted to create a new page. I add the following to that page and press save:
 +
 
 +
<nowiki><span style="color: red; display:none; font-size: 0px;">[[Reign Began::{{{began}}}]][[Reign Ended::{{{ended}}}]][[Inherited From::{{{inherited}}}]][[Name of the Realm::{{{realm}}}]]</span></nowiki>
 +
 
 +
Notice the "font-size" is 0px. This is why the text will be hidden on pages you use this template on.
 +
 
 +
======On the Article Page======
 +
Now to use this template an article page, you use the following code:
 +
<pre>{{Archon Timeline
 +
|began=
 +
|ended=
 +
|inherited=
 +
|realm=
 +
}}</pre>
 +
Notice each line corresponds to a space in the template ("|began=" and "{{{began}}}" for example)?
 +
 
 +
So instead of adding "<nowiki>[[Reign Began::2340]]</nowiki>", "<nowiki>[[Reign Ended::2375]]</nowiki>", "<nowiki>[[Inherited From::Nine Archons]]</nowiki>", and "<nowiki>[[Name of the Realm::Lyran Commonwealth]]</nowiki> to the [[Robert Mardsen]] page, I would add this instead:
 +
<pre>{{Archon Timeline
 +
|began=2340
 +
|ended=2375
 +
|inherited=Nine Archons
 +
|realm=Lyran Commonwealth
 +
}}</pre>
 +
 
 +
You can simply paste the empty template onto each Archon page and quickly add the information instead of hunting in the paragraphs where you can hide the properties. It's much faster, trust me.
 +
 
 +
===Creating the Semantic Table===
 +
Now that that you have added all the properties to each of the Archon articles, you are ready to create your table. You're query will look like this.
 +
 
 +
<pre>{{#ask:[[Category:Archons]]
 +
|?Reign Began
 +
|?Reign Ended
 +
|?Inherited From
 +
|?Name of the Realm
 +
|sort=Reign Began
 +
|order=ascending
 +
|format=table
 +
|mainlabel=Archons of the Lyran Realm
 +
}}</pre>
  
 +
I'll explain it line by line:
 +
<pre>{{#ask:[[Category:Archons]]</pre> tells the table to look for your properties in the pages listed under the <nowiki>[[Category:Archon]]</nowiki>.
 +
<pre>|?Reign Began
 +
|?Reign Ended
 +
|?Inherited From
 +
|?Name of the Realm</pre> Tells it what properties to look for.
 +
<pre>|sort=Reign Began
 +
|order=ascending</pre>tell it to sort the results in the order of when their reign began instead of listing the Archons in alphabetical order which is the default setting. You can set the order to "ascending" to list the first Archon at the top or "descending" to list the most recent Archon at the top.
 +
<|format=table
 +
|mainlabel=Archons of the Lyran Realm</pre>Two possible formats for the table are "table" that will keep the table as narrow as possible and "broadtable" which will tell the table to be as wide as your screen permits. The "mainlabel" is the name of your table at the top.
  
Generally, you would leave this at 0. If you set it to 5 for example, it would skip the first 5 results.
+
===Timeline===
<nowiki>|offset=0</nowiki>
+
Since you have date properties in your articles, it is possible to plot their reigns on a timeline like the one found on the [[Red Corsair]] and [[Sandbox]] page. Articles that have a single date will appear as a single dot on the timeline like in the [[Red Corsair]] page and articles with two date properties will appear as an event line like on the [[Sandbox]] page. The code used to display a timeline instead of table is very similar with only a few lines changed.
  
 +
<pre>{{#ask:[[Category:Archons]]
 +
|?Reign Began
 +
|?Reign Ended
 +
|?Inherited From
 +
|?Name of the Realm
 +
|format=timeline
 +
|timelineposition=middle
 +
|timelinebands=DECADE
 +
|timelinesize=150px
 +
}}</pre>
  
This determines how many results you want to show at any given time. I set it to 10 to keep this example manageable, but you can display up to 500 at a time.  
+
<pre>|format=timeline</pre> You change the format to "timeline" instead of "table" or "broadtable". Also "eventline" is very similar to "timeline" but it gives a dot for the beginning and ending date property instead of a solid line for the duration of the event. Also it has colors.
<nowiki>|limit=10</nowiki>
+
<pre>|timelineposition=middle</pre> This tells the timeline to display in the middle of the years displayed. Other settings include "start", "end", and "today" (I don't recommend ever using "today" since everything that happens in Battletech is centuries into our future.
 +
<pre>|timelinebands=DECADE</pre>This tells the timeline which date bands to use. "Decade" is the largest band available and best used for timelines that cover several decades or more. This is the setting used on the [[Sandbox]] page. Additional settings include YEAR, MONTH, WEEK, and DAY. You can use several bands like on the [[Red Corsair]] page, just be sure to list them from smaller increments to larger ones.
 +
<pre>|timelinesize=150px</pre>This defines how tall your timeline will be. By default it is 300px tall, but unless you have many events happening at the same time, 150px is plenty enough.
  
 +
==Refresh Tab Button==
 +
Any changes to make to properties on your article pages, like changing a year for example, will automatically be updated on the table or timelines, but they take time to do so on their own. If you want to force it to update immediately, click the "Refresh" tab button (not your browsers refresh button) near the top of the page next to the "edit" and "watch" buttons.
  
And this closes your table.
+
==Additional Resources==
<nowiki>}}</nowiki>
+
I'm happy to answer any questions you all might have or help out with a project. But I'm far from a subject matter expert. Here a few resources I've used to learn what I know.--[[User:Seth|Seth]] 22:22, 17 March 2012 (PDT)
 +
*[http://semantic-mediawiki.org/wiki/Help:Properties_and_types Properties and Type]
 +
*[http://semantic-mediawiki.org/wiki/Help:Table_format Table Format]
 +
*[http://semantic-mediawiki.org/wiki/Help:Timeline_format Timeline Format]
 +
*[http://semantic-mediawiki.org/wiki/Help:Result_formats Results Formats] (For additional formats besides tables and timelines)

Latest revision as of 21:57, 18 March 2012

I'll try to spell out as simply as I can how to use Semantic Wiki to create a new sortable table or timeline. I'll try to be thorough without turning this page into a wall of text.

How does Semantic Wiki (results format) Work?[edit]

Semantic Wiki is much larger than just timelines and tables, but I'll just focus on those two things here. Basically how this works is that you have a inquiry on one page that searches the pages of a specific category for certain properties. For example, if I wanted to know the production year of every BattleMech listed on Sarna, I would tell the page to search the pages under the [[Category:BattleMechs]] category and to look for the property [[Production Year::]]. Here's what that would look like:

{{#ask:[[Category:BattleMechs]]
|?Production Year
|format=table
|mainlabel=BattleMech Timetable
|offset=0
|limit=1
}}

which results in:

BattleMech TimetableProduction Year
Adder (Puma)3010
... further results

Additionally, instead of searching the pages of a category, you can tell it to search a specific page for a property. I just have to replace [[Category:BattleMechs]] with [[Archer]] which results in:

BattleMech TimetableProduction Year
Archer2474

That's nice, but why is this useful?[edit]

A wiki like this is very large and a lot of information is repeated on many different pages. There are quite likely a number of pages that have been updated with current information while older information is still displayed on other pages. With this, you simply update the one page specific to the subject matter and that information is automatically updated on every other page that inquires about that property. Also, scrolling timelines are pretty cool.

Creating a Table From Scratch[edit]

The first thing you will decide what information you want to display. I'll use the example of the list of Archons on the Archon pages as an example. The table there lists four main facts about them: Their name, when their reign began & ended, and which Archon they were descended from. Additionally, I will want to create a note column to define what the Lyran realm was called at the time since it has gone through several different changes. So I will need to create 4 properties for the table to look for. You don't create a property for their name. The names of the articles that you add the properties to (which is the same as the name of the Archon) is used to label the lists on the left hand column.

Creating a Property[edit]

To create a property, you simply type it into the search bar and press go. For example, I'll need to create two properties for the start and end of their reign, and a property for their descent. I'll call the first property "Reign Began", so I will type "Property:Reign Began" into the search bar and press go. I will be directed to a link to create a new page. Do so.

Defining Your New Property[edit]

Now you should have a blank page called "Property:Reign Began". Now you need to tell that property what kind of property it is. Possible types include:

  • Page
  • Date
  • Text
  • Number

There are more examples, but these are the most useful ones. For additional property types, visit this page about properties and types.

For the property "Reign Began" I would probably choose to define it as a date. While it won't be a clickable link on the table to the year, I will be able to sort the table by the dates and display their reigns in a scrollable timeline. However, you may decide to to define it as a page so people can click it and go to the page for that given year. But since I am going to define it as a date, I add the following to the page and save it.

[[Has type::date]]

If I had decided to define it as a page instead, I would have added this instead:

[[Has type::page]]

I'll repeat the process for the properties for their reign ending ("Property:Reign Ended"), their descent ("Property:Inherited From"), and notes ("Property:Notes"). I'll also define the "Reign Ended" property as a date ([[Has type::date]]) but I will define the "Inherited From" property as a page([[Has type::Inherited From]]) and the "Name of the Realm" property as a text ([[Has type::Text]]).

Inserting the Property Into the Page[edit]

Adding the properties to the page is fairly straight forward. To add the "Reign Began" property to an Archon page, you simply go to one, Robert Marsden for example and add this line to the page, "[[Reign Began::2340]]". The same is repeated for all the other properties you want to add, "[[Reign Ended::2375]]", "[[Inherited From::Nine Archons]]", and "[[Name of the Realm::Lyran Commonwealth]].

Inserting the Property Into the Page Cleanly and Quickly[edit]

If all you do is just type "[[Reign Began::2340]]", then you have done the minimum necessary to add the property to that page. But you have likely replaced an existing link to the page [[2340]] with the property, and now you can't click that number to go to the page for that year (because that property type is a date instead of a page). So a faster and cleaner way to add the properties to that page will be to use a template that uses hidden text. An example of this is what I did for the timeline on the Red Corsair article. For every planet the Red Corsair attacked, I added hidden text that added the properties I wanted to display on the timeline (check the page for Arc-Royal for example. What I did was use a template.

Using a Template to Add Hidden Properties[edit]

In the interest of keeping you from falling asleep, I won't go into depth about how to create a template. Instead I'll just provide one and people can use it and adjust it to their needs.

On the Template Page[edit]

First I create a template by typing "Template:Archon Timeline" into the search bar and pressing "Go". I'm prompted to create a new page. I add the following to that page and press save:

<span style="color: red; display:none; font-size: 0px;">[[Reign Began::{{{began}}}]][[Reign Ended::{{{ended}}}]][[Inherited From::{{{inherited}}}]][[Name of the Realm::{{{realm}}}]]</span>

Notice the "font-size" is 0px. This is why the text will be hidden on pages you use this template on.

On the Article Page[edit]

Now to use this template an article page, you use the following code:

{{Archon Timeline
|began=
|ended=
|inherited=
|realm=
}}

Notice each line corresponds to a space in the template ("|began=" and "{{{began}}}" for example)?

So instead of adding "[[Reign Began::2340]]", "[[Reign Ended::2375]]", "[[Inherited From::Nine Archons]]", and "[[Name of the Realm::Lyran Commonwealth]] to the Robert Mardsen page, I would add this instead:

{{Archon Timeline
|began=2340
|ended=2375
|inherited=Nine Archons
|realm=Lyran Commonwealth
}}

You can simply paste the empty template onto each Archon page and quickly add the information instead of hunting in the paragraphs where you can hide the properties. It's much faster, trust me.

Creating the Semantic Table[edit]

Now that that you have added all the properties to each of the Archon articles, you are ready to create your table. You're query will look like this.

{{#ask:[[Category:Archons]]
|?Reign Began
|?Reign Ended
|?Inherited From
|?Name of the Realm
|sort=Reign Began
|order=ascending
|format=table
|mainlabel=Archons of the Lyran Realm
}}

I'll explain it line by line:

{{#ask:[[Category:Archons]]

tells the table to look for your properties in the pages listed under the [[Category:Archon]].

|?Reign Began
|?Reign Ended
|?Inherited From
|?Name of the Realm

Tells it what properties to look for.

|sort=Reign Began
|order=ascending

tell it to sort the results in the order of when their reign began instead of listing the Archons in alphabetical order which is the default setting. You can set the order to "ascending" to list the first Archon at the top or "descending" to list the most recent Archon at the top.

<|format=table

|mainlabel=Archons of the Lyran RealmTwo possible formats for the table are "table" that will keep the table as narrow as possible and "broadtable" which will tell the table to be as wide as your screen permits. The "mainlabel" is the name of your table at the top.

Timeline[edit]

Since you have date properties in your articles, it is possible to plot their reigns on a timeline like the one found on the Red Corsair and Sandbox page. Articles that have a single date will appear as a single dot on the timeline like in the Red Corsair page and articles with two date properties will appear as an event line like on the Sandbox page. The code used to display a timeline instead of table is very similar with only a few lines changed.

{{#ask:[[Category:Archons]]
|?Reign Began
|?Reign Ended
|?Inherited From
|?Name of the Realm
|format=timeline
|timelineposition=middle
|timelinebands=DECADE
|timelinesize=150px
}}
|format=timeline

You change the format to "timeline" instead of "table" or "broadtable". Also "eventline" is very similar to "timeline" but it gives a dot for the beginning and ending date property instead of a solid line for the duration of the event. Also it has colors.

|timelineposition=middle

This tells the timeline to display in the middle of the years displayed. Other settings include "start", "end", and "today" (I don't recommend ever using "today" since everything that happens in Battletech is centuries into our future.

|timelinebands=DECADE

This tells the timeline which date bands to use. "Decade" is the largest band available and best used for timelines that cover several decades or more. This is the setting used on the Sandbox page. Additional settings include YEAR, MONTH, WEEK, and DAY. You can use several bands like on the Red Corsair page, just be sure to list them from smaller increments to larger ones.

|timelinesize=150px

This defines how tall your timeline will be. By default it is 300px tall, but unless you have many events happening at the same time, 150px is plenty enough.

Refresh Tab Button[edit]

Any changes to make to properties on your article pages, like changing a year for example, will automatically be updated on the table or timelines, but they take time to do so on their own. If you want to force it to update immediately, click the "Refresh" tab button (not your browsers refresh button) near the top of the page next to the "edit" and "watch" buttons.

Additional Resources[edit]

I'm happy to answer any questions you all might have or help out with a project. But I'm far from a subject matter expert. Here a few resources I've used to learn what I know.--Seth 22:22, 17 March 2012 (PDT)