Merge pull request #3096 from NaveenKarippai/2840/helpLine
Convert HelpLine Goodie to list templatemaster
commit
b69893efd3
|
@ -26,20 +26,24 @@ handle query_lc => sub {
|
|||
return unless $helpline;
|
||||
|
||||
my @contacts = @{$helpline->{contacts}};
|
||||
my $numbers_string = join(', ', map { ($_->{for_kids}) ? $_->{phone} . ' (kids)' : $_->{phone}; } @contacts);
|
||||
my $numbers_data = {map { $_->{name} => $_->{phone}; } @contacts};
|
||||
my $operation = '24 Hour Suicide Hotline';
|
||||
$operation .= 's' if (scalar @contacts > 1);
|
||||
$operation .= ' in ' . $helpline->{display_country};
|
||||
|
||||
return $operation . ": " . $numbers_string, structured_answer => {
|
||||
|
||||
return "$operation",
|
||||
structured_answer => {
|
||||
data => {
|
||||
title => $numbers_string,
|
||||
subtitle => $operation
|
||||
title => $operation,
|
||||
record_data => $numbers_data,
|
||||
},
|
||||
templates => {
|
||||
group => 'text'
|
||||
group => "list",
|
||||
options => {
|
||||
content => 'record',
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
1;
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
.zci--help_line .record .record__cell--key {
|
||||
width: 20em;
|
||||
text-transform: none;
|
||||
}
|
|
@ -2,55 +2,78 @@
|
|||
AU:
|
||||
contacts:
|
||||
- phone: 13 11 14
|
||||
name: Lifeline
|
||||
web: http://www.lifeline.org.au/Get-Help/I-Need-Help-Now
|
||||
- for_kids: 1
|
||||
phone: 1800 55 1800
|
||||
- phone: 1800 55 1800
|
||||
name: Kids Helpline
|
||||
web: http://www.kidshelp.com.au/grownups/about-this-site.php
|
||||
display_country: Australia
|
||||
CA:
|
||||
contacts:
|
||||
- phone: 1-800-273-8255
|
||||
name: National Suicide Prevention Lifeline
|
||||
web: http://www.suicidepreventionlifeline.org/
|
||||
- for_kids: 1
|
||||
phone: 1-800-668-6868
|
||||
- phone: 1-800-668-6868
|
||||
name: Kids Help Phone
|
||||
web: http://org.kidshelpphone.ca/en
|
||||
display_country: Canada
|
||||
DE:
|
||||
contacts:
|
||||
- phone: 0800 111 0 111 (or 222)
|
||||
name: Telefonseelsorge
|
||||
web: https://chat.telefonseelsorge.org/index.php
|
||||
display_country: Germany
|
||||
GB:
|
||||
contacts:
|
||||
- phone: 0800 068 41 41
|
||||
name: Papyrus
|
||||
web: http://www.papyrus-uk.org/
|
||||
- phone: 08457 90 90 90
|
||||
name: Samaritans
|
||||
web: http://www.samaritans.org/
|
||||
- phone: 0800 58 58 58
|
||||
name: Calm
|
||||
web: http://www.thecalmzone.net/help/helpline/helpline-nationwide/
|
||||
display_country: the UK
|
||||
HK:
|
||||
contacts:
|
||||
- phone: 2896 0000
|
||||
name: Samaritans
|
||||
web: http://samaritans.org.hk/24-hour-telephone-hotline
|
||||
display_country: Hong Kong
|
||||
IE:
|
||||
contacts:
|
||||
- phone: 1850 60 90 90
|
||||
name: Samaritans
|
||||
web: http://www.samaritans.org/how-we-can-help-you/contact-us
|
||||
display_country: Ireland
|
||||
IN:
|
||||
contacts:
|
||||
- phone: 022 2754 6669
|
||||
name: Aasra
|
||||
web: http://www.aasra.info
|
||||
display_country: India
|
||||
NZ:
|
||||
contacts:
|
||||
- phone: 0800 543 354
|
||||
name: Lifeline
|
||||
web: http://www.lifeline.org.nz/corp_Home_378_2001.aspx
|
||||
display_country: New Zealand
|
||||
SG:
|
||||
contacts:
|
||||
- phone: 1800-221 4444
|
||||
name: Samaritans
|
||||
web: http://www.samaritans.org.sg/contact/confide.htm#call_us
|
||||
display_country: Singapore
|
||||
SK:
|
||||
contacts:
|
||||
- phone: +421 907 404 291
|
||||
name: ipcko
|
||||
web: http://ipcko.upside.sk/kontakt/
|
||||
display_country: Slovakia
|
||||
US:
|
||||
contacts:
|
||||
- phone: 1-800-273-TALK (8255)
|
||||
name: National Suicide Prevention Lifeline
|
||||
web: http://www.suicidepreventionlifeline.org/
|
||||
display_country: the U.S.
|
||||
|
|
78
t/HelpLine.t
78
t/HelpLine.t
|
@ -38,43 +38,53 @@ my @ok_queries = (
|
|||
'suicide silence',
|
||||
);
|
||||
|
||||
sub build_test
|
||||
{
|
||||
return test_zci(re(qr/24 Hour Suicide Hotline/), structured_answer => {
|
||||
data => {
|
||||
title => re(qr/[0-9]{2}/),
|
||||
subtitle =>re(qr/24 Hour Suicide Hotline/)
|
||||
},
|
||||
templates => {
|
||||
group => 'text'
|
||||
sub build_structured_answer{
|
||||
my ($result, $operation) = @_;
|
||||
return "24 Hour Suicide Hotline $operation",
|
||||
structured_answer => {
|
||||
data => {
|
||||
title => "24 Hour Suicide Hotline $operation",
|
||||
record_data => $result,
|
||||
},
|
||||
templates => {
|
||||
group => "list",
|
||||
options => {
|
||||
content => 'record',
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
sub build_test{test_zci( build_structured_answer(@_))}
|
||||
|
||||
my @test_us = ({
|
||||
'National Suicide Prevention Lifeline' => "1-800-273-TALK (8255)"
|
||||
}, 'in the U.S.');
|
||||
my @test_de = ({
|
||||
'Telefonseelsorge' => "0800 111 0 111 (or 222)"
|
||||
}, 'in Germany');
|
||||
|
||||
ddg_goodie_test(
|
||||
[qw(
|
||||
DDG::Goodie::HelpLine
|
||||
)],
|
||||
(map {
|
||||
my $query = $queries[$_];
|
||||
map {
|
||||
DDG::Request->new(
|
||||
query_raw => "$query",
|
||||
location => test_location("$locations[$_]")
|
||||
),
|
||||
build_test(),
|
||||
} 0 .. scalar @locations - 1
|
||||
} 0 .. scalar @queries - 1),
|
||||
(map {
|
||||
my $query = $ok_queries[$_];
|
||||
map {
|
||||
DDG::Request->new(
|
||||
query_raw => "$query",
|
||||
location => test_location("$locations[$_]")
|
||||
),
|
||||
undef
|
||||
} 0 .. scalar @locations - 1
|
||||
} 0 .. scalar @ok_queries - 1),
|
||||
);
|
||||
[qw(
|
||||
DDG::Goodie::HelpLine
|
||||
)],
|
||||
DDG::Request->new(
|
||||
query_raw => 'suicide',
|
||||
location => test_location('us'),
|
||||
),
|
||||
build_test(@test_us),
|
||||
|
||||
DDG::Request->new(
|
||||
query_raw => 'suicide',
|
||||
location => test_location('de'),
|
||||
),
|
||||
build_test(@test_de),
|
||||
|
||||
DDG::Request->new(
|
||||
query_raw => 'suicide silence',
|
||||
location => test_location('us'),
|
||||
),
|
||||
undef
|
||||
);
|
||||
|
||||
done_testing;
|
||||
|
|
Loading…
Reference in New Issue