CGI-Kwiki

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

# Change log for CGI::Kwiki

version: 0.18
date:    Sun Sep  7 11:14:56 PDT 2003
changes:
  - Changed template/local to local/template
  - Handle edit collisions
  - Merge config file settings on --upgrade
  - Move LOGIN button to prefs
  - Initial plugin framework
  - Diff plugin
  - i18n support - Autrijus Tang
  - FastCGI support - Autrijus Tang
  - Schwern's patches - Michael Schwern

version: 0.17
date:    Mon Jun  9 23:48:01 PDT 2003
changes:
  - RCS Support!!!

README  view on Meta::CPAN

        cgi_class:         CGI::Kwiki::CGI
        cookie_class:      CGI::Kwiki::Cookie
        database_class:    CGI::Kwiki::Database
        metadata_class:    CGI::Kwiki::Metadata
        display_class:     CGI::Kwiki::Display
        edit_class:        CGI::Kwiki::Edit
        formatter_class:   CGI::Kwiki::Formatter
        template_class:    CGI::Kwiki::Template
        search_class:      CGI::Kwiki::Search
        changes_class:     CGI::Kwiki::Changes
        prefs_class:       CGI::Kwiki::Prefs
        pages_class:       CGI::Kwiki::Pages
        slides_class:      CGI::Kwiki::Slides
        javascript_class:  CGI::Kwiki::Javascript
        style_class:       CGI::Kwiki::Style
        scripts_class:     CGI::Kwiki::Scripts

    This is a list of all the classes that make up the kwiki. You can change
    anyone of them to be a class of your own.

    Let's say that you wanted to change the BOLD format indicator from

lib/CGI/Kwiki.pm  view on Meta::CPAN

        database
        metadata
        backup
        display
        edit
        formatter
        template
        plugin
        search
        changes
        prefs
        pages
        slides
        javascript
        style
        scripts
        blog
        i18n
        import
    )
}

lib/CGI/Kwiki.pm  view on Meta::CPAN

# The most basic attributes inherited by almost all classes
attribute 'driver';
attribute 'config';
attribute 'cgi';
attribute 'plugin';
attribute 'template';
attribute 'formatter';
attribute 'database';
attribute 'metadata';
attribute 'backup';
attribute 'prefs';
attribute 'i18n';

# Constructor inherited by most classes
sub new {
    my ($class, $driver) = @_;
    my $self = bless {}, $class;
    $self->driver($driver);
    $self->config($driver->config);
    $self->cgi($driver->cgi);
    $self->plugin($driver->plugin);
    $self->template($driver->template);
    $self->formatter($driver->formatter);
    $self->database($driver->database);
    $self->metadata($driver->metadata);
    $self->backup($driver->backup);
    $self->prefs($driver->prefs);
    return $self;
}

