CGI-Wiki-Kwiki
view release on metacpan or search on metacpan
copy the templates into the perl5 lib path. Added a new
copy of wiki.cgi into the 'bin' directory. The installer
script copies the templates and the cgi script into the current
directory, and creates an empty sqlite database. This should
leave you with a working CGI::Wiki::Kwiki install.
Added comments to most of the templates to explain their
function. Added a stylesheet, installed along with the
templates.
Fixed bug where the prefs page died if the site had a ' in
the name. This will invalidate most existing preferences
cookies.
Changed search to use CGI::Wiki::Search::DB, as it's simpler
and doesn't spew weird cleanup errors.
Added character set support, this requires a seperate patch
to CGI::Wiki to allow the store to support charsets. Made
the default charset of a new site utf-8.
******************* NOTE TO UPGRADERS ************************
** If you are upgrading from a version earlier than 0.50, **
** please make sure that you install the updated templates **
** found in the templates/ directory of the tarball. **
** Changed: recent_changes.tt **
**************************************************************
2004/06/10 - (0.50) Improved RecentChanges.
2004/06/02 - (0.49) Documentation tweaks, added a default template_path
of './templates'. New 'prefs_expire' option to let you decide
when preferences cookie will expire.
******************* NOTE TO UPGRADERS ************************
** If you are upgrading from a version earlier than 0.48, **
** please make sure that you install the updated templates **
** found in the templates/ directory of the tarball. **
** Added: preferences.tt **
** Changed: navbar.tt **
**************************************************************
lib/CGI/Wiki/Kwiki.pm view on Meta::CPAN
'CGI::Wiki::Formatter::UseMod;
],
}, # example only, not default
site_name => 'CGI::Wiki::Kwiki site',
admin_email => 'email@invalid',
template_path => './templates',
stylesheet_url => "",
home_node => 'HomePage',
cgi_path => CGI::url(),
search_map => './search_map',
prefs_expire => '+1M', # passed to CGI::Cookie; see its docs
charset => 'iso-8859-1', # characterset for the wiki
);
The C<db_type> parameter refers to a CGI::Wiki::Store::[type] class.
Valid values are 'MySQL', SQLite', etc: see the L<CGI::Wiki> man page
and any other CGI::Wiki::Store classes you have on your
system. C<db_user> and C<db_pass> will be used to access this
database.
C<formatters> should be a reference to a hash listing all the
lib/CGI/Wiki/Kwiki.pm view on Meta::CPAN
allowed_tags => [ qw( p b i pre ) ],
],
},
site_name => 'CGI::Wiki::Kwiki site',
admin_email => 'email@invalid',
template_path => './templates',
stylesheet_url => "",
home_node => 'HomePage',
cgi_path => CGI::url(),
search_map => "./search_map",
prefs_expire => '+1M',
charset => 'iso-8859-1',
};
our $diff_plugin = CGI::Wiki::Plugin::Diff->new;
sub new {
my $class = shift;
my $self = bless {}, $class;
my %args = @_;
lib/CGI/Wiki/Kwiki.pm view on Meta::CPAN
my %data = $self->{wiki}->retrieve_node($node);
$version ||= $data{version};
my %criteria = ( name => $node, version => $version );
my %node_data = $self->{wiki}->retrieve_node( %criteria );
my ( $content, $checksum ) = @node_data{qw( content checksum )};
my @formatter_labels = sort keys %{ $self->{formatters} };
my %prefs_data = $self->get_prefs_from_cookie;
my $username = $prefs_data{username};
my %tt_vars = (
content => CGI::escapeHTML($content),
checksum => CGI::escapeHTML($checksum),
version => $version,
formatter_labels => \@formatter_labels,
formatter => CGI::escapeHTML($data{metadata}{formatter}[0]||""),
username => $username,
);
lib/CGI/Wiki/Kwiki.pm view on Meta::CPAN
);
$self->process_template(
template => "userstats.tt",
vars => \%tt_vars,
);
}
sub show_preferences_form {
my $self = shift;
# Get defaults for form fields from cookie.
my %prefs = $self->get_prefs_from_cookie;
$self->process_template(
template => "preferences.tt",
vars => {
%prefs,
show_prefs_form => 1,
not_editable => 1,
},
);
}
sub get_prefs_from_cookie {
my $self = shift;
my %cookies = CGI::Cookie->fetch;
my $cookie_name = $self->prefs_cookie_name;
my %data;
if ( $cookies{$cookie_name} ) {
%data = $cookies{$cookie_name}->value; # call ->value in list context
}
return ( username => $data{username} || "",
);
}
sub set_preferences {
my ($self, %args) = @_;
my $cookie = $self->make_prefs_cookie( %args );
$self->process_template(
template => "preferences.tt",
vars => {
not_editable => 1,
},
cookies => $cookie,
);
}
sub make_prefs_cookie {
my ($self, %args) = @_;
my $cookie_name = $self->prefs_cookie_name;
my $cookie = CGI::Cookie->new(
-name => $cookie_name,
-value => {
username => $args{username},
},
-expires => $self->prefs_expire,
);
return $cookie;
}
sub prefs_expire {
my $self = shift;
return $self->{prefs_expire};
}
sub prefs_cookie_name {
my $self = shift;
my $name = $self->{site_name} . "_userprefs";
$name =~ s/\W//g;
}
1;
t/08_preferences.t view on Meta::CPAN
my $run_tests = $@ ? 0 : 1;
SKIP: {
skip "DBD::SQLite not installed - no database to test with", 1
unless $run_tests;
CGI::Wiki::Setup::SQLite::setup( "./t/wiki.db" );
my $wiki = CGI::Wiki::Kwiki->new(
db_type => "SQLite",
db_name => "./t/wiki.db",
prefs_expire => "DUMMY_VALUE",
);
my $cookie = $wiki->make_prefs_cookie;
like( $cookie, qr/expires=DUMMY_VALUE/, "prefs_expire option used" );
}
templates/preferences.tt view on Meta::CPAN
[%# the user preferences page
-%]
[%- INCLUDE header.tt %]
[% IF show_prefs_form %]
<form action="[% cgi_url %]" method="POST">
<h1>Username</h1>
<p>How you wish to be identified in Recent Changes:</p>
<input type="text" size="20" name="username" value="[% username %]" />
<input type="submit" value="Set preferences" />
<input type="hidden" name="action" value="preferences" />
<input type="hidden" name="set" value="1" />
</form>
[% ELSE %]
<p>Preferences saved.</p>
( run in 1.258 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )