Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: online services #1166

Merged
merged 11 commits into from
Nov 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .valalintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
build
*~
builddir
.flatpak-builder
/tuba_windows_portable/
server/
15 changes: 15 additions & 0 deletions data/dev.geopjr.Tuba.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@
<key name="proxy" type="s">
<default>''</default>
</key>
<key name="analytics" type="b">
<default>false</default>
</key>
<key name="update-contributors" type="b">
<default>false</default>
</key>
<key name="last-analytics-update" type="s">
<default>''</default>
</key>
<key name="last-contributors-update" type="s">
<default>''</default>
</key>
<key name="contributors" type="as">
<default>['1021928818','2964685538','2486375860','3456423266','1352322503','445941323','3177176442','2386917030','987913018','1837154139','4173902237','4223975552','3163563143','3320460562','4233664772','136476033','4041964504','3998595277','580879396','4086778421']</default>
</key>

<key name="window-w" type="i">
<default>600</default>
Expand Down
1 change: 1 addition & 0 deletions data/gresource.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
<file preprocess="xml-stripblanks">icons/scalable/actions/tuba-mail-unread-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/tuba-starred-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/tuba-camera-focus-symbolic.svg</file>
<file preprocess="xml-stripblanks">icons/scalable/actions/tuba-heart-filled-symbolic.svg</file>
<!-- <file preprocess="xml-stripblanks">icons/scalable/actions/tuba-language-symbolic.svg</file> -->

<file>gtk/help-overlay.ui</file>
Expand Down
2 changes: 2 additions & 0 deletions data/icons/scalable/actions/tuba-heart-filled-symbolic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 9 additions & 1 deletion data/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ headerbar.flat.no-title .title {
background-color: alpha(@warning_bg_color, .1);
}

.ttl-post.direct:hover {
.ttl-post.direct:hover{
background-color: darker(alpha(@warning_bg_color, .1));
}

Expand Down Expand Up @@ -770,3 +770,11 @@ list.uniform-border-color row {
.emoji-reaction-expander > box > list, .emoji-reaction-expander > box > list > row {
border-radius: inherit;
}

.ttl-profile-cover.thanks {
background: alpha(@accent_bg_color, 0.1);
}

.ttl-profile-cover.thanks avatar {
border-color: alpha(@accent_bg_color, 0.1);
}
37 changes: 36 additions & 1 deletion data/ui/dialogs/preferences.ui
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<property name="page_increment">1</property>
</object>
<template class="TubaDialogsPreferences" parent="AdwPreferencesDialog">
<property name="search-enabled">True</property>
<property name="search-enabled">True</property>
<child>
<object class="AdwPreferencesPage">
<property name="icon_name">tuba-settings-symbolic</property>
Expand Down Expand Up @@ -200,6 +200,41 @@
</child>
</object>
</child>
<child>
<object class="AdwPreferencesGroup">
<property name="title" translatable="yes">Online Services</property>
<property name="description" translatable="yes">Configure features that connect to api.tuba.geopjr.dev</property>
<child>
<object class="AdwActionRow">
<property name="title" translatable="yes">Send Preference Analytics</property>
<property name="subtitle" translatable="yes">Send your preferences to Tuba's developers for popularity research biweekly</property>
<property name="activatable-widget">analytics_switch</property>
<child type="suffix">
<object class="GtkButton">
<property name="icon-name">tuba-eye-open-negative-filled-symbolic</property>
<property name="valign">center</property>
<property name="tooltip-text" translatable="yes">Preview Analytics</property>
<signal name="clicked" handler="on_analytics_preview" swapped="no" />
<style>
<class name="flat" />
</style>
</object>
</child>
<child type="suffix">
<object class="GtkSwitch" id="analytics_switch">
<property name="valign">center</property>
</object>
</child>
</object>
</child>
<child>
<object class="AdwSwitchRow" id="update_contributors">
<property name="title" translatable="yes">Update Supporters Periodically</property>
<property name="subtitle" translatable="yes">Fetch the list of Tuba's supporters biweekly</property>
</object>
</child>
</object>
</child>
</object>
</child>
<child>
Expand Down
18 changes: 18 additions & 0 deletions data/ui/views/profile_header.ui
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,24 @@
</style>
</object>
</child>
<child type="overlay">
<object class="GtkImage" id="supporter_icon">
<property name="valign">start</property>
<property name="halign">start</property>
<property name="visible">0</property>
<property name="margin-bottom">48</property>
<!-- translators: Tooltip text shown on an icon that indicates -->
<!-- that the user is either a financial supporter -->
<!-- or contributor to Tuba -->
<property name="tooltip-text" translatable="yes">Tuba Supporter</property>
<property name="icon-name">tuba-heart-filled-symbolic</property>
<style>
<class name="osd" />
<class name="cover-badge" />
<class name="only-icon" />
</style>
</object>
</child>
<property name="child">
<object class="TubaWidgetsBackground" id="background">
<accessibility>
Expand Down
9 changes: 9 additions & 0 deletions server/.editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*.cr]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
5 changes: 5 additions & 0 deletions server/.env.json.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"token": "SECRET_SERVER_ADMIN_TOKEN",
"github": "GITHUB_TOKEN",
"database": "DATABASE_LOCATION"
}
7 changes: 7 additions & 0 deletions server/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/docs/
/lib/
/bin/
/.shards/
*.dwarf
.env.json
*.db
69 changes: 69 additions & 0 deletions server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Tuba's API Server

