diff options
-rw-r--r-- | .gitignore | 4 | ||||
-rwxr-xr-x | build.py | 61 | ||||
-rwxr-xr-x | build.sh | 7 | ||||
-rw-r--r-- | css/help.css | 6 | ||||
-rw-r--r-- | css/popup.css | 2 | ||||
-rw-r--r-- | css/redirector.css | 115 | ||||
-rw-r--r-- | help.html | 5 | ||||
-rw-r--r-- | icon.html | 13 | ||||
-rw-r--r-- | images/icon128active.png | bin | 1289 -> 1211 bytes | |||
-rw-r--r-- | images/icon128disabled.png | bin | 1275 -> 1202 bytes | |||
-rw-r--r-- | images/icon128redirected.png | bin | 0 -> 1168 bytes | |||
-rw-r--r-- | js/background.js | 25 | ||||
-rw-r--r-- | js/controllers/redirectorpage.js | 7 | ||||
-rw-r--r-- | js/platform.js | 6 | ||||
-rw-r--r-- | js/redirect.js | 2 | ||||
-rw-r--r-- | manifest.json | 1 | ||||
-rw-r--r-- | popup.html | 4 | ||||
-rw-r--r-- | redirector.html | 106 |
18 files changed, 245 insertions, 119 deletions
@@ -1,3 +1,7 @@ *.xpi *.DS_Store +*.zip +build/* +ffox.sh + diff --git a/build.py b/build.py new file mode 100755 index 0000000..741da58 --- /dev/null +++ b/build.py @@ -0,0 +1,61 @@ +#!/usr/bin/python + +import os, os.path, re, zipfile, json + +def get_files_to_zip(): + #Exclude git stuff, build scripts etc. + exclude = [r'(\\|/)\.git(\\|/)', r'\.(py|sh)$', r'\.DS_Store$', r'\.gitignore$',r'(\\|/)build(\\|/)'] + + zippable_files = [] + for root, folders, files in os.walk('.'): + for f in files: + file = os.path.join(root,f) + if not any(re.search(p, file) for p in exclude): + zippable_files.append(file) + return zippable_files + +def create_addon(files, browser): + output_folder = 'build' + if not os.path.isdir(output_folder): + os.mkdir(output_folder) + + extension = 'zip' + if browser == 'firefox': + extension = 'xpi' + + output_file = os.path.join(output_folder, 'redirector-%s.%s' % (browser, extension)) + zf = zipfile.ZipFile(output_file, 'w', zipfile.ZIP_STORED) + + print '' + print '**** Creating addon for %s ****' % browser + for f in files: + print 'Adding', f + if f.endswith('manifest.json'): + manifest = json.load(open(f)) + if browser != 'firefox': + del manifest['applications'] #Firefox specific, and causes warnings in other browsers... + + if browser == 'opera': + manifest['options_ui']['page'] = 'redirector.html' #Opera opens options in new tab, where the popup would look really ugly + manifest['options_ui']['chrome_style'] = False + + zf.writestr(f[2:], json.dumps(manifest, indent=2)) + else: + zf.write(f[2:]) + + zf.close() + +if __name__ == '__main__': + #Make sure we can run this from anywhere + folder = os.path.dirname(os.path.realpath(__file__)) + os.chdir(folder) + + files = get_files_to_zip() + + print '******* REDIRECTOR BUILD SCRIPT *******' + print '' + + browsers = ['chrome', 'firefox', 'opera'] + for b in browsers: + create_addon(files, b) + diff --git a/build.sh b/build.sh deleted file mode 100755 index 47e0b4b..0000000 --- a/build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh -if [ -f Redirector.xpi ]; -then - rm Redirector.xpi -fi - -zip Redirector.xpi * -r -x *unittest* *.DS_Store -x .gitignore *.xpi *.sh diff --git a/css/help.css b/css/help.css index ae6928e..02ca9ee 100644 --- a/css/help.css +++ b/css/help.css @@ -30,12 +30,6 @@ h1 { margin-bottom:80px; } -h1 span { - font-size:80px; - position: relative; - top:3px; -} - h4 { font-size:24px; margin-bottom:0px; diff --git a/css/popup.css b/css/popup.css index 7451ec8..1f0069c 100644 --- a/css/popup.css +++ b/css/popup.css @@ -9,6 +9,7 @@ h1 { margin-top:-4px; font-size:22px; font-weight: bold; + letter-spacing: 1.5px; } h1 span { @@ -27,4 +28,5 @@ button { margin-top:-16px; color:red; height:13px; + font-size:12px; }
\ No newline at end of file diff --git a/css/redirector.css b/css/redirector.css index 3eb2d72..18c0977 100644 --- a/css/redirector.css +++ b/css/redirector.css @@ -13,11 +13,10 @@ h1, h2, h3, h5, h6 { h1 { font-size:55px; - margin:-15px 0px 0px 0px; - -webkit-user-select:none; - -moz-user-select:none; + margin-bottom:0px; cursor:default; padding:0px; + letter-spacing: 2.1px; } h3 { @@ -34,7 +33,7 @@ h4 { h5 { font-size:20px; - margin:-20px 0 0 0; + margin:-6px 0 0 0; color:#5e6163; } @@ -170,8 +169,9 @@ input[type="radio"] { /* Table of redirects */ .redirect-table { - width:90%; - max-width: 800px; + width:intrinsic; + max-width:1024px; + min-width:600px; border:solid 1px #bbb; margin:0px auto; border-radius:3px; @@ -179,12 +179,32 @@ input[type="radio"] { .redirect-row { position: relative; - font-size:13px; + font-size:14px; padding:8px; line-height:18px; border-bottom:solid 1px #bbb; } +.redirect-info { + display:table; +} + +.redirect-info div { + display:table-row; +} + +.redirect-info div label { + display:table-cell; + padding:3px 5px; + white-space: nowrap; +} + +.redirect-info div p { + display:table-cell; + word-wrap:break-word; + max-width:900px; +} + .redirect-row:last-child { border-bottom: none !important; } @@ -193,7 +213,7 @@ input[type="radio"] { background:#f8f8f8; } -.redirect-row.disabled label, .redirect-row.disabled span, a.disabled { +.redirect-row.disabled label, .redirect-row.disabled span, .redirect-row.disabled p, a.disabled { color:#bbb !important; } @@ -207,13 +227,15 @@ input[type="radio"] { #delete-redirect-form { position: fixed; - width:500px; + padding:10px; + min-width:500px; + width:intrinsic; background:white; border:solid 1px #bbb; border-radius:3px; z-index: 6000; left:50%; - margin-left:-250px; + margin-left:-260px; top:50%; margin-top:-220px; height:220px; @@ -228,6 +250,16 @@ input[type="radio"] { font-weight:bold; text-align: right; display:inline-block; + vertical-align: top; +} + +#delete-redirect-form div span { + display:inline-block; + width: 330px; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + vertical-align: top; } .redirect-row h4 span.disabled-marker { @@ -277,43 +309,70 @@ a.disabled:hover { #edit-redirect-form { position: fixed; - width:500px; + display:table; + width:700px; background:white; border:solid 1px #bbb; border-radius:3px; z-index: 6000; left:50%; - margin-left:-250px; + margin-left:-350px; top:50%; margin-top:-258px; font-size:12px; } -#edit-redirect-form div{ - margin-bottom:7px; +.form-grid { + display:table; } -#edit-redirect-form div label:first-child { - width:130px; +.form-grid > div{ + display:table-row; +} + +.form-grid > div > label { + display:table-cell; font-weight:bold; text-align: right; + padding:6px; + white-space: nowrap; + width:120px; + vertical-align:top; +} + +.edit-example-result { + width:500px; display:inline-block; + word-wrap:break-word; + margin-top:4px; } -#edit-redirect-form .second-column { - display:block; - margin-left: 133px; +.example-result-error { + margin-top:4px; + display:inline-block; +} + +#unescape-matches, #escape-matches { + margin-top:5px; } -#edit-redirect-form div input[type='text'] { - width:300px; +.form-grid div input[type='text'] { + width:510px; +} + +.input-cell { + padding-top:2px; +} + +.input-cell label { + display:block; } .error { color:red; } -.placeholder, { +.placeholder { color:#c0c0c0; font-size:11px; } @@ -322,6 +381,10 @@ a.disabled:hover { color: #c0c0c0; } +.advanced { + margin-top:8px; +} + #advanced-toggle { padding-top:3px; text-align: center; @@ -335,13 +398,19 @@ a.disabled:hover { text-decoration: underline; } +.advanced div .input-cell label:first-child { + margin-top:2px; +} + a[ng-click] { cursor:pointer; } -#wildcardtype { +#wildcardtype, #regextype { margin-right:10px; + display:inline-block; + margin-top:1px; } .button-container { @@ -1,13 +1,14 @@ <!DOCTYPE html> <html> <head> - <title>Redirector Help</title> + <title>REDIRECTOR HELP</title> <meta charset="UTF-8"> <link rel="stylesheet" href="css/help.css" /> + <link rel="shortcut icon" href="images/icon32active.png"> </head> <body> - <h1><span>☈</span>edirector Help</h1> + <h1>REDIRECTOR HELP</h1> <h3>Table of contents</h3> <ul> <li><a href="#whatisredirector">What is Redirector?</a></li> @@ -21,16 +21,7 @@ <body> <script> - var data = { - 16: [ 32, 0, 16], - 19: [ 35, 1, 18], - 32: [ 64, 1, 32], - 38: [ 75, 2, 38], - 48: [ 95, 1, 48], - 128: [260, 2, 131], - }; - - + function createImageLink(size, logoFontSize, logoX, logoY) { var colors = {'#333' : 'active', '#bbb' : 'disabled', 'green' : 'redirected'}; for (var color in colors) { @@ -59,7 +50,7 @@ createImageLink(32, 64, 1, 32); createImageLink(38, 75, 2, 38); createImageLink(48, 95, 1, 48); - createImageLink(128, 260, 2, 131); + createImageLink(128, 215, 12, 116); }); diff --git a/images/icon128active.png b/images/icon128active.png Binary files differindex fa723bf..5ef6a8b 100644 --- a/images/icon128active.png +++ b/images/icon128active.png diff --git a/images/icon128disabled.png b/images/icon128disabled.png Binary files differindex 0f7d19a..002c9d5 100644 --- a/images/icon128disabled.png +++ b/images/icon128disabled.png diff --git a/images/icon128redirected.png b/images/icon128redirected.png Binary files differnew file mode 100644 index 0000000..8f7c6df --- /dev/null +++ b/images/icon128redirected.png diff --git a/js/background.js b/js/background.js index 15bb89b..f57bbdf 100644 --- a/js/background.js +++ b/js/background.js @@ -21,7 +21,7 @@ var tabIdToIcon = { function log(msg) { if (log.enabled) { - console.log(msg); + console.log('REDIRECTOR: ' + msg); } } log.enabled = true; @@ -49,7 +49,7 @@ function setIcon(image19, image38, tabId) { //decide whether or not we want to redirect. function checkRedirects(details) { - log('Checking: ' details.type + ': ' + details.url); + log('Checking: ' + details.type + ': ' + details.url); //We only allow GET request to be redirected, don't want to accidentally redirect //sensitive POST parameters @@ -166,15 +166,21 @@ function setUpRedirectListener() { redirectEvent.removeListener(checkRedirects); //Unsubscribe first, in case there are changes... - storage.get({redirects:null}, function(obj) { - if (!obj.redirects) { - log('No redirects to set up'); + storage.get({redirects:'firstrun'}, function(obj) { + var redirects = obj.redirects; + + if (redirects === 'firstrun') { + log('No redirects to set up, first run of extension'); //TODO: import old Firefox redirects return; } - partitionedRedirects = createPartitionedRedirects(obj.redirects); - var filter = createFilter(obj.redirects); + if (redirects.length == 0) { + return; + } + + partitionedRedirects = createPartitionedRedirects(redirects); + var filter = createFilter(redirects); log('Setting filter for listener: ' + JSON.stringify(filter)); redirectEvent.addListener(checkRedirects, filter, ["blocking"]); @@ -194,10 +200,11 @@ function updateIcon() { //First time setup updateIcon(); storage.get({disabled:false}, function(obj) { - console.log('REDIRECTOR IS HERE'); if (!obj.disabled) { setUpRedirectListener(); + } else { + log('Redirector is disabled'); } }); -console.log('Redirector starting up...'); +log('Redirector starting up...');
\ No newline at end of file diff --git a/js/controllers/redirectorpage.js b/js/controllers/redirectorpage.js index 05fbe9f..9f0fba6 100644 --- a/js/controllers/redirectorpage.js +++ b/js/controllers/redirectorpage.js @@ -19,15 +19,12 @@ redirectorApp.controller('RedirectorPageCtrl', ['$scope', '$timeout', function($ var arr = $s.redirects.map(normalize); storage.set({redirects:arr}, function() { - console.log('Saved redirects at ' + new Date()); + console.log('Saved ' + arr.length + ' redirects at ' + new Date()); }); } $s.redirects = []; - storage.get('redirects', function(results) { - if (!results || !results.redirects) { - return; - } + storage.get({redirects:[]}, function(results) { for (var i=0; i < results.redirects.length; i++) { $s.redirects.push(normalize(results.redirects[i])); diff --git a/js/platform.js b/js/platform.js deleted file mode 100644 index 293ad7a..0000000 --- a/js/platform.js +++ /dev/null @@ -1,6 +0,0 @@ -//This file contains the stuff that's different between browsers, as much as possible - -//Defaults are the Chrome apis, then we override what's necessary... -var platform = { - -};
\ No newline at end of file diff --git a/js/redirect.js b/js/redirect.js index 16fa78c..7433027 100644 --- a/js/redirect.js +++ b/js/redirect.js @@ -113,7 +113,7 @@ Redirect.prototype = { if (!this.exampleUrl) { - this.error = 'No example URL defined'; + this.error = 'No example URL defined.'; return; } diff --git a/manifest.json b/manifest.json index 834b928..5a1e28d 100644 --- a/manifest.json +++ b/manifest.json @@ -10,6 +10,7 @@ "128": "images/icon128active.png" }, "permissions" : ["webRequest", "webRequestBlocking", "storage", "tabs", "http://*/*", "https://*/*"], + "applications": { "gecko": { "id": "redirector@einaregilsson.com" @@ -1,14 +1,14 @@ <!DOCTYPE html> <html> <head> - <title>Redirector</title> + <title>REDIRECTOR</title> <link rel="stylesheet" href="css/popup.css" /> <meta charset="UTF-8"> <script src="js/angular.min.js"></script> <script src="js/popup.js"></script> </head> <body ng-app="popupApp" ng-controller="PopupCtrl"> - <h1><span>☈</span>edirector</h1> + <h1>REDIRECTOR</h1> <div class="disabled"><span ng-show="disabled">Disabled</span></div> <button ng-click="toggleDisabled()">{{disabled ? 'Enable Redirector' : 'Disable Redirector'}}</button> <button ng-click="openRedirectorSettings()">Edit Redirects</button> diff --git a/redirector.html b/redirector.html index c437288..9f907cb 100644 --- a/redirector.html +++ b/redirector.html @@ -1,9 +1,11 @@ <!DOCTYPE html> <html> <head> - <title>Redirector</title> - <link rel="stylesheet" href="css/redirector.css" /> + <title>REDIRECTOR</title> <meta charset="UTF-8"> + <link rel="stylesheet" href="css/redirector.css" /> + <!-- ☈ --> + <link rel="shortcut icon" href="images/icon32active.png"> <script src="js/angular.min.js"></script> <script src="js/redirect.js"></script> <script src="js/app.js"></script> @@ -49,52 +51,59 @@ <!-- Form for creating and editing redirects --> <div id="edit-redirect-form" ng-show="showEditForm" ng-controller="EditRedirectCtrl"> <h3>{{editIndex >= 0 ? 'Edit' : 'Create'}} Redirect</h3> - <div> - <label>Description:</label> - <input type="text" ng-model="redirect.description" placeholder="Enter a description for your redirect rule" /> - </div> - <div> - <label>Example URL:</label> - <input type="text" ng-model="redirect.exampleUrl" ng-change="redirect.updateExampleResult()" placeholder="http://example.com/some/path?a=1" /> - </div> - <div> - <label>Include pattern:</label> - <input type="text" ng-model="redirect.includePattern" ng-change="redirect.updateExampleResult()" placeholder="Pattern that matches the urls you want to redirect" /> - </div> - <div> - <label>Redirect to:</label> - <input type="text" ng-model="redirect.redirectUrl" ng-change="redirect.updateExampleResult()" placeholder="The url you want to redirect requests to" /> - </div> - <div> - <label>Pattern type:</label> - <label id="wildcardtype"><input type="radio" ng-change="redirect.updateExampleResult()" ng-model="redirect.patternType" name="patterntype" value="W">Wildcard</label> - <label><input type="radio" ng-change="redirect.updateExampleResult()" ng-model="redirect.patternType" name="patterntype" value="R">Regular Expression</label> - </div> - <div> - <label>Example result:</label> - <span class="error" ng-show="redirect.error">{{redirect.error}}</span><span ng-show="redirect.exampleResult">{{redirect.exampleResult}}</span> + <div class="form-grid"> + <div> + <label>Description:</label> + <div class="input-cell"><input type="text" ng-model="redirect.description" placeholder="Enter a description for your redirect rule" /></div> + </div> + <div> + <label>Example URL:</label> + <div class="input-cell"><input type="text" ng-model="redirect.exampleUrl" ng-change="redirect.updateExampleResult()" placeholder="http://example.com/some/path?a=1" /></div> + </div> + <div> + <label>Include pattern:</label> + <div class="input-cell"><input type="text" ng-model="redirect.includePattern" ng-change="redirect.updateExampleResult()" placeholder="Pattern that matches the urls you want to redirect" /></div> + </div> + <div> + <label>Redirect to:</label> + <div class="input-cell"><input type="text" ng-model="redirect.redirectUrl" ng-change="redirect.updateExampleResult()" placeholder="The url you want to redirect requests to" /></div> + </div> + <div> + <label>Pattern type:</label> + <div class="input-cell"> + <label id="wildcardtype"> + <input type="radio" ng-change="redirect.updateExampleResult()" ng-model="redirect.patternType" name="patterntype" value="W">Wildcard</label> + <label id="regextype"> + <input type="radio" ng-change="redirect.updateExampleResult()" ng-model="redirect.patternType" name="patterntype" value="R">Regular Expression</label> + </div> + </div> + <div> + <label>Example result:</label> + <div class="input-cell"><span class="error example-result-error" ng-show="redirect.error">{{redirect.error}}</span><span class="edit-example-result" ng-show="redirect.exampleResult">{{redirect.exampleResult}}</span></div> + </div> </div> <div id="advanced-toggle"> <a ng-click="showAdvanced=true" ng-show="!showAdvanced">Show advanced options...</a> <a ng-click="showAdvanced=false" ng-show="showAdvanced">Hide advanced options...</a> </div> - <div id="advanced" ng-show="showAdvanced"> + <div class="form-grid advanced" ng-show="showAdvanced"> <div> <label>Exclude pattern:</label> - <input type="text" ng-change="redirect.updateExampleResult()" ng-model="redirect.excludePattern" placeholder="Pattern to exclude certain urls from the redirection"/> + <div class="input-cell"><input type="text" ng-change="redirect.updateExampleResult()" ng-model="redirect.excludePattern" placeholder="Pattern to exclude certain urls from the redirection"/></div> </div> <div> <label for="unescape-matches">Unescape matches:</label> - <input id="unescape-matches" ng-change="redirect.updateExampleResult()" ng-model="redirect.unescapeMatches" type="checkbox"><span class="placeholder">E.g. turn %2Fbar%2Ffoo%3Fx%3D2 into /bar/foo?x=2</span> + <div class="input-cell"><input id="unescape-matches" ng-change="redirect.updateExampleResult()" ng-model="redirect.unescapeMatches" type="checkbox"><span class="placeholder">E.g. turn %2Fbar%2Ffoo%3Fx%3D2 into /bar/foo?x=2</span></div> </div> <div> <label for="escape-matches">Escape matches:</label> - <input id="escape-matches" ng-change="redirect.updateExampleResult()" ng-model="redirect.escapeMatches" type="checkbox"><span class="placeholder">E.g. turn /bar/foo?x=2 into %2Fbar%2Ffoo%3Fx%3D2</span> + <div class="input-cell"><input id="escape-matches" ng-change="redirect.updateExampleResult()" ng-model="redirect.escapeMatches" type="checkbox"><span class="placeholder">E.g. turn /bar/foo?x=2 into %2Fbar%2Ffoo%3Fx%3D2</span></div> </div> <div> <label>Apply to:</label> - - <label ng-repeat="(key,value) in requestTypes " ng-class="{'second-column' : !$first}"><input type="checkbox" ng-checked="appliesTo(key)" ng-click="toggleApplies(key)">{{value}}</label> + <div class="input-cell"> + <label ng-repeat="(key,value) in requestTypes"><input type="checkbox" ng-checked="appliesTo(key)" ng-click="toggleApplies(key)">{{value}}</label> + </div> </div> </div> @@ -107,7 +116,7 @@ <div id="blur-wrapper" ng-class="{blur: showEditForm || showDeleteForm}"> - <h1><span style="font-size:100px; position:relative; top:4px">☈</span>edirector</h1> + <h1>REDIRECTOR</h1> <h5>Go where <em>YOU</em> want!</h5> <div id="menu"> @@ -132,20 +141,23 @@ <div class="redirect-table" ng-controller="ListRedirectsCtrl"> <div class="redirect-row" ng-class="{disabled: r.disabled}" ng-repeat="r in redirects"> <h4><span class="disabled-marker" ng-show="r.disabled">[Disabled] </span><span>{{r.description}}</span></h4> - <div> - <label>Redirect:</label> <span>{{r.includePattern}}</span> - </div> - <div> - <label>to:</label> <span>{{r.redirectUrl}}</span> - </div> - <div ng-show="r.excludePattern"> - <label>excluding:</label> <span>asdfasdf</span> - </div> - <div> - <label>Example:</label> <span class="error" ng-show="r.error">{{r.error}}</span><span ng-show="r.exampleResult">{{r.exampleUrl}} <span class="arrow">→</span> {{r.exampleResult}}</span> - </div> - <div> - <label>Applies to:</label> <span>{{r.appliesTo|requestTypeDisplay}}</span> + <div class="redirect-info"> + <div> + <label>Redirect:</label> + <p>{{r.includePattern}}</p> + </div> + <div> + <label>to:</label><p>{{r.redirectUrl}}</p> + </div> + <div ng-show="r.excludePattern"> + <label>excluding:</label><p>asdfasdf</p> + </div> + <div> + <label>Example:</label> <p><span class="error" ng-show="r.error">{{r.error}}</span><span ng-show="r.exampleResult">{{r.exampleUrl}} <span class="arrow">→</span> {{r.exampleResult}}</span></p> + </div> + <div> + <label>Applies to:</label> <p>{{r.appliesTo|requestTypeDisplay}}</p> + </div> </div> <div> <a class="btn blue" ng-click="toggleDisabled(r)">{{r.disabled ? "Enable" : "Disable"}}</a> |