Skip to content
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
55 changes: 55 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Release
on:
push:
tags:
- "v*"

permissions:
contents: write

jobs:
build-and-release:
name: Build and release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7.0.1

- name: Install pnpm
uses: pnpm/action-setup@v6.0.10
with:
version: 11.24.0
run_install: false

- name: Install Node.js
uses: actions/setup-node@v7.0.0
with:
node-version: 24.20.0
cache: pnpm

- name: Install dependencies
run: pnpm install

- name: Postinstall steps
run: pnpm svelte-kit sync
working-directory: apps/web

- name: Build
run: pnpm build
working-directory: apps/web

- name: Zip build output
# zip the *contents* of build/ (not the folder itself) so index.html
# ends up at the root of the archive
run: |
cd apps/web/build
zip -r "${{ github.workspace }}/ttu-reader-${{ github.ref_name }}.zip" .

- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ github.ref_name }}" \
"ttu-reader-${{ github.ref_name }}.zip" \
--title "${{ github.ref_name }}" \
--generate-notes
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ Following export targets are available:
| Zip File | Creates an offline archive of the selected data |
| GDrive | Allows you to upload and download data to your GDrive account.<br/> Requires a google login - the default session is valid for 50 minutes and requires a manual reauthentication/export afterwards if no custom credentials with a client secret are used.<br/>You can revoke the app permissions any time in your [google security settings](https://myaccount.google.com/permissions) |
| OneDrive | Allows you to upload and download data to your OneDrive account.<br/>Requires a microsoft login - the default session is valid for 50 minutes and requires a manual reauthentication/export afterwards if no custom credentials with a client secret are used.<br/>You can revoke the app permissions any time in your [microsoft account privacy settings](https://microsoft.com/consent)<br/> |
| ttsu-sync-server | Allows you to upload and download data to a self hosted [ttsu-sync-server](https://github.com/Minnowo/ttsu-sync-server) instance.<br/>Authenticates with a long lived API key instead of an OAuth login, so there is no reauthentication timeout |
| Filesystem | Allows you to store and read data from a configured folder on your hard drive.<br/>You have to grant permissions once per new opened tab.<br/>Only available on desktop chromium browsers - some browser like Brave may need additional flags in the browser settings enabled in order to see/use this option |

To export data select books in the manager and click/tap on the respective icon in the header.
Expand Down Expand Up @@ -416,6 +417,17 @@ To create such custom credentials follow these steps for the hoster you want to
42. Create a new OneDrive source on AJATT Reader with the client id and/or client secret you just have created
</details>
<br/>
<details>
<summary>ttsu-sync-server</summary>

ttsu-sync-server is a open source self-hostable server. See the [ttsu-sync-server](https://github.com/Minnowo/ttsu-sync-server) repo for how to build, configure and run the server itself.

45. Once the server is running, create a user and generate an API key
46. Under `Settings` > `Data` click the `+ Add` button to add a new remote data source
47. Choose `ttsu-sync-server` as the source
48. Enter the server's base URL (e.g. `http://127.0.0.1:8080`) in the "Client ID" field and the API key you generated in the "Client Secret" field. The username is not used by the server, only the API key
</details>
<br/>

You may find following additional controls for storage source settings:

Expand Down Expand Up @@ -571,3 +583,23 @@ pnpm build
### External Hoster

In case you want to use external hoster like GDrive for data import/export follow the steps described in [Storage Sources](#storage-sources)


# Dev

1. Have [Node.js](https://nodejs.org/) and [Yarn](https://classic.yarnpkg.com/) installed
```sh
git clone <repo-url>
```
2. Install the dependencies
```sh
yarn
```

3. Start the dev server:
```sh
yarn dev --host 0.0.0.0
```



14 changes: 14 additions & 0 deletions apps/web/src/lib/components/book-card/book-manager-header.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
fileCountData$,
fsStorageSource$,
gDriveStorageSource$,
ttsuSyncServerStorageSource$,
isOnline$,
oneDriveStorageSource$
} from '$lib/data/store';
Expand Down Expand Up @@ -137,6 +138,19 @@
requiresConnectivity: false
}
]
: []),
...(isStorageSourceAvailable(
StorageKey.TTSU_SYNC_SERVER,
$ttsuSyncServerStorageSource$,
window
)
? [
{
label: 'ttsu-sync-server',
key: StorageKey.TTSU_SYNC_SERVER,
requiresConnectivity: true
}
]
: [])
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
gDriveStorageSource$,
lastExportedTarget$,
lastExportedTypes$,
oneDriveStorageSource$
oneDriveStorageSource$,
ttsuSyncServerStorageSource$
} from '$lib/data/store';
import { executeReplicate$ } from '$lib/functions/replication/replication-progress';
import { createEventDispatcher } from 'svelte';
Expand Down Expand Up @@ -46,6 +47,19 @@
: []),
...(isStorageSourceAvailable(StorageKey.FS, $fsStorageSource$, window)
? [{ ...getStorageIconData(StorageKey.FS), source: StorageKey.FS, label: 'Filesystem' }]
: []),
...(isStorageSourceAvailable(
StorageKey.TTSU_SYNC_SERVER,
$ttsuSyncServerStorageSource$,
window
)
? [
{
...getStorageIconData(StorageKey.TTSU_SYNC_SERVER),
source: StorageKey.TTSU_SYNC_SERVER,
label: 'ttsu-sync-server'
}
]
: [])
].filter((icon) => icon.source !== $storageSource$);
}
Expand Down
4 changes: 4 additions & 0 deletions apps/web/src/lib/components/log-report-dialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
showExternalPlaceholder$,
gDriveStorageSource$,
oneDriveStorageSource$,
ttsuSyncServerStorageSource$,
fsStorageSource$,
syncTarget$,
keepLocalStatisticsOnDeletion$,
Expand Down Expand Up @@ -148,6 +149,9 @@
gDriveStorageSource$.getValue() === StorageSourceDefault.GDRIVE_DEFAULT,
oneDriveStorageSource:
oneDriveStorageSource$.getValue() === StorageSourceDefault.ONEDRIVE_DEFAULT,
ttsuSyncServerStorageSource:
ttsuSyncServerStorageSource$.getValue() ===
StorageSourceDefault.TTSU_SYNC_SERVER_DEFAULT,
fsStorageSource: !!fsStorageSource$.getValue(),
syncTarget: !!syncTarget$.getValue(),
keepLocalStatisticsOnDeletion: keepLocalStatisticsOnDeletion$.getValue(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
gDriveStorageSource$,
isOnline$,
oneDriveStorageSource$,
ttsuSyncServerStorageSource$,
syncTarget$
} from '$lib/data/store';
import { AutoReplicationType } from '$lib/functions/replication/replication-options';
Expand Down Expand Up @@ -73,6 +74,9 @@
case StorageKey.ONEDRIVE:
configuredIsSourceDefault = name === $oneDriveStorageSource$;
break;
case StorageKey.TTSU_SYNC_SERVER:
configuredIsSourceDefault = name === $ttsuSyncServerStorageSource$;
break;
case StorageKey.FS:
configuredIsSourceDefault = name === $fsStorageSource$;
break;
Expand Down Expand Up @@ -258,7 +262,12 @@
{@const storageSourceIsSourceDefault = isStorageSourceDefault(
storageSource.name,
storageSource.type,
[$gDriveStorageSource$, $oneDriveStorageSource$, $fsStorageSource$]
[
$gDriveStorageSource$,
$oneDriveStorageSource$,
$ttsuSyncServerStorageSource$,
$fsStorageSource$
]
)}
<div class="flex flex-col">
<div class="flex">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
let storageSourceEncryptionDisabled = configuredEncryptionDisabled || false;
let storageSourceTypes = [
{ key: StorageKey.GDRIVE, label: 'GDrive' },
{ key: StorageKey.ONEDRIVE, label: 'OneDrive' }
{ key: StorageKey.ONEDRIVE, label: 'OneDrive' },
{ key: StorageKey.TTSU_SYNC_SERVER, label: 'ttsu-sync-server' }
];

