Re: [elinks-users] Trying to get hooks.pl working

2013-08-06 Thread John Magolske
* Witold Filipczyk  [130806 12:00]:
> W dniu 06.08.2013 o 17:12 John Magolske  pisze:
> > I just came across this hooks.pl snippet that allows ELinks to
> > display threaded comments on Hacker News nicely indented:
> > 
> > sub pre_format_html_hook {
> >   my ($url, $html) = (shift, shift);
> >   if ($url =~ m|news.ycombinator.com/item\?id=|) {
> > $html =~ s| > width=([0-9]{1,3})>|' 'x($1/10)|eg;
> >   }
> >   return $html;
> > }
> > 
> > http://pastebin.com/P4frn4N7
> > https://news.ycombinator.com/item?id=6151718
> > 
> > ... tried compiling with Perl support:
> >
> > % ./configure --with-lua --with-perl
> >   [...]
> >   checking for Perl... no
> >
> > Not sure why perl isn't found...
> 
> Did you install libperl-dev?

Ah, but of course...installing libperl-dev did the trick, works
perfectly now. Nice to be reading indented HN comments in ELinks.

Thanks!

John

-- 
John Magolske
http://B79.net/contact
___
elinks-users mailing list
elinks-users@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-users


[elinks-users] Trying to get hooks.pl working

2013-08-06 Thread John Magolske
Hi,

I just came across this hooks.pl snippet that allows ELinks to display
threaded comments on Hacker News nicely indented:

sub pre_format_html_hook {
  my ($url, $html) = (shift, shift);
  if ($url =~ m|news.ycombinator.com/item\?id=|) {
$html =~ s||' 'x($1/10)|eg;
  }
  return $html;
}

http://pastebin.com/P4frn4N7
https://news.ycombinator.com/item?id=6151718

Hacker News uses "s.gif" with varying width values to adjust the
indenting of comments, which ELinks doensn't recognise. The above code
swaps those out with   entities. Looks like a nice solution, but I
can't seem to get it working. I've had success using hooks.lua, which
required compiling ELinks with Lua support. So I tried compiling with
Perl support:

% ./configure --with-lua --with-perl
  [...]
  checking for Perl... no
  checking for Lua... yes
  [...]

Not sure why perl isn't found...

% which perl
  /usr/bin/perl
% which lua
  /usr/bin/lua

A subsequent `make` leaves a binary that has no mention of Perl:

./elinks --version
ELinks 0.13.GIT
Built on Aug  5 2013 22:48:20
Features:
[...] Scripting (Lua)

Any ideas as to why? Is it possible to have support for more than one
scripting language in a given binary? FWIW, this is on Debian Sid.

Thanks,

John

-- 
John Magolske
http://B79.net/contact
___
elinks-users mailing list
elinks-users@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-users


Re: [elinks-users] Piping the HTML source of a page open in ELinks to another application

2012-09-19 Thread John Magolske
* John Magolske  [120814 23:02]:
> I'm looking for a way to pipe the HTML of a page open in ELinks to
> another application without having to re-download the page. 
> 
> I have a ELinks mapping & script that automates saving a web-page
> to text -- with two keypresses the HTML is converted to text and
> automatically opened in Vim for editing & saving to an appropriate
> location. Very handy, but this approach uses URI passing and %c,
> which involves re-downloading the HTML source over the net.
> [...]
> What I'd like to be able to do is pipe the source of an open page
> through `elinks -dump` without an internet connection, and without
> having to manually save it somewhere first.

After reading a few helpful threads [1] from the archives of this list
and looking over the contrib/lua/hooks.lua file, I pieced together a
solution which seems to work fairly well. Not having much experience
with Lua, it's quite possible this can be more correct/clean. Any
suggestions for improvement are welcome. Might be time to pick up the
Programming in Lua book...

The relevant bits from my ~/.elinks/hooks.lua file:

-- Convert HTML to plaintext & open file in Vim
function save_to_text ()
-- See if we can obtain the local document.
local doc = current_document()
if doc then
-- Create a temporary file
local tmp = tmpname ()
-- Write document into the temporary file.
writeto (tmp) write (doc) writeto()
-- convert HTML to plaintext and open Vim in a new tmux window
execute(
"elinks -dump -no-references -no-numbering " ..tmp.. ">|" ..tmp..".txt 
;\
echo \"\n\n[saved on: `date +%Y\/%m\/%d\\ %a\\ %k:%M\\ %Z` ]\" >>" 
..tmp..".txt ;\
echo " ..current_url ().. " >>" ..tmp..".txt;\
tmux new-window -n vim-elink \"vim \""..tmp..".txt")
-- Tell elinks to delete after this function.
table.insert (tmp_files, tmp)
end
end