Server to be used for Tuba's analytics and other services.

## Notice

The analytics in question are anonymized voluntarily published (aka OPT-IN) Tuba settings and will be used to gather a general idea of what settings are popular.

<details><summary>Example analytics body</summary>

```json
{
"accounts": [
"0c604c54-15a9-43eb-b4e3-11d986ee33d3"
],
"analytics": {
"color-scheme": "TUBA_COLOR_SCHEME_SYSTEM",
"timeline-page-size": "20",
"live-updates": "TRUE",
"public-live-updates": "FALSE",
"show-spoilers": "FALSE",
"show-preview-cards": "TRUE",
"larger-font-size": "FALSE",
"larger-line-height": "FALSE",
"aggressive-resolving": "FALSE",
"strip-tracking": "TRUE",
"scale-emoji-hover": "FALSE",
"letterbox-media": "FALSE",
"media-viewer-expand-pictures": "TRUE",
"enlarge-custom-emojis": "FALSE",
"use-blurhash": "TRUE",
"group-push-notifications": "FALSE",
"advanced-boost-dialog": "TRUE",
"reply-to-old-post-reminder": "TRUE",
"spellchecker-enabled": "TRUE",
"darken-images-on-dark-mode": "FALSE",
"media-viewer-last-used-volume": "1.000000",
"monitor-network": "TRUE",
"dim-trivial-notifications": "FALSE"
}
}
```

</details>

The API might also provide additional content or features to Tuba users. Future additions to the API will also abide by the same standards of being optional, opt-in and privacy respecting.

## Installation

- Fill the config file [`.env.json.example`](./.env.json.example)
- Rename it to `.env.json`
- Run:

```sh
$ shards install
$ shards build --release
```

## Usage

```sh
$ ./bin/server --help
-b HOST, --bind HOST Host to bind (defaults to 0.0.0.0)
-p PORT, --port PORT Port to listen for connections (defaults to 3000)
-s, --ssl Enables SSL
--ssl-key-file FILE SSL key file
--ssl-cert-file FILE SSL certificate file
-h, --help Shows this help
```
26 changes: 26 additions & 0 deletions server/shard.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: 2.0
shards:
backtracer:
git: https://github.com/sija/backtracer.cr.git
version: 1.2.2

db:
git: https://github.com/crystal-lang/crystal-db.git
version: 0.13.1

exception_page:
git: https://github.com/crystal-loot/exception_page.git
version: 0.4.1

kemal:
git: https://github.com/kemalcr/kemal.git
version: 1.6.0

radix:
git: https://github.com/luislavena/radix.git
version: 0.4.1

sqlite3:
git: https://github.com/crystal-lang/crystal-sqlite3.git
version: 0.21.0

19 changes: 19 additions & 0 deletions server/shard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: server
version: 0.1.1

authors:
- Evan Paterakis <[email protected]>

dependencies:
kemal:
github: kemalcr/kemal
sqlite3:
github: crystal-lang/crystal-sqlite3

targets:
server:
main: src/server.cr

crystal: '>= 1.12.1'

license: GPL-3.0-only
Loading
Loading