Modul:Quotations/doc
Ini ialah laman pendokumenan untuk Modul:Quotations
This module is used by Template:Q.
Coding
[sunting]The intent of this module was to make a quotations library which can be built and used asynchronously. An editor can reference a work or author which is not yet coded, and the display will still look fine, and if the information is later coded, the template will make use of it at that time.
Language modules
[sunting]Each language needs its own module, such as that found at Module:Quotations/grc, which can be used as a starting point in creating a language module which does not yet exist. This module takes the information and does the lookups in its data module (in this case Module:Quotations/grc/data), and returns the results to be formatted by the main module.
The data module should be a table, with entries for each author. Each author table should include information about the author, such as years active and the title of the Wikipedia article for the author, as well as tables for each of its works, with information such as the year the work was written, the title of its Wikipedia article, and the title of its Wiksource article. Alias tables can be used for convergence, such as when a work might have two common titles, as well as abbreviations.
Note that the module is designed to work with whatever data is available, and it should not be considered necessary to add all possible data; some is better than none.
Note: In order for a language module to be recognized, the corresponding language code must be added to the hasData
table in this module.
Reference link
[sunting]One of the more complex aspects of coding the data set lies in the reference link, which is meant to be a fairly dynamic link which formats itself to account for information given. It is formatted in the author's data table as a table of strings and tables. Strings not prefixed by a period are inserted as is. Strings prefixed with a period indicate variable references. Tables which begin with a function run that function with the table's following elements as parameters. Tables not beginning with a function are nested variable addresses. Take the reference link format table data.Plato.rlFormat2
, which is used solely by Plato's Republic:
{'s:el:', '.rlTitle', '/', {'.chapterSelect', {'authorData', 'republicChapters'}, '.ref1'}, '#p', '.ref1', {'.lower', '.ref2'} }
The first element, 's:el'
, is a simple string, and will be inserted as-is into the link target; it is the prefix for the Greek Wikisource, where a native language version of The Republic is found.
The second element, '.rlTitle'
, begins with a period, indicating that it should be replaced by the variable 'rlTitle'
, which is given in The Republic’s data table as 'Πολιτεία'
.
The third element, '/'
, is a standard string, and will be inserted into the link as-is.
The fourth element is a function call, using the function chapterSelect
, which is called with two parameters. The second parameter is the variable ref1
, which is the chapter given by the user. The first parameter is formatted as a nested reference, it will be the variable republicChapters
, which is found within data.Plato
.
There is no getting around the fact that it is not the easiest format in the world, but it does make for a powerful and flexible engine to interpret data and create the proper link.
External Reference link
[sunting]If the source is not wikilinkable, then you'll need an external reference link instead of a reference link. You can use the same method as reference links, except use '.xrlFormat'
instead of '.rlFormat'
, and the URL to link to is the '.xurl'
parameter for the work. For example:
data['Julius Firmicus Maternus'].xrlFormat1 = {'.xurl'}
data['Julius Firmicus Maternus'].works = {
['Matheseos Libri VIII'] = {['year'] = 'c. 334–337', ['xurl'] = 'https://archive.org/details/matheseoslibrivi02firmuoft', ['xrlFormat'] = 1}
}
Language-specific submodules
[sunting]