GithubHelp home page GithubHelp logo

xvxx / phetch Goto Github PK

View Code? Open in Web Editor NEW
175.0 4.0 7.0 8.79 MB

🐭 quick lil gopher client for your terminal

License: MIT License

Rust 99.20% Makefile 0.80%
gopher tui console terminal gopher-client cli gopher-protocol rust

phetch's People

Contributors

kseistrup avatar mmpx12 avatar nyaaawhatsupdoc avatar theenbyperor avatar walksanator avatar xvxx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

phetch's Issues

Feature request: open media files in media player

Added beginnings of support for this in #15

For whatever reason, ffmpeg supports opening gopher URLs. So mpv gopher://some.url/9/file.mp4 actually will stream!

All we need to add is an action to open media files (item types s or ;) with either mpv or VLC! Though the URL scheme supported for these is only item type 9, so we'd need to replace the s or ; item type in the URL with 9

I'm already sharing my personal drive via gopher directory listing on my home network. With this change the combo of phetch + gopher server could make a very nice little media server :)

A question about navigation

When looking at the keyboard shortcuts help page in phetch, I can't help wondering: Is there a reason we can't lose the Ctrl- part of many of the commands?

If we use the left/right/up/down arrows to move the cursor, and use numbers (or Enter) to select a link, couldn't we just choose g for “go to”, b for “bookmarks”, and so on: i.e., losing the Ctrl- part entirely (except for ^C, perhaps), thus only having to press a single key in order to indicate an action?

Found the missing Makefile 😉

I felt a Makefile was missing, so I wrote one. I rarely write makefiles, so you can most likely do a much better job yourself, but here's a simple one:

📎 Makefile

Thread ‘main’ panicked at ‘attempt to subtract with overflow’

