# Copyright (C) 2008 Eric Hsu # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the # Free Software Foundation, Inc. # 59 Temple Place, Suite 330 # Boston, MA 02111-1307 USA $ModulesDescription .= '

$Id: bfc.pl,v 0.9 2008/07/20 23:20:09 Eric Hsu Exp $

'; # ============== # = config-bfc = # ============== # Here are some config settings we want across all BFCs. Perhaps these should be in a config file that gets loaded in... $UsePathInfo=0; #on Leopard server, we get the "stacking" URL problem, so we use gta.pl?page instead of gta.pl/page format. $WikiLinks = 0; # No CamelCase links $FreeLinks=1; $BracketText=1; $BracketWiki=1; $CreoleLineBreaks = 1; sub UsemodRule {}; # get TOC to start headers at depth 2 $EditNote='Click to pop up Formatting Help'; # $TopLinkBar=0; # As a rule, don't allow the navigation at the top. $StyleSheet='http://bfc.sfsu.edu/bfc4.css'; $Translate{'Unlock Wiki'}="Remove Stray Locks (e.g. those left after crashes)"; $Translate{'Summary:'}="Summary of Your Changes:"; # ============== # = gotobar-bfc = # ============== # New GotoBar (the navigation at the top) *OldGetGotoBar = *GetGotoBar; *GetGotoBar = *BFCGetGotoBar; sub BFCGetGotoBar { my $div = "  |  "; $UserGotoBar = GetPageLink($HomePage, "HOME") . $div; if ($ShowCart) { unless (GetParam('action', '') eq 'cart') { $UserGotoBar .= ScriptLink('action=cart', T('CART')) . $div ; } else { $UserGotoBar .= ScriptLink('action=cart', T('REFRESH CART')) . $div ; $UserGotoBar .= <CLEAR CART $div CLEARCART } } $UserGotoBar .= "FIND: " . GetSearchForm() ; return $q->span({-class=>'gotobar bar'}, $UserGotoBar); } # ============== # = footer-bfc = # ============== # Make the footer more minimal. Remove last edited. *OldPrintFooter = *PrintFooter; *PrintFooter = *NewPrintFooter; sub NewPrintFooter { my ($id, $rev, $comment) = @_; if (GetParam('embed', $EmbedWiki)) { print $q->end_html, "\n"; return; } print GetCommentForm($id, $rev, $comment), $q->start_div({-class=>'wrapper close'}), $q->end_div(), $q->end_div(), $q->start_div({-class=>'footer'}), $q->hr(), GetGotoBar($id), GetFooterLinks($id, $rev), # GetFooterTimestamp($id, $rev), # GetSearchForm() ; if ($DataDir =~ m|/tmp/|) { print $q->p($q->strong(T('Warning') . ': ') . Ts('Database is stored in temporary directory %s', $DataDir)); } print T($FooterNote) if $FooterNote; # print $q->p(GetValidatorLink()) if GetParam('validate', $ValidatorLink); # print $q->p(Ts('%s seconds', (time - $Now))) if GetParam('timing',0); print $q->end_div(); PrintMyContent($id) if defined(&PrintMyContent); foreach my $sub (@MyFooters) { print &$sub(@_); } ; print $q->end_html, "\n"; } *OldestGetFooterLinks = *GetFooterLinks; *GetFooterLinks = *NewestGetFooterLinks; sub NewestGetFooterLinks { my ($id, $rev) = @_; my @elements; if ($id and $rev ne 'history' and $rev ne 'edit') { if ($CommentsPrefix) { if ($id =~ /^$CommentsPrefix(.*)/o) { push(@elements, GetPageLink($1, "Back to " . $1, 'original')); #patch } else { push(@elements, GetPageLink($CommentsPrefix . $id, undef, 'comment')); #patch } } if (UserCanEdit($id, 0)) { if ($rev) { # showing old revision push(@elements, GetOldPageLink('edit', $id, $rev, Ts('Edit revision %s of this page', $rev))); } else { # showing current revision push(@elements, GetEditLink($id, T('Edit this page'), undef, T('e'))); } } else { # no permission or generated page # push(@elements, ScriptLink('action=password', T('This page is read-only'), 'password')); } } if (UserIsEditor() ) { push @elements, GetAddNewPageForm(); } push(@elements, GetHistoryLink($id, T('View other revisions'))) if $Action{history} and $id and $rev ne 'history' and GetParam('action', '') eq 'edit'; #patch push(@elements, GetPageLink($id, T('View current revision')), GetRCLink($id, T('View all changes'))) if $Action{history} and $rev ne ''; push(@elements, ScriptLink("action=contrib;id=" . UrlEncode($id), T('View contributors'), 'contrib')) if $Action{contrib} and $id and $rev eq 'history'; if ($Action{admin} and GetParam('action', '') ne 'admin') { my $action = 'action=admin'; $action .= ';id=' . UrlEncode($id) if $id; push(@elements, ScriptLink($action, T('Administration'), 'admin')) if (UserIsAdmin()); } push @elements, GetPageLink("RecentChanges", "Recent Changes"); my $username = GetParam('username', ''); my $LoginOrOut = "Login"; $LoginOrOut = "Logout $username" if (UserIsEditor()); push @elements, ScriptLink("action=password;lastpage=$id", $LoginOrOut); return @elements ? $q->span({-class=>'edit bar'}, join ("  |  ", @elements)) : ''; } # # # =============== # # = comment-bfc = # # =============== # # *OldAddComment = *AddComment; # *AddComment = *NewAddComment; # # sub NewAddComment { # my ($string, $comment) = @_; # $comment =~ s/\r//g; # Remove "\r"-s (0x0d) from the string # $comment =~ s/\s+$//g; # Remove whitespace at the end # # # $comment = RunMyMacros($comment); # # if ($comment ne '' and $comment ne $NewComment) { # my $author = GetParam('username', T('Anonymous')); # my $homepage = GetParam('homepage', ''); # $homepage = 'http://' . $homepage # if $homepage and not substr($homepage,0,7) eq 'http://'; # $author = "[$homepage $author]" if $homepage; # $author = "[[$author]]" if (UserIsEditor()); # All editors should make a page for themselves # $string .= "\n----\n\n" if $string and $string ne "\n"; # $string .= $comment . "\n\n" # . '-- ' . $author . ' //' . TimeToText($Now) . "//\n\n"; # } # return $string; # } # # # # ============== # = search-bfc = # ============== # This just (1) makes the search field wider and # (2) moves the search/replace boxes to the admin page *OldGetSearchForm = *GetSearchForm; *GetSearchForm = *NewGetSearchForm; sub NewGetSearchForm { my $form = $q->textfield(-name=>'search', -id=>'search', -size=>30, -accesskey=>T('f'), -title=>'Find text on site') . ' '; # Only show replace form in admin page!! Too dangerous otherwise. my $action = GetParam("action",undef); # was if ($ReplaceForm) if ($action eq "admin") { $form .= $q->textfield(-name=>'replace', -id=>'replace', -size=>20) . ' ' . $q->checkbox(-name=>'delete', -label=>T('Delete')) . ' '; } if (%Languages) { $form .= $q->textfield(-name=>'lang', -id=>'searchlang', -size=>10, -default=>GetParam('lang', '')) . ' '; } return GetFormStart(undef, 'get', 'search') . $form . $q->endform(); } sub GetAddNewPageForm { my $form =< Add New Page: END return $form; } __END__ = bfc.pl. (0.9a) New subtle top menu from BFCGetGotoBar(). DO NOT call it NewGetGotoBar. This was clobbering the system due to some other module trying to override with that name. Unclosed