Skip to content

Instantly share code, notes, and snippets.

@briandrum
Last active December 21, 2015 15:08
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briandrum/6324052 to your computer and use it in GitHub Desktop.
Save briandrum/6324052 to your computer and use it in GitHub Desktop.
// After making the required edits below, use something like http://daringfireball.net/2007/03/javascript_bookmarklet_builder to create the bookmarklet.
(function(){
var form=document.createElement("form");
// Edit the action value to match your domain and section names.
form.setAttribute("action","http://example.com/symphony/publish/entries/new/");
form.setAttribute("method","post");
// Edit the params to match your auth-token
// (found on the author page) and section fields.
var params={
"auth-token":"your-auth-token",
"fields[date-published]":new Date(),
"fields[title]":document.title,
"fields[body]":(function(){
var html = "";
var sel = window.getSelection();
if (sel.rangeCount) {
var container = document.createElement("div");
var blockquote = document.createElement("blockquote");
for (var i = 0, len = sel.rangeCount; i < len; ++i) {
blockquote.appendChild(sel.getRangeAt(i).cloneContents());
}
container.appendChild(blockquote);
html = container.innerHTML;
}
return html;
})(),
"fields[url]":document.URL,
"action[save]":""
};
for(var key in params) {
if(params.hasOwnProperty(key)) {
var hiddenField=document.createElement("input");
hiddenField.setAttribute("type","hidden");
hiddenField.setAttribute("name",key);
hiddenField.setAttribute("value",params[key]);
form.appendChild(hiddenField);
}
};
document.body.appendChild(form);
form.submit();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment