Skip to content

Commit

Permalink
Add Readme to folio dir
Browse files Browse the repository at this point in the history
  • Loading branch information
joerick committed Aug 30, 2023
1 parent b1467dd commit 1000ed6
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/main/src/DirWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as path from 'node:path';
import {app} from 'electron';
import * as fs from 'node:fs/promises';
import {Mutex} from 'async-mutex';
import FolioDirReadme from './FolioDirReadme.md?raw'

Check failure on line 5 in packages/main/src/DirWatcher.ts

View workflow job for this annotation

GitHub Actions / eslint

Missing semicolon

const APP_SUPPORT_DIR = app.getPath('appData')

Check failure on line 7 in packages/main/src/DirWatcher.ts

View workflow job for this annotation

GitHub Actions / eslint

Missing semicolon
const MY_APP_DIR = path.join(APP_SUPPORT_DIR, 'bitfolio')

Check failure on line 8 in packages/main/src/DirWatcher.ts

View workflow job for this annotation

GitHub Actions / eslint

Missing semicolon
Expand All @@ -15,6 +16,7 @@ export interface FolioFile {

const IGNORE_LIST = [
'.DS_Store',
'README.txt',
]

Check failure on line 20 in packages/main/src/DirWatcher.ts

View workflow job for this annotation

GitHub Actions / eslint

Missing semicolon

export default class DirWatcher {
Expand All @@ -24,8 +26,6 @@ export default class DirWatcher {

constructor() {
console.log("Folio dir: ", MY_APP_FOLIO_DIR);

Check warning on line 28 in packages/main/src/DirWatcher.ts

View workflow job for this annotation

GitHub Actions / eslint

Strings must use singlequote
// ensure the directory exists
fs.mkdir(MY_APP_FOLIO_DIR, {recursive: true});

this.watcher = this.watch();
this.watcher.catch(console.error)

Check failure on line 31 in packages/main/src/DirWatcher.ts

View workflow job for this annotation

GitHub Actions / eslint

Missing semicolon
Expand All @@ -34,6 +34,12 @@ export default class DirWatcher {
watcher?: Promise<void>;

async watch() {
// ensure the directory exists
await fs.mkdir(MY_APP_FOLIO_DIR, {recursive: true});

// ensure the readme exists
await fs.writeFile(path.join(MY_APP_FOLIO_DIR, 'README.txt'), FolioDirReadme, {flag: 'w'});

await this.updateIfNeeded()

Check failure on line 43 in packages/main/src/DirWatcher.ts

View workflow job for this annotation

GitHub Actions / eslint

Missing semicolon

for await (const event of fs.watch(MY_APP_FOLIO_DIR)) {
Expand Down
46 changes: 46 additions & 0 deletions packages/main/src/FolioDirReadme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
Bitfolio
========

Put files in this directory to view them in Bitfolio.

Supported file types:

- Images: .jpg, .jpeg, .png, .gif
- Video: .mp4, .webm, .mov
- Webpages: .html
- Fragment shaders: .glsl

Filename tags
-------------

To customize the display of a file, you can add tags to the filename.

- *Duration*: to set a file duration to 10 seconds, add `.10s.` to the
filename. e.g. `myvideo.10s.mp4`. If a duration is specified for a video,
it will loop for the duration.

- *Conform*: to specify the scale mode of a file, you can add `.fill.`,
`.fit.` or `.1-1.` to the filename. e.g. `myimage.fill.jpg`. The
default is `fill`.

Shaders
-------

Shaders can be written in [Tinyshader] format. There is one extra option - you
can specify the resolution of the shader using a comment at the start of the
file.

Here's an example:

*sample.glsl*
```
// {"resolution": 80}
t*=0.2;
color = vec3(
sin(x+t),
sawtooth(x*y+t),
triangle(x*r+t)
);
```

[Tinyshader]: https://tinyshader.com

0 comments on commit 1000ed6

Please sign in to comment.