This page is a translated version of the page Extension:Cargo and the translation is 35% complete.
MediaWiki扩展手册
Cargo
发行状态: 稳定版
实现 特殊页面 , API , 解析器函数
描述 用来存储和查询包含在模板中的数据的扩展。
作者 Yaron Koren <yaron57@gmail.com> (Yaron Koren留言)
最新版本 3.7 (2024年9月)
兼容性政策 master分支维持向后兼容。
MediaWiki 1.39+
数据库更改
Composer mediawiki/cargo
cargo_tables
cargo_pages
cargo_backlinks
许可协议 GNU通用公眾授權條款2.0或更新版本
下載
示例 包含对#cargo_query的各种调用的页面
  • $wgCargoFileDataColumns
  • $wgCargoDrilldownLargestFontSize
  • $wgCargoDecimalMark
  • $wgCargoDefaultStringBytes
  • $wgCargoAllowedSQLFunctions
  • $wgCargoHideNamespaceName
  • $wgCargoPageDataColumns
  • $wgCargoIgnoreBacklinks
  • $wgCargoMaxVisibleHierarchyDrilldownValues
  • $wgCargoDrilldownSmallestFontSize
  • $wgCargoLegacyNullLuaFieldsAsEmptyString
  • $wgCargoRecurringEventMaxInstances
  • $wgCargoDefaultMapService
  • $wgCargoStoreUseTemplateArgsFallback
  • $wgCargoTablesPrioritizeReplacements
  • $wgCargoMaxQueryLimit
  • $wgCargoDigitGroupingCharacter
  • $wgCargoDefaultQueryLimit
  • $wgCargoDrilldownNumRangesForNumbers
  • $wgCargo24HourTime
  • $wgCargoDrilldownUseTabs
  • $wgCargoMapClusteringMinimum
  • $wgCargoDrilldownMinValuesForComboBox
  • recreatecargodata
  • deletecargodata
  • runcargoqueries
季度下載量 53 (Ranked 88th)
翻译Cargo扩展
問題 开启的任务 · 报告错误

Cargo是MediaWiki的一项扩展,可以提供轻量的方式来存储和查询数据,这些数据是通常通过信息框(infobox)等模板调用的。 Cargo在概念上类似于Semantic MediaWiki 扩展,但是有许多优点,比如容易安装,容易使用。

Cargo将所有的数据存在数据库表中,而这些表可以被MediaWiki自己的数据库(默认)或分开的数据替换。 在大多数情况下,每个模板都会将其数据存储在单个数据库表中,每个相关模板参数对应一列。 有少量例外:包含数组/列表以及包含地理位置的字段的处理会更复杂一些,这是因为大多数数据库系统缺乏对这些类型的原生支持。 多个模板也可以将它们的数据存储在同一个数据库表中。

这个扩展定义了许多解析器函数,以下三个最为重要:

  • #cargo_declare - 位于模板的‎<noinclude>部分,为表定义概要。
  • #cargo_store - 为Cargo的表存储一行,通常位于模板的‎<includeonly>部分。
  • #cargo_query - 查询一个或多个Cargo数据表,使用SQL组件。

还定义了以下解析器函数:

  • #cargo_attach - 定义一个模板加入其他模板声明的行。
  • #cargo_compound_query - 在一个位置显示多次查询结果。
  • #cargo_display_map - 显示一个单点的地图。
  • #recurring_event - 输出反复发生时间的日期,为了#cargo_store使用。

Cargo还定义了各种接口,用于查看和向下钻取此存储的数据。 As such, it adds the following special pages:

  • Special:CargoQuery
  • Special:CargoTableDiagram
  • Special:CargoTables
  • Special:Drilldown

Cargo使用MySQL和PostgreSQL数据库系统测试和工作。 理论上也支持SQLite,但是并没有充分测试,而且有可能无法正常工作。

Cargo扩展要求MediaWiki的版本至少为MediaWiki 1.38+。

