MindTouch Developer Center > Deki - Japanese > エクステンション

日本語Wikiオープンしました。翻訳はこちらではなく以下の方を更新してください
http://jp.opengarden.org/index.php?t...83%A7%E3%83%B3

 

Table of Contents

 

最初に

Deki Wiki "Hayes"(ヘイズ)には、ページにダイナミックコンテンツを足す新メカニズムを紹介します。以前バージョンDeki Wiki "Gooseberry"(グースベリー)では一応出来た事ですが、カスタムエクステンションを導入するもに、ソースコードの編集が必要だった。Hayesでは、ダイナミックコンテンツ機能はうんっと良くして、新Service Oriented Architecture (SOA)を利用して導入を可能にしてます。現在、コントロールパネルで、サービス管理で登録しただけで、出来ます。

エクステンションははローカルもしくはリモートのどちらかで動作するサービスです。 ローカルで動作するエクステンションは余分なネットワークトラフィックを必要としないのでネットワークの帯域幅で有利です。 ただし、ローカルでエクステンションを動作させるには構築が必要で、追加のアプリケーションのインストールといったいくつかのステップが必要となることもあります。別の方法としてイントラネットもしくはインターネット上のサービスをリモートのエクステンションとして動作させることができます。  この場合、他の誰かによって構成されて、容易に利用可能です。 エクステンションをリモートで動作させることは多くの Deki Wiki で利用することができ、全てのサイトのエクステンションを用意にアップデートすることが出来ます。

以下のスクリーンショットはエクステンション・サービスの追加がいかに簡単かを示したものです。

./control-panel.png
コントロールパネル
./service-mgmt.png
サービスの管理 - 一覧表示
./remote-service.png
サービスの管理 - リモートサービスの追加

 エクステンション追加時には、利用方法について適用できるいくつかの設定項目があります:

  • 名前空間: エクステンションの名前空間を置き換えします。 空白にすると、エクステンション関数から名前空間のプリフィックスを取り除きます。
  • タイトル: ドキュメンテーション・ページのエクステンションのタイトルを置き換えします。
  • 説明: ドキュメンテーション・ページのエクステンションについての説明文のカスタマイズを追加します。

エクステンションで何ができるのか?

Deki Wikiはすぐに使えるいくつかのエクステンションを提供しており、そのエクステンションを使うことによりwikiのページは動的なコンテンツを埋め込むことが簡単に出来ます。

Flickr Service
スライドショーとバッチ
./flickr.png
Google Service
マーカとポップアップ・バブル付のGoogle Maps
./google-maps.png
Graphviz Service
複雑なグラフの生成
./graphviz.png
ImageMagick Service
画像に効果を適用
./imagemagick.png
MathService
数式の生成
./math.png
Yahoo Service
株式情報とチャートの表示
./yahoo-stock.png

エクステンションの利用方法は?

エクステンションは関数群で定義し、コントロールパネルでそのサービスを有効にすることにより利用できます。 様々な方法でこれらの機能を呼び出すことができます。

簡単な呼び出しで使われる一般的な使用方法は直接インラインに二重の中括弧 {{...}} を使うことです。  次の関数は"マイページ"をページ内に含むことになります。

{{wiki.page("My page")}} 

もうひとつの一般的な使い方は<pre class="script"> ブロック内で呼び出すことです。  The <pre> 記法の利点は他のマークアップに影響されずに複数行にまたぐことができることです。

<pre class="script">wiki.page("My Page")</pre> 

最後の記法はやや特殊ですが、大きなストリング引数を持つ関数に適しています。  それは <pre class="script"> 記法をも使いますが、関数を呼び出すのに, もうひとつの属性を追加します。  たとえば <pre class="script" function="function-name"> のようにです。  <pre> ブロックの内容には最初の引数として渡されます。

<pre class="script" function="wiki.page">My Page</pre> 

What Extensions are available?

DekiWiki ships with a dozen extensions for Google, Windows Live, Flickr, and many others.  All extensions are setup in a similar manner, but some extension have prerequisites before they can be used.  Consult the documentation for each extension to see what is needed to set it up.


What data types do Extensions support?

Extensions use a small set of data types.  They are

  • nil - the empty value (i.e. nil, null)
  • bool - a boolean value (i.e. true, false)
  • num - an integer or floating-point number (e.g. 1, -5, 0.6)
  • string - a sequence of characters (e.g. "Hello World")
  • uri - a uniform resource identifier (only used internally)
  • map - an associative array (e.g. { a : 1, b : 2 })
  • list - an indexed array (e.g. [ 1, 2, "a" ])
  • xml - an xml document (only used internally)

