[perldocjp-cvs 1553] CVS update: docs/articles/www.perl.com/pub/2005/06/02

Zurück zum Archiv-Index

ktats****@users***** ktats****@users*****
2012年 9月 27日 (木) 23:28:07 JST


Index: docs/articles/www.perl.com/pub/2005/06/02/catalyst.html
diff -u docs/articles/www.perl.com/pub/2005/06/02/catalyst.html:1.2 docs/articles/www.perl.com/pub/2005/06/02/catalyst.html:1.3
--- docs/articles/www.perl.com/pub/2005/06/02/catalyst.html:1.2	Thu Sep 27 23:18:20 2012
+++ docs/articles/www.perl.com/pub/2005/06/02/catalyst.html	Thu Sep 27 23:28:06 2012
@@ -18,6 +18,7 @@
 <ul>
 <li> <a href="#4">スピード</a></li>
 <li> <a href="#5">簡易性</a></li>
+
 <li> <a href="#6">柔軟性</a></li>
 </ul>
 <li> <a href="#7">サンプルアプリケーション: 30行のコードで、MiniMojo, Ajax-Based Wiki</a></li>
@@ -189,12 +190,12 @@
 次のようにします:
 </p>
 
-<pre class=code><code>use Catalyst qw/Email Prototype Textile/;</code></pre>
-<p>will load <code>Catalyst::Plugin::Email</code>, <code>Catalyst::Plugin::Prototype</code>,
+<pre class="prettyprint"><code>use Catalyst qw/Email Prototype Textile/;</code></pre>
+<p class="original">will load <code>Catalyst::Plugin::Email</code>, <code>Catalyst::Plugin::Prototype</code>,
     and <code>Catalyst::Plugin::Textile</code> in one shot.</p>
 
-<p><code>Catalyst::Plugin::Email</code>, <code>Catalyst::Plugin::Prototype</code>,
-    and <code>Catalyst::Plugin::Textile</code>を一回でロードします。</p>
+<p><code>Catalyst::Plugin::Email</code>と<code>Catalyst::Plugin::Prototype</code>と
+    と<code>Catalyst::Plugin::Textile</code>を一回でロードします。</p>
 
 <p><em>開発</em></p>
 <p class="original">Catalyst comes with a built-in lightweight HTTP server for development purposes.
@@ -229,7 +230,7 @@
 <code>Catalyst::Log</code> クラスでロギングを動かしています;
 デバッギングのためや目的の情報を得るために、以下のような行を追加することで、どんなアクションも記録できます。
 
-<pre class=code><code>$c-&gt;log-&gt;info("We made it past the for loop");
+<pre class="prettyprint"><code>$c-&gt;log-&gt;info("We made it past the for loop");
 $c-&gt;log-&gt;debug( $sql_query );</code></pre>
 <p><img src="http://www.perl.com/2005/06/02/graphics/log-screenshot.gif" alt="Log screenshot" height="411" width="515"><br>
   <em>Figure 1. Logging</em></p>
@@ -300,7 +301,7 @@
 URLとアクションのマッピングには複数のやりかたがあります(that is, a Catalyst method)。
 あなたがどうしたいかに依ります。まず、文字どおりのディスパッチ、特定のパスにマッチするものは:
 
-<pre class=code><code>package MyApp::C::Quux;
+<pre class="prettyprint"><code>package MyApp::C::Quux;
 
 # http://localhost:3000/foo/bar/yada だけにマッチ
 sub baz : Path('foo/bar/yada') { }</code></pre>
@@ -310,7 +311,7 @@
 
 <p>トップレベル、または、グローバルは、アプリケーションベースでメソッド名に直接マッチします:</p>
 
-<pre class=code><code>package MyApp::C::Foo;
+<pre class="prettyprint"><code>package MyApp::C::Foo;
 
 # http://localhost:3000/bar にのみマッチ
 sub bar : Global { }</code></pre>
@@ -322,7 +323,7 @@
 Controllerクラスの名前から由来する名前空間でのみ動きます。
 </p>
 