本页顶部的导航框列举了一些关于Cargo的页面,可以了解更多Cargo的知识,以及如何工作、如何使用和如何安装。

Installation

Configuration

Below are Cargo's global configuration settings along with their default values.

To configure Cargo to use a separate database instead of the MediaWiki database, the following settings are provided:

Separate database configuration settings
Setting Default Description
$wgCargoDBtype null Database type.
$wgCargoDBserver null Host name or IP address of database server.
$wgCargoDBname null Name of the database.
$wgCargoDBuser null Database username.
$wgCargoDBpassword null The password for $wgCargoDBuser.
$wgCargoDBprefix null Database table name prefix.
$wgCargoDBRowFormat null Data base row format.

For character configuration as related to numbers, the following configuring settings are provided:

Character configuration settings
Setting Default Description
$wgCargoDecimalMark . Decimal character for numbers.
$wgCargoDigitGroupingCharacter , Thousands digit separator.

The remaining global configuration settings are as follows:

Setting Default Description
$wgCargoAllowedSQLFunctions [] Sets allowed SQL functions. See Using SQL Functions for defaults.
$wgCargoRecurringEventMaxInstances 100 The number of max instances to store for recurring events with no set end date.
$wgCargoDefaultStringBytes 300 The default number of characters for fields of type Page, String, Wikitext string, File, URL, Email
$wgCargoDefaultQueryLimit 100 Number of results to show for #cargo_query if no limit is set
$wgCargoMaxQueryLimit 5000 The maximum allowed number of results for #cargo_query
$wgCargo24HourTime false If true uses 24-hour time for Datetime field types.
$wgCargoDefaultMapService OpenLayers Sets the default map service to Google Maps, if set to googlemaps, to Leaflet if set to leaflet, and to OpenLayers if set to openlayers.
$wgCargoGoogleMapsKey null API key for Google Maps, for the googlemaps display format.
$wgCargoMapClusteringMinimum 80 If the number of map points displayed is greater than the value of $wgCargoMapClusteringMinimum, the map displays the locations in "clusters" instead of individual points, for readability. If set to a very high number, does not display clustering.
$wgCargoDrilldownUseTabs true Displays Special:Drilldown table names as tabs at the top instead of a vertical list at the side.
$wgCargoDrilldownSmallestFontSize -1 If set to a positive number, sets the smallest font size, in pixels, for a tag-cloud-style display of filter values.
$wgCargoDrilldownLargestFontSize -1 If set to a positive number, sets the largest font size, in pixels, for a tag-cloud-style display of filter values.
$wgCargoDrilldownMinValuesForComboBox 40 Sets the minimum number of values before their display is converted to a combo box, instead of individual links.
$wgCargoDrilldownNumRangesForNumbers 5 For fields/filters of type Integer or Float, specifies the number of "buckets" into which values are divided.
$wgCargoMaxVisibleHierarchyDrilldownValues 30 If set to a positive integer, specifies the maximum number of values shown at a time for any hierarchy field (All the top-level values are shown irrespective of this value). The values are hidden beyond a certain depth of the hierarchy such that the count of total visible values is at most this number.
$wgCargoTablesPrioritizeReplacements false If true, all tables having a replacement appear at the top of the Special:CargoTables page, instead displaying them in alphabetical order.
$wgCargoPageDataColumns [] The set of fields to store in the _pageData Cargo table. See Storing page data .
$wgCargoFileDataColumns [] The set of fields to store in the _fileData Cargo table. See Storing file data .
$wgCargoHideNamespaceName [6] Array of namespaces to hide from query results.
$wgCargoLegacyNullLuaFieldsAsEmptyString false Null results to the Lua Cargo query function should return as string rather than nil. This allows you to rollback a breaking change from early 2022. New wikis created after this time should not enable this.
$wgCargoStoreUseTemplateArgsFallback true Enable the behavior that looks for template arguments that match the template's declared table to fill columns.


參見