Changes between Version 1 and Version 2 of WikiMacros
- Timestamp:
- Jun 21, 2008, 6:11:58 PM (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
WikiMacros
v1 v2 1 = Wiki マクロ=2 Wiki マクロとは、 Python で書かれた 'カスタム関数' によって Trac の Wiki エンジンを拡張するプラグインです。 WikiFormatting エンジンが利用可能なあらゆるコンテキストにおいて、マクロを使用することによって、動的な HTML データが挿入されます。 1 = Wiki Macros = 2 Trac 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. 3 3 4 もう 1 種類のマクロは WikiProcessors です。これは通常、Wiki以外のマークアップ形式と表示を取り扱うために使用し、多くは、 (ソースコードハイライトのような) より大きいブロックに使用します。 4 Another kind of macros are WikiProcessors. They typically deal with alternate markup formats and representation of larger blocks of information (like source code highlighting). 5 5 6 == マクロの利用==7 マクロ呼び出しは、二つの ''角括弧 (square brackets) '' で括られた箇所です。 Python 関数のように、マクロは引数を取ることができ、括弧 (parenthesis) の中に、カンマで区切ったリストで表記します。 6 == Using Macros == 7 Macro calls are enclosed in two ''square brackets''. Like Python functions, macros can also have arguments, a comma separated list within parentheses. 8 8 9 === 利用例===9 === Examples === 10 10 11 11 {{{ 12 12 [[Timestamp]] 13 13 }}} 14 は、以下のように表示されます:14 Display: 15 15 [[Timestamp]] 16 16 … … 18 18 [[HelloWorld(Testing)]] 19 19 }}} 20 は、以下のように表示されます:20 Display: 21 21 [[HelloWorld(Testing)]] 22 22 23 == マクロ一覧==23 == Available Macros == 24 24 25 ''Note : 以下に示すリストはマクロドキュメントを含むものだけです。 `-OO` による最適化や、 [wiki:TracModPython mod_python] での `PythonOptimize` オプションが設定されていると表示されません。''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].'' 26 26 27 27 [[MacroList]] … … 31 31 The [http://trac-hacks.org/ Trac Hacks] site provides a wide collection of macros and other Trac [TracPlugins plugins] contributed by the Trac community. If you're looking for new macros, or have written one that you'd like to share with the world, please don't hesitate to visit that site. 32 32 33 == カスタムマクロを開発する==34 マクロは、 Trac 自身と同じように [http://www.python.org/ Python programming language] で書かれています。とてもシンプルなモジュールで、たった一つの `execute()` 関数だけを持ちます。マクロの識別はファイル名で行います。 Trac は、呼び出されたマクロが返却したデータをマクロが呼び出された Wiki ページの HTML に挿入して表示を行います。 33 == Developing Custom Macros == 34 Macros, 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 `execute()` function. Trac will display the returned data inserted into the HTML representation of the Wiki page where the macro is called. 35 35 36 最も簡単なマクロの例です:36 It's easiest to learn from an example: 37 37 {{{ 38 38 #!python … … 43 43 }}} 44 44 45 Environment (`env`) オブジェクトを使用することも出来ます。この例では、コンフィグレーションとデータベースにアクセスしています:45 You can also use the environment (`env`) object, for example to access configuration data and the database, for example: 46 46 {{{ 47 47 #!python … … 50 50 }}} 51 51 52 Note : バージョン 0.9 以降、 Wiki マクロは TracPlugins でも書くことが出来るようになりました。これによって、 HTTP request へのダイレクトアクセスなど、 "古い" マクロでは実現できなかったことが出来るようになりました。52 Note that since version 0.9, wiki macros can also be written as TracPlugins. This gives them some capabilities that “classic” macros do not have, such as being able to directly access the HTTP request. 53 53 54 マクロ開発についての詳しい情報は、プロジェクトメインサイトの [http://trac.edgewall.org/wiki/TracDev 開発リソース] を参照してください。 54 For more information about developing macros, see the [http://projects.edgewall.com/trac/wiki/TracDev development resources] on the main project site. 55 55 56 56 ----