Skip to content

Commit a348c27

Browse files
evan-bussKab1r
andauthored
Merge pull request #95 from evan-buss/development
* Improve error handling. - Don't log.Fatal or panic() - Return errors from func instead of logging directly in library code - Send more error messages via websocket - Make sure IRC connection is open before writing. * Various maintenance tasks. (#76) - Use new devcontainer "features" instead of scripts - Update Go and NPM packages. - Fix breaking change with use-local-storage-state - Add makefile for common commands * Update Go packages. * feat: add --searchbot flag (#86) * feat: add --searchbot flag * fix: uncomment flag assignment * feat: add flag to disable automatic browser downloads (#87) * chore: update npm and go deps * feat: add desktop webview functionality - some webviews don't have native copy paste so I update the search field on user selection * feat: open desktop mode by default * fix: get windows build working * fix: windows tweaks - use filepath.join() instead of path.join() - change default download dir depending on which subcommand is selected - allow double clicking on windows (disable cobra mousetrap thing) * fix: resize grid on window height change * fix: re-render grids when page height changes * fix: set desktop mode as the default - allows double clicking the executable to open the GUI * fix: move openbrowser setting out of the server config - server code shouldn't care how the page is being displayed. * fix: Fully type redux stores / middleware / actions - replace AppThunk with createAsyncThunk * remove unused npm packages * cleanup / add loading animation * feat: download and extract files with ".temp" extension until completed - This allows Calibre to watch a directory and only import the file when it's completed. * fix: use separate config for each cobra command. * fix: default desktop mode opens the browser. - Cross compilation becomes A LOT more complicated once CGO is in the mix. Requires the time and energy to get build scripts to work across all platforms, and update the automated Github Actions to build on multiple machines (MacOS requires MacOS runner, Windows / Linux require Linux runner) - This commit adds a build flag "webview" to enable webview desktop support but the default without the build flag is to open the browser on start. * fix: use new build flag syntax * block until close * Add TLS Support for IRC communication (#90) * Fix length comparison so zero doesn't appear. (#74) * feat: Add IRC TLS support Co-authored-by: Evan Buss <[email protected]> * ci: update action versions / publish dev docker images - update docker tag configuration to publish 'edge' version whenever the 'development' branch is updated. * fix: command binding fixes - EnableTLS flag was only enabled for the server mode. - "--dir" server mode flag wasn't registered properly. - update * chore: update npm packages - updated to react 18 * fix: actually fix zero comparison? * feat: migrate ui to mantine (#93) * wip: start rewriting sidebar in mantine - this is the start of making the layout responsive for various device sizes * feat: rewrite sidebar with mantine - responsive - dark mode support * feat: convert book list to mantine * feat: rewrite notification drawer in mantine * wip: start converting search page * feat: convert search page to mantine * wip: start implement book table in react table * wip: re-implement table with react-table Goals: - mantine styling - resizeable - filterable - dark mode * wip: react table implementation * wip: grid style tweaks * wip: play with animations * feat: finish converting components to mantine * feat: remove evergreen-ui dependency * chore: remove react-use * Update README.md * styling: fix issues - long text overflows - nicer sidebar toggling - overflow wrapping with scroll * chore: update dependencies * feat: show placeholder when search empty * fix: error line word wrapping * docs: update readme Co-authored-by: Kabir Kwatra <[email protected]>
2 parents 8639492 + ccb4b31 commit a348c27

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+9264
-5378
lines changed

.devcontainer/Dockerfile

+7-14
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,12 @@
1-
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.191.0/containers/go/.devcontainer/base.Dockerfile
1+
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.217.4/containers/ubuntu/.devcontainer/base.Dockerfile
22

3-
# [Choice] Go version: 1, 1.16, 1.15
4-
ARG VARIANT="1.17"
5-
FROM mcr.microsoft.com/vscode/devcontainers/go:${VARIANT}
6-
7-
# [Choice] Node.js version: none, lts, 16, 14, 12, 10
8-
ARG NODE_VERSION="none"
9-
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
3+
# [Choice] Ubuntu version (use hirsuite or bionic on local arm64/Apple Silicon): hirsute, focal, bionic
4+
ARG VARIANT="hirsute"
5+
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}
106

117
# [Optional] Uncomment this section to install additional OS packages.
128
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
13-
&& apt-get -y install --no-install-recommends tmux
14-
15-
# [Optional] Uncomment the next line to use go get to install anything else you need
16-
RUN go get golang.org/x/tools/cmd/stringer
9+
&& apt-get -y install --no-install-recommends tmux
1710

18-
# [Optional] Uncomment this line to install global node packages.
19-
RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g npm-check-updates" 2>&1
11+
# # [Optional] Uncomment this line to install global node packages.
12+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g npm-check-updates" 2>&1

.devcontainer/devcontainer.json

