Browse Source

Getting rid of CheckSetup in Wala, plans to move stuff to a setup script.

pull/1/head
Brennen Bearnes 16 years ago
parent
commit
c650ae7ec4
3 changed files with 91 additions and 21 deletions
  1. +2
    -20
      lib/Wala.pm
  2. +0
    -1
      p1k3.conf.pl
  3. +89
    -0
      setup.pl

+ 2
- 20
lib/Wala.pm View File

@ -25,19 +25,7 @@ retaining all the wonderful full-page editing features of a wiki.
=head1 INSTALLATION
This script is a self-contained package, which makes the code easy to test.
To actually use it as a wala, create a script named "wala.pl" in the same
directory, containing the following three lines:
#!/usr/bin/perl
use Wala;
my $w = Wala->new();
$w->run;
You can experiment with the wala by use'ing it and calling its functions
without calling "run". By default, required directories and files should
be created as needed, but you can visit wala.pl?setup in your browser,
or call C<setup()> from a script at any time.
TODO
=head2 CONFIGURATION
@ -59,7 +47,6 @@ You can set options directly from the calling script, like so:
ScriptName => 'wala.pl',
ShowSearchlinks => 1, # Display "see also" box on pages
LogRelatedLinks => 1, # Log related links for a given change.
CheckSetup => 1, # Check for setup files every time
UseCache => 0, # Don't use caching behavior
NoCache => qr/^([A-Z]|PageIndex|RecentChanges|HomePage|PageChangeTimes)$/x,
);
@ -136,7 +123,6 @@ my %WalaConf = (
TitleString => 'wala::', # Display before page names in titles
ScriptName => 'wala.pl', # substr( $0, rindex( $0, "/" ) + 1 );
ShowSearchlinks => 1, # Display "see also" box on pages
CheckSetup => 1, # Check for setup files every time
UseCache => 0, # Don't use caching behavior
NoCache => qr/^([A-Z]|PageIndex|RecentChanges|HomePage
|PageChangeTimes)$/x,
@ -206,7 +192,6 @@ sub run {
my ($result);
my $page = $self->HomePage;
$self->setup() if $self->CheckSetup;
$self->parse_cookies($ENV{'HTTP_COOKIE'});
my $querystring = $ENV{'QUERY_STRING'};
@ -957,13 +942,10 @@ sub print_page {
# this takes care of several special pages. it also grabs links to search
# engines and backreferences to other pages.
if ($pagename eq 'RecentChanges') {
$pagetext .= $self->print_recent_changes;
}
if ($pagename eq 'RecentChanges' ) { $pagetext .= $self->print_recent_changes; }
elsif ($pagename eq 'PageIndex' ) { $pagetext .= $self->get_list_of_pages(); }
elsif ($pagename eq 'PageChangeTimes') { $pagetext .= $self->get_change_times(); }
elsif ($pagename =~ m/^([A-Za-z])$/ ) { $pagetext .= $self->get_list_of_pages("^$1.*"); }
elsif ($pagename eq 'setup' ) { $pagetext .= $self->setup(); }
elsif ($pagename eq $self->HomePage ) { $linklist = ''; }
elsif (! $self->ShowSearchlinks ) { $linklist = ''; }
else {


+ 0
- 1
p1k3.conf.pl View File

@ -30,7 +30,6 @@ our %WalaConf = (
TimeZone => "UTC",
TitleString => "p1k3 wala::",
ScriptName => "http://p1k3.com/wala/wala.pl",
CheckSetup => 0,
# No trailing slash on RootDir, please.
RootDir => "/home/bbearnes/wala",
FeedURL => "http://p1k3.com/wala/wala_feed.pl",


+ 89
- 0
setup.pl View File

@ -0,0 +1,89 @@
#############
# Setup #
#############
sub setup {
my $self = shift;
my $pagesdir = $self->PagesDir;
my $homepage = $self->HomePage;
my $result = '<p>';
if (! -d $self->RootDir) {
if ( mkdir $self->RootDir, 0777 ) {
$result .= 'Made root directory.<br />';
} else {
return;
}
}
if (! -d $pagesdir)
{
if ( mkdir $pagesdir, 0777 ) {
$result .= 'Made pages directory.<br />';
}
if ( mkdir( $self->DiffDir, 0777 ) ) {
$result .= 'Made diffs directory.<br />';
}
}
else
{
$result .= 'Root directory exists.<br />';
}
if( ! -d $self->CacheDir )
{
mkdir( $self->CacheDir, 0777 );
$result .= 'Made cache directory.<br />';
}
else
{
$result .= 'Cache directory exists.<br />';
}
if( ! -e "$pagesdir/" . $self->HomePage )
{
write_file("$pagesdir/$homepage",
"Welcome to the Wala.\n\n"
. "See TextFormattingRules\n");
$result .= "Created $homepage.<br />";
}
else
{
$result .= 'HomePage exists.<br />';
}
if( ! -e "$pagesdir/TextFormattingRules" )
{
my $markup = <<"MARKUP";
Wala has the following '''text formatting rules''':
* Start a line with * to create a ''bulleted list''.
# Start a line with # to create a ''numbered list''.
:Start a line with a : to indent it.
Start a line with a space to display it like source code.
Start a line with a | to create a table:
|This is|a table|
|specified with|formatting rules.|
SmashWordsTogetherLikeSo to create a link to a new page, or use brackets around a [word]. Click on the link to create the page.
For links, just type the URL:
http://walawiki.org/
Alternatively, surround the URL with brackets and put a description after it, separated by a space:
[http://walawiki.org WalaWiki]
To include an image, just type the URL of the image.
MARKUP
write_file("$pagesdir/TextFormattingRules", $markup);
$result .= "Created TextFormattingRules.<br />";
}
else
{
$result .= "TextFormattingRules exists.<br />";
}
$result .= "</p>\n\n";
return( $result );
}

|||||||
x
 
000:0
Loading…
Cancel
Save