<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>Blog-O! (Posts about mozilla)</title><link>https://bwinton.github.io/weblog.latte.ca/</link><description></description><atom:link rel="self" href="https://bwinton.github.io/weblog.latte.ca/tags/mozilla.xml" type="application/rss+xml"></atom:link><language>en</language><lastBuildDate>Sat, 13 Apr 2019 21:03:15 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Hey!  Let’s Write a WebExtension!</title><link>https://bwinton.github.io/weblog.latte.ca/blake/tech/firefox/webextensiontutorial/</link><dc:creator>Blake Winton</dc:creator><description>&lt;div&gt;&lt;p&gt;&lt;small&gt;(This article is also posted on &lt;a href="https://hacks.mozilla.org/2015/09/lets_write_a_webextension/"&gt;Mozilla
Hacks&lt;/a&gt;.)&lt;/small&gt;&lt;/p&gt;
&lt;p&gt;You might have heard about Mozilla’s &lt;a href="https://wiki.mozilla.org/WebExtensions" title="Mozilla’s WebExtensions Wiki Page"&gt;WebExtensions&lt;/a&gt;, our
implementation of a new browser extension API for writing
multiprocess-compatible add-ons.  Maybe you’ve been wondering what it was about,
and how you could use it. Well, I’m here to help!  I think &lt;a href="https://developer.mozilla.org/en-US/Add-ons/WebExtensions" title="MDN’s WebExtensions Documentation"&gt;MDN’s WebExtensions
Docs&lt;/a&gt; have a pretty great definition:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;WebExtensions are a new way to write Firefox extensions.&lt;/p&gt;
&lt;p&gt;The technology is developed for cross-browser compatibility: to a large extent
the API is compatible with the &lt;a href="https://developer.chrome.com/extensions" title="Chrome’s Extension API"&gt;extension API&lt;/a&gt; supported by Google
Chrome and Opera. Extensions written for these browsers will in most cases run
in Firefox with just a few changes. The API is also fully compatible with
&lt;a href="https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Multiprocess_Firefox" title="a.k.a. Electrolysis"&gt;multiprocess Firefox&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The only thing I would add is that while Mozilla is implementing most of the API
that Chrome and Opera support, we’re not restricting ourselves to only that API.
Where it makes sense, we will be adding new functionality and talking with other
browser makers about implementing it as well.  Finally, since the WebExtension
API is still under development, it’s probably best if you use &lt;a href="https://nightly.mozilla.org/" title="Download Nightly Here"&gt;Firefox
Nightly&lt;/a&gt; for this tutorial, so that you get the most up-to-date,
standards-compliant behaviour.  But keep in mind, this is still experimental
technology — things might break!&lt;/p&gt;
&lt;h4&gt;Starting off&lt;/h4&gt;
&lt;p&gt;Okay, let’s start with a reasonably simple add-on. We’ll add a button, and when
you click it, it will open up &lt;a href="http://chilloutandwatchsomecatgifs.com/" title="Cat Gifs!"&gt;one of my favourite sites&lt;/a&gt; in a new
tab.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://bwinton.github.io/weblog.latte.ca/blake/tech/firefox/webextensiontutorial/"&gt;Read more…&lt;/a&gt; (9 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>addon</category><category>firefox</category><category>mozilla</category><category>webextension</category><guid>https://bwinton.github.io/weblog.latte.ca/blake/tech/firefox/webextensiontutorial/</guid><pubDate>Mon, 21 Sep 2015 18:52:00 GMT</pubDate></item><item><title>A long time ago, on a computer far far away…</title><link>https://bwinton.github.io/weblog.latte.ca/blake/employment/mozilla/sixyears/</link><dc:creator>Blake Winton</dc:creator><description>&lt;div&gt;&lt;p&gt;Six years ago, I started contributing to Mozilla.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://bwinton.github.io/weblog.latte.ca/blake/employment/mozilla/sixyears/"&gt;Read more…&lt;/a&gt; (4 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>anniversary</category><category>employment</category><category>mozilla</category><category>thunderbird</category><guid>https://bwinton.github.io/weblog.latte.ca/blake/employment/mozilla/sixyears/</guid><pubDate>Fri, 27 Feb 2015 19:04:00 GMT</pubDate></item><item><title>ES6 Templates</title><link>https://bwinton.github.io/weblog.latte.ca/blake/tech/firefox/templates/</link><dc:creator>Blake Winton</dc:creator><description>&lt;div&gt;&lt;p&gt;One of my favourite upcoming features in ES6 is Template Strings.  I’ve used
JQuery’s &lt;a href="http://ejohn.org/blog/javascript-micro-templating/"&gt;templates&lt;/a&gt; in
&lt;a href="https://bugzilla.mozilla.org/show_bug.cgi?id=686347"&gt;some previous code&lt;/a&gt; I’ve
worked on, and while it was very useful in finishing the feature on time, it’s
aged now and relying on third-party libraries which we don’t have time to keep
up to date isn’t the best idea and so we’re in the middle of &lt;a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1014609"&gt;some work to
remove them&lt;/a&gt;.  So having
said that, I’m quite happy to see something similar arriving in the base
language, so that we can take advantage of it without having to add any extra
code.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;As an aside, all the code below was tested in &lt;a href="http://getfirefox.com"&gt;Firefox
34&lt;/a&gt;, using the
&lt;a href="https://developer.mozilla.org/en-US/docs/Tools/Scratchpad"&gt;Scratchpad&lt;/a&gt;.  The
comments are pasted in below the code when you select it and choose the
&lt;code&gt;Execute » Display&lt;/code&gt; menu item or hit &lt;code&gt;Ctrl+L&lt;/code&gt; (&lt;code&gt;Cmd+L&lt;/code&gt; on Mac).  I
&lt;a href="https://twitter.com/addyosmani/status/541978036904554496"&gt;hear&lt;/a&gt; they also
&lt;a href="https://plus.google.com/+AddyOsmani/posts/BW5h61SoGf8"&gt;work in Chrome&lt;/a&gt;, but
they didn’t seem to in the version I was running (39.0.2171.95), and I didn’t
want to start messing with an &lt;code&gt;--es-staging&lt;/code&gt; flag.  If someone can confirm
whether they work or not, I would certainly appreciate it!  :)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href="https://bwinton.github.io/weblog.latte.ca/blake/tech/firefox/templates/"&gt;Read more…&lt;/a&gt; (5 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>es6</category><category>mozilla</category><category>templates</category><guid>https://bwinton.github.io/weblog.latte.ca/blake/tech/firefox/templates/</guid><pubDate>Mon, 12 Jan 2015 19:45:00 GMT</pubDate></item><item><title>Figuring out where things are in an image.</title><link>https://bwinton.github.io/weblog.latte.ca/blake/tech/firefox/heatmap1/</link><dc:creator>Blake Winton</dc:creator><description>&lt;div&gt;&lt;p&gt;People love &lt;a href="https://blog.mozilla.org/ux/2012/06/firefox-heatmap-study-2012-results-are-in/"&gt;heatmaps&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;They’re a great way to show how much various UI elements are used in relation
to each other, and are much easier to read at a glance than a table of click-
counts would be.  They can also reveal hidden patterns of usage based on the
locations of elements, let us know if we’re focusing our efforts on the
correct elements, and tell us how effective our communication about new
features is.  Because they’re so useful, one of the things I am doing in my
new role is setting up the framework to provide our UX team with automatically
updating heatmaps for both Desktop and Android Firefox.
&lt;/p&gt;&lt;p&gt;&lt;a href="https://bwinton.github.io/weblog.latte.ca/blake/tech/firefox/heatmap1/"&gt;Read more…&lt;/a&gt; (4 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>heatmap</category><category>mozilla</category><category>tributary</category><guid>https://bwinton.github.io/weblog.latte.ca/blake/tech/firefox/heatmap1/</guid><pubDate>Mon, 07 Jul 2014 15:53:31 GMT</pubDate></item><item><title>Using Persona in Angular apps.</title><link>https://bwinton.github.io/weblog.latte.ca/blake/tech/firefox/angularpersonatool/</link><dc:creator>Blake Winton</dc:creator><description>&lt;div&gt;&lt;p&gt;In my &lt;a href="http://weblog.latte.ca/blake/tech/firefox/cssLines.html"&gt;previous blog post&lt;/a&gt;, I mentioned a tool
I’m writing to make it easy for designers to link mockups to live bugs.  But I
didn’t mention that I had a reasonably-working version of the tool written in
&lt;a href="http://backbonejs.org/"&gt;Backbone&lt;/a&gt; which I’ve decided to port to &lt;a href="http://angularjs.org/"&gt;Angular&lt;/a&gt;.  The reasons why are largely beside the point of this
blog post, but I’ll try to sum them up by saying that I reached a point where
Backbone seemed to be confusing me more than helping me, and Angular got a
&lt;em&gt;lot&lt;/em&gt; of good press at &lt;a href="http://fluentconf.com/fluent2013"&gt;FluentConf&lt;/a&gt; this
year.&lt;/p&gt;
&lt;p&gt;So this morning’s task in &lt;a href="https://github.com/bwinton/arewecreatingyet/commits/feature/angular"&gt;the re-write&lt;/a&gt; was to
re-hook up the &lt;a href="https://login.persona.org/about"&gt;Persona&lt;/a&gt; integration.  I had
read recently that when you had a lot of dom-manipulation functions, you should
probably put that code in a directive, and since I hadn’t written an Angular
directive yet, I figured this would be a great time to learn how.  Writing &lt;a href="https://github.com/bwinton/arewecreatingyet/blob/feature/angular/views/index.html#L30"&gt;the
html&lt;/a&gt;
was pretty easy, of course, and most of the code from the existing
implementation (which was largely based on the code from the &lt;a href="https://github.com/jbuck/express-persona/blob/master/README.md"&gt;express-persona
readme&lt;/a&gt;) could
be ported over fairly quickly.  The only tricky part I ran into was figuring
out that I needed to include &lt;a href="https://github.com/bwinton/angular-tools/blob/master/persona.js#L36"&gt;&lt;code&gt;restrict: 'E'&lt;/code&gt;&lt;/a&gt; in the
&lt;a href="http://docs.angularjs.org/guide/directive#directivedefinitionobject"&gt;Directive Definition Object&lt;/a&gt;.  After I
was done, I noticed that there really wasn’t that much in the code that had
anything to do with the tool I’m writing, and thus I pulled it out into a
separate repo so that other people can use it.&lt;/p&gt;
&lt;p&gt;And with that, I announce &lt;a href="https://github.com/bwinton/angular-tools/"&gt;Angular-Tools&lt;/a&gt;, a repo containing one or more tools
which you might find useful if you build Angular apps.  As always, pull
requests and bug reports welcome!&lt;/p&gt;&lt;/div&gt;</description><category>angular</category><category>mozilla</category><category>persona</category><guid>https://bwinton.github.io/weblog.latte.ca/blake/tech/firefox/angularpersonatool/</guid><pubDate>Fri, 28 Jun 2013 19:16:50 GMT</pubDate></item><item><title>Drawing lines with CSS.</title><link>https://bwinton.github.io/weblog.latte.ca/blake/tech/firefox/csslines/</link><dc:creator>Blake Winton</dc:creator><description>&lt;div&gt;&lt;p&gt;One of the things I’m working on as part of my job&lt;sup id="fnref:1"&gt;&lt;a class="footnote-ref" href="https://bwinton.github.io/weblog.latte.ca/blake/tech/firefox/csslines/#fn:1" rel="footnote"&gt;1&lt;/a&gt;&lt;/sup&gt; at Mozilla is &lt;a href="https://github.com/bwinton/arewecreatingyet"&gt;a tool&lt;/a&gt; to make it easy for designers to
create mockups that are linked to live bugs, similar to the ones at &lt;a href="http://areweprettyyet.com/4/mainWindow/#"&gt;Are We
Pretty Yet&lt;/a&gt;.  Now, I’ve got the
background showing up, and the bugs overlayed on top of it, but as it stands,
I’m requiring the designers to draw the lines connecting the bugs to the
various areas in the mockup right on the mockup itself!  This is obviously a
fairly terrible idea, since it makes it much harder than it should to move
stuff around after the fact, and requires a ton of up-front planning when
creating the initial image.  But what are my other options?&lt;/p&gt;
&lt;p&gt;I thought for a while about layering a canvas element over the mockup; it would
let me draw whatever shapes I wanted to, but passing the click events through
to the mockup seemed like it would be fairly annoying, and I don’t think the
connecting lines should appear in front of the boxes showing the bug details,
which adds another wrinkle.  Then, over lunch, I started to wonder what it
would look like if a 1px by 1px black square got stretched and rotated with
CSS…  So I took some time after lunch, and played around a little, and it seems
like it just might work!  &lt;a href="http://jsfiddle.net/aBjp7/8/"&gt;Give it a try&lt;/a&gt;, let me
know if you have any ideas to make it better, and feel free to take the idea
anywhere you think it might be useful!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Update:&lt;/strong&gt; In the comments, Andrew points out that I could use a 1px by 1px
span instead, which would make it &lt;em&gt;much&lt;/em&gt; easier to change the colour of the
line, so I’ve linked to his jsfiddle instead.  :)&lt;/p&gt;
&lt;div class="footnote"&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li id="fn:1"&gt;
&lt;p&gt;Sometimes I still can’t believe how lucky I am to get to do this stuff all day, and get paid for it! &lt;a class="footnote-backref" href="https://bwinton.github.io/weblog.latte.ca/blake/tech/firefox/csslines/#fnref:1" rev="footnote" title="Jump back to footnote 1 in the text"&gt;↩&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;&lt;/div&gt;</description><category>css</category><category>line</category><category>mozilla</category><category>pixel</category><category>transform</category><guid>https://bwinton.github.io/weblog.latte.ca/blake/tech/firefox/csslines/</guid><pubDate>Fri, 14 Jun 2013 18:57:43 GMT</pubDate></item><item><title>Cleaning out your Firefox profile.</title><link>https://bwinton.github.io/weblog.latte.ca/blake/employment/mozilla/tabsaver/</link><dc:creator>Blake Winton</dc:creator><description>&lt;div&gt;&lt;p&gt;For a while now, I’ve been having problems with my Firefox profile.  To be fair,
it’s mostly because of random &lt;a href="about:config"&gt;about:config&lt;/a&gt; tweaks I’ve made, but
still, not being able to test the &lt;a href="https://blog.mozilla.org/blog/2012/11/20/firefox-introduces-new-social-api-and-previews-integration-with-facebook/"&gt;new SocialAPI&lt;/a&gt; stuff was pretty annoying.  So I decided to try &lt;a href="http://support.mozilla.org/en-US/kb/reset-firefox-easily-fix-most-problems"&gt;resetting my profile&lt;/a&gt;,
to clear out all the junk, and hopefully even make it a little faster.&lt;/p&gt;
&lt;p&gt;But, as the page I linked to just up there mentions, resetting your profile will
lose your open tabs, windows and tab groups, which kinda sucks, because I have
57 open tabs, in various groups, and I really don’t want to lose them!
Fortunately, I’m a programmer, so I hacked on Firefox to get it to save and
restore my tabs, and now I’m a happy camper!&lt;/p&gt;
&lt;p&gt;A couple of days later, one of my co-workers had some similar problems, and also
wanted to re-set his profile to try and fix them.  I hadn’t saved the results of
my hacking, so I had to re-create it for him from a combination of memory and
the documentation.  The new code I came up with looked something like this:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;gBrowser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tabs&lt;/span&gt;
&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;rv&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;"var tabs = [\n"&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;lt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;rv&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'  "'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nx"&gt;linkedBrowser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;contentWindow&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;location&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s1"&gt;'",\n'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nx"&gt;rv&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'];\nfor (var i = 0; i &amp;amp;lt; tabs.length; i++ ) {\n'&lt;/span&gt;
&lt;span class="nx"&gt;rv&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="s1"&gt;'  gBrowser.addTab(tabs[i]);\n}\n'&lt;/span&gt;
&lt;/pre&gt;


&lt;p&gt;To run it, first open &lt;a href="about:config"&gt;about:config&lt;/a&gt;, and make sure the
&lt;code&gt;devtools.chrome.enabled&lt;/code&gt; preference is set to &lt;code&gt;true&lt;/code&gt; (double-click it if it
isn’t, and it should switch automatically), then go to the &lt;code&gt;Tools » Web
Developer » Scratchpad&lt;/code&gt; menu item, which should open up a small new window with
some javascript comments in it.  While that window is focused, click on
&lt;code&gt;Environment » Browser&lt;/code&gt;, to make sure that you’re running the code in the
browser’s chrome (instead of in the page’s content).  Paste the code in, and
click &lt;code&gt;Execute » Display&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;That should result in a bunch of code in grey surrounded by &lt;code&gt;/*&lt;/code&gt; and &lt;code&gt;*/&lt;/code&gt; that
looks like:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;tabs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
&lt;span class="s2"&gt;"http://weblog.latte.ca/blake"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="s2"&gt;"http://breakingtheegg.tumblr.com/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;lt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;tabs&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;gBrowser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;addTab&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tabs&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/pre&gt;


&lt;p&gt;Copy that out of the scratchpad into your favourite editor, remove the &lt;code&gt;/*&lt;/code&gt; and
&lt;code&gt;*/&lt;/code&gt;, and run the profile reset.&lt;/p&gt;
&lt;p&gt;Once you’re done resetting your profile, you’ll need to change the
&lt;code&gt;devtools.chrome.enabled&lt;/code&gt; preference to &lt;code&gt;true&lt;/code&gt; again, and then re-open the
Scratchpad, paste the new code you saved back in to it, click on the
&lt;code&gt;Execute » Run&lt;/code&gt; menu item, and &lt;strong&gt;shazam&lt;/strong&gt;!  All your tabs should be back
(although they won’t be in their original tab groups.  If anyone needs me to
figure out how to do that, just let me know, and I’ll give it a try).&lt;/p&gt;&lt;/div&gt;</description><category>cleaning</category><category>faster</category><category>firefox</category><category>mozilla</category><category>profile</category><guid>https://bwinton.github.io/weblog.latte.ca/blake/employment/mozilla/tabsaver/</guid><pubDate>Fri, 23 Nov 2012 18:42:09 GMT</pubDate></item><item><title>Pushing code to a remote server the volo way.</title><link>https://bwinton.github.io/weblog.latte.ca/blake/employment/mozilla/volodeploy/</link><dc:creator>Blake Winton</dc:creator><description>&lt;div&gt;&lt;p&gt;The &lt;a href="https://github.com/bwinton/australis-customization/"&gt;side-project&lt;/a&gt; I’m working
on is coming along nicely, and so I figured it was time to let other people
see it.  Now, I could just have everyone huddle around my screen, but since
many of the people who would be interested aren’t in the same city (or even
same timezone) as I am, that wouldn’t work out so well.  We tried screen-
sharing, but a lot of what’s being worked on is animation, and the frame-rates
of the screen-sharing application we were using weren’t up to the task.  To
get around that, I could have recorded a video, but since a lot of the value
of a prototype like this is being able to play around with it, that’s also not
a great solution.  So, obviously, the best thing to do would be to put it on a
publicly available server, and let people run it in their own web browser,
whenever they wanted!&lt;/p&gt;
&lt;p&gt;Now, I’m running a server or two that I could put it up on, but since the
project is related to Mozilla, and since Mozilla offers some personal webspace
on &lt;a href="http://people.mozilla.org/"&gt;one of their servers&lt;/a&gt;, I figured I might as
well put it up &lt;a href="https://people.mozilla.com/~bwinton/australis/customization/mac/?scroll"&gt;there&lt;/a&gt;.  :)&lt;/p&gt;
&lt;p&gt;So, to make it easy for me to remember to build and upload the code (and to
prevent me from trying to figure out all the correct options to rsync every
time I wanted to upload the code), I took a couple of minutes to &lt;a href="https://github.com/bwinton/australis-customization/blob/master/australis/customization/mac/volofile#L23"&gt;add a
command&lt;/a&gt; to my volofile, which lets me merely type &lt;code&gt;volo deploy&lt;/code&gt;, and have it
optimize the code, and copy only the changed files to the remote server.&lt;/p&gt;&lt;/div&gt;</description><category>deploy</category><category>mozilla</category><category>remote</category><category>rsync</category><category>server</category><category>volo</category><guid>https://bwinton.github.io/weblog.latte.ca/blake/employment/mozilla/volodeploy/</guid><pubDate>Sun, 22 Jul 2012 18:04:39 GMT</pubDate></item><item><title>X-Tag: or how to cut your html in half by adding 28 lines of Javascript…</title><link>https://bwinton.github.io/weblog.latte.ca/blake/employment/mozilla/x-tags/</link><dc:creator>Blake Winton</dc:creator><description>&lt;div&gt;&lt;p&gt;As a side-project, I’ve been working on a prototype which is heavily based on
&lt;a href="https://people.mozilla.com/~bwinton/australis-customization/customizationMode-liveDemo-i02.html"&gt;a demo page&lt;/a&gt; from Stephen Horlander.  Now, that page is
pretty amazing, but if you look at the source (using command-u or control-u in
Firefox, and command-alt-u or control-alt-u in Chrome), you’ll see a lot of code
that looks like this:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&amp;amp;lt;div class="menuPanelButton subscribeButton"&amp;amp;gt;
  &amp;amp;lt;div class="button"&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;
  &amp;amp;lt;div class="label"&amp;amp;gt;Subscribe&amp;amp;lt;/div&amp;amp;gt;
