From: Michael Andreen Date: Sat, 15 Mar 2014 20:51:50 +0000 (+0100) Subject: Update to be compatible with newer Catalyst. X-Git-Url: https://ruin.nu/git/?p=ndwebbie.git;a=commitdiff_plain;h=a55dcea9b24ca54ee4a1a992c2d381cb5dde963b Update to be compatible with newer Catalyst. --- diff --git a/dependencies b/dependencies index 51ca051..3cabb01 100644 --- a/dependencies +++ b/dependencies @@ -1,10 +1,10 @@ - Task::Catalyst - Pulls in Moose and lots of other dependencies - DBD::Pg - Catalyst::Plugin::PageCache -- Catalyst::Plugin::Cache - Catalyst::Plugin::Compress::Zlib - Catalyst::Plugin::Session::DynamicExpiry -- Catalyst::Plugin::Unicode +- Catalyst::Plugin::Session::State::Cookie +- Catalyst::Plugin::Session::Store::File - Catalyst::Plugin::Authorization::ACL - Parse::BBCode - Catalyst::Model::Adaptor @@ -27,6 +27,7 @@ Bot deps: ------- Pulled by other things +- Catalyst::Plugin::Cache DateTime::TimeZone Email::Valid CGI diff --git a/lib/NDWeb.pm b/lib/NDWeb.pm index b72d765..63708aa 100644 --- a/lib/NDWeb.pm +++ b/lib/NDWeb.pm @@ -13,11 +13,12 @@ use Catalyst::Runtime 5.80; # directory use parent qw/Catalyst/; + use Catalyst qw/ -Debug ConfigLoader Static::Simple - Unicode + Unicode::Encoding Authentication Authentication::Store::NDWeb @@ -31,9 +32,6 @@ use Catalyst qw/ Session::Store::File Session::State::Cookie - Compress::Gzip - Compress::Deflate - Cache PageCache /; @@ -86,6 +84,7 @@ __PACKAGE__->config( page_cache => { }); __PACKAGE__->config( default_model => 'Model'); +__PACKAGE__->config( encoding => 'UTF-8'); # Start the application __PACKAGE__->setup(); diff --git a/lib/NDWeb/Controller/Root.pm b/lib/NDWeb/Controller/Root.pm index 6fab7f2..4aa6d95 100644 --- a/lib/NDWeb/Controller/Root.pm +++ b/lib/NDWeb/Controller/Root.pm @@ -33,7 +33,7 @@ NDWeb::Controller::Root - Root Controller for NDWeb sub index : Local Path Args(0) { my ( $self, $c ) = @_; - $c->visit('/wiki/index'); + $c->visit('/wiki/main'); } sub default : Path { diff --git a/lib/NDWeb/Controller/Wiki.pm b/lib/NDWeb/Controller/Wiki.pm index 1c3ea87..2e54d48 100644 --- a/lib/NDWeb/Controller/Wiki.pm +++ b/lib/NDWeb/Controller/Wiki.pm @@ -29,16 +29,22 @@ sub auto : Priate { $c->stash(wikiformat => \&wikiformat); } -sub index :Path :Args(0) { - my ( $self, $c ) = @_; +sub index :Path :Args(1) { + my ( $self, $c, $page ) = @_; - push @{$c->req->captures}, ('Info','Main'); - $c->forward('page'); + $c->forward('page',$page); $c->stash(template => 'wiki/page.tt2'); } -sub page : LocalRegex(^(?:([A-Z]\w*)(?::|%3A))?([A-Z]\w*)$) { +sub main :Path :Args(0) { my ( $self, $c ) = @_; + + $c->forward('page', ['Info:Main']); + $c->stash(template => 'wiki/page.tt2'); +} + +sub page : Private { + my ( $self, $c, $p ) = @_; my $dbh = $c->model; $c->forward('findPage'); @@ -47,8 +53,8 @@ sub page : LocalRegex(^(?:([A-Z]\w*)(?::|%3A))?([A-Z]\w*)$) { $c->forward('loadText'); unless ($c->stash->{page}->{wpid}){ - $c->stash->{page}->{namespace} = $c->req->captures->[0]; - $c->stash->{page}->{name} = $c->req->captures->[1]; + $c->stash->{page}->{namespace} = $c->stash->{namespace}; + $c->stash->{page}->{name} = $c->stash->{name}; $c->stash->{page}->{fullname} = ($c->stash->{page}->{namespace} ? $c->stash->{page}->{namespace}.':' : '') . $c->stash->{page}->{name}; $c->stash->{page}->{post} = $dbh->selectrow_array(q{SELECT post @@ -59,8 +65,8 @@ sub page : LocalRegex(^(?:([A-Z]\w*)(?::|%3A))?([A-Z]\w*)$) { $c->stash(title => $c->stash->{page}->{fullname}); } -sub edit : LocalRegex(^edit/(?:([A-Z]\w*)(?::|%3A))?([A-Z]\w*)$) { - my ( $self, $c ) = @_; +sub edit :Local :Args(1) { + my ( $self, $c, @p ) = @_; my $dbh = $c->model; $c->forward('findPage'); @@ -72,12 +78,12 @@ sub edit : LocalRegex(^edit/(?:([A-Z]\w*)(?::|%3A))?([A-Z]\w*)$) { unless ($c->stash->{page}->{wpid}){ $c->acl_access_denied('test',$c->action,'No edit access for this page') unless @{$c->stash->{namespaces}}; - $c->stash->{page}->{namespace} = $c->req->captures->[0]; - $c->stash->{page}->{name} = $c->req->captures->[1]; + $c->stash->{page}->{namespace} = $c->stash->{namespace}; + $c->stash->{page}->{name} = $c->stash->{name}; } } -sub history : LocalRegex(^history/(?:([A-Z]\w*)(?::|%3A))?([A-Z]\w*)$) { +sub history :Local :Args(1) { my ( $self, $c ) = @_; my $dbh = $c->model; @@ -195,12 +201,16 @@ sub findPage : Private { my @arguments = ($c->stash->{UID}); my $where; - if ($p){ + if ($p =~ /^\d+$/){ $where = q{AND wpid = $2}; push @arguments, $p; - }else{ + } elsif ($p =~ /^(?:([A-Z]\w*):)?([A-Z]\w*)$/){ $where = q{AND (namespace = COALESCE($2,'') AND name = $3)}; - push @arguments, @{$c->req->captures}; + push @arguments, $1, $2; + $c->stash(namespace => $1); + $c->stash(name => $2); + } else { + $c->detach('/default'); } my $query = q{SELECT wpid,namespace,name,wprev diff --git a/root/static/ui/ui.datepicker.css b/root/static/ui/ui.datepicker.css old mode 100755 new mode 100644