From cad247150fd6d995618eee1fc5b05351633d2fc2 Mon Sep 17 00:00:00 2001 From: Carl Masak Date: Sat, 18 Oct 2008 00:48:25 +0200 Subject: [PATCH] [p5w] now cosmetically removes the underscores in page titles --- docs/JANITORS | 2 -- p5w/November.pm | 33 +++++++++++++++++++++++---------- p5w/skin/edit.tmpl | 2 +- p5w/skin/not_found.tmpl | 2 +- p5w/skin/page_history.tmpl | 4 ++-- p5w/skin/toolbar.tmpl | 6 +++--- p5w/skin/view_diff.tmpl | 2 +- 7 files changed, 31 insertions(+), 20 deletions(-) diff --git a/docs/JANITORS b/docs/JANITORS index 6f16538..d2241a4 100644 --- a/docs/JANITORS +++ b/docs/JANITORS @@ -15,8 +15,6 @@ free to remove it. * Add 'return_to' links for the login and logout actions. And maybe redirects, or at least manual links. -* Cosmetically remove the underscores in link titles. - * Implement 'created new page' flag in recent-changes. * Implement 'minor edits'. diff --git a/p5w/November.pm b/p5w/November.pm index a9b0332..aad2fc7 100644 --- a/p5w/November.pm +++ b/p5w/November.pm @@ -57,7 +57,6 @@ sub handle_request { if (ref($handler) eq "CODE") { $handler->($cgi); - } else { print unknown_action($cgi); @@ -95,10 +94,20 @@ sub exists_wiki_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 { my ($page, $title) = @_; - $title ||= $page; + $title ||= pp($page); return exists_wiki_page( $page ) ? qq|$title| : qq|$title|; @@ -185,7 +194,7 @@ sub format_html { $text =~ s{ \— }{—}msxg; - # Add paragraphs + # Add paragraph tags $text =~ s{\n\s*\n}{\n

}xg; return $text; @@ -435,7 +444,8 @@ sub view_page { my $template = HTML::Template->new( 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; my $contents; @@ -542,8 +552,8 @@ sub edit_page { filename => $TEMPLATE_PATH.'edit.tmpl'); $template->param(PAGE => $page); - my $title = $action . ' ' . $page; - $template->param(TITLE => $title); + $template->param(ACTION => $action); + $template->param(TITLE => pp($page)); $template->param(PAGETAGS => read_page_tags($page)); $template->param(CONTENT => $old_content); $template->param(LOGGED_IN => logged_in($cgi)); @@ -590,8 +600,9 @@ sub view_history { my $template = HTML::Template->new( filename => $TEMPLATE_PATH.'page_history.tmpl'); - $template->param(PAGE => $page); - $template->param(CHANGES => \@changes); + $template->param(PAGE => $page); + $template->param(TITLE => pp($page)); + $template->param(CHANGES => \@changes); $template->param(LOGGED_IN => logged_in($cgi)); print status_ok(), @@ -625,8 +636,9 @@ sub view_diff { my $template = HTML::Template->new( filename => $TEMPLATE_PATH.'view_diff.tmpl'); - $template->param(PAGE => $page); - $template->param(HUNKS => \@changes); + $template->param(PAGE => $page); + $template->param(TITLE => pp($page)); + $template->param(HUNKS => \@changes); $template->param(LOGGED_IN => logged_in($cgi)); print status_ok(), @@ -815,4 +827,5 @@ sub tag_count_normalize { use POSIX; ceil( ( log($step + 1 ) * 10 ) / log 2 ); } + 1; diff --git a/p5w/skin/edit.tmpl b/p5w/skin/edit.tmpl index a55874b..5a279b6 100644 --- a/p5w/skin/edit.tmpl +++ b/p5w/skin/edit.tmpl @@ -7,7 +7,7 @@

-

+

diff --git a/p5w/skin/not_found.tmpl b/p5w/skin/not_found.tmpl index 11714d4..828f0a4 100644 --- a/p5w/skin/not_found.tmpl +++ b/p5w/skin/not_found.tmpl @@ -8,7 +8,7 @@

Page not found

- The page was not found. + The page '' was not found.
diff --git a/p5w/skin/page_history.tmpl b/p5w/skin/page_history.tmpl index bcb0fc3..a6ac41f 100644 --- a/p5w/skin/page_history.tmpl +++ b/p5w/skin/page_history.tmpl @@ -1,13 +1,13 @@ - History of '<TMPL_VAR NAME=PAGE>' + History of '<TMPL_VAR NAME=TITLE>'
-

History of ''

+

History of ''

    diff --git a/p5w/skin/toolbar.tmpl b/p5w/skin/toolbar.tmpl index dd0755d..d640a04 100644 --- a/p5w/skin/toolbar.tmpl +++ b/p5w/skin/toolbar.tmpl @@ -1,12 +1,12 @@