Entering 0 to go back (because that's what I learned from gild), this is what I get:

thread 'main' panicked at 'attempt to subtract with overflow', src/menu.rs:556:68
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

Setting the suggested environment variable doesn't add any information, just 24 lines with

N: <unknown>

where N is in the interval 0..23.

Features update

Hi,
I've just packaged phetch for NetBSD. The package is currently in the testing repo but its my goal to move it to the main one within a few days.
Could you please update the README.md file adding NetBSD to the list of OS/plattform supporting phetch?
Thx!

--raw: erratic behaviour

Seen in f533d15:

It seems like phetch is ignoring its first argument after --raw:

$ phetch --raw phkt.io
--raw needs gopher-url
$ phetch --raw IGNORED phkt.io | head -1
i  ____    _   _     _  __    _____	(null)	phkt.io	70
$ phetch --version
phetch v0.1.12-dev

Feature idea: --dump $URL

It would be sweet to be able to dump a rendered version of a gopher URL with e.g. -d URL/--dump URL, such that the output is coloured if stdout is a TTY and plain text if not. This feature complements the -r/--raw switch, similarly to what we can do with e.g. lynx and w3m:

$ lynx --dump "$URL"       # dump a formatted page to stdout
$ lynx --source "$URL"     # dump raw html to stdout
$ w3m -dump "$URL"         # dump a formatted page to stdout
$ w3m -dump_source "$URL"  # dump raw html to stdout

Scroll behavior

Is it possible to add an option to scroll the entire height of the viewport/by page? Pressing spacebar or page down seems to only scroll by a fixed amount of lines, which requires taking time to figure out where I left off while reading a block of text. Scrolling an entire page makes it so that we can pick up from the top of the terminal after previously reading the last visible line.

configure colours

I use a light theme and, while i have my yellow set in .Xresources to be darker than usual, Phetch uses a lot of yellow text. It would be nice to be able to configure the colours in a simple config file.

Panic when truncating lines mid code point

Good example of this is seen by visiting: baud.baby. You'll get a panic claiming byte index 'x' is not a char boundary.

The offending code is here:

&line.text(&self.raw)[..MAX_COLS]

You're slicing a string without accounting for the index MAX_COLS possibly being in the middle of a code point. This is confirmed by the following replacement code which fixes the issue, instead truncating the line string using a char iterator:

let text_str = if line.text_len() > MAX_COLS {
    line.text(&self.raw).chars().take(MAX_COLS).collect::<String>()
} else {
    line.text(&self.raw).chars().collect::<String>()
};
let text = &text_str[..];

I'd have modified this and made a pull request myself, but I literally learnt Rust this afternoon for the purpose of fixing this panic, so I'm 95% sure there's a more elegant solution 😛

Circular navigation

How do you like the idea of “circular navigation”? We can use the front page as an example:

phetch

And let's pretend that we can only navigate by numbers or cursor keys. If I want to select 7, I either have to move my hand to the 7 button or I have to press cursor down 6 times.

What if moving off the top took me to the bottom, and moving off the bottom took me to the top, as if the numbers were placed on a ring?

I.e., when I want to move from 1 to 7, I can simply press once and I get to keep my fingers on the arrow keys.

Cargo.toml: no feature ‘tls’

Seen in b072529:

$ make
cargo build --release --features tls
error: Package `phetch v0.1.12-dev (…/phetch)` does not have these features: `tls`
make: *** [Makefile:22: target/release/phetch] Error 101

Omitting --features tls from Makefile builds the intended target since it is now the default.

Wrap kind of works, but doesn't.

Wrap will wrap a line, but any characters beyond 78 are cut off and missing. Phetch is receiving the entire content per raw dump, but does not properly render it.

stack overflow

Hi,

I'm using frankenwm as my window manager. On some tiling layouts having phetch
running and launching another window makes phetch crash.

Should add that this is phetch-1.0.4, it didn't happen on 1.0.3.
phetch-1.0.4 is running on my machine only, I haven't commited the update to the
repo yet due to this.

================================================================================

$ thread 'main' has overflowed its stack fatal runtime error: stack overflow
Abort (core dumped)

$ $ file phetch.core                                                   
phetch.core: ELF 64-bit LSB core file, x86-64, version 1 (SYSV), NetBSD-style, from 'phetch', pid=26420, uid=1001, gid=0, nlwps=2, lwp=1 (signal 6/code 32767)

$ $ gdb phetch.core                                                    
GNU gdb (GDB) 8.3
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "x86_64--netbsd".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
"/home/pin/phetch.core": not in executable format: file format not recognized
(gdb) bt
No stack.
(gdb) q
$ 

================================================================================

Not very useful but, thats all I could get from it.

Any changes from 1.0.3 to 1.0.4 that might be causing this?
I went through the commits between versions and couldn't figure out what it
could be...

Option collisions and the configuration file

This post is more about the general picture, but in case my examples are in conflict with the latest phetch, I am specifically referring to dd6e7ee.

Phetch now has so many commandline options and a configuration file that I feel it's time to reflect on option names, shortcuts, and how these interact with the configuration file.

What I see now is:

$ phetch --help
phetch - quick lil gopher client (v0.1.13-dev - 2020-01-11)

Usage:

    phetch [options]        Launch phetch in interactive mode
    phetch [options] [url]  Open Gopher URL in interactive mode

Options:

    -t, --tls               Try to open all pages w/ TLS
    -T, --tor               Try to open all pages w/ Tor
                            Set the TOR_PROXY env variable to use
                            an address other than the default :9050
    -r, --raw               Print raw Gopher response only
    -p, --print             Print rendered Gopher response only
    -l, --local             Connect to 127.0.0.1:7070

    --emoji                 Show TLS/Tor status as emoji.
    -h, --help              Show this screen
    -v, --version           Show phetch version

Once you've launched phetch, use `ctrl-h` to view the on-line help.

Until now there have been no option collisions, but now we have the letter T, that means one thing in lower case and another thing in upper case, even when the total amount of options are very small compared to programs like curl or ls.

One way could be to eliminate the short option, e.g. so that --tor doesn't have a short option. Another way could be to use another ‘significant’ letter than the first:

    -t, --tls               Try to open all pages w/ TLS
    -o, --tor               Try to open all pages w/ Tor

The latter approach can be seen in ls(1):

    -F, --classify          append indicator (one of */=>@|) to entries

However, care also have to taken to provide options for negating an option set in the configuration file. What if phetch.conf has

# Always use TOR to connect to sites
tor yes

and we want to connect to a site without using TOR? For this scenario we need to be able to override the values set in the configuration file. Some programs, e.g. ls uses -X, --no-x, where the uppercase shortcut is taken to mean ‘no’:

    -G, --no-group          in a long listing, don't print group names

I find this approach easy to remember.

Here's a suggestion:

$ phetch --help
Usage: phetch [OPTIONS] [URL]

positional arguments:
  URL               Optional gopher URL

optional arguments:
  -h, --help        Show this help message and exit
  -v, --version     Show version information and exit

  -t, --tls         Try to open all pages w/TLS
  -T, --no-tls      Do not use TLS

  -o, --tor         Try to open all pages w/TOR
  -O, --no-tor      Do not use TOR

  -e, --emoji       Show TLS/TOR status as emoji
  -E, --no-emoji    I do not care about emoji

  -r, --raw         Print raw Gopher response only
  -p, --print       Print rendered Gopher response only
  -l, --local       Connect to 127.0.0.1:7070

Commandline options always override options set in phetch.conf.

Once you've launched phetch, use ‘Ctrl-h’ to view the on-line help.

And perhaps this would be nice to have, too:

  -c CONFIG, --config=CONFIG
                    Use CONFIG instead of ~/.config/phetch.conf
  -C, --no-config   Ignore the default configuration file

Update AUR package to 1.2.0

https://aur.archlinux.org/packages/phetch is marked out-of-date as of 2022-12-07.
You are listed as the maintainer of the package, and i believe this patch is all that is needed to update it.

diff --git a/PKGBUILD b/PKGBUILD
index f76ddec..e5e9d5d 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,7 +1,7 @@
 #Maintainer: chris west <[email protected]>
 
 pkgname=phetch
-pkgver=1.1.0
+pkgver=1.2.0
 pkgrel=1
 pkgdesc="A quick lil gopher client for your terminal."
 url="https://github.com/xvxx/phetch"
@@ -10,7 +10,7 @@ makedepends=('cargo')
 arch=('x86_64')
 license=('MIT')
 source=("$pkgname-$pkgver.tar.gz::https://crates.io/api/v1/crates/$pkgname/$pkgver/download")
-sha256sums=('3a72e95457ef4ee6177de06abda6708dc830e3f50570f2e71f83c2015a89d683')
+sha256sums=('a0806d2ea41a70dd803f9a0d8c670995c71982f8e333919251c8fbe004f2de11')
 
 build() {
   cd "$pkgname-$pkgver"

--print doesn't

Seen in dd6e7ee:

The -p, --print option no longer prints anything to stdout. Exit code is 0 (zero). It does fetch the given gopher URL, though.

Getting "No route to host (os error 65)"

Getting "No route to host (os error 65)" when trying to visit gopher://g.nixers.net either from bookmarks or direct from the command line.

09-28-2020-11-29

09-28-2020-11-17

I am able to access this particular gopherhole using Lynx so the issue seems to be with phetch. Any idea what's going on here?

I'm on NetBSD in case the error relates to the "OS"

Resuming from ^Z breaks drawing

When I use ^Z to suspend phetch and then resume it, keystrokes render on the screen and phetch doesn't update the screen to reflect said keystrokes.

Selector display not updating in terminal multiplexer

Hello, I seem to be running into an issue where if I have phetch running in a terminal multiplexer like mtm, the screen doesn't update when I move around with the arrow keys. I can still browse to different pages normally, it's just that the selector doesn't accurately show the selected link.

I've tried running phetch with mtm in GNOME Terminal to no avail and I can sometimes get it to work in TTY.

Thanks.

Edit: I've tested phetch in tmux and it seems to work fine, maybe it's a problem with the multiplexer.

Enhancement: ‘q’ or ‘Esc’ to quit

Please, can we have q (and possibly Esc) to quit? Right now I press 0 and phetch will exit qith a stack trac, as mentioned in #1, but q and Esc will feel more intuitive.

PS: I really like the navigation in phetch, it feels like a huge improvement compared to gild.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.