This is an old revision of the document!
Batocera-specific Code Snippets
In-links
In-links refer to linking to another page on this wiki. When doing so, you don't need to include the "https://wiki.batocera.org/" at the start, just the namespace, followed by a colon (:), and then the page name. For example:
Here's a link to the syntax page in the "wiki" namespace.
which is coded as:
[[wiki:syntax|Here's a link to the syntax page in the "wiki" namespace.]]
In-links to the null namespace
If you're referring to a page that doesn't belong to a namespace, remember to use a lone colon at the start so it will work no matter which page the user is looking at it from. For example:
This in-link won't work from particular other pages as there's no colon. But this one will always work.
which is coded as:
[[access_the_batocera_via_ssh|This in-link won't work from particular other pages as there's no colon.]] [[:access_the_batocera_via_ssh|But this one will always work]].
You are encouraged to use in-links over hard-coded links, as that will allow the wiki to automatically update the link should the page name ever change in the future.
Section linking
If you'd like to link to a particular section in the page, add a hash (#) followed by the name of the section in all lower-case and with under-scores replacing spaces (special characters are usually just completely omitted). For example:
This links to the "links" section of the syntax page.
which is coded as:
[[wiki:syntax#links|This links to the "links" section of the syntax page.]]
For links that simply refer to another section in the same page that you're current on, you only need to specify the header name preceded by a hash:
[[#in-links|section in the same page that you're current on]]
Sections are identified by their name alone, irrelevant of how nested they are inside of other headers. If there are multiple sections with the same name in the same page, they are identified by having a digit added to the end of them.
You can always click the little “linking” icon that appears when you hover your mouse over the header for that section.
Embedded images
Images can be added to a page if needed. Keep in mind that visuals should be in addition to the written explanation, not a replacement. The syntax is the following:
{{:image-name?Size|Alternative Text}}
For example, the “north button” image is located at https://wiki.batocera.org/_media/wiki:north.png (wiki:north.png is the name), it is the North button on a controller, which corresponds to the X Button on a SNES pad, and if we want to display this image at a 20 width pixel size, we need to put {{:wiki:north.png?nolink&20|North button (X SNES)}} and the wiki will show
instead. Also if the image fails to load, or if we use the mouse cursor on it, it'll display “North button (X SNES)”; this is important for accessibility too.
Icons can be created and distributed for free with: https://logomakr.com/
Scalable Vector Graphics (SVG) files are also good for creating/editing iconography. These can be edited with Illustrator or the freely distributed Inkscape.
Sample SVG file:
Inter-wiki links
Let's face it, Wikipedia is a great source of information for technical aspects at times. If you ever need to link to a Wikipedia page specifically, you should use the "wp>(title of Wikipedia page)" format for its link. For example:
Here's their page on home video-game console generations.
which is invoked by
[[wp>Home_video_game_console_generations|Here's their page on home video-game console generations.]]
Note that you don't need to include the full URL, just the Wikipedia page title. It also appears with the Wikipedia icon, isn't that neat?
Unformatted code
Code can be displayed by using the <code>print (“Hello World”)</code> but it will lead to a grey box. So for some one liners you can try to use
%%print ("Hello World")%%
You can create downloadable files by specifying its file-name as a parameter in the <code> header along with its syntax. eg.
<code java script.js> Here is my Javascript code. </code>
would become
- script.js
Here is my Javascript code.
If you just want a raw text file without syntax highlighting, use a hyphen (-) as your syntax.
No formatting
It is also possible to ask the wiki to not apply formatting to a specific element by surrounding it by %%, or by using <nowiki></nowiki>
For example, writing down the following:
echo 'jambon' >> sandwich.txt
will display as
echo 'jambon' » sandwich.txt
transforming the >> into a », however writing
%%echo 'jambon' >> sandwich.txt%% or <nowiki>echo 'jambon' >> sandwich.txt</nowiki> will display it correctly.
Display tables (vertical bar method)
The more common way of displaying tables in this wiki is through the use of vertical bars (|) and carats (^). These keys are available with [Shift]+[\] and [Shift]+[6] on standard QWERTY ASCII keyboards.
Headers are identified by beginning with a carat. Regular elements begin with vertical bars. Elements that aren't closed with another carat or bar will be discarded. For example:
^ Header 1 ^ Attribute 2 ^ Notes ^ | Emulator 1 | ''.zip'' ''.nes'' | Is pretty cool. | | Emulator 2 | ''.nes'' | Is cooler, but less compatible. | | Emulator 3 | | Emulator 4
would appear as
| Header 1 | Attribute 2 | Notes |
|---|---|---|
| Emulator 1 | .zip .nes | Is pretty cool. |
| Emulator 2 | .nes | Is cooler, but less compatible. |
| Emulator 3 | ||
Alignment is handled by using double white spaces on the side of the element you want it to align to. For example:
| This element at the top isn't a header, and is right aligned. | An empty element is below this one. | ^ But this one is. Headers don't have to only be at the top, but should in most cases. ^ | ^ Any element can be closed with either a bar or a carat, it doesn't matter which. | But they will decide the element type for the next element. |
would appear as
| This element at the top isn't a header, and is right aligned. | An empty element is below this one. |
| But this one is. Headers don't have to only be at the top, but should in most cases. | |
|---|---|
| Any element can be closed with either a bar or a carat, it doesn't matter which. | But they will decide the element type for the next element. |
Display tables (csv)
One easy way to display a table is to use a comma separated values (csv) structure. Think of it like a 2-D spreadsheet, but in a pure text format where the separator of the columns is a Comma, and the separator for the lines is a newline, and the first line serves as a header.
Putting a CSV structure inside the <csv></csv> elements will display it, so for instance, if you have
Emulator name, Emulated system, Original manufacturer Picodrive, Master system/Genesis, Sega Genesis plus GX, Master system/Genesis, Sega
and add the <csv></csv> like this :
<csv> Emulator name, Emulated system, Original manufacturer Picodrive, Master system/Genesis, Sega Genesis plus GX, Master system/Genesis, Sega </csv>
it will then display as this
| Emulator name | Emulated system | Original manufacturer |
|---|---|---|
| Picodrive | Master system/Genesis | Sega |
| Genesis plus GX | Master system/Genesis | Sega |
CSV SAMPLE OUTPUT GOOGLE
<csv file=https://docs.google.com/spreadsheets/URL/pub?output=csv> </csv>
To link to a Google spreadsheet:
- Open your spreadsheet in Google Docs.
- Click the “Share” botton in the toolbar, and choose “Anyone with the link” for Visibility.
- Open your spreadsheet in Google Docs.
- From the spreadsheet menu select: File | Publish as a Web Page
- Sheets to Publish: “All Sheets”, and check the box “Automatically republish when changes are made” to ensure your data is auto updated.
- Click “Start Publishing”. This will activate the options in the box “Get a link to the published data”, below.
- Change the export type from “Web Page” to “CSV (comma-separated values)”.
- Change “All sheets” to “Sheet1” (or select the sheet you want to export)
- Change “All Cells” to the specific range you want to export, beginning with the header row. Use Excel-style notation, like A1:C6 for the first 3 columns and the first 6 rows.
- Click “Republish now”
- Copy the link (check it ends with output=csv) and paste it into your dokuwiki CSV table using the file= attribute described above.
- batocera_wiki_code_snippets.1631931366.txt.gz
- Last modified: 5 years ago
- by atari