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

Add new JSMinify Instant Answer #3352

Merged
merged 22 commits into from
Jul 19, 2016
Merged

Add new JSMinify Instant Answer #3352

merged 22 commits into from
Jul 19, 2016

Conversation

sahildua2305
Copy link
Collaborator

What does your Pull Request do (check all that apply)?

Choose the most relevant items and use the following title template to name
your Pull Request.

  • New Instant Answer
    • Cheat Sheets: New {Cheat Sheet Name} Cheat Sheet
    • Other: New JS Minify Instant Answer
  • Improvement
    • Bug fix: {IA Name}: Fix {Issue number or one-line description}
    • Enhancement: {IA Name}: {Description of Improvements}
  • Non–Instant Answer
    • Other (Role, Template, Test, Documentation, etc.): {GoodieRole/Templates/Tests/Docs}: {Short Description}
Description of changes

Developing an interactive JS Minifier using this library. Work in progress

People to notify (@mention interested parties)

@moollaza @MariagraziaAlastra


Instant Answer Page: https://duck.co/ia/view/js_minify

@daxtheduck
Copy link

daxtheduck commented Jul 5, 2016

Js Minify

Description: An Interactive JavaScript Minifier Tool

Example Query: [js minify](https://beta.duckduckgo.com/?q=js minify), [js minifier](https://beta.duckduckgo.com/?q=js minifier)

Tab Name: Answer

Source:

These are the important fields from the IA page. Please check these for errors or missing information and update the IA page


This is an automated message which will be updated as changes are made to the IA page

zci answer_type => 'jsminify';
zci is_cached => 1;

triggers any => 'js minify', 'js minifier';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sahildua2305 I think we'd also want this to trigger for queries like "javascript minify, javascript minifier, minify js, minify javascript"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely! This is just the beginning. I have added these trigger words for testing. I'll add more. Thanks for suggesting these words. 😄

@MariagraziaAlastra
Copy link
Member

@sahildua2305 Thanks for working on this! Please let me know if you need any help 😄

@sahildua2305
Copy link
Collaborator Author

@MariagraziaAlastra Actually I need help in getting started with this. With this initial setup, I am not able to show anything on search page. The IA gets triggered but doesn't show anything. Not even an IA tab.

Can you please look into this? I may be missing something naive.

@MariagraziaAlastra
Copy link
Member

@sahildua2305 It actually triggers for me:
screenshot-devour-sertum codio io 5000 2016-07-05 22-55-58

@sahildua2305
Copy link
Collaborator Author

Weird! I'll check again. Thanks a lot.

@sahildua2305
Copy link
Collaborator Author

@MariagraziaAlastra I have pushed a working interactive js minifier (with very basic UI) and it looks like this -
selection_154

Please deploy this on Beta. 😄

return;

// set the flag to true so it doesn't get run again
shown = true;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shown logic seems like it is indicative of a different, underlying problem... does onShow get called multiple times?

Copy link
Collaborator Author

@sahildua2305 sahildua2305 Jul 6, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onShow gets called every time the Answer tab is shown.

For example, if user searches for js minify by default Answer tab will be opened. If user clicks on Web tab and then comes back to Answer tab, onShow will be called again.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this is done in other javascript, but it just seems like something that should be built-in at a lower level. Carry on!

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! 👍

@daxtheduck daxtheduck deployed to beta.duckduckgo.com July 6, 2016 12:07 Active
@MariagraziaAlastra
Copy link
Member

@sahildua2305 Hey, nice job here, thanks!
Your PR is deployed to beta, but it doesn't trigger yet. Will let you know when we have the library installed on our end, so you can use DDG.require() instead - it shouldn't take long anyway. 😄

I tested it on DuckPAN in the meantime and it works really well. As discussed on Slack, why don't you make the tab name be "Minifier" instead? Maybe "JavaScript Minifier", even.

@sahildua2305
Copy link
Collaborator Author

sahildua2305 commented Jul 6, 2016

@MariagraziaAlastra Thanks 😇

I have changed the tab name to "Minifier" so that even CSS minifier can come under the same name. However it's not showing up as Minifier in search results.

Also, @moollaza the CSS minifier doesn't need to be different. I can change this IA's name to Minifier and hence it can be used to minify CSS or JS depending upon the query. There can be an option to choose between CSS and JS for the user. What do you think?

@GuiltyDolphin GuiltyDolphin changed the title Add new JS minifier Add new JSMinify Instant Answer Jul 6, 2016
@MariagraziaAlastra
Copy link
Member

Yeah, disabling the button until the library is loaded sounds like a good idea. Thanks @sahildua2305!

@sahildua2305
Copy link
Collaborator Author

@MariagraziaAlastra please deploy this on beta so that we can test it. I have made the library load on change in textarea contents. I have also disabled the button till the time library is loaded.

@daxtheduck daxtheduck deployed to beta.duckduckgo.com July 18, 2016 15:16 Active
$minifyButton.css('cursor', 'default');

// Add event handler for change in input of textarea
$input.on('input', function() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sahildua2305 maybe try on keyup instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid keyup won't be triggered if user pastes the code using context menu. input will be triggered whenever the input changes, in any way. @MariagraziaAlastra

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok cool, I was worried about IE9, but turns out this has basic support there, except for deleting, pressing backspace and cutting, and I think we don't care about either of those 😄

@MariagraziaAlastra
Copy link
Member

Hey @sahildua2305 it's deployed again! It works, but for some reason the minified code shows underneath the original code, instead of showing on the right:
screenshot-beta duckduckgo com 2016-07-18 17-21-59

I'm using Firefox 47, 1920 × 1080 screen resolution

@sahildua2305
Copy link
Collaborator Author

sahildua2305 commented Jul 18, 2016

@MariagraziaAlastra this is weird! It works for me. at a lower resolution. Can you please check the dimensions of div with class zci__main inside #zci-js_minify?

Edit: I just tested on 1920 x 1080 resolution using the emulator. It shows well on the side for me. 😕

Edit 2: I figured out what's causing problem. I'll fix this one right now.

Edit 3: Fixed! Please test it. 😄

@daxtheduck daxtheduck deployed to beta.duckduckgo.com July 19, 2016 01:11 Active
@MariagraziaAlastra
Copy link
Member

MariagraziaAlastra commented Jul 19, 2016

@sahildua2305 Thanks, deployed again! Looks good on my laptop, let me just test it on my desktop in a few hours, before the IAs release.
Hopefully it should be ready!

@sahildua2305
Copy link
Collaborator Author

@MariagraziaAlastra let me know how it goes 😄

@MariagraziaAlastra
Copy link
Member

@sahildua2305 It's ready! Merging now...
Thanks again for the great work here! 😄

@daxtheduck
Copy link

@sahildua2305 this is now merged! It should be live on DuckDuckGo within one week (or during the next release) and we'll be sure to notify you when it happens.

After your Instant Answer goes live for the World to use, you will be able to see traffic information about your IA as well as receive feedback directly from users.

Please refer to the maintenance guide and docs to keep up with potential changes to your Instant Answer.

Thank you again for your help!

@MariagraziaAlastra MariagraziaAlastra merged commit 479814b into duckduckgo:master Jul 19, 2016
@@ -0,0 +1,8 @@
<h5>Minify JavaScript Code on the go!</h5>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a title property from data -- don't need the content template to render this 👍

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change the text to "JavaScript Minifier"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants