Skip to content

Commit

Permalink
[p5w] create tollbar.tmpl, and use <TMPL_INCLUDE> to include it in al…
Browse files Browse the repository at this point in the history
…l templates. Make it reuseable for all wiki pages (i hope). Add "History" and "Back to ..." buttons on it.
  • Loading branch information
ilyabelikin committed Sep 10, 2008
1 parent 81a04cf commit 303653a
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 68 deletions.
4 changes: 1 addition & 3 deletions p5w/skin/action_not_authorized.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
<link rel="stylesheet" type="text/css" href="spartan.css" />
</head>
<body>
<ul id="toolbar">
&nbsp;
</ul>
<TMPL_INCLUDE NAME="toolbar.tmpl">
<div id="content">
<h1>Not logged in</h1>
<p>You need to be logged in to <TMPL_VAR NAME=DISALLOWED_ACTION>.</p>
Expand Down
8 changes: 1 addition & 7 deletions p5w/skin/edit.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
<link rel="stylesheet" type="text/css" href="spartan.css" />
</head>
<body>
<ul id="toolbar">
<TMPL_IF NAME=LOGGED_IN>
<li><a href="?action=log_out">Log out</a></li>
<TMPL_ELSE>
<li><a href="?action=log_in">Log in</a></li>
</TMPL_IF>
</ul>
<TMPL_INCLUDE NAME="toolbar.tmpl">
<div id="content">
<h1><TMPL_VAR NAME=TITLE></h1>
<form method="POST">
Expand Down
4 changes: 1 addition & 3 deletions p5w/skin/log_in.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
<link rel="stylesheet" type="text/css" href="spartan.css" />
</head>
<body onload="document.login.user_name.focus()">
<ul id="toolbar">
&nbsp;
</ul>
<TMPL_INCLUDE NAME="toolbar.tmpl">
<div id="content">
<h1>Log in</h1>
<p>Everything you say can, and will, be used against you. Please
Expand Down
4 changes: 1 addition & 3 deletions p5w/skin/login_failed.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
<link rel="stylesheet" type="text/css" href="spartan.css" />
</head>
<body>
<ul id="toolbar">
&nbsp;
</ul>
<TMPL_INCLUDE NAME="toolbar.tmpl">
<div id="content">
<h1>Login failed</h1>
<p>Something went wrong. Sorry.</p>
Expand Down
4 changes: 1 addition & 3 deletions p5w/skin/login_succeeded.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
<link rel="stylesheet" type="text/css" href="spartan.css" />
</head>
<body>
<ul id="toolbar">
&nbsp;
</ul>
<TMPL_INCLUDE NAME="toolbar.tmpl">
<div id="content">
<h1>Login successful</h1>
<p>You got in!</p>
Expand Down
4 changes: 1 addition & 3 deletions p5w/skin/logout_succeeded.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
<link rel="stylesheet" type="text/css" href="spartan.css" />
</head>
<body>
<ul id="toolbar">
&nbsp;
</ul>
<TMPL_INCLUDE NAME="toolbar.tmpl">
<div id="content">
<h1>Logout successful</h1>
<p>You got out!</p>
Expand Down
9 changes: 1 addition & 8 deletions p5w/skin/not_found.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@
<link rel="stylesheet" type="text/css" href="spartan.css" />
</head>
<body>
<ul id="toolbar">
<li><a href="?action=edit">Edit</a></li>
<TMPL_IF NAME=LOGGED_IN>
<li><a href="?action=log_out">Log out</a></li>
<TMPL_ELSE>
<li><a href="?action=log_in">Log in</a></li>
</TMPL_IF>
</ul>
<TMPL_INCLUDE NAME="toolbar.tmpl">
<div id="content">
<h1>Page not found</h1>
The page <TMPL_VAR NAME=PAGE> was not found.
Expand Down
8 changes: 1 addition & 7 deletions p5w/skin/page_history.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
<link rel="stylesheet" type="text/css" href="spartan.css" />
</head>
<body>
<ul id="toolbar">
<TMPL_IF NAME=LOGGED_IN>
<li><a href="?action=log_out">Log out</a></li>
<TMPL_ELSE>
<li><a href="?action=log_in">Log in</a></li>
</TMPL_IF>
</ul>
<TMPL_INCLUDE NAME="toolbar.tmpl">
<div id="content">
<h1>History of '<TMPL_VAR NAME=PAGE>'</h1>

