Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Updated wiki code to match what I use on IcculusLan.
  • Loading branch information
icculus committed Apr 15, 2009
1 parent c3068c7 commit 2e14a17
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 8 deletions.
2 changes: 1 addition & 1 deletion common.php
Expand Up @@ -52,7 +52,7 @@ function current_sql_datetime()
function get_alext_wiki_url($extname)
{
$htmlextname = htmlentities($extname, ENT_QUOTES);
return("wiki/wiki.pl?$htmlextname");
return("wiki/$htmlextname");
} // get_alext_wiki_url


Expand Down
4 changes: 3 additions & 1 deletion wiki/config
Expand Up @@ -91,7 +91,7 @@ $FastGlob = 1; # 1 = new faster code, 0 = old compatible code
$MetaKeywords = 1; # 1 = Google-friendly, 0 = search-engine averse
$NamedAnchors = 1; # 0 = no anchors, 1 = enable anchors,
# 2 = enable but suppress display
$SlashLinks = 0; # 1 = use script/action links, 0 = script?action
$SlashLinks = 1; # 1 = use script/action links, 0 = script?action
$UpperFirst = 1; # 1 = free links start uppercase, 0 = no ucfirst
$AdminBar = 1; # 1 = admins see admin links, 0 = no admin bar
$RepInterMap = 0; # 1 = intermap is replacable, 0 = not replacable
Expand Down Expand Up @@ -143,5 +143,7 @@ $RcFile = "$DataDir/rclog"; # New RecentChanges logfile
$RcOldFile = "$DataDir/oldrclog"; # Old RecentChanges logfile
$IndexFile = "$DataDir/pageidx"; # List of all pages
$EmailFile = "$DataDir/emails"; # Email notification lists
$NoCreateLinks = 1; # 1 = don't make those '?' links, 0 = make them.
$PrinterMode = 0; # 1 = trim out some stuff, 0 = work as usual.

# == End of Configuration =================================================
58 changes: 52 additions & 6 deletions wiki/wiki.pl
Expand Up @@ -62,19 +62,19 @@ package UseModWiki;
$OpenPageName @KeptList @IndexList $IndexInit $TableMode
$q $Now $UserID $TimeZoneOffset $ScriptName $BrowseCode $OtherCode
$AnchoredLinkPattern @HeadingNumbers $TableOfContents $QuotedFullUrl
$ConfigError $UploadPattern );
$ConfigError $UploadPattern $NoCreateLinks $PrinterMode );

# == Configuration =====================================================
$DataDir = "/webspace/projects/alextreg/wiki"; # Main wiki directory
$UseConfig = 1; # 1 = use config file, 0 = do not look for config
$ConfigFile = "$DataDir/config"; # Configuration file

# Default configuration (used if UseConfig is 0)
$CookieName = "Wiki"; # Name for this wiki (for multi-wiki sites)
$SiteName = "Wiki"; # Name of site (used for titles)
$CookieName = "AlutWiki"; # Name for this wiki (for multi-wiki sites)
$SiteName = "AlutWiki"; # Name of site (used for titles)
$HomePage = "HomePage"; # Home page (change space to _)
$RCName = "RecentChanges"; # Name of changes page (change space to _)
$LogoUrl = "/wiki.gif"; # URL for site logo ("" for no logo)
$LogoUrl = ""; # URL for site logo ("" for no logo)
$ENV{PATH} = "/usr/bin/"; # Path used to find "diff"
$ScriptTZ = ""; # Local time zone ("" means do not print)
$RcDefault = 30; # Default number of RecentChanges days
Expand Down Expand Up @@ -149,14 +149,14 @@ package UseModWiki;
$UseIndex = 0; # 1 = use index file, 0 = slow/reliable method
$UseHeadings = 1; # 1 = allow = h1 text =, 0 = no header formatting
$NetworkFile = 1; # 1 = allow remote file:, 0 = no file:// links
$BracketWiki = 0; # 1 = [WikiLnk txt] link, 0 = no local descriptions
$BracketWiki = 0; # 1 = [WikiLnk txt] link, 0 = no local descriptions
$UseLookup = 1; # 1 = lookup host names, 0 = skip lookup (IP only)
$FreeUpper = 1; # 1 = force upper case, 0 = do not force case
$FastGlob = 1; # 1 = new faster code, 0 = old compatible code
$MetaKeywords = 1; # 1 = Google-friendly, 0 = search-engine averse
$NamedAnchors = 1; # 0 = no anchors, 1 = enable anchors,
# 2 = enable but suppress display
$SlashLinks = 0; # 1 = use script/action links, 0 = script?action
$SlashLinks = 1; # 1 = use script/action links, 0 = script?action
$UpperFirst = 1; # 1 = free links start uppercase, 0 = no ucfirst
$AdminBar = 1; # 1 = admins see admin links, 0 = no admin bar
$RepInterMap = 0; # 1 = intermap is replacable, 0 = not replacable
Expand All @@ -175,6 +175,8 @@ package UseModWiki;
$EditNameLink = 0; # 1 = edit links use name (CSS), 0 = '?' links
$UseMetaWiki = 0; # 1 = add MetaWiki search links, 0 = no MW links
$BracketImg = 1; # 1 = [url url.gif] becomes image link, 0 = no img
$NoCreateLinks = 0; # 1 = don't make those '?' links, 0 = make them.
$PrinterMode = 0; # 1 = trim out some stuff, 0 = work as usual.

