From 29ada01d3f107153fbe8274cfaca5a6eb5a18399 Mon Sep 17 00:00:00 2001 From: sdua Date: Mon, 4 Jul 2016 22:51:31 +0000 Subject: [PATCH] JsMinify: Init IA --- lib/DDG/Goodie/JsMinify.pm | 31 ++++++++++++++ share/goodie/js_minify/content.handlebars | 1 + share/goodie/js_minify/js_minify.css | 0 share/goodie/js_minify/js_minify.js | 14 +++++++ t/JSMinify.t | 49 +++++++++++++++++++++++ 5 files changed, 95 insertions(+) create mode 100644 lib/DDG/Goodie/JsMinify.pm create mode 100644 share/goodie/js_minify/content.handlebars create mode 100644 share/goodie/js_minify/js_minify.css create mode 100644 share/goodie/js_minify/js_minify.js create mode 100644 t/JSMinify.t diff --git a/lib/DDG/Goodie/JsMinify.pm b/lib/DDG/Goodie/JsMinify.pm new file mode 100644 index 000000000..80700c3f1 --- /dev/null +++ b/lib/DDG/Goodie/JsMinify.pm @@ -0,0 +1,31 @@ +package DDG::Goodie::JsMinify; +# ABSTRACT: An Interactive JavaScript Minifier Tool + +use DDG::Goodie; +use strict; + +zci answer_type => 'jsminify'; +zci is_cached => 1; + +triggers any => 'js minify', 'js minifier'; + +handle query_lc => sub { + + return unless $_; + + return '', + structured_answer => { + + data => {}, + + templates => { + group => 'text', + item => 0, + options => { + content => 'DDH.js_minify.content' + } + } + }; +}; + +1; diff --git a/share/goodie/js_minify/content.handlebars b/share/goodie/js_minify/content.handlebars new file mode 100644 index 000000000..720e9d6a7 --- /dev/null +++ b/share/goodie/js_minify/content.handlebars @@ -0,0 +1 @@ +

JS Minifier

\ No newline at end of file diff --git a/share/goodie/js_minify/js_minify.css b/share/goodie/js_minify/js_minify.css new file mode 100644 index 000000000..e69de29bb diff --git a/share/goodie/js_minify/js_minify.js b/share/goodie/js_minify/js_minify.js new file mode 100644 index 000000000..1d9112857 --- /dev/null +++ b/share/goodie/js_minify/js_minify.js @@ -0,0 +1,14 @@ +DDH.js_minify = DDH.js_minify || {}; + +(function(DDH) { + "use strict"; + + DDH.js_minify.build = function(ops) { + + return { + onShow: function() { + + } + }; + } +}); \ No newline at end of file diff --git a/t/JSMinify.t b/t/JSMinify.t new file mode 100644 index 000000000..7bae23cac --- /dev/null +++ b/t/JSMinify.t @@ -0,0 +1,49 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use Test::More; +use Test::Deep; +use DDG::Test::Goodie; + +zci answer_type => "jsminify"; +zci is_cached => 1; + +# Build a structured answer that should match the response from the +# Perl file. +sub build_structured_answer { + my @test_params = @_; + + return "plain text response", + structured_answer => { + + data => { + title => "My Instant Answer Title", + subtitle => "My Subtitle", + # image => "http://website.com/image.png", + }, + + templates => { + group => "text", + # options => { + # + # } + } + }; +} + +# Use this to build expected results for your tests. +sub build_test { test_zci(build_structured_answer(@_)) } + +ddg_goodie_test( + [qw( DDG::Goodie::JSMinify )], + # At a minimum, be sure to include tests for all: + # - primary_example_queries + # - secondary_example_queries + 'example query' => build_test('query'), + # Try to include some examples of queries on which it might + # appear that your answer will trigger, but does not. + 'bad example query' => undef, +); + +done_testing;