sub load_driver {
    require CGI::Kwiki::Config;
    my $config = CGI::Kwiki::Config->new;
    my $driver_class = $config->driver_class;
    eval qq{ require $driver_class }; die $@ if $@;
    my $driver = $driver_class->new($config);
    $config->driver($driver);

lib/CGI/Kwiki.pm  view on Meta::CPAN

    cgi_class:         CGI::Kwiki::CGI
    cookie_class:      CGI::Kwiki::Cookie
    database_class:    CGI::Kwiki::Database
    metadata_class:    CGI::Kwiki::Metadata
    display_class:     CGI::Kwiki::Display
    edit_class:        CGI::Kwiki::Edit
    formatter_class:   CGI::Kwiki::Formatter
    template_class:    CGI::Kwiki::Template
    search_class:      CGI::Kwiki::Search
    changes_class:     CGI::Kwiki::Changes
    prefs_class:       CGI::Kwiki::Prefs
    pages_class:       CGI::Kwiki::Pages
    slides_class:      CGI::Kwiki::Slides
    javascript_class:  CGI::Kwiki::Javascript
    style_class:       CGI::Kwiki::Style
    scripts_class:     CGI::Kwiki::Scripts

This is a list of all the classes that make up the kwiki. You can change
anyone of them to be a class of your own.

Let's say that you wanted to change the B<BOLD> format indicator from

lib/CGI/Kwiki/Cookie.pm  view on Meta::CPAN

package CGI::Kwiki::Cookie;
$VERSION = '0.16';
use strict;
use base 'CGI::Kwiki';
use CGI::Kwiki;

attribute 'prefs';

sub new {
    my $class = shift;
    my $self = $class->SUPER::new(@_);
    $self->prefs($self->fetch);
    return $self;
}

sub header {
    my ($self) = @_;
    my $cookie = $self->create;
    return CGI::header(
        -cookie => $cookie,
        -charset => $self->config->encoding,
    );
}

sub create{
    my ($self) = @_;
    return CGI::cookie(
        -name => 'prefs', 
        -value => { map $self->escape($_), %{$self->prefs} },
        -expires => '+5y',
        -pragma => 'no-cache',
        -cache_control => 'no-cache',
        -last_modified => gmtime,
    );
}

sub fetch {
    my ($self) = @_;
    return { map $self->unescape($_), CGI::cookie('prefs') };
}

1;

__END__

=head1 NAME 

CGI::Kwiki::CGI - CGI Base Class for CGI::Kwiki

lib/CGI/Kwiki/Driver.pm  view on Meta::CPAN

use CGI::Kwiki;

attribute $_
  for grep {$_ ne 'new'} CGI::Kwiki::classes();

sub new {
    my ($class, $config) = @_;
    my $self = bless {}, $class;
    $self->config($config);
    $self->load_class('cgi');
    $self->load_class('prefs');
    $self->load_class('template');
    $self->load_class('plugin');
    $self->load_class('cookie');
    $self->load_class('metadata');
    $self->load_class('database');
    $self->load_class('formatter');
    $self->load_class('backup');
    $self->database->backup($self->backup);
    return $self;
}

lib/CGI/Kwiki/Metadata.pm  view on Meta::CPAN

    print METADATA $self->driver->template->render($template,
        edit_by => $self->edit_by,
        edit_time => scalar(gmtime),
        @key_values,
    );
    close METADATA;
}

sub edit_by {
    my ($self) = @_;
    $self->driver->cookie->prefs->{user_name} ||
    $CGI::Kwiki::user_name ||
    ''; 
}

sub metadata_template {
    <<END;
edit_by: [% edit_by %] 
edit_time: [% edit_time %] 
END
}

lib/CGI/Kwiki/Pages.pm  view on Meta::CPAN

This will upgrade everything except the config file and the changed pages. Other upgrade options are:

  --reinstall  - Upgrade everything including config file.
  --config     - Upgrade config file. You will lose local settings!
  --scripts    - Upgrade cgi scripts.
  --pages      - Upgrade default kwiki pages unless changed by a user.
  --template   - Upgrade templates.
  --javascript - Upgrade javascript.
  --style      - Upgrade css stylesheets.
__KwikiUserName__
You should strongly consider entering a username in [Preferences http:index.cgi?action=prefs]. This will allow the kwiki to keep track of who changed what page. The username will show up in the RecentChanges page.

The username is saved in a cookie, so it should stay around after you are done with your session. If you happen to be using a public machine, you may wish to clear the username when you are done.

By default Kwiki requires that you create a page about yourself prior to setting your username. So if your name is Eddy Merckz, you should create a page called EddyMerckz, and describe yourself a bit. Then you can go to [Preferences http:index.cgi?ac...

lib/CGI/Kwiki/Pages/zh_cn.pm  view on Meta::CPAN

这个指令会把组态档案跟被修改过的页面外,所有的档案都加以升级。另外还有其她的升级选项:

  --reinstall  - 所有的档案都升级,也包括了组态档案。
  --config     - 升级组态档案。你将会移师所有本地端的设定!
  --scripts    - 祇升级 cgi 脚本。
  --pages      - 祇升级预设的快纪页面,除非该页面已被使用者变更过了。
  --template   - 祇升级模版。
  --javascript - 祇升级 javascript 。
  --style      - 祇升级 css 样式表。
__快纪使用者名称__
你真的该认真考虑到[偏好设定 http:index.cgi?action=prefs]输入使用者名称。这会让快纪能够保持追踪谁变更了甚么页面。这个使用者名称将会显示在[最近更动 http:index.cgi?RecentChanges]页面里。

使用者名称会被储存在 cookie 里,所以就算你结束这个联机期间也应该还会被保留住。如果你在用公用机器的话,你就应该在离开前清除掉这里的使用者名称。

在预设的情况下,快纪会在你设定使用者名称时,要求你先建立一个关于你自己的页面。所以如果引的名字的是路人甲的话,你就应该先建立一个叫[路人甲]的页面,然后在那一页里稍微描è¿...

lib/CGI/Kwiki/Pages/zh_tw.pm  view on Meta::CPAN

這個指令會把組態檔案跟被修改過的頁面外,所有的檔案都加以升級。另外還有其她的升級選項:

  --reinstall  - 所有的檔案都升級,也包括了組態檔案。
  --config     - 升級組態檔案。妳將會移師所有本地端的設定!
  --scripts    - 祇升級 cgi 腳本。
  --pages      - 祇升級預設的快紀頁面,除非該頁面已被使用者變更過了。
  --template   - 祇升級模版。
  --javascript - 祇升級 javascript 。
  --style      - 祇升級 css 樣式表。
__快紀使用者名稱__
妳真的該認真考慮到[偏好設定 http:index.cgi?action=prefs]輸入使用者名稱。這會讓快紀能夠保持追蹤誰變更了甚麼頁面。這個使用者名稱將會顯示在[最近更動 http:index.cgi?RecentChanges]頁面裡。

使用者名稱會被儲存在 cookie 裡,所以就算妳結束這個連線期間也應該還會被保留住。如果妳在用公用機器的話,妳就應該在離開前清除掉這裡的使用者名稱。

在預設的情況下,快紀會在妳設定使用者名稱時,要求你先建立一個關於妳自己的頁面。所以如果引的名字的是路人甲的話,妳就應該先建立一個叫[路人甲]的頁面,然後在那一頁裡稍微描è¿...

lib/CGI/Kwiki/Plugin/Diff.pm  view on Meta::CPAN


sub methods {
    qw(entry_form display_diff);
}

sub entry_form {
    my ($self, $page_id) = @_;
    $page_id ||= $self->cgi->page_id;

    return '' 
      unless $self->prefs->{select_diff} &&
             $self->backup->has_history;
    my $history = $self->backup->history;
    return '' unless @$history > 1;
    my $head_revision = $history->[0]{revision};
    my $current_revision = $self->cgi->current_revision || 
                           $head_revision;
    my (@values, %labels, $selected);
    for (@$history) {
        my $key = $_->{revision};
        push @values, $key;

lib/CGI/Kwiki/Plugin/Diff.pm  view on Meta::CPAN

<input type="hidden" name="page_id" value="$page_id" />
<input type="hidden" name="head_revision" value="$head_revision" />
<input type="hidden" name="current_revision" value="$current_revision" />
</form>
FORM
}

sub display_diff {
    my ($self) = shift;
    return '' 
      unless $self->prefs->{show_diff} &&
             $self->backup->has_history;
    my $page_id = $self->cgi->page_id;
    my $history = $self->backup->history;
    return '' unless @$history > 1;
    $self->diff($page_id,
                $history->[1]{revision},
                $history->[0]{revision},
                2,
               );
}

lib/CGI/Kwiki/Prefs.pm  view on Meta::CPAN

        show_changed
    );
}

attribute($_) for pref_fields();

sub new {
    my $class = shift;
    my $self = $class->SUPER::new(@_);
    $self->driver->load_class('cookie');
    my $prefs = $self->driver->cookie->prefs;
    for my $pref ($self->pref_fields) {
        $self->$pref(defined $prefs->{$pref} ? $prefs->{$pref} : '')
          unless defined $self->$pref;
    }
    return $self;
}

sub all {
    my ($self) = @_;
    map {
        my $pref = $_;
        ($pref, $self->$pref());

lib/CGI/Kwiki/Prefs.pm  view on Meta::CPAN

}

sub process {
    my ($self) = @_;
    $self->error_msg('');
    $self->save 
      if $self->cgi->button eq 'SAVE';
    $self->cgi->page_id($self->config->preferences_page);
    return
      $self->template->process('display_header') .
      $self->template->process('prefs_body',
          error_msg => $self->error_msg,
          $self->all,
      ) .
      $self->template->process('basic_footer');
}

sub save {
    my ($self) = @_;
    for my $pref ($self->pref_fields) {
        $self->$pref($self->cgi->$pref);
    }
    unless ($self->user_name eq '' or 
            $self->database->exists($self->user_name)
           ) {
        $self->error_msg(
          '<p>' . $self->loc("Username must be a valid wiki page (about yourself).") . '</p>'
        );
        return;
    }
    $self->driver->cookie->prefs({$self->all});
}
    
1;

__END__

=head1 NAME 

CGI::Kwiki::Prefs - Preferences Base Class for CGI::Kwiki

lib/CGI/Kwiki/Template.pm  view on Meta::CPAN

sub suffix { 
    my ($self, $file) = @_;
    $file =~ /README/ ? '' : '.html';
}

sub process {
    my ($self, $template, %vars) = @_;
    my @vars = (
        $self->config->all,
        $self->cgi->all,
        $self->prefs->all,
        $self->driver->metadata->all,
        $self->all,
        %vars,
    );
    my @templates = ref $template ? @$template : $template;
    return join '', map {
        $self->render($self->read_template($_), @vars)
    } @templates;
}

lib/CGI/Kwiki/Template.pm  view on Meta::CPAN

    my $return;
    eval {
        $return = $self->driver->plugin->call_packed($1, $2);
    };
    return "<!-- $@ -->" if $@;
    return $return;
}

sub checkbox {
    my ($self, $boxname) = @_;
    my $prefs = $self->driver->cookie->prefs;
    my $checked = $prefs->{$boxname} ? ' checked' : '';
    return qq{<input type="checkbox" name="$boxname"$checked>};
}

1;

__DATA__

=head1 NAME 

CGI::Kwiki::Template - HTML Template Base Class for CGI::Kwiki

lib/CGI/Kwiki/Template.pm  view on Meta::CPAN

<div class="sidetitle">
{{KwikiNavigation}}
</div><!-- close "sidetitle" -->

<div class="side">
<span><a href="[% script %]?[% top_page %]" accesskey="1">[% loc_top_page %]</a></span>
[% IF has_privacy %]
<span><a href="blog.cgi">[% loc_blog_page %]</a></span>
[% END %]
<span><a href="[% script %]?[% changes_page %]">[% loc_changes_page %]</a></span>
<span><a href="[% script %]?action=prefs">[% loc_preferences_page %]</a></span>
</div><!-- close "side" -->

<div class="powered">
Powered by:<br /><a href="http://kwiki.org">Kwiki 0.18</a>
</div><!-- close "powered" -->

</div><!-- close "links" -->

</body>
</html>

lib/CGI/Kwiki/Template.pm  view on Meta::CPAN

<div class="sidetitle">
{{KwikiNavigation}}
</div><!-- close "sidetitle" -->

<div class="side">
<span><a href="[% script %]?[% top_page %]" accesskey="1">[% loc_top_page %]</a></span>
[% IF has_privacy %]
<span><a href="blog.cgi">[% loc_blog_page %]</a></span>
[% END %]
<span><a href="[% script %]?[% changes_page %]">[% loc_changes_page %]</a></span>
<span><a href="[% script %]?action=prefs">[% loc_preferences_page %]</a></span>
</div><!-- close "side" -->

<div class="powered">
Powered by:<br /><a href="http://kwiki.org">Kwiki 0.18</a>
</div><!-- close "powered" -->

