This repository has been archived by the owner on Oct 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ASCII Code: New ASCII Codes Table Goodie (#4042)
* Add: Initialized ASCII Table Goodie * Update: Fixed content options * Update: Title added to td tags * Update: CSS for tables * Fix: Makes titles more verbose in template * Update: Tests for Ascii Table added * AsciiTable: Fix variable name to be more generic * AsciiTable: Improved testing of IA * AsciiTable: Chomp the table * AsciiTable: Add meta source * AsciiTable: Rename table_rows -> table * AsciiTable: Use already existing CSS * AsciiTable: Data now contains Headers * AsciiTable: Makes template more generic * AsciiTable: Updated tests for checking table headers * AsciiTable: Fix required table styling * AsciiTable: Fix tests * Use CSS to set chomp height * Remove table scroll div * Switch to List template * Update AsciiTable.t
- Loading branch information
1 parent
264282b
commit d1e5d9c
Showing
6 changed files
with
820 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package DDG::Goodie::AsciiTable; | ||
# ABSTRACT: Shows Ascii Table | ||
|
||
use DDG::Goodie; | ||
use YAML::XS 'LoadFile'; | ||
use strict; | ||
use warnings; | ||
|
||
zci answer_type => 'ascii_table'; | ||
|
||
zci is_cached => 1; | ||
|
||
triggers start => 'ascii table', 'ascii tables', 'ascii reference table', | ||
'ascii reference'; | ||
|
||
my $ascii = LoadFile(share('data.yml')); | ||
|
||
handle remainder => sub { | ||
return unless $_ eq ''; | ||
|
||
return '', | ||
structured_answer => { | ||
id => 'ascii_table', | ||
name => 'ASCII Table', | ||
data => { | ||
title => 'ASCII Table', | ||
table => $ascii | ||
}, | ||
meta => { | ||
sourceName => 'asciitable.com', | ||
sourceUrl => 'http://www.asciitable.com/' | ||
}, | ||
templates => { | ||
group => 'list', | ||
item => 0, | ||
options => { | ||
content => 'DDH.ascii_table.content', | ||
moreAt => 1 | ||
} | ||
} | ||
}; | ||
}; | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.zci--ascii_table .c-list__content.chomp { | ||
max-height: 14em; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
DDH.ascii_table = DDH.ascii_table || {}; | ||
|
||
DDH.ascii_table.build = function(ops) { | ||
"use strict"; | ||
|
||
Spice.registerHelper('get_value', function(obj, key) { | ||
if (obj) { | ||
if (key in obj) { | ||
return obj[key]; | ||
} | ||
} | ||
return ''; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<table class='record__body ascii_table'> | ||
<thead> | ||
<tr class='record__row'> | ||
{{#each table.header}} | ||
<th class='tx--bold' title='{{ key }}'>{{ abbr }}</th> | ||
{{/each}} | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{#each table.body}} | ||
<tr class='record__row'> | ||
{{#each ../table.header}} | ||
<td class='record__cell' title='{{ this.key }}'>{{ get_value ../this this.abbr }}</td> | ||
{{/each}} | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> |
Oops, something went wrong.