Skip to content

Commit

Permalink
Switch to all in one binary
Browse files Browse the repository at this point in the history
commit 0323204
Author: RedSkiesReaperr <[email protected]>
Date:   Mon Aug 19 11:25:17 2024 +0200

    Update README.md

commit 5908700
Author: RedSkiesReaperr <[email protected]>
Date:   Mon Aug 19 11:17:16 2024 +0200

    Updated README.md

commit bcd3368
Author: RedSkiesReaperr <[email protected]>
Date:   Mon Aug 19 10:53:46 2024 +0200

    Docker build fixes

commit 96e93aa
Author: RedSkiesReaperr <[email protected]>
Date:   Mon Aug 19 10:53:23 2024 +0200

    Some adjustments for headless mode

commit 85ae26d
Author: RedSkiesReaperr <[email protected]>
Date:   Mon Aug 19 09:47:51 2024 +0200

    Add make build rule

commit 0c18fc5
Author: RedSkiesReaperr <[email protected]>
Date:   Sat Aug 17 09:56:52 2024 +0200

    Fixes

commit beb154e
Author: RedSkiesReaperr <[email protected]>
Date:   Fri Aug 16 10:08:19 2024 +0200

    Initialize core only at dashboardScreen.Init()

commit d286607
Author: RedSkiesReaperr <[email protected]>
Date:   Fri Aug 16 10:07:21 2024 +0200

    Fix config struct not updated after a call to .Update()

commit b6c250c
Author: RedSkiesReaperr <[email protected]>
Date:   Thu Aug 15 00:47:34 2024 +0200

    tasks can be re-run on demand

commit abf87d2
Author: RedSkiesReaperr <[email protected]>
Date:   Wed Aug 14 23:42:36 2024 +0200

    Fix howlongtobeat 404 requests

commit 44a70b8
Author: RedSkiesReaperr <[email protected]>
Date:   Wed Aug 14 23:26:19 2024 +0200

    Configuration screen works & nicer TUI

commit 8f9c359
Author: RedSkiesReaperr <[email protected]>
Date:   Wed Aug 14 23:25:10 2024 +0200

    Get config value through ConfigKey

commit 4e846b7
Author: RedSkiesReaperr <[email protected]>
Date:   Wed Aug 14 12:29:10 2024 +0200

    Rework config/ to use spf13/viper package

commit 1b9de66
Author: RedSkiesReaperr <[email protected]>
Date:   Wed Aug 14 10:50:29 2024 +0200

    Added style & menus to home screen

commit f7988ce
Author: RedSkiesReaperr <[email protected]>
Date:   Tue Aug 13 17:41:07 2024 +0200

    Refacto + Fix miss-exported functions/structs

commit 8be536c
Author: RedSkiesReaperr <[email protected]>
Date:   Tue Aug 13 17:24:49 2024 +0200

    Fix circleci build job

commit 7cdef7b
Author: RedSkiesReaperr <[email protected]>
Date:   Tue Aug 13 16:32:18 2024 +0200

    Nicer task screen

commit a0da4d4
Author: RedSkiesReaperr <[email protected]>
Date:   Mon Aug 12 19:20:25 2024 +0200

    Single app begin (dashboard & task details works)

commit 1c3d263
Author: RedSkiesReaperr <[email protected]>
Date:   Mon Aug 12 19:19:52 2024 +0200

    cleanup dependencies

commit d1dea34
Author: RedSkiesReaperr <[email protected]>
Date:   Mon Aug 12 19:19:36 2024 +0200

    Rework tui package architecture

commit 7d3cc87
Author: RedSkiesReaperr <[email protected]>
Date:   Mon Aug 12 19:19:05 2024 +0200

    Updated docker stuff

commit 0e56ece
Author: RedSkiesReaperr <[email protected]>
Date:   Sun Aug 11 23:32:25 2024 +0200

    Add -no-logfile option

commit 3e06271
Author: RedSkiesReaperr <[email protected]>
Date:   Sat Aug 10 22:18:51 2024 +0200

    Architecture rework

commit 5186c6a
Author: RedSkiesReaperr <[email protected]>
Date:   Fri Feb 9 17:11:45 2024 +0100

    Create base dashboard layout with panels and a table

commit 89135c1
Author: RedSkiesReaperr <[email protected]>
Date:   Fri Feb 9 12:32:53 2024 +0100

    Implement dialog workflow with configuration saving

