MediaWiki中的自动顺序文章命名

时间:2013-03-20 14:42:30

标签: mediawiki semantic-mediawiki

我正在尝试在公司维基中添加一个部分,它将作为基于Documentum的数据仓库的一种前端(因为没有搜索功能和糟糕的内部组织)。我们的想法是使用元数据和直接链接为每个文档创建文章存根,并使用Semantic Mediawiki来跟踪和组织系统中的文章。

我正在使用语义表单来管理文章创建(在使用API​​从几个电子表格进行初步推送之后),但我也希望自动化文章命名,以便系统从用户的手中开始结束。所有的标题都是像MBMA-00001这样的东西,所以我想要MBMA页面上的一个按钮,当按下时,搜索Category:MBMA,确定当前系统中MBMA-n的最高数量,并将用户带到已经输入MBMA-n + 1的语义表格模板作为标题。

InputBoxCreateBoxCreateArticle等扩展程序似乎不支持此功能,但是我可以添加另一个扩展程序吗?或者我必须弄清楚如何自己编写?

2 个答案:

答案 0 :(得分:1)

我打算说你可能需要创建自己的,因为你的要求看起来很专业,但后来我遇到了DPL Page Name S/N Maker扩展,看起来与它们完全匹配。

您还可以选择variant of the extension using Semantic Forms

答案 1 :(得分:1)

上面链接的模板正是我所需要的,但实际上并没有按照书面形式工作。对于其他有此需求的人来说,这里有一个清理和更正的版本,可以删除有问题的字符串函数并完美运行:

{{#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)]]
相关问题