From e7a840ed9a817cf4db59c90e680afd89e146b581 Mon Sep 17 00:00:00 2001
From: Simon McVittie
Date: Sun, 16 Nov 2008 18:11:39 +0000
Subject: htmlbalance: new plugin that balances tags by parsing and
re-serializing
---
t/htmlbalance.t | 13 +++++++++++++
1 file changed, 13 insertions(+)
create mode 100755 t/htmlbalance.t
(limited to 't')
diff --git a/t/htmlbalance.t b/t/htmlbalance.t
new file mode 100755
index 000000000..cd124e473
--- /dev/null
+++ b/t/htmlbalance.t
@@ -0,0 +1,13 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use Test::More tests => 7;
+
+BEGIN { use_ok("IkiWiki::Plugin::htmlbalance"); }
+
+is(IkiWiki::Plugin::htmlbalance::sanitize(content => "
"), "
");
+is(IkiWiki::Plugin::htmlbalance::sanitize(content => "
"), "");
+is(IkiWiki::Plugin::htmlbalance::sanitize(content => ""), "");
+is(IkiWiki::Plugin::htmlbalance::sanitize(content => "foo "), "foo ");
+is(IkiWiki::Plugin::htmlbalance::sanitize(content => " foo "), " foo ");
+is(IkiWiki::Plugin::htmlbalance::sanitize(content => "a>"), "a>");
--
cgit v1.2.3
From 43039d7d86ea66578743867a0b1d484e65816bb2 Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Mon, 17 Nov 2008 14:22:11 -0500
Subject: modify to skip tests if the neccessary perl modules are not available
---
t/htmlbalance.t | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
(limited to 't')
diff --git a/t/htmlbalance.t b/t/htmlbalance.t
index cd124e473..783ed9841 100755
--- a/t/htmlbalance.t
+++ b/t/htmlbalance.t
@@ -1,9 +1,20 @@
#!/usr/bin/perl
use warnings;
use strict;
-use Test::More tests => 7;
-BEGIN { use_ok("IkiWiki::Plugin::htmlbalance"); }
+BEGIN {
+ eval q{
+ use HTML::TreeBuilder;
+ use XML::Atom::Util qw(encode_xml);
+ };
+ if ($@) {
+ eval q{use Test::More skip_all => "HTML::TreeBuilder or XML::Atom::Util not available"};
+ }
+ else {
+ eval q{use Test::More tests => 7};
+ }
+ use_ok("IkiWiki::Plugin::htmlbalance");
+}
is(IkiWiki::Plugin::htmlbalance::sanitize(content => "
"), "
");
is(IkiWiki::Plugin::htmlbalance::sanitize(content => ""), "");
--
cgit v1.2.3
From 181bdbe1a9a8a1eb07259466361d98bdc1378499 Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Mon, 17 Nov 2008 14:27:11 -0500
Subject: use HTML::Entities
---
IkiWiki/Plugin/htmlbalance.pm | 4 ++--
doc/plugins/htmlbalance/discussion.mdwn | 2 ++
t/htmlbalance.t | 3 +--
3 files changed, 5 insertions(+), 4 deletions(-)
(limited to 't')
diff --git a/IkiWiki/Plugin/htmlbalance.pm b/IkiWiki/Plugin/htmlbalance.pm
index 8f43d5dac..3a2d62d15 100644
--- a/IkiWiki/Plugin/htmlbalance.pm
+++ b/IkiWiki/Plugin/htmlbalance.pm
@@ -11,7 +11,7 @@ use warnings;
use strict;
use IkiWiki 2.00;
use HTML::TreeBuilder;
-use XML::Atom::Util qw(encode_xml);
+use HTML::Entities;
sub import { #{{{
hook(type => "getsetup", id => "htmlbalance", call => \&getsetup);
@@ -39,7 +39,7 @@ sub sanitize (@) { #{{{
$node->delete();
}
else {
- $ret .= encode_xml($node);
+ $ret .= encode_entities($node);
}
}
$tree->delete();
diff --git a/doc/plugins/htmlbalance/discussion.mdwn b/doc/plugins/htmlbalance/discussion.mdwn
index bad052f1c..c66528a4f 100644
--- a/doc/plugins/htmlbalance/discussion.mdwn
+++ b/doc/plugins/htmlbalance/discussion.mdwn
@@ -2,6 +2,8 @@ Would it be possible to use [[!cpan HTML::Entities]] rather than
`XML::Atom::Util` for encoding entities? The former is already an ikiwiki
dependency (via [[!cpan HTML::Parser]]).
+> Now switched to HTML::Entities --[[Joey]]
+
I also wonder if there's any benefit to using this plugin aside from with
aggregate. Perhaps a small one but aggregate seems like the main case..
wondering if it would be better to just have aggregate balanace the html
diff --git a/t/htmlbalance.t b/t/htmlbalance.t
index 783ed9841..e5a5db0ee 100755
--- a/t/htmlbalance.t
+++ b/t/htmlbalance.t
@@ -5,10 +5,9 @@ use strict;
BEGIN {
eval q{
use HTML::TreeBuilder;
- use XML::Atom::Util qw(encode_xml);
};
if ($@) {
- eval q{use Test::More skip_all => "HTML::TreeBuilder or XML::Atom::Util not available"};
+ eval q{use Test::More skip_all => "HTML::TreeBuilder not available"};
}
else {
eval q{use Test::More tests => 7};
--
cgit v1.2.3
From c42f174e655526bfaace70b31f9cbc79e2e1be9a Mon Sep 17 00:00:00 2001
From: Simon McVittie
Date: Sun, 21 Dec 2008 15:24:53 +0000
Subject: beautify_urlpath: add a regression test
---
t/beautify_urlpath.t | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
create mode 100755 t/beautify_urlpath.t
(limited to 't')
diff --git a/t/beautify_urlpath.t b/t/beautify_urlpath.t
new file mode 100755
index 000000000..b9d3493a2
--- /dev/null
+++ b/t/beautify_urlpath.t
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+use Test::More tests => 7;
+
+BEGIN { use_ok("IkiWiki"); }
+
+$IkiWiki::config{usedirs} = 1;
+$IkiWiki::config{htmlext} = "HTML";
+is(IkiWiki::beautify_urlpath("foo/bar"), "./foo/bar");
+is(IkiWiki::beautify_urlpath("../badger"), "../badger");
+is(IkiWiki::beautify_urlpath("./bleh"), "./bleh");
+is(IkiWiki::beautify_urlpath("foo/index.HTML"), "./foo/");
+is(IkiWiki::beautify_urlpath("index.HTML"), "./");
+$IkiWiki::config{usedirs} = 0;
+is(IkiWiki::beautify_urlpath("foo/index.HTML"), "./foo/index.HTML");
--
cgit v1.2.3
From f0c76aa51ca7a1dbfb8fcfa679baa114e563b895 Mon Sep 17 00:00:00 2001
From: Simon McVittie
Date: Sun, 21 Dec 2008 16:37:20 +0000
Subject: Add a regression test for &openiduser
---
t/openiduser.t | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
create mode 100755 t/openiduser.t
(limited to 't')
diff --git a/t/openiduser.t b/t/openiduser.t
new file mode 100755
index 000000000..fe4d2b445
--- /dev/null
+++ b/t/openiduser.t
@@ -0,0 +1,30 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+BEGIN {
+ eval q{
+ use Net::OpenID::VerifiedIdentity;
+ };
+ if ($@) {
+ eval q{use Test::More skip_all => "Net::OpenID::VerifiedIdentity not available"};
+ }
+ else {
+ eval q{use Test::More tests => 9};
+ }
+ use_ok("IkiWiki::Plugin::openid");
+}
+
+# Some typical examples:
+
+is(IkiWiki::openiduser('http://josephturian.blogspot.com'), 'josephturian [blogspot.com]');
+is(IkiWiki::openiduser('http://yam655.livejournal.com/'), 'yam655 [livejournal.com]');
+is(IkiWiki::openiduser('http://id.mayfirst.org/jamie/'), 'jamie [id.mayfirst.org]');
+
+# and some less typical ones taken from the ikiwiki commit history
+
+is(IkiWiki::openiduser('http://thm.id.fedoraproject.org/'), 'thm [id.fedoraproject.org]');
+is(IkiWiki::openiduser('http://dtrt.org/'), 'dtrt.org');
+is(IkiWiki::openiduser('http://alcopop.org/me/openid/'), 'openid [alcopop.org/me]');
+is(IkiWiki::openiduser('http://id.launchpad.net/882/bielawski1'), 'bielawski1 [id.launchpad.net/882]');
+is(IkiWiki::openiduser('http://technorati.com/people/technorati/drajt'), 'drajt [technorati.com/people/technorati]');
--
cgit v1.2.3
From 5b67c54b2276f053ea0a427597334e0808694727 Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Sun, 21 Dec 2008 12:59:11 -0500
Subject: add another test
---
t/beautify_urlpath.t | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
(limited to 't')
diff --git a/t/beautify_urlpath.t b/t/beautify_urlpath.t
index b9d3493a2..94b923d3b 100755
--- a/t/beautify_urlpath.t
+++ b/t/beautify_urlpath.t
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use warnings;
use strict;
-use Test::More tests => 7;
+use Test::More tests => 8;
BEGIN { use_ok("IkiWiki"); }
@@ -12,5 +12,6 @@ is(IkiWiki::beautify_urlpath("../badger"), "../badger");
is(IkiWiki::beautify_urlpath("./bleh"), "./bleh");
is(IkiWiki::beautify_urlpath("foo/index.HTML"), "./foo/");
is(IkiWiki::beautify_urlpath("index.HTML"), "./");
+is(IkiWiki::beautify_urlpath("../index.HTML"), "../");
$IkiWiki::config{usedirs} = 0;
is(IkiWiki::beautify_urlpath("foo/index.HTML"), "./foo/index.HTML");
--
cgit v1.2.3
From 13d77c369e5c2856fad78e48b0e39e4e76d1d5aa Mon Sep 17 00:00:00 2001
From: Joey Hess
Date: Sun, 21 Dec 2008 13:46:00 -0500
Subject: avoid an uninitialized value warning
---
t/openiduser.t | 7 +++++++
1 file changed, 7 insertions(+)
(limited to 't')
diff --git a/t/openiduser.t b/t/openiduser.t
index fe4d2b445..52d879484 100755
--- a/t/openiduser.t
+++ b/t/openiduser.t
@@ -17,7 +17,14 @@ BEGIN {
# Some typical examples:
+# This test, when run by Test::Harness using perl -w, exposes a warning in
+# Net::OpenID::VerifiedIdentity. Normally that warning is not displayed, as
+# that module does not use warnings. To avoid cluttering the test output,
+# disable the -w switch temporarily.
+$^W=0;
is(IkiWiki::openiduser('http://josephturian.blogspot.com'), 'josephturian [blogspot.com]');
+$^W=1;
+
is(IkiWiki::openiduser('http://yam655.livejournal.com/'), 'yam655 [livejournal.com]');
is(IkiWiki::openiduser('http://id.mayfirst.org/jamie/'), 'jamie [id.mayfirst.org]');
--
cgit v1.2.3