pinboard-elinks

Check-in [e662f63e44]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Make sure everything is local ref.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256: e662f63e44667641fa380a3dbfe506fbce925ae063b6d2cf5a79d01ff6621035
User & Date: atomicules@lavabit.com 2012-12-29 12:06:17
Context
2013-05-27
14:41
Change keybindings to suit my environment

(Alt bindings conflict with dwm) check-in: 90f82277b0 user: atomicules@lavabit.com tags: master, trunk

2012-12-29
12:06
Make sure everything is local ref. check-in: e662f63e44 user: atomicules@lavabit.com tags: master, trunk
2012-12-28
12:35
Use .netrc for storing API token check-in: bb5603e612 user: atomicules@lavabit.com tags: master, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to pinboard.lua.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
--Pinboard tools for ELinks
--source from your ~/.elinks/hooks.lua file with `dofile("pinboard.lua")`

--ALT+p to save a bookmark. Brings up an XDialog, first row is to enter a description, second row is for tags
--ALT+l to read later. 
--Reformats the mobile site to be better for ELinks

--In order to be able to delete need to enter auth_token in `.netrc`. See README
local pb_base = 'https://pinboard.in/add?'
local pb_url

function addto_pinboard (description, tags)
	url = current_url ()
	title = current_title ()
	doc_url = pb_base..'url='..escape (url)..'&title='..escape (title)..'&description='..escape (description)..'&tags='..escape (tags)..'&next='..escape (url)..' ','Pinboard','toolbar=no,width=700,height=350';
    return doc_url
end
	bind_key ("main", "Alt-p",
		function () xdialog("<Description>", "<Tags>",
			function (description, tags)
				return "goto_url",
				addto_pinboard (description, tags) 
		end)
	end)


function readlater_pinboard ()
	url = current_url ()
	title = current_title ()
	doc_url = pb_base..'later=yes&next=same&noui=yes&jump=close&url='..escape (url)..'&title='..escape (title)..' ','Pinboard','toolbar=no,width=100,height=100';
	--Uses &next=same to immediately return to page being bookmarked
    return doc_url
end
	bind_key ("main", "Alt-l",
		function () return "goto_url", readlater_pinboard () end)














|
|
|












|
|
|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
--Pinboard tools for ELinks
--source from your ~/.elinks/hooks.lua file with `dofile("pinboard.lua")`

--ALT+p to save a bookmark. Brings up an XDialog, first row is to enter a description, second row is for tags
--ALT+l to read later. 
--Reformats the mobile site to be better for ELinks

--In order to be able to delete need to enter auth_token in `.netrc`. See README
local pb_base = 'https://pinboard.in/add?'
local pb_url

function addto_pinboard (description, tags)
	local url = current_url ()
	local title = current_title ()
	local doc_url = pb_base..'url='..escape (url)..'&title='..escape (title)..'&description='..escape (description)..'&tags='..escape (tags)..'&next='..escape (url)..' ','Pinboard','toolbar=no,width=700,height=350';
    return doc_url
end
	bind_key ("main", "Alt-p",
		function () xdialog("<Description>", "<Tags>",
			function (description, tags)
				return "goto_url",
				addto_pinboard (description, tags) 
		end)
	end)


function readlater_pinboard ()
	local url = current_url ()
	local title = current_title ()
	local doc_url = pb_base..'later=yes&next=same&noui=yes&jump=close&url='..escape (url)..'&title='..escape (title)..' ','Pinboard','toolbar=no,width=100,height=100';
	--Uses &next=same to immediately return to page being bookmarked
    return doc_url
end
	bind_key ("main", "Alt-l",
		function () return "goto_url", readlater_pinboard () end)


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
		html = string.gsub (html, '<div style="visibility:hidden;display:none" class="delete_div" id="destroy_.-</div>', '')
		return html
	end
end


function new_edit_link (s)
	_,_,link = string.find (s, '<a class="bookmark_title.-href="(.-)"')
	login,token = readnetrc()
	--But need to escape any %X (where X is a digit) in the URL http://stackoverflow.com/a/6705995/208793
	link = string.gsub (link, "([%%])", "%%%1")
	if string.find(pb_url, "/b:") and not (login == nil) then --if on individual bm page, add Delete button as well
		delete_link = '<a href="https://api.pinboard.in/v1/posts/delete?url='..link..'&auth_token='..login..":"..token..'" class="delete">Delete</a>'
	else
		delete_link = ''
	end
	replacement = string.gsub (s, '<a onclick="edit.-</a>', '<a href="'..pb_base..'url='..link..'" class="edit">Edit</a> '..delete_link..'<br>')
	return replacement
end


function readnetrc () 
	local login
	local password







|
|







|







53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
		html = string.gsub (html, '<div style="visibility:hidden;display:none" class="delete_div" id="destroy_.-</div>', '')
		return html
	end
end


function new_edit_link (s)
	local _,_,link = string.find (s, '<a class="bookmark_title.-href="(.-)"')
	local login,token = readnetrc()
	--But need to escape any %X (where X is a digit) in the URL http://stackoverflow.com/a/6705995/208793
	link = string.gsub (link, "([%%])", "%%%1")
	if string.find(pb_url, "/b:") and not (login == nil) then --if on individual bm page, add Delete button as well
		delete_link = '<a href="https://api.pinboard.in/v1/posts/delete?url='..link..'&auth_token='..login..":"..token..'" class="delete">Delete</a>'
	else
		delete_link = ''
	end
	local replacement = string.gsub (s, '<a onclick="edit.-</a>', '<a href="'..pb_base..'url='..link..'" class="edit">Edit</a> '..delete_link..'<br>')
	return replacement
end


function readnetrc () 
	local login
	local password