</div><!-- close "links" -->

</body>
</html>

lib/CGI/Kwiki/Template.pm  view on Meta::CPAN

<div class="sidetitle">
{{KwikiNavigation}}
</div><!-- close "sidetitle" -->

<div class="side">
<span><a href="[% script %]?[% top_page %]" accesskey="1">[% loc_top_page %]</a></span>
[% IF has_privacy %]
<span><a href="blog.cgi">[% loc_blog_page %]</a></span>
[% END %]
<span><a href="[% script %]?[% changes_page %]">[% loc_changes_page %]</a></span>
<span><a href="[% script %]?action=prefs">[% loc_preferences_page %]</a></span>
</div><!-- close "side" -->

<div class="powered">
Powered by:<br /><a href="http://kwiki.org">Kwiki 0.18</a>
</div><!-- close "powered" -->

</div><!-- close "links" -->

</body>
</html>

lib/CGI/Kwiki/Template.pm  view on Meta::CPAN


  <a id="entry"></a>
  <h2 class="title"><a href="[% script %]?action=search&search=[% page_id %]">[% page_id %]</a></h2>

<div class="upper-nav">
<a href="[% script %]?[% top_page %]" accesskey="1">[% loc_top_page %]</a> | 
[% IF has_privacy %]
<a href="blog.cgi">[% loc_blog_page %]</a> | 
[% END %]
<a href="[% script %]?[% changes_page %]">[% loc_changes_page %]</a> | 
<a href="[% script %]?action=prefs">[% loc_preferences_page %]</a> | 
<form method="post" action="[% script %]" enctype="application/x-www-form-urlencoded" style="display: inline">
<input type="text" name="search" size="15" value="{{Search}}" onfocus="this.value=''" />
<input type="hidden" name="action" value="search" />
</form>
</div><!-- close "upper-nav" -->
<a id="skip-upper-nav"></a>

  <hr />
__edit_body__
<h2 class="comments-head">{{EDIT}}</h2>

lib/CGI/Kwiki/Template.pm  view on Meta::CPAN

<input type="checkbox" name="blog"
       onclick="setProtected(this)">
<b>{{Blog this page on SAVE}}</b><br />
<input type="checkbox" name="delete"
       onclick="setForDelete(this)">
<b>{{Permanently delete this page on SAVE}}</b><br />
[% END %]
</form>

</div><!-- close "comments-post" -->
__prefs_body__
[% IF not_admin %]
<form method="post" enctype="application/x-www-form-urlencoded" action="admin.cgi" 
>
<input type="submit" name="button-login" value="{{LOGIN}}">
<input type="hidden" name="action" value="prefs">
<b>{{(You must be a site administrator to login)}}</b>
</form>
<hr />
[% END %]

[% IF is_admin %]
<form method="post" enctype="application/x-www-form-urlencoded" action="kwiki.cgi" 
>
<input type="submit" name="button-logout" value="{{LOGOUT}}">
<input type="hidden" name="action" value="prefs">
</form>
<hr />
[% END %]

<form>
<p>{{Your [KwikiUserName] will be used to indicate who changed a page. This can be viewed in [[% changes_page %]].}}
</p>
<span style="color:red">[% error_msg %]</span>
{{UserName: &nbsp;}}
<input type="text" name="user_name" value="[% user_name %]" size="20"> 
<br /><br />
[% checkbox(show_changed) %] {{Show changed message at bottom of display.}}<br />
[% checkbox(select_diff) %] {{Show diff pulldown at bottom of display.}}<br />
[% checkbox(show_diff) %] {{Show latest diff at bottom of display.}}<br />
<br />
<input type="submit" name="button-save" value="{{SAVE}}">
<b>{{(Click the SAVE button after making changes)}}</b>
<input type="hidden" name="action" value="prefs">
</form>
__preview_body__
<h2 class="comments-head">{{PREVIEW}}</h2>

<div class="comments-post">

[% preview %]

</div><!-- close "comments-post" -->



( run in 1.394 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )