Giter Site home page Giter Site logo

astro's Introduction

astro

print

A Gemini web browser using shell script

Installing

There is an AUR package for archlinux users:

astro astro-git

You can also move the file astro to a folder in your PATH variable, or run make install, by default it will be installed into ~/.local/bin. Use PREFIX to override the install location, e.g.

Using

Start browsing by running astro with an optional URL:

astro gemini://rawtext.club:1965/~sloum/spacewalk.gmi

you can omit the protocol and port:

astro rawtext.club/~sloum/spacewalk.gmi

no arguments takes you to gemini.circumlunar.space:

astro

Client certificates

astro can work with client certificates if capsules requires them for authentication.

astro allows a single client certificate per (sub)domain identified by it's name. If a client cert for a specific domain is available astro will send it to the server with every request.

When a resource requires a client cert and astro can't find one it will show you a command to create a client cert for the capsule. The certificates are stored in ~/.config/astro/certs/.

To remove a certificate simply delete the <domain>.crt and <domain>.key files in the directory mentioned above.

Key bindings

  • b to go back one page
  • u go one path segment up
  • o to open a new URL, you'll be prompted to type it
  • r to reload the page
  • H to go to the home page
  • g to follow a link in the current page, a link will be displayed, and
  • s to save the page to a file
  • m to add the current page to bookmarks
  • M to go to a bookmark
  • K to delete the bookmark of the current page
  • q to quit

More coming.

Configuration

You can setup a config file at ~/.config/astro/astro.conf to configure astro the way you like.

The file uses a simple key=value style, see the complete example for the default values below.

hints:

  • astro will be appended to cachehome, the directory must be writable for your user.
  • The style- keys must be ANSI style codes.
margin=8
homepage="gemini.circumlunar.space/"
sty_header1='\033[35;7;1m'
sty_header2='\033[35;4;1m'
sty_header3='\033[35;4m'
sty_quote='\033[2;3m  '
sty_linkb='\033[35m'
sty_linkt=' => \033[36;3m '
sty_listb='\033[35;1m  โ€ข'
sty_listt='\033[0m'

Meta

This software is a work in progress and may not work as it is intended to.

Contributing

Please read the contributing file.

Further works

  • Better history
  • Opening files
  • Support input

Inspired by

Packaging

I'm not the maintainer of the AUR packages for this project, thanks guzzisti for the contribution.

astro's People

Contributors

akashdoppalapudi avatar blmayer avatar paemuri avatar rnwgnr avatar rockstorm101 avatar shakna-israel avatar sotpapathe 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

Watchers

 avatar  avatar  avatar

astro's Issues

Install

Instead of using cp, you could use the coreutil install, which can make sure permissions are done correctly, and exists to do exactly this:

install -m +x astro -d $(PREFIX)

It will set the mode (by the -m flag), ensure that the destination directories exist (-d, so you can install to nested ones that don't exist yet), it'll preserve any file flags, it'll set the correct user/group IDs when sudo is invoked, it'll be a no-op if the destination file is the same as the one being installed, and on Linux, it'll preserve any SELinux context that exists,.

Confusing license

First of all, thank you for the amazing project! :)

Looking at the LICENSE file, it seems the project is released under the GPLv2 license, but astro --version says it's MIT. Does that make sense?

discussion: performance of astro

Out of curiosity i started some investigation about performance bottlenecks of astro. I added a very basic stopwatch function to get a first insight where the most time is spent. The output is stored in a "trace.XXXXXX" file in astro's cache folder.

A performance bottleneck that became obvious pretty fast are sed commands - especially sed commands that are called very often. This essentially boils down to sed in the typesetgmi function.

hardcore test is geminispace.info/known-hosts which at the time of writing sports over 2200 link lines.
Current main on my test machine:

url: gemini://geminispace.info:1965/known-hosts
openssl fetch took .172193728 seconds
status extract took .005172634 seconds
typeset took 24.502104686 seconds

Replacing the 2 sed commands in the link rendering section of typesetgmi gets me down to:

typeset took 13.076992820 seconds

Even on a "normal page" like station.martinrue.com the difference is noticable. It gets down from 1.36 seconds to 0.93 seconds for me.

The current state of the branch has some drawbacks:

  • the links page is not that easy to read
  • the linkcounter is hardcoded as in "it is always there", but the appearance is still customizable

What do you think?

shell compatibility

I'm in the works of preparing another PR and came across an ambiguity with the current implementation:
The shebang requests /bin/sh that will most probably be linked to a more powerful shell on most system (like bash).