-<pre class=code><code>package MyApp::C::Catalog::Product;
+<pre class="prettyprint"><code>package MyApp::C::Catalog::Product;
 
 # http://localhost:3000/catalog/product/buy にマッチ
 sub buy : Local { }
@@ -343,7 +344,7 @@
 マッチした値は、<code>$c-&gt;request-&gt;snippets</code>の配列から利用できます。
 </p>
 
-<pre class=code><code>package MyApp::C::Catalog;
+<pre class="prettyprint"><code>package MyApp::C::Catalog;
 
 # http://localhost:3000/item23/order189 にマッチ
 sub bar : Regex('^item(\d+)/order(\d+)$') { 
@@ -358,7 +359,7 @@
 
 <p>正規表現はグローバルに動きます; 名前空間でのみ動かしたければ、正規表現に名前空間の名前を使ってください:</p>
 
-<pre class=code><code>sub foo : Regex('^catalog/item(\d+)$') { # ...</code></pre>
+<pre class="prettyprint"><code>sub foo : Regex('^catalog/item(\d+)$') { # ...</code></pre>
 
 <p class="original">Finally, you can have private methods, which are never available through URLs.
   You can only reach them from within the application, with a namespace-prefixed
@@ -368,7 +369,7 @@
 アプリケーション内からのみ、namespace-prefixed なパスで使うことができます:
 </p>
 
-<pre class=code><code>package MyApp::C::Foo;
+<pre class="prettyprint"><code>package MyApp::C::Foo;
 # matches nothing, and is only available via $c-&gt;forward('/foo/bar').
 sub bar : Private { }</code></pre>
 
@@ -392,7 +393,7 @@
 が直接に利用可能です. <code>stash</code> は、ユニバーサルなハッシュで、
 アプリケーションのコンポーネントでデータを共有するためのものです:</p>
 
-<pre class=code><code>$c-&gt;stash-&gt;{error_message} = "You must select an entry";
+<pre class="prettyprint"><code>$c-&gt;stash-&gt;{error_message} = "You must select an entry";
 
 # TT のテンプレートで:
 [% IF error_message %]
@@ -404,13 +405,13 @@
 
 <p>Stash の値はテンプレートに直接に入ります。 ですが、全てのコンテキストオブジェクトもまた利用可能です:</p>
 
-<pre class=code><code>&lt;h1&gt;[% c.config.name %]&lt;/h1&gt;</code></pre>
+<pre class="prettyprint"><code>&lt;h1&gt;[% c.config.name %]&lt;/h1&gt;</code></pre>
 
 <p class="original">To show a Mason example, if you want to use <code>Catalyst::View::Mason</code>:</p>
 
 <p>Masonの例を見るために, <code>Catalyst::View::Mason</code>が欲しければ:</p>
 
-<pre class=code><code>% foreach my $k (keys $c-&gt;req-&gt;params) {
+<pre class="prettyprint"><code>% foreach my $k (keys $c-&gt;req-&gt;params) {
   param: &lt;% $k %&gt;: value: &lt;% $c-&gt;req-&gt;params-&gt;{$k} %&gt;
 % }</code></pre>
 
@@ -480,7 +481,7 @@
 
 <p>このコマンドを実行:</p>
 
-<pre class=code><code>$ catalyst.pl MiniMojo
+<pre class="prettyprint"><code>$ catalyst.pl MiniMojo
 $ cd MiniMojo</code></pre>
 
 <p class="original">You've just created the skeleton for your entire application, complete with
@@ -495,7 +496,7 @@
 
 <p>ビルトインサーバの起動:</p>
 
-<pre class=code><code>$ script/minimojo_server.pl</code></pre>
+<pre class="prettyprint"><code>$ script/minimojo_server.pl</code></pre>
 
 <p class="original">MiniMojo is already running, though it isn't doing much
 just yet. (You should have received a web page consisting solely
@@ -519,7 +520,7 @@
 <p>プライベートな<code>end</code> アクションをアプリケーションクラス、<em>lib/MiniMojo.pm</em>に追加します。
 その新しいファイルを編集します:</p>
 
-<pre class=code><code>sub end : Private {
+<pre class="prettyprint"><code>sub end : Private {
     my ( $self, $c ) = @_;
     $c-&gt;forward('MiniMojo::V::TT') unless $c-&gt;res-&gt;output;
 }</code></pre>
@@ -542,7 +543,7 @@
 
 <p>ヘルパースクリプトが作った アプリケーションクラスの<code>default</code>アクションを置き換えます:</p>
 
-<pre class=code><code>sub default : Private {
+<pre class="prettyprint"><code>sub default : Private {
     my ( $self, $c ) = @_;
     $c-&gt;forward('/page/show');
 }</code></pre>
@@ -578,7 +579,7 @@
 <p>次に、<em>minimojo.sql</em>というファイルを作ります。
 SQLiteに<code>page</code>テーブルをセットアップするSQLです。</p>
 
-<pre class=code><code>-- minimojo.sql
+<pre class="prettyprint"><code>-- minimojo.sql
 CREATE TABLE page (
     id INTEGER PRIMARY KEY,
     title TEXT,
@@ -590,7 +591,7 @@
 
 <p>これから、データベースを作成します。<code>sqlite</code>コマンドラインプログラムを使います:</p>
 
-<pre class=code><code>$ sqlite minimojo.db &lt; minimojo.sql</code></pre>
+<pre class="prettyprint"><code>$ sqlite minimojo.db &lt; minimojo.sql</code></pre>
 
 <p class="original">Depending on your setup, it might be necessary to call this as <code>sqlite3</code>.</p>
 
@@ -600,9 +601,9 @@
 
 <p>ヘルパースクリプトでModelクラスと基本のユニットテストを作ります(Figure 3に結果があります):</p>
 
-<pre class=code><code>$ script/minimojo_create.pl model CDBI CDBI dbi:SQLite:/path/to/minimojo.db</code></pre>
+<pre>$ script/minimojo_create.pl model CDBI CDBI dbi:SQLite:/path/to/minimojo.db</pre>
 
-<p><img src="http://www.perl.com/2005/06/02/graphics/model-create-screenshot.gif" alt="Model-creation screenshot" height="372" width="515"><br><em>Figure 3. Creating the model</em></p>
+<p><img src="http://www.perl.com/2005/06/02/graphics/model-create-screenshot.gif" height="372" width="515" alt="Model-creation screenshot"><br><em>Figure 3. Creating the model</em></p>
 
 <p class="original">The <em>minimojo_create.pl</em> script is a helper that uses Template
 Toolkit to automate the creation of particular modules. The previous command
@@ -631,7 +632,7 @@
 
 <p>ヘルパースクリプトによるViewクラスの作成:</p>
 
-<pre class=code><code>$ script/minimojo_create.pl view TT TT</code></pre>
+<pre class="prettyprint"><code>$ script/minimojo_create.pl view TT TT</code></pre>
 
 <p class="original">View classes go into <em>lib/MiniMojo/V/</em>.</p>
 
@@ -643,7 +644,7 @@
 
 <p>ヘルパースクリプトにより<code>Page</code>Controllerクラスを作ります:</p>
 
-<pre class=code><code>$ script/minimojo_create.pl controller Page</code></pre>
+<pre class="prettyprint"><code>$ script/minimojo_create.pl controller Page</code></pre>
 
 <p class="original">Controller classes live in <em>lib/MiniMojo/C/</em>.</p>
 
@@ -653,7 +654,7 @@
 
 <p><em>lib/MiniMojo/C/Page.pm</em>に<code>show</code>アクションを追加します:</p>
 
-<pre class=code><code>sub show : Regex('^(\w+)\.html$') {
+<pre class="prettyprint"><code>sub show : Regex('^(\w+)\.html$') {
     my ( $self, $c ) = @_;
     $c-&gt;stash-&gt;{template} = 'view.tt';
     # $c-&gt;forward('page');
@@ -684,7 +685,7 @@
 
 <p><em>root/view.tt</em>を作ります:</p>
 
-<pre class=code><code>&lt;html&gt;
+<pre class="prettyprint"><code>&lt;html&gt;
     &lt;head&gt;&lt;title&gt;MiniMojo&lt;/title&gt;&lt;/head&gt;
     &lt;body&gt;
         &lt;h1&gt;MiniMojo is set up!&lt;/h1&gt;
@@ -713,7 +714,7 @@
 <p><code>Prototype</code> と <code>Textile</code> プラグインを使うために、
 アプリケーションクラスの<em>lib/MiniMojo.pm</em>を変更しましょう:</p>
 
-<pre class=code><code>use Catalyst qw/-Debug Prototype Textile/;</code></pre>
+<pre class="prettyprint"><code>use Catalyst qw/-Debug Prototype Textile/;</code></pre>
 
 <p class="original">
 Note that you can use the plugins by specifying their base names; Catalyst
@@ -731,7 +732,7 @@
 ページViewと、編集のコードを追加します:</p>
 
 
-<pre class=code><code>sub page : Private {
+<pre class="prettyprint"><code>sub page : Private {
     my ( $self, $c, $title ) = @_;
     $title ||= $c-&gt;req-&gt;snippets-&gt;[0] || 'Frontpage';
     my $query = { title =&gt; $title };
@@ -759,7 +760,7 @@
 
 <p><code>show</code>アクション中の<code>$c-&gt;forward('page');</code>をコメントを外します。</p>
 
-<pre class=code><code>sub edit : Local {
+<pre class="prettyprint"><code>sub edit : Local {
     my ( $self, $c, $title ) = @_;
     $c-&gt;forward('page');
     $c-&gt;stash-&gt;{page}-&gt;body( $c-&gt;req-&gt;params-&gt;{body} )
@@ -803,7 +804,7 @@
 
 <p><em>root/view.tt</em> を変更し、Ajax codeを含めます:</p>
 
-<pre class=code><code>&lt;html&gt;
+<pre class="prettyprint"><code>&lt;html&gt;
      &lt;head&gt;&lt;title&gt;MiniMojo&lt;/title&gt;&lt;/head&gt;
      [% c.prototype.define_javascript_functions %]
      [% url = base _ 'page/edit/' _ page.title %]
@@ -821,7 +822,7 @@
 
 <p>その行:</p>
 
-<pre class=code><code>[% c.prototype.define_javascript_functions %]</code></pre>
+<pre class="prettyprint"><code>[% c.prototype.define_javascript_functions %]</code></pre>
 
 <p class="original">includes the whole <em>prototype.js</em> library in a <code>script</code>
 block. Note that the <code>prototype</code> plugin is available in the context
@@ -832,7 +833,7 @@
 
 <p>セクション</p>
 
-<pre class=code><code>[% url = base _ 'page/edit/' _ page.title %] 
+<pre class="prettyprint"><code>[% url = base _ 'page/edit/' _ page.title %] 
 &lt;body Onload="new Ajax.Updater( 'view',  '[% url %]' )"&gt;
 &lt;h1&gt;[% page.title %]&lt;/h1&gt;
 &lt;div id="view"&gt;&lt;/div&gt;</code></pre>
@@ -844,14 +845,14 @@
 
 <p>最後に:</p>
 
-<pre class=code><code>&lt;textarea id="editor" rows="24" cols="80"&gt;[% page.body %]&lt;/textarea&gt;
+<pre class="prettyprint"><code>&lt;textarea id="editor" rows="24" cols="80"&gt;[% page.body %]&lt;/textarea&gt;
     [% c.prototype.observe_field( 'editor', {
         url =&gt; url,
         with =&gt; "'body='+value",
         update =&gt; 'view' }
     ) %]</code></pre>
 
-<p>periodically checks the <code>textarea</code> for changes and makes an Ajax
+<p class="original">periodically checks the <code>textarea</code> for changes and makes an Ajax
 request on demand.</p>
 
 <p>定期的に <code>textarea</code> を、変更があるかチェックし、デーモンでAjaxリクエストを作ります。</p>



perldocjp-cvs メーリングリストの案内
Zurück zum Archiv-Index