Jifty::Manual::Tutorial_ja(3) XXXXXXXXXXXJifty

XX

XXXXXXXXXXXXXXJiftyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXX

XXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

JiftyXXXXXXX

XXXXXXXXXXXXXXXXXXDRY (Don't Repeat Yourself) XXXXXXXXXXXXXXXXXXXXXXXPerlXCPANXXXXXXXXXXXXJiftyXCPANXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXCPANXXXXXXXXXXXX100XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXPerlXXXXXXXXXXPerlXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXJiftyXXXXXXXXXXXXXXXXXXXXXXJiftyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXPerlXXXXXXXXXXCPANXXXXXXXXXJiftyXXXXXXXXXXXXXXXXXXXX

  # perl -MCPAN -e'install Jifty'

JiftyX".tar.gz"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  # tar xzvf jifty-<version>.tgz
  # cd jifty-<version>
  # perl Makefile.PL
  # make
  # make test
  # make install

XXXXXXXXXXXXXXXXXXXXXXXXX"[email protected]"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX``XXXXXX''XXXXXXXXXX

XXXXXXXXXXXXXXXXXXX

JiftyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXjiftyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXbin/XXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXJiftyXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXJiftyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXJiftyXXXXXXXXXXXXXXXXX

  # jifty app --name MyWeblog
  Creating new application MyWeblog
  Creating directory MyWeblog/lib
  Creating directory MyWeblog/lib/MyWeblog
  Creating directory MyWeblog/bin
  Creating directory MyWeblog/etc
  Creating directory MyWeblog/doc
  Creating directory MyWeblog/log
  Creating directory MyWeblog/var
  Creating directory MyWeblog/var/mason
  Creating directory MyWeblog/share
  Creating directory MyWeblog/share/po
  Creating directory MyWeblog/share/web
  Creating directory MyWeblog/share/web/templates
  Creating directory MyWeblog/share/web/static
  Creating directory MyWeblog/lib/MyWeblog/Model
  Creating directory MyWeblog/lib/MyWeblog/Action
  Creating directory MyWeblog/t
  Creating configuration file MyWeblog/etc/config.yml

XXXXXXXXXXXXXXXXXX

lib
lib/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
bin
bin/XXXXXjiftyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"schema"XXXXXXXXXXXXXXXXXXXXX"server"XXXXXXjiftyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    jifty help
etc
etc/XXXXXXXXXXXXXXXXXXXXXXXXXXJiftyXXXXXXXXXXXXXXXXX
doc
XXXJiftyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXdoc/XXXXXXXXX
log
JiftyXLog::Log4perlXXXXXXXXXXXXXXXXXXXXXXlogXXXXXXXserver.logXerror.logXXXXXXXXXXXXX
var
JiftyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
share/web/po
JiftyXXXXXXXXXXXXXXXX(``portable object templates'')Xshare/web/po/XXXXXXXXX
share/web/templates
XXXXJiftyXXXXXXXXXXXXXXXXXXXTemplate::DeclareXXXXXXXXXXXXHTML::MasonXXXXXXXXXXXXXXXXXXMasonXXXXXXXXshare/web/templates/XXXXXXXXXJiftyXXXXXXXXXXXXXXXXXXXXXXXXXshare/web/templates/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

PerlXXXXJiftyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  perl -MJifty::Util -e 'print Jifty::Util->share_root'
share/web/static
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXshare/web/static/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXJiftyXXXXXXCSSXXXXXXXXXJavascriptXXXXXXPonyXXXXXXXXJiftyXXXXXXXXXXXXshare/web/staticXXXXXXXXJiftyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

lib/MyWebLog/Model
XXXXXXXXXXXXXXXXXXXX"lib/MyWeblog/Model"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXJiftyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

JiftyXXXXXXXXXXXXXXXXXXJifty::Manual::ObjectModelXXXXXXXX

lib/MyWebLog/Action
XXXXXXXXXXXXXXXXXAPIXXXXXXXXXXXXXHTMLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXJiftyXXXXXXXXXXXXXXXXXXXXXXXXX("CREATE", "READ", "UPDATE", "DELETE")XXXXXXXXXXXXXXXXXX
t
JiftyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXMyWebLogXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXRSSXAtomXXXXXXXXXXXXXXXXX

XX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"post"XXXXXX

  # cd MyWeblog
  # jifty model --name Post
  Writing file /tmp/MyWeblog/lib/MyWeblog/Model/Post.pm
  Writing file /tmp/MyWeblog/t/00-model-Post.t

XXXXXXXXXXXPostXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXlib/MyWeblog/Model/Post.pmXXXXXXXXX

XXXXXXXXXXXXXXX

  use strict;
  use warnings;
  
  package MyWeblog::Model::Post;
  use Jifty::DBI::Schema;
  
  use MyWeblog::Record schema {
  
  };
  
  # Your model-specific methods go here.
  
  1;

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"body"X"title"XXXXXXXXXXXX"category"XXXXXXX"category"X"tags"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXX

  use MyWeblog::Record schema {

XXXXXXXXXX

  column title =>
        type is 'text',
        label is 'Title',
        default is 'Untitled post';
  column body => 
        type is 'text',
        label is 'Content',
        render_as 'Textarea';

XXXXXXXXXXXXXXXX

JiftyXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXX"jifty server"XXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXJiftyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXJiftyXXXXXXXXXSQLiteXXXXXXXXXXXXXXXXXXXXXXXXXXXXXPostgreSQLXMySQLXXXXXXXXetc/config.ymlXXXXXXXXXXXXXXXXX(Jifty::ConfigXXXXXXXXXXXXXXX)X

    # jifty server
    WARN - Application schema has no version in the database.
    WARN - Automatically creating your database.
    INFO - Generating SQL for application MyWeblog...
    INFO - Using MyWeblog::Model::Post, as it appears to be new.
    INFO - Using Jifty::Model::Session, as it appears to be new.
    INFO - Using Jifty::Model::Metadata, as it appears to be new.
    INFO - Set up version 0.0.1, jifty version 0.81208
    INFO - You can connect to your server at http://localhost:8888/

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXJiftyXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXURLXXXXXXXXXXXXXXXXXXXXXAJAXXXXXXXUIXXXXXXXXXXXXXXXXXPonyXXXXXXXX

XXXXXXXXXXXXX``./bin/jifty server''XXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXlib/MyWeblog/View.pmXXXXXXXXXXXXXXXXXXXXXXXX

  package MyWeblog::View;
  use strict;
  use warnings;
  use Jifty::View::Declare -base;
  
  template post => page { title => 'Post Entry' } content {
      my $action = new_action(class => 'CreatePost');
  
      form {
          render_action $action;
          form_submit(label => 'Post');
      }
  };
  
  1;

XXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXAJAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXX

lib/MyWeblog/View.pmXXXXX"post"XXXXXXXXXXXXXX``1;''XXXXXXXXXXXXXXXXXXXXX

  template '/' => page {
      # Get all posts.
      my $posts = MyWeblog::Model::PostCollection->new;
      $posts->unlimit;
  
      # Display each post in a <dl>.
      dl {
          while (my $post = $posts->next) {
              dt { $post->title }
              dd { $post->body  }
          }
      }
  };

XXX"http://localhost:8888"XXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXJiftyXXXXXXXXXXXXXXXXXXXPage regionsXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXAJAXXX"lynx"X"w3m"XXXXXXXXXXXXXXXXXXXXXGETXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXlib/MyWeblog/View.pmX'/'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  template '/' => page {
      render_region(
          name => 'myweblog-posts',
          path => '/fragments/page_of_posts',
      );
  };

XXXXXXXXXXXXXXXXXXXXXXXXXlib/MyWeblog/View.pmXXX"/fragments/page_of_posts"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  template '/fragments/page_of_posts' => sub {
      # Retrieve the current page argument, defaulting to 1.
      my $page = get('page') || 1;
      
      # Get all posts.
      my $posts = MyWeblog::Model::PostCollection->new;
      $posts->unlimit;
      
      # Display up to three posts on the current page.
      $posts->set_page_info(
          current_page => $page,
          per_page     => 3,
      );
  
      # Notify the user what page they're on if there are multiple.
      if ($posts->pager->last_page > 1) {
          p { "Page $page of " . $posts->pager->last_page }
      }
  
      # Display the current page of posts.
      dl {
          attr { class => 'list' };
  
          while (my $post = $posts->next) {
              dt { $post->title }
              dd { $post->body  }
          }
      };
  
      # Previous page link, the 'page' argument here will set a new value when
      # this region is invoked again.
      if ($posts->pager->previous_page) {
          hyperlink(
              label => 'Previous Page',
              onclick => {
                  args => {
                      page => $posts->pager->previous_page,
                  },
              },
          );
      }
  
      # Next page link.
      if ($posts->pager->next_page) {
          hyperlink(
              label => 'Next Page',
              onclick => {
                  args => {
                      page => $posts->pager->next_page,
                  },
              },
          );
      }
  };

XXXXXXXJiftyXXXXXXXXXXXXXXXXXXXXXXX"/post"XXXXXX3XXXXXXXXXXXXXXXXXXXXXXXXXXXXAJAXXXXX"Next Page"X"Previous Page"XXXXXXXXXXXXXXXXXXXXXXJavascriptXXXXX"lynx"XXXXXXXAJAXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX!

XXXXXXXXXXXXXXXXXX?

"MyWeblog::Model::PostCollection"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXPostCollection.pmXXXXXXXXXXXXXXXXXXJiftyX"Jifty::ClassLoader"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXJifty::ClassLoaderXXXXXXXX

XXXXXXX

XXXXXXXXXXXXXXXURLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXURLXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

lib/MyWeblog/Dispatcher.pmXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  package MyWeblog::Dispatcher;
  use strict;
  use warnings;
  use Jifty::Dispatcher -base;
  
  before '*' => run {
      my $top = Jifty->web->navigation;
      $top->child(Home => url => '/');
      $top->child(Post => url => '/post', label => 'Post Article');
  };
  
  1;

XXXXXXXXXXXXJifty::Web::MenuXXXXXXXX

XXXXX

XXXXXXXXXXXXXXJiftyXXXXXXXXXXXXXXXXXXXXXXXXXXJiftyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XX"jifty-devel"XXXXXXXXXXXXXXXJiftyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXX

  • XXXXXXXXXXXXX

    Jifty::Manual::Models

  • JiftyXXXXXXX

    Jifty::Manual::Actions

  • XXXXXXXXX

    Jifty::Manual::PageRegions

  • CSSXJS

    Jifty::Manual::UsingCSSandJS, Jifty::Manual::JavaScript

  • XXXXXXX

    Jifty::Manual::TutorialRestXXXXXXXXXXXX

  • XX - XXXXXXXXXXX

    Jifty::Manual::Continuations

  • XXXXXXXXXXXXX

    Jifty::Manual::AccessControl

  • XXXXXXXXXX

    Jifty::Manual::Deploying

  • XXXXXXXXXXXXXX

    Jifty::Manual::Upgrading

  • XXXXXXXXXX

    Jifty::Manual::Cookbook

XXXXXX

XXXXXXXX

"jifty"XXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  jifty help
  jifty help <command>

XXXXXXXXXXXXXXXXXXXXXXXXXXXXX"AdminMode"XXXXXXXXXXXXXXXXXXXXXXXXXXOnline DocsXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXX

"[email protected]"XXJiftyXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

XXXXXXXXXXXXXXXXX"[email protected]"XXXXXXXXXXXXXX

wikiXXX

wikiXXXXXXXXXXXXXXwikiXJiftyXXXXXXXXXXXXX

<http://jifty.org/>XXXXXXXXXXXXXXXXX

XXwikiXXWiftyXXXJiftyXXXXwikiXXXXXXXXXXXXXXXXXjiftyXsubversionXXXXXXXXXXXXXXXXX

XXXXXXX

JiftyXXXX"[email protected]"XXXXXXXXXX

XXX

XXXX ("ishigaki_at_cpan.org")