Skip to content

Commit

Permalink
Merge branch 'master' into Item13525
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelDaum committed Jul 20, 2015
2 parents 5735e2d + 9376d4a commit b825ac4
Show file tree
Hide file tree
Showing 17 changed files with 540 additions and 91 deletions.
@@ -1,6 +1,7 @@
!noci
templates/icons.tmpl 0444
templates/view.famfamfam.tmpl 0444
templates/subscribe.famfamfam.tmpl 0444

data/System/DocumentGraphics.txt 0644 Documentation
data/System/FamFamFamContrib.txt 0644 Documentation
Expand Down
Expand Up @@ -7,4 +7,12 @@
# programs. The use of text files makes it easy to implement 'out of band'
# processing, as well as taking maximum advantage of filestore caching. This
# is the reference implementation of a store.</dd></dl>
# ---+ Extensions
# ---++ PlainFileStoreContrib
# **BOOLEAN**
# Check before every store modification that there are no suspicious
# files left over from RCS. This check should be enabled whenever there
# is a risk that old RCS data has been mixed in to a PlainFileStore.
$Foswiki::cfg{Extensions}{PlainFileStoreContrib}{CheckForRCS} = 0;

1;
8 changes: 7 additions & 1 deletion PlainFileStoreContrib/lib/Foswiki/Store/PlainFile.pm
Expand Up @@ -1102,7 +1102,13 @@ sub _saveDamage {
my $latest = _latestFile( $meta, $attachment );
return unless ( _e $latest );

if ( _e "$latest,v" && !$Foswiki::inUnitTestMode ) {
if ( $Foswiki::cfg{Extensions}{PlainFileStoreContrib}{CheckForRCS}
&& !$Foswiki::inUnitTestMode
&& _e("$latest,v") )
{
my $path =
Encode::encode_utf8( $Foswiki::cfg{DataDir} ) . "/"
. $meta->getPath();
die <<DONE;
PlainFileStore is selected but you have ,v files present in the directory tree, Save aborted to avoid loss of topic history.
Did you remember to convert the store? The administrator should review tools/bulk_copy.pl, or select an RCS based store.
Expand Down
236 changes: 236 additions & 0 deletions RCSStoreContrib/test/unit/RCSStoreContrib/gen_bulk_copy_test.pl
@@ -0,0 +1,236 @@
#! /usr/bin/env perl
#
# Author: Crawford Currie http://c-dot.co.uk
#
# Foswiki - The Free and Open Source Wiki, http://foswiki.org/
#
# Copyright (C) 2015 Foswiki Contributors. Foswiki Contributors
# are listed in the AUTHORS file in the root of this distribution.
# NOTE: Please extend that file, not this notice.
#
# 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.

#
# Run from the root of a Foswiki install to generate a test web suitable
# for testing bulk_copy.pl
#
# Two parameters, the charset of the source install and the charset of the
# dest install
# e.g.
#
# $ perl tools/gen_bulk_copy_test_web.pl UTF-8 ISO-8859-1
#
# will generate a web with filenames encoded using UTF-8, but only using
# codepoints that map to ISO-8859-1
#
# If there is no second parameter, the same charset is assumed.
# If there are no parameters, the charset is taken from the LC_CTYPE.
#
# The web generated is called Testbulkcopy.
use strict;
use Encode;
use POSIX qw(locale_h);
use locale;

die "Not at the root of a conventional Foswiki install"
unless -d "data" && -d "pub";

our $old_locale = setlocale(LC_CTYPE);
die "Could not determine locale"
unless ( $old_locale && $old_locale =~ /^(.*?)\.(.*)$/ );

our ( $lang, $old_encoding ) = ( $1, $2 );

our $source_encoding = $ARGV[0] || $old_encoding;
our $dest_encoding = $ARGV[1] || $source_encoding;
our $time = 1422748800;

sub recode {
my $s = shift;
return Encode::encode( $old_encoding,
Encode::decode( $source_encoding, $s, Encode::FB_CROAK ) );
}

sub report {
my $s = join( ' ', @_ );
return unless $s =~ /\S/;
$s =~ s/\s*$//s;
print recode($s) . "\n";
}

our $locale = "$lang.$source_encoding";
our $setlocale = POSIX::setlocale( LC_CTYPE, $locale );
die "Failed to set locale $locale. Is locale installed?" unless $setlocale;
report "Source encoding is $source_encoding";
report "Destination encoding is $dest_encoding";

# Explore the encodings
our $chlim = 65536;
my %classes = (
'upper' => '',
'lower' => '',
'alnum' => '',
'ascii' => '',
'digit' => ''
);
my %rex = map { $_ => "[:$_:]" } keys %classes;

report "Exploring character sets... $source_encoding";
for ( $chlim = 0 ; $chlim < 65536 ; $chlim++ ) {
my $uch = chr($chlim);
eval {
my $uuch = $uch;
my $octets =
Encode::encode( $source_encoding, $uuch, Encode::FB_CROAK );
};
if ($@) {
print "SKIP $chlim\n" if $chlim < 256;
next;
}
foreach my $class ( keys %classes ) {
$classes{$class} .= $uch if $uch =~ /[$rex{$class}]/;
}
}
report "...can use $chlim characters";
foreach my $c ( keys %classes ) {
report "......", length( $classes{$c} ), $c;
}

# Make N characters in the source encoding
sub make_chars {
my $n = shift;
my $chs = join( '', map { $classes{$_} } @_ );
my $l = length($chs);
my $rex = quotemeta($chs);
$n ||= 1;
my $tries = 0;
my $str = '';
while ( length($str) < $n ) {
$tries++;
my $codepoint = my $uch = substr( $chs, int( rand($l) ), 1 );

# Avoid ASCII until we've tried lots of other things
if ( $uch =~ /[[:ascii:]]/ ) {

#report "$tries:",ord($uch),"$uch isascii";
next unless $tries > $l;
report "forced to pick", ord($uch), "$uch isascii";
}
$str .= Encode::encode( $source_encoding, $uch, Encode::FB_CROAK );
}
return $str;
}

# Make a 4-character wikiword
sub make_wikiword {
return
make_chars( 1, 'upper' )
. make_chars( 1, 'lower', 'digit' )
. make_chars( 1, 'upper' )
. make_chars( 1, 'alnum' );
}

sub ci {
my $path = shift;
die "ci requires a path" unless -f $path;
report `ci -q -mcomment -f -t-none -wProjectContributor $path`;
report `rm -f $path`;
report `co -q -l $path`;
chmod( 0644, $path );
}

# Make a valid web name that incorporates dodgy chars. This doesn't work
# in 1.1.9 - it just doesn't see the web when copying because the regexes
# in 1.1.9 are fundamentally borked.
#our $web = 'System';
#while (-d "data/$web") {
# $web = "Testbulkcopy".make_chars(5, 'alnum');
#}
our $web = "Testbulkcopy";
report "Web name is $web";

our @made;

sub make_topic {
my ( $name, $text, $rev ) = @_;
my $path = "data/$web/$name";
push( @made, "topic $name version $rev " );
open( F, ">:encoding($source_encoding)", "$path.txt" )
|| die recode( "Failed", $path, $! );
print F <<THIS;
%META:TOPICINFO{author="ProjectContributor" date="$time" format="1.1" version="$rev"}%
$text
THIS
$time++;
close(F);
ci("$path.txt");
}

sub make_attachment {
my ( $topic, $name, $data, $rev ) = @_;
mkdir "pub/$web/$topic";
my $path = "pub/$web/$topic/$name";
open( F, ">", $path ) || die recode( "Failed", $path, $! );
binmode(F);
print F $data;
close(F);
ci($path);
push( @made, "attachment $path:$rev" );
}

mkdir "data/$web";
mkdir "pub/$web";
make_topic( "WebPreferences", "REV 1", 1 );

# Make a topic that has no history
make_topic( "NoHistory", 'REV 4', 4 );

# Make a history that has no topic
make_topic( "NoTopic", 'History only, no cache', 4 );
unlink "data/$web/NoTopic.txt";

# Make a history that has out-of-sequence TOPICINFO
make_topic( "RevHistory", "REV 1", 3 );
make_topic( "RevHistory", "REV 2", 2 );
make_topic( "RevHistory", "REV 3", 1 );

# Make a topc with attachments
my $att_name = make_chars( 5, 'alnum' ) . '.att';
make_topic( "HasAttachments", <<CONTENT, 1 );
%META:FILEATTACHMENT{name="$att_name" comment="logo" user="ProjectContributor" version="1" date="$time"}%
REV 1
CONTENT
$time++;

make_topic( "HasAttachments", <<CONTENT, 2 );
REV 2
%META:FILEATTACHMENT{name="$att_name" comment="logo" user="ProjectContributor" version="4" date="$time"}%
CONTENT
$time++;

make_attachment( "HasAttachments", $att_name, 'REV 1', 1 );
make_attachment( "HasAttachments", $att_name, 'REV 2', 2 );
make_attachment( "HasAttachments", $att_name, 'REV 3', 3 );
make_attachment( "HasAttachments", $att_name, 'REV 4', 4 );

my $made = join( "\n", map { " * $_" } @made );
make_topic( "WebHome", <<DATA, 1 );
This is an automatically generated test web, designed to test the
ools/bulk_copy.pl script. It contains topic histories stored using RCS,
and targets particular types of damage that can occur.
The contents should be:
$made
DATA

1;
31 changes: 12 additions & 19 deletions core/data/System/AppendixCascadingStyleSheets.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1435757231" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1437331638" format="1.1" version="1"}%
%META:TOPICPARENT{name="DeveloperDocumentationCategory"}%
%STARTINCLUDE%
---+ Appendix C: CSS
Expand Down Expand Up @@ -40,15 +40,14 @@ A wide range of standard styles are used in the Foswiki core code and topics, an
|=.foswikiContentFooter= | Optional container around text placed below topic text |
|=.foswikiFooterNote= | Text below topic text; for instance with parent or "topic moved" message |
|=#foswikiLogin= | Login box |
|=.foswikiLogo= | Logo |
|=#foswikiLogo= | Logo |
|=.foswikiPreviewArea= | Container around topic preview |
|=.foswikiTopicActions= | Topic Actions list |
|=.foswikiTopicInfo= | Topic Info section containing REVINFO |
|=.foswikiTopicText= | The rendered Topic text |
|=.foswikiTabs= | Container for tabs (styled bullet list, =.foswikiTabs ul=) |
|=li.foswikiActiveTab= | Active tab |
|=.foswikiTabContent= | Container for content below tabs |
|=#foswikiLogo= | %INCLUDE{"%TOPIC%" section="deprecated" version="2.0" alternative=".foswikiMain"}% |
|=.foswikiMain= | The container for the main contents, usually including the header (only used by default templates) |</sticky>

---+++ General appearance
Expand All @@ -63,7 +62,6 @@ A wide range of standard styles are used in the Foswiki core code and topics, an
|=.foswikiToc= | Table of Contents block |
|=.foswikiTocTitle= | Title text of Table of Contents |
|=.foswikiHidden= | Hidden elements |
|=.foswikiActual= | Font size of body text (if that font size is set in pixels) |
|=.foswikiSmall= | Small text |
|=.foswikiSmallish= | Somewhat less smaller text; in-between normal and small |
|=.foswikiLarge= | Large text, for instance for introduction paragraphs |
Expand Down Expand Up @@ -116,7 +114,8 @@ See also: [[#HtmlFormElements][HTML form elements]]
---+++ HTML form elements
<sticky>
%TABLE{databg="#fff"}%
|=.foswikiForm= | Container for data form in topic, including header |
|=.foswikiForm= | Container for data form in topic, including header |
|=.foswikiActionFormStepSign= | Indicator for each form step (see =foswikiFormStep=) |
|=.foswikiFormSteps= | Container around a form that contains a number of separate 'steps'; each 'step' in a separate row |
|=.foswikiFormStep= | Form step row |
|=.foswikiLast= | Last step (always in combination with =foswikiFormStep=); sometimes used as last table row |
Expand All @@ -142,12 +141,13 @@ See also: [[#HtmlFormElements][HTML form elements]]
---+++ Search and lists
<sticky>
%TABLE{databg="#fff"}%
|=.foswikiSearchResult= | Container around image and contents |
|=.foswikiSearchResultContents= | Search result content, such as title, summary, author |
|=.foswikiSearchResultCount= | Search results count |
|=.foswikiSearchResultImage= | Container around image (=img= tag) in Search results |
|=.foswikiSearchResultMeta= | Search result meta data such as author name, date |
|=.foswikiSearchResultTitle= | Search result title |
|=.foswikiSearchResults= | List of search results |
|=.foswikiListItem= | Container around list item |
|=.foswikiListItemImage= | Container around image (=img= tag) in list item |
|=.foswikiListItemTitle= | List item title |
|=.foswikiListItemContents= | List item content, such as summary and =foswikiListItemMeta= |
|=.foswikiListItemMeta= | List item meta data such as author name, date |
|=.foswikiSearchResultsHeader= | Search results header with search string, number of hits |
|=.foswikiSearchResultsPager= | Search results pagination |
|=.foswikiSummary= | Topic or list item summary |
Expand All @@ -157,14 +157,8 @@ See also: [[#HtmlFormElements][HTML form elements]]
|=.foswikiBottomRow= | Last row in search results |
|=.foswikiSRRev= | Revision number in search results listing |
|=.foswikiSRAuthor= | Author in search results listing |
|=.foswikiSearchResultCount= | Search results count |
|=#foswikiNumberOfResultsContainer= | See [[%TOPIC%#BehaviourClasses][Behaviour classes]] below |
|=.foswikiWebSearchForm= | Container around the search form |
|=.foswikiSearchResult= | %INCLUDE{"%TOPIC%" section="deprecated" version="2.0" alternative=".foswikiListItem"}% |
|=.foswikiSearchResultImage= | %INCLUDE{"%TOPIC%" section="deprecated" version="2.0" alternative=".foswikiListItemImage"}% |
|=.foswikiSearchResultTitle= | %INCLUDE{"%TOPIC%" section="deprecated" version="2.0" alternative=".foswikiListItemTitle"}% |
|=.foswikiSearchResultContents= | %INCLUDE{"%TOPIC%" section="deprecated" version="2.0" alternative=".foswikiListItemContents"}% |
|=.foswikiSearchResultMeta= | %INCLUDE{"%TOPIC%" section="deprecated" version="2.0" alternative=".foswikiListItemMeta"}% |</sticky>
|=.foswikiWebSearchForm= | Container around the search form |</sticky>

---+++ Other elements
<sticky>
Expand All @@ -178,8 +172,7 @@ See also: [[#HtmlFormElements][HTML form elements]]
|=.foswikiEditboxStyleMono= | Gives the edit textarea monospaced font (not used with WYSWIWYG) |
|=.foswikiEditboxStyleProportional= | Gives the edit textarea proportional font (not used with WYSWIWYG) |
|=p.foswikiAllowNonWikiWord= | Message "Allow non <nop>WikiWord for the new topic name" |
|=.foswikiIcon= | Icon image; span around image or the image itself |
|=.foswikiActionFormStepSign= | %INCLUDE{"%TOPIC%" section="deprecated" version="2.0"}% - indicator for each form step (see =.foswikiFormStep=) |</sticky>
|=.foswikiIcon= | Icon image; span around image or the image itself |</sticky>

---+++ History
<sticky>
Expand Down
4 changes: 2 additions & 2 deletions core/data/System/VarQUERY.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1434650530" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1437230349" format="1.1" version="1"}%
%META:TOPICPARENT{name="Macros"}%
---+ QUERY -- get the value of meta-data
Uses the query syntax described in [[%SYSTEMWEB%.QuerySearch][QuerySearch]] to get information about meta-data from one specified topic.
Expand Down Expand Up @@ -48,5 +48,5 @@ Only some configuration settings are available via QUERY: %FORMAT{"%QUERY{"{Acce

%STOPINCLUDE%
---++ Related
[[VarMETA][META]] [[!QuerySearch][QuerySearch]]
[[VarMETA][META]] [[QuerySearch][QuerySearch]]
<!--%JQREQUIRE{"chili"}%-->
4 changes: 2 additions & 2 deletions core/data/System/VarREVINFO.txt
@@ -1,4 +1,4 @@
%META:TOPICINFO{author="ProjectContributor" date="1434650530" format="1.1" version="1"}%
%META:TOPICINFO{author="ProjectContributor" date="1437230349" format="1.1" version="1"}%
%META:TOPICPARENT{name="Macros"}%
---+ REVINFO -- revision information of current topic
=%<nop>REVINFO%= is equivalent to =%<nop>REVINFO{format="r1.$rev - $date - $wikiusername"}%=
Expand All @@ -24,7 +24,7 @@ Supported formatting tokens:
| =$date= | Revision date. Actual date format defined as {DefaultDateFormat} in [[%SCRIPTURLPATH{"configure"}%][configure]] |
| =$time= | Revision time |
| =$iso= | Revision date in ISO date format |
!| =$min=, =$sec=, etc. | Same date format qualifiers as [[VarGMTIME][GMTIME{"format"}]] |
| =$min=, =$sec=, etc. | Same date format qualifiers as [[VarGMTIME][GMTIME{"format"}]] |
---++ Examples
* <verbatim class="tml">%REVINFO{"$date - $wikiusername" rev="43"}%</verbatim>
* To get the latest revision, even when looking at an older revision: <verbatim class="tml">%REVINFO{"$rev" rev="-1"}%</verbatim>
Expand Down

0 comments on commit b825ac4

Please sign in to comment.