diff --git a/README.md b/README.md index 47460f9..013f54b 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,36 @@ -# Browsh [![Build Status](https://travis-ci.org/tombh/texttop.svg?branch=master)](https://travis-ci.org/tombh/texttop) +[![Build Status](https://travis-ci.org/tombh/texttop.svg?branch=master)](https://travis-ci.org/tombh/texttop) -**A fully interactive, realtime and modern browser rendered to TTY** +![Browsh Logo](https://www.brow.sh/assets/images/browsh-header.jpg) -or Firefox in your terminal 😲 - -// Gifs go here +**A fully interactive, realtime and modern text-based browser rendered to TTYs and browsers** ## Why? Not all the world has good Internet. If all you have is a 3kbps connection tethered from a phone -then it's good to SSH into a server and browse the web through +then it's good to SSH into a server and browse the web through, say, [elinks](https://github.com/tombh/texttop/issues/17). That way the _server_ downloads the web pages and uses the limited bandwidth of an -SSH connection to display the result. But it lacks JS support and all -that other modern HTML5 goodness. So Browsh is simply a way to have -the power of a remote server running a modern browser, but interfaced -through the simplicity of a terminal and very low bandwidth. +SSH connection to display the result. But traditional text-based browsers +lack JS support and all that other modern HTML5 goodness. Browsh is different +in that it's backed by a real browser, namely headless Firefox, and uses that +to create purely text-based version of web pages and web apps that can be easily +rendered in a terminal or indeed, somewhat ironically, in another browser. Though note that currently the browser client doesn't have feature parity with the terminal client. Why not VNC? Well VNC is certainly one solution but it doesn't quite have the same ability to deal with extremely bad Internet. Also, -Browsh can use MoSH to further reduce the bandwidth and stability -requirements of the connection. Mosh offers features like automatic -reconnection of dropped connections and diff-only screen updates. -Furthermore, other than SSH or MoSH, Browsh doesn't require a client +terminal Browsh can use MoSH to further reduce bandwidth and increase stability +of the connection. Mosh offers features like automatic +reconnection of dropped or roamed connections and diff-only screen updates. +Furthermore, other than SSH or MoSH, terminal Browsh doesn't require a client like VNC. -Another reason could be to offload the battery-drain of a modern -browser from your laptop. If you're a CLI-native, then you could -potentially get a few more hours life if your CPU-hungry browser +One final reason to use terminal Browsh could be to offload the battery-drain of a modern +browser from your laptop or low-powered device like a Raspberry Pi. If you're a CLI-native, +then you could potentially get a few more hours life if your CPU-hungry browser is running somehwere else on mains electricity. -But of course the biggest reason for Browsh is probably just that it's -cool geekery. You may just appreciate the sheer simplicty of browsing -a text-based web in your terminal. - ## Installation Download a binary from the [releases](https://github.com/tombh/texttop/releases) (~2-6MB). @@ -55,7 +50,7 @@ To setup a dev env you will need NodeJS and Golang installed. If you get stuck setting up your env, take a look in `.travis.yml`, it has to setup everything from scratch for every push to Github. -I'd recommend `[nvm](https://github.com/creationix/nvm)` for NodeJS - note that +I'd recommend [nvm](https://github.com/creationix/nvm) for NodeJS - note that `nvm install` will automatically parse the `.nvmrc` version in this repo to get the correct NodeJS version. For Golang it's probably best to just use your OS's package manager. The current Golang version being used is stored in `.travis.yml`. @@ -72,17 +67,21 @@ Then the ideal setup for development is: * have Webpack watch the JS code so that it rebuilds automatically: `webpack --watch` * run the CLI client without giving it the responsibility to launch Firefox: - `go run ./interfacer/*.go -use-existing-ff` + `go run ./interfacer/src/main.go -use-existing-ff -debug` * have Mozilla's handy `web-ext` tool run Firefox and reinstall the webextension everytime webpack rebuilds it: (in `webext/dist`) `web-ext run --verbose` ## Tests -For the webextension: in `webext/` folder, `npm test` -For CLI unit tests: in `/interfacer` run `go test src/browsh/*.go` -For CLI E2E tests: in `/interfacer` run `go test test/tty/*.go` -FOr HTTP Service tests: in `/interfacer` run `go test test/http-server/*.go` +For the webextension: in `webext/` folder, `npm test` +For CLI unit tests: in `/interfacer` run `go test src/browsh/*.go` +For CLI E2E tests: in `/interfacer` run `go test test/tty/*.go` +FOr HTTP Service tests: in `/interfacer` run `go test test/http-server/*.go` + +## Special Thanks + * [@tobimensch](https://github.com/tobimensch) For essential early feedback and user testing. + * [@arasatasaygin](https://github.com/arasatasaygin) For the Browsh logo. ## License GNU General Public License v3.0 diff --git a/interfacer/src/browsh/browsh.go b/interfacer/src/browsh/browsh.go index b730580..dc87b7c 100644 --- a/interfacer/src/browsh/browsh.go +++ b/interfacer/src/browsh/browsh.go @@ -22,6 +22,20 @@ import ( ) var ( + logo = ` + //// //// + / / / / + // // + // // ,,,,,,,, + //////// ..,,,,,,,,, + // // .., ,,, .,. + //////// .., ,,,,,.. + //////// ..,,,,,,,,, + //////// ........... + ////////// + ****/////////////////// + ********/////////////// + ***********************` webSocketPort = flag.String("websocket-port", "3334", "Web socket service address") firefoxBinary = flag.String("firefox", "firefox", "Path to Firefox executable") isFFGui = flag.Bool("with-gui", false, "Don't use headless Firefox") @@ -81,7 +95,9 @@ func initialise() { if IsTesting { *isDebug = true } - setupLogging() + if *isDebug { + setupLogging() + } } // Shutdown tries its best to cleanly shutdown browsh and the associated browser @@ -161,7 +177,8 @@ func TTYStart(injectedScreen tcell.Screen) { screen = injectedScreen initialise() setupTcell() - writeString(0, 0, "Starting Browsh, the modern terminal web browser.", tcell.StyleDefault) + writeString(1, 0, logo, tcell.StyleDefault) + writeString(0, 15, "Starting Browsh, the modern text-based web browser.", tcell.StyleDefault) startFirefox() Log("Starting Browsh CLI client") go readStdin() diff --git a/interfacer/src/browsh/firefox.go b/interfacer/src/browsh/firefox.go index f5379bf..2287b45 100644 --- a/interfacer/src/browsh/firefox.go +++ b/interfacer/src/browsh/firefox.go @@ -260,15 +260,15 @@ func setupFirefox() { func startFirefox() { if !*isUseExistingFirefox { - writeString(0, 1, "Waiting for Firefox to connect...", tcell.StyleDefault) + writeString(0, 16, "Waiting for Firefox to connect...", tcell.StyleDefault) if IsTesting { - writeString(0, 2, "TEST MODE", tcell.StyleDefault) + writeString(0, 17, "TEST MODE", tcell.StyleDefault) go startWERFirefox() } else { setupFirefox() } } else { - writeString(0, 1, "Waiting for a user-initiated Firefox instance to connect...", tcell.StyleDefault) + writeString(0, 16, "Waiting for a user-initiated Firefox instance to connect...", tcell.StyleDefault) } } diff --git a/interfacer/src/browsh/ui.go b/interfacer/src/browsh/ui.go index 1914736..e7863e2 100644 --- a/interfacer/src/browsh/ui.go +++ b/interfacer/src/browsh/ui.go @@ -26,11 +26,17 @@ func renderUI() { // Not for use in the browser frames themselves. If you want anything to appear in // the browser that must be done through the webextension. func writeString(x, y int, str string, style tcell.Style) { + xOriginal := x if *IsHTTPServer { Log(str) return } for _, c := range str { + if string(c) == "\n" { + y++ + x = xOriginal + continue + } screen.SetContent(x, y, c, nil, style) x++ }