Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Commit

Permalink
ASCII Code: New ASCII Codes Table Goodie (#4042)
Browse files Browse the repository at this point in the history
* 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
manrajgrover authored and moollaza committed Apr 11, 2017
1 parent 264282b commit d1e5d9c
Show file tree
Hide file tree
Showing 6 changed files with 820 additions and 0 deletions.
44 changes: 44 additions & 0 deletions lib/DDG/Goodie/AsciiTable.pm
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;
3 changes: 3 additions & 0 deletions share/goodie/ascii_table/ascii_table.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.zci--ascii_table .c-list__content.chomp {
max-height: 14em;
}
14 changes: 14 additions & 0 deletions share/goodie/ascii_table/ascii_table.js
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 '';
});
};
18 changes: 18 additions & 0 deletions share/goodie/ascii_table/content.handlebars
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>
Loading

0 comments on commit d1e5d9c

Please sign in to comment.