$: if (browser && 'showDirectoryPicker' in window) {
Expand Down
16 changes: 14 additions & 2 deletions apps/web/src/lib/components/storage-unlock.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
onMount(() => {
skipKeyDownListener$.next(true);

if (passwordElm) { passwordElm.focus() }
if (passwordElm) {
passwordElm.focus();
}

return () => skipKeyDownListener$.next(false);
});
Expand All @@ -63,7 +65,17 @@
<div>{description}</div>
<div class="my-2">{action}</div>
{#if requiresSecret}
<input type="password" placeholder="Password" bind:value={secret} bind:this={passwordElm} on:keyup={(evt) => {if (evt.key === 'Enter') {unlock()}}}/>
<input
type="password"
placeholder="Password"
bind:value={secret}
bind:this={passwordElm}
on:keyup={(evt) => {
if (evt.key === 'Enter') {
unlock();
}
}}
/>
{/if}
<div class="text-red-500">{error}</div>
</div>
Expand Down
20 changes: 14 additions & 6 deletions apps/web/src/lib/data/storage/handler/api-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import {
type ExternalFile
} from '$lib/data/storage/handler/base-handler';
import { getStorageHandler } from '$lib/data/storage/storage-handler-factory';
import { StorageOAuthManager } from '$lib/data/storage/storage-oauth-manager';
import { StorageKey } from '$lib/data/storage/storage-types';
import { database } from '$lib/data/store';
import {
Expand All @@ -33,8 +32,9 @@ import { ReplicationSaveBehavior } from '$lib/functions/replication/replication-
import { replicationProgress$ } from '$lib/functions/replication/replication-progress';
import { mergeStatistics, updateStatisticToStore } from '$lib/functions/statistic-util';
import pLimit from 'p-limit';
import { AuthType, type StorageAuthManager } from '../storage-auth-manager';

interface RequestOptions {
export interface RequestOptions {
method?: string;
headers?: Record<string, string>;
body?: XMLHttpRequestBodyInit | null | undefined;
Expand Down Expand Up @@ -74,17 +74,17 @@ export abstract class ApiStorageHandler extends BaseStorageHandler {

protected abstract executeDelete(id: string): Promise<void>;

protected authManager: StorageOAuthManager;
protected authManager: StorageAuthManager;

protected rootId = '';

protected titleToId = new Map<string, string>();

protected titleToFiles = new Map<string, ExternalFile[]>();

constructor(storageType: StorageKey, window: Window, refreshEndpoint: string) {
constructor(storageType: StorageKey, window: Window, authManager: StorageAuthManager) {
super(window, storageType);
this.authManager = new StorageOAuthManager(this.storageType, refreshEndpoint);
this.authManager = authManager;
}

updateSettings(
Expand Down Expand Up @@ -707,7 +707,15 @@ export abstract class ApiStorageHandler extends BaseStorageHandler {
}

if (token) {
xhr.setRequestHeader('Authorization', `Bearer ${token}`);
switch (this.authManager.getAuthType()) {
case AuthType.BASIC:
xhr.setRequestHeader('Authorization', `Basic ${token}`);
break;

case AuthType.OAUTH:
xhr.setRequestHeader('Authorization', `Bearer ${token}`);
break;
}
}

xhr.send(options.body || null);
Expand Down
7 changes: 6 additions & 1 deletion apps/web/src/lib/data/storage/handler/gdrive-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { BaseStorageHandler, type ExternalFile } from '$lib/data/storage/handler
import { StorageKey } from '$lib/data/storage/storage-types';
import { database, gDriveStorageSource$ } from '$lib/data/store';
import pLimit from 'p-limit';
import { StorageOAuthManager } from '../storage-oauth-manager';

interface GDriveFile extends ExternalFile {
thumbnailLink?: string;
Expand All @@ -23,7 +24,11 @@ export class GDriveStorageHandler extends ApiStorageHandler {
private baseUploadApiUrl = 'https://www.googleapis.com/upload/drive/v3/files';

constructor(window: Window) {
super(StorageKey.GDRIVE, window, gDriveRefreshEndpoint);
super(
StorageKey.GDRIVE,
window,
new StorageOAuthManager(StorageKey.GDRIVE, gDriveRefreshEndpoint)
);
}

setInternalSettings(storageSourceName: string) {
Expand Down
7 changes: 6 additions & 1 deletion apps/web/src/lib/data/storage/handler/onedrive-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { BaseStorageHandler, type ExternalFile } from '$lib/data/storage/handler
import { StorageKey } from '$lib/data/storage/storage-types';
import { database, oneDriveStorageSource$ } from '$lib/data/store';
import pLimit from 'p-limit';
import { StorageOAuthManager } from '../storage-oauth-manager';

interface OneDriveFile extends ExternalFile {
thumbnails?: ExternalThumbnail[];
Expand Down Expand Up @@ -54,7 +55,11 @@ export class OneDriveStorageHandler extends ApiStorageHandler {
private baseEndpoint = 'https://graph.microsoft.com/v1.0/me/drive/items';

constructor(window: Window) {
super(StorageKey.ONEDRIVE, window, oneDriveTokenEndpoint);
super(
StorageKey.ONEDRIVE,
window,
new StorageOAuthManager(StorageKey.ONEDRIVE, oneDriveTokenEndpoint)
);
}

setInternalSettings(storageSourceName: string) {
Expand Down
Loading
Loading