commit
d65cc0ce27
|
@ -0,0 +1,51 @@
|
|||
package DDG::Goodie::DdgShortcuts;
|
||||
# ABSTRACT: Returns a cheat sheet for DuckDuckGo keyboard shortcuts
|
||||
|
||||
use DDG::Goodie;
|
||||
|
||||
zci answer_type => "ddg_shortcuts";
|
||||
zci is_cached => 1;
|
||||
|
||||
name "DDG_Shortcuts";
|
||||
description "DuckDuckGo Shortcuts Cheat Sheet";
|
||||
primary_example_queries "DuckDuckGo shortcuts", "DDG Cheat Sheet";
|
||||
secondary_example_queries "Display DuckDuckGo's keyboard shortcuts";
|
||||
category "cheat_sheets";
|
||||
topics "computing", "geek", "trivia";
|
||||
code_url "https://github.com/duckduckgo/zeroclickinfo-goodies/blob/master/lib/DDG/Goodie/DDGShortcuts.pm";
|
||||
attribution github => ['https://github.com/Qeole','Qeole'],
|
||||
twitter => ['https://twitter.com/qeole','Qeole'];
|
||||
|
||||
my @ddg_aliases = map { (
|
||||
$_ . " ",
|
||||
$_ . "'s ",
|
||||
$_ . "s "
|
||||
) } (
|
||||
'duck duck go',
|
||||
'duckduck go',
|
||||
'duck duckgo',
|
||||
'duckduckgo',
|
||||
'ddg'
|
||||
);
|
||||
my @ddg_shortcuts_triggers = map { (
|
||||
$_.'cheatsheet',
|
||||
$_.'cheat sheet',
|
||||
$_.'keyboard shortcuts',
|
||||
$_.'shortcuts',
|
||||
$_.'shortcuts cheatsheet',
|
||||
$_.'shortcuts cheat sheet'
|
||||
) } @ddg_aliases;
|
||||
|
||||
triggers startend => @ddg_shortcuts_triggers;
|
||||
|
||||
my $TEXT = scalar share('ddg_shortcuts.txt')->slurp(iomode => '<:encoding(UTF-8)'),
|
||||
my $HTML = scalar share('ddg_shortcuts.html')->slurp(iomode => '<:encoding(UTF-8)');
|
||||
|
||||
handle remainder => sub {
|
||||
return
|
||||
heading => "DuckDuckGo Shortcuts Cheat Sheet",
|
||||
answer => $TEXT,
|
||||
html => $HTML,
|
||||
};
|
||||
|
||||
1;
|
|
@ -0,0 +1,50 @@
|
|||
.zci--answer .zero_click_wrapper .zero_click {
|
||||
padding-left: 0px !important;
|
||||
margin-left: 0px !important;
|
||||
margin-right: 0px !important;
|
||||
}
|
||||
|
||||
.zci--answer .ddg_shortcuts-container {
|
||||
max-height: 52ex;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.zci--answer .ddg_shortcuts-column {
|
||||
width: 45%;
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.zci--answer .ddg_shortcuts-column:first-of-type {
|
||||
margin-right: 56px;
|
||||
}
|
||||
|
||||
.zci--answer .ddg_shortcuts-column b {
|
||||
line-height: 220%;
|
||||
}
|
||||
|
||||
.zci--answer table.ddg_shortcuts-table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.zci--answer table.ddg_shortcuts-table td {
|
||||
padding-right: 10px;
|
||||
padding-bottom: 1ex;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.zci--answer table.ddg_shortcuts-table td code {
|
||||
white-space: nowrap;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.zci--answer table.ddg_shortcuts-table tr td:first-child {
|
||||
width: 72px;
|
||||
}
|
||||
|
||||
@media (max-width: 400px) {
|
||||
.zci--answer .ddg_shortcuts-column {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
<div class="ddg_shortcuts-container">
|
||||
<h5>DuckDuckGo shortcuts</h5>
|
||||
<div class="ddg_shortcuts-column">
|
||||
<b>Open results</b>
|
||||
<table class="ddg_shortcuts-table">
|
||||
<tr>
|
||||
<td>
|
||||
<code>↵</code> or <code>l</code> or <code>o</code>
|
||||
</td>
|
||||
<td>Go to the highlighted result, or use it right away to go to the first result</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>Ctrl</code>/<code>⌘</code> + <code>↵</code>
|
||||
</td>
|
||||
<td>Open a result in the background</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>d</code>
|
||||
</td>
|
||||
<td>Domain search (if a result is highlighted)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>'</code> or <code>v</code>
|
||||
</td>
|
||||
<td>Open the highlighted result in a new window/tab. Since this uses JavaScript, you need to turn off pop-up blockers first.</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="ddg_shortcuts-column">
|
||||
<b>Move around</b>
|
||||
<table class="ddg_shortcuts-table">
|
||||
<tr>
|
||||
<td>
|
||||
<code>←</code> or <code>→</code>
|
||||
</td>
|
||||
<td>Navigate instant answer tabs. When an instant answer is open, navigate within the instant answer.</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>↓</code> or <code>j</code>
|
||||
</td>
|
||||
<td>Next search result</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>↑</code> or <code>k</code>
|
||||
</td>
|
||||
<td>Previous search result</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>/</code> or <code>h</code>
|
||||
</td>
|
||||
<td>Go to search box</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>s</code>
|
||||
</td>
|
||||
<td>Go to misspelling link (if any)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>t</code>
|
||||
</td>
|
||||
<td>Go to top</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<code>m</code>
|
||||
</td>
|
||||
<td>Go to main results</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,18 @@
|
|||
~ DuckDuckGo Shortcuts ~
|
||||
|
||||
Open results
|
||||
|
||||
↵ or l or o Go to the highlighted result, or use it right away to go to the first result
|
||||
Ctrl/⌘ + ↵ Open a result in the background
|
||||
d Domain search (if a result is highlighted)
|
||||
' or v Open the highlighted result in a new window/tab. Since this uses JavaScript, you need to turn off pop-up blockers first.
|
||||
|
||||
Move around
|
||||
|
||||
← or → Navigate instant answer tabs. When an instant answer is open, navigate within the instant answer.
|
||||
↓ or j Next search result
|
||||
↑ or k Previous search result
|
||||
/ or h Go to search box
|
||||
s Go to misspelling link (if any)
|
||||
t Go to top
|
||||
m Go to main results
|
|
@ -0,0 +1,126 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More;
|
||||
use DDG::Test::Goodie;
|
||||
|
||||
zci answer_type => "ddg_shortcuts";
|
||||
zci is_cached => 1;
|
||||
|
||||
# This goodie always returns the same answer whenever its triggered
|
||||
my $test_zci = test_zci(
|
||||
qr/^~ DuckDuckGo Shortcuts ~.*Open results.*Move around.*/s,
|
||||
heading => 'DuckDuckGo Shortcuts Cheat Sheet',
|
||||
html => qr#<div(.*<table class="ddg_shortcuts-table".*<tr.*<td.*</table.*)+</div>$#s,
|
||||
);
|
||||
|
||||
ddg_goodie_test(
|
||||
[qw( DDG::Goodie::DdgShortcuts )],
|
||||
|
||||
'duck duck go cheatsheet' => $test_zci, # Generated triggers - start
|
||||
'duck duck go cheat sheet' => $test_zci,
|
||||
'duck duck go keyboard shortcuts' => $test_zci,
|
||||
'duck duck go shortcuts' => $test_zci,
|
||||
'duck duck go shortcuts cheatsheet' => $test_zci,
|
||||
'duck duck go shortcuts cheat sheet' => $test_zci,
|
||||
'duck duck go\'s cheatsheet' => $test_zci,
|
||||
'duck duck go\'s cheat sheet' => $test_zci,
|
||||
'duck duck go\'s keyboard shortcuts' => $test_zci,
|
||||
'duck duck go\'s shortcuts' => $test_zci,
|
||||
'duck duck go\'s shortcuts cheatsheet' => $test_zci,
|
||||
'duck duck go\'s shortcuts cheat sheet' => $test_zci,
|
||||
'duck duck gos cheatsheet' => $test_zci,
|
||||
'duck duck gos cheat sheet' => $test_zci,
|
||||
'duck duck gos keyboard shortcuts' => $test_zci,
|
||||
'duck duck gos shortcuts' => $test_zci,
|
||||
'duck duck gos shortcuts cheatsheet' => $test_zci,
|
||||
'duck duck gos shortcuts cheat sheet' => $test_zci,
|
||||
'duckduck go cheatsheet' => $test_zci,
|
||||
'duckduck go cheat sheet' => $test_zci,
|
||||
'duckduck go keyboard shortcuts' => $test_zci,
|
||||
'duckduck go shortcuts' => $test_zci,
|
||||
'duckduck go shortcuts cheatsheet' => $test_zci,
|
||||
'duckduck go shortcuts cheat sheet' => $test_zci,
|
||||
'duckduck go\'s cheatsheet' => $test_zci,
|
||||
'duckduck go\'s cheat sheet' => $test_zci,
|
||||
'duckduck go\'s keyboard shortcuts' => $test_zci,
|
||||
'duckduck go\'s shortcuts' => $test_zci,
|
||||
'duckduck go\'s shortcuts cheatsheet' => $test_zci,
|
||||
'duckduck go\'s shortcuts cheat sheet' => $test_zci,
|
||||
'duckduck gos cheatsheet' => $test_zci,
|
||||
'duckduck gos cheat sheet' => $test_zci,
|
||||
'duckduck gos keyboard shortcuts' => $test_zci,
|
||||
'duckduck gos shortcuts' => $test_zci,
|
||||
'duckduck gos shortcuts cheatsheet' => $test_zci,
|
||||
'duckduck gos shortcuts cheat sheet' => $test_zci,
|
||||
'duck duckgo cheatsheet' => $test_zci,
|
||||
'duck duckgo cheat sheet' => $test_zci,
|
||||
'duck duckgo keyboard shortcuts' => $test_zci,
|
||||
'duck duckgo shortcuts' => $test_zci,
|
||||
'duck duckgo shortcuts cheatsheet' => $test_zci,
|
||||
'duck duckgo shortcuts cheat sheet' => $test_zci,
|
||||
'duck duckgo\'s cheatsheet' => $test_zci,
|
||||
'duck duckgo\'s cheat sheet' => $test_zci,
|
||||
'duck duckgo\'s keyboard shortcuts' => $test_zci,
|
||||
'duck duckgo\'s shortcuts' => $test_zci,
|
||||
'duck duckgo\'s shortcuts cheatsheet' => $test_zci,
|
||||
'duck duckgo\'s shortcuts cheat sheet' => $test_zci,
|
||||
'duck duckgos cheatsheet' => $test_zci,
|
||||
'duck duckgos cheat sheet' => $test_zci,
|
||||
'duck duckgos keyboard shortcuts' => $test_zci,
|
||||
'duck duckgos shortcuts' => $test_zci,
|
||||
'duck duckgos shortcuts cheatsheet' => $test_zci,
|
||||
'duck duckgos shortcuts cheat sheet' => $test_zci,
|
||||
'duckduckgo cheatsheet' => $test_zci,
|
||||
'duckduckgo cheat sheet' => $test_zci,
|
||||
'duckduckgo keyboard shortcuts' => $test_zci,
|
||||
'duckduckgo shortcuts' => $test_zci,
|
||||
'duckduckgo shortcuts cheatsheet' => $test_zci,
|
||||
'duckduckgo shortcuts cheat sheet' => $test_zci,
|
||||
'duckduckgo\'s cheatsheet' => $test_zci,
|
||||
'duckduckgo\'s cheat sheet' => $test_zci,
|
||||
'duckduckgo\'s keyboard shortcuts' => $test_zci,
|
||||
'duckduckgo\'s shortcuts' => $test_zci,
|
||||
'duckduckgo\'s shortcuts cheatsheet' => $test_zci,
|
||||
'duckduckgo\'s shortcuts cheat sheet' => $test_zci,
|
||||
'duckduckgos cheatsheet' => $test_zci,
|
||||
'duckduckgos cheat sheet' => $test_zci,
|
||||
'duckduckgos keyboard shortcuts' => $test_zci,
|
||||
'duckduckgos shortcuts' => $test_zci,
|
||||
'duckduckgos shortcuts cheatsheet' => $test_zci,
|
||||
'duckduckgos shortcuts cheat sheet' => $test_zci,
|
||||
'ddg cheatsheet' => $test_zci,
|
||||
'ddg cheat sheet' => $test_zci,
|
||||
'ddg keyboard shortcuts' => $test_zci,
|
||||
'ddg shortcuts' => $test_zci,
|
||||
'ddg shortcuts cheatsheet' => $test_zci,
|
||||
'ddg shortcuts cheat sheet' => $test_zci,
|
||||
'ddg\'s cheatsheet' => $test_zci,
|
||||
'ddg\'s cheat sheet' => $test_zci,
|
||||
'ddg\'s keyboard shortcuts' => $test_zci,
|
||||
'ddg\'s shortcuts' => $test_zci,
|
||||
'ddg\'s shortcuts cheatsheet' => $test_zci,
|
||||
'ddg\'s shortcuts cheat sheet' => $test_zci,
|
||||
'ddgs cheatsheet' => $test_zci,
|
||||
'ddgs cheat sheet' => $test_zci,
|
||||
'ddgs keyboard shortcuts' => $test_zci,
|
||||
'ddgs shortcuts' => $test_zci,
|
||||
'ddgs shortcuts cheatsheet' => $test_zci, # Generated triggers - end
|
||||
|
||||
'DDGs Shortcuts Cheat Sheet' => $test_zci, # Upper case triggers
|
||||
'ddgs shortcuts cheat sheet WHATEVER AFTER' => $test_zci, # starting trigger
|
||||
'WHATEVER BEFORE ddgs shortcuts cheat sheet' => $test_zci, # ending trigger
|
||||
'ddgs shortcuts WHATEVER HERE cheat sheet' => $test_zci, # triggers on "ddgs shortcuts"
|
||||
|
||||
"DuckDuckGo shortcuts" => $test_zci, # primary_example_queries
|
||||
"DDG Cheat Sheet" => $test_zci, # primary_example_queries
|
||||
"Display DuckDuckGo's keyboard shortcuts" => $test_zci, # secondary_example_queries
|
||||
|
||||
'ddgs WHATEVER IN BETWEEN shortcuts cheat sheet' => undef, # no complete trigger
|
||||
'BEFORE ddgs shortcuts cheat sheet AND AFTER' => undef, # no start/end trigger
|
||||
'DUCKDUCKGO ddg shortcuts cheat sheet AFTER' => undef, # no start/end trigger
|
||||
'ddgs shortcut cheat sheet' => undef, # misspelled trigger
|
||||
);
|
||||
|
||||
done_testing;
|
Loading…
Reference in New Issue