Skip to content

Commit

Permalink
Update 'Contributors' section automatically in about:nightly (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
xabolcs authored and whimboo committed Sep 26, 2012
1 parent 6528261 commit 3368984
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 15 deletions.
2 changes: 1 addition & 1 deletion extension/chrome.manifest
Expand Up @@ -34,4 +34,4 @@ overlay chrome://navigator/content/navigator.xul chrome://n

# Songbird chrome
overlay chrome://songbird/content/xul/layoutBaseOverlay.xul chrome://nightly/content/songbirdOverlay.xul application=songbird@songbirdnest.com

override chrome://nightly/skin/aboutNightly/aboutNightly.css chrome://nightly/skin/aboutNightly/aboutNightly-sb.css application=songbird@songbirdnest.com
135 changes: 135 additions & 0 deletions extension/chrome/content/aboutNightly/aboutNightly.js
@@ -0,0 +1,135 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Nightly Tester Tools.
*
* The Initial Developer of the Original Code is
* Szabolcs Hubai <szab.hu@gmail.com>.
*
* Portions created by the Initial Developer are Copyright (C) 2012
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Robert Strong <robert.bugzilla@gmail.com>
* Blair McBride <bmcbride@mozilla.com>
* Marcos Santiago <littledodgeviper@sbcglobal.net>
* Jimmy Phan <jphan9@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */

const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;

const ADDON_ID = "{8620c15f-30dc-4dba-a131-7c5d20cf4a29}";


function init() {
window.removeEventListener("load", init, false);

try {
var { AddonManager: manager } = Cu.import("resource://gre/modules/AddonManager.jsm");
} catch (e) {
var manager = ExtensionManager;
}

manager.getAddonByID(ADDON_ID, fillContributorsCallback);
}

function fillContributorsCallback(aAddon) {
appendToList("about", "about", [ aAddon.creator ], "label");
appendToList("contributors", "contributorsList", aAddon.contributors, "li");
}

var ExtensionManager = {
getAddonByID: function (aID, aCallback) {
if (!aID || typeof aID !== "string") {
throw Components.Exception("aID must be a non-empty string",
Cr.NS_ERROR_INVALID_ARG);
}

if (typeof aCallback !== "function") {
throw Components.Exception("aCallback must be a function",
Cr.NS_ERROR_INVALID_ARG);
}

function EM_NS(aProperty) {
return "http://www.mozilla.org/2004/em-rdf#" + aProperty;
}

var em = Cc['@mozilla.org/extensions/manager;1']
.getService(Ci.nsIExtensionManager);
var rdfs = Cc["@mozilla.org/rdf/rdf-service;1"]
.getService(Ci.nsIRDFService);
var ds = em.datasource;
var extension = rdfs.GetResource("urn:mozilla:item:" + aID);

var addon = { creator: {}, contributors: [] };

arc = rdfs.GetResource(EM_NS("creator"));
var creator = ds.GetTarget(extension, arc, true);
if (creator) {
addon.creator.name = creator.QueryInterface(Ci.nsIRDFLiteral).Value;
}

arc = rdfs.GetResource(EM_NS("contributor"));
var contributors = ds.GetTargets(extension, arc, true);
if (contributors.hasMoreElements()) {
while (contributors.hasMoreElements()) {
addon.contributors.push({
name: contributors.getNext().QueryInterface(Ci.nsIRDFLiteral).Value
});
}
}

aCallback(addon);
}
}

function appendToList(aHeaderId, aNodeId, aItems, aEType) {
var header = document.getElementById(aHeaderId);
var node = document.getElementById(aNodeId);

if (!aItems || aItems.length === 0) {
header.hidden = true;
return 0;
}

aItems.forEach(function (aCurrentItem) {
var url = aCurrentItem.url;
var listElem = document.createElement(aEType);
var textContainer = listElem;
if (url) {
textContainer = document.createElement("a");
listElem.appendChild(textContainer);
textContainer.href = url;
}
textContainer.textContent = aCurrentItem.name;
node.appendChild(listElem);
});

return aItems.length;
}


window.addEventListener("load", init, false);
Expand Up @@ -57,24 +57,20 @@
<head>
<title>About Nightly Test Tools</title>
<link rel="stylesheet" href="chrome://global/skin/about.css" type="text/css"/>
<link rel="stylesheet" href="chrome://nightly/skin/aboutNightly/aboutNightly.css" type="text/css"/>
<script src="chrome://nightly/content/aboutNightly/aboutNightly.js"></script>
</head>
<body>
<h1>About Nightly Tester Tools</h1>

<div id="about"><a name="about"></a>
Original author:
<a href="http://www.oxymoronical.com/">
Dave Townsend
</a>
Author:
</div>

<div id="contributors"><a name="contributors"></a>
<h2>Contributors</h2>

<ul>
<li><a href="http://github.com/harthur">harth</a></li>
<li><a href="http://k0s.org/mozilla">Jeff Hammel</a></li>
</ul>
<ul id="contributorsList" />
</div>

<div id="features"><a name="features"></a>
Expand All @@ -100,7 +96,7 @@
</a>
</li>
<li>
<a href="https://wiki.mozilla.org/Auto-tools/Projects/NightlyTesterTools">
<a href="https://wiki.mozilla.org/Auto-tools/Automation_Development/Projects/Addons/NightlyTesterTools">
Wiki
</a>
</li>
Expand All @@ -111,12 +107,12 @@
</li>

<li>
<a href="https://bugzilla.mozilla.org/buglist.cgi?component=Nightly%20Tester%20Tools&amp;product=Other%20Applications&amp;resolution=---">
<a href="https://github.com/mozilla/nightlytt/issues">
Bugs and feature requests
</a>
</li>
<li>
<a href="http://github.com/mozautomation/nightlytt">
<a href="https://github.com/mozilla/nightlytt">
Source code
</a>
</li>
Expand Down
53 changes: 53 additions & 0 deletions extension/chrome/skin/aboutNightly/aboutNightly-sb.css
@@ -0,0 +1,53 @@
html {
background: -moz-Dialog;
padding: 0 1em;
font: message-box;
}

body {
color: -moz-FieldText;
position: relative;
min-width: 330px;
max-width: 50em;
margin: 4em auto;
border: 1px solid ThreeDShadow;
-moz-border-radius: 10px;
padding: 3em;
-moz-padding-start: 30px;
background: -moz-Field;
}

.aboutPageWideContainer {
max-width: 80%;
}

#aboutLogoContainer {
border: 1px solid ThreeDLightShadow;
width: 300px;
margin-bottom: 2em;
}

