2012-12-28 20:45:32 +01:00
|
|
|
/* linkwave -- Store/retrieve/manage bookmarks
|
|
|
|
Copyright (C) 2012 Tom Willemsen <tom at ryuslash dot org>
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
/// Commentary:
|
|
|
|
|
|
|
|
// A wrapper script that should allow conkeror to interface with
|
|
|
|
// linkwave. Does not yet allow searching through collected
|
|
|
|
// bookmarks, only adding new ones.
|
|
|
|
|
|
|
|
/// Code:
|
|
|
|
|
|
|
|
define_variable("linkwave_program", "linkwave",
|
2012-12-28 20:24:20 +01:00
|
|
|
"The location of the linkwave executable.");
|
|
|
|
|
|
|
|
function linkwave_add_url(I, url, title)
|
|
|
|
{
|
|
|
|
let url_string = load_spec_uri_string(load_spec(url));
|
|
|
|
let title = yield I.minibuffer.read($prompt="name (required): ",
|
|
|
|
$initial_value=title);
|
|
|
|
let description = yield I.minibuffer.read(
|
|
|
|
$prompt="extended description: "
|
|
|
|
);
|
|
|
|
let tags = yield I.minibuffer.read(
|
|
|
|
$prompt="tags (comma delimited): "
|
|
|
|
);
|
|
|
|
let command = linkwave_program + ' "' + url_string + '" "' + title
|
|
|
|
+ '" "' + description + '" \''
|
|
|
|
+ tags.split(',').map(function (str)
|
|
|
|
{ return str.trim(); }).join("' '")
|
|
|
|
+ "'";
|
|
|
|
yield shell_command(command);
|
|
|
|
}
|
|
|
|
|
|
|
|
function linkwave_add(I) {
|
|
|
|
check_buffer(I.buffer, content_buffer);
|
|
|
|
let result = yield linkwave_add_url(I, I.buffer.top_frame,
|
|
|
|
I.buffer.title);
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
I.window.minibuffer.message('Added to linkwave');
|
|
|
|
else
|
|
|
|
I.window.minibuffer.message('Couldn\'t add to linkwave');
|
|
|
|
}
|
|
|
|
interactive("linkwave-add",
|
|
|
|
"Bookmark a page in linkwave",
|
|
|
|
linkwave_add);
|
|
|
|
|
|
|
|
function linkwave_add_link(I) {
|
|
|
|
check_buffer(I.buffer, content_buffer);
|
|
|
|
bo = yield read_browser_object(I);
|
|
|
|
let result = yield linkwave_add_url(I, encodeURIComponent(bo),
|
|
|
|
bo.textContent);
|
|
|
|
|
|
|
|
if (!result)
|
|
|
|
I.window.minibuffer.message('Added to linkwave');
|
|
|
|
else
|
|
|
|
I.window.minibuffer.message('Couldn\'t add to linkwave');
|
|
|
|
}
|
|
|
|
interactive("linkwave-add-link",
|
|
|
|
"Bookmark a link in linkwave",
|
|
|
|
linkwave_add_link);
|
|
|
|
|
|
|
|
provide("linkwave");
|