Show info panel when posting to scuttle

This commit is contained in:
Tom Willemse 2016-09-30 15:33:02 +02:00
parent f17ca04d07
commit b8fa90a560

View file

@ -29,6 +29,49 @@ function scuttle_get_url(path)
return url.spec + '/' + path; return url.spec + '/' + path;
} }
function scuttle_send_url(I, obj, default_name) {
var postlinkurl;
var uri_string = load_spec_uri_string(load_spec(obj));
var panel = create_info_panel(
I.window, 'scuttle-panel',
[['scuttle-bookmarking', 'Sending URL to Scuttle: ', uri_string]]
);
try {
let description = yield I.minibuffer.read(
$prompt = "name (required): ",
$initial_value = default_name
);
let tags = yield I.minibuffer.read(
$prompt = "tags (space delimited): "
);
let extended = yield I.minibuffer.read(
$prompt = "extended description: "
);
postlinkurl = scuttle_get_url(
'posts_add.php?&url=' + escape(uri_string) +
'&description=' + escape(description) +
'&tags=' + escape(tags) +
'&extended=' + escape(extended)
);
} finally {
panel.destroy();
}
try {
var content = yield send_http_request(
load_spec({uri: postlinkurl}));
var dom = scuttle_parse_xml(content.responseText);
var result = dom.getElementsByTagName('result')[0];
var code = result.getAttribute('code');
I.window.minibuffer.message(code);
if (code === 'done')
scuttle_bookmarked_hook.run();
} catch (e) { }
}
function scuttle_bookmarked_widget(window) function scuttle_bookmarked_widget(window)
{ {
this.class_name = 'scuttle-bookmark-widget'; this.class_name = 'scuttle-bookmark-widget';
@ -72,81 +115,13 @@ interactive("scuttle-post",
"bookmark the page via scuttle", "bookmark the page via scuttle",
function (I) { function (I) {
check_buffer(I.buffer, content_buffer); check_buffer(I.buffer, content_buffer);
let posturl = scuttle_get_url( co_call(scuttle_send_url(I, I.buffer.top_frame, I.buffer.title));
'posts_add.php?&url=' +
escape(load_spec_uri_string(load_spec(I.buffer.top_frame))) +
'&description=' +
escape((
yield I.minibuffer.read(
$prompt = "name (required): ",
$initial_value = I.buffer.title
)
)) +
'&tags=' +
escape((
yield I.minibuffer.read(
$prompt = "tags (space delimited): "
)
)) +
'&extended=' +
escape((
yield I.minibuffer.read(
$prompt = "extended description: "
)
)));
try {
var content = yield send_http_request(
load_spec({uri: posturl}));
var dom = scuttle_parse_xml(content.responseText);
var result = dom.getElementsByTagName('result')[0];
var code = result.getAttribute('code');
I.window.minibuffer.message(code);
if (code === 'done')
scuttle_bookmarked_hook.run();
} catch (e) { }
}); });
interactive("scuttle-post-link", interactive("scuttle-post-link",
"bookmark the link via scuttle", "bookmark the link via scuttle",
function (I) { function (I) {
var bo = yield read_browser_object(I); let bo = yield read_browser_object(I);
var mylink = load_spec_uri_string(
load_spec(encodeURIComponent(bo)));
check_buffer(I.buffer, content_buffer); check_buffer(I.buffer, content_buffer);
let postlinkurl = scuttle_get_url( co_call(scuttle_send_url(I, encodeURIComponent(bo), bo.textContent));
'posts_add.php?&url=' +
mylink +
'&description=' +
escape((
yield I.minibuffer.read(
$prompt = "name (required): ",
$initial_value = bo.textContent
)
)) +
'&tags=' +
escape((
yield I.minibuffer.read(
$prompt = "tags (space delimited): "
)
)) +
'&extended=' +
escape((
yield I.minibuffer.read(
$prompt = "extended description: "
)
)));
try {
var content = yield send_http_request(
load_spec({uri: postlinkurl}));
var dom = scuttle_parse_xml(content.responseText);
var result = dom.getElementsByTagName('result')[0];
var code = result.getAttribute('code');
I.window.minibuffer.message(code);
if (code === 'done')
scuttle_bookmarked_hook.run();
} catch (e) { }
}, $browser_object = browser_object_links); }, $browser_object = browser_object_links);