Login to scuttle automatically if possible
This commit is contained in:
parent
ec922b7be4
commit
1e46767718
2 changed files with 35 additions and 10 deletions
|
@ -40,6 +40,8 @@ require("cdispass");
|
|||
require("jira");
|
||||
require('scuttle');
|
||||
|
||||
scuttle_url = 'https://ryuslash.org/scuttle/';
|
||||
|
||||
define_browser_object_class(
|
||||
"history-url", null,
|
||||
function (I, prompt) {
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
// define_hook('scuttle_bookmarked_hook');
|
||||
|
||||
define_variable("scuttle_username", null,
|
||||
"Username of te scuttle account.");
|
||||
define_variable("scuttle_password", null,
|
||||
"Password of the scuttle account.");
|
||||
define_variable("scuttle_url", null,
|
||||
"The URL where scuttle can be found.");
|
||||
|
||||
function scuttle_parse_xml(text)
|
||||
{
|
||||
var parser = Components
|
||||
|
@ -8,6 +15,20 @@ function scuttle_parse_xml(text)
|
|||
return parser.parseFromString(text, 'text/xml');
|
||||
}
|
||||
|
||||
function scuttle_get_url(path)
|
||||
{
|
||||
let url = make_uri(scuttle_url);
|
||||
|
||||
if (scuttle_username != null)
|
||||
url.username = scuttle_username;
|
||||
if (scuttle_password != null)
|
||||
url.password = scuttle_password;
|
||||
|
||||
url.path += '/api';
|
||||
|
||||
return url.spec + '/' + path;
|
||||
}
|
||||
|
||||
function scuttle_bookmarked_widget(window)
|
||||
{
|
||||
this.class_name = 'scuttle-bookmark-widget';
|
||||
|
@ -23,12 +44,12 @@ scuttle_bookmarked_widget.prototype = {
|
|||
var obj = this;
|
||||
function doit() {
|
||||
check_buffer(obj.window.buffers.current, content_buffer);
|
||||
let posturl = 'https://ryuslash.org/scuttle/api/is_bookmarked.php?url=' +
|
||||
encodeURIComponent(
|
||||
load_spec_uri_string(
|
||||
load_spec(obj.window.buffers.current.top_frame)
|
||||
)
|
||||
);
|
||||
let posturl = scuttle_get_url('is_bookmarked.php?url=' +
|
||||
encodeURIComponent(
|
||||
load_spec_uri_string(
|
||||
load_spec(obj.window.buffers.current.top_frame)
|
||||
)
|
||||
));
|
||||
|
||||
try {
|
||||
let content = yield send_http_request(
|
||||
|
@ -51,7 +72,8 @@ interactive("scuttle-post",
|
|||
"bookmark the page via scuttle",
|
||||
function (I) {
|
||||
check_buffer(I.buffer, content_buffer);
|
||||
let posturl = 'https://ryuslash.org/scuttle/api/posts_add.php?&url=' +
|
||||
let posturl = scuttle_get_url(
|
||||
'posts_add.php?&url=' +
|
||||
escape(load_spec_uri_string(load_spec(I.buffer.top_frame))) +
|
||||
'&description=' +
|
||||
escape((
|
||||
|
@ -71,7 +93,7 @@ interactive("scuttle-post",
|
|||
yield I.minibuffer.read(
|
||||
$prompt = "extended description: "
|
||||
)
|
||||
));
|
||||
)));
|
||||
|
||||
try {
|
||||
var content = yield send_http_request(
|
||||
|
@ -93,7 +115,8 @@ interactive("scuttle-post-link",
|
|||
var mylink = load_spec_uri_string(
|
||||
load_spec(encodeURIComponent(bo)));
|
||||
check_buffer(I.buffer, content_buffer);
|
||||
let postlinkurl = 'https://ryuslash.org/scuttle/api/posts_add.php?&url=' +
|
||||
let postlinkurl = scuttle_get_url(
|
||||
'posts_add.php?&url=' +
|
||||
mylink +
|
||||
'&description=' +
|
||||
escape((
|
||||
|
@ -113,7 +136,7 @@ interactive("scuttle-post-link",
|
|||
yield I.minibuffer.read(
|
||||
$prompt = "extended description: "
|
||||
)
|
||||
));
|
||||
)));
|
||||
|
||||
try {
|
||||
var content = yield send_http_request(
|
||||
|
|
Loading…
Reference in a new issue