Skip to content

Commit

Permalink
completes #184 by adding options for markdown convertion
Browse files Browse the repository at this point in the history
  • Loading branch information
neocotic committed May 13, 2013
1 parent e13521d commit ec8cb56
Show file tree
Hide file tree
Showing 10 changed files with 298 additions and 61 deletions.
76 changes: 75 additions & 1 deletion chrome/bin/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -668,13 +668,25 @@
}
},
"opt_anchor_text": {
"message": "This section refers to links that are rendered by the $O_EMPH$Anchor$C_EMPH$ template.",
"message": "This section refers to $O_ABBR_1$HyperText Markup Language$O_ABBR_2$HTML$C_ABBR$ links that are rendered by the $O_EMPH$Anchor$C_EMPH$ template.",
"description": "Text for the Anchor Tags section.",
"placeholders": {
"c_abbr": {
"content": "</abbr>",
"example": "</abbr>"
},
"c_emph": {
"content": "</em>",
"example": "</em>"
},
"o_abbr_1": {
"content": "<abbr title=\"",
"example": "<abbr title=\""
},
"o_abbr_2": {
"content": "\">",
"example": "\">"
},
"o_emph": {
"content": "<em>",
"example": "<em>"
Expand Down Expand Up @@ -2493,6 +2505,20 @@
}
}
},
"opt_guide_options_markdown_inline_text": {
"message": "Whether or not the option to render $O_LINK_MARKDOWN$Markdown$C_LINK$ links using the inline style is enabled",
"description": "Description of the markdownInline variable on the Guide tab of the Options page under the Options section.",
"placeholders": {
"c_link": {
"content": "</a>",
"example": "</a>"
},
"o_link_markdown": {
"content": "<a href=\"http://en.wikipedia.org/wiki/Markdown\" target=\"_blank\">",
"example": "<a href=\"http://en.wikipedia.org/wiki/Markdown\">"
}
}
},
"opt_guide_options_menu_text": {
"message": "Whether or not the option to show the context (right-click) menu is enabled",
"description": "Description of the menu variable on the Guide tab of the Options page under the Options section."
Expand Down Expand Up @@ -3385,6 +3411,54 @@
"message": "Warning",
"description": "Text for the Warning option for the Level field in the Developer Tools dialog on the Options page under the Logging section."
},
"opt_markdown_header": {
"message": "Markdown",
"description": "Header for the Markdown section."
},
"opt_markdown_text": {
"message": "This section refers to content that is converted to $O_LINK_MARKDOWN$Markdown$C_LINK$ from $O_ABBR_1$HyperText Markup Language$O_ABBR_2$HTML$C_ABBR$.",
"description": "Text for the Markdown section.",
"placeholders": {
"c_abbr": {
"content": "</abbr>",
"example": "</abbr>"
},
"c_link": {
"content": "</a>",
"example": "</a>"
},
"o_abbr_1": {
"content": "<abbr title=\"",
"example": "<abbr title=\""
},
"o_abbr_2": {
"content": "\">",
"example": "\">"
},
"o_link_markdown": {
"content": "<a href=\"http://en.wikipedia.org/wiki/Markdown\" target=\"_blank\">",
"example": "<a href=\"http://en.wikipedia.org/wiki/Markdown\">"
}
}
},
"opt_markdown_inline_label": {
"message": "Inline Links",
"description": "Label for the Inline Links field."
},
"opt_markdown_inline_sub_text": {
"message": "Markdown links are rendered using the inline style $CODE$",
"description": "Help text for the Inline Links field.",
"placeholders": {
"code": {
"content": "<code>[text](url)</code>",
"example": "[title](url)"
}
}
},
"opt_markdown_inline_text": {
"message": "Link references no longer listed at the end of the output",
"description": "Text for the Inline Links field."
},
"opt_menu_header": {
"message": "Context Menu",
"description": "Header for the Context Menu section on the General tab of the Options page."
Expand Down
1 change: 0 additions & 1 deletion chrome/bin/css/options.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ a {cursor: pointer;}
a.ref-link {font-weight: bold;}
a.ref-link:hover {text-decoration: none;}
abbr[data-original-title] {cursor: help; border-bottom: 1px dotted #ddd;}
legend + p {margin-top: 18px; -webkit-margin-top-collapse: separate;}
input[type="file"] {margin-top: -3px;}
input[type="file"]::-webkit-file-upload-button {display: inline-block; *display: inline; *zoom: 1; padding: 4px 12px; margin-bottom: 0; font-size: 14px; line-height: 20px; text-align: center; vertical-align: middle; cursor: pointer; color: #333; text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); background-color: #f5f5f5; background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6); background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6)); background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6); background-image: -o-linear-gradient(top, #ffffff, #e6e6e6); background-image: linear-gradient(to bottom, #ffffff, #e6e6e6); background-repeat: repeat-x; filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffffff', endColorstr='#ffe6e6e6', GradientType=0); border-color: #e6e6e6 #e6e6e6 #bfbfbf; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); *background-color: #e6e6e6; filter:progid:DXImageTransform.Microsoft.gradient(enabled = false); border: 1px solid #bbb; *border: 0; border-bottom-color: #a2a2a2; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; *margin-left: .3em; -webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05); -moz-box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05); box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05);}
input[type="file"]::-webkit-file-upload-button:hover, input[type="file"]::-webkit-file-upload-button:active, input[type="file"].active::-webkit-file-upload-button, input[type="file"].disabled::-webkit-file-upload-button, input[type="file"][disabled]::-webkit-file-upload-button {color: #333; background-color: #e6e6e6; *background-color: #d9d9d9;}
Expand Down
28 changes: 23 additions & 5 deletions chrome/bin/lib/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// For all details and documentation:
// <http://neocotic.com/template>
(function() {
var AppError, BLACKLIST, DEFAULT_TEMPLATES, EXTENSION_ID, Extension, HOMEPAGE_DOMAIN, Icon, OPERATING_SYSTEMS, POPUP_DELAY, REAL_EXTENSION_ID, R_EXPRESSION_TAG, R_UPPER_CASE, R_VALID_URL, SHORTENERS, SUPPORT, UNKNOWN_LOCALE, addAdditionalData, browser, buildConfig, buildDerivedData, buildIcons, buildPopup, buildStandardData, buildTemplate, callUrlShortener, deriveMessageInfo, deriveMessageTempate, evaluateExpressions, executeScriptsInExistingWindows, ext, getActiveUrlShortener, getBrowserVersion, getHotkeys, getOperatingSystem, getTemplateWithKey, getTemplateWithMenuId, getTemplateWithShortcut, initStatistics, initTemplate, initTemplates, initTemplates_update, initToolbar, initToolbar_update, initUrlShorteners, initUrlShorteners_update, init_update, isBlacklisted, isExtensionActive, isNewInstall, isProductionBuild, isProtectedPage, isSpecialPage, isWebStore, nullIfEmpty, onMessage, onMessageExternal, operatingSystem, selectOrCreateTab, showNotification, transformData, updateHotkeys, updateProgress, updateStatistics, updateTemplateUsage, updateUrlShortenerUsage, _ref,
var AppError, BLACKLIST, DEFAULT_TEMPLATES, EXTENSION_ID, Extension, HOMEPAGE_DOMAIN, Icon, OPERATING_SYSTEMS, POPUP_DELAY, REAL_EXTENSION_ID, R_EXPRESSION_TAG, R_UPPER_CASE, R_VALID_URL, SHORTENERS, SUPPORT, UNKNOWN_LOCALE, addAdditionalData, browser, buildConfig, buildDerivedData, buildIcons, buildPopup, buildStandardData, buildTemplate, callUrlShortener, deriveMessageInfo, deriveMessageTempate, evaluateExpressions, executeScriptsInExistingWindows, ext, getActiveUrlShortener, getBrowserVersion, getHotkeys, getOperatingSystem, getTemplateWithKey, getTemplateWithMenuId, getTemplateWithShortcut, initStatistics, initTemplate, initTemplates, initTemplates_update, initToolbar, initToolbar_update, initUrlShorteners, initUrlShorteners_update, init_update, isBlacklisted, isExtensionActive, isNewInstall, isProductionBuild, isProtectedPage, isSpecialPage, isWebStore, nullIfEmpty, onMessage, onMessageExternal, operatingSystem, selectOrCreateTab, showNotification, toMarkdown, transformData, updateHotkeys, updateProgress, updateStatistics, updateTemplateUsage, updateUrlShortenerUsage, _ref,
__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; },
__hasProp = {}.hasOwnProperty,
__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 @@ -752,6 +752,16 @@
return updateProgress(null, false);
};

toMarkdown = function(html) {
var inline;

log.trace();
inline = store.get('markdown').inline;
return md(html, {
inline: inline
});
};

updateHotkeys = function() {
var hotkeys;

Expand Down Expand Up @@ -1021,7 +1031,7 @@
};

buildStandardData = function(tab, getCallback) {
var anchor, bitly, ctab, data, extension, googl, handler, menu, notifications, shortcuts, stats, toolbar, url, yourls;
var anchor, bitly, ctab, data, extension, googl, handler, markdown, menu, notifications, shortcuts, stats, toolbar, url, yourls;

log.trace();
ctab = $.extend({}, tab);
Expand All @@ -1042,6 +1052,7 @@
anchor = store.get('anchor');
bitly = store.get('bitly');
googl = store.get('googl');
markdown = store.get('markdown');
menu = store.get('menu');
notifications = store.get('notifications');
shortcuts = store.get('shortcuts');
Expand Down Expand Up @@ -1142,13 +1153,14 @@
};
},
linkmarkdown: function() {
return md(this.linkhtml);
return toMarkdown(this.linkhtml);
},
lowercase: function() {
return function(text, render) {
return render(text).toLowerCase();
};
},
markdowninline: markdown.inline,
menu: menu.enabled,
menuoptions: menu.options,
menupaste: menu.paste,
Expand Down Expand Up @@ -1199,7 +1211,7 @@
return getCallback('selecthtml');
},
selectionmarkdown: function() {
return md(this.selectionhtml);
return toMarkdown(this.selectionhtml);
},
selectmarkdown: function() {
return getCallback('selectmarkdown');
Expand Down Expand Up @@ -1373,7 +1385,7 @@
result = result.join('\n');
}
if (convertTo === 'markdown') {
result = md(result);
result = toMarkdown(result);
}
map[placeholder] = result;
}
Expand Down Expand Up @@ -2198,6 +2210,7 @@
}
store.init({
anchor: {},
markdown: {},
menu: {},
notifications: {},
shortcuts: {},
Expand All @@ -2214,6 +2227,11 @@
}
return (_ref2 = anchor.title) != null ? _ref2 : anchor.title = false;
});
store.modify('markdown', function(markdown) {
var _ref1;

return (_ref1 = markdown.inline) != null ? _ref1 : markdown.inline = false;
});
store.modify('menu', function(menu) {
var _ref1, _ref2, _ref3;

Expand Down
13 changes: 12 additions & 1 deletion chrome/bin/lib/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,17 @@
};

load = function() {
var anchor, menu, shortcuts;
var anchor, markdown, menu, shortcuts;

log.trace();
anchor = store.get('anchor');
markdown = store.get('markdown');
menu = store.get('menu');
shortcuts = store.get('shortcuts');
$('#analytics').prop('checked', store.get('analytics'));
$('#anchorTarget').prop('checked', anchor.target);
$('#anchorTitle').prop('checked', anchor.title);
$('#markdownInline').prop('checked', markdown.inline);
$('#menuEnabled').prop('checked', menu.enabled);
$('#menuOptions').prop('checked', menu.options);
$('#menuPaste').prop('checked', menu.paste);
Expand Down Expand Up @@ -229,6 +231,15 @@
}, function(jel, key, value) {
return analytics.track('Anchors', 'Changed', utils.capitalize(key), Number(value));
});
bindSaveEvent('#markdownInline', 'change', 'markdown', function(key) {
var value;

value = this.is(':checked');
log.debug("Changing markdown " + key + " to '" + value + "'");
return value;
}, function(jel, key, value) {
return analytics.track('Markdown', 'Changed', utils.capitalize(key), Number(value));
});
bindSaveEvent('#menuEnabled, #menuOptions, #menuPaste', 'change', 'menu', function(key) {
var value;

Expand Down
66 changes: 42 additions & 24 deletions chrome/bin/pages/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,6 @@
<div class="row">
<div class="span12">
<form class="form-horizontal">
<fieldset>
<legend i18n-content="opt_anchor_header"></legend>
<p i18n-content="opt_anchor_text"></p>
<div class="control-group">
<label class="control-label" for="anchorTitle" i18n-content="opt_anchor_title_label"></label>
<div class="controls">
<label class="checkbox span5 tight-left">
<input type="checkbox" id="anchorTitle">
<span i18n-content="opt_anchor_title_text"></span>
<p class="help-block" i18n-content="opt_anchor_title_sub_text"></p>
</label>
</div>
</div>
<div class="control-group">
<label class="control-label" for="anchorTarget" i18n-content="opt_anchor_target_label"></label>
<div class="controls">
<label class="checkbox span5 tight-left">
<input type="checkbox" id="anchorTarget">
<span i18n-content="opt_anchor_target_text"></span>
<p class="help-block" i18n-content="opt_anchor_target_sub_text"></p>
</label>
</div>
</div>
</fieldset>
<fieldset>
<legend i18n-content="opt_notification_header"></legend>
<div class="control-group">
Expand Down Expand Up @@ -195,6 +171,44 @@
</div>
</div>
</fieldset>
<fieldset>
<legend i18n-content="opt_anchor_header"></legend>
<p i18n-content="opt_anchor_text"></p>
<div class="control-group">
<label class="control-label" for="anchorTitle" i18n-content="opt_anchor_title_label"></label>
<div class="controls">
<label class="checkbox span5 tight-left">
<input type="checkbox" id="anchorTitle">
<span i18n-content="opt_anchor_title_text"></span>
<p class="help-block" i18n-content="opt_anchor_title_sub_text"></p>
</label>
</div>
</div>
<div class="control-group">
<label class="control-label" for="anchorTarget" i18n-content="opt_anchor_target_label"></label>
<div class="controls">
<label class="checkbox span5 tight-left">
<input type="checkbox" id="anchorTarget">
<span i18n-content="opt_anchor_target_text"></span>
<p class="help-block" i18n-content="opt_anchor_target_sub_text"></p>
</label>
</div>
</div>
</fieldset>
<fieldset>
<legend i18n-content="opt_markdown_header"></legend>
<p i18n-content="opt_markdown_text"></p>
<div class="control-group">
<label class="control-label" for="markdownInline" i18n-content="opt_markdown_inline_label"></label>
<div class="controls">
<label class="checkbox span5 tight-left">
<input type="checkbox" id="markdownInline">
<span i18n-content="opt_markdown_inline_text"></span>
<p class="help-block" i18n-content="opt_markdown_inline_sub_text"></p>
</label>
</div>
</div>
</fieldset>
<fieldset>
<legend i18n-content="opt_misc_header"></legend>
<div class="control-group">
Expand Down Expand Up @@ -965,6 +979,10 @@ <h3 i18n-content="opt_guide_notes_header"></h3>
<td>googlAccount</td>
<td i18n-content="opt_guide_options_googl_account_text"></td>
</tr>
<tr>
<td>markdownInline <span class="label label-success pull-right" i18n-content="opt_guide_new_text"></span></td>
<td i18n-content="opt_guide_options_markdown_inline_text"></td>
</tr>
<tr>
<td>menu</td>
<td i18n-content="opt_guide_options_menu_text"></td>
Expand Down
Loading

0 comments on commit ec8cb56

Please sign in to comment.