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

Micropilot #73

Merged
merged 30 commits into from
Apr 17, 2013
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.swp
*~
packages/micropilot
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
For users: https://github.com/mozilla/blushproof/wiki

For developers:
Requirements: nodejs, volo version 0.2.8 or higher

To checkout:
`npm install -g volo`
`git clone https://github.com/mozilla/blushproof`
`cd .git`
`rm -rf hooks`
Expand Down
Binary file modified blushproof.xpi
Binary file not shown.
5 changes: 5 additions & 0 deletions lib/bpUI.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const BROWSERURL = "chrome://browser/content/browser.xul"
let bpContentPolicy = require("bpContentPolicy");
let bpCategorizer = require("bpCategorizer");
let bpUtil = require("bpUtil");
let monitor = require("monitor").monitor;

const { Cc, Ci, Cu } = require("chrome");
// The second param avoids polluting the scope
const { ForgetAboutSite } = Cu.import("resource://gre/modules/ForgetAboutSite.jsm", {});
Expand All @@ -22,6 +24,9 @@ let blushPanel = panel.Panel({
contentURL: data.url("blushthis.html"),
onMessage: function(aMessage) {
console.log("received message", aMessage);
// Placeholder for metrics. We don't know the format, etc. yet.
monitor.record({ name: aMessage, ts: Date.now() });

let host = utils.getMostRecentBrowserWindow().gBrowser.selectedBrowser
.contentWindow.location.host;
// Unfortunately, [current browser].contentWindow.location is not an
Expand Down
31 changes: 31 additions & 0 deletions lib/monitor.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// This module encapsulates all the micropilot logic. Other modules should only
// ever have to use monitor.record.

let micropilot = require("micropilot");

const { storage } = require("simple-storage");

let monitor = micropilot.Micropilot("blushproof").start();

function daily_upload() {
// Placeholder for metadata about the upload. We probably want to keep track
// of the last upload.
monitor.record({ts: Date.now()});
// Placeholder for the upload url.
monitor.upload("fake.com", { simulate: true }).then(function(req) {
console.log(JSON.stringify(req.content));
});
};

micropilot.Fuse({
start: Date.now(),
// Run forever
duration: false,
// Upload every day in milliseconds
pulseinterval: 24 * 60 * 60 * 1000,
// (Upload more often for testing)
// pulseinterval: 10 * 1000,
pulsefn: daily_upload
});

exports.monitor = monitor;
20 changes: 18 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,21 @@
"description": "stop opening naughty sites accidentally",
"author": "David Keeler <[email protected]>, Monica Chew <[email protected]>, Gregg Lind <[email protected]>",
"license": "MPL 2.0",
"version": "0.1"
}
"version": "0.1",
"dependencies": [
"micropilot"
],
"preferences": [
{
"type": "bool",
"title": "micropilotlog",
"name": "micropilotlog",
"value": true
}
],
"volo": {
"dependencies": {
"packages/micropilot": "github:gregglind/micropilot/v0.8"
Copy link
Contributor

Choose a reason for hiding this comment

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

I was expecting this to automatically fetch micropilot for me. Too much to ask, or do I not have volo set up correctly?

Copy link
Author

Choose a reason for hiding this comment

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

I think, but am not sure, that this means that if we use volo to install blushproof itself then volo will fetch packages/micropilot, e.g.

volo create myaddon micropilot-template

However, I'm not sure how/if we can take advantage of that in the development cycle.

@gregglind, any clues?

Copy link
Author

Choose a reason for hiding this comment

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

This doesn't seem to be supported: volojs/volo#149

Seems like the intended workflow is to manually call volo add -f when you want to update the dependency.

Copy link
Author

Choose a reason for hiding this comment

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

Hmm, figure out workflow by reading bugs: volojs/volo#22

@jrburke, is the expected workflow to contribute to a git-managed codebase with volo dependencies to

git clone myproject
cd myproject
volo add

?

}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

So, there's no newline at the end of this file. Do we care?

Copy link
Author

Choose a reason for hiding this comment

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

I got a trailing whitespace error when I tried to commit! Seems a little strict...