-- Convert HTML to markdown & open file in Vim
function save_to_markd ()
-- See if we can obtain the local document.
local doc = current_document()
if doc then
-- Create a temporary file
local tmp = tmpname ()
-- Write document into the temporary file.
writeto (tmp) write (doc) writeto()
-- convert HTML to markdown and open Vim in a new tmux window
execute(
"pandoc -r html -w markdown --no-wrap --reference-links " ..tmp.. ">|" 
..tmp..".txt ;\
echo \"\n\n[saved on: `date +%Y\/%m\/%d\\ %a\\ %k:%M\\ %Z` ]\" >>" 
..tmp..".txt ;\
echo " ..current_url ().. " >>" ..tmp..".txt ;\
tmux new-window -n vim-elink \"vim \"" ..tmp..".txt")
-- Tell elinks to delete after this function.
table.insert (tmp_files, tmp)
end
end

console_hook_functions = {
txt = save_to_text,
mkd = save_to_markd,
}

bind_key ("main", "Ctrl-H", save_to_text)
bind_key ("main", "Ctrl-G", save_to_markd)




[1] 
http://archives.linuxfromscratch.org/mail-archives/elinks-users/2006-March/001109.html
http://archives.linuxfromscratch.org/mail-archives/elinks-users/2006-April/001120.html

Regards,

John

-- 
John Magolske
http://B79.net/contact
___
elinks-users mailing list
elinks-users@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-users


Re: [elinks-users] Piping the HTML source of a page open in ELinks to another application

2012-09-11 Thread John Magolske
* John Magolske  [120814 23:02]:
> I'm looking for a way to pipe the HTML of a page open in ELinks to
> another application without having to re-download the page. 
> 
> I have a ELinks mapping & script that automates saving a web-page
> to text -- with two keypresses the HTML is converted to text and
> automatically opened in Vim for editing & saving to an appropriate
> location. Very handy, but this approach uses URI passing and %c,
> which involves re-downloading the HTML source over the net.
> [...]
> What I'd like to be able to do is pipe the source of an open page
> through `elinks -dump` without an internet connection, and without
> having to manually save it somewhere first.

I'm guessing the only way to do this would be through something like
a Lua scripting approach. If so, might anyone know of a script that
could provide a good starting point to learn from?

Thanks,

John

-- 
John Magolske
http://B79.net/contact
___
elinks-users mailing list
elinks-users@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-users


[elinks-users] Piping the HTML source of a page open in ELinks to another application

2012-08-14 Thread John Magolske
Hi,

I'm looking for a way to pipe the HTML of a page open in ELinks to
another application without having to re-download the page. 

I have a ELinks mapping & script that automates saving a web-page
to text -- with two keypresses the HTML is converted to text and
automatically opened in Vim for editing & saving to an appropriate
location. Very handy, but this approach uses URI passing and %c,
which involves re-downloading the HTML source over the net.

When I don't have an internet connection and want to save a particular
page to text, what I do now is hit the key for "Save the current
document in source form", manually save it to a particular location,
then use `elinks -dump` to convert that file to text.

What I'd like to be able to do is pipe the source of an open page
through `elinks -dump` without an internet connection, and without
having to manually save it somewhere first.

Any thoughts on how to do this?

John

-- 
John Magolske
http://B79.net/contact
___
elinks-users mailing list
elinks-users@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-users


[elinks-users] PhantomJS, headless JavaScript tool ... use with ELinks?

2011-04-16 Thread John Magolske
I use ELinks for 90%+ of my web browsing, and would love to find a way
of dealing with JavaScript. I just found out about PhantomJS [1], a
"minimalistic, headless, WebKit-based, JavaScript-driven tool". I'm
wondering if this might be an option for dealing with JavaScript when
browsing the net with ELinks, by passing the URI to an external script
that returns some nice html back to ELinks. I haven't played around
with it at all, but it seems promising. Maybe pipe the html through
something like goose [2] or boilerpipe [3] for good measure. I found
out about PhantomJS on this [4] thread.

[1] http://code.google.com/p/phantomjs/
[2] https://github.com/jiminoc/goose
[3] http://code.google.com/p/boilerpipe/
[4] http://news.ycombinator.com/item?id=2298237

Regards,

John

-- 
John Magolske
http://B79.net/contact
___
elinks-users mailing list
elinks-users@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-users


[elinks-users] PhantomJS, headless JavaScript tool ... use with ELinks?

2011-03-07 Thread John Magolske
I use ELinks for 90%+ of my web browsing, and would love to find a way
of dealing with JavaScript. I just found out about PhantomJS [1], a
"minimalistic, headless, WebKit-based, JavaScript-driven tool". I'm
wondering if this might be an option for dealing with JavaScript when
browsing the net with ELinks -- pass the URI to an external script
that returns some nice html back to ELinks. I haven't played around
with it at all, but it seems promising. Maybe pipe the html through
something like goose [2] or boilerpipe [3] for good measure. I read
about PhantomJS on this [4] thread.

[1] http://code.google.com/p/phantomjs/
[2] https://github.com/jiminoc/goose
[3] http://code.google.com/p/boilerpipe/
[4] http://news.ycombinator.com/item?id=2298237

Regards,

John

-- 
John Magolske
http://B79.net/contact
___
elinks-users mailing list
elinks-users@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-users


[elinks-users] a url that locks up elinks

2009-09-17 Thread John Magolske
Hi,

