To use these modules, just copy-and-paste the text into .pl files in your modules directory.
push(@MyInitVariables, \&EditButtonAdd);
sub EditButtonAdd() {
my $edit_url = $ScriptName . '?action=edit;id=' . UrlEncode(GetId());
$HtmlHeaders .= qq{<link rel="alternate" type="application/wiki" title="Edit this page!" href="} . $edit_url . qq{"/>};
}This module enables Oddmuse to handle addresses that were rewritten by your web server's rewrite rules, so that they look like http://example.com/PageName rather than http://example.com/wiki/PageName. In particular, it fixes the case where there is no PageName provided, and treats it as if the starting page of the wiki was requested.
$ModulesDescription .= '<p>$Id: fastcgi.pl,v 0.1 2007/06/13 15:27:00 as Exp $</p>';
*OldGetId = *GetId;
*GetId = *NewGetId;
sub NewGetId {
if ( (!$q->param) &&
($UsePathInfo) &&
($q->path_info eq "/") ) { return $HomePage };
return OldGetId();
}Traditionally, if you click on the page title on a wiki, it will do a search for links to that page. This is something specific to wiki and, to be honest, not very user-friendly. This module will remove the link from the page titles, and move it to the "Administration" menu.
$ModulesDescription .= '<p>$Id: nosearch.pl,v 0.1 2007/06/13 15:42:00 as Exp $</p>';
*OldGetSearchLink = *GetSearchLink;
*GetSearchLink = *NewGetSearchLink;
sub NewGetSearchLink {
my ($text, $class, $name, $title) = @_;
$name = UrlEncode($name);
$text =~ s/_/ /g;
return $q->span({-class=>$class }, $text);
}
push(@MyAdminCode, \&BacklinksMenu);
sub BacklinksMenu {
my ($id, $menuref, $restref) = @_;
if ($id) {
my $text = T('Backlinks');
my $class = 'backlinks';
my $name = "backlinks";
my $title = T("Click to search for references to this page");
my $link = ScriptLink('search=' . $id, $text, $class, $name, $title);
push(@$menuref, $link);
}
}This module takes the dates from the page names in the journal and formats them so that they can be turned into pretty calendar pages with your @CSS@.
sub PrintJournal {
return if $CollectingJournal; # avoid infinite loops
local $CollectingJournal = 1;
my ($num, $regexp, $mode, $offset, $search) = @_;
$regexp = '^\d\d\d\d-\d\d-\d\d' unless $regexp;
$num = 10 unless $num;
$offset = 0 unless $offset;
my @pages = sort JournalSort (grep(/$regexp/, $search ? SearchTitleAndBody($search) : AllPagesList()));
if ($mode eq 'reverse' or $mode eq 'future') {
@pages = reverse @pages;
}
$b = defined($Today) ? $Today : CalcDay($Now);
if ($mode eq 'future') {
for (my $i = 0; $i < @pages; $i++) {
$a = $pages[$i];
if (JournalSort() == -1) {
@pages = @pages[$i..$#pages];
last;
}
}
} elsif ($mode eq 'past') {
for (my $i = 0; $i < @pages; $i++) {
$a = $pages[$i];
if (JournalSort() == 1) {
@pages = @pages[$i..$#pages];
last;
}
}
}
return unless $pages[$offset]; # not enough pages
my $more = ($#pages >= $offset + $num);
my $max = $more ? ($offset + $num - 1) : $#pages;
@pages = @pages[$offset .. $max];
if (@pages) {
# Now save information required for saving the cache of the current page.
local %Page;
local $OpenPageName='';
print $q->start_div({-class=>'journal'});
PrintAllJournalPages(1, 1, @pages);
print $q->end_div();
print ScriptLink("action=more;num=$num;regexp=$regexp;search=$search;mode=$mode;offset="
. ($offset + $num), T('More...'), 'more') if $more;
}
}
sub j_month_name {
my $month = shift;
my @month_name = (T('January'), T('February'), T('March'), T('April'),
T('May'), T('June'), T('July'), T('August'),
T('September'), T('October'), T('November'),
T('December'));
return $month_name[$month-1];
}
sub PrintAllJournalPages {
my ($links, $comments, @pages) = @_;
my $lang = GetParam('lang', 0);
@pages = @pages[0 .. $JournalLimit - 1] if $#pages >= $JournalLimit and not UserIsAdmin();
for my $id (@pages) {
OpenPage($id);
my @languages = split(/,/, $Page{languages});
next if $lang and @languages and not grep(/$lang/, @languages);
my $title = NormalToFree($id);
print $q->start_div({-class=>'page'});
if ($id =~/^(\d\d\d\d)-(\d\d?)-(\d\d?)_(.*)/) {
print $q->div({-class=>'date'},
$q->span({-class=>'day'}, $3),
$q->span({-class=>'month'}, j_month_name($2)),
$q->span({-class=>'year'}, $1),
);
# Use this to remove the dates from the titles.
# $title = NormalToFree($4);
}
print $q->h1($links ? GetPageLink($id, $title) : $q->a({-name=>$id},$title));
PrintPageHtml();
if ($comments and $id !~ /^$CommentsPrefix/o) {
print $q->p({-class=>'comment'},
GetPageLink($CommentsPrefix . $id, T('Comments on this page')));
}
print $q->end_div();;
}
}
This page changes the way that BannedContent works – instead of checking only links, it checks the whole text of the page.
sub BannedContent {
my $str = shift;
foreach my $line (split(/\n/, $str)) {
foreach my $rule (split(/\n/, GetPageContent($BannedContent))) {
if ($line =~ /($rule)/isx) {
return Tss('Rule "%1" matched "%2" on this page.', $rule, $line);
}
}
}
return 0;
}