Editing
Brighter Shores:Style guide/Semantic MediaWiki
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Shortcut|BS:SMW}} '''Semantic MediaWiki''' is an excellent tool for creating retrievable data across every page. This project page aims to standardise the usage of SMW. For more details on how to use SMW, see [https://www.semantic-mediawiki.org/wiki/Help:User_manual the manual]. ==Declaring attributes== Most properties should be defined in infoboxes or other templates. In the few cases where this needs to be done inline, use {{T|Set}}. ==Fetching data== All attribute requests should be done via wrapper templates. These will be watched by an abuse filter that warns and prevents editors from changing dynamic data. The primary template used to fetch data inline is {{T|Get}}. For more complex data display, see [https://www.semantic-mediawiki.org/wiki/Help:Inline_queries #ask and #show in the manual]. ==Property pages== Property pages are where data types of the properties are defined. They should also include a short description and a list of what modules/templates automatically set the property. This can all be done using the {{T|property}} template. <code><nowiki>{{Property|Name=|type=|desc=|templates=}}</nowiki></code> ==Cheatsheet== ===Defining attributes=== {| class="wikitable" ! Code ! Display ! Function |- | <code><nowiki>[[foo::bar]]</nowiki></code> | [[foo::bar]] | Defines the property "foo" as bar and creates a link to [[bar]] |- | <code><nowiki>[[foo::bar|baz]]</nowiki></code> | [[foo::bar|baz]] | Defines the property "foo" as bar and creates a link to [[bar]] on the text "baz" |- | <code><nowiki>[[foo::bar| ]]</nowiki></code> | [[foo::bar| ]] | Defines the property "foo" as bar and creates no text |- | <code><nowiki>{{#set:foo=bar}}</nowiki></code> | {{#set:foo=bar}} | Defines the property "foo" as bar and displays nothing. Multiple properties can be defined this way. '''Note''': Use {{T|Set}} if defining properties in the content namespaces. |- |<syntaxhighlight lang="lua"> -- setup data table - standard key-value pairs where key is property name and value is property value local data1 = { foo = 'bar', ['Has property2'] = 'value2' } -- set the properties local result1 = mw.smw.set(data1) if result1 == true then -- everything fine else -- error message is in result1.error end -- setup data table - an array of strings, in format 'propname=propvalue' local data2 = { 'foo=bar', 'Has property2=value2' } -- set the properties local result2 = mw.smw.set(data2) if result2 == true then -- everything fine else -- error message is in result2.error end </syntaxhighlight> | | Used in lua modules to set data, similarly to the #set parser function - all methods are equivalent, so use whichever is easier for the module at the time. See [https://github.com/SemanticMediaWiki/SemanticScribunto/blob/master/docs/README.md SemanticScribunto documentation] for more information. |- |<syntaxhighlight lang="lua"> -- setup data table - multiple property values for one property local data3 = { foo = { 'bar', 'baz', 'qok' } } -- set the properties local result3 = mw.smw.set(data3) if result3 == true then -- everything fine else -- error message is in result3.error end </syntaxhighlight> | | As above, but setting multiple values to the same property. |} ===Retrieving attributes with #ask=== {| class="wikitable" ! Code ! Display ! Function |- | <code><nowiki>[[Category:Foo]]</nowiki></code> | [[Brighter Shores:Semantic MediaWiki cheatsheet/examples#category|Example]] | Finds all pages that are in category "foo" |- | <code><nowiki>?foo</nowiki></code> | [[Brighter Shores:Semantic MediaWiki cheatsheet/examples#?Property|Example]] | Shows the property "foo" of all results |- | <code>limit=X</code> | [[Brighter Shores:Semantic MediaWiki cheatsheet/examples#limit|Example]] | Confines the displayed results to limit X |- | <code>offset=X</code> | [[Brighter Shores:Semantic MediaWiki cheatsheet/examples#offset|Example]] | Begins the search at an offset of X |- | <code><nowiki>[[foo::bar]]</nowiki></code> | [[Brighter Shores:Semantic MediaWiki cheatsheet/examples#Property:query|Example]] | Finds all pages that contain a property of "foo" that is equal to "bar" |- | <code><nowiki>[[foo::!bar]]</nowiki></code> | [[Brighter Shores:Semantic MediaWiki cheatsheet/examples#Property:!|Example]] | Finds all pages that contain a property of "foo" that is not equal to "bar" |- | <code><nowiki>[[foo::>X]]</nowiki></code> | [[Brighter Shores:Semantic MediaWiki cheatsheet/examples#Property:gte|Example]] | Finds all pages that contain a property of "foo" that is greater than or equal to X |- | <code><nowiki>[[foo::>>X]]</nowiki></code> | [[Brighter Shores:Semantic MediaWiki cheatsheet/examples#Property:gt|Example]] | Finds all pages that contain a property of "foo" that is greater than X |- | <code><nowiki>[[foo::<X]]</nowiki></code> | [[Brighter Shores:Semantic MediaWiki cheatsheet/examples#Property:lte|Example]] | Finds all pages that contain a property of "foo" that is less than or equal to X |- | <code><nowiki>[[foo::<<X]]</nowiki></code> | [[Brighter Shores:Semantic MediaWiki cheatsheet/examples#Property:lt|Example]] | Finds all pages that contain a property of "foo" that is less than X |- | <code><nowiki>[[foo::bar||baz]]</nowiki></code> <code><nowiki>[[foo::bar]] OR [[foo::baz]]</nowiki></code> | [[Brighter Shores:Semantic MediaWiki cheatsheet/examples#Property:or|Example]] | Finds all pages that contain a property of "foo" that is "bar" or "baz" |} ====Lua==== For details on fetching information via lua, see [https://github.com/SemanticMediaWiki/SemanticScribunto/blob/master/docs/mw.smw.ask.md#result mw.smw.ask documentation]. ===Retrieving attributes with #show=== {| class="wikitable" ! Code ! Display ! Function |- | <code><nowiki>{{#show:Bar|?foo}}</nowiki></code> '''Note:''' Use <code><nowiki>{{Get|Bar|foo}}</nowiki></code> | [[Brighter Shores:Semantic MediaWiki cheatsheet/examples#show|Example]] | Shows the property "foo" of page [[Bar]] |- |} ==See also== * [[Special:Ask]] * [https://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki Semantic MediaWiki's official website] * {{Wp|Semantic MediaWiki}} on Wikipedia {{Style guides}}
Summary:
Please note that all contributions to Brighter Shores Wiki are considered to be released under the CC BY-NC-SA 3.0 (see
Brighter Shores:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Navbox
(
edit
)
Template:Shortcut
(
edit
)
Template:Style guides
(
edit
)
Template:T
(
edit
)
Template:WP
(
edit
)
Template:Wp
(
edit
)
Module:Navbox
(
edit
)
Module:Shortcut
(
edit
)
Module:T
(
edit
)
Module:Tnavbar
(
view source
) (semi-protected)
Module:Yesno
(
view source
) (semi-protected)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Project page
Discussion
British English
Views
Read
Edit source
View history
More
Refresh
Search
Discord
Discord
Navigation
About us
User help
Random page
Recent changes
Chopsticks Hickory Cutlery
5m
ago
-
Fyri
Guard Studded Legs
9m
ago
-
J41L-B8
Guard Studded Helmet
10m
ago
-
J41L-B8
Forks Hickory Cutlery
11m
ago
-
Fyri
Show more...
Brighter Shores
Professions
Factions
Episodes
Premium Pass
Monsters
Quests
Community
Policies
Tools
What links here
Related changes
Special pages
Page information