Navigating to the following url, I find Elinks hangs indefinitely
displaying the message "Request sent" with the cpu maxed out at 100%:

http://www.eweek.com/c/a/Application-Development/Google-Delivers-New-Javalike-Language-Noop-473613/

Ctrl-C won't quit, I have to manually Kill-9 Elinks to stop it.

Does anyone else experience this behavior with this url?

TIA,

John

-- 
John Magolske
http://B79.net/contact
___
elinks-users mailing list
elinks-users@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-users


[elinks-users] caching of pages, localhost

2009-07-10 Thread John Magolske
Hi,

I wrote the following wrapper script to launch elinks after running
the restview [1] command, for viewing reStructuredText documents:

#!/bin/sh
restview --listen=*:8080 "$1" > /dev/null &
STATUS_PID=$!
elinks http://myhostname:8080/
kill $STATUS_PID

Every time I have to hit the reload key to reload the browser, as
it shows whatever previous page was viewed. Is there some way to
prevent this? The only way I've found to avoid this in other cases
is with "elinks -no-connect 1 $1", but here that gets:

Unable to retrieve http://myhostname:8080/: Connection refused

I've tried "elinks -eval 'set ... ' " in the script with every combo
of document.cache.* & document.browse.* I could think of, but nothing
seems to work.

TIA for any suggestions,

John

[1] http://mg.pov.lt/restview/



-- 
John Magolske
http://B79.net/contact
___
elinks-users mailing list
elinks-users@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-users


Re: [elinks-users] Shift-Tab, move-link-prev redux

2009-06-25 Thread John Magolske
* Kalle Olavi Niemitalo  [090625 16:21]:
> Thanos Papaïoannou  writes:
> > 2. When not on a link, Tab moves the cursor to the link closest
> > to the top of the page; is there a way to force the link to jump to
> > the nearest link instead?
>
> In ELinks 0.12pre1, there is a new action move-link-right-line
> that may do what you want.

Thank you! This is something I've been wanting in ELinks for a while,
IMHO, a major usability boost. There's also move-link-left-line for
jumping to the nearest previous link.

John


-- 
John Magolske
http://B79.net/contact
___
elinks-users mailing list
elinks-users@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-users


Re: [elinks-users] adjusting the page width

2009-05-08 Thread John Magolske
* Y. Hida  [090508 17:20]:
> On 2009-05-08, John Magolske  wrote:
> > document.browse.margin_width = 9
> >
> > will reduce the page width to 110 columns, but 9 is the maximum
> > value that can be set. Is there some way to achieve a narrower page
> > width? It would also be nice to somehow toggle between full-width
> > and reduced-width with a key binding.
> 
> If you can compile elinks from source, the following patch (against
> current git master) would do it.  This adds toggle-margin action
> (default keybind "M") to toggle the margin between 0 and the specified
> margin_width (which can be up to 100 now).

Thanks! This patch does exactly what I was looking for.

One question -- is there a way to have it toggle the margin between
say, 2 or 3 (rather than 0) and the specified margin_width? Maybe by
changing something in this line:

+   "margin_width", 0, 0, 100, 3,

Regards,

John


-- 
John Magolske
http://B79.net/contact
___
elinks-users mailing list
elinks-users@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-users


[elinks-users] adjusting the page width

2009-05-08 Thread John Magolske
Hi,

I'm running ELinks in a Linux framebuffer console & GNU Screen, and
am looking for a way to adust the width of viewed pages. My console
is set to 128 columns, which can be a bit wide sometimes. I'd like
to view pages in the 80-90 column range.

In ~/.elinks/elinks.conf setting:

document.browse.margin_width = 9

will reduce the page width to 110 columns, but 9 is the maximum
value that can be set. Is there some way to achieve a narrower page
width? It would also be nice to somehow toggle between full-width
and reduced-width with a key binding.

TIA for any suggestions,

John


-- 
John Magolske
http://B79.net/contact
___
elinks-users mailing list
elinks-users@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-users


[elinks-users] Ctrl-C -- possible to make it not quit ELinks?

2008-02-28 Thread John Magolske
I picked up the habit of using Ctrl-C to close unresponsive
connections while using w3m. Now that I'm using ELinks more & more,
occasionally I make the mistake of hitting Ctrl-C, which will close
an ELinks session along with all open tabs without warning.

I'm re-training myself to use "z", which is currently mapped to
"Abort connection". But would like to find a way to prevent
accidentally closing ELinks in this way.

Adding the "Ctrl-C" binding to "Abort connection" made no difference.
In the list archives I found:

> If you do e.g. "stty intr undef" so that Ctrl-C does not give
> ELinks a signal, then ELinks will handle it as a bindable key.

http://linuxfromscratch.org/pipermail/elinks-users/2006-December/001384.html

But this disables the functionality of Ctrl-C altogether within the
terminal. Are there any other options?

Regards,

John

-- 
John Magolske
http://B79.net/contact
___
elinks-users mailing list
elinks-users@linuxfromscratch.org
http://linuxfromscratch.org/mailman/listinfo/elinks-users