+45-39
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,47 @@
11
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2-
// https://github.com/microsoft/vscode-dev-containers/tree/v0.191.0/containers/go
2+
// https://github.com/microsoft/vscode-dev-containers/tree/v0.217.4/containers/ubuntu
33
{
4-
"name": "Go",
5-
"build": {
6-
"dockerfile": "Dockerfile",
7-
"args": {
8-
"VARIANT": "1.17",
9-
"NODE_VERSION": "16"
10-
}
11-
},
12-
"runArgs": [
13-
"--cap-add=SYS_PTRACE",
14-
"--security-opt",
15-
"seccomp=unconfined"
16-
],
17-
// Set *default* container specific settings.json values on container create.
18-
"settings": {
19-
"go.toolsManagement.checkForUpdates": "local",
20-
"go.useLanguageServer": true,
21-
"go.gopath": "/go",
22-
"go.goroot": "/usr/local/go"
23-
},
24-
// Add the IDs of extensions you want installed when the container is created.
25-
"extensions": [
26-
"golang.Go",
27-
"eamodio.gitlens",
28-
"bradlc.vscode-tailwindcss",
29-
"esbenp.prettier-vscode",
30-
"GitHub.copilot"
31-
],
32-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
33-
"forwardPorts": [
34-
3000,
35-
5228
36-
],
37-
// Use 'postCreateCommand' to run commands after the container is created.
38-
// "postCreateCommand": "go version",
39-
// Comment out connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
40-
"remoteUser": "vscode"
41-
}
4+
"name": "Ubuntu",
5+
"build": {
6+
"dockerfile": "Dockerfile",
7+
"args": {
8+
"VARIANT": "jammy"
9+
}
10+
},
11+
// Set *default* container specific settings.json values on container create.
12+
"settings": {
13+
"go.toolsManagement.checkForUpdates": "local",
14+
"go.addTags": {
15+
"tags": "json",
16+
"options": "json=omitempty",
17+
"promptForTags": false,
18+
"transform": "snakecase",
19+
"template": ""
20+
},
21+
"go.useLanguageServer": true,
22+
"go.gopath": "/go",
23+
"go.goroot": "/usr/local/go"
24+
},
25+
"runArgs": ["--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"],
26+
// Add the IDs of extensions you want installed when the container is created.
27+
"extensions": [
28+
"golang.Go",
29+
"eamodio.gitlens",
30+
"bradlc.vscode-tailwindcss",
31+
"esbenp.prettier-vscode",
32+
"GitHub.copilot"
33+
],
34+
// Use 'forwardPorts' to make a list of ports inside the container available locally.
35+
// "forwardPorts": [],
36+
// Use 'postCreateCommand' to run commands after the container is created.
37+
// "postCreateCommand": "uname -a",
38+
// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
39+
"remoteUser": "vscode",
40+
"features": {
41+
"docker-in-docker": "latest",
42+
"git": "latest",
43+
"sshd": "latest",
44+
"node": "lts",
45+
"golang": "latest"
46+
}
47+
}

.github/home_v3.png

387 KB
Loading

.github/home_v3_dark.png

380 KB
Loading

.github/workflows/docker_hub.yml

+16-10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ name: Publish Image to Docker Hub
77
on:
88
workflow_dispatch:
99
push:
10+
branches:
11+
- master
12+
- development
1013
tags:
1114
- 'v*.*.*'
1215

@@ -16,40 +19,43 @@ jobs:
1619

1720
steps:
1821
- name: Checkout Repository
19-
uses: actions/checkout@v2
22+
uses: actions/checkout@v3
2023

2124
- name: Set Docker Metadata
2225
id: meta
23-
uses: docker/metadata-action@v3
26+
uses: docker/metadata-action@v4
2427
with:
2528
# list of Docker images to use as base name for tags
2629
images: |
2730
evanbuss/openbooks
2831
# generate Docker tags based on the following events/attributes
32+
# 'latest' when push to master with tag
33+
# 'edge' when push to development
34+
# '1.1.1' when push version tag v1.1.1
2935
flavor: |
30-
latest=true
36+
latest=auto
3137
tags: |
32-
type=sha
38+
type=semver,pattern={{version}}
39+
type=edge,branch=development
3340
3441
- name: Set up QEMU
35-
uses: docker/setup-qemu-action@v1
42+
uses: docker/setup-qemu-action@v2
3643

3744
- name: Set up Docker Buildx
3845
id: buildx
39-
uses: docker/setup-buildx-action@v1
46+
uses: docker/setup-buildx-action@v2
4047
with:
4148
version: latest
4249
install: true
43-
use: true
4450

4551
- name: Login to Docker Hub
46-
uses: docker/login-action@v1
52+
uses: docker/login-action@v2
4753
with:
4854
username: ${{ secrets.DOCKER_USERNAME }}
4955
password: ${{ secrets.DOCKER_HUB_TOKEN }}
5056

5157
- name: Build and Push
52-
uses: docker/build-push-action@v2
58+
uses: docker/build-push-action@v3
5359
with:
5460
context: .
5561
platforms: linux/amd64,linux/arm64,linux/arm
@@ -58,7 +64,7 @@ jobs:
5864
tags: ${{ steps.meta.outputs.tags }}
5965

