Changeset 17116
- Timestamp:
- 08/05/08 23:18:49 (5 years ago)
- Location:
- websites/mobilecat/trunk
- Files:
-
- 2 added
- 2 removed
- 8 modified
-
lib/MobileCat/Controller/API/Mail/Post.pm (modified) (1 diff)
-
lib/MobileCat/Controller/Entry.pm (modified) (3 diffs)
-
lib/MobileCat/Controller/Root.pm (modified) (1 diff)
-
mobilecat.yaml (modified) (1 diff)
-
root/entry/list.tt (modified) (2 diffs)
-
root/entry/page.tt (deleted)
-
root/entry/post.tt (added)
-
root/entry/show.tt (added)
-
root/index.tt (modified) (2 diffs)
-
root/post.tt (deleted)
-
root/settings/index.tt (modified) (1 diff)
-
root/static/mobile.css (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
websites/mobilecat/trunk/lib/MobileCat/Controller/API/Mail/Post.pm
r16952 r17116 41 41 $c->req->param(filter => 1); 42 42 $c->req->param(body => $text); 43 $c->forward('/ post');43 $c->forward('/entry/create'); 44 44 } 45 45 -
websites/mobilecat/trunk/lib/MobileCat/Controller/Entry.pm
r16955 r17116 2 2 use strict; 3 3 use warnings; 4 use base 'Catalyst::Controller ';4 use base 'Catalyst::Controller::Resources'; 5 5 6 sub default :Path { 7 my ($self, $c, $entry_id) = @_; 6 __PACKAGE__->config( member => { 7 delete => { method => 'POST', path => 'delete' }, 8 }); 8 9 9 if ($entry_id) { 10 $c->view('TT')->template('entry/page.tt'); 11 $c->forward('page', [ $entry_id ]); 12 } 13 elsif (my $user_id = $c->req->param('user')) { 14 $c->view('TT')->template('entry/list.tt'); 15 $c->forward('user', [ $user_id ]); 16 } 17 else { 18 $c->view('TT')->template('entry/list.tt'); 10 use Acme::Neko; 11 12 sub list { 13 my ($self, $c) = @_; 14 if (my $user_id = $c->req->param('user')) { 15 $c->forward('user_list', [ $user_id ]); 16 } else { 19 17 $c->forward('recent'); 20 18 } … … 25 23 $c->stash->{entries} = $c->model('Entries')->search(undef, { 26 24 order_by => ['created_at DESC'], 27 page => 1,28 25 rows => 5, 29 26 }); 30 27 } 31 28 32 sub user :Private {29 sub user_list :Private { 33 30 my ($self, $c, $user_id) = @_; 34 31 my $user = $c->model('Users')->find($user_id); 35 unless ($user) {36 $c->error(404);37 return;38 }39 32 40 33 $c->stash->{entries} = $c->model('Entries')->search({ … … 47 40 } 48 41 49 sub page :Private { 42 sub post { 43 my ($self, $c) = @_; 44 } 45 46 sub create { 47 my ($self, $c) = @_; 48 49 $c->view('TT')->template('entry/post.tt'); 50 51 if ($c->req->param('filter')) { 52 $c->req->param(body => do { 53 Acme::Neko->nya( $c->req->param('body') ); 54 }); 55 } 56 57 $c->req->param(user_agent => $c->req->user_agent); 58 $c->req->param(user_id => $c->user->id) if $c->user_exists; 59 $c->form( 60 body => [ 'NOT_BLANK', ['NOT_REGEX', qr/^\s+$/] ], 61 user_agent => [], 62 user_id => [], 63 ); 64 65 if ($c->form->has_error) { 66 return; 67 } else { 68 $c->model('Entries')->create($c->form->valid); 69 } 70 71 $c->res->redirect( $c->uri_for('/') ); 72 } 73 74 sub show { 50 75 my ($self, $c, $entry_id) = @_; 51 my $entry = $c->model('Entries')->find($entry_id); 52 unless ($entry) { 76 $c->stash->{entry} = $c->model('Entries')->find($entry_id) or do { 53 77 $c->error(404); 54 78 return; 79 }; 80 } 81 82 sub delete { 83 my ($self, $c, $entry_id) = @_; 84 if (not $c->user_exists) { 85 return; 55 86 } 87 88 my $entry = $c->model('Entries')->single({ 89 id => $entry_id, 90 user_id => $c->user->id, 91 }) or do { 92 $c->error(404); 93 return; 94 }; 56 95 57 $c->stash->{entry} = $entry; 96 $entry->delete; 97 98 $c->res->redirect( $c->uri_for('/entry', { user => $c->user->id }) ); 58 99 } 59 100 -
websites/mobilecat/trunk/lib/MobileCat/Controller/Root.pm
r16955 r17116 6 6 __PACKAGE__->config->{namespace} = ''; 7 7 8 use Acme::Neko;9 10 8 sub index :Private { 11 9 my ($self, $c) = @_; 12 10 $c->forward('/entry/recent'); 13 }14 15 sub post :Local {16 my ($self, $c) = @_;17 18 return unless $c->req->method eq 'POST';19 20 if ($c->req->param('filter')) {21 $c->req->param(body => do {22 Acme::Neko->nya( $c->req->param('body') );23 });24 }25 26 $c->req->param(user_agent => $c->req->user_agent);27 $c->req->param(user_id => $c->user->id) if $c->user_exists;28 $c->form(29 body => [ 'NOT_BLANK', ['NOT_REGEX', qr/^\s+$/] ],30 user_agent => [],31 user_id => [],32 );33 34 if ($c->form->has_error) {35 return;36 } else {37 $c->model('Entries')->create($c->form->valid);38 }39 40 $c->res->redirect( $c->uri_for('/') );41 11 } 42 12 -
websites/mobilecat/trunk/mobilecat.yaml
r16950 r17116 8 8 expires: 3600 9 9 storage: /tmp/mobilecat/session 10 param: sid 10 11 11 12 validator: -
websites/mobilecat/trunk/root/entry/list.tt
r16955 r17116 1 1 [% WHILE (entry = entries.next); 2 INCLUDE "entry/ page.tt";2 INCLUDE "entry/show.tt"; 3 3 END; 4 4 %] 5 5 6 [% IF template.name == "entry/list.tt" %] 7 6 [% IF entries.attrs.page %] 8 7 <div class="center"> 9 8 [% FOREACH page = entries.pager.pages_in_navigation(5) %] … … 23 22 [% END %] 24 23 </div> 24 [% END %] 25 25 26 [% IF template.name == "entry/list.tt" %] 26 27 <br /> 27 28 <a href="[% c.req.uri.hostless %]" accesskey="8">更新</a><br /> -
websites/mobilecat/trunk/root/index.tt
r16955 r17116 1 <a href="/ post">投稿する</a><br />1 <a href="/entry/new">投稿する</a><br /> 2 2 <br /> 3 3 … … 6 6 <br /> 7 7 <a href="/" accesskey="0">更新</a><br /> 8 <a href="/ post" accesskey="1">投稿する</a><br />8 <a href="/entry/new" accesskey="1">投稿する</a><br /> 9 9 <a href="/about">ここは何?</a><br /> 10 10 [% IF c.user_exists %] -
websites/mobilecat/trunk/root/settings/index.tt
r16952 r17116 11 11 <img src="http://static.koneta.org/dot.gif" height="5" /><br /> 12 12 13 <a href="[% c.uri_for('/entry/', { user => c.user.id }) %]">自分の投稿リスト</a><br /> 14 <img src="http://static.koneta.org/dot.gif" height="5" /><br /> 15 13 16 <a href="[% c.uri_for('/logout') %]">ログアウト</a><br /> 14 17 <img src="http://static.koneta.org/dot.gif" height="5" /><br /> -
websites/mobilecat/trunk/root/static/mobile.css
r16950 r17116 10 10 } 11 11 .small { 12 font-size: 16pt;12 font-size: smaller; 13 13 } 14 14 .center {
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)