&amp;amp;lt;/div&amp;amp;gt;
&lt;/pre&gt;


&lt;p&gt;and:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&amp;amp;lt;div class="customizeToolbarItem"&amp;amp;gt;
  &amp;amp;lt;div class="customizeToolbarItemIcon share"&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;
  &amp;amp;lt;div class="customizeToolbarItemLabel"&amp;amp;gt;Share&amp;amp;lt;/div&amp;amp;gt;
&amp;amp;lt;/div&amp;amp;gt;
&lt;/pre&gt;


&lt;p&gt;Now, one or two of those would be fine, but when we get into more than that, the
repetition really starts to bug me, and I think “Wouldn’t it be better if I
could just write stuff like:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&amp;amp;lt;panel-button type="subscribe"&amp;amp;gt;Subscribe&amp;amp;lt;/panel-button&amp;amp;gt;
…
&amp;amp;lt;toolbar-item type="share"&amp;amp;gt;Share&amp;amp;lt;/toolbar-item&amp;amp;gt;
&lt;/pre&gt;


&lt;p&gt;instead?”  And it turns out I can, using a new library called
&lt;a href="http://mozilla.github.com/x-tag/"&gt;x-tag&lt;/a&gt;!  The first thing I need to do is
register the new tags I’ll be using.  That’s done with code like this:&lt;/p&gt;
&lt;pre class="code literal-block"&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="c1"&gt;// These first two lines are here because I’m using require.js, which I’ll&lt;/span&gt;
&lt;span class="c1"&gt;// talk about in a future blog post…&lt;/span&gt;
&lt;span class="nx"&gt;define&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;require&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="s2"&gt;"jquery"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"x-tag"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;xtag&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="c1"&gt;// And this is the meat of the functionality.&lt;/span&gt;
    &lt;span class="c1"&gt;// First, we’ll register the new "panel-button" tag.&lt;/span&gt;
    &lt;span class="nx"&gt;xtag&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"panel-button"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;onCreate&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;self&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="c1"&gt;// When the tag is first seen, make the innerHTML be this stuff below.&lt;/span&gt;
        &lt;span class="nx"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&amp;amp;lt;div class='menuPanelButton "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;attr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"'&amp;amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
                    &lt;span class="s2"&gt;"&amp;amp;lt;img src='images/button-"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;attr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;".png'"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
                    &lt;span class="s2"&gt;"     class='button'&amp;amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
                    &lt;span class="s2"&gt;"&amp;amp;lt;div class='label'&amp;amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"&amp;amp;lt;/div&amp;amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; 
                  &lt;span class="s2"&gt;"&amp;amp;lt;/div&amp;amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="c1"&gt;// And then, we’ll register the new "toolbar-item" tag.&lt;/span&gt;
    &lt;span class="nx"&gt;xtag&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;register&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"toolbar-item"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;onCreate&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(){&lt;/span&gt;
        &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;self&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;$&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="c1"&gt;// We could also replace this element with the html below, but I&lt;/span&gt;
        &lt;span class="c1"&gt;// haven’t done that here because I haven’t needed to yet.&lt;/span&gt;
        &lt;span class="nx"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"&amp;amp;lt;div class='customizeToolbarItem'&amp;amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
                    &lt;span class="s2"&gt;"&amp;amp;lt;div class='customizeToolbarItemIcon "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;attr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"'&amp;amp;gt;&amp;amp;lt;/div&amp;amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
                    &lt;span class="s2"&gt;"&amp;amp;lt;div class='customizeToolbarItemLabel'&amp;amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;text&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s2"&gt;"&amp;amp;lt;/div&amp;amp;gt;"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt;
                  &lt;span class="s2"&gt;"&amp;amp;lt;/div&amp;amp;gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/pre&gt;


&lt;p&gt;The second step is to replace all the old html with the new tags.  (I did
that, too, of course.)  And there we go.  That’s it.  In the file I was
modifying, the combination of that and moving the javascript out into a
separate file took the html from 275 lines down to 146 lines, and let me more
easily change the buttons around, and add new ones.  I call that a win, and
from now on, whenever I see large blocks of repeated html, I’m going to be
seriously tempted to switch them to an x-tag!&lt;/p&gt;
&lt;p&gt;One caveat I will mention is that in my first attempt, I tried to use both the
&lt;code&gt;content&lt;/code&gt; property, and the &lt;code&gt;onCreate&lt;/code&gt; method, and that totally didn’t work,
since the content would be replaced by the value of the content property long
before I had a chance to muck around with it in the onCreate.  So in the future,
I think I’ll just jump straight into using the onCreate method, since it’s not
that much harder.&lt;/p&gt;&lt;/div&gt;</description><category>html</category><category>mozilla</category><category>xtag</category><guid>https://bwinton.github.io/weblog.latte.ca/blake/employment/mozilla/x-tags/</guid><pubDate>Fri, 13 Jul 2012 01:39:32 GMT</pubDate></item><item><title>Requiring jQuery UI.</title><link>https://bwinton.github.io/weblog.latte.ca/blake/employment/mozilla/jqueryui/</link><dc:creator>Blake Winton</dc:creator><description>&lt;div&gt;&lt;p&gt;Yesterday afternoon, I watched &lt;a href="https://air.mozilla.org/apps-templates-dev-ecosystem-tools/"&gt;a video&lt;/a&gt; from &lt;a href="https://twitter.com/jlongster"&gt;James Long&lt;/a&gt; about &lt;a href="https://github.com/mozilla/mortar"&gt;Mortar&lt;/a&gt;, which is a template for making HTML 5 Open Web Apps.  Now, coincidentally, I’m starting a new project (in my spare time, obviously, since it’s a Sunday), and while it’s not an Open Web App, I saw no reason not to use the &lt;a href="https://github.com/volojs/volo"&gt;same&lt;/a&gt; &lt;a href="http://requirejs.org/"&gt;tools&lt;/a&gt; they were using.&lt;/p&gt;
&lt;p&gt;Of course, since nothing’s easy, I ran into a problem pretty quickly.  My problem was that every time I tried to &lt;code&gt;require("jquery-ui");&lt;/code&gt;, I got an error of “ReferenceError: jQuery is not defined”.  There wasn’t a lot of information about how to fix it, so after most of an afternoon mucking around, I finally came up with something that seems to work, and thought I would post it.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Go into your &lt;code&gt;www/js/lib&lt;/code&gt; directory.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;curl -O https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.js&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Edit the jquery-ui.js file.  At the top add the line &lt;code&gt;define(["jquery"], function (jQuery) {&lt;/code&gt;, and at the bottom, add the line &lt;code&gt;});&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;That’s it.  From there you should be good to go!&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Now, I suspect there’s a better way to do this, and hopefully &lt;a href="https://twitter.com/jrburke"&gt;James&lt;/a&gt; or &lt;a href="https://twitter.com/clarkbw"&gt;Bryan&lt;/a&gt; will jump in the comments and tell me what it is, but for now, at least this works.&lt;/p&gt;&lt;/div&gt;</description><category>jquery-ui</category><category>mozilla</category><category>requirejs</category><guid>https://bwinton.github.io/weblog.latte.ca/blake/employment/mozilla/jqueryui/</guid><pubDate>Sun, 08 Jul 2012 22:14:31 GMT</pubDate></item></channel></rss>