# Names of sites. (The first entry is used for the number link.)
@IsbnNames = ('bn.com', 'amazon.com', 'search');
Expand Down Expand Up @@ -209,6 +211,8 @@ package UseModWiki;
$IndexFile = "$DataDir/pageidx"; # List of all pages
$EmailFile = "$DataDir/emails"; # Email notification lists

# == End of Configuration =================================================

if ($RepInterMap) {
push @ReplaceableFiles, $InterFile;
}
Expand Down Expand Up @@ -404,13 +408,25 @@ sub InitRequest {
} else {
$CGI::DISABLE_UPLOADS = 1; # no uploads
}
# Modify query string and script path for slashed links
if ($SlashLinks && (length($ENV{'PATH_INFO'}) > 1)) {
$ENV{'QUERY_STRING'} .= '&' if ($ENV{'QUERY_STRING'});
$ENV{'QUERY_STRING'} .= substr($ENV{'PATH_INFO'}, 1);
}
$q = new CGI;
# Fix some issues with editing UTF8 pages (if charset specified)
if ($HttpCharset ne '') {
$q->charset($HttpCharset);
}
$Now = time; # Reset in case script is persistent
$ScriptName = pop(@ScriptPath); # Name used in links

# Fix script name for relative links when slashed page links are used
if ($SlashLinks) {
my $numberOfSlashes = ($ENV{PATH_INFO} =~ tr[/][/]);
$ScriptName = ('../' x $numberOfSlashes) . $ScriptName;
}

$IndexInit = 0; # Must be reset for each request
$InterSiteInit = 0;
%InterSite = ();
Expand Down Expand Up @@ -470,7 +486,15 @@ sub DoBrowseRequest {
}
$action = lc(&GetParam('action', ''));
$id = &GetParam('id', '');
if ($action eq 'printer') {
$action = 'browse';
$PrinterMode = 1;
}
if ($action eq 'browse') {
if ($PrinterMode) {
$EmbedWiki = 1;
$NoCreateLinks = 1;
}
if ($FreeLinks && (!-f &GetPageFile($id))) {
$id = &FreeToNormal($id);
}
Expand Down Expand Up @@ -1189,6 +1213,8 @@ sub GetPageOrEditAnchoredLink {
}
if ($EditNameLink) {
return &GetEditLink($id, $name);
} elsif ($NoCreateLinks) {
return $name;
} else {
return $name . &GetEditLink($id, '?');
}
Expand Down Expand Up @@ -1279,6 +1305,15 @@ sub GetHistoryLink {
return &ScriptLink("action=history&id=$id", $text);
}

sub GetPrinterLink {
my ($id, $text) = @_;

if ($FreeLinks) {
$id =~ s/ /_/g;
}
return &ScriptLink("action=printer&id=$id", $text);
}

sub GetHeader {
my ($id, $title, $oldId) = @_;
my $header = "";
Expand All @@ -1292,6 +1327,8 @@ sub GetHeader {
$title =~ s/_/ /g; # Display as spaces
}
$result .= &GetHtmlHeader("$SiteName: $title");

$result .= $q->h1($header . &GetPageLink($id, $id)) if ($PrinterMode);
return $result if ($embed);

$result .= '<div class=wikiheader>';
Expand Down Expand Up @@ -1400,6 +1437,8 @@ sub GetFooterText {
$result .= T('This page is read-only');
}
$result .= ' | ';
$result .= &GetPrinterLink($id, T('Printer-happy version'));
$result .= ' | ';
$result .= &GetHistoryLink($id, T('View other revisions'));
if ($rev ne '') {
$result .= ' | ';
Expand Down Expand Up @@ -1603,6 +1642,13 @@ sub CommonMarkup {
local $_ = $text;

if ($doLines < 2) { # 2 = do line-oriented only
# The <nocreatelinks> tag prevents creation of '?' links...useful for
# pages with a lot of source code that make the Wiki think there are
# tons of CamelCaseWords that are potential wiki items.
if (s/\&lt;nocreatelinks\&gt;//ige) {
$NoCreateLinks = 1;
}

# The <nowiki> tag stores text with no markup (except quoting HTML)
s/\&lt;nowiki\&gt;((.|\n)*?)\&lt;\/nowiki\&gt;/&StoreRaw($1)/ige;
# The <pre> tag wraps the stored text with the HTML <pre> tag
Expand Down

0 comments on commit 2e14a17

Please sign in to comment.