6066
- name: Docker Hub Description
61-
uses: peter-evans/dockerhub-description@v2
67+
uses: peter-evans/dockerhub-description@v3
6268
with:
6369
username: ${{ secrets.DOCKER_USERNAME }}
6470
password: ${{ secrets.DOCKER_PASSWORD }}

.github/workflows/release.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@ jobs:
1414
runs-on: ubuntu-latest
1515
steps:
1616
- name: Checkout code
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v3
1818

1919
- uses: actions/setup-go@v2
2020
with:
2121
go-version: "^1.17.0"
2222
- run: go version
2323

2424
- name: Setup Node.js
25-
uses: actions/setup-node@v2
25+
uses: actions/setup-node@v3
2626
with:
27-
node-version: "16"
27+
node-version: 16
2828

2929
- name: Build
3030
run: ./build.sh

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# start persist
2+
mock_server
23
openbooks
34
!openbooks/
45
*.DS_Store

.vscode/launch.json

+3-14
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,15 @@
1010
"request": "launch",
1111
"mode": "debug",
1212
"program": "cmd/openbooks",
13-
"args": [
14-
"server",
15-
"--log",
16-
"--server",
17-
"localhost"
18-
],
13+
"args": ["server", "--log", "--server", "localhost", "--persist"]
1914
},
2015
{
2116
"name": "Launch OpenBooks CLI",
2217
"type": "go",
2318
"request": "launch",
2419
"mode": "debug",
2520
"program": "cmd/openbooks",
26-
"args": [
27-
"cli",
28-
"download",
29-
"--server",
30-
"localhost",
31-
"!test"
32-
],
21+
"args": ["cli", "download", "--server", "localhost", "!test"]
3322
}
3423
]
35-
}
24+
}

README.md

+18-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@
66

77
Openbooks allows you to download ebooks from irc.irchighway.net quickly and easily.
88

9-
![openbooks](https://raw.githubusercontent.com/evan-buss/openbooks/master/.github/home_v2.png)
9+
<picture>
10+
<source media="(prefers-color-scheme: dark)" srcset="./.github/home_v3_dark.png">
11+
<img alt="openbooks screenshot" src="./.github/home_v3.png">
12+
</picture>
13+
1014

1115
## Getting Started
1216

@@ -42,6 +46,8 @@ two modes; Server or CLI. In CLI mode you interact and download books through
4246
a terminal interface. In server mode the application runs as a web application
4347
that you can visit in your browser.
4448

49+
Double clicking the executable will open the UI in your browser. In the future it may use [webviews](https://developer.microsoft.com/en-us/microsoft-edge/webview2/) to provide a "native-like" desktop application.
50+
4551
## Development
4652

4753
### Install the dependencies
@@ -72,6 +78,15 @@ that you can visit in your browser.
7278
go run . server --server localhost --log
7379
```
7480

81+
### Desktop App
82+
Compile OpenBooks with experimental webview support:
83+
84+
``` shell
85+
cd cmd/openbooks
86+
go build -tags webview
87+
```
88+
89+
7590
## Why / How
7691

7792
- I wrote this as an easier way to search and download books from irchighway.net. It handles all the extraction and data processing for you. You just have to click the book you want. Hopefully you find it much easier than the IRC interface.
@@ -88,5 +103,5 @@ that you can visit in your browser.
88103
- React.js
89104
- TypeScript
90105
- Redux / Redux Toolkit
91-
- Tailwind CSS
92-
- Evergreen UI
106+
- Mantine UI / @emotion/react
107+
- Framer Motion

cli/cli.go

+10-8
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import (
1010
)
1111

1212
type Config struct {
13-
UserName string // Username to use when connecting to IRC
14-
Log bool // True if IRC messages should be logged
15-
Dir string
16-
Server string
17-
irc *irc.Conn
18-
Version string
13+
UserName string // Username to use when connecting to IRC
14+
Log bool // True if IRC messages should be logged
15+
Dir string
16+
Server string
17+
EnableTLS bool
18+
SearchBot string
19+
Version string
20+
irc *irc.Conn
1921
}
2022

2123
// StartInteractive instantiates the OpenBooks CLI interface
@@ -37,7 +39,7 @@ func StartInteractive(config Config) {
3739
}
3840

3941
go core.StartReader(ctx, config.irc, handler)
40-
terminalMenu(config.irc)
42+
terminalMenu(config)
4143

4244
<-ctx.Done()
4345
}
@@ -93,7 +95,7 @@ func StartSearch(config Config, query string) {
9395
time.Sleep(time.Until(nextSearchTime))
9496

9597
go core.StartReader(ctx, config.irc, handler)
96-
core.SearchBook(config.irc, query)
98+
core.SearchBook(config.irc, config.SearchBot, query)
9799

98100
setLastSearchTime()
99101
fmt.Printf("%sSent search request.", clearLine)

0 commit comments

Comments
 (0)