Changes between Version 2 and Version 3 of WikiMacros


Ignore:
Timestamp:
Dec 31, 2005, 4:43:10 PM (18 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WikiMacros

    v2 v3  
    1 =  Wiki マクロ =
    2 Wiki マクロとは、Python で書かれた 'カスタム関数' によって Trac の Wiki エンジンを拡張するプラグインです。 WikiFormatting エンジンがサポートするあらゆるコンテクストにおいて、マクロを使用することによって、動的なHTMLデータが挿入されます。
     1=  Wiki Macros =
     2Trac macros are plugins to extend the Trac engine with custom 'functions' written in Python. A macro inserts dynamic HTML data in any context supporting WikiFormatting.
    33
    4 もう1種類のマクロは WikiProcessors です。これは通常、Wiki以外のマークアップ形式と表示を取り扱うために使用し、多くは、(ソースコードハイライトのような)より大きいブロックに使用します。参考: WikiProcessors
     4Another kind of macros are WikiProcessors. They typically deal with alternate markup formats and representation of larger blocks of information (like source code highlighting).
    55
    6 == マクロの利用 ==
    7 マクロ呼び出しは、二つの ''角括弧 (square brackets) '' で括られた箇所です。Python関数のように、マクロは引数を取ることができ、括弧 (parenthesis) の中に、カンマで区切ったリストで表記します。
     6== Using Macros ==
     7Macro calls are enclosed in two ''square brackets''. Like python functions, macros can also have arguments, a comma separated list within parentheses.
    88
    9 === 利用例 ===
     9=== Examples ===
    1010
    1111{{{
    1212 [[Timestamp]]
    1313}}}
    14 は、以下のように表示されます:
     14Display:
    1515 [[Timestamp]]
    1616
     
    1818 [[HelloWorld(Testing)]]
    1919}}}
    20 は、以下のように表示されます:
     20Display:
    2121 [[HelloWorld(Testing)]]
    2222
     23== Available Macros ==
    2324
    24 == 利用可能なマクロ ==
    25 マクロは現在のところ新機能の扱いです。利用可能な (そして配布対象となっている) マクロの一覧は、まだそれほど充実していません。
    26 今後の Trac のリリースででは、役に立つマクロライブラリの構築を考えています。マクロを寄贈してもらえるのであれば、喜んで配布に含めます (詳しくは下をご覧下さい) 。
     25''Note that the following list will only contain the macro documentation if you've not enabled `-OO` optimizations, or not set the `PythonOptimize` option for [wiki:TracModPython mod_python].''
    2726
    28  * '''HelloWorld''' -- マクロの例。これからマクロを書きたいときに参考になります。
    29  * '''Timestamp''' -- 現在の日時を挿入する。
    30 
    31 
    32 ----
    33 
     27[[MacroList]]
    3428
    3529== Macros from around the world ==
    3630The [http://projects.edgewall.com/trac/ Trac Project] has a section dedicated to user-contributed macros, [http://projects.edgewall.com/trac/wiki/MacroBazaar MacroBazaar]. If you're looking for new macros, or have written new ones to share with the world, don't hesitate adding it to the [http://projects.edgewall.com/trac/wiki/MacroBazaar MacroBazaar] wiki page.
    3731
    38   http://projects.edgewall.com/trac/wiki/MacroBazaar
    39 
    40 
    4132----
    4233
     34== Developing Custom Macros ==
     35Macros, like Trac itself, are written in the [http://www.python.org/ Python programming language]. They are very simple modules, identified by the filename and should contain a single ''entry point'' function. Trac will display the returned data inserted into the HTML where the macro was called.
    4336
    44 == 新しいマクロを開発する ==
    45 マクロは、 Trac 自身と同じように [http://www.python.org/ Python programming language] で書かれています。とてもシンプルなモジュールで、たった一つの ''インタフェース (entry point) '' 関数だけを持ちます。マクロの識別はファイル名で行います。Trac は、呼び出されたマクロが返却したデータをHTMLに挿入して表示を行います。
    46 
    47 最も簡単なマクロの例です:
     37It's easiest to learn from an example:
    4838{{{
     39#!python
    4940# MyMacro.py -- The world's simplest macro
    5041
     
    5344}}}
    5445
    55 === 上級トピック: Template-enabled Macros ===
    56 高度な用途のために、マクロでは HDF 形式での構造化出力をサポートしています。これは、 Trac が生成するページと同じように clearSilver テンプレートを使って HTML を生成することができます。要するに、これは普遍的かつ、よく設計された高度なマクロを可能にします。
    57 
    58 マクロでは、メインとなる HDF ツリーに直接アクセスし、自由に操作することができます。
    59 
    60 例:
     46You can also use the environment (`env`) object, for example to access configuration data and the database, for example:
    6147{{{
    62 def execute(hdf, args, env):
    63     # Currently hdf is set only when the macro is called
    64     # From a wiki page
    65     if hdf:
    66         hdf.setValue('wiki.macro.greeting', 'Hello World')
    67        
    68     # args will be null if the macro is called without parentesis.
    69     args = args or 'No arguments'
    70     return 'Hello World, args = ' + args
    71 }}}
    72 
    73 また、environment (env) オブジェクトによって、コンフィグデータへのアクセスも提供されています。
    74 
    75 例:
    76 {{{
     48#!python
    7749def execute(hdf, txt, env):
    7850    return env.get_config('trac', 'repository_dir')
    7951}}}
     52
     53Note that since version 0.9, wiki macros can also be written as TracPlugins. This gives them some capabilities than “classic” macros do not have, such as directly access the HTTP request.
     54
     55For more information about developing macros, see the [http://projects.edgewall.com/trac/wiki/TracDev development resources] on the main project site.
     56
    8057----
    81 参考:  WikiProcessors, WikiFormatting, TracGuide
     58See also:  WikiProcessors, WikiFormatting, TracGuide