aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlouise <louise>2009-09-23 17:01:00 +0000
committerlouise <louise>2009-09-23 17:01:00 +0000
commitc2c5be29c47584ea0aff8934ee7a796f30bb35b2 (patch)
tree07ba92d114f17d5b53bbedad65bd13d352b63e82
parenta6e0574642c9b6aa0f4d3c43bba1f12b56bfdfa5 (diff)
Delegate setting of site title to cobrands
-rw-r--r--perllib/Cobrand.pm26
-rw-r--r--perllib/Cobrands/Emptyhomes/Util.pm13
-rw-r--r--perllib/Page.pm4
-rwxr-xr-xt/Cobrand.t21
-rw-r--r--t/Cobrands/Mysite/Util.pm7
5 files changed, 61 insertions, 10 deletions
diff --git a/perllib/Cobrand.pm b/perllib/Cobrand.pm
index e170ec87d..f450304b5 100644
--- a/perllib/Cobrand.pm
+++ b/perllib/Cobrand.pm
@@ -7,7 +7,7 @@
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: louise@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: Cobrand.pm,v 1.21 2009-09-23 15:43:54 louise Exp $
+# $Id: Cobrand.pm,v 1.22 2009-09-23 17:01:00 louise Exp $
package Cobrand;
use strict;
@@ -365,12 +365,14 @@ sub header_params {
}
}
-=item root_path_pattern COBRAND
+=item root_path_js COBRAND
+
+Return some js to set the root path from which AJAX queries should be made
=cut
sub root_path_js {
- my ($cobrand) = @_;
+ my ($cobrand) = @_;
my $handle;
if ($cobrand){
$handle = cobrand_handle($cobrand);
@@ -382,6 +384,24 @@ sub root_path_js {
}
}
+=item site_title COBRAND
+
+Return the title to be used in page heads.
+
+=cut
+sub site_title {
+ my ($cobrand) = @_;
+ my $handle;
+ if ($cobrand){
+ $handle = cobrand_handle($cobrand);
+ }
+ if ( !$cobrand || !$handle || !$handle->can('site_title')){
+ return '';
+ } else{
+ return $handle->site_title();
+ }
+}
+
1;
diff --git a/perllib/Cobrands/Emptyhomes/Util.pm b/perllib/Cobrands/Emptyhomes/Util.pm
index 8dbeca4b4..3c02f08f3 100644
--- a/perllib/Cobrands/Emptyhomes/Util.pm
+++ b/perllib/Cobrands/Emptyhomes/Util.pm
@@ -7,7 +7,7 @@
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: louise@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: Util.pm,v 1.4 2009-09-09 15:29:27 louise Exp $
+# $Id: Util.pm,v 1.5 2009-09-23 17:01:00 louise Exp $
package Cobrands::Emptyhomes::Util;
use Standard;
@@ -84,5 +84,16 @@ sub set_lang_and_domain{
mySociety::Locale::change();
}
+=item site_title
+
+Return the title to be used in page heads
+
+=cut
+
+sub site_title {
+ my ($self) = @_;
+ return _('Report Empty Homes');
+}
+
1;
diff --git a/perllib/Page.pm b/perllib/Page.pm
index b4ca97f3a..ffd8d3945 100644
--- a/perllib/Page.pm
+++ b/perllib/Page.pm
@@ -6,7 +6,7 @@
# Copyright (c) 2006 UK Citizens Online Democracy. All rights reserved.
# Email: matthew@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Page.pm,v 1.183 2009-09-23 15:43:54 louise Exp $
+# $Id: Page.pm,v 1.184 2009-09-23 17:01:00 louise Exp $
#
package Page;
@@ -184,7 +184,7 @@ sub template_vars ($$){
'alert' => _('Local alerts'),
'faq' => _('Help'),
'about' => _('About us'),
- 'site_title' => _('Report Empty Homes'),
+ 'site_title' => Cobrand::site_title(get_cobrand($q)),
'host' => $host,
'lang_code' => $lang,
'lang' => $lang eq 'en-gb' ? 'Cymraeg' : 'English',
diff --git a/t/Cobrand.t b/t/Cobrand.t
index 8a5c69c95..f0f1751a0 100755
--- a/t/Cobrand.t
+++ b/t/Cobrand.t
@@ -6,12 +6,12 @@
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: louise@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Cobrand.t,v 1.12 2009-09-23 15:43:54 louise Exp $
+# $Id: Cobrand.t,v 1.13 2009-09-23 17:01:00 louise Exp $
#
use strict;
use warnings;
-use Test::More tests => 38;
+use Test::More tests => 41;
use Test::Exception;
use FindBin;
@@ -171,12 +171,25 @@ sub test_root_path_js {
# should get the results of the root_path_js function in the cobrand module if one exists
is($root_path_js, 'root path js', 'root_path_js returns output from cobrand module');
- # should return an empty regex string otherwise
+ # should return a js string setting the root path to an empty string otherwise
$cobrand = 'nosite';
$root_path_js = Cobrand::root_path_js($cobrand);
is($root_path_js, 'var root_path = "";', 'root_path_pattern returns a string setting the root path to an empty string if no cobrand module');
}
+sub test_site_title {
+ my $cobrand = 'mysite';
+ my $site_title = Cobrand::site_title($cobrand);
+
+ # should get the results of the site_title function in the cobrand module if one exists
+ is($site_title, 'Mysite Title', 'site_title returns output from cobrand module');
+
+ # should return an empty string otherwise
+ $cobrand = 'nosite';
+ $site_title = Cobrand::site_title($cobrand);
+ is($site_title, '', 'site_title returns an empty string if no site title');
+}
+
ok(test_cobrand_handle() == 1, 'Ran all tests for the cobrand_handle function');
ok(test_cobrand_page() == 1, 'Ran all tests for the cobrand_page function');
ok(test_site_restriction() == 1, 'Ran all tests for the site_restriction function');
@@ -189,3 +202,5 @@ ok(test_extra_update_data() == 1, 'Ran all tests for extra_update_data');
ok(test_extra_params() == 1, 'Ran all tests for extra_params');
ok(test_header_params() == 1, 'Ran all tests for header_params');
ok(test_root_path_js() == 1, 'Ran all tests for root_js');
+ok(test_site_title() == 1, 'Ran all tests for site_title');
+
diff --git a/t/Cobrands/Mysite/Util.pm b/t/Cobrands/Mysite/Util.pm
index 9cac84ca8..370e9d700 100644
--- a/t/Cobrands/Mysite/Util.pm
+++ b/t/Cobrands/Mysite/Util.pm
@@ -7,7 +7,7 @@
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: louise@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: Util.pm,v 1.11 2009-09-23 15:43:54 louise Exp $
+# $Id: Util.pm,v 1.12 2009-09-23 17:01:00 louise Exp $
package Cobrands::Mysite::Util;
use Page;
@@ -70,4 +70,9 @@ sub header_params {
sub root_path_js {
return 'root path js';
}
+
+sub site_title {
+ return 'Mysite Title';
+}
+
1;