Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

feat (addon) #444 enhance sites with tippy top data #616

Closed
wants to merge 3 commits into from

Conversation

rlr
Copy link
Contributor

@rlr rlr commented May 2, 2016

r? @oyiptong and/or @k88hudson

Fixes #444


This change is Reviewable

if (this.options.sites) {
sites = this.options.sites;
} else {
sites = JSON.parse(data.load("content/favicons/top_sites.json"));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if you want to touch the JSON file directly vs the require("tippy-top-sites") exported version via index.js (since we inject a couple values on the fly). /cc @k88hudson

Copy link
Contributor

@k88hudson k88hudson May 3, 2016

Choose a reason for hiding this comment

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

yeah i agree, i think it would be better to just require the file, since we might need stuff that gets added in there

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How do I do that? Do I need to copy over that index.js into the addon data directory? Can I use it from there with require? Since it's in node_modules, wasn't sure how.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's just a simple require("tippy-top-sites"), per ./content-test/faker.js:3.

Copy link
Contributor

Choose a reason for hiding this comment

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

The issue with using require is that this is addon js. The tippy-top-sites module won't be available in the addon at runtime.

One way to get around this is to duplicate the module in a directory that will be packaged with the addon.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah yes. This is a bit more verbose, but we can wire it up during the npm run bundle step:

const writeFile = require("fs").writeFileSync;
const join = require("path").join;
const tippy = require("tippy-top-sites");

const OUT_FILE = join("data", "content", "favicons", "top_sites.json");

writeFile(OUT_FILE, JSON.stringify(tippy));

@coveralls
Copy link

Coverage Status

Coverage remained the same at 91.433% when pulling 1cba1f2 on rlr:gh444/tippytop into 2545c21 on mozilla:master.

* Create a key using the domain (minus the www.).
*/
_getKey(url) {
let domain = URL(url).host;
Copy link
Contributor

@k88hudson k88hudson May 3, 2016

Choose a reason for hiding this comment

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

I think we'll probably want to expand this to include all subdomains of a host as well, although that will result in some conflicts (e.g. aws.amazon.com and amazon.com are separate tippy-top entries)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I had talked about this with @oyiptong and we decided it was safer to match the full domain. I don't think there are that many cases in the top sites where we want to include all it's subdomains? I could be wrong.

@k88hudson
Copy link
Contributor

YAY! This is awesome. A couple of small notes in the code. For the issue with matching subdomains, I think it's fine to do that as a follow-up.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.2%) to 91.639% when pulling bb2110c on rlr:gh444/tippytop into 2545c21 on mozilla:master.

@rlr
Copy link
Contributor Author

rlr commented May 3, 2016

OK, I think I fixed the important easy things. I can file followups for 1) figuring out a better way to use the tippy tops package 2) look into if we want to match all subdomains.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 91.639% when pulling ea9d90d on rlr:gh444/tippytop into 5bc8ed8 on mozilla:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.2%) to 91.475% when pulling ea9d90d on rlr:gh444/tippytop into 5bc8ed8 on mozilla:master.

@rlr rlr removed their assignment May 3, 2016
@k88hudson
Copy link
Contributor

Ok, looks good to me!

@rlr rlr closed this May 3, 2016
@rlr rlr deleted the gh444/tippytop branch May 3, 2016 22:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants