- #!/usr/bin/perl
- package IkiWiki;
- use warnings;
- use strict;
- use Encode;
- use URI::Escape q{uri_escape_utf8};
- use POSIX ();
- use Storable;
- use open qw{:utf8 :std};
- use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase
- %pagestate %wikistate %renderedfiles %oldrenderedfiles
- %pagesources %delpagesources %destsources %depends %depends_simple
- @mass_depends %hooks %forcerebuild %loaded_plugins %typedlinks
- %oldtypedlinks %autofiles};
- use Exporter q{import};
- our @EXPORT = qw(hook debug error htmlpage template template_depends
- deptype add_depends pagespec_match pagespec_match_list bestlink
- htmllink readfile writefile pagetype srcfile pagename
- displaytime will_render gettext ngettext urlto targetpage
- add_underlay pagetitle titlepage linkpage newpagefile
- inject add_link add_autofile
- %config %links %pagestate %wikistate %renderedfiles
- %pagesources %destsources %typedlinks);
- our $VERSION = 3.00; # plugin interface version, next is ikiwiki version
- our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE
- our $installdir='/usr'; # INSTALLDIR_AUTOREPLACE done by Makefile, DNE
- # Page dependency types.
- our $DEPEND_CONTENT=1;
- our $DEPEND_PRESENCE=2;
- our $DEPEND_LINKS=4;
- # Optimisation.
- use Memoize;
- memoize("abs2rel");
- memoize("sortspec_translate");
- memoize("pagespec_translate");
- memoize("template_file");
- sub getsetup () {
- wikiname => {
- type => "string",
- default => "wiki",
- description => "name of the wiki",
- safe => 1,
- rebuild => 1,
- },
- adminemail => {
- type => "string",
- default => undef,
- example => 'me@example.com',
- description => "contact email for wiki",
- safe => 1,
- rebuild => 0,
- },
- adminuser => {
- type => "string",
- default => [],
- description => "users who are wiki admins",
- safe => 1,
- rebuild => 0,
- },
- banned_users => {
- type => "string",
- default => [],
- description => "users who are banned from the wiki",
- safe => 1,
- rebuild => 0,
- },
- srcdir => {
- type => "string",
- default => undef,
- example => "$ENV{HOME}/wiki",
- description => "where the source of the wiki is located",
- safe => 0, # path
- rebuild => 1,
- },
- destdir => {
- type => "string",
- default => undef,
- example => "/var/www/wiki",
- description => "where to build the wiki",
- safe => 0, # path
- rebuild => 1,
- },
- url => {
- type => "string",
- default => '',
- example => "http://example.com/wiki",
- description => "base url to the wiki",
- safe => 1,
- rebuild => 1,
- },
- cgiurl => {
- type => "string",
- default => '',
- example => "http://example.com/wiki/ikiwiki.cgi",
- description => "url to the ikiwiki.cgi",
- safe => 1,
- rebuild => 1,
- },
- cgi_wrapper => {
- type => "string",
- default => '',
- example => "/var/www/wiki/ikiwiki.cgi",
- description => "filename of cgi wrapper to generate",
- safe => 0, # file
- rebuild => 0,
- },
- cgi_wrappermode => {
- type => "string",
- default => '06755',
- description => "mode for cgi_wrapper (can safely be made suid)",
- safe => 0,
- rebuild => 0,
- },
- rcs => {
- type => "string",
- default => '',
- description => "rcs backend to use",
- safe => 0, # don't allow overriding
- rebuild => 0,
- },
- default_plugins => {
- type => "internal",
- default => [qw{mdwn link inline meta htmlscrubber passwordauth
- openid signinedit lockedit conditional
- recentchanges parentlinks editpage}],
- description => "plugins to enable by default",
- safe => 0,
- rebuild => 1,
- },
- add_plugins => {
- type => "string",
- default => [],
- description => "plugins to add to the default configuration",
- safe => 1,
- rebuild => 1,
- },
- disable_plugins => {
- type => "string",
- default => [],
- description => "plugins to disable",
- safe => 1,
- rebuild => 1,
- },
- templatedir => {
- type => "string",
- default => "$installdir/share/ikiwiki/templates",
- description => "additional directory to search for template files",
- advanced => 1,
- safe => 0, # path
- rebuild => 1,
- },
- underlaydir => {
- type => "string",
- default => "$installdir/share/ikiwiki/basewiki",
- description => "base wiki source location",
- advanced => 1,
- safe => 0, # path
- rebuild => 0,
- },
- underlaydirbase => {
- type => "internal",
- default => "$installdir/share/ikiwiki",
- description => "parent directory containing additional underlays",
- safe => 0,
- rebuild => 0,
- },
- wrappers => {
- type => "internal",
- default => [],
- description => "wrappers to generate",
- safe => 0,
- rebuild => 0,
- },
- underlaydirs => {
- type => "internal",
- default => [],
- description => "additional underlays to use",
- safe => 0,
- rebuild => 0,
- },
- verbose => {
- type => "boolean",
- example => 1,
- description => "display verbose messages?",
- safe => 1,
- rebuild => 0,
- },
- syslog => {
- type => "boolean",
- example => 1,
- description => "log to syslog?",
- safe => 1,
- rebuild => 0,
- },
- usedirs => {
- type => "boolean",
- default => 1,
- description => "create output files named page/index.html?",
- safe => 0, # changing requires manual transition
- rebuild => 1,
- },
- prefix_directives => {
- type => "boolean",
- default => 1,
- description => "use '!'-prefixed preprocessor directives?",
- safe => 0, # changing requires manual transition
- rebuild => 1,
- },
- indexpages => {
- type => "boolean",
- default => 0,
- description => "use page/index.mdwn source files",
- safe => 1,
- rebuild => 1,
- },
- discussion => {
- type => "boolean",
- default => 1,
- description => "enable Discussion pages?",
- safe => 1,
- rebuild => 1,
- },
- discussionpage => {
- type => "string",
- default => gettext("Discussion"),
- description => "name of Discussion pages",
- safe => 1,
|