Compare commits

..

1 Commits

Author SHA1 Message Date
Alex Schroeder
76ce0426c7 wiki.pl: first steps towards HTML::Tiny and Mojolicious::Lite
The current state displays the HomePage and allows you to switch to RecentChanges and back.
Not much else works, I'm afraid.
2015-10-12 10:27:31 +02:00
369 changed files with 11080 additions and 15288 deletions

1
.gitattributes vendored
View File

@@ -1 +0,0 @@
*.pl linguist-language=Perl

6
.gitignore vendored
View File

@@ -1,11 +1,9 @@
*~
/build/
\#*\#
/test-data*
/test-data
/Mac/pkg/
*.dmg
*.pkg
.DS_Store
wiki.log
.prove
TAGS
wiki.log

View File

@@ -3,7 +3,7 @@
# subdirectory.
VERSION_NO=$(shell git describe --tags)
TRANSLATIONS=$(wildcard modules/translations/[a-z]*-utf8.pl$)
TRANSLATIONS=$(wildcard modules/translations/[a-z]*.pl$)
MODULES=$(wildcard modules/*.pl)
BUILD=build/wiki.pl $(foreach file, $(notdir $(MODULES)) $(notdir $(TRANSLATIONS)), build/$(file))
@@ -19,13 +19,9 @@ build:
clean:
rm -rf build
prove t/setup.pl
release:
perl stuff/release ~/oddmuse.org/releases 2.3.3
build/wiki.pl: wiki.pl
perl -lne "s/(\\\$$q->a\(\{-href=>'https:\/\/www.oddmuse.org\/'\}, 'Oddmuse'\))/\\\$$q->a({-href=>'https:\/\/git.savannah.gnu.org\/cgit\/oddmuse.git\/tag\/?id=$(VERSION_NO)'}, 'wiki.pl') . ' ($(VERSION_NO)), see ' . \$$1/; print" < $< > $@
perl -lne "s/(\\\$$q->a\({-href=>'http:\/\/www.oddmuse.org\/'}, 'Oddmuse'\))/\\\$$q->a({-href=>'http:\/\/git.savannah.gnu.org\/cgit\/oddmuse.git\/tag\/?id=$(VERSION_NO)'}, 'wiki.pl') . ' ($(VERSION_NO)), see ' . \$$1/; print" < $< > $@
build/%-utf8.pl: modules/translations/%-utf8.pl
perl -lne "s/(AddModuleDescription\('[^']+', '[^']+')\)/\$$1, 'translations\/', '$(VERSION_NO)')/; print" < $< > $@
@@ -36,8 +32,8 @@ build/national-%.pl: modules/translations/national-%.pl
build/month-names-%.pl: modules/translations/month-names-%.pl
perl -lne "s/(AddModuleDescription\('[^']+', '[^']+')\)/\$$1, 'translations\/', '$(VERSION_NO)')/; print" < $< > $@
# from: https://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/namespaces.pl
# to: https://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/namespaces.pl?id=2.1-11-gd4f1e27
# from: http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/namespaces.pl
# to: http://git.savannah.gnu.org/cgit/oddmuse.git/tree/modules/namespaces.pl?id=2.1-11-gd4f1e27
build/%.pl: modules/%.pl
perl -lne "s/(AddModuleDescription\('[^']+', '[^']+')\)/\$$1, undef, '$(VERSION_NO)')/; print" < $< > $@
@@ -53,10 +49,5 @@ translations: $(TRANSLATIONS)
perl stuff/oddtrans -l $$f wiki.pl $(MODULES) > $$f-new && mv $$f-new $$f; \
done
# Running four jobs in parallel, but clean up data directories without
# race conditions!
jobs ?= 4
test:
prove t/setup.pl
prove --jobs=$(jobs) --state=slow,save t
prove t

View File

@@ -23,21 +23,12 @@ usermod -a -G sudo alex
Now you can login as {{{alex}}} and do everything else using {{{sudo}}}.
You need to copy wiki.pl into your cgi-bin directory, and you need to
make the script executable. You might also have to change its owner to
an appropriate user on your system.
make the script executable.
{{{
sudo wget -O /usr/lib/cgi-bin/wiki.pl \
http://git.savannah.gnu.org/cgit/oddmuse.git/plain/wiki.pl
sudo chmod +x /usr/lib/cgi-bin/wiki.pl
sudo chown www-data.www-data /usr/lib/cgi-bin/wiki.pl
}}}
If you're on SUSE, the user might not be {{{www-data}}} but
{{{wwwrun}}} without appropriate group:
{{{
sudo chown wwwrun.root /usr/lib/cgi-bin/wiki.pl
}}}
You should be able to test it right now! Visit
@@ -94,7 +85,7 @@ Enjoy your wiki experience.
Visit https://www.oddmuse.org/ to learn more about the translation
files and modules that are part of this package.
== Checking the Apache Setup
== Apache
If you think this information doesn't work for you, here are some things
to check.
@@ -128,7 +119,7 @@ The default site is configured in
sudo a2ensite default
}}}
This file also lists the directories we've used in our instructions
This file also lists the directories we've used in out instructions
above.
{{{
@@ -145,32 +136,6 @@ simply restart it all:
sudo service apache2 graceful
}}}
== Using just Perl
You can use Mojolicious as your web server. There is a simple
##server.pl## which you can use. Here's how you might start it:
{{{
mkdir ~/oddmuse
WikiDataDir=$HOME/oddmuse perl server.pl daemon
}}}
This makes the server available on {{{http://localhost:3000/wiki}}}.
If it works for you, feel free to upgrade to Hypnotoad.
{{{
WikiDataDir=$HOME/oddmuse hypnotoad server.pl
}}}
Note: Hypnotoad uses a different default port. The above makes the
server available on {{{http://localhost:8080/wiki}}}. Hypnotoad will
keep forking new processes. To stop it, use the {{{-s}}} flag.
{{{
hypnotoad -s server.pl
}}}
== License
Permission is granted to copy, distribute and/or modify this document

View File

@@ -1,14 +0,0 @@
#!/bin/bash
if test -z "$2" -o ! -z "$3"; then
echo "Usage: delete.sh USERNAME WIKI"
exit 1
fi
username=$1
wiki=$2
for p in $(curl --silent "https://campaignwiki.org/wiki/$wiki?action=index;raw=1"); do
echo "Deleting: $p"
curl -F frodo=1 -F "title=$p" -F text=DeletedPage -F summary=Deleted -F username="$username" "https://campaignwiki.org/wiki/$wiki"
sleep 5
done

View File

@@ -3,7 +3,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -12,7 +12,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use CGI;
use CGI::Carp qw(fatalsToBrowser);

View File

@@ -1,131 +0,0 @@
#! /usr/bin/perl -w
# Copyright (C) 2005-2016 Alex Schroeder <alex@gnu.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
use Modern::Perl;
use LWP::UserAgent;
use utf8;
binmode(STDOUT, ":utf8");
my $ua = LWP::UserAgent->new;
sub url_encode {
my $str = shift;
return '' unless $str;
utf8::encode($str); # turn to byte string
my @letters = split(//, $str);
my %safe = map {$_ => 1} ('a' .. 'z', 'A' .. 'Z', '0' .. '9', '-', '_', '.', '!', '~', '*', "'", '(', ')', '#');
foreach my $letter (@letters) {
$letter = sprintf("%%%02x", ord($letter)) unless $safe{$letter};
}
return join('', @letters);
}
sub get_raw {
my $uri = shift;
my $response = $ua->get($uri);
return $response->content if $response->is_success;
}
sub get_wiki_page {
my ($wiki, $id, $password) = @_;
my $parameters = [
pwd => $password,
action => 'browse',
id => $id,
raw => 1,
];
my $response = $ua->post($wiki, $parameters);
return $response->decoded_content if $response->is_success;
die "Getting $id returned " . $response->status_line;
}
sub get_wiki_index {
my $wiki = shift;
my $parameters = [
search => "flickr.com",
context => 0,
raw => 1,
];
my $response = $ua->post($wiki, $parameters);
return $response->decoded_content if $response->is_success;
die "Getting the index returned " . $response->status_line;
}
sub post_wiki_page {
my ($wiki, $id, $username, $password, $text) = @_;
my $parameters = [
username => $username,
pwd => $password,
recent_edit => 'on',
text => $text,
title => $id,
];
my $response = $ua->post($wiki, $parameters);
die "Posting to $id returned " . $response->status_line unless $response->code == 302;
}
my %seen = ();
sub write_flickr {
my ($id, $flickr, $dir, $file) = @_;
say "Found $flickr";
warn "$file was seen before: " . $seen{$file} if $seen{$file};
die "$file contains unknown characters" if $file =~ /[^a-z0-9_.]/;
$seen{$file} = "$id used $flickr";
my $bytes = get_raw($flickr) or die("No data for $id");
open(my $fh, '>', "$dir/$file") or die "Cannot write $dir/$file";
binmode($fh);
print $fh $bytes;
close($fh);
}
sub convert_page {
my ($wiki, $pics, $dir, $username, $password, $id) = @_;
say $id;
my $text = get_wiki_page($wiki, $id, $password);
my $is_changed = 0;
while ($text =~ m!(https://[a-z0-9.]+.flickr.com/(?:[a-z0-9.]+/)?([a-z0-9_]+\.(?:jpg|png)))!) {
my $flickr = $1;
my $file = $2;
write_flickr($id, $flickr, $dir, $file);
$is_changed = 1;
my $re = quotemeta($flickr);
$text =~ s!$flickr!$pics/$file!g;
}
if ($is_changed) {
post_wiki_page($wiki, $id, $username, $password, $text);
} else {
# die "$id has no flickr matches?\n$text";
}
sleep(5);
}
sub convert_site {
my ($wiki, $pics, $dir, $username, $password) = @_;
my @ids = split(/\n/, get_wiki_index($wiki));
for my $id (@ids) {
convert_page($wiki, $pics, $dir, $username, $password, $id);
}
}
our $AdminPass;
do "/home/alex/password.pl";
convert_site('https://alexschroeder.ch/wiki',
'https://alexschroeder.ch/pics',
'/home/alex/alexschroeder.ch/pics',
'Alex Schroeder',
$AdminPass);

1111
contrib/oddmuse-curl.el Normal file

File diff suppressed because it is too large Load Diff

168
contrib/vc-oddmuse.el Normal file
View File

@@ -0,0 +1,168 @@
;;; vc-oddmuse.el -- add VC support to oddmuse-curl
;;
;; Copyright (C) 2014 Alex Schroeder <alex@gnu.org>
;;
;; Latest version:
;; http://git.savannah.gnu.org/cgit/oddmuse.git/plain/contrib/vc-oddmuse.el
;; Discussion, feedback:
;; http://www.emacswiki.org/cgi-bin/wiki/OddmuseCurl
;;
;; This program is free software: you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by the Free
;; Software Foundation, either version 3 of the License, or (at your option)
;; any later version.
;;
;; This program is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
;; more details.
;;
;; You should have received a copy of the GNU General Public License along
;; with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; Add the following to your init file:
;;
;; (add-to-list 'vc-handled-backends 'oddmuse)
(add-to-list 'vc-handled-backends 'oddmuse)
(require 'oddmuse-curl)
(require 'diff)
(defun vc-oddmuse-revision-granularity () 'file)
(defun vc-oddmuse-registered (file)
"Handle files in `oddmuse-directory'."
(string-match (concat "^" (expand-file-name oddmuse-directory))
(file-name-directory file)))
(defun vc-oddmuse-state (file)
"Return the current version control state of FILE.
For a list of possible values, see `vc-state'."
;; Avoid downloading the current version from the wiki and comparing
;; the text: Too much traffic!
'edited)
(defun vc-oddmuse-working-revision (file)
"The current revision based on `oddmuse-revisions'."
(oddmuse-revision-get oddmuse-wiki oddmuse-page-name))
(defun vc-oddmuse-checkout-model (files)
"No locking."
'implicit)
(defun vc-oddmuse-create-repo (file)
(error "You cannot create Oddmuse wikis using Emacs."))
(defun vc-oddmuse-register (files &optional rev comment)
"This always works.")
(defun vc-oddmuse-revert (file &optional contents-done)
"No idea"
nil)
(defvar vc-oddmuse-log-command
(concat "curl --silent %w"
" --form action=rc"
" --form showedit=1"
" --form all=1"
" --form from=1"
" --form raw=1"
" --form match='%r'")
"Command to use for publishing index pages.
It must print the page to stdout.
See `oddmuse-format-command' for the formatting options.")
(defun vc-oddmuse-print-log (files buffer &optional shortlog start-revision limit)
"Load complete recent changes for the files."
;; Derive `oddmuse-wiki' from the first file
(with-oddmuse-file (car files)
;; The wiki expects a Perl regular expression!
(let ((regexp (concat "^(" (mapconcat 'file-name-nondirectory files "|") ")$")))
(oddmuse-run "Getting recent changes" vc-oddmuse-log-command nil nil buffer)))
(with-current-buffer buffer
(oddmuse-render-rss3))
'limit-unsupported)
(defun vc-oddmuse-log-outgoing ()
(error "This is not supported."))
(defun vc-oddmuse-log-incoming ()
(error "This is not supported."))
(defvar vc-oddmuse-get-revision-command
(concat "curl --silent"
" --form action=browse"
" --form id=%t"
" --form revision=%v"
" --form raw=1"
" '%w'")
"Command to use to get older revisions of a page.
It must print the page to stdout.
%? '?' character
%w URL of the wiki as provided by `oddmuse-wikis'
%t Page title as provided by `oddmuse-page-name'
%v Revision to retrieve as provided by `oddmuse-revision'")
(defun oddmuse-revision-filename (rev)
"Return filename for revision REV.
This uses `oddmuse-directory', `wiki' and `pagename' as bound by
`with-oddmuse-file'."
(concat oddmuse-directory
"/" wiki
"/" pagename
".~" rev "~"))
(defun vc-oddmuse-diff (files &optional rev1 rev2 buffer)
"Report the differences for FILES."
(setq buffer (or buffer (get-buffer-create "*vc-diff*")))
(dolist (file files)
(with-oddmuse-file file
(setq rev1 (or rev1 (oddmuse-get-latest-revision wiki pagename)))
(dolist (rev (list rev1 rev2))
(when (and rev (not (file-readable-p (oddmuse-revision-filename rev))))
(let* ((oddmuse-revision rev)
(command vc-oddmuse-get-revision-command)
(filename (oddmuse-revision-filename rev)))
(with-temp-buffer
(oddmuse-run
(concat "Downloading revision " rev)
command wiki pagename)
(write-file filename)))))
(diff-no-select
(if rev1 (oddmuse-revision-filename rev1) file)
(if rev2 (oddmuse-revision-filename rev2) file)
nil
(vc-switches 'oddmuse 'diff)
buffer))))
(defun vc-oddmuse-revert (file &optional contents-done)
"Revert FILE back to the wiki revision.
If optional arg CONTENTS-DONE is non-nil, then nothing needs to
be done, as the contents of FILE have already been reverted from
a version backup."
(unless contents-done
(with-oddmuse-file file
(let ((command (oddmuse-format-command vc-oddmuse-get-revision-command)))
(with-temp-buffer
(oddmuse-run "Loading" command)
(write-file file))))))
(defun vc-oddmuse-checkin (files rev comment)
"Commit changes in FILES to this backend.
REV is a historical artifact and should be ignored. COMMENT is
used as a check-in comment."
(dolist (file files)
(with-oddmuse-file file
(let* ((summary comment)
(command (oddmuse-format-command oddmuse-post-command))
(buf (get-buffer-create " *oddmuse-response*")))
(with-temp-buffer
(insert-file-contents file)
(oddmuse-run "Posting" command wiki pagename buf t 302))))))
(provide 'vc-oddmuse)

View File

@@ -1,7 +1,110 @@
/* This file is in the public domain. */
/* @import url(https://fonts.googleapis.com/css?family=Noticia+Text:400,400italic,700italic,700&subset=latin,latin-ext); */
/* vietnamese */
@font-face {
font-family: 'Noticia Text';
font-style: normal;
font-weight: 400;
src: local('Noticia Text'), local('NoticiaText-Regular)'), url('/fonts/NoticiaText-Regular.woff') format('woff');
unicode-range: U+0102-0103, U+1EA0-1EF1, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Noticia Text';
font-style: normal;
font-weight: 400;
src: local('Noticia Text'), local('NoticiaText-Regular)'), url('/fonts/NoticiaText-Regular.woff') format('woff');
unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Noticia Text';
font-style: normal;
font-weight: 400;
src: local('Noticia Text'), local('NoticiaText-Regular)'), url('/fonts/NoticiaText-Regular.woff') format('woff');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
/* vietnamese */
@font-face {
font-family: 'Noticia Text';
font-style: normal;
font-weight: 700;
src: local('Noticia Text Bold'), local('NoticiaText-Bold)'), url('/fonts/NoticiaText-Bold.woff') format('woff');
unicode-range: U+0102-0103, U+1EA0-1EF1, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Noticia Text';
font-style: normal;
font-weight: 700;
src: local('Noticia Text Bold'), local('NoticiaText-Bold)'), url('/fonts/NoticiaText-Bold.woff') format('woff');
unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Noticia Text';
font-style: normal;
font-weight: 700;
src: local('Noticia Text Bold'), local('NoticiaText-Bold)'), url('/fonts/NoticiaText-Bold.woff') format('woff');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
/* vietnamese */
@font-face {
font-family: 'Noticia Text';
font-style: italic;
font-weight: 400;
src: local('Noticia Text Italic'), local('NoticiaText-Italic)'), url('/fonts/NoticiaText-Italic.woff') format('woff');
unicode-range: U+0102-0103, U+1EA0-1EF1, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Noticia Text';
font-style: italic;
font-weight: 400;
src: local('Noticia Text Italic'), local('NoticiaText-Italic)'), url('/fonts/NoticiaText-Italic.woff') format('woff');
unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Noticia Text';
font-style: italic;
font-weight: 400;
src: local('Noticia Text Italic'), local('NoticiaText-Italic)'), url('/fonts/NoticiaText-Italic.woff') format('woff');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
/* vietnamese */
@font-face {
font-family: 'Noticia Text';
font-style: italic;
font-weight: 700;
src: local('Noticia Text Bold Italic'), local('NoticiaText-BoldItalic)'), url('/fonts/NoticiaText-BoldItalic.woff') format('woff');
unicode-range: U+0102-0103, U+1EA0-1EF1, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Noticia Text';
font-style: italic;
font-weight: 700;
src: local('Noticia Text Bold Italic'), local('NoticiaText-BoldItalic)'), url('/fonts/NoticiaText-BoldItalic.woff') format('woff');
unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Noticia Text';
font-style: italic;
font-weight: 700;
src: local('Noticia Text Bold Italic'), local('NoticiaText-BoldItalic)'), url('/fonts/NoticiaText-BoldItalic.woff') format('woff');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
font-family: 'Symbola';
src: local('Symbola'), url('/fonts/Symbola.woff') format('woff'), url('/fonts/Symbola.ttf') format('truetype');
}
body, rss {
font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
font-family: "Noticia Text", Symbola, serif;
font-style: normal;
font-size: 14pt;
margin: 1em 3em;

View File

@@ -1,536 +0,0 @@
/* This file is in the public domain. */
html{ text-align: center; }
body, rss {
font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
font-style: normal;
font-size: 14pt;
padding: 1em 3em;
max-width: 72ex;
display: inline-block;
text-align: left;
color: #000;
background-color: #fff;
}
@media print {
body {
font-size: 12pt;
}
/* hide all the crap */
div.diff, div.diff+hr, div.refer, div.near, div.definition, div.sister,
div.cal, div.footer, span.specialdays, span.gotobar, a.edit, a.number span,
div.rc form, form.tiny, p.comment, p#plus1, div.g-plusone, div.content a.feed {
display:none;
}
div.content a.book,
div.content a.movie {
text-decoration: none;
}
a cite {
font-style: italic;
}
img[alt="RSS"] { display: none }
a.rss { font-size: 8pt }
}
/* headings: we can use larger sizes if we use a lighter color.
we cannot inherit the font-family because header and footer use a narrow font. */
h1, h2, h3, title {
font-family: inherit;
font-weight: normal;
}
h1, channel title {
font-size: 32pt;
margin: 1em 0 0.5em 0;
padding: 0.4em 0;
}
h2 {
font-size: 18pt;
margin: 2em 0 0 0;
padding: 0;
}
h3 {
font-size: inherit;
font-weight: bold;
padding: 0;
margin: 1em 0 0 0;
clear: both;
}
/* headers in the journal are smaller */
div.journal h1, item title {
font-size: inherit;
padding: 0;
clear: both;
border-bottom: 1px solid #000;
}
div.journal h2 {
font-family: inherit;
font-size: inherit;
}
div.journal h3 {
font-family: inherit;
font-size: inherit;
font-weight: inherit;
font-style: italic;
}
div.journal hr {
visibility: hidden;
}
p.more {
margin-top: 3em;
}
/* Links in headings appear on journal pages. */
h1 a, h2 a, h3 a {
color:inherit;
text-decoration:none;
font-weight: normal;
}
h1 a:visited, h2 a:visited, h3 a:visited {
color: inherit;
}
/* for download buttons and the like */
.button {
display: inline-block;
font-size: 120%;
cursor: pointer;
padding: 0.4em 0.6em;
text-shadow: 0px -1px 0px #ccc;
background-color: #cfa;
border: 1px solid #9d8;
border-radius: 5px;
box-shadow: 0px 1px 3px white inset, 0px 1px 3px black;
}
.button .icon {
color: #363;
text-shadow: 0px -1px 1px white, 0px 1px 3px #666;
}
.button a {
text-decoration: none;
font-weight: normal;
}
/* links */
a.pencil {
padding-left: 1ex;
text-decoration: none;
color: inherit;
visibility: hidden;
transition: visibility 0s 1s, opacity 1s linear;
opacity: 0;
}
*:hover > a.pencil {
visibility: visible;
transition: opacity .5s linear;
opacity: 1;
}
@media print {
a.pencil {
display: none;
}
}
a.number {
text-decoration: none;
}
/* stop floating content from flowing over the footer */
hr {
clear: both;
}
/* the distance between links in the navigation bars */
span.bar a {
margin-right: 1ex;
}
a img {
border: none;
}
/* search box in the top bar */
.header form, .header p {
display: inline;
white-space: nowrap;
}
label[for="searchlang"], #searchlang, .header input[type="submit"] {
/* don't use display: none! http://stackoverflow.com/questions/5665203/getting-iphone-go-button-to-submit-form */
visibility: hidden; position: absolute;
}
/* wrap on the iphone */
@media only screen and (max-device-width: 480px) {
}
.header input {
width: 10ex;
}
/* other form fields */
input[type="text"] {
padding: 0;
font-size: 80%;
line-height: 125%;
}
/* code */
textarea, pre, code, tt {
font-family: "Andale Mono", Monaco, "Courier New", Courier, monospace, "Symbola";
font-size: 80%;
}
pre {
overflow:hidden;
white-space: pre-wrap; /* CSS 3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
/* styling for divs that will be invisible when printing
when printing. */
div.header, div.footer, div.near, div.definition, p.comment, a.tag {
font-size: 14pt;
}
@media print {
div.header, div.footer, div.near, div.definition, p.comment, a.tag {
font-size: 8pt;
}
}
div.footer form.search {
display: none;
}
div.rc li + li {
margin-top: 1em;
}
div.rc li strong, table.history strong, strong.description {
font-family: inherit;
font-weight: inherit;
}
div.diff {
padding-left: 5%;
padding-right: 5%;
font-size: 12pt;
color: #000;
}
div.old {
background-color: #ffffaf;
}
div.new {
background-color: #cfffcf;
}
div.refer {
padding-left: 5%;
padding-right: 5%;
font-size: 12pt;
}
div.message {
background-color:#fee;
color:#000;
}
img.xml {
border:none;
padding:1px;
}
a.small img {
max-width:300px;
}
a.large img {
max-width:600px;
}
div.sister {
margin-right:1ex;
background-color:inherit;
}
div.sister p {
margin-top:0;
}
div.sister hr {
display:none;
}
div.sister img {
border:none;
}
div.near, div.definition {
background-color:#efe;
}
div.sidebar {
float:right;
border:1px dotted #000;
padding:0 1em;
}
div.sidebar ul {
padding-left:1em;
}
/* replacements, features */
ins {
font-style: italic;
text-decoration: none;
}
acronym, abbr {
letter-spacing:0.1em;
font-variant:small-caps;
}
/* Interlink prefix not shown */
a .site, a .separator {
display: none;
}
a cite { font:inherit; }
/* browser borkage */
textarea[name="text"] { width:97%; height:80%; }
textarea[name="summary"] { width:97%; height:3em; }
/* comments */
textarea[name="aftertext"] { width:97%; height:10em; }
div.commentshown {
font-size: 12pt;
padding: 2em 0;
}
div.commenthidden {
display:none;
}
div.commentshown {
display:block;
}
p.comment {
margin-bottom: 0;
}
div.comment {
font-size: 14pt;
}
div.comment h2 {
margin-top: 5em;
}
/* comment pages with username, homepage, and email subscription */
.comment form span { display: block; }
.comment form span label { display: inline-block; width: 10em; }
/* IE sucks */
.comment input#username,
.comment input#homepage,
.comment input#mail { width: 20em; }
/* cal */
div.month { padding:0; margin:0 2ex; }
body > div.month {
float:right;
background-color: inherit;
border:solid thin;
padding:0 1ex;
}
.year > .month {
float:left;
}
.footer {
clear:both;
}
.month .title a.local {
background-color: inherit;
}
.month a.local {
background-color: #ddf;
}
.month a.today {
background-color: #fdd;
}
.month a {
color:inherit;
font-weight:inherit;
text-decoration: none;
background-color: #eee;
}
/* history tables and other tables */
table.history {
border: none;
}
td.history {
border: none;
}
table.user {
border: none;
border-top: 1px solid #ccc;
border-bottom: 1px solid #ccc;
padding: 1em;
margin: 1em 2em;
}
table.user tr td, table.user tr th {
border: none;
padding: 0.2em 0.5em;
vertical-align: top;
}
table.arab tr th {
font-weight:normal;
text-align:left;
vertical-align:top;
}
table.arab, table.arab tr th, table.arab tr td {
border:none;
}
th.nobreak {
white-space:nowrap;
}
table.full { width:99%; margin-left:1px; }
table.j td, table.j th, table tr td.j, table tr th.j, .j { text-align:justify; }
table.l td, table.l th, table tr td.l, table tr th.l, .l { text-align:left; }
table.r td, table.r th, table tr td.r, table tr th.r, .r { text-align:right; }
table.c td, table.c th, table tr td.c, table tr th.c, .c { text-align:center; }
table.t td { vertical-align: top; }
td.half { width:50%; }
td.third { width:33%; }
form table td { padding:5px; }
/* lists */
dd { padding-bottom:0.5ex; }
dl.inside dt { float:left; }
/* search */
div.search span.result { font-size:larger; }
div.search span.info { font-size:smaller; font-style:italic; }
div.search p.result { display:none; }
img.logo {
float: right;
margin: 0 0 0 1ex;
padding: 0;
border: 1px solid #000;
opacity: 0.3;
background-color:#ffe;
}
/* images */
div.content a.feed img, div.journal a.feed img,
div.content a img.smiley, div.journal a img.smiley, img.smiley,
div.content a.inline img, div.journal a.inline img,
div.content li a.image img, div.journal li a.image img {
margin: 0; padding: 0; border: none;
}
div.image a img {
margin-bottom: 0;
}
div.image span.caption {
margin: 0 1em;
}
img {
max-width: 100%;
}
.left { float:left; margin-right: 1em; }
.right { float:right; margin-left: 1em; }
.half img { height: 50%; width: 50%; }
.face img { width: 200px; }
div.left .left, div.right .right {
float:none;
}
.center { text-align:center; }
table.aside {
float:right;
width:40%;
margin-left: 1em;
padding: 1ex;
border: 1px dotted #666;
}
table.aside td {
text-align:left;
}
div.sidebar {
float:right; width: 250px;
text-align: right;
border: none;
margin: 1ex;
}
.bigsidebar {
float:right;
width: 500px;
border: none;
margin-left: 1ex;
font-size: 80%;
}
dl.irc dt { width:20ex; float:left; text-align:right; clear:left; }
dl.irc dt span.time { float:left; }
dl.irc dd { margin-left:22ex; }
/* portrait */
div.footer, div.comment, hr { clear: both; }
.portrait { float: left; font-size: small; margin-right: 1em; }
.portrait a { color: #999; }
div.left { float:left; margin:1em; padding: 0.5em; }
div.left p { display:table-cell; }
div.left p + p { display:table-caption; caption-side:bottom; }
p.table a { float:left; width:20ex; }
p.table + p { clear:both; }
/* rss */
channel * { display: block; }
channel title {
margin-top: 30pt;
}
copyright {
font-size: 14pt;
margin-top: 1em;
}
channel > link:before {
font-size: 18pt;
display: block;
margin: 1em;
padding: 0.5em;
content: "This is an RSS feed, designed to be read in a feed reader.";
color: red;
border: 1px solid red;
}
link, license {
font-size: 11pt;
margin-bottom: 9pt;
}
username:before { content: "Last edited by "; }
username:after { content: "."; }
generator:before { content: "Feed generated by "; }
generator:after { content: "."; }
channel description {
font-weight: bold;
}
item description {
font-style: italic;
font-weight: normal;
margin-bottom: 1em;
}
docs, language,
pubDate, lastBuildDate, ttl, guid, category, comments,
docs, image title, image link,
status, version, diff, history, importance {
display: none;
}

View File

@@ -321,6 +321,7 @@ div.sister {
float:left;
margin-right:1ex;
padding-right:1ex;
border-right:1px dashed;
}
div.sister p { padding:1ex; margin:0; }
div.sister hr { display:none; }

View File

@@ -8,8 +8,110 @@
@import url(https://fonts.googleapis.com/css?family=Noticia+Text:400,400italic,700italic,700&subset=latin,latin-ext); */
/* vietnamese */
@font-face {
font-family: 'Noticia Text';
font-style: normal;
font-weight: 400;
src: local('Noticia Text'), local('NoticiaText-Regular)'), url('/fonts/NoticiaText-Regular.woff') format('woff');
unicode-range: U+0102-0103, U+1EA0-1EF1, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Noticia Text';
font-style: normal;
font-weight: 400;
src: local('Noticia Text'), local('NoticiaText-Regular)'), url('/fonts/NoticiaText-Regular.woff') format('woff');
unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Noticia Text';
font-style: normal;
font-weight: 400;
src: local('Noticia Text'), local('NoticiaText-Regular)'), url('/fonts/NoticiaText-Regular.woff') format('woff');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
/* vietnamese */
@font-face {
font-family: 'Noticia Text';
font-style: normal;
font-weight: 700;
src: local('Noticia Text Bold'), local('NoticiaText-Bold)'), url('/fonts/NoticiaText-Bold.woff') format('woff');
unicode-range: U+0102-0103, U+1EA0-1EF1, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Noticia Text';
font-style: normal;
font-weight: 700;
src: local('Noticia Text Bold'), local('NoticiaText-Bold)'), url('/fonts/NoticiaText-Bold.woff') format('woff');
unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Noticia Text';
font-style: normal;
font-weight: 700;
src: local('Noticia Text Bold'), local('NoticiaText-Bold)'), url('/fonts/NoticiaText-Bold.woff') format('woff');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
/* vietnamese */
@font-face {
font-family: 'Noticia Text';
font-style: italic;
font-weight: 400;
src: local('Noticia Text Italic'), local('NoticiaText-Italic)'), url('/fonts/NoticiaText-Italic.woff') format('woff');
unicode-range: U+0102-0103, U+1EA0-1EF1, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Noticia Text';
font-style: italic;
font-weight: 400;
src: local('Noticia Text Italic'), local('NoticiaText-Italic)'), url('/fonts/NoticiaText-Italic.woff') format('woff');
unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Noticia Text';
font-style: italic;
font-weight: 400;
src: local('Noticia Text Italic'), local('NoticiaText-Italic)'), url('/fonts/NoticiaText-Italic.woff') format('woff');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
/* vietnamese */
@font-face {
font-family: 'Noticia Text';
font-style: italic;
font-weight: 700;
src: local('Noticia Text Bold Italic'), local('NoticiaText-BoldItalic)'), url('/fonts/NoticiaText-BoldItalic.woff') format('woff');
unicode-range: U+0102-0103, U+1EA0-1EF1, U+20AB;
}
/* latin-ext */
@font-face {
font-family: 'Noticia Text';
font-style: italic;
font-weight: 700;
src: local('Noticia Text Bold Italic'), local('NoticiaText-BoldItalic)'), url('/fonts/NoticiaText-BoldItalic.woff') format('woff');
unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
font-family: 'Noticia Text';
font-style: italic;
font-weight: 700;
src: local('Noticia Text Bold Italic'), local('NoticiaText-BoldItalic)'), url('/fonts/NoticiaText-BoldItalic.woff') format('woff');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
}
@font-face {
font-family: 'Symbola';
src: local('Symbola'), url('/fonts/Symbola.woff') format('woff');
}
body {
font-family: "Palatino Linotype", "Book Antiqua", Palatino, serif;
font-family: "Noticia Text", Symbola, serif;
font-size: 14pt;
color: #000;
background-color: #eed;
@@ -17,20 +119,16 @@ body {
}
textarea, pre, code, tt {
font-family: "Andale Mono", Monaco, "Courier New", Courier, monospace, Symbola;
font-size: 80%;
font-family: "Andale Mono", Monaco, "Courier New", Courier, monospace, Symbola;
font-size: 80%;
}
@media print {
body {
background-color: white;
background-color: white;
font-family: Times, serif;
font-size:10pt;
}
/* Printing from Firefox */
svg {
transform: translate(-1.5cm, -1cm);
}
}
/* iPhone */
@@ -51,10 +149,9 @@ textarea, pre, code, tt {
.browse { min-height: 3em; }
.header form, .header p { margin: 0; }
/* hide the buttons but don't use display:none because of
http://stackoverflow.com/questions/5665203/getting-iphone-go-button-to-submit-form
.header input[type="submit"] { position: absolute; visibility: hidden; } */
.header input { width: 6em; font-size: 80%; }
.header input[type="checkbox"] { width: 1em; }
http://stackoverflow.com/questions/5665203/getting-iphone-go-button-to-submit-form */
.header input[type="submit"] { position: absolute; visibility: hidden; }
.header input { width: 5em; font-size: 80%; }
.footer { clear:both; font-size: 90%; }
.content input { font-size: 80%; line-height: 125%; }
@@ -78,9 +175,9 @@ input#mail, input#homepage, input#username {
/* titles */
h1 {
font-weight: bold;
font-size: 150%;
padding: 1em 0;
font-weight: bold;
font-size: 150%;
padding: 1em 0;
}
h1 a:link, h1 a:visited {
color: inherit;
@@ -120,7 +217,7 @@ a:active {
border: 1px solid #9d8;
border-radius: 5px;
box-shadow: 0px 1px 3px white inset,
0px 1px 3px black;
0px 1px 3px black;
}
.button a {
text-decoration: none;
@@ -142,15 +239,15 @@ a.pencil { display: none; }
/* table of contents */
.toc {
font-size: smaller;
border-left: 1em solid #886;
font-size: smaller;
border-left: 1em solid #886;
}
.toc ol {
list-style-type: none;
padding-left: 1em;
list-style-type: none;
padding-left: 1em;
}
.toc a {
font-weight: normal;
font-weight: normal;
}
/* images with links, captions, etc */
@@ -206,28 +303,26 @@ div.message {
}
table.history { border-style:none; }
td.history { border-style:none; }
div.history span.dash + strong { font-weight: normal; }
span.result { font-size:larger; }
span.info { font-size:smaller; font-style:italic; }
div.rc hr { display: none; }
div.rc li { padding-bottom: 0.5em; }
div.rc li strong { font-weight: normal; }
/* Tables */
table.user {
margin: 1em 0;
padding: 0 1em;
border-top: 1px solid black;
border-bottom: 1px solid black;
margin: 1em 0;
padding: 0 1em;
border-top: 1px solid black;
border-bottom: 1px solid black;
}
div.aside table.user {
margin: 1em 0;
padding: 0;
margin: 1em 0;
padding: 0;
}
table.user td, table.user th {
border-style: none;
padding:5px 10px;
vertical-align: top;
border-style: none;
padding:5px 10px;
vertical-align: top;
}
table.user th { font-weight:bold; }
table.user td.r { text-align:right; }
@@ -238,7 +333,7 @@ table.user td.mark { background-color:yellow; }
tr:empty { display: block; height: 0.5em; }
@media print {
table {
font-size: 9pt;
font-size: 9pt;
margin: 0;
}
table.user td, table.user th {

View File

@@ -51,13 +51,13 @@ a.image:hover img {
}
/* a.definition soll aussehen wie h2 */
h2, p > a.definition {
h2, p a.definition {
display: block;
clear: both;
}
/* Such Link im h1 soll nicht auffallen. */
h1, h2, h3, h4, h1 a, h1 a:visited, p > a.definition {
h1, h2, h3, h4, h1 a, h1 a:visited, p a.definition {
color: #666;
font-size: 30pt;
font-weight: normal;
@@ -219,3 +219,50 @@ code {
background: #eee;
white-space: pre-wrap;
}
@font-face {
font-family: 'Gentium Basic';
font-style: normal;
font-weight: 700;
src: local('Gentium Basic Bold'), local('GentiumBasic-Bold'), url(/fonts/GenBasB.woff) format('woff');
}
@font-face {
font-family: 'Gentium Basic';
font-style: italic;
font-weight: 400;
src: local('Gentium Basic Italic'), local('GentiumBasic-Italic'), url(/fonts/GenBasI.woff) format('woff');
}
@font-face {
font-family: 'Gentium Basic';
font-style: italic;
font-weight: 700;
src: local('Gentium Basic Bold Italic'), local('GentiumBasic-BoldItalic'), url(/fonts/GenBasBI.woff) format('woff');
}
@font-face {
font-family: 'Gentium Basic';
font-style: normal;
font-weight: 400;
src: local('Gentium Basic'), local('GentiumBasic'), url(/fonts/GenBasR.woff) format('woff');
}
@font-face {
font-family: 'Gentium Plus';
font-style: normal;
font-weight: 400;
src: local('Gentium Plus'), local('GentiumPlus'), url(/fonts/GentiumPlus-R.woff) format('woff');
}
@font-face {
font-family: 'Gentium Plus';
font-style: italic;
font-weight: 400;
src: local('Gentium Plus Italic'), local('GentiumPlus-Italic'), url(/fonts/GentiumPlus-I.woff) format('woff');
}
@font-face {
font-family: 'Symbola';
src: local('Symbola'), url('/fonts/Symbola.woff') format('woff') url('/fonts/Symbola.ttf') format('truetype');
}

View File

@@ -3,7 +3,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -12,7 +12,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
package OddMuse;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;
@@ -33,7 +36,7 @@ sub AdminPowerDelete {
OpenPage($id);
my $status = DeletePage($id);
if ($status) {
print $q->p(GetPageLink($id) . ' ' . T('not deleted:') . ' ' . $status);
print $q->p(GetPageLink($id) . ' ' . T('not deleted: ')) . $status;
} else {
print $q->p(GetPageLink($id) . ' ' . T('deleted'));
WriteRcLog($id, Ts('Deleted %s', $id), 0, $Page{revision},
@@ -41,7 +44,7 @@ sub AdminPowerDelete {
GetCluster($Page{text}));
}
# Regenerate index on next request
Unlink($IndexFile);
unlink($IndexFile);
ReleaseLock();
print $q->p(T('Main lock released.'));
PrintFooter();
@@ -58,30 +61,30 @@ sub AdminPowerRename {
print $q->p(T('Main lock obtained.'));
# page file -- only check for existing or missing pages here
my $fname = GetPageFile($id);
ReportError(Ts('The page %s does not exist', $id), '400 BAD REQUEST') unless IsFile($fname);
ReportError(Ts('The page %s does not exist', $id), '400 BAD REQUEST') unless -f $fname;
my $newfname = GetPageFile($new);
ReportError(Ts('The page %s already exists', $new), '400 BAD REQUEST') if IsFile($newfname);
ReportError(Ts('The page %s already exists', $new), '400 BAD REQUEST') if -f $newfname;
# Regenerate index on next request -- remove this before errors can occur!
Unlink($IndexFile);
unlink($IndexFile);
# page file
CreateDir($PageDir); # It might not exist yet
Rename($fname, $newfname)
rename($fname, $newfname)
or ReportError(Tss('Cannot rename %1 to %2', $fname, $newfname) . ": $!", '500 INTERNAL SERVER ERROR');
# keep directory
my $kdir = GetKeepDir($id);
my $newkdir = GetKeepDir($new);
CreateDir($KeepDir); # It might not exist yet (only the parent directory!)
Rename($kdir, $newkdir)
rename($kdir, $newkdir)
or ReportError(Tss('Cannot rename %1 to %2', $kdir, $newkdir) . ": $!", '500 INTERNAL SERVER ERROR')
if IsDir($kdir);
if -d $kdir;
# refer file
if (defined(&GetRefererFile)) {
my $rdir = GetRefererFile($id);
my $newrdir = GetRefererFile($new);
CreateDir($RefererDir); # It might not exist yet
Rename($rdir, $newrdir)
rename($rdir, $newrdir)
or ReportError(Tss('Cannot rename %1 to %2', $rdir, $newrdir) . ": $!", '500 INTERNAL SERVER ERROR')
if IsDir($rdir);
if -d $rdir;
}
# RecentChanges
OpenPage($new);

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -29,7 +29,7 @@ $NewQuestion = 'Write your question here:';
sub IncrementInFile {
my $filename = shift;
sysopen my $fh, encode_utf8($filename), O_RDWR|O_CREAT or die "can't open $filename: $!";
sysopen my $fh, $filename, O_RDWR|O_CREAT or die "can't open $filename: $!";
flock $fh, LOCK_EX or die "can't flock $filename: $!";
my $num = <$fh> || 1;
seek $fh, 0, 0 or die "can't rewind $filename: $!";

View File

@@ -171,9 +171,9 @@ sub UserCanEditAutoLockFix {
return 0 if $id eq 'SampleUndefinedPage' or $id eq T('SampleUndefinedPage')
or $id eq 'Sample_Undefined_Page' or $id eq T('Sample_Undefined_Page');
return 1 if UserIsAdmin() || UserIsEditor();
return 0 if $id ne '' and IsFile(GetLockedPageFile($id));
return 0 if $LockOnCreation{$id} and not IsFile(GetPageFile($id)); # new page
return 0 if !$EditAllowed or IsFile($NoEditFile);
return 0 if $id ne '' and -f GetLockedPageFile($id);
return 0 if $LockOnCreation{$id} and not -f GetPageFile($id); # new page
return 0 if !$EditAllowed or -f $NoEditFile;
return 0 if $editing and UserIsBanned(); # this call is more expensive
return 0 if $EditAllowed >= 2 and (not $CommentsPrefix or $id !~ /^$CommentsPrefix/);
return 1 if $EditAllowed >= 3 and ($comment or (GetParam('aftertext', '') and not GetParam('text', '')));
@@ -206,17 +206,18 @@ except where noted.
Copyleft 2008 by B.w.Curry <http://www.raiazome.com>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This file is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this file; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
=cut

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
# Grab MLDBM at http://search.cpan.org/dist/MLDBM/lib/MLDBM.pm
# ie: http://search.cpan.org/CPAN/authors/id/C/CH/CHAMAS/MLDBM-2.01.tar.gz
@@ -41,8 +44,8 @@ sub BacklinksMenu {
$Action{buildback} = \&BuildBacklinkDatabase;
sub BuildBacklinkDatabase {
print GetHttpHeader('text/plain');
Unlink($backfile); # Remove old database
tie my %backhash, 'MLDBM', encode_utf8($backfile) or die "Cannot open file $backfile $!\n";
unlink $backfile; # Remove old database
tie my %backhash, 'MLDBM', $backfile or die "Cannot open file $backfile $!\n";
log1("Starting Database Store Process ... please wait\n\n");
foreach my $name (AllPagesList()) {
@@ -98,7 +101,7 @@ sub GetBackLink {
our ($BacklinkBanned);
$BacklinkBanned = "HomePage|ScratchPad" if !$BacklinkBanned;
tie my %backhash, 'MLDBM', encode_utf8($backfile), O_CREAT|O_RDWR, oct(644) or die "Cannot open file $backfile $!\n";
tie my %backhash, 'MLDBM', $backfile, O_CREAT|O_RDWR, oct(644) or die "Cannot open file $backfile $!\n";
# Search database for matches
while ( my ($source, $hashes) = each %backhash ) {
@@ -114,7 +117,7 @@ sub GetBackLink {
foreach my $backlink (@backlinks) {
my ($class, $resolved, $title, $exists) = ResolveId($backlink);
if (($resolved ne $id) && ($resolved !~ /^($BacklinkBanned)$/)) {
push(@unpopped, ScriptLink(UrlEncode($resolved), $resolved, $class . ' backlink', undef, Ts('Internal Page: %s', $resolved)));
push(@unpopped, ScriptLink(UrlEncode($resolved), $resolved, $class . ' backlink', undef, T('Internal Page: ' . $resolved)));
}
}

View File

@@ -1,4 +1,4 @@
# Copyright (C) 2013-2016 Alex Schroeder <alex@gnu.org>
# Copyright (C) 2013 Alex Schroeder <alex@gnu.org>
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
@@ -21,12 +21,11 @@ compared to the list of regular expressions on the C<BannedHosts> page
(see C<$BannedHosts>). If the contributor is already banned, this is
mentioned. If the contributor is not banned, you'll see a button
allowing you to ban him or her immediately. If you click the button,
the IP will be added to the C<BannedHosts> page for you.
the IP or hostname will be added to the C<BannedHosts> page for you.
=cut
use strict;
use v5.10;
our ($q, $Now, %Page, $OpenPageName, %Action, $UrlPattern, $BannedContent, $BannedHosts, @MyAdminCode);
AddModuleDescription('ban-contributors.pl', 'Ban Contributors Extension');
@@ -57,18 +56,17 @@ sub IsItBanned {
sub DoBanHosts {
my $id = shift;
my $content = GetParam('content', '');
my $range = GetParam('range', '');
my $regexp = GetParam('regexp', '');
my $host = GetParam('host', '');
if ($content) {
SetParam('text', GetPageContent($BannedContent)
. $content . " # " . CalcDay($Now) . " "
. NormalToFree($id) . "\n");
SetParam('summary', NormalToFree($id));
DoPost($BannedContent);
} elsif ($regexp) {
} elsif ($host) {
$host =~ s/\./\\./g;
SetParam('text', GetPageContent($BannedHosts)
. $regexp . " # " . CalcDay($Now)
. " $range "
. "^" . $host . " # " . CalcDay($Now) . " "
. NormalToFree($id) . "\n");
SetParam('summary', NormalToFree($id));
DoPost($BannedHosts);
@@ -96,14 +94,10 @@ sub DoBanHosts {
if (IsItBanned($_, \@regexps)) {
print $q->p(Ts("%s is banned", $name));
} else {
my ($start, $end) = BanContributors::get_range($_);
$range = "[$start - $end]";
$name .= " " . $range;
print GetFormStart(undef, 'get', 'ban'),
GetHiddenValue('action', 'ban'),
GetHiddenValue('id', $id),
GetHiddenValue('range', $range),
GetHiddenValue('regexp', BanContributors::get_regexp_ip($start, $end)),
GetHiddenValue('host', $_),
GetHiddenValue('recent_edit', 'on'),
$q->p($name, $q->submit(T('Ban!'))), $q->end_form();
}
@@ -159,100 +153,8 @@ sub NewBanContributorsWriteRcLog {
$q->submit(T('Ban!'))),
$q->end_form();
};
print $q->p(T("Consider banning the IP number as well:"), ' ',
print $q->p(T("Consider banning the IP number as well: "),
ScriptLink('action=ban;id=' . UrlEncode($id), T('Ban contributors')));
};
return OldBanContributorsWriteRcLog(@_);
}
package BanContributors;
use Net::Whois::Parser qw/parse_whois/;
sub get_range {
my $ip = shift;
my $response = parse_whois(domain => $ip);
my ($start, $end);
my $re = '(?:[0-9]{1,3}\.){3}[0-9]{1,3}';
my ($start, $end) = $response->{inetnum} =~ /($re) *- *($re)/;
return $start, $end;
}
sub get_groups {
my ($from, $to) = @_;
my @groups;
if ($from < 10) {
my $to = $to >= 10 ? 9 : $to;
push(@groups, [$from, $to]);
$from = $to + 1;
}
while ($from < $to) {
my $to = int($from/100) < int($to/100) ? $from + 99 - $from % 100 : $to;
if ($from % 10) {
push(@groups, [$from, $from + 9 - $from % 10]);
$from += 10 - $from % 10;
}
if (int($from/10) < int($to/10)) {
if ($to % 10 == 9) {
push(@groups, [$from, $to]);
$from = 1 + $to;
} else {
push(@groups, [$from, $to - 1 - $to % 10]);
$from = $to - $to % 10;
}
} else {
push(@groups, [$from - $from % 10, $to]);
last;
}
if ($to % 10 != 9) {
push(@groups, [$from, $to]);
$from = 1 + $to; # jump from 99 to 100
}
}
return \@groups;
}
sub get_regexp_range {
my @chars;
for my $group (@{get_groups(@_)}) {
my ($from, $to) = @$group;
my $char;
for (my $i = length($from); $i >= 1; $i--) {
if (substr($from, - $i, 1) eq substr($to, - $i, 1)) {
$char .= substr($from, - $i, 1);
} else {
$char .= '[' . substr($from, - $i, 1) . '-' . substr($to, - $i, 1). ']';
}
}
push(@chars, $char);
}
return join('|', @chars);
}
sub get_regexp_ip {
my ($from, $to) = @_;
my @start = split(/\./, $from);
my @end = split(/\./, $to);
my $regexp = "^";
for my $i (0 .. 3) {
if ($start[$i] eq $end[$i]) {
$regexp .= $start[$i];
} elsif ($start[$i] eq '0' and $end[$i] eq '255') {
last;
} elsif ($start[$i + 1] > 0) {
$regexp .= '(' . $start[$i] . '\.('
. get_regexp_range($start[$i + 1], '255') . ')|'
. get_regexp_range($start[$i] + 1, $end[$i + 1]) . ')';
$regexp .= '\.';
last;
} else {
$regexp .= '(' . get_regexp_range($start[$i], $end[$i]) . ')$';
last;
}
$regexp .= '\.' if $i < 3;
}
return $regexp;
}
# this is required in case we concatenate other modules to this one
package OddMuse;

View File

@@ -45,8 +45,7 @@ This extension works with logbannedcontent.pl.
=cut
our (%AdminPages, %LockOnCreation, @MyInitVariables, %PlainTextPages, $BannedContent, $BannedFile,
$FullUrlPattern);
our (%AdminPages, %LockOnCreation, @MyInitVariables, %PlainTextPages, $BannedContent, $BannedFile);
our ($BannedRegexps);
$BannedRegexps = 'BannedRegexps';
@@ -62,8 +61,6 @@ push(@MyInitVariables, sub {
sub RegexpNewBannedContent {
my $str = shift;
# remove URLs as they are controlled by $BannedContent
$str =~ s/$FullUrlPattern//g;
my $rule = RegexpOldBannedContent($str, @_);
if (not $rule) {
foreach (split(/\n/, GetPageContent($BannedRegexps))) {

View File

@@ -19,7 +19,7 @@ AddModuleDescription('bbcode.pl', 'bbCode Extension');
our ($q, @HtmlStack, @MyRules, %RuleOrder, $UrlProtocols, $FullUrlPattern);
push(@MyRules, \&bbCodeRule);
$RuleOrder{\&bbCodeRule} = 300; # must come after PortraitSupportRule, MarkdownRule
$RuleOrder{\&bbCodeRule} = 100; # must come after PortraitSupportRule
our ($bbBlock);
my %bbTitle = qw(h1 1 h2 1 h3 1 h4 1 h5 1 h6 1);

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -3,7 +3,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -12,7 +12,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;
@@ -23,7 +26,6 @@ our ($q, %Page, %Action, $Now, $OpenPageName, $CollectingJournal, $FreeLinkPatte
our ($CalendarOnEveryPage, $CalAsTable, $CalStartMonday);
$CalendarOnEveryPage = 0; # 1=on every page is a month-div situated in the header, use css to control
# 2=this month and the previous month; 3=this, previous and next month
$CalAsTable = 0; # 0=every month-div is "free", 1=every month-div is caught in a table, use css to control
$CalStartMonday = 0; # 0=week starts with Su, 1=week starts with Mo
@@ -35,22 +37,8 @@ sub NewCalendarGetHeader {
return $header unless $CalendarOnEveryPage;
my $action = GetParam('action', 'browse');
return $header if grep(/^$action$/, ('calendar', 'edit'));
my $cal;
my ($sec, $min, $hour, $mday, $mon, $year) = localtime($Now);
$year += 1900;
# $mon is 0 based and thus good for previous month
if ($mon < 1) { $year -= 1; $mon += 12; };
$cal .= Cal($year, $mon) if $CalendarOnEveryPage > 1;
# the current month
$mon += 1;
if ($mon > 12) { $year += 1; $mon -= 12; };
$cal .= Cal($year, $mon) if $CalendarOnEveryPage;
# the next month
$mon += 1;
if ($mon > 12) { $year += 1; $mon -= 12; };
$cal .= Cal($year, $mon) if $CalendarOnEveryPage > 2;
# insert calendars before header div
$header =~ s!<div class="header">!<div class="cal">$cal</div><div class="header">!;
my $cal = Cal();
$header =~ s/<div class="header">/$cal<div class="header">/;
return $header;
}
@@ -100,7 +88,7 @@ sub Cal {
$year_text, 'local collection year'));
}
}}e;
return "<div class=\"month\"><pre>$cal</pre></div>";
return "<div class=\"cal month\"><pre>$cal</pre></div>";
}
$Action{collect} = \&DoCollect;
@@ -141,7 +129,7 @@ sub CalendarRule {
my $oldpos = pos;
Clean(CloseHtmlEnvironments());
Dirty($1);
print $q->div({-class => 'cal'}, Cal($2, $3));
print Cal($2, $3);
pos = $oldpos;
return AddHtmlEnvironment('p');
} elsif (/\G(month:([+-]\d\d?))/cg
@@ -156,7 +144,7 @@ sub CalendarRule {
$mon += 1 + $delta;
while ($mon < 1) { $year -= 1; $mon += 12; };
while ($mon > 12) { $year += 1; $mon -= 12; };
print $q->div({-class => 'cal'}, Cal($year, $mon, undef, $id));
print Cal($year, $mon, undef, $id);
pos = $oldpos;
return AddHtmlEnvironment('p');
}

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,8 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;
use utf8;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;
@@ -56,8 +59,8 @@ sub NewCommentcountScriptLink {
$num = $1;
}
# Fix plurals
my $plural = T('Comments on');
my $singular = T('Comment on');
my $plural = T('Comments on ');
my $singular = T('Comment on ');
$text =~ s/$plural/$singular/ if($num == 1);
$text = $num . ' ' . $text;
}

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,

View File

@@ -1,35 +1,34 @@
# Copyright (C) 2005 Fletcher T. Penney <fletcher@freeshell.org>
# Copyright (C) 2016 Alex Schroeder <alex@gnu.org>
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation; either version 3 of the License, or (at your option) any later
# version.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
=head1 Creation Date Extension
This module stores additional information about a page when it is first created:
=over
=item C<created> is the date the page is first saved
=item C<originalAuthor> is the username that first created a page
=back
=cut
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
#
# This module stores additional information about a page when it is
# first created:
# created = the date the page is FIRST saved
# originalAuthor = the username that first created a page
#
# Of course, you can customize this to store more information
use strict;
use v5.10;
AddModuleDescription('creationdate.pl', 'CreationDate Module');
our (%Page, $Now, @MyAdminCode, %Action, $q, $FS, $RcOldFile, $RcFile);
our (%Page, $Now);
*CreationDateOldOpenPage = \&OpenPage;
*OpenPage = \&CreationDateOpenPage;
@@ -40,45 +39,3 @@ sub CreationDateOpenPage{
$Page{originalAuthor} = GetParam('username','') unless $Page{originalAuthor}
or $Page{revision};
}
# Allow administrators to add the 'created' item to page files, based on rc log
# files.
push(@MyAdminCode, \&CreationDateMenu);
sub CreationDateMenu {
my ($id, $menuref, $restref) = @_;
push(@$menuref,
ScriptLink('action=add-creation-date',
T('Add creation date to page files'),
'creationdate')) if UserIsAdmin();
}
$Action{'add-creation-date'} = \&AddCreationDate;
sub AddCreationDate {
print GetHeader('', T('Add creation date to page files'));
print $q->start_div({-class=>'creationdate'});
print '<ul>';
RequestLockOrError();
for my $file ($RcOldFile, $RcFile) {
open(my $F, '<:encoding(UTF-8)', encode_utf8($file)) or next;
while (my $line = <$F>) {
chomp($line);
my ($ts, $id, $minor, $summary, $host, $username, $revision)
= split(/$FS/, $line);
next unless $revision == 1;
print $q->li(NormalToFree($id));
OpenPage($id);
next unless $Page{revision}; # skip if page no longer exists
next if $Page{created} and $Page{originalAuthor};
$Page{created} = $ts unless $Page{created};
$Page{originalAuthor} = $username unless $Page{originalAuthor};
SavePage();
}
}
ReleaseLock();
print '</ul>';
print $q->end_div();
PrintFooter();
}

View File

@@ -405,7 +405,8 @@ sub CreoleRule {
if ($is_left_justified and
$is_right_justified) { $attributes .= 'align="center"' }
elsif ($is_right_justified) { $attributes .= 'align="right"' }
elsif ($is_left_justified) { $attributes .= 'align="left"' }
# this is the default:
# elsif ($is_left_justified) { $attributes .= 'align="left"' }
return
(InElement('td') || InElement('th') ? CloseHtmlEnvironmentUntil('tr') : '')

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -77,7 +77,8 @@ sub DoUnifiedDiff { # copied from DoDiff
RequestLockDir('diff') or return '';
WriteStringToFile($oldName, $_[0]);
WriteStringToFile($newName, $_[1]);
my $diff_out = decode_utf8(`diff -U 99999 -- \Q$oldName\E \Q$newName\E | tail -n +7`); # should be +4, but we always add extra line # TODO that workaround is ugly, fix it!
my $diff_out = `diff -U 99999 -- \Q$oldName\E \Q$newName\E | tail -n +7`; # should be +4, but we always add extra line # TODO that workaround is ugly, fix it!
utf8::decode($diff_out); # needs decoding
$diff_out =~ s/\n\K\\ No newline.*\n//g; # Get rid of common complaint.
ReleaseLockDir('diff');
# No need to unlink temp files--next diff will just overwrite.

View File

@@ -1,49 +0,0 @@
#! /usr/bin/perl
# Copyright (C) 20152017 Alex Schroeder <alex@gnu.org>
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
use strict;
use v5.10;
AddModuleDescription('ditaa.pl', 'Ditaa for Diagrams');
our ($q, $bol, @MyRules, @KnownLocks, $TempDir);
push (@MyRules, \&DitaaRule);
push(@KnownLocks, 'diagram');
sub DitaaRule {
if ($bol && m/\G&lt;diagram(\s+style=".*")?&gt;\n((.*\n)+)&lt;\/diagram&gt;/cg) {
return "MIME::Base64 not installed" unless eval { require MIME::Base64; };
my $style = $1;
my $map = UnquoteHtml($2);
RequestLockDir('diagram', undef, undef, 1);
WriteStringToFile("$TempDir/diagram.txt", $map);
$ENV{LANG}='en_US.UTF-8'; # Java needs Locale to match as well!
my $output = `ditaa "$TempDir/diagram.txt" "$TempDir/diagram.png"`;
my $image = '';
# not UTF-8 layer!
if (open(IN, '<', "$TempDir/diagram.png")) {
local $/ = undef; # Read complete files
$image = <IN>;
close IN;
}
ReleaseLockDir('diagram');
my $data = MIME::Base64::encode_base64($image);
my $url = "data:image/png;base64,$data";
return CloseHtmlEnvironments()
. "<div$style>" . $q->img({-src=>$url, -alt=>$map}) . "</div>";
}
return undef;
}

View File

@@ -3,7 +3,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -12,7 +12,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
# This module offers the user the additional possibility to
# edit a page by double-clicking on it. The user must have

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -29,7 +29,7 @@ push(@MyInitVariables, \&DraftInit);
sub DraftInit {
if (GetParam('Draft', '')) {
SetParam('action', 'draft') ; # Draft button used
} elsif (IsFile("$DraftDir/" . GetParam('username', $q->remote_addr())) # draft exists
} elsif (-f "$DraftDir/" . GetParam('username', $q->remote_addr()) # draft exists
and $FooterNote !~ /action=draft/) { # take care of mod_perl persistence
$FooterNote = $q->p(ScriptLink('action=draft', T('Recover Draft'))) . $FooterNote;
}
@@ -47,9 +47,9 @@ sub DoDraft {
WriteStringToFile($draft, EncodePage(text=>$text, id=>$id));
SetParam('msg', T('Draft saved')); # invalidate cache
print GetHttpHeader('', T('Draft saved'), '204 NO CONTENT');
} elsif (IsFile($draft)) {
} elsif (-f $draft) {
my $data = ParseData(ReadFileOrDie($draft));
Unlink($draft);
unlink ($draft);
$Message .= $q->p(T('Draft recovered'));
DoEdit($data->{id}, $data->{text}, 1);
} else {
@@ -76,19 +76,22 @@ push(@MyMaintenance, \&DraftCleanup);
sub DraftFiles {
return map {
substr($_, length($DraftDir) + 1);
} Glob("$DraftDir/*"), Glob("$DraftDir/.*");
my $x = $_;
$x = substr($x, length($DraftDir) + 1);
utf8::decode($x);
$x;
} bsd_glob("$DraftDir/*"), bsd_glob("$DraftDir/.*");
}
sub DraftCleanup {
print '<p>' . T('Draft Cleanup');
foreach my $draft (DraftFiles()) {
next if $draft eq '.' or $draft eq '..';
my $ts = Modified("$DraftDir/$draft");
my $ts = (stat("$DraftDir/$draft"))[9];
if ($Now - $ts < 1209600) { # 14*24*60*60
print $q->br(), Tss("%1 was last modified %2 and was kept",
$draft, CalcTimeSince($Now - $ts));
} elsif (Unlink("$DraftDir/$draft")) {
} elsif (unlink("$DraftDir/$draft")) {
print $q->br(), Tss("%1 was last modified %2 and was deleted",
$draft, CalcTimeSince($Now - $ts));
} else {

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
# Makes the wiki logo depend on the current date.
#

View File

@@ -1,6 +1,6 @@
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -9,7 +9,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -18,7 +18,7 @@ use v5.10;
AddModuleDescription('edit-cluster.pl', 'Edit Cluster Extension');
our ($q, $FS, $RcDefault, @RcDays, $RecentTop, $LastUpdate, $ShowAll);
our ($q, $FS, $RcDefault, @RcDays, $RecentTop, $LastUpdate);
our $EditCluster = 'EditCluster';
@@ -34,7 +34,7 @@ sub GetRc {
$changetime{$pagename} = $ts;
}
my $date = '';
my $all = GetParam('all', $ShowAll);
my $all = GetParam('all', 0);
my ($idOnly, $userOnly, $hostOnly, $clusterOnly, $filterOnly, $match, $lang) =
map { GetParam($_, ''); }
('rcidonly', 'rcuseronly', 'rchostonly', 'rcclusteronly',
@@ -128,7 +128,7 @@ sub EditClusterNewRcHeader {
$action = "action=rc$action";
}
my $days = GetParam('days', $RcDefault);
my $all = GetParam('all', $ShowAll);
my $all = GetParam('all', 0);
my @menu;
if ($all) {
push(@menu, ScriptLink("$action;days=$days;all=0",

View File

@@ -3,7 +3,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -12,7 +12,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
# This module creates a list of all questions on the page, e.g.
# for a faq. It does so by recognizing all lines that begin with

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA,
use strict;
use v5.10;

View File

@@ -27,7 +27,8 @@ sub FixEncoding {
ValidIdOrDie($id);
RequestLockOrError();
OpenPage($id);
my $text = decode_utf8($Page{text});
my $text = $Page{text};
utf8::decode($text);
Save($id, $text, T('Fix character encoding'), 1) if $text ne $Page{text};
ReleaseLock();
ReBrowsePage($id);

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -12,8 +12,8 @@ our ($q, $OpenPageName, @MyRules, $CrossbarPageName);
push(@MyRules, \&FormsRule);
sub FormsRule {
if (IsFile(GetLockedPageFile($OpenPageName)) or (InElement('div', '^class="crossbar"$') and
IsFile(GetLockedPageFile($CrossbarPageName)))) {
if (-f GetLockedPageFile($OpenPageName) or (InElement('div', '^class="crossbar"$') and
-f GetLockedPageFile($CrossbarPageName))) {
if (/\G(\&lt;form.*?\&lt;\/form\&gt;)/cgs) {
my $form = $1;
my $oldpos = pos;

View File

@@ -163,7 +163,8 @@ sub GdSecurityImageGenerate {
my ($imgData) = $img->out(force => 'png');
my $ticketId = Digest::MD5::md5_hex(rand());
CreateDir($GdSecurityImageDir);
open my $fh, ">:raw", encode_utf8(GdSecurityImageGetImageFile($ticketId))
my $file = GdSecurityImageGetImageFile($ticketId);
open my $fh, ">:raw", $file
or ReportError(Ts('Image storing failed. (%s)', $!), '500 INTERNAL SERVER ERROR');
print $fh $imgData;
#print $fh $png; ### experimental ###
@@ -186,7 +187,9 @@ sub GdSecurityImageIsValidId {
}
sub GdSecurityImageReadImageFile {
if (open(my $IN, '<:raw', encode_utf8(shift))) {
my $file = shift;
utf8::encode($file); # filenames are bytes!
if (open(my $IN, '<:raw', $file)) {
local $/ = undef; # Read complete files
my $data=<$IN>;
close $IN;
@@ -208,7 +211,7 @@ sub GdSecurityImageDoImage {
print $q->header(-type=>'image/png');
print $data;
Unlink(GdSecurityImageGetImageFile($id));
unlink(GdSecurityImageGetImageFile($id));
}
sub GdSecurityImageCleanup {
@@ -216,10 +219,10 @@ sub GdSecurityImageCleanup {
if (!GdSecurityImageIsValidId($id)) {
return;
}
my @files = (Glob("$GdSecurityImageDir/*.png"), Glob("$GdSecurityImageDir/*.ticket"));
my @files = (bsd_glob("$GdSecurityImageDir/*.png"), bsd_glob("$GdSecurityImageDir/*.ticket"));
foreach my $file (@files) {
if ($Now - Modified($file) > $GdSecurityImageDuration) {
Unlink($file);
if ($Now - (stat $file)[9] > $GdSecurityImageDuration) {
unlink($file);
}
}
}
@@ -252,7 +255,7 @@ sub GdSecurityImageCheck {
}
if (GdSecurityImageIsValidId($id)) {
Unlink(GdSecurityImageGetTicketFile($id));
unlink(GdSecurityImageGetTicketFile($id));
}
$GdSecurityImageId = GdSecurityImageGenerate();

View File

@@ -30,18 +30,18 @@ $GitMail = 'unknown@oddmuse.org';
sub GitCommit {
my ($message, $author) = @_;
my $oldDir = cwd;
ChangeDir("$DataDir/page");
chdir("$DataDir/page");
capture {
system($GitBinary, qw(add -A));
system($GitBinary, qw(commit -q -m), $message, "--author=$author <$GitMail>");
};
ChangeDir($oldDir);
chdir($oldDir);
}
sub GitInitRepository {
return if IsDir("$DataDir/page/.git");
return if -d "$DataDir/page/.git";
capture {
system($GitBinary, qw(init -q --), encode_utf8("$DataDir/page"));
system($GitBinary, qw(init -q --), "$DataDir/page");
};
GitCommit('Initial import', 'Oddmuse');
}

View File

@@ -80,7 +80,7 @@ sub GitRun {
my $exitStatus;
# warn join(' ', $GitBinary, @_) . "\n";
ChangeDir($GitRepo);
chdir($GitRepo);
if ($GitDebug) {
# TODO use ToString here
# capture the output of the git comand in a temporary file
@@ -99,7 +99,7 @@ sub GitRun {
} else {
$exitStatus = system($GitBinary, @_);
}
ChangeDir($oldDir);
chdir($oldDir);
return $exitStatus;
}
@@ -108,7 +108,7 @@ sub GitInitVariables {
}
sub GitInitRepository {
return if IsDir("$GitRepo/.git");
return if -d "$GitRepo/.git";
my $exception = shift;
CreateDir($GitRepo);
GitRun(qw(init --quiet));
@@ -187,16 +187,17 @@ sub DoGitCleanup {
}
sub GitCleanup {
if (IsDir($GitRepo)) {
if (-d $GitRepo) {
print $q->p('Git cleanup starting');
AllPagesList();
# delete all the files including all the files starting with a dot
opendir(DIR, encode_utf8($GitRepo)) or ReportError("cannot open directory $GitRepo: $!");
opendir(DIR, $GitRepo) or ReportError("cannot open directory $GitRepo: $!");
foreach my $file (readdir(DIR)) {
my $name = decode_utf8($file);
my $name = $file;
utf8::decode($name); # filenames are bytes
next if $file eq '.git' or $file eq '.' or $file eq '..' or $IndexHash{$name};
print $q->p("Deleting left over file $name");
Unlink("$GitRepo/$file") or print $q->p("Cannot delete $GitRepo/$name: $!");
unlink "$GitRepo/$file" or ReportError("cannot delete $GitRepo/$name: $!");
}
closedir DIR;
# write all the files again, just to be sure

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -1,5 +1,4 @@
# Copyright (C) 2006-2014 Alex Schroeder <alex@gnu.org>
# Copyright (C) 2016 Ingo Belka
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
@@ -26,9 +25,6 @@ our ($GotobarName);
$GotobarName = 'GotoBar';
our ($GotobarSetHome, $GotobarSetRC);
# 0 does set home-link and/or rc-link automatically, 1 doesn't
# do this later so that the user can customize $GotobarName
push(@MyInitVariables, \&GotobarInit);
@@ -57,10 +53,10 @@ sub GotobarInit {
# is the list of recent changes.
$count++;
if ($count == 1) {
unless ($GotobarSetHome) {$HomePage = FreeToNormal($page)};
} elsif ($count == 2) {
unless ($GotobarSetRC) {$RCName = FreeToNormal($page);}
}
$HomePage = FreeToNormal($page);
} elsif ($count == 2) {
$RCName = FreeToNormal($page);
}
}
}
}

View File

@@ -53,7 +53,7 @@ sub GravatarFormAddition {
return $html unless $type eq 'comment';
my $addition = $q->span({-class=>'mail'},
$q->label({-for=>'mail'}, T('Email:') . ' ')
$q->label({-for=>'mail'}, T('Email: '))
. ' ' . $q->textfield(-name=>'mail', -id=>'mail',
-default=>GetParam('mail', '')));
$html =~ s!(name="homepage".*?)</p>!$1 $addition</p>!i;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;
@@ -40,7 +43,7 @@ sub HtmlTemplate {
my $type = shift;
# return header.de.html, or header.html, or error.html, or report an error...
foreach my $f ((map { "$type.$_" } HtmlTemplateLanguage()), $type, "error") {
return "$HtmlTemplateDir/$f.html" if IsFile("$HtmlTemplateDir/$f.html");
return "$HtmlTemplateDir/$f.html" if -r "$HtmlTemplateDir/$f.html";
}
ReportError(Tss('Could not find %1.html template in %2', $type, $HtmlTemplateDir),
'500 INTERNAL SERVER ERROR');

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -3,7 +3,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -12,7 +12,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -5,7 +5,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -14,7 +14,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
# This module offers the possibility to restrict viewing of "hidden"
# pages to only editors or admins. The restriction may be based

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;
@@ -84,7 +87,7 @@ sub GetActionHtmlTemplate {
my $action = GetParam('action', 'browse');
# return browse.de.html, or browse.html, or error.html, or report an error...
foreach my $f ((map { "$action.$_" } HtmlTemplateLanguage()), $action, "error") {
return "$HtmlTemplateDir/$f.html" if IsFile("$HtmlTemplateDir/$f.html");
return "$HtmlTemplateDir/$f.html" if -r "$HtmlTemplateDir/$f.html";
}
ReportError(Tss('Could not find %1.html template in %2', $action, $HtmlTemplateDir),
'500 INTERNAL SERVER ERROR');

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;
@@ -28,7 +31,7 @@ push(@MyRules, \&HtmlLinksRule);
$RuleOrder{\&HtmlLinksRule} = 105;
sub HtmlLinksRule {
if (IsFile(GetLockedPageFile($OpenPageName))) {
if (-f GetLockedPageFile($OpenPageName)) {
$HtmlLinks = 1;
} else {
$HtmlLinks = 0;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -32,7 +32,7 @@ sub DivFooRule {
my $str = $1;
CreateDir($ImagifyDir);
my $fileName = sha256_hex($str) . '.' . $ImagifyFormat;
system('convert', %ImagifyParams, "caption:$str", "$ImagifyDir/$fileName") unless IsFile("$ImagifyDir/$fileName");
system('convert', %ImagifyParams, "caption:$str", "$ImagifyDir/$fileName") unless -e "$ImagifyDir/$fileName";
my $src = $ScriptName . "/imagify/" . UrlEncode($fileName);
return CloseHtmlEnvironments() . $q->img({-class => 'imagify', -src => $src, -alt => '(rendered text)'}) . AddHtmlEnvironment('p');
}

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -214,7 +214,7 @@ sub JoinerSendRegistrationConfirmationEmail {
print $EMAIL "From: $JoinerEmailSenderAddress\n";
print $EMAIL "Subject: $SiteName " . T('Registration Confirmation') . "\n";
print $EMAIL "\n";
print $EMAIL T('Visit the link below to confirm registration.') . "\n";
print $EMAIL T('Visit the link blow to confirm registration.') . "\n";
print $EMAIL "\n";
print $EMAIL "$link\n";
print $EMAIL "\n";

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
# In your CSS file, use something like this, for example:

View File

@@ -131,8 +131,8 @@ sub MakeLaTeX {
# Select which binary to use for conversion of dvi to images
my $useConvert = 0;
if (not IsFile($dvipngPath)) {
if (not IsFile($convertPath)) {
if (not -e $dvipngPath) {
if (not -e $convertPath) {
return "[Error: dvipng binary and convert binary not found at $dvipngPath or $convertPath ]";
}
else {
@@ -155,13 +155,13 @@ sub MakeLaTeX {
}
# check cache
if (not IsFile("$LatexDir/$hash.png") or ZeroSize("$LatexDir/$hash.png")) {
if (not -f "$LatexDir/$hash.png" or -z "$LatexDir/$hash.png") { #If file doesn't exist or is zero bytes
# Then create the image
# read template and replace <math>
CreateDir($LatexDir);
if (not IsFile($LatexDefaultTemplateName)) {
open (my $F, '>', encode_utf8($LatexDefaultTemplateName)) or return '[Unable to write template]';
mkdir($LatexDir) unless -d $LatexDir;
if (not -f $LatexDefaultTemplateName) {
open (my $F, '>', $LatexDefaultTemplateName) or return '[Unable to write template]';
print $F $LatexDefaultTemplate;
close $F;
}
@@ -169,12 +169,12 @@ sub MakeLaTeX {
$template =~ s/<math>/$latex/gi;
#setup rendering directory
my $dir = "$LatexDir/$hash";
if (IsDir($dir)) {
Unlink((Glob("$dir/*")));
if (-d $dir) {
unlink (bsd_glob('$dir/*'));
} else {
CreateDir($dir);
mkdir($dir) or return "[Unable to create $dir]";
}
ChangeDir($dir) or return "[Unable to switch to $dir]";
chdir ($dir) or return "[Unable to switch to $dir]";
WriteStringToFile ("srender.tex", $template);
my $errorText = qx(latex srender.tex);
@@ -197,16 +197,16 @@ sub MakeLaTeX {
$error = "[dvipng error $? ($output)]" if $?;
}
if (not $error and IsFile('srender1.png') and not ZeroSize('srender1.png')) {
if (not $error and -f 'srender1.png' and not -z 'srender1.png') {
my $png = ReadFileOrDie("srender1.png");
WriteStringToFile ("$LatexDir/$hash.png", $png);
} else {
$error = "[Error retrieving image for $latex]";
}
}
Unlink(glob('*'));
ChangeDir($LatexDir);
RemoveDir($dir);
unlink (glob('*'));
chdir ($LatexDir);
rmdir ($dir);
return $error if $error;
}

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,8 +11,13 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
#
# Based on code of tagmap.pl module by Fletcher T. Penney
# and searchtags.pl module by Brock Wilcox
use strict;
use v5.10;

View File

@@ -38,7 +38,7 @@ sub DoListLocked {
print $q->start_div({-class=>'content list locked'}), $q->start_p();
}
foreach my $id (AllPagesList()) {
PrintPage($id) if IsFile(GetLockedPageFile($id));
PrintPage($id) if -f GetLockedPageFile($id);
}
if (not $raw) {
print $q->end_p(), $q->end_div();

View File

@@ -2,7 +2,7 @@
# Copyright (C) 2008 Weakish Jiang <weakish@gmail.com>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -29,7 +29,6 @@ our %TranslationsLibrary = (
'bg' => 'bulgarian-utf8.pl',
'ca' => 'catalan-utf8.pl',
'de' => 'german-utf8.pl',
'et' => 'estonian-utf8.pl',
'es' => 'spanish-utf8.pl',
'fi' => 'finnish-utf8.pl',
'fr' => 'french-utf8.pl',
@@ -73,11 +72,10 @@ sub LoadLanguage {
foreach (@prefs) {
last if $Lang{$_} eq 'en'; # the default
my $file = $TranslationsLibrary{$Lang{$_}};
next unless $file; # file is not listed, eg. there is no file for "de-ch"
$file = "$LoadLanguageDir/$file" if defined $LoadLanguageDir;
if (IsFile($file)) {
if (-r $file) {
do $file;
do "$ConfigFile-$Lang{$_}" if IsFile("$ConfigFile-$Lang{$_}");
do "$ConfigFile-$Lang{$_}" if -r "$ConfigFile-$Lang{$_}";
$CurrentLanguage = $Lang{$_};
last;
}

View File

@@ -64,9 +64,9 @@ You can change this expiry time by setting C<$LnCacheHours>.
push (@MyMaintenance, \&LnMaintenance);
sub LnMaintenance {
if (opendir(DIR, encode_utf8($RssDir))) { # cleanup if they should expire anyway
foreach my $file (readdir(DIR)) {
Unlink("$RssDir/$file") if $Now - Modified($file) > $LnCacheHours * 3600;
if (opendir(DIR, $RssDir)) { # cleanup if they should expire anyway
foreach (readdir(DIR)) {
unlink "$RssDir/$_" if $Now - (stat($_))[9] > $LnCacheHours * 3600;
}
closedir DIR;
}
@@ -157,7 +157,7 @@ sub LocalNamesInit {
my %data = ();
if (GetParam('cache', $UseCache) > 0) {
foreach my $uri (keys %todo) { # read cached rss files if possible
if ($Now - Modified($todo{$uri}) < $LnCacheHours * 3600) {
if ($Now - (stat($todo{$uri}))[9] < $LnCacheHours * 3600) {
$data{$uri} = ReadFile($todo{$uri});
delete($todo{$uri}); # no need to fetch them below
}
@@ -396,10 +396,10 @@ sub DoDefine {
$q->start_div({-class=>'content define'}),
GetFormStart(undef, 'get', 'def');
my $go = T('Go!');
print $q->p($q->label({-for=>"defined"}, T('Name:') . ' '),
print $q->p($q->label({-for=>"defined"}, T('Name: ')),
$q->textfield(-name=>"name", -id=>"defined",
-tabindex=>"1", -size=>20));
print $q->p($q->label({-for=>"definition"}, T('URL:') . ' '),
print $q->p($q->label({-for=>"definition"}, T('URL: ')),
$q->textfield(-name=>"link", -id=>"definition",
-tabindex=>"2", -size=>20));
print $q->p($q->submit(-label=>$go, -tabindex=>"3"),
@@ -446,7 +446,7 @@ sub GetWantedPages {
# if any wanted pages remain, print them
if (@wanted) {
return $q->div({-class=>'definition'},
$q->p(T('Define external redirect:'), ' ',
$q->p(T('Define external redirect: '),
map { my $page = NormalToFree($_);
ScriptLink('action=define;name='
. UrlEncode($page),

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;
@@ -19,7 +22,7 @@ use v5.10;
AddModuleDescription('login.pl', 'Login Module');
our ($q, %Action, $SiteName, @MyAdminCode, $IndexFile, $DataDir, $FullUrl);
our ($RegistrationForm, $MinimumPasswordLength, $RegistrationsMustBeApproved, $LoginForm, $PasswordFile, $PasswordFileToUse, $PendingPasswordFile, $RequireLoginToEdit, $ConfirmEmailAddress, $UnconfirmedPasswordFile, $EmailSenderAddress, $EmailCommand, $EmailRegExp, $NotifyPendingRegistrations, $EmailConfirmationMessage, $ResetPasswordMessage, $LogoutForm, $ResetForm, $ChangePassForm, $RequireCamelUserName, $UsernameRegExp);
our ($RegistrationForm, $MinimumPasswordLength, $RegistrationsMustBeApproved, $LoginForm, $PasswordFile, $PasswordFileToUse, $PendingPasswordFile, $RequireLoginToEdit, $ConfirmEmailAddress, $UncomfirmedPasswordFile, $EmailSenderAddress, $EmailCommand, $EmailRegExp, $NotifyPendingRegistrations, $EmailConfirmationMessage, $ResetPasswordMessage, $LogoutForm, $ResetForm, $ChangePassForm, $RequireCamelUserName, $UsernameRegExp);
my $EncryptedPassword = "";
@@ -37,7 +40,7 @@ $RegistrationsMustBeApproved = 1 unless defined $RegistrationsMustBeApproved;
$PendingPasswordFile = "$DataDir/pending" unless defined $PendingPasswordFile;
$ConfirmEmailAddress = 1 unless defined $ConfirmEmailAddress;
$UnconfirmedPasswordFile = "$DataDir/uncomfirmed" unless defined $UnconfirmedPasswordFile;
$UncomfirmedPasswordFile = "$DataDir/uncomfirmed" unless defined $UncomfirmedPasswordFile;
$EmailSenderAddress = "fletcher\@freeshell.org" unless defined $EmailSenderAddress;
$EmailCommand = "/usr/sbin/sendmail -oi -t" unless defined $EmailCommand;
@@ -68,7 +71,7 @@ $PasswordFileToUse = $RegistrationsMustBeApproved
? $PendingPasswordFile : $PasswordFile;
$PasswordFileToUse = $ConfirmEmailAddress
? $UnconfirmedPasswordFile : $PasswordFileToUse;
? $UncomfirmedPasswordFile : $PasswordFileToUse;
$RegistrationForm = <<'EOT' unless defined $RegistrationForm;
<p>Your Username should be a CamelCase form of your real name, e.g. JohnDoe.</p>
@@ -287,7 +290,7 @@ sub DoProcessLogin {
ReportError(T('Username and/or password are incorrect.'))
unless (AuthenticateUser($username,$pwd));
Unlink($IndexFile);
unlink($IndexFile);
print GetHeader('', Ts('Register for %s', $SiteName), '');
print '<div class="content">';
print Ts('Logged in as %s.', $username);
@@ -315,7 +318,7 @@ $Action{process_logout} = \&DoProcessLogout;
sub DoProcessLogout {
SetParam('pwd','');
SetParam('username','');
Unlink($IndexFile); # I shouldn't have to do this...
unlink($IndexFile); # I shouldn't have to do this...
print GetHeader('', Ts('Logged out of %s', $SiteName), '');
print '<div class="content">';
print T('You are now logged out.');
@@ -325,7 +328,7 @@ sub DoProcessLogout {
sub UserExists {
my $username = shift;
if (open (my $PASSWD, '<', encode_utf8($PasswordFile))) {
if (open (my $PASSWD, '<', $PasswordFile)) {
while ( <$PASSWD> ) {
if ($_ =~ /^$username:/) {
return 1;
@@ -335,7 +338,7 @@ sub UserExists {
}
if ($RegistrationsMustBeApproved) {
if (open (my $PASSWD, '<', encode_utf8($PendingPasswordFile))) {
if (open (my $PASSWD, '<', $PendingPasswordFile)) {
while ( <$PASSWD> ) {
if ($_ =~ /^$username:/) {
return 1;
@@ -346,7 +349,7 @@ sub UserExists {
}
if ($ConfirmEmailAddress) {
if (open (my $PASSWD, '<', encode_utf8($UnconfirmedPasswordFile))) {
if (open (my $PASSWD, '<', $UncomfirmedPasswordFile)) {
while ( <$PASSWD> ) {
if ($_ =~ /^$username:/) {
return 1;
@@ -487,13 +490,14 @@ sub ConfirmUser {
my ($username, $key) = @_;
my $FileToUse = $RegistrationsMustBeApproved
? $PendingPasswordFile : $PasswordFileToUse;
if (open(my $PASSWD, '<', encode_utf8($UnconfirmedPasswordFile))) {
if (open(my $PASSWD, '<', $UncomfirmedPasswordFile)) {
while (<$PASSWD>) {
if ($_ =~ /^$username:(.*):(.*)/) {
if (crypt($1,$key) eq $key) {
AddUser($username,$1,$2,$FileToUse);
close $PASSWD;
RemoveUser($username,$UnconfirmedPasswordFile);
RemoveUser($username,$UncomfirmedPasswordFile);
if ($RegistrationsMustBeApproved) {
SendNotification($username);
}
@@ -511,7 +515,8 @@ sub RemoveUser {
my %passwords = ();
my %emails = ();
if (open (my $PASSWD, '<', encode_utf8($FileToUse))) {
if (open (my $PASSWD, '<', $FileToUse)) {
while ( <$PASSWD> ) {
if ($_ =~ /^(.*):(.*):(.*)$/) {
next if ($1 eq $username);
@@ -594,7 +599,8 @@ sub ChangePassword {
my %passwords = ();
my %emails = ();
if (open (my $PASSWD, '<', encode_utf8($PasswordFile))) {
if (open (my $PASSWD, '<', $PasswordFile)) {
while ( <$PASSWD> ) {
if ($_ =~ /^(.*):(.*):(.*)$/) {
$passwords{$1}=$2;
@@ -606,7 +612,7 @@ sub ChangePassword {
$passwords{$user} = $hash;
open (my $PASSWD, '>', encode_utf8($PasswordFile));
open (my $PASSWD, '>', $PasswordFile);
foreach my $key ( sort keys(%passwords)) {
print $PASSWD "$key:$passwords{$key}:$emails{$key}\n";
}
@@ -713,7 +719,7 @@ sub DoApprovePending {
}
} else {
print '<ul>';
if (open(my $PASSWD, '<', encode_utf8($PendingPasswordFile))) {
if (open(my $PASSWD, '<', $PendingPasswordFile)) {
while (<$PASSWD>) {
if ($_ =~ /^(.*):(.*):(.*)$/) {
print '<li>' . ScriptLink("action=approve_pending;user=$1;",$1) . ' - ' . $3 . '</li>';
@@ -734,7 +740,8 @@ sub DoApprovePending {
sub ApproveUser {
my ($username) = @_;
if (open(my $PASSWD, '<', encode_utf8($PendingPasswordFile))) {
if (open(my $PASSWD, '<', $PendingPasswordFile)) {
while (<$PASSWD>) {
if ($_ =~ /^$username:(.*):(.*)/) {
AddUser($username,$1,$2,$PasswordFile);

View File

@@ -118,7 +118,7 @@ sub DoLogout {
print
GetHeader('', Ts('Logged out of %s', $SiteName), '') .
$q->div({-class=> 'content'}, $q->p(T('You are now logged out.'), $id ? $q->p(ScriptLink('action=browse;id=' . UrlEncode($id) . '&time=' . time, Ts('Return to %s', NormalToFree($id)))) : ''));
$q->div({-class=> 'content'}, $q->p(T('You are now logged out.'), $id ? $q->p(ScriptLink('action=browse;id=' . UrlEncode($id) . '&time=' . time, T('Return to ' . NormalToFree($id)))) : ''));
PrintFooter();
}
@@ -266,17 +266,18 @@ except where noted.
Copyleft 2008 by B.w.Curry <http://www.raiazome.com>.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This file is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this file; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
=cut

View File

@@ -56,12 +56,14 @@ sub MacFixEncoding {
return unless %Namespaces;
my %hash = ();
for my $key (keys %Namespaces) {
utf8::decode($key);
$key = NFC($key);
$hash{$key} = $NamespaceRoot . '/' . $key . '/';
}
%Namespaces = %hash;
%hash = ();
for my $key (keys %InterSite) {
utf8::decode($key);
$key = NFC($key);
$hash{$key} = $Namespaces{$key} if $Namespaces{$key};
}

View File

@@ -106,7 +106,7 @@ sub MailFormAddition {
. ScriptLink("action=subscribe;pages=$id", T('subscribe'), 'subscribe');
}
$addition = $q->span({-class=>'mail'},
$q->label({-for=>'mail'}, T('Email:') . ' ')
$q->label({-for=>'mail'}, T('Email: '))
. ' ' . $q->textfield(-name=>'mail', -id=>'mail',
-default=>GetParam('mail', ''))
. $addition);
@@ -120,7 +120,7 @@ sub MailIsSubscribed {
return 0 unless $mail;
# open the DB file
require DB_File;
tie my %h, "DB_File", encode_utf8($MailFile);
tie my %h, "DB_File", $MailFile;
my %subscribers = map {$_=>1} split(/$FS/, UrlDecode($h{UrlEncode($id)}));
untie %h;
return $subscribers{$mail};
@@ -197,7 +197,7 @@ sub NewMailDeletePage {
sub MailDeletePage {
my $id = shift;
require DB_File;
tie my %h, "DB_File", encode_utf8($MailFile);
tie my %h, "DB_File", $MailFile;
foreach my $mail (split(/$FS/, UrlDecode(delete $h{UrlEncode($id)}))) {
my %subscriptions = map {$_=>1} split(/$FS/, UrlDecode($h{UrlEncode($mail)}));
delete $subscriptions{$id};
@@ -274,7 +274,7 @@ sub MailSubscription {
my $mail = shift;
return unless $mail;
require DB_File;
tie my %h, "DB_File", encode_utf8($MailFile);
tie my %h, "DB_File", $MailFile;
my @result = split(/$FS/, UrlDecode($h{UrlEncode($mail)}));
untie %h;
@result = sort @result;
@@ -303,15 +303,16 @@ sub DoMailSubscriptionList {
'<ul>';
}
require DB_File;
tie my %h, "DB_File", encode_utf8($MailFile);
tie my %h, "DB_File", $MailFile;
foreach my $encodedkey (sort keys %h) {
my @values = sort split(/$FS/, UrlDecode($h{$encodedkey}));
my $key = UrlDecode($encodedkey);
if ($raw) {
print join(' ', $key, @values) . "\n";
} else {
print $q->li(Ts('%s:', MailLink($key, @values)) . ' '
. join(' ', map { MailLink($_, $key) } @values));
print $q->li(Ts('%s: ', MailLink($key, @values)),
join(' ', map { MailLink($_, $key) } @values));
}
}
print '</ul></div>' unless $raw;
@@ -382,7 +383,7 @@ sub MailSubscribe {
return unless $mail and @pages;
# open the DB file
require DB_File;
tie my %h, "DB_File", encode_utf8($MailFile);
tie my %h, "DB_File", $MailFile;
# add to the mail entry
my %subscriptions = map {$_=>1} split(/$FS/, UrlDecode($h{UrlEncode($mail)}));
for my $id (@pages) {
@@ -441,7 +442,7 @@ sub MailUnsubscribe {
my ($mail, @pages) = @_;
return unless $mail and @pages;
require DB_File;
tie my %h, "DB_File", encode_utf8($MailFile);
tie my %h, "DB_File", $MailFile;
my %subscriptions = map {$_=>1} split(/$FS/, UrlDecode($h{UrlEncode($mail)}));
foreach my $id (@pages) {
delete $subscriptions{$id};
@@ -480,7 +481,8 @@ sub DoMailMigration {
$q->start_div({-class=>'content mailmigrate'});
require DB_File;
tie my %h, "DB_File", encode_utf8($MailFile);
tie my %h, "DB_File", $MailFile;
my $found = 0;
foreach my $key (keys %h) {
if (index($key, '@') != -1) {

View File

@@ -1,5 +1,5 @@
#! /usr/bin/perl
# Copyright (C) 20142017 Alex Schroeder <alex@gnu.org>
# Copyright (C) 2014 Alex Schroeder <alex@gnu.org>
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
@@ -18,7 +18,7 @@ use v5.10;
AddModuleDescription('markdown-rule.pl', 'Markdown Rule Extension');
our ($q, $bol, %RuleOrder, @MyRules, $UrlProtocols, $FullUrlPattern, @HtmlStack);
our ($q, $bol, %RuleOrder, @MyRules, $UrlProtocols, $FullUrlPattern);
push(@MyRules, \&MarkdownRule);
# Since we want this package to be a simple add-on, we try and avoid
@@ -31,20 +31,16 @@ $RuleOrder{\&MarkdownRule} = 200;
# https://help.github.com/articles/github-flavored-markdown
sub MarkdownRule {
# \escape
if (m/\G\\([-#>*`=])/cg) {
return $1;
}
# atx headers
elsif ($bol and m~\G(\s*\n)*(#{1,6})[ \t]*~cg) {
if ($bol and m~\G(\s*\n)*(#{1,6})[ \t]*~cg) {
my $header_depth = length($2);
return CloseHtmlEnvironments()
. AddHtmlEnvironment("h" . $header_depth);
}
# end atx header at a newline
elsif ((InElement('h1') or InElement('h2') or InElement('h3') or
InElement('h4') or InElement('h5') or InElement('h6'))
and m/\G\n/cg) {
InElement('h4') or InElement('h5') or InElement('h6'))
and m/\G\n/cg) {
return CloseHtmlEnvironments()
. AddHtmlEnvironment("p");
}
@@ -60,71 +56,33 @@ sub MarkdownRule {
return CloseHtmlEnvironments()
. AddHtmlEnvironment('blockquote');
}
# ``` = code
elsif ($bol and m/\G```[ \t]*\n(.*?)\n```[ \t]*(\n|$)/cgs) {
return CloseHtmlEnvironments() . $q->pre($1)
. AddHtmlEnvironment("p");
}
# ` = code
elsif (m/\G`([^`].*?)`/cg) {
return $q->code($1);
}
# ***bold and italic***
elsif (not InElement('strong') and not InElement('em') and m/\G\*\*\*/cg) {
return AddHtmlEnvironment('em') . AddHtmlEnvironment('strong');
}
elsif (InElement('strong') and InElement('em') and m/\G\*\*\*/cg) {
return CloseHtmlEnvironment('strong') . CloseHtmlEnvironment('em');
}
# **bold**
elsif (m/\G\*\*/cg) {
return AddOrCloseHtmlEnvironment('strong');
}
# *italic* (closing before adding environment!)
elsif (InElement('em') and m/\G\*/cg) {
return CloseHtmlEnvironment('em');
}
elsif ($bol and m/\G\*/cg or m/\G(?<=\P{Word})\*/cg) {
return AddHtmlEnvironment('em');
# *italic*
elsif (m/\G\*/cg) {
return AddOrCloseHtmlEnvironment('em');
}
# ~~strikethrough~~ (deleted)
elsif (m/\G~~/cg) {
return AddOrCloseHtmlEnvironment('del');
}
# indented lists = nested lists
elsif ($bol and m/\G(\s*\n)*()([*-]|\d+\.)[ \t]*/cg
or InElement('li') && m/\G(\s*\n)+( *)([*-]|\d+\.)[ \t]*/cg) {
my $nesting_goal = int(length($2)/4) + 1;
my $tag = ($3 eq '*' or $3 eq '-') ? 'ul' : 'ol';
my $nesting_current = 0;
my @nesting = grep(/^[uo]l$/, @HtmlStack);
my $html = CloseHtmlEnvironmentUntil('li'); # but don't close li element
# warn "\@nesting is (@nesting)\n";
# warn " goal is $nesting_goal\n";
# warn " tag is $3 > $tag\n";
while (@nesting > $nesting_goal) {
$html .= CloseHtmlEnvironment(pop(@nesting));
# warn " pop\n";
}
# if have the correct nesting level, but the wrong type, close it
if (@nesting == $nesting_goal
and $nesting[$#nesting] ne $tag) {
$html .= CloseHtmlEnvironment(pop(@nesting));
# warn " switch\n";
}
# now add a list of the appropriate type
if (@nesting < $nesting_goal) {
$html .= AddHtmlEnvironment($tag);
# warn " add $tag\n";
}
# and a new list item
if (InElement('li')) {
$html .= CloseHtmlEnvironmentUntil($nesting[$#nesting]);
# warn " close li\n";
}
$html .= AddHtmlEnvironment('li');
# warn " add li\n";
return $html;
# - bullet list
elsif ($bol and m/\G(\s*\n)*-[ \t]*/cg
or InElement('li') and m/\G(\s*\n)+-[ \t]*/cg) {
return CloseHtmlEnvironment('li')
. OpenHtmlEnvironment('ul',1) . AddHtmlEnvironment('li');
}
# 1. numbered list
elsif ($bol and m/\G(\s*\n)*\d+\.[ \t]*/cg
or InElement('li') and m/\G(\s*\n)+\d+\.[ \t]*/cg) {
return CloseHtmlEnvironment('li')
. OpenHtmlEnvironment('ol',1) . AddHtmlEnvironment('li');
}
# beginning of a table
elsif ($bol and !InElement('table') and m/\G\|/cg) {
@@ -166,6 +124,11 @@ sub MarkdownRule {
}
return OpenHtmlEnvironment('pre',1) . $str; # always level 1
}
# ``` = code
elsif ($bol and m/\G```[ \t]*\n(.*?)\n```[ \t]*(\n|$)/cgs) {
return CloseHtmlEnvironments() . $q->pre($1)
. AddHtmlEnvironment("p");
}
# [an example](http://example.com/ "Title")
elsif (m/\G\[(.+?)\]\($FullUrlPattern(\s+"(.+?)")?\)/cg) {
my ($text, $url, $title) = ($1, $2, $4);
@@ -178,31 +141,3 @@ sub MarkdownRule {
}
return;
}
push(@MyRules, \&MarkdownExtraRule);
sub MarkdownExtraRule {
# __italic underline__
if (m/\G__/cg) {
return AddOrCloseHtmlEnvironment('em', 'style="font-style: normal; text-decoration: underline"');
}
# _underline_ (closing before adding environment!)
elsif (InElement('em', 'style="font-style: normal; text-decoration: underline"') and m/\G_/cg) {
return CloseHtmlEnvironment('em');
}
elsif ($bol and m/\G_/cg or m/\G(?<=\P{Word})_/cg) {
return AddHtmlEnvironment('em', 'style="font-style: normal; text-decoration: underline"');
}
# //italic//
elsif (m/\G\/\//cg) {
return AddOrCloseHtmlEnvironment('em');
}
# /italic/ (closing before adding environment!)
elsif (InElement('em') and m/\G\//cg) {
return CloseHtmlEnvironment('em');
}
elsif ($bol and m/\G\//cg or m/\G(?<=\P{Word})\//cg) {
return AddHtmlEnvironment('em');
}
return;
}

View File

@@ -1,73 +0,0 @@
#! /usr/bin/perl
# Copyright (C) 2017 Alex Schroeder <alex@gnu.org>
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any later
# version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <http://www.gnu.org/licenses/>.
use strict;
use v5.10;
AddModuleDescription('mermaid.pl', 'Mermaid for Diagrams');
our ($bol, @MyRules, $MermaidCss, $MermaidJs, $HtmlHeaders, %Page);
$MermaidCss = '/mermaid/mermaid.css';
$MermaidJs = '/mermaid/mermaid.min.js';
# When browsing a page containing mermaid markup, load the mermaid Javascript and CSS
*MermaidOldBrowsePage = *BrowsePage;
*BrowsePage = *MermaidNewBrowsePage;
sub MermaidNewBrowsePage {
my ($id) = @_;
OpenPage($id);
# Uses <mermaid> to render graphs
if ($Page{text} =~ /<mermaid>/
and $HtmlHeaders !~ /mermaid/) {
$HtmlHeaders .= qq{
<link type="text/css" rel="stylesheet" href="$MermaidCss" />
<script type="text/javascript" src="$MermaidJs"></script>
};
}
return MermaidOldBrowsePage(@_);
}
# When previewing an edit containing mermaid markup, load the mermaid Javascript
# and CSS
*MermaidOldDoEdit = *DoEdit;
*DoEdit = *MermaidNewDoEdit;
sub MermaidNewDoEdit {
# Uses <mermaid> to render graphs
if (GetParam('text') =~ /&lt;mermaid&gt;/
and $HtmlHeaders !~ /mermaid/) {
$HtmlHeaders = q{
<link rel="stylesheet" href="/mermaid/mermaid.css" />
<script type="text/javascript" src="/mermaid/mermaid.min.js"></script>
};
}
return MermaidOldDoEdit(@_);
}
# And a formatting rule, of course.
push(@MyRules, \&MermaidRule);
sub MermaidRule {
if ($bol && m/\G\&lt;mermaid\&gt;\n(.+?)\n\&lt;\/mermaid\&gt;/cgs) {
return CloseHtmlEnvironments()
. '<div class="mermaid">' . UrlDecode($1) . '</div>';
}
return undef;
}

View File

@@ -54,10 +54,10 @@ sub BisectAction {
sub BisectInitialScreen {
print GetFormStart(undef, 'get', 'bisect');
print GetHiddenValue('action', 'bisect');
my @disabledFiles = Glob("$ModuleDir/*.p[ml].disabled");
my @disabledFiles = bsd_glob("$ModuleDir/*.p[ml].disabled");
if (@disabledFiles == 0) {
print T('Test / Always enabled / Always disabled'), $q->br();
my @files = Glob("$ModuleDir/*.p[ml]");
my @files = bsd_glob("$ModuleDir/*.p[ml]");
for (my $i = 0; $i < @files; $i++) {
my $moduleName = fileparse($files[$i]);
my @disabled = ($moduleName eq 'module-bisect.pl' ? (-disabled=>'disabled') : ());
@@ -68,7 +68,7 @@ sub BisectInitialScreen {
}
print $q->submit(-name=>'bad', -value=>T('Start'));
} else {
print T('Bisecting proccess is already active.'), $q->br();
print T('Biscecting proccess is already active.'), $q->br();
print $q->submit(-name=>'stop', -value=>T('Stop'));
}
print $q->end_form();
@@ -78,7 +78,7 @@ sub BisectProcess {
my ($isGood) = @_;
my $parameterHandover = '';
BisectEnableAll();
my @files = Glob("$ModuleDir/*.p[ml]");
my @files = bsd_glob("$ModuleDir/*.p[ml]");
for (my $i = @files - 1; $i >= 0; $i--) { # handle user choices
if (GetParam("m$i") eq 'on') {
$parameterHandover .= GetHiddenValue("m$i", GetParam("m$i"));
@@ -102,7 +102,7 @@ sub BisectProcess {
print $q->end_form();
return;
}
print T('Module count (only testable modules):'), ' ', $q->strong(scalar @files), $q->br();
print T('Module count (only testable modules): '), $q->strong(scalar @files), $q->br();
print $q->br(), T('Current module statuses:'), $q->br();
my $halfsize = ($end - $start + 1) / 2.0; # + 1 because it is count
$end -= int($halfsize) unless $isGood;
@@ -131,7 +131,7 @@ sub BisectProcess {
}
sub BisectEnableAll {
for (Glob("$ModuleDir/*.p[ml].disabled")) { # reenable all modules
for (bsd_glob("$ModuleDir/*.p[ml].disabled")) { # reenable all modules
my $oldName = $_;
s/\.disabled$//;
print Ts('Enabling %s', (fileparse($_))[0]), '...', $q->br() if $_[0];

View File

@@ -40,8 +40,8 @@ sub ModuleUpdaterAction {
if (GetParam('ok')) {
ModuleUpdaterApply();
} else {
Unlink(Glob("$TempDir/*.p[ml]")); # XXX is it correct to use $TempDir for such stuff? What if something else puts .pm files there?
for (Glob("$ModuleDir/*.p[ml]")) {
unlink bsd_glob("$TempDir/*.p[ml]"); # XXX is it correct to use $TempDir for such stuff? What if something else puts .pm files there?
for (bsd_glob("$ModuleDir/*.p[ml]")) {
my $curModule = fileparse($_);
ProcessModule($curModule);
}
@@ -58,7 +58,7 @@ sub ModuleUpdaterAction {
}
sub ModuleUpdaterApply {
for (Glob("$TempDir/*.p[ml]")) {
for (bsd_glob("$TempDir/*.p[ml]")) {
my $moduleName = fileparse($_);
if (move($_, "$ModuleDir/$moduleName")) {
print $q->strong("Module $moduleName updated successfully!"), $q->br();
@@ -66,7 +66,7 @@ sub ModuleUpdaterApply {
print $q->strong("Unable to replace module $moduleName: $!"), $q->br();
}
}
Unlink(Glob("$TempDir/*.p[ml]")); # XXX same as above
unlink bsd_glob("$TempDir/*.p[ml]"); # XXX same as above
print $q->br(), $q->strong('Done!');
}
@@ -81,14 +81,15 @@ sub ProcessModule {
. ' If this is your own module, please contribute it to Oddmuse!'), $q->br();
return;
}
open my $fh, ">:utf8", encode_utf8("$TempDir/$module") or die("Could not open file $TempDir/$module: $!");
open my $fh, ">", "$TempDir/$module" or die("Could not open file. $!");
utf8::encode($moduleData);
print $fh $moduleData;
close $fh;
my $diff = DoModuleDiff("$ModuleDir/$module", "$TempDir/$module");
if (not $diff) {
print $q->strong('This module is up to date, there is no need to update it.'), $q->br();
Unlink("$TempDir/$module");
unlink "$TempDir/$module";
return;
}
print $q->strong('There is a newer version of this module. Here is a diff:'), $q->br();
@@ -108,5 +109,7 @@ sub ProcessModule {
}
sub DoModuleDiff {
decode_utf8(`diff -U 3 -- \Q$_[0]\E \Q$_[1]\E`);
my $diff = `diff -U 3 -- \Q$_[0]\E \Q$_[1]\E`;
utf8::decode($diff); # needs decoding
return $diff;
}

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -80,28 +80,14 @@ $NamespaceSlashing = 0; # affects : decoding NamespaceRcLines
# variables (eg. localnames.pl)
unshift(@MyInitVariables, \&NamespacesInitVariables);
sub GetNamespace {
my $ns = GetParam('ns', '');
if (not $ns and $UsePathInfo) {
my $path_info = decode_utf8($q->path_info());
# make sure ordinary page names are not matched!
if ($path_info =~ m|^/($InterSitePattern)(/.*)?|
and ($2 or $q->keywords or NamespaceRequiredByParameter())) {
$ns = $1;
}
}
ReportError(Ts('%s is not a legal name for a namespace', $ns))
if $ns and $ns !~ m/^($InterSitePattern)$/;
return $ns;
}
sub NamespacesInitVariables {
%Namespaces = ();
# Do this before changing the $DataDir and $ScriptName
if ($UsePathInfo) {
$Namespaces{$NamespacesMain} = $ScriptName . '/';
foreach my $name (Glob("$DataDir/*")) {
if (IsDir($name)
foreach my $name (bsd_glob("$DataDir/*")) {
utf8::decode($name);
if (-d $name
and $name =~ m|/($InterSitePattern)$|
and $name ne $NamespacesMain
and $name ne $NamespacesSelf) {
@@ -111,7 +97,18 @@ sub NamespacesInitVariables {
}
$NamespaceRoot = $ScriptName; # $ScriptName may be changed below
$NamespaceCurrent = '';
my $ns = GetNamespace();
my $ns = GetParam('ns', '');
if (not $ns and $UsePathInfo) {
my $path_info = $q->path_info();
utf8::decode($path_info);
# make sure ordinary page names are not matched!
if ($path_info =~ m|^/($InterSitePattern)(/.*)?|
and ($2 or $q->keywords or NamespaceRequiredByParameter())) {
$ns = $1;
}
}
ReportError(Ts('%s is not a legal name for a namespace', $ns))
if $ns and $ns !~ m/^($InterSitePattern)$/;
if ($ns
and $ns ne $NamespacesMain
and $ns ne $NamespacesSelf) {
@@ -140,8 +137,13 @@ sub NamespacesInitVariables {
$StaticUrl .= UrlEncode($NamespaceCurrent) . '/'
if substr($StaticUrl,-1) eq '/'; # from static-copy.pl
$WikiDescription .= "<p>Current namespace: $NamespaceCurrent</p>";
$LastUpdate = Modified($IndexFile);
CreateDir($DataDir);
# override LastUpdate
my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size, $atime,$mtime,$ctime,$blksize,$blocks)
= stat($IndexFile);
$LastUpdate = $mtime;
CreateDir($DataDir); # Create directory if it doesn't exist
ReportError(Ts('Cannot create %s', $DataDir) . ": $!", '500 INTERNAL SERVER ERROR')
unless -d $DataDir;
}
$Namespaces{$NamespacesSelf} = $ScriptName . '?';
# reinitialize
@@ -222,19 +224,19 @@ sub NewNamespaceGetRcLines { # starttime, hash of seen pages to use as a second
# opening a rcfile, compare the first timestamp with the
# starttime. If any rcfile exists with no timestamp before the
# starttime, we need to open its rcoldfile.
foreach my $rcfile (@rcfiles) {
open(my $F, '<:encoding(UTF-8)', encode_utf8($rcfile));
foreach my $file (@rcfiles) {
open(my $F, '<:encoding(UTF-8)', $file);
my $line = <$F>;
my ($ts) = split(/$FS/, $line); # the first timestamp in the regular rc file
my @new;
if (not $ts or $ts > $starttime) { # we need to read the old rc file, too
push(@new, GetRcLinesFor($rcoldfiles{$rcfile}, $starttime,\%match, \%following));
push(@new, GetRcLinesFor($rcoldfiles{$file}, $starttime,\%match, \%following));
}
push(@new, GetRcLinesFor($rcfile, $starttime, \%match, \%following));
push(@new, GetRcLinesFor($file, $starttime, \%match, \%following));
# strip rollbacks in each namespace separately
@new = StripRollbacks(@new);
# prepend the namespace to both pagename and author
my $ns = $namespaces{$rcfile};
my $ns = $namespaces{$file};
if ($ns) {
for (my $i = $#new; $i >= 0; $i--) {
# page id
@@ -405,7 +407,7 @@ $Action{namespaces} = \&DoNamespacesList;
sub DoNamespacesList {
if (GetParam('raw', 0)) {
print GetHttpHeader('text/plain');
print join("\n", sort keys %Namespaces), "\n";
print join("\n", keys %Namespaces), "\n";
} else {
print GetHeader('', T('Namespaces')),
$q->start_div({-class=>'content namespaces'}),
@@ -413,7 +415,7 @@ sub DoNamespacesList {
GetHiddenValue('id', $HomePage);
my $new = $q->textfield('ns') . ' ' . $q->submit('donamespace', T('Go!'));
print $q->ul($q->li([map { $q->a({-href => $Namespaces{$_} . $HomePage},
$_); } sort keys %Namespaces]), $q->li($new));
$_); } keys %Namespaces]), $q->li($new));
print $q->end_form() . $q->end_div();
PrintFooter();
}
@@ -439,6 +441,8 @@ sub NamespacesNewGetId {
# In this case GetId() will have set the parameter Test to 1.
# http://example.org/cgi-bin/wiki.pl/Test?rollback-1234=foo
# This doesn't set the Test parameter.
return if $id and $UsePathInfo and $id eq $NamespaceCurrent and not GetParam($id) and not GetParam('ns');
if ($UsePathInfo and $id eq $NamespaceCurrent and not GetParam($id) and not GetParam('ns')) {
$id = undef;
}
return $id;
}

View File

@@ -18,7 +18,7 @@ use v5.10;
AddModuleDescription('near-links.pl', 'Near Links');
our ($q, $Now, %AdminPages, %InterSite, $CommentsPrefix, $DataDir, $UseCache, @MyFooters, @MyMaintenance, @MyInitVariables, @Debugging, $InterSitePattern, @UserGotoBarPages, @IndexOptions);
our ($q, %AdminPages, %InterSite, $CommentsPrefix, $DataDir, $UseCache, @MyFooters, @MyMaintenance, @MyInitVariables, @Debugging, $InterSitePattern, @UserGotoBarPages, @IndexOptions);
=head1 Near Links
@@ -128,8 +128,7 @@ sub NearLinksMaintenance {
# skip if less than 12h old and caching allowed (the default)
foreach my $site (keys %NearSite) {
next if GetParam('cache', $UseCache) > 0
and IsFile("$NearDir/$site")
and $Now - Modified("$NearDir/$site") < 0.5;
and -f "$NearDir/$site" and -M "$NearDir/$site" < 0.5;
print $q->p(Ts('Getting page index file for %s.', $site));
my $data = GetRaw($NearSite{$site});
print $q->p($q->strong(Ts('%s returned no data, or LWP::UserAgent is not available.',

View File

@@ -3,7 +3,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -12,7 +12,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);

View File

@@ -3,7 +3,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -12,7 +12,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);

View File

@@ -3,7 +3,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -12,7 +12,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use CGI qw/:standard/;
use CGI::Carp qw(fatalsToBrowser);

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

View File

@@ -2,7 +2,7 @@
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@@ -11,7 +11,10 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program; if not, write to the
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307 USA
use strict;
use v5.10;

Some files were not shown because too many files have changed in this diff Show More