【问题标题】:Automatic sequential article naming in MediaWikiMediaWiki 中的自动顺序文章命名
【发布时间】:2013-03-20 14:42:29
【问题描述】:

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

我正在使用语义表单来管理文章的创建(在使用 API 从一些电子表格进行初始推送之后),但我还想自动化文章命名,以便系统从一开始就掌握用户的手结尾。所有的标题都将是 MBMA-00001 之类的东西,所以我想要 MBMA 页面上的一个按钮,按下该按钮时,将搜索 Category:MBMA,确定系统中当前的最大编号 MBMA-n,并将用户带到已输入 MBMA-n+1 作为标题的语义表单模板。

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

【问题讨论】:

    标签: mediawiki semantic-mediawiki


    【解决方案1】:

    我要说的是您可能需要创建自己的,因为您的要求似乎很专业,但后来我遇到了 DPL Page Name S/N Maker 扩展名,它似乎与他们完全匹配。

    还有一个variant of the extension using Semantic Forms,您可能更喜欢。

    【讨论】:

    • 太棒了,这看起来正是我所需要的。谢谢!
    【解决方案2】:

    上面链接的模板正是我所需要的,但实际上并没有像写的那样工作。对于将来有此需求的任何其他人,这里有一个清理和更正的版本,它删除了有问题的字符串函数并完美运行:

    {{#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)]]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-10
      • 2021-07-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多