Author: kake
Date: 2012-03-20 12:16:15 +0000 (Tue, 20 Mar 2012)
New Revision: 1316
Modified:
trunk/t/34_search_paging.t
Log:
Skip the right number of tests.
Modified: trunk/t/34_search_paging.t
===================================================================
--- trunk/t/34_search_paging.t 2012-03-18 09:48:44 UTC (rev 1315)
+++ trunk/t/34_search_paging.t 2012-03-20 12:16:15 UTC (rev 1316)
@@ -30,7 +30,7 @@
# Test with OS co-ords.
eval { require Geo::Coordinates::OSGB; };
SKIP: {
- skip "Geo::Coordinates::OSGB not installed", 3 if $@;
+ skip "Geo::Coordinates::OSGB not installed", 6 if $@;
$config->geo_handler( 1 );
foreach my $i ( 1 .. 50 ) {
@@ -69,7 +69,7 @@
# Test with OSIE co-ords.
eval { require Geo::Coordinates::ITM; };
SKIP: {
- skip "Geo::Coordinates::ITM not installed", 3 if $@;
+ skip "Geo::Coordinates::ITM not installed", 6 if $@;
# We must create a new search object after changing the geo_handler
# in order to force it to create a fresh locator.
@@ -111,7 +111,7 @@
# Test with UTM.
eval { require Geo::Coordinates::UTM; };
SKIP: {
- skip "Geo::Coordinates::UTM not installed", 3 if $@;
+ skip "Geo::Coordinates::UTM not installed", 6 if $@;
# We must create a new search object after changing the geo_handler
# in order to force it to create a fresh locator.
Author: kake
Date: 2012-03-16 15:53:42 +0000 (Fri, 16 Mar 2012)
New Revision: 1313
Modified:
trunk/newpage.cgi
trunk/preferences.cgi
trunk/search.cgi
trunk/wiki.cgi
Log:
Removed trailing whitespace that's been annoying me for ages.
Modified: trunk/newpage.cgi
===================================================================
--- trunk/newpage.cgi 2012-03-14 17:14:30 UTC (rev 1312)
+++ trunk/newpage.cgi 2012-03-16 15:53:42 UTC (rev 1313)
@@ -2,8 +2,7 @@
use warnings;
use strict;
-use sigtrap die => 'normal-signals';
-
+use sigtrap die => 'normal-signals';
use CGI;
use OpenGuides::Config;
use OpenGuides::Template;
Modified: trunk/preferences.cgi
===================================================================
--- trunk/preferences.cgi 2012-03-14 17:14:30 UTC (rev 1312)
+++ trunk/preferences.cgi 2012-03-16 15:53:42 UTC (rev 1313)
@@ -2,8 +2,7 @@
use warnings;
use strict;
-use sigtrap die => 'normal-signals';
-
+use sigtrap die => 'normal-signals';
use CGI;
use OpenGuides::Config;
use OpenGuides::CGI;
Modified: trunk/search.cgi
===================================================================
--- trunk/search.cgi 2012-03-14 17:14:30 UTC (rev 1312)
+++ trunk/search.cgi 2012-03-16 15:53:42 UTC (rev 1313)
@@ -2,8 +2,7 @@
use warnings;
use strict;
-use sigtrap die => 'normal-signals';
-
+use sigtrap die => 'normal-signals';
use CGI;
use OpenGuides::Config;
use OpenGuides::Search;
Modified: trunk/wiki.cgi
===================================================================
--- trunk/wiki.cgi 2012-03-14 17:14:30 UTC (rev 1312)
+++ trunk/wiki.cgi 2012-03-16 15:53:42 UTC (rev 1313)
@@ -2,8 +2,7 @@
use strict;
use warnings;
-use sigtrap die => 'normal-signals';
-
+use sigtrap die => 'normal-signals';
use vars qw( $VERSION );
$VERSION = '0.65';
Author: kake
Date: 2012-03-14 17:14:30 +0000 (Wed, 14 Mar 2012)
New Revision: 1312
Added:
trunk/t/91_username_in_templates.t
Modified:
trunk/Changes
trunk/MANIFEST
trunk/lib/OpenGuides/Template.pm
trunk/preferences.cgi
Log:
Made the 'username' TT variable accessible to all templates.
Modified: trunk/Changes
===================================================================
--- trunk/Changes 2012-03-13 17:24:05 UTC (rev 1311)
+++ trunk/Changes 2012-03-14 17:14:30 UTC (rev 1312)
@@ -4,6 +4,7 @@
<http://dev.openguides.org/log/trunk>.
0.66 ?
+ All templates now have access to the "username" TT variable.
Add CSS classes for each category and locale to the "content" div
(and hence we now require version 2.24 of Template).
Switch to using Geo::Coordinates::OSGB/ITM instead of
Modified: trunk/MANIFEST
===================================================================
--- trunk/MANIFEST 2012-03-13 17:24:05 UTC (rev 1311)
+++ trunk/MANIFEST 2012-03-14 17:14:30 UTC (rev 1312)
@@ -155,6 +155,7 @@
t/85_universal_edit_link.t
t/86_recent_changes.t
t/90_css_category_locale_classes.t
+t/91_username_in_templates.t
t/templates/15_test.tt
wiki.cgi
META.json
Modified: trunk/lib/OpenGuides/Template.pm
===================================================================
--- trunk/lib/OpenGuides/Template.pm 2012-03-13 17:24:05 UTC (rev 1311)
+++ trunk/lib/OpenGuides/Template.pm 2012-03-14 17:14:30 UTC (rev 1312)
@@ -190,10 +190,20 @@
$tt_vars->{node_param} = CGI->escape($args{wiki}->formatter->node_name_to_node_param($args{node}));
}
- # Now set further TT variables if explicitly supplied - do this last
- # as these override auto-set ones.
+ # Now set further TT variables if explicitly supplied - do this after the
+ # above auto-setting as these override auto-set ones.
$tt_vars = { %$tt_vars, %{ $args{vars} || {} } };
+ # Finally, dig out the username from the cookie if we haven't already
+ # been sent it in vars.
+ if ( !$tt_vars->{username} ) {
+ my %prefs = OpenGuides::CGI->get_prefs_from_cookie(config => $config);
+ # If there's nothing in there, it defaults to "Anonymous".
+ if ( $prefs{username} ne "Anonymous" ) {
+ $tt_vars->{username} = $prefs{username};
+ }
+ }
+
my $header = "";
unless ( $args{noheaders} ) {
Modified: trunk/preferences.cgi
===================================================================
--- trunk/preferences.cgi 2012-03-13 17:24:05 UTC (rev 1311)
+++ trunk/preferences.cgi 2012-03-14 17:14:30 UTC (rev 1312)
@@ -38,6 +38,8 @@
);
push @cookies, $rc_cookie;
}
+ # We have to send the username to OpenGuides::Template because they might
+ # have changed it, in which case it won't be in the cookie yet.
print OpenGuides::Template->output(
wiki => $wiki,
config => $config,
@@ -46,6 +48,7 @@
vars => {
not_editable => 1,
not_deletable => 1,
+ username => $prefs{username},
}
);
}
Added: trunk/t/91_username_in_templates.t
===================================================================
--- trunk/t/91_username_in_templates.t (rev 0)
+++ trunk/t/91_username_in_templates.t 2012-03-14 17:14:30 UTC (rev 1312)
@@ -0,0 +1,64 @@
+use strict;
+use Cwd;
+use OpenGuides;
+use OpenGuides::CGI;
+use OpenGuides::Test;
+use Test::More;
+
+eval { require DBD::SQLite; };
+if ( $@ ) {
+ my ($error) = $@ =~ /^(.*?)\n/;
+ plan skip_all =>
+ "DBD::SQLite could not be used - no database to test with. ($error)";
+}
+
+plan tests => 2;
+
+my $config = OpenGuides::Test->make_basic_config;
+$config->custom_template_path( cwd . "/t/templates/tmp/" );
+my $guide = OpenGuides->new( config => $config );
+
+# Clear out the database from any previous runs.
+OpenGuides::Test::refresh_db();
+
+# Write a node.
+OpenGuides::Test->write_data(
+ guide => $guide,
+ node => "Ship Of Fools",
+ return_output => 1,
+ );
+
+# Write a custom banner template that includes the username.
+eval {
+ unlink cwd . "/t/templates/tmp/custom_banner.tt";
+};
+
+open( my $fh, ">", cwd . "/t/templates/tmp/custom_banner.tt" ) or die $!;
+print $fh <<EOF;
+<div class="banner_username">
+ [% IF username %]
+ You are logged in as [% username %].
+ [% ELSE %]
+ You are not logged in.
+ [% END %]
+</div>
+EOF
+close $fh or die $!;
+
+# Set a username in the cookie.
+my $cookie = OpenGuides::CGI->make_prefs_cookie(
+ config => $config,
+ username => "Kake",
+);
+$ENV{HTTP_COOKIE} = $cookie;
+
+# Check that username appears if cookie is set.
+my $output = $guide->display_node( id => "Ship Of Fools", return_output => 1 );
+like( $output, qr/You are logged in as Kake./,
+ "username sent to templates if set in prefs cookie" );
+
+# Check that username doesn't appear if cookie not set.
+delete $ENV{HTTP_COOKIE};
+$output = $guide->display_node( id => "Ship Of Fools", return_output => 1 );
+like( $output, qr/You are not logged in./,
+ "...but not if no username is set." );
Author: kake
Date: 2012-03-06 09:35:12 +0000 (Tue, 06 Mar 2012)
New Revision: 1310
Modified:
trunk/Changes
Log:
Documented changes 1306 and 1308, which I forgot to put in the Changes file before.
Modified: trunk/Changes
===================================================================
--- trunk/Changes 2012-03-06 09:31:54 UTC (rev 1309)
+++ trunk/Changes 2012-03-06 09:35:12 UTC (rev 1310)
@@ -4,6 +4,10 @@
<http://dev.openguides.org/log/trunk>.
0.66 ?
+ Switch to using Geo::Coordinates::OSGB/ITM instead of
+ Geography::NationalGrid (which no longer exists on CPAN).
+ Make sure that whitespace is collapsed in autocreated categories
+ and locales, to avoid creating undeletable pages.
Add an autocreate_content.tt template to include a map link in content
for autocreated categories and locales (#275).
Author: kake
Date: 2012-03-05 02:01:37 +0000 (Mon, 05 Mar 2012)
New Revision: 1307
Modified:
trunk/t/19_autocreate.t
Log:
Fixed whitespace/line length.
Modified: trunk/t/19_autocreate.t
===================================================================
--- trunk/t/19_autocreate.t 2012-03-02 21:06:35 UTC (rev 1306)
+++ trunk/t/19_autocreate.t 2012-03-05 02:01:37 UTC (rev 1307)
@@ -7,7 +7,8 @@
eval { require DBD::SQLite; };
if ( $@ ) {
my ($error) = $@ =~ /^(.*?)\n/;
- plan skip_all => "DBD::SQLite could not be used - no database to test with. ($error)";
+ plan skip_all =>
+ "DBD::SQLite could not be used - no database to test with. ($error)";
}
plan tests => 4;
@@ -18,7 +19,7 @@
my $wiki = $guide->wiki;
# Clear out the database from any previous runs.
- OpenGuides::Test::refresh_db();
+OpenGuides::Test::refresh_db();
# Write a custom template to autofill content in autocreated nodes.
eval {