NEW: bookmark web pages directly from your browser to Leo

79 views
Skip to first unread message

Terry Brown

unread,
Oct 2, 2011, 3:56:01 PM10/2/11
to leo-editor
I've added web page bookmarking from your browser to Leo.

Docs., appended to the mod_http plugin, where this functionality lives,
are pasted below.

Screen shot of the form which pops up when you click the Bookmark
button in your browser attached. The body text of the corresponding
bookmark node created in Leo is:

Leo's Home Page
http://webpages.charter.net/edreamleo/front.html

Tags: leo, python

Leo's Home Page

Collected: Sun 02 Oct 2011 02:52:51 PM CDT

Keep this under your pillow.

If you had some text selected on the page in your browser that would
also appear in the above, and repeatedly bookmarking the same page with
different selections incrementally adds such quotes to the bookmark
node.

Here are the docs.:


Can also be used for bookmarking directly from the browser to Leo. To
do this, add a bookmark to the browser with the following URL / Location:

javascript:w=window;if(w.content){w=w.content}; d=w.document; w.open('http://localhost:8130/_/add/bkmk/?&name=' + escape(d.title) + '&selection=' + escape(window.getSelection()) + '&url=' + escape(w.location.href),%22_blank%22,%22toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=no, width=800, height=300, status=no%22);void(0)

and edit the port (8130 in the example above) to match the port you're using
for mod_http.

Bookmarks are created as the first node in the outline which has been opened longest.
You can set the ``@string`` ``http_bookmark_unl`` to specify an alternative location,
e.g.::

@string http_bookmark_unl = /home/tbrown/.bookmarks.leo#@bookmarks-->Incoming

to place them in the `Incoming` node in the `@bookmarks` node in the `.bookmarks.leo` outline.

The headline is preceeded with '@url ' *unless* the ``bookmarks`` plugin is loaded.
If the ``bookmarks`` plugin is loaded the bookmark will have to be moved to a ``@bookmarks`` tree to be useful.

The browser may or may not be able to close the bookmark form window for you, depending on settings - set ``dom.allow_scripts_to_close_windows`` to true
in ``about:config`` in Firefox.

bm.jpg

Matt Wilkie

unread,
Oct 3, 2011, 2:24:51 AM10/3/11
to leo-e...@googlegroups.com
> If you had some text selected on the page in your browser that would
> also appear in the above,

cool! it was exactly this feature which let met start using
www.delicio.us for my bookmarks (with seondary attractive feature
being tags, and available from any computer being the last desirable).

> and repeatedly bookmarking the same page with
> different selections incrementally adds such quotes to the bookmark
> node.

very thoughtful extra. I'll definitely be having a look at this, thanks Terry.

--matt

Edward K. Ream

unread,
Oct 3, 2011, 12:38:00 PM10/3/11
to leo-e...@googlegroups.com
On Sun, Oct 2, 2011 at 2:56 PM, Terry Brown <terry_...@yahoo.com> wrote:
> I've added web page bookmarking from your browser to Leo.

I agree, this is totally cool. However, this was not working for me::

@string http_bookmark_unl = ~/ekr.leo#Notes-->Bookmarks

I was getting (from g.openWithFileName) the message::

can not open ~/ekr.leo#Notes-->Bookmarks

Rev 4521 contains a proposed fix to add_bookmark, marked with EKR,
which works for me on Windows 7.

Please take a look and see if the fix makes sense. Thanks.

Edward

Terry Brown

unread,
Oct 3, 2011, 2:48:03 PM10/3/11
to leo-e...@googlegroups.com

The only way I can see that it makes sense is if the behavior of
urlparse is different in different OSes / python versions. That seems
unlikely.

Also I think the code ensures the UNL search won't happen - is it
working for you? It seems the the initial path.find() removes the '#'
so calling urlparse on the unl part would leave you with
parsed.fragment == ''

Cheers -Terry


> Edward
>

Terry Brown

unread,
Oct 3, 2011, 2:54:09 PM10/3/11
to leo-e...@googlegroups.com
On Mon, 3 Oct 2011 13:48:03 -0500
Terry Brown <terry_...@yahoo.com> wrote:

> Also I think the code ensures the UNL search won't happen - is it
> working for you? It seems the the initial path.find() removes the '#'
> so calling urlparse on the unl part would leave you with
> parsed.fragment == ''

Hmm, I guess that's not the case, I was off by one, the unl fragment
has the '#' at the start of it, so calling urlparse on it is ok, but it
still makes no sense to me why the original code (which of course was
working for me) wouldn't work.

A mystery, but perhaps not a very important one.

Cheers -Terry

Edward K. Ream

unread,
Oct 3, 2011, 3:51:18 PM10/3/11
to leo-e...@googlegroups.com
On Mon, Oct 3, 2011 at 1:54 PM, Terry Brown <terry_...@yahoo.com> wrote:

> it still makes no sense to me why the original code (which of course was
> working for me) wouldn't work.
>
> A mystery, but perhaps not a very important one.

It's important enough :-) Presumably there is some platform-dependent
difference. I'll test on Ubuntu next.

The code is mostly working for me, although sometimes the bookmark is
created as a child of a previous bookmark.

I'm sure we will get to the bottom of these glitches. The
communication between Leo and the browser is the important part, and
that seems to be working well.

BTW, I wish, once again, that Bernhard Mulder could see the fruits of
his good work. He would be happy with what you have done...

Edward

Fidel N

unread,
Nov 21, 2013, 6:04:44 PM11/21/13
to leo-e...@googlegroups.com
Wow I finally got around to make this work, and its very very impressive, thanks for this!

