[Jifty-commit] r2367 - in jifty/trunk: . examples/MyWeblog/bin
examples/MyWeblog/doc examples/MyWeblog/etc
examples/MyWeblog/lib examples/MyWeblog/lib/MyWeblog
examples/MyWeblog/lib/MyWeblog/Action
examples/MyWeblog/lib/MyWeblog/Model examples/MyWeblog/share
examples/MyWeblog/share/po examples/MyWeblog/share/web
examples/MyWeblog/share/web/static
examples/MyWeblog/share/web/templates
examples/MyWeblog/share/web/templates/_elements
examples/MyWeblog/share/web/templates/fragments
examples/MyWeblog/t examples/MyWeblog/var
examples/MyWeblog/var/mason examples/MyWeblog/var/mason/cache
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Sun Dec 10 21:19:06 EST 2006
Author: jesse
Date: Sun Dec 10 21:19:05 2006
New Revision: 2367
Added:
jifty/trunk/examples/MyWeblog/
jifty/trunk/examples/MyWeblog/Makefile.PL
jifty/trunk/examples/MyWeblog/bin/
jifty/trunk/examples/MyWeblog/bin/jifty (contents, props changed)
jifty/trunk/examples/MyWeblog/doc/
jifty/trunk/examples/MyWeblog/etc/
jifty/trunk/examples/MyWeblog/etc/config.yml
jifty/trunk/examples/MyWeblog/lib/
jifty/trunk/examples/MyWeblog/lib/MyWeblog/
jifty/trunk/examples/MyWeblog/lib/MyWeblog/Action/
jifty/trunk/examples/MyWeblog/lib/MyWeblog/Model/
jifty/trunk/examples/MyWeblog/lib/MyWeblog/Model/Post.pm
jifty/trunk/examples/MyWeblog/share/
jifty/trunk/examples/MyWeblog/share/po/
jifty/trunk/examples/MyWeblog/share/web/
jifty/trunk/examples/MyWeblog/share/web/static/
jifty/trunk/examples/MyWeblog/share/web/templates/
jifty/trunk/examples/MyWeblog/share/web/templates/_elements/
jifty/trunk/examples/MyWeblog/share/web/templates/_elements/nav
jifty/trunk/examples/MyWeblog/share/web/templates/fragments/
jifty/trunk/examples/MyWeblog/share/web/templates/fragments/page-of-posts
jifty/trunk/examples/MyWeblog/share/web/templates/index.html
jifty/trunk/examples/MyWeblog/share/web/templates/post
jifty/trunk/examples/MyWeblog/t/
jifty/trunk/examples/MyWeblog/t/00-model-Post.t
jifty/trunk/examples/MyWeblog/var/
jifty/trunk/examples/MyWeblog/var/mason/
jifty/trunk/examples/MyWeblog/var/mason/cache/
Modified:
jifty/trunk/ (props changed)
Log:
r46076 at pinglin: jesse | 2006-12-10 20:01:21 +0000
* a full copy of the sample weblog app from the tutorial
Added: jifty/trunk/examples/MyWeblog/Makefile.PL
==============================================================================
--- (empty file)
+++ jifty/trunk/examples/MyWeblog/Makefile.PL Sun Dec 10 21:19:05 2006
@@ -0,0 +1,6 @@
+use inc::Module::Install;
+name('MyWeblog');
+version('0.01');
+requires('Jifty' => '0.61123_01');
+
+WriteAll;
Added: jifty/trunk/examples/MyWeblog/bin/jifty
==============================================================================
--- (empty file)
+++ jifty/trunk/examples/MyWeblog/bin/jifty Sun Dec 10 21:19:05 2006
@@ -0,0 +1,15 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+use File::Basename qw(dirname);
+use UNIVERSAL::require;
+
+BEGIN {
+ Jifty::Util->require or die $UNIVERSAL::require::ERROR;
+ my $root = Jifty::Util->app_root;
+ unshift @INC, "$root/lib" if ($root);
+}
+
+use Jifty::Script;
+$SIG{INT} = $SIG{TERM} = sub { warn "Stopped\n"; exit; };
+Jifty::Script->dispatch();
Added: jifty/trunk/examples/MyWeblog/etc/config.yml
==============================================================================
--- (empty file)
+++ jifty/trunk/examples/MyWeblog/etc/config.yml Sun Dec 10 21:19:05 2006
@@ -0,0 +1,40 @@
+---
+framework:
+ AdminMode: 1
+ ApplicationClass: MyWeblog
+ ApplicationName: MyWeblog
+ Database:
+ CheckSchema: 1
+ Database: myweblog
+ Driver: SQLite
+ Host: localhost
+ Password: ''
+ RecordBaseClass: Jifty::DBI::Record::Cachable
+ User: ''
+ Version: 0.0.1
+ DevelMode: 1
+ L10N:
+ PoDir: share/po
+ LogLevel: INFO
+ Mailer: Sendmail
+ MailerArgs: []
+
+ Plugins: []
+
+ PubSub:
+ Backend: Memcached
+ Enable: ~
+ Web:
+ BaseURL: http://localhost
+ DataDir: var/mason
+ Globals: []
+
+ MasonConfig:
+ autoflush: 0
+ default_escape_flags: h
+ error_format: text
+ error_mode: fatal
+ Port: 8888
+ ServeStaticFiles: 1
+ StaticRoot: share/web/static
+ TemplateRoot: share/web/templates
Added: jifty/trunk/examples/MyWeblog/lib/MyWeblog/Model/Post.pm
==============================================================================
--- (empty file)
+++ jifty/trunk/examples/MyWeblog/lib/MyWeblog/Model/Post.pm Sun Dec 10 21:19:05 2006
@@ -0,0 +1,24 @@
+use strict;
+use warnings;
+
+package MyWeblog::Model::Post;
+use Jifty::DBI::Schema;
+
+use MyWeblog::Record schema {
+
+ column title =>
+ type is 'text',
+ label is 'Title',
+ default is 'Untitled post';
+
+ column body =>
+ type is 'text',
+ label is 'Content',
+ render_as 'Textarea';
+
+};
+
+# Your model-specific methods go here.
+
+1;
+
Added: jifty/trunk/examples/MyWeblog/share/web/templates/_elements/nav
==============================================================================
--- (empty file)
+++ jifty/trunk/examples/MyWeblog/share/web/templates/_elements/nav Sun Dec 10 21:19:05 2006
@@ -0,0 +1,11 @@
+<%init>
+my $top = Jifty->web->navigation;
+$top->child( Home => url => "/", sort_order => 1);
+$top->child( Post => url => "/post", label => "Post Article");
+
+if (Jifty->config->framework('AdminMode') ) {
+ $top->child(Administration => url => "/__jifty/admin/", sort_order => 998);
+ $top->child(OnlineDocs => url => "/__jifty/online_docs/", label => 'Online docs', sort_order => 999);
+ }
+return();
+</%init>
Added: jifty/trunk/examples/MyWeblog/share/web/templates/fragments/page-of-posts
==============================================================================
--- (empty file)
+++ jifty/trunk/examples/MyWeblog/share/web/templates/fragments/page-of-posts Sun Dec 10 21:19:05 2006
@@ -0,0 +1,30 @@
+<%args>
+$page => 1
+</%args>
+<%init>
+my $posts = MyWeblog::Model::PostCollection->new();
+$posts->unlimit();
+$posts->set_page_info( current_page => $page,
+ per_page => 15
+ );
+$m->out("No items found.") if ($posts->pager->total_entries == 0);
+
+</%init>
+% if ($posts->pager->last_page > 1) {
+ Page <% $page %> of <% $posts->pager->last_page %>
+% }
+<dl class="list">
+% while (my $post = $posts->next) {
+ <dt><% $post->title %></dt>
+ <dd><% $post->body %></dd>
+% }
+</dl>
+
+% if ($posts->pager->previous_page) {
+ <% Jifty->web->link( label => "Previous Page", onclick => { args => { page => $posts->pager->previous_page }
+} ) %>
+% }
+% if ($posts->pager->next_page) {
+ <% Jifty->web->link( label => "Next Page", onclick => { args => { page => $posts->pager->next_page } } ) %>
+% }
+
Added: jifty/trunk/examples/MyWeblog/share/web/templates/index.html
==============================================================================
--- (empty file)
+++ jifty/trunk/examples/MyWeblog/share/web/templates/index.html Sun Dec 10 21:19:05 2006
@@ -0,0 +1,10 @@
+<&| /_elements/wrapper, title => Jifty->config->framework('ApplicationName') &>
+
+<% Jifty->web->region(name => "myweblog-posts",
+ path => "/fragments/page_of_posts") %>
+</&>
+<%init>
+my $posts = MyWeblog::Model::PostCollection->new();
+$posts->unlimit();
+</%init>
+
Added: jifty/trunk/examples/MyWeblog/share/web/templates/post
==============================================================================
--- (empty file)
+++ jifty/trunk/examples/MyWeblog/share/web/templates/post Sun Dec 10 21:19:05 2006
@@ -0,0 +1,13 @@
+<%init>
+my $action = Jifty->web->new_action(class => 'CreatePost');
+</%init>
+
+<&| /_elements/wrapper, title => "Post to your weblog" &>
+<% Jifty->web->form->start() %>
+<% Jifty->web->form->next_page( url => '/') %>
+<% $action->form_field('title') %>
+<% $action->form_field('body') %>
+<% Jifty->web->form->submit( label => 'Post' ) %>
+<% Jifty->web->form->end() %>
+</&>
+
Added: jifty/trunk/examples/MyWeblog/t/00-model-Post.t
==============================================================================
--- (empty file)
+++ jifty/trunk/examples/MyWeblog/t/00-model-Post.t Sun Dec 10 21:19:05 2006
@@ -0,0 +1,49 @@
+#!/usr/bin/env perl
+use warnings;
+use strict;
+
+=head1 DESCRIPTION
+
+A basic test harness for the Post model.
+
+=cut
+
+use Jifty::Test tests => 11;
+
+# Make sure we can load the model
+use_ok('MyWeblog::Model::Post');
+
+# Grab a system user
+my $system_user = MyWeblog::CurrentUser->superuser;
+ok($system_user, "Found a system user");
+
+# Try testing a create
+my $o = MyWeblog::Model::Post->new(current_user => $system_user);
+my ($id) = $o->create();
+ok($id, "Post create returned success");
+ok($o->id, "New Post has valid id set");
+is($o->id, $id, "Create returned the right id");
+
+# And another
+$o->create();
+ok($o->id, "Post create returned another value");
+isnt($o->id, $id, "And it is different from the previous one");
+
+# Searches in general
+my $collection = MyWeblog::Model::PostCollection->new(current_user => $system_user);
+$collection->unlimit;
+is($collection->count, 2, "Finds two records");
+
+# Searches in specific
+$collection->limit(column => 'id', value => $o->id);
+is($collection->count, 1, "Finds one record with specific id");
+
+# Delete one of them
+$o->delete;
+$collection->redo_search;
+is($collection->count, 0, "Deleted row is gone");
+
+# And the other one is still there
+$collection->unlimit;
+is($collection->count, 1, "Still one left");
+
More information about the Jifty-commit
mailing list