Skip to content

Commit

Permalink
[p5w] now cosmetically removes the underscores in page titles
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Masak committed Oct 17, 2008
1 parent 685f1ba commit cad2471
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 20 deletions.
2 changes: 0 additions & 2 deletions docs/JANITORS
Expand Up @@ -15,8 +15,6 @@ free to remove it.
* Add 'return_to' links for the login and logout actions. And maybe redirects, * Add 'return_to' links for the login and logout actions. And maybe redirects,
or at least manual links. or at least manual links.


* Cosmetically remove the underscores in link titles.

* Implement 'created new page' flag in recent-changes. * Implement 'created new page' flag in recent-changes.


* Implement 'minor edits'. * Implement 'minor edits'.
Expand Down
33 changes: 23 additions & 10 deletions p5w/November.pm
Expand Up @@ -57,7 +57,6 @@ sub handle_request {


if (ref($handler) eq "CODE") { if (ref($handler) eq "CODE") {
$handler->($cgi); $handler->($cgi);

} }
else { else {
print unknown_action($cgi); print unknown_action($cgi);
Expand Down Expand Up @@ -95,10 +94,20 @@ sub exists_wiki_page {
return $page && -e $CONTENT_PATH.$page; return $page && -e $CONTENT_PATH.$page;
} }


# Pretty-printing of page names. A more self-explanatory (but still succinct)
# name for this subrouting would be a good thing -- suggestions welcome.
sub pp {
my ($name) = @_;

$name =~ s/_/ /g;

return $name;
}

sub make_link { sub make_link {
my ($page, $title) = @_; my ($page, $title) = @_;


$title ||= $page; $title ||= pp($page);
return exists_wiki_page( $page ) return exists_wiki_page( $page )
? qq|<a href="/?page=$page">$title</a>| ? qq|<a href="/?page=$page">$title</a>|
: qq|<a href="/?page=$page&action=edit" class="nonexistent">$title</a>|; : qq|<a href="/?page=$page&action=edit" class="nonexistent">$title</a>|;
Expand Down Expand Up @@ -185,7 +194,7 @@ sub format_html {


$text =~ s{ \&amp;mdash; }{&mdash;}msxg; $text =~ s{ \&amp;mdash; }{&mdash;}msxg;


# Add paragraphs # Add paragraph tags
$text =~ s{\n\s*\n}{\n<p>}xg; $text =~ s{\n\s*\n}{\n<p>}xg;


return $text; return $text;
Expand Down Expand Up @@ -435,7 +444,8 @@ sub view_page {
my $template = HTML::Template->new( my $template = HTML::Template->new(
filename => $TEMPLATE_PATH.'view.tmpl'); filename => $TEMPLATE_PATH.'view.tmpl');


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


my $contents; my $contents;
Expand Down Expand Up @@ -542,8 +552,8 @@ sub edit_page {
filename => $TEMPLATE_PATH.'edit.tmpl'); filename => $TEMPLATE_PATH.'edit.tmpl');


$template->param(PAGE => $page); $template->param(PAGE => $page);
my $title = $action . ' ' . $page; $template->param(ACTION => $action);
$template->param(TITLE => $title); $template->param(TITLE => pp($page));
$template->param(PAGETAGS => read_page_tags($page)); $template->param(PAGETAGS => read_page_tags($page));
$template->param(CONTENT => $old_content); $template->param(CONTENT => $old_content);
$template->param(LOGGED_IN => logged_in($cgi)); $template->param(LOGGED_IN => logged_in($cgi));
Expand Down Expand Up @@ -590,8 +600,9 @@ sub view_history {
my $template = HTML::Template->new( my $template = HTML::Template->new(
filename => $TEMPLATE_PATH.'page_history.tmpl'); filename => $TEMPLATE_PATH.'page_history.tmpl');


$template->param(PAGE => $page); $template->param(PAGE => $page);
$template->param(CHANGES => \@changes); $template->param(TITLE => pp($page));
$template->param(CHANGES => \@changes);
$template->param(LOGGED_IN => logged_in($cgi)); $template->param(LOGGED_IN => logged_in($cgi));


print status_ok(), print status_ok(),
Expand Down Expand Up @@ -625,8 +636,9 @@ sub view_diff {
my $template = HTML::Template->new( my $template = HTML::Template->new(
filename => $TEMPLATE_PATH.'view_diff.tmpl'); filename => $TEMPLATE_PATH.'view_diff.tmpl');


$template->param(PAGE => $page); $template->param(PAGE => $page);
$template->param(HUNKS => \@changes); $template->param(TITLE => pp($page));
$template->param(HUNKS => \@changes);
$template->param(LOGGED_IN => logged_in($cgi)); $template->param(LOGGED_IN => logged_in($cgi));


print status_ok(), print status_ok(),
Expand Down Expand Up @@ -815,4 +827,5 @@ sub tag_count_normalize {
use POSIX; use POSIX;
ceil( ( log($step + 1 ) * 10 ) / log 2 ); ceil( ( log($step + 1 ) * 10 ) / log 2 );
} }

1; 1;
2 changes: 1 addition & 1 deletion p5w/skin/edit.tmpl
Expand Up @@ -7,7 +7,7 @@
<body> <body>
<TMPL_INCLUDE NAME="toolbar.tmpl"> <TMPL_INCLUDE NAME="toolbar.tmpl">
<div id="content"> <div id="content">
<h1><TMPL_VAR NAME=TITLE></h1> <h1><TMPL_VAR NAME=ACTION> <TMPL_VAR NAME=TITLE></h1>
<form method="POST"> <form method="POST">
<input type="hidden" name="page" value="<TMPL_VAR NAME=PAGE>" /> <input type="hidden" name="page" value="<TMPL_VAR NAME=PAGE>" />
<input type="hidden" name="action" value="edit" /> <input type="hidden" name="action" value="edit" />
Expand Down
2 changes: 1 addition & 1 deletion p5w/skin/not_found.tmpl
Expand Up @@ -8,7 +8,7 @@
<TMPL_INCLUDE NAME="toolbar.tmpl"> <TMPL_INCLUDE NAME="toolbar.tmpl">
<div id="content"> <div id="content">
<h1>Page not found</h1> <h1>Page not found</h1>
The page <TMPL_VAR NAME=PAGE> was not found. The page '<TMPL_VAR NAME=TITLE>' was not found.
</div> </div>
</body> </body>
</html> </html>
4 changes: 2 additions & 2 deletions p5w/skin/page_history.tmpl
@@ -1,13 +1,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head> <head>
<title>History of '<TMPL_VAR NAME=PAGE>'</title> <title>History of '<TMPL_VAR NAME=TITLE>'</title>
<link rel="stylesheet" type="text/css" href="spartan.css" /> <link rel="stylesheet" type="text/css" href="spartan.css" />
</head> </head>
<body> <body>
<TMPL_INCLUDE NAME="toolbar.tmpl"> <TMPL_INCLUDE NAME="toolbar.tmpl">
<div id="content"> <div id="content">
<h1>History of '<TMPL_VAR NAME=PAGE>'</h1> <h1>History of '<TMPL_VAR NAME=TITLE>'</h1>


<ul> <ul>
<TMPL_LOOP NAME=CHANGES> <TMPL_LOOP NAME=CHANGES>
Expand Down
6 changes: 3 additions & 3 deletions p5w/skin/toolbar.tmpl
@@ -1,12 +1,12 @@
<ul id="toolbar"> <ul id="toolbar">
<TMPL_IF NAME=LOGGED_IN> <TMPL_IF NAME=LOGGED_IN>
<TMPL_IF NAME=VIEW_PAGE> <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=PAGE>&action=edit">Edit</a></li>
<li><a href="?page=<TMPL_VAR NAME=TITLE>&action=view_history">History</a></li> <li><a href="?page=<TMPL_VAR NAME=PAGE>&action=view_history">History</a></li>
<TMPL_ELSE> <TMPL_ELSE>


<TMPL_IF NAME=PAGE> <TMPL_IF NAME=PAGE>
<li><a href="?page=<TMPL_VAR NAME=PAGE>">Back to <TMPL_VAR NAME=PAGE></a></li> <li><a href="?page=<TMPL_VAR NAME=PAGE>">Back to <TMPL_VAR NAME=TITLE></a></li>
<TMPL_ELSE> <TMPL_ELSE>
<li><a href="/">Back to Main Page</a></li> <li><a href="/">Back to Main Page</a></li>
</TMPL_IF> </TMPL_IF>
Expand Down
2 changes: 1 addition & 1 deletion p5w/skin/view_diff.tmpl
Expand Up @@ -7,7 +7,7 @@
<body> <body>
<TMPL_INCLUDE NAME="toolbar.tmpl"> <TMPL_INCLUDE NAME="toolbar.tmpl">
<div id="content"> <div id="content">
<h1>Diff of <TMPL_VAR NAME=PAGE></h1> <h1>Diff of <TMPL_VAR NAME=TITLE></h1>


<table class="diff"> <table class="diff">
<TMPL_LOOP NAME=HUNKS> <TMPL_LOOP NAME=HUNKS>
Expand Down

0 comments on commit cad2471

Please sign in to comment.