img {
border: 0;
}

#version {
font-weight: bold;
color: #909090;
margin: -24px 0 9px 17px;
}

ul {
margin: 0;
-moz-margin-start: 1.5em;
padding: 0;
list-style: square;
}

ul > li {
margin-top: .5em;
}

th, td {
padding: 0 5px;
}
Empty file.
2 changes: 1 addition & 1 deletion extension/components/aboutNightly.js
Expand Up @@ -16,7 +16,7 @@ AboutNightly.prototype = {

newChannel: function(aURI) {
let ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
let channel = ios.newChannel("chrome://nightly/content/aboutNightly.xhtml",
let channel = ios.newChannel("chrome://nightly/content/aboutNightly/aboutNightly.xhtml",
null, null);
channel.originalURI = aURI;
return channel;
Expand Down
4 changes: 2 additions & 2 deletions extension/install.rdf
Expand Up @@ -13,7 +13,7 @@
<!-- Front End MetaData -->
<em:name>Nightly Tester Tools</em:name>
<em:description>Useful tools for the nightly tester.</em:description>
<em:creator>Mozilla QA Automation Services</em:creator>
<em:creator>Automation Development</em:creator>
<em:contributor>Dave Hunt</em:contributor>
<em:contributor>Dave Townsend (original author)</em:contributor>
<em:contributor>Ed Morley</em:contributor>
Expand All @@ -29,7 +29,7 @@
<em:contributor>Tony Mechelynck</em:contributor>

<em:iconURL>chrome://nightly/content/brand/icon.png</em:iconURL>
<em:homepageURL>https://wiki.mozilla.org/QA/Automation_Services/Projects/Addons/NightlyTesterTools</em:homepageURL>
<em:homepageURL>https://wiki.mozilla.org/Auto-tools/Automation_Development/Projects/Addons/NightlyTesterTools</em:homepageURL>

<!-- Firefox version -->
<em:targetApplication>
Expand Down

0 comments on commit 3368984

Please sign in to comment.