summaryrefslogtreecommitdiff
path: root/doc/style.css
AgeCommit message (Expand)Author
2007-05-122007-04-06use popup balloon for more backlinks, rather than expanding on hover, sincejoey
2007-03-31* Hide excess backlinks and expand using CSS trick; control quantiy viajoey
2007-03-31* Add a templates page to the basewiki. It will automatically list alljoey
2007-03-22* Make ikiwiki's stylesheet support printing by hiding parts of the pagejoey
2007-02-19* Add a openidlogin-bg.gif to wikiicons and have the stylesheet use it for thejoey
2007-02-13* Make the basewiki be full of symlinks to pages that should be the samejoey
2007-02-10merge to basewikijoey
2007-02-10web commit by JoshTriplett: Nuke trailing whitespace.joey
2007-02-10web commit by JoshTriplett: Avoid overriding the user's choice of sans-serif ...joey
2006-03-29Implemented --underlaydir, and moved files provided by underlay out of docjoey
2006-03-29minorjoey
2006-03-29minor improvementsjoey
2006-03-29better buttonjoey
2006-03-29add rss buttonjoey
2006-03-29fixjoey
2006-03-29fixjoey
2006-03-29fixjoey
2006-03-29fixjoey
2006-03-29fixjoey
2006-03-29add things needed by formbuilderjoey
2006-03-29addjoey
lass="hl opt">,
  • htmlext => "html",
  • cgi => 0,
  • post_commit => 0,
  • rcs => '',
  • url => '',
  • cgiurl => '',
  • historyurl => '',
  • diffurl => '',
  • rss => 0,
  • atom => 0,
  • allowrss => 0,
  • allowatom => 0,
  • discussion => 1,
  • rebuild => 0,
  • refresh => 0,
  • getctime => 0,
  • w3mmode => 0,
  • wrapper => undef,
  • wrappermode => undef,
  • svnpath => "trunk",
  • gitorigin_branch => "origin",
  • gitmaster_branch => "master",
  • srcdir => undef,
  • destdir => undef,
  • pingurl => [],
  • templatedir => "$installdir/share/ikiwiki/templates",
  • underlaydir => "$installdir/share/ikiwiki/basewiki",
  • underlaydirs => [],
  • setup => undef,
  • adminuser => undef,
  • adminemail => undef,
  • plugin => [qw{mdwn link inline htmlscrubber passwordauth openid
  • signinedit lockedit conditional recentchanges}],
  • libdir => undef,
  • timeformat => '%c',
  • locale => undef,
  • sslcookie => 0,
  • httpauth => 0,
  • userdir => "",
  • usedirs => 1,
  • numbacklinks => 10,
  • account_creation_password => "",
  • prefix_directives => 0,
  • } #}}}
  • sub checkconfig () { #{{{
  • # locale stuff; avoid LC_ALL since it overrides everything
  • if (defined $ENV{LC_ALL}) {
  • $ENV{LANG} = $ENV{LC_ALL};
  • delete $ENV{LC_ALL};
  • }
  • if (defined $config{locale}) {
  • if (POSIX::setlocale(&POSIX::LC_ALL, $config{locale})) {
  • $ENV{LANG}=$config{locale};
  • $gettext_obj=undef;
  • }
  • }
  • if ($config{w3mmode}) {
  • eval q{use Cwd q{abs_path}};
  • error($@) if $@;
  • $config{srcdir}=possibly_foolish_untaint(abs_path($config{srcdir}));
  • $config{destdir}=possibly_foolish_untaint(abs_path($config{destdir}));
  • $config{cgiurl}="file:///\$LIB/ikiwiki-w3m.cgi/".$config{cgiurl}
  • unless $config{cgiurl} =~ m!file:///!;
  • $config{url}="file://".$config{destdir};
  • }
  • if ($config{cgi} && ! length $config{url}) {
  • error(gettext("Must specify url to wiki with --url when using --cgi"));
  • }
  • $config{wikistatedir}="$config{srcdir}/.ikiwiki"
  • unless exists $config{wikistatedir};
  • if ($config{rcs}) {
  • eval qq{use IkiWiki::Rcs::$config{rcs}};
  • if ($@) {
  • error("Failed to load RCS module IkiWiki::Rcs::$config{rcs}: $@");
  • }
  • }
  • else {
  • require IkiWiki::Rcs::Stub;
  • }
  • if (exists $config{umask}) {
  • umask(possibly_foolish_untaint($config{umask}));
  • }
  • run_hooks(checkconfig => sub { shift->() });
  • return 1;
  • } #}}}
  • sub loadplugins () { #{{{
  • if (defined $config{libdir}) {
  • unshift @INC, possibly_foolish_untaint($config{libdir});
  • }
  • loadplugin($_) foreach @{$config{plugin}};
  • run_hooks(getopt => sub { shift->() });
  • if (grep /^-/, @ARGV) {
  • print STDERR "Unknown option: $_\n"
  • foreach grep /^-/, @ARGV;
  • usage();
  • }
  • return 1;
  • } #}}}
  • sub loadplugin ($) { #{{{
  • my $plugin=shift;
  • return if grep { $_ eq $plugin} @{$config{disable_plugins}};
  • foreach my $dir (defined $config{libdir} ? possibly_foolish_untaint($config{libdir}) : undef,
  • "$installdir/lib/ikiwiki") {
  • if (defined $dir && -x "$dir/plugins/$plugin") {
  • require IkiWiki::Plugin::external;
  • import IkiWiki::Plugin::external "$dir/plugins/$plugin";
  • return 1;
  • }
  • }
  • my $mod="IkiWiki::Plugin::".possibly_foolish_untaint($plugin);
  • eval qq{use $mod};
  • if ($@) {
  • error("Failed to load plugin $mod: $@");
  • }
  • return 1;
  • } #}}}
  • sub error ($;$) { #{{{
  • my $message=shift;
  • my $cleaner=shift;
  • if ($config{cgi}) {
  • print "Content-type: text/html\n\n";
  • print misctemplate(gettext("Error"),
  • "<p>".gettext("Error").": $message</p>");
  • }
  • log_message('err' => $message) if $config{syslog};
  • if (defined $cleaner) {
  • $cleaner->();
  • }
  • die $message."\n";
  • } #}}}
  • sub debug ($) { #{{{
  • return unless $config{verbose};
  • return log_message(debug => @_);
  • } #}}}
  • my $log_open=0;
  • sub log_message ($$) { #{{{
  • my $type=shift;
  • if ($config{syslog}) {
  • require Sys::Syslog;
  • if (! $log_open) {
  • Sys::Syslog::setlogsock('unix');
  • Sys::Syslog::openlog('ikiwiki', '', 'user');
  • $log_open=1;
  • }
  • return eval {
  • Sys::Syslog::syslog($type, "[$config{wikiname}] %s", join(" ", @_));
  • };
  • }
  • elsif (! $config{cgi}) {
  • return print "@_\n";
  • }
  • else {
  • return print STDERR "@_\n";
  • }
  • } #}}}
  • sub possibly_foolish_untaint ($) { #{{{
  • my $tainted=shift;
  • my ($untainted)=$tainted=~/(.*)/s;
  • return $untainted;
  • } #}}}
  • sub basename ($) { #{{{
  • my $file=shift;
  • $file=~s!.*/+!!;
  • return $file;
  • } #}}}
  • sub dirname ($) { #{{{
  • my $file=shift;
  • $file=~s!/*[^/]+$!!;
  • return $file;
  • } #}}}
  • sub pagetype ($) { #{{{
  • my $page=shift;
  • if ($page =~ /\.([^.]+)$/) {
  • return $1 if exists $hooks{htmlize}{$1};
  • }
  • return;
  • } #}}}
  • sub isinternal ($) { #{{{
  • my $page=shift;
  • return exists $pagesources{$page} &&
  • $pagesources{$page} =~ /\._([^.]+)$/;
  • } #}}}
  • sub pagename ($) { #{{{
  • my $file=shift;
  • my $type=pagetype($file);
  • my $page=$file;
  • $page=~s/\Q.$type\E*$// if defined $type;
  • return $page;
  • } #}}}
  • sub targetpage ($$) { #{{{
  • my $page=shift;
  • my $ext=shift;
  • if (! $config{usedirs} || $page =~ /^index$/ ) {
  • return $page.".".$ext;
  • } else {
  • return $page."/index.".$ext;
  • }
  • } #}}}
  • sub htmlpage ($) { #{{{
  • my $page=shift;
  • return targetpage($page, $config{htmlext});
  • } #}}}
  • sub srcfile ($) { #{{{
  • my $file=shift;
  • return "$config{srcdir}/$file" if -e "$config{srcdir}/$file";
  • foreach my $dir (@{$config{underlaydirs}}, $config{underlaydir}) {
  • return "$dir/$file" if -e "$dir/$file";
  • }
  • error("internal error: $file cannot be found in $config{srcdir} or underlay");
  • return;
  • } #}}}
  • sub add_underlay ($) { #{{{
  • my $dir=shift;
  • if ($dir=~/^\//) {
  • unshift @{$config{underlaydirs}}, $dir;
  • }
  • else {
  • unshift @{$config{underlaydirs}}, "$config{underlaydir}/../$dir";
  • }
  • return 1;
  • } #}}}
  • sub readfile ($;$$) { #{{{
  • my $file=shift;
  • my $binary=shift;
  • my $wantfd=shift;
  • if (-l $file) {
  • error("cannot read a symlink ($file)");
  • }
  • local $/=undef;
  • open (my $in, "<", $file) || error("failed to read $file: $!");
  • binmode($in) if ($binary);
  • return \*$in if $wantfd;
  • my $ret=<$in>;
  • close $in || error("failed to read $file: $!");
  • return $ret;
  • } #}}}
  • sub writefile ($$$;$$) { #{{{
  • my $file=shift; # can include subdirs
  • my $destdir=shift; # directory to put file in
  • my $content=shift;
  • my $binary=shift;
  • my $writer=shift;
  • my $test=$file;
  • while (length $test) {
  • if (-l "$destdir/$test") {
  • error("cannot write to a symlink ($test)");
  • }
  • $test=dirname($test);
  • }
  • my $newfile="$destdir/$file.ikiwiki-new";
  • if (-l $newfile) {
  • error("cannot write to a symlink ($newfile)");
  • }
  • my $dir=dirname($newfile);
  • if (! -d $dir) {
  • my $d="";
  • foreach my $s (split(m!/+!, $dir)) {
  • $d.="$s/";
  • if (! -d $d) {
  • mkdir($d) || error("failed to create directory $d: $!");
  • }
  • }
  • }
  • my $cleanup = sub { unlink($newfile) };
  • open (my $out, '>', $newfile) || error("failed to write $newfile: $!", $cleanup);
  • binmode($out) if ($binary);
  • if ($writer) {
  • $writer->(\*$out, $cleanup);
  • }
  • else {
  • print $out $content or error("failed writing to $newfile: $!", $cleanup);
  • }
  • close $out || error("failed saving $newfile: $!", $cleanup);
  • rename($newfile, "$destdir/$file") ||
  • error("failed renaming $newfile to $destdir/$file: $!", $cleanup);
  • return 1;
  • } #}}}
  • my %cleared;
  • sub will_render ($$;$) { #{{{
  • my $page=shift;
  • my $dest=shift;
  • my $clear=shift;
  • # Important security check.
  • if (-e "$config{destdir}/$dest" && ! $config{rebuild} &&
  • ! grep { $_ eq $dest } (@{$renderedfiles{$page}}, @{$oldrenderedfiles{$page}})) {
  • error("$config{destdir}/$dest independently created, not overwriting with version from $page");
  • }
  • if (! $clear || $cleared{$page}) {
  • $renderedfiles{$page}=[$dest, grep { $_ ne $dest } @{$renderedfiles{$page}}];
  • }
  • else {
  • foreach my $old (@{$renderedfiles{$page}}) {
  • delete $destsources{$old};
  • }
  • $renderedfiles{$page}=[$dest];
  • $cleared{$page}=1;
  • }
  • $destsources{$dest}=$page;
  • return 1;
  • } #}}}
  • sub bestlink ($$) { #{{{
  • my $page=shift;
  • my $link=shift;
  • my $cwd=$page;
  • if ($link=~s/^\/+//) {
  • # absolute links
  • $cwd="";
  • }
  • $link=~s/\/$//;
  • do {
  • my $l=$cwd;
  • $l.="/" if length $l;
  • $l.=$link;
  • if (exists $links{$l}) {
  • return $l;
  • }
  • elsif (exists $pagecase{lc $l}) {
  • return $pagecase{lc $l};
  • }
  • } while $cwd=~s!/?[^/]+$!!;
  • if (length $config{userdir}) {
  • my $l = "$config{userdir}/".lc($link);
  • if (exists $links{$l}) {
  • return $l;
  • }
  • elsif (exists $pagecase{lc $l}) {
  • return $pagecase{lc $l};
  • }
  • }
  • #print STDERR "warning: page $page, broken link: $link\n";
  • return "";
  • } #}}}
  • sub isinlinableimage ($) { #{{{
  • my $file=shift;
  • return $file =~ /\.(png|gif|jpg|jpeg)$/i;
  • } #}}}
  • sub pagetitle ($;$) { #{{{
  • my $page=shift;
  • my $unescaped=shift;
  • if ($unescaped) {
  • $page=~s/(__(\d+)__|_)/$1 eq '_' ? ' ' : chr($2)/eg;
  • }
  • else {
  • $page=~s/(__(\d+)__|_)/$1 eq '_' ? ' ' : "&#$2;"/eg;
  • }
  • return $page;
  • } #}}}