使用 SMW 子对象而无需复制内容
Using SMW subobjects without having to duplicate the content
我想要实现的示例
我有许多补丁页面("Patch 1.4"、"Patch 1.5" 等)列出了对项目所做的更改,其中 affected/changed 内容链接到它们相应的页面("confirmation dialog"、"foo" 等):
Patch 1.4
- Fixed spelling in the [[confirmation dialog]]
Patch 1.5
- Added two options: [[foo]], [[bar]]
关于更改内容的页面("confirmation dialog"、"foo"、...),我想自动显示所有相应的更改:
Foo
- [[Patch 1.5]]: Added two options: [[foo]], [[bar]]
Semantic MediaWiki 的子对象可以做到这一点
#subobject
允许我为补丁页面上的每个更改创建一个(匿名)对象:
{{#subobject:|
|Changes=Added two options: [[foo]], [[bar]]
|Affects=Foo|Bar
}}
并且在每个页面上("foo" 等)我可以包含一个 #ask
subobject query 来列出所有匹配的子对象:
{{#ask: [[Affects::{{FULLPAGENAME}}]]
|? Changes
}}
太棒了。
问题:我必须复制更改条目。
在补丁页面上,更改条目如下所示:
* Added two options: [[foo]], [[bar]] {{#subobject:|
|Changes=Added two options: [[foo]], [[bar]]
|Affects=Foo|Bar
}}
所以我必须指定 "Added two options: [[foo]], [[bar]]" 两次:一次用于可见内容,一次用于不可见子对象。
(语义)MediaWiki 中是否有一种无需复制内容即可执行此操作的方法?
理想的解决方案只需要我附上更改条目并在其旁边指定受影响的页面,例如:
* {{ Added two options: [[foo]], [[bar]] }}((foo|bar))
由于每个补丁页面可以列出数百个更改,我不想为每个更改创建一个单独的页面。
如果我明白你的问题,看来你只需要一个简单的查询:
{{#ask: [[-Has subobject::{{FULLPAGENAME}}]]
| ?Changes
| format = ul
| headers = hide
| mainlabel = -
}}
由于使用 SMW 标记可能很乏味且容易出错,您也可以使用 MediaWiki 模板。您可以简化添加补丁更改:
模板:更改
<includeonly><!--
-->{{#subobject:|
| Changes = {{{1|}}}
| Affects = {{{2|}}}|+sep=;
}}<!--
--></includeonly><nowiki/>
{{{1}}}
和 {{{2}}}
是位置参数,Affects
子对象 属性 使用 ;
分隔符(作为管道 |
是不明确的,可能会破坏模板、解析器函数等)。 <nowiki/>
是一种避免调用站点页面空白膨胀的技巧。
您还可以添加一个特殊模板来封装更改查询:
模板:补丁更改
<includeonly><!--
-->{{#ask: [[-Has subobject::{{{1|{{FULLPAGENAME}}}}}]]
| ?Changes
| format = ul
| headers = hide
| mainlabel = -
}}<!--
--></includeonly><nowiki/>
默认情况下,模板会请求当前页面的更改列表(如果位置参数 #1 参数为空),或者您可以稍后在调用站点显式覆盖它(例如,{{Patch changes|Patch 1.5}}
).
补丁 1.4
{{Change | Fixed spelling in the [[confirmation dialog]] | Confirmation dialog}}
{{Patch changes}}
补丁 1.5
{{Change | Added two options: [[foo]], [[bar]] | Foo; Bar}}
{{Patch changes}}
分别
这些链接以后可能会有用:
我想要实现的示例
我有许多补丁页面("Patch 1.4"、"Patch 1.5" 等)列出了对项目所做的更改,其中 affected/changed 内容链接到它们相应的页面("confirmation dialog"、"foo" 等):
Patch 1.4
- Fixed spelling in the [[confirmation dialog]]
Patch 1.5
- Added two options: [[foo]], [[bar]]
关于更改内容的页面("confirmation dialog"、"foo"、...),我想自动显示所有相应的更改:
Foo
- [[Patch 1.5]]: Added two options: [[foo]], [[bar]]
Semantic MediaWiki 的子对象可以做到这一点
#subobject
允许我为补丁页面上的每个更改创建一个(匿名)对象:
{{#subobject:|
|Changes=Added two options: [[foo]], [[bar]]
|Affects=Foo|Bar
}}
并且在每个页面上("foo" 等)我可以包含一个 #ask
subobject query 来列出所有匹配的子对象:
{{#ask: [[Affects::{{FULLPAGENAME}}]]
|? Changes
}}
太棒了。
问题:我必须复制更改条目。
在补丁页面上,更改条目如下所示:
* Added two options: [[foo]], [[bar]] {{#subobject:|
|Changes=Added two options: [[foo]], [[bar]]
|Affects=Foo|Bar
}}
所以我必须指定 "Added two options: [[foo]], [[bar]]" 两次:一次用于可见内容,一次用于不可见子对象。
(语义)MediaWiki 中是否有一种无需复制内容即可执行此操作的方法?
理想的解决方案只需要我附上更改条目并在其旁边指定受影响的页面,例如:
* {{ Added two options: [[foo]], [[bar]] }}((foo|bar))
由于每个补丁页面可以列出数百个更改,我不想为每个更改创建一个单独的页面。
如果我明白你的问题,看来你只需要一个简单的查询:
{{#ask: [[-Has subobject::{{FULLPAGENAME}}]]
| ?Changes
| format = ul
| headers = hide
| mainlabel = -
}}
由于使用 SMW 标记可能很乏味且容易出错,您也可以使用 MediaWiki 模板。您可以简化添加补丁更改:
模板:更改
<includeonly><!--
-->{{#subobject:|
| Changes = {{{1|}}}
| Affects = {{{2|}}}|+sep=;
}}<!--
--></includeonly><nowiki/>
{{{1}}}
和 {{{2}}}
是位置参数,Affects
子对象 属性 使用 ;
分隔符(作为管道 |
是不明确的,可能会破坏模板、解析器函数等)。 <nowiki/>
是一种避免调用站点页面空白膨胀的技巧。
您还可以添加一个特殊模板来封装更改查询:
模板:补丁更改
<includeonly><!--
-->{{#ask: [[-Has subobject::{{{1|{{FULLPAGENAME}}}}}]]
| ?Changes
| format = ul
| headers = hide
| mainlabel = -
}}<!--
--></includeonly><nowiki/>
默认情况下,模板会请求当前页面的更改列表(如果位置参数 #1 参数为空),或者您可以稍后在调用站点显式覆盖它(例如,{{Patch changes|Patch 1.5}}
).
补丁 1.4
{{Change | Fixed spelling in the [[confirmation dialog]] | Confirmation dialog}}
{{Patch changes}}
补丁 1.5
{{Change | Added two options: [[foo]], [[bar]] | Foo; Bar}}
{{Patch changes}}
分别
这些链接以后可能会有用: