我正在尝试添加一个部分到企业wiki,它将作为一种基于文档的数据仓库的前端(因为没有搜索功能和糟糕的内部组织)。这个想法是为每个文档创建一个带有元数据和直接链接的文章存根,并使用Semantic Mediawiki来跟踪和组织系统中的文章。
我使用Semantic Forms来管理文章创建(在使用API从几个电子表格初始推送之后),但我想自动化文章命名,以便系统从头到尾保持用户的手。所有的标题都将是像MBMA-00001这样的东西,所以我希望在MBMA页面上有一个按钮,当按下时,搜索类别:MBMA,确定系统中目前最高的数字MBMA-n,并将用户带到一个语义表单模板,其中MBMA-n+1已经输入作为标题。
扩展,如InputBox, CreateBox和CreateArticle似乎不支持此功能,但是否有另一个扩展,我可以添加,将这样做?还是我得自己想办法写?
上面链接的模板正是我所需要的,但实际上并没有像写的那样工作。对于将来有此需求的任何人,这里有一个清理和更正的版本,它删除了有问题的字符串函数,并且工作完美:
{{#if: {{{form|}}}
| {{#ifexist: Form:{{{form|}}}
|
| <strong class="error">Warning! The form "{{{form|}}}" may not be a valid form name!</strong>
}}
|
}}<!---
-->{{#if: {{{form|}}}
| {{#ifeq: {{lc:{{NS:{{{namespace|}}} }} }}
| {{lc:{{{namespace|}}} }}
|
| <strong class="error">Warning! "{{{namespace}}}" may not be a valid namespace name!</strong>
}}
|
}}<!---
-->The next document number is '''<!--
-->{{#if: {{{namespace|}}} | {{{namespace|}}}: }}{{{prefix|}}}<!--
-->{{padleft:<!----------- (X+1) => 0000(X+1)
-->{{#expr:<!---------- 0000X+1 => (X+1)
-->{{replace|<!----- "Namespace:prefix0000X" => "0000X"
-->{{replace|<!-- "*[[Namespace:prefix0000X]]" => "Namespace:prefix0000X"
-->{{#dpl:<!-- return pages named "*[[Namespace:prefix0000X]]"
-->titleregexp =^{{{prefix|}}}[0-9]{{{{pad|5}}}}$<!--
-->| namespace = {{{namespace|}}}<!--
-->| order = descending<!--
-->| mode = userformat<!--
-->| format = ,%PAGE%<!--
-->| noresultsheader = {{padleft:0|{{{pad|5}}}|0}}<!--
-->| count = 1
}}
|/^([^{{!}}]+{{!}}){1}([^]]+).*/
|2
}}
| {{#if: {{{namespace|}}} | {{{namespace|}}}:}}{{{prefix|}}}
|
}}
+1
}}
| {{{pad|5}}}
| 0
}}'''
----
{{#if: {{{form|}}}
| {{#forminput: {{{form|}}}
| {{{width|20}}}
| {{{prefix|}}}<!--
-->{{padleft:<!----------- (X+1) => 0000(X+1)
-->{{#expr:<!---------- 0000X+1 => (X+1)
-->{{replace|<!----- "Namespace:prefix0000X" => "0000X"
-->{{replace|<!-- "*[[Namespace:prefix0000X]]" => "Namespace:prefix0000X"
-->{{#dpl:<!-- return pages named "*[[Namespace:prefix0000X]]"
-->titleregexp =^{{{prefix|}}}[0-9]{{{{pad|5}}}}$<!--
-->| namespace = {{{namespace|}}}<!--
-->| order = descending<!--
-->| mode = userformat<!--
-->| format = ,%PAGE%<!--
-->| noresultsheader = {{padleft:0|{{{pad|5}}}|0}}<!--
-->| count = 1
}}
|/^([^{{!}}]+{{!}}){1}([^]]+).*/
|2
}}
|{{#if: {{{namespace|}}} | {{{namespace|}}}:}}{{{prefix|}}}
|
}}
+1
}}
| {{{pad|5}}}
| 0
}}
| {{{buttonlabel|Add}}}
| {{#if: {{{namespace|}}} | namespace = {{{namespace|}}} }}
}}
| <includeonly><strong class="error">Warning! You haven't specified a SemanticForm for page creation! Please specify a SemanticForm name.</strong></includeonly>
}}<noinclude>{{documentation}}</noinclude>
和文档子页:
{{documentation subpage}}
{{intricate template}}
== Parameters ==
All parameters to the template are optional.
{| class="wikitable"
|-
! form
| Specifies a SemanticForm name, which will handle the pages you create.
|-
! namespace
| Specifies a Namespace, which the new page will belong to.
|-
! prefix
| Specifies a title fragment, which will prefix the generated number
|-
! pad
| The number of digits required in the page number. The default value is "5".
|-
! width
| Sets the width of the input box. The default value is "20".
|-
! buttonlabel
| Sets the text of the Create button. The default value is "Add".
|}
== Example ==
<pre><nowiki>{{DPLSNMakerSF
| form = MBMA Document
| namespace =
| prefix = MBMA-
| pad = 5
| width = 30
| buttonlabel = Create
}}
</nowiki></pre>
== See also ==
[[mw:extension:DPL Page Name S/N Maker (using SemanticForms)]]
我想说你可能需要创建你自己的,因为你的需求似乎很专业,但后来我遇到了DPL页面名称S/N Maker扩展,它似乎与它们完全匹配。
还有一个使用Semantic Forms的扩展变体,您可能更喜欢。