Expand Down
8 changes: 1 addition & 7 deletions p5w/skin/recent_changes.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
<link rel="stylesheet" type="text/css" href="spartan.css" />
</head>
<body>
<ul id="toolbar">
<TMPL_IF NAME=LOGGED_IN>
<li><a href="?action=log_out">Log out</a></li>
<TMPL_ELSE>
<li><a href="?action=log_in">Log in</a></li>
</TMPL_IF>
</ul>
<TMPL_INCLUDE NAME="toolbar.tmpl">
<div id="content">
<h1>Recent changes</h1>

Expand Down
19 changes: 19 additions & 0 deletions p5w/skin/toolbar.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<ul id="toolbar">
<TMPL_IF NAME=LOGGED_IN>
<TMPL_IF NAME=VIEW_PAGE>
<li><a href="?page=<TMPL_VAR NAME=TITLE>&action=edit">Edit</a></li>
<li><a href="?page=<TMPL_VAR NAME=TITLE>&action=view_history">History</a></li>
<TMPL_ELSE>

<TMPL_IF NAME=PAGE>
<li><a href="?page=<TMPL_VAR NAME=PAGE>">Back to <TMPL_VAR NAME=PAGE></a></li>
<TMPL_ELSE>
<li><a href="/">Back to Main Page</a></li>
</TMPL_IF>

</TMPL_IF>
<li><a href="?action=log_out">Log out</a></li>
<TMPL_ELSE>
<li><a href="?action=log_in">Log in</a></li>
</TMPL_IF>
</ul>
8 changes: 1 addition & 7 deletions p5w/skin/unknown_action.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
<link rel="stylesheet" type="text/css" href="spartan.css" />
</head>
<body>
<ul id="toolbar">
<TMPL_IF NAME=LOGGED_IN>
<li><a href="?action=log_out">Log out</a></li>
<TMPL_ELSE>
<li><a href="?action=log_in">Log in</a></li>
</TMPL_IF>
</ul>
<TMPL_INCLUDE NAME="toolbar.tmpl">
<div id="content">
<h1>Unknown action</h1>
Unknown action "<TMPL_VAR NAME=ACTION>".
Expand Down
9 changes: 1 addition & 8 deletions p5w/skin/view.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@
<link rel="stylesheet" type="text/css" href="spartan.css" />
</head>
<body>
<ul id="toolbar">
<li><a href="?page=<TMPL_VAR NAME=TITLE>&action=edit">Edit</a></li>
<TMPL_IF NAME=LOGGED_IN>
<li><a href="?action=log_out">Log out</a></li>
<TMPL_ELSE>
<li><a href="?action=log_in">Log in</a></li>
</TMPL_IF>
</ul>
<TMPL_INCLUDE NAME="toolbar.tmpl">
<div id="content">
<h1><TMPL_VAR NAME=TITLE></h1>
<TMPL_VAR NAME=CONTENT>
Expand Down
8 changes: 1 addition & 7 deletions p5w/skin/view_diff.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
<link rel="stylesheet" type="text/css" href="spartan.css" />
</head>
<body>
<ul id="toolbar">
<TMPL_IF NAME=LOGGED_IN>
<li><a href="?action=log_out">Log out</a></li>
<TMPL_ELSE>
<li><a href="?action=log_in">Log in</a></li>
</TMPL_IF>
</ul>
<TMPL_INCLUDE NAME="toolbar.tmpl">
<div id="content">
<h1>Diff of <TMPL_VAR NAME=PAGE></h1>

Expand Down
8 changes: 6 additions & 2 deletions p5w/wiki
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ sub view_page {
my $template = HTML::Template->new(
filename => $TEMPLATE_PATH.'view.tmpl');

$template->param(TITLE => $page);
$template->param(TITLE => $page,);
$template->param(VIEW_PAGE => 1) unless $revision;

my $contents;
if ( my ($path) = $page =~ m[ ^ $PUGS_PREFIX \b (.*) $ ]x ) {
if ( -d (my $file = $PUGS_PATH.$path) ) {
Expand Down Expand Up @@ -487,7 +489,9 @@ sub log_in {
eq $users{$user_name}->{password} ) {

my $template = HTML::Template->new(
filename => $TEMPLATE_PATH.'login_succeeded.tmpl');
filename => $TEMPLATE_PATH.'login_succeeded.tmpl'
);
$template->param(LOGGED_IN => 1);

my $session_id = md5_base64(time);
my $session_cookie = $cgi->cookie(
Expand Down

0 comments on commit 303653a

Please sign in to comment.