Skip to content

Commit

Permalink
🔨 chore: crlf -> lf
Browse files Browse the repository at this point in the history
  • Loading branch information
fawni committed Aug 30, 2024
1 parent 48a53a8 commit ad9278e
Show file tree
Hide file tree
Showing 11 changed files with 433 additions and 438 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM rust:1.74 AS builder
FROM rust:1.80 AS builder
WORKDIR /usr/src/tamako
COPY . .
RUN cargo install sqlx-cli --no-default-features --features native-tls,postgres
Expand All @@ -12,4 +12,4 @@ COPY --from=builder /usr/src/tamako/tamako /app/
COPY --from=builder /usr/src/tamako/migrations/ /app/migrations/
COPY --from=builder /usr/src/tamako/assets/ /app/assets/
COPY --from=builder /usr/local/cargo/bin/sqlx /usr/local/bin/sqlx
CMD [ "/app/tamako" ]
CMD [ "/app/tamako" ]
344 changes: 172 additions & 172 deletions LICENSE

Large diffs are not rendered by default.

146 changes: 73 additions & 73 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,74 +1,74 @@
# tamako🐞

[![status-badge](https://ci.codeberg.org/api/badges/12523/status.svg)](https://ci.codeberg.org/repos/12523)
[![crates.io](https://img.shields.io/crates/v/tamako.svg)](https://crates.io/crates/tamako)
[![dependency status](https://deps.rs/repo/codeberg/fawn/tamako/status.svg)](https://deps.rs/repo/codeberg/fawn/tamako)

tamako is a cozy, minimalistic, single-user, _anonymous_ whispers service

![scrot](meta/scrot.png)

## Prerequisites

- [sqlx-cli](https://crates.io/crates/sqlx-cli)
- a postgresql database

## Environment variables

| Name | Type | Default | Notes |
| ------------------------- | ------ | ------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `TAMAKO_HOST` | String | 127.0.0.1 | the host to run the server on |
| `TAMAKO_PORT` | u16 | 8715 | the port to serve the server on |
| `DATABASE_URL` | String | _none_ | the database url. this should be a valid postgresql connection url |
| `WEBHOOK_URL` | String | _none_ | _(optional)_ the discord webhook url. this will be used to send _private and public_ whispers to a discord channel |
| `TAMAKO_SECRET` | String | _none_ | the secret key used for authentication. think of it like a master password |
| `TAMAKO_USER_NAME` | String | tamako | _(optional)_ used in the fronted header |
| `TAMAKO_USER_DESCRIPTION` | String | Cozy anonymous whispers 🐞 | _(optional)_ used in the fronted header |

## Installation

### Docker Compose (Recommended)

This will also create a postgres service container.

1. Clone the repo
2. Configure `docker-compose.yml` to match your setup, most importantly change the environment variables
3. `docker compose up -d`

### Locally

1. Clone the repo
2. Rename `.env.example` to `.env` and change env variables inside it
3. Build tamako: `cargo build --release`
4. Run tamako: `./target/release/tamako`

### Docker

Using docker directly is possible, but you have to configure the container yourself.

```sh
docker run -d --name tamako --restart unless-stopped -p 8715:8715 fawni/tamako:latest
```

## TUI

tamako comes with a pretty little tui frontend for it called mochi

![mochi](meta/mochi.png)

### Installation

```sh
go install codeberg.org/fawn/tamako/cmd/mochi@latest
```
### Usage

```sh
mochi --url https://tamako.fawn.moe
```

`mochi -h` for more info.

## License

# tamako🐞

[![status-badge](https://ci.codeberg.org/api/badges/12523/status.svg)](https://ci.codeberg.org/repos/12523)
[![crates.io](https://img.shields.io/crates/v/tamako.svg)](https://crates.io/crates/tamako)
[![dependency status](https://deps.rs/repo/codeberg/fawn/tamako/status.svg)](https://deps.rs/repo/codeberg/fawn/tamako)

tamako is a cozy, minimalistic, single-user, _anonymous_ whispers service

![scrot](meta/scrot.png)

## Prerequisites

- [sqlx-cli](https://crates.io/crates/sqlx-cli)
- a postgresql database

## Environment variables

| Name | Type | Default | Notes |
| ------------------------- | ------ | ------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| `TAMAKO_HOST` | String | 127.0.0.1 | the host to run the server on |
| `TAMAKO_PORT` | u16 | 8715 | the port to serve the server on |
| `DATABASE_URL` | String | _none_ | the database url. this should be a valid postgresql connection url |
| `WEBHOOK_URL` | String | _none_ | _(optional)_ the discord webhook url. this will be used to send _private and public_ whispers to a discord channel |
| `TAMAKO_SECRET` | String | _none_ | the secret key used for authentication. think of it like a master password |
| `TAMAKO_USER_NAME` | String | tamako | _(optional)_ used in the fronted header |
| `TAMAKO_USER_DESCRIPTION` | String | Cozy anonymous whispers 🐞 | _(optional)_ used in the fronted header |

## Installation

### Docker Compose (Recommended)

This will also create a postgres service container.

1. Clone the repo
2. Configure `docker-compose.yml` to match your setup, most importantly change the environment variables
3. `docker compose up -d`

### Locally

1. Clone the repo
2. Rename `.env.example` to `.env` and change env variables inside it
3. Build tamako: `cargo build --release`
4. Run tamako: `./target/release/tamako`

### Docker

Using docker directly is possible, but you have to configure the container yourself.

```sh
docker run -d --name tamako --restart unless-stopped -p 8715:8715 fawni/tamako:latest
```

## TUI

tamako comes with a pretty little tui frontend for it called mochi

![mochi](meta/mochi.png)

### Installation

```sh
go install codeberg.org/fawn/tamako/cmd/mochi@latest
```
### Usage

```sh
mochi --url https://tamako.fawn.moe
```

`mochi -h` for more info.

## License

[OSL-3.0](LICENSE)
54 changes: 27 additions & 27 deletions cmd/mochi/tui/keys/keys.go
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
package keys

import "github.com/charmbracelet/bubbles/key"

type Keymap struct {
Copy key.Binding
Refresh key.Binding
Delete key.Binding
}

func NewKeymap() *Keymap {
return &Keymap{
Copy: key.NewBinding(
key.WithKeys("enter"),
key.WithHelp("enter", "copy"),
),
Refresh: key.NewBinding(
key.WithKeys("r"),
key.WithHelp("r", "refresh"),
),
Delete: key.NewBinding(
key.WithKeys("delete"),
key.WithHelp("delete", "delete"),
key.WithDisabled(), // TODO: implement auth
),
}
}
package keys

import "github.com/charmbracelet/bubbles/key"

type Keymap struct {
Copy key.Binding
Refresh key.Binding
Delete key.Binding
}

func NewKeymap() *Keymap {
return &Keymap{
Copy: key.NewBinding(
key.WithKeys("enter"),
key.WithHelp("enter", "copy"),
),
Refresh: key.NewBinding(
key.WithKeys("r"),
key.WithHelp("r", "refresh"),
),
Delete: key.NewBinding(
key.WithKeys("delete"),
key.WithHelp("delete", "delete"),
key.WithDisabled(), // TODO: implement auth
),
}
}
58 changes: 29 additions & 29 deletions cmd/mochi/tui/minimal/minimal.go
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
package minimal

import (
"fmt"

"codeberg.org/fawn/tamako/cmd/mochi/tamako"
"codeberg.org/fawn/tamako/cmd/mochi/tui/styles"
)

func Render(w tamako.Whisper) {
res := titleMargin(styles.TitleStyle.Render("tamako") + fmt.Sprintf(" - %s", snowflakeStyle(fmt.Sprintf("%d", w.Snowflake))))
res += line("\nName", name(w.Name))
res += line("Message", w.Message)
res += line("Private", fmt.Sprintf("%t", w.Private))
res += line("Timestamp", w.Timestamp)

fmt.Println(res)
}

func name(n string) string {
if n == "anon" {
return mutedStyle(n)
}
return n
}

func line(key string, value string) string {
return textStyle(fmt.Sprintf("%s: %s", keyStyle(key), value)) + "\n"
}
package minimal

import (
"fmt"

"codeberg.org/fawn/tamako/cmd/mochi/tamako"
"codeberg.org/fawn/tamako/cmd/mochi/tui/styles"
)

func Render(w tamako.Whisper) {
res := titleMargin(styles.TitleStyle.Render("tamako") + fmt.Sprintf(" - %s", snowflakeStyle(fmt.Sprintf("%d", w.Snowflake))))
res += line("\nName", name(w.Name))
res += line("Message", w.Message)
res += line("Private", fmt.Sprintf("%t", w.Private))
res += line("Timestamp", w.Timestamp)

fmt.Println(res)
}

func name(n string) string {
if n == "anon" {
return mutedStyle(n)
}
return n
}

func line(key string, value string) string {
return textStyle(fmt.Sprintf("%s: %s", keyStyle(key), value)) + "\n"
}
28 changes: 14 additions & 14 deletions cmd/mochi/tui/minimal/styles.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package minimal

import (
"codeberg.org/fawn/tamako/cmd/mochi/tui/styles"
lg "github.com/charmbracelet/lipgloss"
)

var (
titleMargin = lg.NewStyle().Margin(1, 0, 1, 2).Render
textStyle = lg.NewStyle().MarginLeft(2).Render
keyStyle = lg.NewStyle().Foreground(styles.Colors.Primary).Bold(true).Render
mutedStyle = lg.NewStyle().Foreground(styles.Colors.Muted).Italic(true).Render
snowflakeStyle = lg.NewStyle().Italic(true).Render
)
package minimal

import (
"codeberg.org/fawn/tamako/cmd/mochi/tui/styles"
lg "github.com/charmbracelet/lipgloss"
)

var (
titleMargin = lg.NewStyle().Margin(1, 0, 1, 2).Render
textStyle = lg.NewStyle().MarginLeft(2).Render
keyStyle = lg.NewStyle().Foreground(styles.Colors.Primary).Bold(true).Render
mutedStyle = lg.NewStyle().Foreground(styles.Colors.Muted).Italic(true).Render
snowflakeStyle = lg.NewStyle().Italic(true).Render
)
30 changes: 15 additions & 15 deletions cmd/mochi/tui/styles/delegates.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
package styles

import (
"github.com/charmbracelet/bubbles/list"
)

func NewListDelegate() list.DefaultDelegate {
d := list.NewDefaultDelegate()
d.Styles.SelectedTitle = d.Styles.SelectedTitle.Foreground(Colors.Primary).BorderLeftForeground(Colors.Primary)
d.Styles.SelectedDesc = d.Styles.SelectedDesc.Foreground(Colors.Secondary).BorderLeftForeground(Colors.Primary)
d.Styles.NormalTitle = d.Styles.NormalTitle.Foreground(Colors.Text)
d.Styles.NormalDesc = d.Styles.NormalDesc.Foreground(Colors.Muted)

return d
}
package styles

import (
"github.com/charmbracelet/bubbles/list"
)

func NewListDelegate() list.DefaultDelegate {
d := list.NewDefaultDelegate()
d.Styles.SelectedTitle = d.Styles.SelectedTitle.Foreground(Colors.Primary).BorderLeftForeground(Colors.Primary)
d.Styles.SelectedDesc = d.Styles.SelectedDesc.Foreground(Colors.Secondary).BorderLeftForeground(Colors.Primary)
d.Styles.NormalTitle = d.Styles.NormalTitle.Foreground(Colors.Text)
d.Styles.NormalDesc = d.Styles.NormalDesc.Foreground(Colors.Muted)

return d
}
46 changes: 23 additions & 23 deletions cmd/mochi/tui/styles/styles.go
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package styles

import lg "github.com/charmbracelet/lipgloss"

var (
AppStyle = lg.NewStyle().
Margin(1, 2)
TitleStyle = lg.NewStyle().
Foreground(Colors.White).
Background(Colors.Primary).
Bold(true).
Padding(0, 1)

Primary = lg.NewStyle().
Foreground(Colors.Primary).
Render
Error = lg.NewStyle().
Foreground(Colors.Red).
Render
Success = lg.NewStyle().
Foreground(Colors.Green).
Render
)
package styles

import lg "github.com/charmbracelet/lipgloss"

var (
AppStyle = lg.NewStyle().
Margin(1, 2)
TitleStyle = lg.NewStyle().
Foreground(Colors.White).
Background(Colors.Primary).
Bold(true).
Padding(0, 1)

Primary = lg.NewStyle().
Foreground(Colors.Primary).
Render
Error = lg.NewStyle().
Foreground(Colors.Red).
Render
Success = lg.NewStyle().
Foreground(Colors.Green).
Render
)
Loading

0 comments on commit ad9278e

Please sign in to comment.