Unfortunately astro at the moment won't work with dash - which seems to be the default link for /bin/sh on Debian-based systems.

Not sure how to tackle this - we could simply switch the shebang to /bin/bash or try to find out what breaks astro on dash.

What do you think?

support for client certificates

Have you ever considered implementing support for client certificates for authenticating on capsules like Astrobotany or Martin Rue's Station?

I did a quick test and i't should possible without too much hassle.
My proposal:

  • allow a single cert by (sub)domain, automatically selected by astro
  • store certs in .config/astro/certs in PEM format (crt and key file separate) named by (sub)domain, e.g. example.com.crt and example.com.key
  • if a request requires a cert
    • check if the cert for this (sub)domain is already there
    • if so repeat the request with the cert: openssl s_client ... -cert <crt> -key <key>
    • otherwise print instructions on how to create a cert with openssl, e.g.: openssl req -x509 -newkey rsa:4096 -keyout ~/.config/astro/certs/example.com.key -out ~/.config/astro/certs/example.com.crt -days 36500 -nodes

We could even create the cert ourselves if need be.

This is essentially how client certs are currently handled in gmni/cgmnlm and it works quite well.

Show link numbers and customize key bindings

I guess this is a feature request, or I could not find a way to configure neither of these so please help:

  1. Customize key bindings while on less. I.e. make l open links instead of o.
  2. Display link numbers while "rendering" the pages. Like bollux does on the screenshot below. Links are clearly labelled 1 to 8 so I know quickly which one I want to follow when I hit g. Otherwise I have to read the list provided afterwards and guess which link is the one I wanted (which is easy when there's only 8 links but gets complicated when there's 50)

I don't really know how hard any of this is to implement but they are the only two things I missed when trying this software out. Nonetheless, great job on this little program, thank you for it.

2023-07-31_17-34

BUG: Does not play well with Unix systems

I am on Void Linux, I am running Void without GNU coreutils, that might sound strange, but is really simple, I built toybox, then ubase, and then sbase and put all that into /usr/local/bin. Then I progressively started to get rid of GNU packages. So I guess your program is using non-standard functions of printf or echo. GNU adds tons of things to the coreutils, it is easy to mistake them for being standard, they are not, they should clarify what is an extension and what is strictly POSIX but they do no. Anyways, here is the problem:

image

\e[?25l        Circumlunar Gemini Outpost
\e[m        
\e[m        Project Gemini has moved!!!
\e[m        
\e[m        This server, gemini.circumlunar.space, is no longer the official home of Project Gemini!  The official 
\e[m        protocol specification, FAQ and other documentation now lives at geminiprotocol.net:
\e[m        
\e[m        1 =>  gemini://geminiprotocol.net New official Project Gemini capsule
\e[m        
\e[m        Please update your bookmarks, your subscription to the news feed, and any links to the project capsule in 
\e[m        your content!
\e[m        
\e[m        CAPCOM aggregator
\e[m        
\e[m        This server hosts the first Gemini content aggregator, CAPCOM.
\e[m        
\e[m        2 =>  capcom/ CAPCOM
\e[m        
\e[m        Free Gemini hosting
\e[m        
\e[m        In the earlier stages of Project Gemini, free hosting was provided at this server.  The offer has been 
\e[m        discontinued for new users, but existing accounts remain open and content remains online.
\e[m        
\e[m        3 =>  users/ Users with Gemini content on this server
\e[musage: od [-bdosvx] [-A addressformat] [-E | -e] [-j skip] [-t outputformat] [file ...]

printf: Illegal option

I'm trying astro for the first time, and when I load a page I get these error messages at the bottom:

Keys: qgrbosHmM, to see a description run astro -h./astro: 254: printf: Illegal option -
./astro: 254: printf: Illegal option -
./astro: 254: printf: Illegal option -
Screenshot image

Steps to Reproduce

  1. Using Ubuntu 22.04
  2. Log into /bin/bash shell
  3. git clone https://github.com/blmayer/astro.git
  4. git checkout f97bc206a69bd961ccbce814813d5ec98f1714a7
  5. ./astro gemini://derelict.garden/astro.gmi

What I attempted

I tried patching astro like this ๐Ÿ‘‡ and the error went away.

diff --git a/astro b/astro
index 465bd79..9b454c4 100755
--- a/astro
+++ b/astro
@@ -251,7 +251,7 @@ EOF
                                        do
                                                printf "%*s" "$margin" ""
                                                # shellcheck disable=SC2059
-                                               printf "$sty$txt\\n"
+                                               printf "$sty $txt\\n"
                                        done
                                }
                        fi

However, that introduces an extra space on every line which may be unwanted.

Regression on POSIX shells

The following change introduced in 055ecf1 produces the render below on POSIX compliant shells (tested with dash 0.5.12). I guess you can either change the shebang for a non-POSIX compliant shell or revert this change (reverting seems to work as expected)

Change at https://github.com/blmayer/astro/blame/297bdb047d2247a7da088f58bcbdbefc10ac9a22/astro#L203:

- printf -- "$sty$txt\\n"
+ echo -e "$sty$txt"

Current ugly output (note the spurious "-e"):

        -e Project Gemini
        -e 
        -e Gemini in 100 words
        -e 
        -e Gemini is a new internet technology supporting an electronic library of interconnected text 
        -e documents.  That's not a new idea, but it's not old fashioned either.  It's timeless, and deserves 
        -e tools which treat it as a first class concept, not a vestigial corner case.  Gemini isn't about 
        -e innovation or disruption, it's about providing some respite for those who feel the internet has been 
        -e disrupted enough already.  We're not out to change the world or destroy other technologies.  We are 
        -e out to build a lightweight online space where documents are just documents, in the interests of 
        -e every reader's privacy, attention and bandwidth.
        -e 
        -e  1 => If you'd like to know more, read our FAQ
        -e  2 => Or, if you'd prefer, here's a video overview
        -e 
        -e Official resources
        -e 
        -e  3 => Official Project Gemini news
        -e  4 => Official Gemini documentation
        -e  5 => Known Gemini software
        -e  6 => Known Gemini servers
        -e 
        -e CAPCOM aggregator
        -e 
        -e This server hosts the first Gemini content aggregator, CAPCOM.
        -e 
        -e  7 => CAPCOM
        -e 
        -e Free Gemini hosting
        -e 
        -e In the earlier stages of Project Gemini, free hosting was provided at this server.  The offer has 
        -e been discontinued for new users, but existing accounts remain open and content remains online.
        -e 
        -e  8 => Users with Gemini content on this server
~
~

typesetting broken on specific percent-encoded URIs

Came across this on station.martinrue.com - text on the capsule:
gemini://gemi.dev/cgi-bin/waffle.cgi/article?https%3A%2F%2Fpluralistic.net%2F2023%2F08%2F03%2Fthere-is-no-cloud%2F%23linkdump

This brings astro to issue a warning:
astro: line 205: printf: '\': invalid format character

The URI is broken in output then:
gemini://gemi.dev/cgi-bin/waffle.cgi/article?https%3A%2F%2Fpluralistic.net%2F2023 0,00000008%2F03%2Fthere-is-no-cloud%2F%23linkdump

bookmarks save in .cache?

Thanks for this amazing project...it perfectly fits the spirit of gemini. :)

It seems that bookmarks are currently saved in ~/.cache/astro/bookmarks.
For me it seems a bit odd to save the bookmarks in .cache which should be ephemeral, i'd rather expect it in ~/.config/... or ~/.local/...

What do you think?

Fails loading unqualified URLS with a path component

When I try opening a URL that is both unqualified (no gemini:// prefix) and pathed (has /astro.gmi as a suffix) I find that astro fails to render the page. When I exit astro, I see this error in the terminal:

$ ./astro derelict.garden/astro.gmi
rm: cannot remove '/home/nic/.cache/astro/links': No such file or directory

It also affects URLs opened from within astro. Press o then derelict.garden/astro.gmi.

Debug Mode

Running astro in debug mode yields some insight.

Passing case:

Starting with gemini://derelict.garden/astro.gmi
 - margin:     8
Parsing: gemini://derelict.garden/astro.gmi
Parsed URL: proto: gemini host: derelict.garden path: /astro.gmi

Failing case:

Starting with derelict.garden/astro.gmi
 - margin:     8
Parsing: derelict.garden/astro.gmi
Parsed URL: proto:  host:  path: derelict.garden/astro.gmi
Response: proto: gemini host: derelict.garden/astro.gmi port: 1965 path:

Affected Versions

Reproducible for all versions versions from v0.8.0 onward. Most recently observed with v0.14.1 0642554.

I went back to 0.7.2 (ddb79dd) and observed that the page rendered properly when invoked as shown above. The bug with this kind of URL seems to be present in all versions after that.

However, using the same version 0.7.2, I got an error trying to open derelict.garden/astro.gmi from within astro.

Passing cases

For completeness, all of the following test cases work correctly and without error. โœ…

./astro gemini://derelict.garden/astro.gmi
./astro gemini://derelict.garden
./astro derelict.garden

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.