How do you create your own Extensions using .Net?

 Refer here for a step-by-step tutorial on creating a new extension.

How do you create your own Extensions without .Net?

Extension use a simple document exchange protocol for registering and invocation.  This makes it possible to write extensions in any language.

Registration

When an extension is registered, it is queried for its list of functions.  Let's assume our service resides at http://ext.mindtouch.com:8080/math.  When we register it, Deki Wiki issues a GET request on this uri, resulting in the following response:

<library>
    <title>MindTouch Deki Math Service</title>
    <copyright>Copyright (c) 2007 MindTouch, Inc.</copyright>
    <uri.help>http://doc.opengarden.org/Deki_API/Reference/Math</uri.help>
    <namespace>math</namespace>
    <function>
        <name>formula</name>
        <uri>http://ext.mindtouch.com:8080/math/formula</uri>
        <access>public</access>
        <return>xml</return>
        <param>
            <name>formula</name>
            <type>str</type>
            <hint>formula in Latex-AMS notation</hint>
        </param>
    </function>
</library>

The important parts in this response are the <namespace> and <function> elements.  The <namespace> element is optional and determines the prefix for the functions.  For example, in this case, the namespace is "math", which means that all functions from this service will be prefixed with "math.".

The <function> element describes a function in the extension.  There can be any number of <function> elements in the response document.  The crucial parts in this element are the <name> and <uri> elements.  The <name> element is the name of the function, which will be combined with the namespace prefix to create the full name; in this case "math.formula".  The <uri> element specifies where the function is located.  When Deki Wiki finds a reference to this functions, it resolves the name to this URI and the POSTs a request document to it.

The rest of the elements (<title>, <uri.help>, <param>, <access>, etc.) are only informative and do not impact registration and execution.  These elements are only used to provide guidance to users when they access extensions.

Invocation

The next step in the chain is invoking an extension function.  Keeping with the Math service, let's look at the following wiki text:

{{math.formula("\\pi=\\frac{3}{4} \\sqrt{3}+24 \\int_0^{1/4}{\\sqrt{x-x^2}dx}")}}

The parameters get converted into a list, which is then serialized to XML.

<value type="list">
    <value key="#" type="str">\pi=\frac{3}{4} \sqrt{3}+24 \int_0^{1/4}{\sqrt{x-x^2}dx}</value>
</value>

The 'key' attribute is always '#' for lists, but has an alphanumeric value for maps.  The 'type' attribute specifies the value type (e.g. nil, bool, num, str, uri, map, list, or xml).

When the function completes, it responds with the invocation result, which is also returned inside an array:

<value type="doc">
    <value key="#" type="xml">
        <html>
            <body>
                <img src="http://ext.mindtouch.com:8080/host/$store/_x002F_math/806b359f-94ef-3aae-e253-2877a0af8a8c.img" />
            </body>
        </html>
    </value>
</value>

The XML format for extensions is base on DekiScript, the built-in expression language for Deki Wiki.  The following table shows how the native DekiScript types are encoded in as XML.

Type
Encoding 
nil
<value type="nil" />
bool
<value type="bool>true</value>
<value type="bool">false</value> ­
numbers
<value type="num">123.4</value>
string
<value type="str">Hello World!</value>
uri
<value type="uri">http://somewhere.com</value>­
map
<value type="map">...</value>
where ... contains zero or more <value> elements with a "key" attribute
list
<value type="list">...</value>
where ... contains zero or more <value> elements with a "key" attribute equal to "#" (e.g. <value type="nil" key="#" />)
xml
<value type="xml">...</value>
where ... contains a single xml node

Factory Included Extension Services

Service Description
Digg
The Digg service embeds the "Digg It" widget.
Feed The Feed service embeds RSS and ATOM feeds.
Flickr The Flickr service emeds photo badges and slideshows.
Gabbly The Gabbly service embeds a chat room that allows users to talk with anyone else across a site.
Google The Google service embeds an interactive Google map control.
Graphviz The Graphviz service generates dynamic flowcharts using the dot graphics notation.
ImageMagick
The ImageMagick service allows images to be manipulated in various ways.
Math
The Math service generate representations of mathematical formulae.
Media The Media service embeds videos from YouTube, Google, VMix, and others.
MySql
The MySql service embeds tables from SQL queries.
Widgetbox
The Widgetbox service embeds widgets from Widgetbox.com
WindowsLive
The WindowsLive service embeds an interactive Virtual Earth control.
Yahoo The Yahoo service embeds interactive stock quotes from Yahoo! Finance
タグ

ファイル 0

 
あなたはコメントを投稿するには ログイン しなければなりません。
Powered by MindTouch Deki v.8.08.1a