8 Commits

2 changed files with 56 additions and 15 deletions

View File

@@ -1,3 +1,22 @@
# Connex
A TUI nex browser in perl using Curses
A TUI (terminal UI) nex browser in perl using Curses. See more about the smolnet *Nightfall Express* (nex://) protocol here: https://nightfall.city/nex/
Currently not in one-touch install shape, but you can build it and use it with *cpanm* to get the required libraries.
For all the frippery I added trying to package things the right way for perl, the single script file is just in *scripts/connex.pl* you should be able to run and navigate wherever you'd like in nex-space. ctl-x gets the menu, ">" key lets you choose a link on the page that the browser attaches "[>#]" to mark. "<" navigates back, ctl-q to quit. There is a help dialog accessible from the menu for this meager help:
```
Navigation:
Press '>' key to select a '[>#]link by #
Press '<' key to go back to previous page
Program Features:
Press ctl-x for menu
```
The script needs the following Perl packages:
* FindBin
* Curses::UI
* Net::Telnet
* URI
* URI::Split

View File

@@ -453,22 +453,43 @@ sub is_path_index{
return($result);
}
sub add_page_link{
my $linkline = shift;
my $base_url = shift;
my $uri_object;
#sub add_page_link{
# my $linkline = shift;
# my $base_url = shift;
# my $uri_object;
#my $link= $linkline=~ s/^=>[ ]*(.*$)/$1/r;
local $URI::ABS_ALLOW_RELATIVE_SCHEME = 1;
local $URI::ABS_REMOTE_LEADING_DOTS = 1;
$uri_object=URI->new_abs($linkline=~ /^=>[ ]+([^ ]*)/,$base_url);
push(@page_links, $uri_object->as_string);
my $count = scalar @page_links; #scalar is size/count of links, but $#page_links is highest INDEX
return $linkline =~ s/(^=>.*$)/$1 [\>$count\]/r;
# local $URI::ABS_ALLOW_RELATIVE_SCHEME = 1;
# local $URI::ABS_REMOTE_LEADING_DOTS = 1;
# $uri_object=URI->new_abs($linkline=~ /^=>[ ]+([^ ]*)/,$base_url);
#
# push(@page_links, $uri_object->as_string);
# my $count = scalar @page_links; #scalar is size/count of links, but $#page_links is highest INDEX
# return $linkline =~ s/(^=>.*$)/$1 [\>$count\]/r;
#}
sub add_page_link{
my $linkline = shift;
my $base_url = shift;
my $uri_object;
local $URI::ABS_ALLOW_RELATIVE_SCHEME = 1;
local $URI::ABS_REMOTE_LEADING_DOTS = 1;
#remember inside of braces, ^ means NOT, so any NOT SPACE letters are selected, so everything up to next space
if (defined($linkline=~ /^=> ([^ ]*)/)){ #has to be something here or I think URI->new_abs has exception that crashes app
$uri_object=URI->new_abs($linkline=~ /^=> ([^ ]*)/,$base_url);
push(@page_links, $uri_object->as_string);
my $count = scalar @page_links; #scalar is size/count of links, but $#page_links is highest INDEX
#return $linkline =~ s/(^=>.*$)/$1 [\>$count\]/r; don't need to escape on the replace part of a substitution, I guess?
return $linkline =~ s/(^=> .*$)/$1 [>$count]/r;
}else{
return $linkline;
}
}
#=== NEX REQUESTS AND RESPONSE PROCESSING ===
sub load
{
@@ -489,9 +510,10 @@ sub load
$connect->port($port);
$ok= $connect->open($host);
$ok= $connect->print($path);
#TODO: What if it's not a text file? We need to check and have a download prompt and download if it's not text!
@lines =$connect->getlines(ErrMode=> 'return');
print $connect->eof();
#TODO:handle non-existant request? Die is not pretty to do here
#TODO:handle non-existent request? Die is not pretty to do here
die unless $connect->eof();
$connect->close();
my $widget= $texteditor;
@@ -503,8 +525,8 @@ sub load
my $is_index= is_path_index($path);
undef @page_links; #clear list
foreach $currentline (@lines){
if ($currentline =~ m/^=>/){
if ($is_index){
if ($is_index){ #only do this for index pages
if ($currentline =~ m/^=> /){ #check for valid rocket link with space
$currentline = add_page_link($currentline, $url);
}
}