commit 732f937
Author: RedSkiesReaperr <[email protected]>
Date:   Fri Feb 9 12:30:49 2024 +0100

    Created dialog view to display infos to user

commit 3bd4187
Author: RedSkiesReaperr <[email protected]>
Date:   Fri Feb 9 10:14:25 2024 +0100

    Ignore log files

commit 9a08de2
Author: RedSkiesReaperr <[email protected]>
Date:   Fri Feb 9 10:13:25 2024 +0100

    Remove no more used cmd/configurator

commit d215013
Author: RedSkiesReaperr <[email protected]>
Date:   Mon Feb 5 18:29:24 2024 +0100

    Add debug.log

commit 03c0da9
Author: RedSkiesReaperr <[email protected]>
Date:   Mon Feb 5 18:29:06 2024 +0100

    Configuration view works

commit 58de3fd
Author: RedSkiesReaperr <[email protected]>
Date:   Mon Feb 5 18:27:28 2024 +0100

    Cleaned app & main view

commit 8ef942f
Author: RedSkiesReaperr <[email protected]>
Date:   Sun Feb 4 14:02:06 2024 +0100

    Added Makefile

commit 9ac368c
Author: RedSkiesReaperr <[email protected]>
Date:   Sat Feb 3 17:31:39 2024 +0100

    Adapt circleci config

commit 995aa2b
Author: RedSkiesReaperr <[email protected]>
Date:   Sat Feb 3 17:21:06 2024 +0100

    Setup App & multiview system

commit 78b739a
Author: RedSkiesReaperr <[email protected]>
Date:   Sun Jan 7 13:47:22 2024 +0100

    Use bubble help.Model instead of custom one

commit 10b35b6
Author: RedSkiesReaperr <[email protected]>
Date:   Sun Jan 7 00:13:00 2024 +0100

    config package now store config in json file & Created configurator app
  • Loading branch information
RedSkiesReaperr committed Aug 19, 2024
1 parent 05c8d8e commit 2fb9890
Show file tree
Hide file tree
Showing 59 changed files with 2,174 additions and 777 deletions.
28 changes: 6 additions & 22 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
version: 2.1

orbs:
go: circleci/[email protected]
docker: circleci/[email protected]
go: circleci/[email protected]

jobs:
build_updater:
build:
executor:
name: go/default
tag: 1.21.1
Expand All @@ -17,21 +16,8 @@ jobs:
- go/mod-download
- go/save-cache
- run:
name: Build updater
command: go build -v -o ./updater cmd/updater/main.go

build_watcher:
executor:
name: go/default
tag: 1.21.1
steps:
- checkout
- go/load-cache
- go/mod-download
- go/save-cache
- run:
name: Build watcher
command: go build -v -o ./watcher cmd/watcher/main.go
name: Build application
command: make ci

test:
executor:
Expand All @@ -50,9 +36,7 @@ jobs:
workflows:
main:
jobs:
- build_watcher
- build_updater
- build
- test:
requires:
- build_watcher
- build_updater
- build
4 changes: 4 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.circleci/
bin/*
.env*
*.log
8 changes: 3 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
NOTION_API_SECRET=
NOTION_PAGE_ID=
IGDB_CLIENT_ID=
IGDB_SECRET=
UPDATER_HOST=127.0.0.1
UPDATER_PORT=8080
WATCHER_TICK_DELAY=3
NOTION_API_SECRET=
NOTION_PAGE_ID=
REFRESH_DELAY=2
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,5 @@ Temporary Items
# End of https://www.toptal.com/developers/gitignore/api/go,macos

bin/*
.env
.env
*.log
15 changes: 9 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
FROM golang:1.21.1-alpine as build
FROM golang:1.21.1-alpine AS build

RUN apk update && apk add --no-cache make

WORKDIR /usr/src/app
COPY go.mod go.sum ./
RUN go mod download && go mod verify

COPY . .
RUN go build -v -o /usr/local/bin/updater ./cmd/updater/main.go
RUN go build -v -o /usr/local/bin/watcher ./cmd/watcher/main.go
RUN make docker

# Release stage
FROM alpine:3.18

WORKDIR /bin
COPY --from=build /usr/local/bin/updater /bin/updater
COPY --from=build /usr/local/bin/watcher /bin/watcher
COPY .env .
COPY --from=build /usr/local/bin/igdb-app /bin/igdb-app
RUN touch .env
RUN chmod +x /bin/igdb-app

CMD ["igdb-app", "-headless"]
37 changes: 37 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
SOURCES := main.go logger.go
BINARY:= bin/app
PLATFORMS := darwin/amd64 darwin/arm64 linux/386 linux/amd64 linux/arm linux/arm64
WIN_PLATFORMS := windows/386 windows/amd64 windows/arm windows/arm64

temp = $(subst /, ,$@)
os = $(word 1, $(temp))
arch = $(word 2, $(temp))

.PHONY : release $(PLATFORMS) $(WIN_PLATFORMS) clean

release: $(PLATFORMS) $(WIN_PLATFORMS)

$(PLATFORMS):
GOOS=$(os) GOARCH=$(arch) go build -o $(BINARY)-$(os)-$(arch) $(SOURCES)

$(WIN_PLATFORMS):
GOOS=$(os) GOARCH=$(arch) go build -o $(BINARY)-$(os)-$(arch).exe $(SOURCES)

build:
go build -o $(BINARY) $(SOURCES)

clean:
rm -rf $(BINARY)-*

ci:
go build -v -o ./app $(SOURCES)

dev:
go build -o $(BINARY)-dev $(SOURCES)

docker:
go build -v -o /usr/local/bin/igdb-app $(SOURCES)

run:
go build -o $(BINARY) $(SOURCES)
./$(BINARY)-dev
180 changes: 106 additions & 74 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Notion IGDB autocomplete [![CircleCI](https://dl.circleci.com/status-badge/img/gh/RedSkiesReaperr/notion-igdb-autocomplete/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/RedSkiesReaperr/notion-igdb-autocomplete/tree/main) [![reddit thread](https://img.shields.io/badge/Reddit-FF4500?logo=reddit&logoColor=white)](https://www.reddit.com/r/Notion/comments/17dw8js/created_integration_to_automatically_fill_in/?utm_source=share&utm_medium=web2x&context=3) [![Notion template](https://img.shields.io/badge/Notion-%23000000.svg?logo=notion&logoColor=white)](https://plant-pantry-77c.notion.site/Automated-video-games-library-c833cb560feb4b82935a310e508d34c2)

# Notion IGDB autocomplete [![CircleCI](https://dl.circleci.com/status-badge/img/gh/RedSkiesReaperr/notion-igdb-autocomplete/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/RedSkiesReaperr/notion-igdb-autocomplete/tree/main) [![reddit thread](https://img.shields.io/badge/Reddit-FF4500?logo=reddit&logoColor=white)](https://www.reddit.com/r/Notion/comments/17dw8js/created_integration_to_automatically_fill_in/?utm_source=share&utm_medium=web2x&context=3) [![Notion template](https://img.shields.io/badge/Notion-%23000000.svg?logo=notion&logoColor=white)](https://plant-pantry-77c.notion.site/Automated-video-games-library-c833cb560feb4b82935a310e508d34c2) [![DockerHub](https://img.shields.io/badge/DockerHub-blue.svg?logo=docker&logoColor=white)](https://hub.docker.com/r/redskiesreaperr/notion-igdb-autocomplete)

This Go project aims to automate the completion of video game information in a Notion database. It simplifies the task of collecting and updating details of video games, including titles, franchises, genres, platforms, and release dates, by connecting to the Notion database.

Expand All @@ -9,108 +10,139 @@ This Go project aims to automate the completion of video game information in a N
- Automated Search: Performs online searches to retrieve up-to-date information about video games.
- Database Updates: Updates video game entries in Notion with the latest details, such as titles, franchises, genres, platforms, and release dates.

## System Requirements
- [Docker](https://www.docker.com/products/docker-desktop/)
## Table of Contents
1. [Prerequisites](#prerequisites)
2. [Installation](#installation)
3. [Configuration](#configuration)
4. [Running the Project](#running-the-project)
- [Running on Local Machine](#running-on-local-machine)
- [Running with Docker](#running-with-docker)
5. [Dependencies](#dependencies)
6. [Contributing](#contributing)
7. [License](#license)

## Prerequisites
- Go v1.21.1+ (if running on local machine)
- Make (if running on local machine)
- [Docker](https://www.docker.com/products/docker-desktop/) (if running on docker)
- Access to a Notion database and a Notion integration key (see Configuration section for details)
- Access to IGDB API by a client id and client secret (see Configuration section for details)

## Installation
> This section is mandatory only if you want to download the source & run the code on your local machine. Either, you can directly go to the [Configuration section]()
1. Clone this repository to your local machine:
```sh
git clone https://github.com/RedSkiesReaperr/notion-igdb-autocomplete
cd notion-igdb-autocomplete
```
To get started, you need to install Go, download the source code and install all the dependencies it needs to work properly.

## Configuration
### Clone the Repository
```bash
$ git clone https://github.com/RedSkiesReaperr/notion-igdb-autocomplete
$ cd notion-igdb-autocomplete
```

1. Create environment configuration file:
```sh
cp ./.env.example .env
```

2.
>**If you start from scratch**: Duplicate the [Notion template](https://plant-pantry-77c.notion.site/Automated-video-games-library-c833cb560feb4b82935a310e508d34c2?pvs=4) and go to step 4
>
>**If you already have a Notion database**: Continue to step 3

3. Create a Notion database (or configure an already existing one) with the following properties:
- Title:
- Name: Title
- Type: Title
- Platforms:
- Name: Platforms
- Type: Multi-select
- Genres:
- Name: Genres
- Type: Multi-select
- Franchises:
- Name: Franchises
- Type: Multi-select
- Release date:
- Name: Release date
- Type: Date
- Time to complete (Main Story)
- Name: Time to complete (Main Story)
- Type: Text
- Time to complete (Main + Sides)
- Name: Time to complete (Main + Sides)
- Type: Text
- Time to complete (Completionist)
- Name: Time to complete (Completionist)
- Type: Text

3. Create a private Notion integration on your account by following the [getting started page](https://developers.notion.com/docs/create-a-notion-integration#create-your-integration-in-notion) before the "Setting up the demo locally" step.

4. Put your integration API secret as value of the `NOTION_API_SECRET` in your `.env` file.

5. Go on your Notion databse, click on the "..." button and on the "copy link" option. As mentionned in [environment variables section](https://developers.notion.com/docs/create-a-notion-integration#environment-variables), Get the ID of your database and put it as value of the `NOTION_PAGE_ID` in your `.env` file.
### Install Dependencies
```bash
$ go mod download
```

## Configuration
This section will help you to get all the mandatory variables from third party apps and create the base application configuration.

### 1. Create environment configuration file:
Create a `.env` file to save your configuration informations:
```shell
$ cp ./.env.example .env
```

#### 2. Create a Notion database
>**If you start from scratch**: Duplicate the [Notion template](https://plant-pantry-77c.notion.site/Automated-video-games-library-c833cb560feb4b82935a310e508d34c2?pvs=4) and go to step 2
>**If you already have a Notion database**: Continue to step 1
1. Create a Notion database (or configure an already existing one) with the following properties:
- Title: (**type: Title**)
- Platforms: (**type: Multi-select**)
- Genres: (**type: Multi-select**)
- Franchises: (**type: Multi-select**)
- Release date: (**type: Date**)
- Time to complete (Main Story): (**type: Text**)
- Time to complete (Main + Sides): (**type: Text**)
- Time to complete (Completionist): (**type: Text**)

2. Create a private Notion integration on your account by following the [getting started page](https://developers.notion.com/docs/create-a-notion-integration#create-your-integration-in-notion) before the "Setting up the demo locally" step.
3. Put your integration API secret as value of the `NOTION_API_SECRET` in your `.env` file.
4. Go on your Notion databse, click on the "..." button and on the "copy link" option. As mentionned in [environment variables section](https://developers.notion.com/docs/create-a-notion-integration#environment-variables), Get the ID of your database and put it as value of the `NOTION_PAGE_ID` in your `.env` file.

> ***At this point you should have a Notion database, with all mandatory properties. You should have created a private Notion integration connected with you database. You should have a `.env` file in your cloned project directory who have two values filled: `NOTION_API_SECRET` and `NOTION_PAGE_ID`***
6. Create a Twitch Developer application (needed to use IGDB API) by following the "Account Creation" of [getting started page](https://api-docs.igdb.com/#getting-started). This will give you steps to get your `IGDB_CLIENT_ID` & `IGDB_SECRET`. Afterward fill `IGDB_CLIENT_ID` & `IGDB_SECRET` in your `.env` file. ***If you need more detailed explanations, follow the 'More details about IGDB configuration' section below***.
5. Create a Twitch Developer application (needed to use IGDB API) by following the "Account Creation" of [getting started page](https://api-docs.igdb.com/#getting-started). This will give you steps to get your `IGDB_CLIENT_ID` & `IGDB_SECRET`. Afterward fill `IGDB_CLIENT_ID` & `IGDB_SECRET` in your `.env` file. ***If you need more detailed explanations, follow the 'More details about IGDB configuration' section below***.

🎉 **Congrats, configuration done!** 🎉

### More details about IGDB configuration
Once you are on the Twitch developers portal:
1. On the left menu go in the "Applications" section
2. Then click on the "Register your application" purple button
3. In the registration form:
1. Name field: you fill whatever you want.
2. Second field (about OAuth things): `http://localhost`.
3. Click on create button
3. In the registration form:
1. Name field: you fill whatever you want.
2. Second field (about OAuth things): `http://localhost`.
3. Click on create button
4. Once created it takes you to the applications listing, then click on "Manage" button for your newly created app.
5. Under the captcha, you have a field "client identifier" (or something like that). This value is your `IGDB_CLIENT_ID`
6. Click on the "New secret" button. It gives you the `IGDB_SECRET`

## Usage
Install & configure the application following the steps above.

1. Run the application:
```sh
docker-compose up
```
2. In you Notion database create a new entry with a title matching the pattern `{{YOUR_DESIRED_GAME_NAME}}`

The application will connect to your Notion database, IGDB API and search for video game information.
Video game details, including titles, franchises, genres, platforms, and release dates, will be updated in your Notion database.

## Any question ?
The answer might be [there](https://www.reddit.com/r/Notion/comments/17dw8js/created_integration_to_automatically_fill_in/?utm_source=share&utm_medium=web2x&context=3)
## Running the Project

### Running on Local Machine

1. Compile the project:
```bash
$ make build
```
2. Run the generated binary:
```bash
$ ./bin/app
```

By running the app this way you will get into a nicer and clearer TUI (terminal user interface) than the more conventional way to run. You can navigate through it by using your keyboard. It will also help you to have a better understanding of whats going on. Here is a sneak peak of this TUI:
![tui-demo](https://github.com/user-attachments/assets/3a0dca3a-7d67-42ff-8c35-016b7f55abd7)

### Running with Docker

1. Pull the docker image:
```bash
$ docker pull redskiesreaperr/notion-igdb-autocomplete:latest
```
2. Create and run the container, send the config values as environment variables to the container:
```bash
$ docker run \
-e NOTION_PAGE_ID=your_notion_page_id \
-e IGDB_CLIENT_ID=your_igdb_client_id \
-e IGDB_SECRET=your_igdb_secret \
-e NOTION_API_SECRET=your_notion_api_secret \
-e REFRESH_DELAY=5 \
redskiesreaperr/notion-igdb-autocomplete:latest
```

## Dependencies
Thanks to all the authors who created and maintains the following packages:
- [agnivade/levenshtein](github.com/agnivade/levenshtein)
- [charmbracelet/bubbles](github.com/charmbracelet/bubbles)
- [charmbracelet/bubbletea](github.com/charmbracelet/bubbletea)
- [charmbracelet/lipgloss](github.com/charmbracelet/lipgloss)
- [corpix/uarand](github.com/corpix/uarand)
- [fsnotify/fsnotify](github.com/fsnotify/fsnotify)
- [google/uuid](github.com/google/uuid)
- [jomei/notionapi](github.com/jomei/notionapi)
- [spf13/viper](github.com/spf13/viper)

## Contributing
If you wish to contribute to this project, please follow these steps:

1. Fork this repository.
2. Create a branch for your feature: git checkout -b feature/feature-name
3. Commit your changes: git commit -m 'Added a new feature'
4. Push your branch: git push origin feature/feature-name
5. Submit a Pull Request.
5. Open a Pull Request.

## License
This project is licensed under the MIT License. See the LICENSE file for details.

Feel free to open issues or submit feature requests if you have ideas to enhance this project.

## Contributors
Loading

0 comments on commit 2fb9890

Please sign in to comment.