Do you think it could easily be tweaked to store all the open tabs on the selected web-browser?
This way we could use Leo to store our webbrowser sessions (and a button to restore the session from Leo is very straight fordward).

wgw

unread,
Nov 22, 2013, 3:21:28 PM11/22/13
to leo-e...@googlegroups.com
Yes, +Like from me too for this plugin (shame Google groups doesn't have a "like" feature for posts... unless there is a g+ Leo group?), and tantalizingly reminiscent of ipython's notebook. .... if there were a way to make this two-way and sync with a Leo Notebook, then Leo could take advantage of browser power, like ipython. 

Of course that is a big project, and much of the value is largely found in the viewrendered plugin... and others.

Thanks!

Bill 

Terry Brown

unread,
Nov 22, 2013, 3:35:08 PM11/22/13
to leo-e...@googlegroups.com
On Fri, 22 Nov 2013 12:21:28 -0800 (PST)
wgw <wgwi...@gmail.com> wrote:

> Yes, +Like from me too for this plugin (shame Google groups doesn't have a
> "like" feature for posts... unless there is a g+ Leo group?),
> and tantalizingly reminiscent of ipython's notebook. .... if there were a
> way to make this two-way and sync with a Leo Notebook, then Leo could take
> advantage of browser power, like ipython.

Two way's not that hard, or at least it's doable, not sure if it's
still fully functional, but the pygeotag extension basically
establishes two way communication with the browser for interactively
showing / selecting coordinates on a Google map.

But apart from that particular application (a web map), what would Leo
want to do with two way communication? It's easy to make the browser
display things for you, as long as you don't mind closing the tabs
yourself.

Cheers -Terry

wgw

unread,
Nov 22, 2013, 9:31:10 PM11/22/13
to leo-e...@googlegroups.com
I will have to think about this more, but in general it seems like a natural progression: TK --> QT --> browser. The browser is the most advanced interface available. I'm assuming that was the thinking behind ipython's notebook. Advanced Leo plugins would be simpler to build under a browser, mainly because there is so much technology already built into and around browsers.  And it means as well that, with some tweaking, data and applications could be shared across the network. 

I did an exercise for a Coursera python course (Interactive Python): http://www.codeskulptor.org/#user25_OYhY8H7kpx_47.py.  The fact that python is in the browser means it can be shared easily, built easily, and even co-programmed easily (you can use that link's code and save another version --it generates a new link for each save). 

You could image Leo applications built and shared like that... just point Leonistas to a site and they get a plugin...(a bit scary, but there would be ways to make it safe, I'm assuming...)

My knowledge of Leo doesn't allow me to write anything similar in Leo (ok, why would I want BlackJack in Leo? Just an example!), and I suspect that even if I knew QT well, it would not be easy to build that application, which I did without much training at all. (Of course, this was almost a fill-in-the-blank assignment..) 

But there are more useful cases that fall into the "difficult to do in Leo" (for me): I want to diff two nodes and then interactively update one version using the other -- a kind of interactive bzr conflict resolution, but the two files are in body text with no markup. I can do the diff easily enough, but any kind of interactive editing of parallel texts is beyond me under Leo. So I use Meld instead, outside Leo. 

Or I could generate a html file with the diff data from Leo and that would include a bit of javascript for editing the aligned texts. That would work, but I want to get the manual changes back to Leo. Difficult, but your plugin makes it look doable. 

That's where a Leo --> browser --> Leo  interface (much like the ipython bridge) would be useful: allowing whatever might be done more easily in the browser to be stored in Leo and then (possibly) reworked in Leo and back to the browser... etc.

I suppose I am talking about an Ajax Leo...., but I don't know what that means!

Best,

Bill 

wgw

unread,
Nov 23, 2013, 7:05:54 PM11/23/13
to leo-e...@googlegroups.com
One more thought: perhaps the simplest way to integrate Leo into a browser is to adapt the ipython bridge to ipython notebook. Notebook has full html (markdown, with javascript I believe), so sending it a leo-built html string would run an html app in notebook. 

But, for the moment I have not been successful in getting the ipython bridge to work properly. It does work, it's just that communication seems glitchy. 


A video here (python to javascript bridge that drives a browser): http://www.youtube.com/watch?v=--4Efcd3UkU

IPYTHON roadmap: 

Our work for 2013-2014 is being driven by our grant from the Sloan Foundation. More details of this grant can be found here. For 2013, we are going to focus on really solidifying the single-user notebook experience, which is principally in two major areas:

    • Working with the notebook document, and interacting with other formats (nbconvert)
    • Interactive and dynamic content in the notebook (Javascript plugins / widgets)

Following that, in 2014, we will begin the development of the multi-user notebook. This multi-user notebook will be similar to the single-user notebook, but the server will map directly onto Linux users on a single environment, so that you only need to run a single server for all users of your system (be it a local shared machine, EC2 image, etc.). This multi-user notebook server will be focus on the usage case of small-medium sized groups of trusted users. It will not have features that allow it to scale to large numbers of users on the open internet

Edward K. Ream

unread,
Dec 6, 2013, 8:31:55 AM12/6/13
to leo-editor
On Sun, Oct 2, 2011 at 2:56 PM, Terry Brown <terry_...@yahoo.com> wrote:
I've added web page bookmarking from your browser to Leo.

Docs., appended to the mod_http plugin, where this functionality lives,
are pasted below.

​I've just added these docs to leoProjects.txt, which means that I will be sure to mention the new feature in the release notes.

EKR
Reply all
Reply to author
Forward
0 new messages