Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Item12536: added support for web statistics, charset-convertor and js…
…onrpc git-svn-id: http://svn.foswiki.org/trunk/VirtualHostingContrib@16815 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
- Loading branch information
MichaelDaum
authored and
MichaelDaum
committed
Jul 1, 2013
1 parent
580d43e
commit 9999b1f
Showing
3 changed files
with
264 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#!/usr/bin/perl | ||
# See bottom of file for license and copyright information | ||
use strict; | ||
use warnings; | ||
|
||
BEGIN { | ||
if (-e './setlib.cfg') { | ||
unshift @INC, '.'; | ||
} elsif (-e '../bin/setlib.cfg') { | ||
unshift @INC, '../bin'; | ||
} | ||
require 'setlib.cfg'; | ||
} | ||
|
||
use Foswiki (); | ||
use Foswiki::UI (); | ||
use Foswiki::Contrib::VirtualHostingContrib::VirtualHost (); | ||
use Foswiki::Contrib::CharsetConvertorContrib (); | ||
|
||
# Parse command-line arguments | ||
my %args; | ||
while (my $a = shift @ARGV) { | ||
if ($a =~ /(.*?)=(.*)/) { | ||
$args{$1} = $2; | ||
} else { | ||
$args{$a} = 1; | ||
} | ||
} | ||
|
||
my $hostname = $args{host} || $args{-h}; | ||
|
||
if ($hostname) { | ||
Foswiki::Contrib::VirtualHostingContrib::VirtualHost->run_on($hostname, \&doit); | ||
} else { | ||
Foswiki::Contrib::VirtualHostingContrib::VirtualHost->run_on_each(\&doit); | ||
} | ||
|
||
sub doit { | ||
|
||
unless ($args{-i}) { | ||
local $/ = undef; | ||
print <<'INFORM'; | ||
Foswiki RCS database character set conversion | ||
-i - report what would be done only, do not convert anything | ||
-q - work silently (unless there's an error) | ||
-a - abort on error (default is to report and continue) | ||
-h <hostname> - name of the virtual host to process (default is to process all) | ||
This script will convert the Foswiki RCS database pointed at by | ||
{DataDir} and {PubDir} from the existing character set (as set | ||
by {Site}{CharSet}) to UTF8. | ||
You can run the script in "inspection" mode by passing -i on the | ||
command line. No changes will be made to the database. | ||
Once you have run the script without -i, all: | ||
* web names | ||
* topic names | ||
* attachment names | ||
* topic content | ||
will be converted to UTF8. The conversion is performed *in place* on the data | ||
and pub directories. | ||
Note that no conversion is performed on | ||
* log files | ||
* working/ | ||
* temporary files | ||
Once conversion is complete you must change your {Site}{CharSet} to 'utf-8' | ||
INFORM | ||
die 'Cannot proceed without backup confirmation' unless | ||
ask( "Have you backed up your data ($Foswiki::cfg{DataDir}) and pub ($Foswiki::cfg{PubDir}) directories" ); | ||
die 'Cannot proceed without confirmation of access permissions' unless | ||
ask( "Do you have write permission on all files and directories in $Foswiki::cfg{DataDir} and $Foswiki::cfg{PubDir}" ); | ||
die 'Cannot proceed until you confirm that data is consistent with this setting' unless | ||
ask( "\$Foswiki::cfg{Site}{CharSet} is set to '$Foswiki::cfg{Site}{CharSet}'. Is that correct for the data in your Foswiki database" ); | ||
} | ||
|
||
Foswiki::Contrib::CharsetConvertorContrib::convertCollection('', %args); | ||
} | ||
|
||
# Prompt user for a confirmation | ||
sub ask { | ||
my $q = shift; | ||
my $reply; | ||
|
||
local $/ = "\n"; | ||
|
||
$q .= '?' unless $q =~ /\?\s*$/; | ||
|
||
print $q. ' [y/n] '; | ||
while ( ( $reply = <STDIN> ) !~ /^[yn]/i ) { | ||
print "Please answer yes or no\n"; | ||
} | ||
return ( $reply =~ /^y/i ) ? 1 : 0; | ||
} | ||
|
||
1; | ||
|
||
__END__ | ||
Copyright (C) 2011 Foswiki Contributors. | ||
Author: Crawford Currie http://c-dot.co.uk | ||
For licensing info read LICENSE file in the Foswiki root. | ||
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, published at | ||
http://www.gnu.org/copyleft/gpl.html | ||
As per the GPL, removal of this notice is prohibited. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/perl -wT | ||
# See bottom of file for license and copyright information | ||
use strict; | ||
use warnings; | ||
|
||
BEGIN { | ||
$Foswiki::cfg{Engine} = 'Foswiki::Engine::CLI'; | ||
require Carp; | ||
$SIG{__DIE__} = \&Carp::confess; | ||
if (-e './setlib.cfg') { | ||
unshift @INC, '.'; | ||
} elsif (-e '../bin/setlib.cfg') { | ||
unshift @INC, '../bin'; | ||
} | ||
require 'setlib.cfg'; | ||
$ENV{FOSWIKI_ACTION} = 'jsonrpc'; | ||
} | ||
|
||
use Foswiki (); | ||
use Foswiki::UI (); | ||
use Foswiki::Contrib::VirtualHostingContrib::VirtualHost (); | ||
|
||
my $verbose = 1; | ||
my $hostname = ''; | ||
|
||
foreach my $arg (@ARGV) { | ||
if ($arg =~ /^(.*)=(.*)$/) { | ||
if ($1 eq 'verbose') { | ||
$verbose = ($2 eq 'on')?1:0; | ||
} elsif ($1 eq 'host') { | ||
$hostname = $2; | ||
} | ||
} | ||
} | ||
|
||
if ($hostname) { | ||
Foswiki::Contrib::VirtualHostingContrib::VirtualHost->run_on($hostname, \&doit); | ||
} else { | ||
Foswiki::Contrib::VirtualHostingContrib::VirtualHost->run_on_each(\&doit); | ||
} | ||
|
||
sub doit { | ||
printf("=> Processing %s\n", $Foswiki::Contrib::VirtualHostingContrib::VirtualHost::CURRENT) if $verbose; | ||
$Foswiki::engine->run(); | ||
} | ||
|
||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
Additional copyrights apply to some or all of the code in this | ||
file as follows: | ||
Copyright (C) 1999-2007 Peter Thoeny, peter@thoeny.org | ||
and TWiki Contributors. All Rights Reserved. TWiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
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. For | ||
more details read LICENSE in the root of this distribution. | ||
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. | ||
As per the GPL, removal of this notice is prohibited. | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
#!/usr/bin/perl -wT | ||
# See bottom of file for license and copyright information | ||
use strict; | ||
use warnings; | ||
|
||
use File::Spec; | ||
|
||
BEGIN { | ||
$Foswiki::cfg{Engine} = 'Foswiki::Engine::CLI'; | ||
require Carp; | ||
$SIG{__DIE__} = \&Carp::confess; | ||
if (-e './setlib.cfg') { | ||
unshift @INC, '.'; | ||
} elsif (-e '../bin/setlib.cfg') { | ||
unshift @INC, '../bin'; | ||
} | ||
require 'setlib.cfg'; | ||
$ENV{FOSWIKI_ACTION} = 'statistics'; | ||
} | ||
|
||
use Foswiki (); | ||
use Foswiki::UI (); | ||
use Foswiki::Contrib::VirtualHostingContrib::VirtualHost (); | ||
|
||
my $verbose = 1; | ||
my $hostname = ''; | ||
|
||
foreach my $arg (@ARGV) { | ||
if ($arg =~ /^(.*)=(.*)$/) { | ||
if ($1 eq 'verbose') { | ||
$verbose = ($2 eq 'on')?1:0; | ||
} elsif ($1 eq 'host') { | ||
$hostname = $2; | ||
} | ||
} | ||
} | ||
|
||
if ($hostname) { | ||
Foswiki::Contrib::VirtualHostingContrib::VirtualHost->run_on($hostname, \&doit); | ||
} else { | ||
Foswiki::Contrib::VirtualHostingContrib::VirtualHost->run_on_each(\&doit); | ||
} | ||
|
||
sub doit { | ||
printf("=> Processing %s\n", $Foswiki::Contrib::VirtualHostingContrib::VirtualHost::CURRENT) if $verbose; | ||
$Foswiki::engine->run(); | ||
} | ||
|
||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Copyright (C) 2008-2010 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
Additional copyrights apply to some or all of the code in this | ||
file as follows: | ||
Copyright (C) 1999-2007 Peter Thoeny, peter@thoeny.org | ||
and TWiki Contributors. All Rights Reserved. TWiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
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. For | ||
more details read LICENSE in the root of this distribution. | ||
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. | ||
As per the GPL, removal of this notice is prohibited. |