Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New configuration file #130

Merged
merged 1 commit into from Jan 14, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion chrome/Cakefile
Expand Up @@ -185,7 +185,10 @@ task 'dist', "Create #{CWD} distributable file", ->
async.forEach files, optimizeMessage, (err) -> cb err
(cb) ->
# TODO: Support Windows
exec "zip -r ../#{DIST_FILE} *", cwd: TEMP_PATH, cb
exec [
"rm ../#{DIST_FILE}.zip"
"zip -r ../#{DIST_FILE} *"
].join('&&'), cwd: TEMP_PATH, cb
], (err) ->
throw err if err
wrench.rmdirSyncRecursive TEMP_PATH
Expand Down
26 changes: 26 additions & 0 deletions chrome/bin/configuration.json
@@ -0,0 +1,26 @@
{
"options": {
"limits": [
25
, 50
, 75
, 100
]
}
, "services": {
"bitly": {
"api_key": "R_91eabef2f32d88c07b197c9d69eed516"
, "client_id": "deb9b5c6c0c5928674a0601691e404b1de021f0f"
, "client_secret": "d864c9a5ba89e1fc7af5d1c500a63c9232dca331"
, "login": "templateextension"
, "url": "https://api-ssl.bitly.com/v3/shorten"
}
, "googl": {
"api_key": "AIzaSyD504IwHeL3V2aw6ZGYQRgwWnJ38jNl2MY"
, "api_scope": "https://www.googleapis.com/auth/urlshortener"
, "client_id": "962266498046.apps.googleusercontent.com"
, "client_secret": "D15W+qUHliax3uFu1JVpTCSg"
, "url": "https://www.googleapis.com/urlshortener/v1/url"
}
}
}
30 changes: 15 additions & 15 deletions chrome/bin/lib/background.js
Expand Up @@ -4,7 +4,7 @@
// For all details and documentation:
// <http://neocotic.com/template>
(function() {
var BLACKLIST, DEFAULT_TEMPLATES, EXTENSION_ID, Extension, HOMEPAGE_DOMAIN, OPERATING_SYSTEMS, POPUP_DELAY, REAL_EXTENSION_ID, R_SELECT_TAG, R_UPPER_CASE, R_VALID_URL, SHORTENERS, SUPPORT, addAdditionalData, browser, buildDerivedData, buildPopup, buildStandardData, buildTemplate, callUrlShortener, executeScriptsInExistingWindows, ext, getActiveUrlShortener, getBrowserVersion, getHotkeys, getOperatingSystem, getTemplateWithKey, getTemplateWithMenuId, getTemplateWithShortcut, initStatistics, initTemplate, initTemplates, initTemplates_update, initToolbar, initToolbar_update, initUrlShorteners, initUrlShorteners_update, init_update, isBlacklisted, isExtensionActive, isExtensionGallery, isNewInstall, isProductionBuild, isProtectedPage, isSpecialPage, nullIfEmpty, onMessage, operatingSystem, runSelectors, selectOrCreateTab, services, showNotification, transformData, updateHotkeys, updateProgress, updateStatistics, updateTemplateUsage, updateUrlShortenerUsage,
var BLACKLIST, DEFAULT_TEMPLATES, EXTENSION_ID, Extension, HOMEPAGE_DOMAIN, OPERATING_SYSTEMS, POPUP_DELAY, REAL_EXTENSION_ID, R_SELECT_TAG, R_UPPER_CASE, R_VALID_URL, SHORTENERS, SUPPORT, addAdditionalData, browser, buildDerivedData, buildPopup, buildStandardData, buildTemplate, callUrlShortener, executeScriptsInExistingWindows, ext, getActiveUrlShortener, getBrowserVersion, getHotkeys, getOperatingSystem, getTemplateWithKey, getTemplateWithMenuId, getTemplateWithShortcut, initStatistics, initTemplate, initTemplates, initTemplates_update, initToolbar, initToolbar_update, initUrlShorteners, initUrlShorteners_update, init_update, isBlacklisted, isExtensionActive, isExtensionGallery, isNewInstall, isProductionBuild, isProtectedPage, isSpecialPage, nullIfEmpty, onMessage, operatingSystem, runSelectors, selectOrCreateTab, showNotification, transformData, updateHotkeys, updateProgress, updateStatistics, updateTemplateUsage, updateUrlShortenerUsage,
__hasProp = {}.hasOwnProperty,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; },
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
Expand Down Expand Up @@ -134,8 +134,8 @@
if (this.oauth.hasAccessToken()) {
params.access_token = this.oauth.getAccessToken();
} else {
params.apiKey = services.bitly.api_key;
params.login = services.bitly.login;
params.apiKey = ext.config.services.bitly.api_key;
params.login = ext.config.services.bitly.login;
}
return params;
},
Expand All @@ -152,16 +152,16 @@
name: 'bitly',
oauth: function() {
return new OAuth2('bitly', {
client_id: services.bitly.client_id,
client_secret: services.bitly.client_secret
client_id: ext.config.services.bitly.client_id,
client_secret: ext.config.services.bitly.client_secret
});
},
output: function(resp) {
return JSON.parse(resp).data.url;
},
title: i18n.get('shortener_bitly'),
url: function() {
return services.bitly.url;
return ext.config.services.bitly.url;
}
}, {
getHeaders: function() {
Expand All @@ -177,7 +177,7 @@
getParameters: function() {
if (!this.oauth.hasAccessToken()) {
return {
key: services.googl.api_key
key: ext.config.services.googl.api_key
};
}
},
Expand All @@ -196,17 +196,17 @@
name: 'googl',
oauth: function() {
return new OAuth2('google', {
api_scope: services.googl.api_scope,
client_id: services.googl.client_id,
client_secret: services.googl.client_secret
api_scope: ext.config.services.googl.api_scope,
client_id: ext.config.services.googl.client_id,
client_secret: ext.config.services.googl.client_secret
});
},
output: function(resp) {
return JSON.parse(resp).id;
},
title: i18n.get('shortener_googl'),
url: function() {
return services.googl.url;
return ext.config.services.googl.url;
}
}, {
getHeaders: function() {
Expand Down Expand Up @@ -328,8 +328,6 @@

operatingSystem = '';

services = {};

executeScriptsInExistingWindows = function() {
var runner;
log.trace();
Expand Down Expand Up @@ -1996,6 +1994,8 @@

Extension.prototype.SHORTCUT_MAC_MODIFIERS = '&#8679;&#8997;';

Extension.prototype.config = {};

Extension.prototype.notification = {
description: '',
descriptionStyle: '',
Expand Down Expand Up @@ -2067,9 +2067,9 @@
_this.version = data.version;
return runner.next();
});
runner.push(jQuery, 'getJSON', utils.url('services.json'), function(data) {
runner.push(jQuery, 'getJSON', utils.url('configuration.json'), function(data) {
var shortener, _i, _len;
services = data;
_this.config = data;
for (_i = 0, _len = SHORTENERS.length; _i < _len; _i++) {
shortener = SHORTENERS[_i];
shortener.oauth = typeof shortener.oauth === "function" ? shortener.oauth() : void 0;
Expand Down
44 changes: 31 additions & 13 deletions chrome/bin/lib/options.js
Expand Up @@ -318,7 +318,7 @@
};

loadTemplateControlEvents = function() {
var limit, selectedTemplates, validationErrors, warningMsg;
var filter, limit, selectedTemplates, validationErrors, warningMsg, _i, _len, _ref;
log.trace();
$('#template_wizard [tabify]').click(function() {
return closeWizard();
Expand All @@ -329,6 +329,23 @@
$('#template_reset_btn').click(function() {
return resetWizard();
});
filter = $('#template_filter');
filter.find('option').remove();
_ref = ext.config.options.limits;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
limit = _ref[_i];
filter.append($('<option/>', {
text: limit
}));
}
filter.append($('<option/>', {
disabled: 'disabled',
text: '-----'
}));
filter.append($('<option/>', {
text: i18n.get('opt_show_all_text'),
value: 0
}));
store.init('options_limit', parseInt($('#template_filter').val()));
limit = store.get('options_limit');
$('#template_filter option').each(function() {
Expand Down Expand Up @@ -363,26 +380,26 @@
});
validationErrors = [];
$('#template_wizard').on('hide', function() {
var error, _i, _len, _results;
var error, _j, _len1, _results;
_results = [];
for (_i = 0, _len = validationErrors.length; _i < _len; _i++) {
error = validationErrors[_i];
for (_j = 0, _len1 = validationErrors.length; _j < _len1; _j++) {
error = validationErrors[_j];
_results.push(error.hide());
}
return _results;
});
$('#template_save_btn').click(function() {
var error, template, _i, _j, _len, _len1, _results;
var error, template, _j, _k, _len1, _len2, _results;
template = deriveTemplate();
for (_i = 0, _len = validationErrors.length; _i < _len; _i++) {
error = validationErrors[_i];
for (_j = 0, _len1 = validationErrors.length; _j < _len1; _j++) {
error = validationErrors[_j];
error.hide();
}
validationErrors = validateTemplate(template);
if (validationErrors.length) {
_results = [];
for (_j = 0, _len1 = validationErrors.length; _j < _len1; _j++) {
error = validationErrors[_j];
for (_k = 0, _len2 = validationErrors.length; _k < _len2; _k++) {
error = validationErrors[_k];
_results.push(error.show());
}
return _results;
Expand All @@ -405,13 +422,13 @@
});
warningMsg = null;
$('#delete_btn').click(function() {
var deleteItems, div, item, predefinedCount, predefinedTemplates, template, _i, _len;
var deleteItems, div, item, predefinedCount, predefinedTemplates, template, _j, _len1;
deleteItems = $('#delete_items');
predefinedTemplates = $('<ul/>');
selectedTemplates = getSelectedTemplates();
deleteItems.find('li').remove();
for (_i = 0, _len = selectedTemplates.length; _i < _len; _i++) {
template = selectedTemplates[_i];
for (_j = 0, _len1 = selectedTemplates.length; _j < _len1; _j++) {
template = selectedTemplates[_j];
item = $('<li/>', {
text: template.title
});
Expand Down Expand Up @@ -1289,11 +1306,12 @@
return $this.removeAttr('data-original-title');
});
return base.find('[title]').each(function() {
var $this, placement;
var $this, placement, _ref;
$this = $(this);
placement = $this.attr('data-placement');
placement = placement != null ? trimToLower(placement) : 'top';
return $this.tooltip({
container: (_ref = $this.attr('data-container')) != null ? _ref : 'body',
placement: placement
});
});
Expand Down
9 changes: 1 addition & 8 deletions chrome/bin/pages/options.html
Expand Up @@ -220,14 +220,7 @@
<div class="row">
<div class="span12">
<label for="template_filter" i18n-content="opt_show_label"></label>
<select id="template_filter" class="input-mini">
<option>25</option>
<option>50</option>
<option>75</option>
<option>100</option>
<option disabled>-----</option>
<option value="0" i18n-content="opt_show_all_text"></option>
</select>
<select id="template_filter" class="input-mini"></select>
<div id="template_search" class="pull-right input-append">
<button type="reset" class="btn hide" i18n-content="opt_reset_text"></button>
<input id="template_query" type="text" class="input-medium" i18n-values="placeholder:opt_search_placeholder_text">
Expand Down
16 changes: 0 additions & 16 deletions chrome/bin/services.json

This file was deleted.

2 changes: 1 addition & 1 deletion chrome/bin/vendor/bootstrap.min.js

Large diffs are not rendered by default.

Binary file modified chrome/dist/Template.zip
Binary file not shown.