use Catalyst qw/
+FrBr::Books::Plugin::ConfigLoader
+ +FrBr::Books::Plugin::WebPath
Static::Simple
my ( $self, $c ) = @_;
my $K = __PACKAGE__ . "::auto(): ";
+ my $self_url = $c->request->base . $c->request->path;
+ $self_url =~ s#^https?://[^/]+/#/#;
+ $c->stash->{'self_url'} = $self_url;
+
my $storage = $c->model('Schema')->storage;
$c->stash->{'storage'} = $storage;
$c->stash->{'menu_path'} = [] unless $c->stash->{'menu_path'};
push @{ $c->stash->{'menu_path'} }, {
- 'path' => $c->uri_for("/"),
+ 'path' => $c->web_path("/"),
'name' => "Startseite"
};
$c->stash->{'login_action'} = 'login';
+ $c->log->debug( $K . "Aktuelle Script-URL: '" . $c->stash->{'self_url'} . "'." ) if $c->stash->{'debug_level'} >= 2;
+
1;
} ## end sub auto :
$c->stash->{'menu_path'} = [] unless $c->stash->{'menu_path'};
push @{ $c->stash->{'menu_path'} }, {
- 'path' => $c->uri_for("/books"),
+ 'path' => $c->web_path("/books"),
'name' => "Bücher"
};
$c->stash->{'template'} = 'not_implemented.tt2';
push @{ $c->stash->{'menu_path'} }, {
- 'path' => $c->uri_for("/books/default"),
+ 'path' => $c->web_path("/books/default"),
'name' => "Nicht Implementiert"
};
$c->log->debug( $K . "aufgerufen." ) if $c->stash->{'debug_level'} > 2;
push @{ $c->stash->{'menu_path'} }, {
- 'path' => $c->uri_for("/books/list"),
+ 'path' => $c->web_path("/books/list"),
'name' => "Liste"
};
$c->stash->{'menu_path'} = [] unless $c->stash->{'menu_path'};
push @{ $c->stash->{'menu_path'} }, {
- 'path' => $c->uri_for("/books/new"),
+ 'path' => $c->web_path("/books/new"),
'name' => "Neu"
};
$c->stash->{'template'} = 'not_implemented.tt2';
push @{ $c->stash->{'menu_path'} }, {
- 'path' => $c->uri_for("/login"),
+ 'path' => $c->web_path("/login"),
'name' => "Anmeldung"
};
--- /dev/null
+package FrBr::Books::Plugin::WebPath;
+
+# $Id$
+# $URL$
+
+use strict;
+use warnings;
+
+use Carp qw/croak/;
+
+our $VERSION = '0.02';
+
+=head2 web_path
+
+Wrapper fuer $Catalyst->uri_for(), um C<< $c->request->base >> aus der URI zu entfernen.
+
+=cut
+
+sub web_path {
+
+ my $c = shift;
+ my $K = __PACKAGE__ . "::web_path(): ";
+
+ my $base = $c->req->base;
+ $base =~ s#^(https?://[^/]+/).*#$1#;
+
+ my $uri = $c->uri_for(@_);
+ return '/' if $uri eq $base;
+
+ my $uri_rel = $uri->rel($base);
+ $uri_rel = '/' . $uri_rel unless $uri_rel =~ m#^/#;
+
+ return $uri_rel;
+
+}
+
+1;
+
template. This is the place to define any extra template variables,
macros, load plugins, and perform any other template setup.
+-%]
+[%# -
+
+ MACRO l(text, args) BLOCK;
+ Catalyst.localize(text, args);
+ END;
+
-%]
[%-
+ MACRO uri( path ) BLOCK;
+ Catalyst.uri_for( path );
+ END;
+
+ MACRO path( path ) BLOCK;
+ Catalyst.web_path( path );
+ END;
+
# define a data structure to hold sitewide data
site = {
title => 'Inhalt',
<meta name="copyright" content="copyright 2008 Frank Brehm, Berlin" />
<meta name="robots" content="noindex" />
[% PROCESS site/jsfiles.tt2 -%]
- <link rel="shortcut icon" href="[% Catalyst.uri_for('/static/pic/fbr.ico') %]" />
+ <link rel="shortcut icon" href="[% path('/static/pic/fbr.ico') %]" />
<title>[% site_title or template.title or site.title %]</title>
<style type="text/css">
[% PROCESS site/styles.css %]
[%- ELSE -%]
[%- IF login_action == 'login' -%]
- <span class="login"><a href="[% Catalyst.uri_for("/login") %]">Anmelden</a></span>
+ <span class="login"><a href="[% path("/login") %]">Anmelden</a></span>
[%- ELSE -%]
Angemeldet als: <span class="login">[% current_user %] -
- <a href="[% Catalyst.uri_for("/logout") %]">Abmelden</a></span>
+ <a href="[% path("/logout") %]">Abmelden</a></span>
[%- END -%]
[%- END -%]
</td>
-%]
<!-- Book form -->
-<form method="post" name="book_form" action="[% Catalyst.request.base %][% Catalyst.request.path %]">
+<form method="post" name="book_form" action="[% self_url %]">
<input type="hidden" name="book_form_sent" value="sent" />
[%- IF book_edit.id %]<input type="hidden" name="book_id" value="[% book_edit.id | html %]" />[% END %]
<table class="ftable" cellspacing="0">
<td class="button">
</td>
<td class="item">
- <a href="[% Catalyst.uri_for('/books/search') %]">Suchmaske</a></td>
+ <a href="[% path('/books/search') %]">Suchmaske</a></td>
</tr>
<tr>
<td colspan="2" class="empty">
<td class="button">
</td>
<td class="item">
- <a href="[% Catalyst.uri_for('/books/list') %]">Bücherliste</a></td>
+ <a href="[% path('/books/list') %]">Bücherliste</a></td>
</tr>
<tr>
<td colspan="2" class="empty">
<td class="button">
</td>
<td class="item">
- <a href="[% Catalyst.uri_for('/') %]">Zurück zum Hauptmenü</a></td>
+ <a href="[% path('/') %]">Zurück zum Hauptmenü</a></td>
</tr>
</table>
</div>
[% PROCESS books/book_form.tt2 %]
<div class="back">
-<h2><a href="[% Catalyst.uri_for('/books') %]">[% 'Zurück' %]</a></h2>
+<h2><a href="[% path('/books') %]">[% 'Zurück' %]</a></h2>
</div>
<td class="button">
</td>
<td class="item">
- <a href="[% Catalyst.uri_for('/books') %]">Bücher suchen</a></td>
+ <a href="[% path('/books') %]">Bücher suchen</a></td>
</tr>
</table>
</div>