diff --git a/Cargo.lock b/Cargo.lock index a573654..96a1900 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1325,9 +1325,10 @@ checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" [[package]] name = "edits" -version = "0.31.1" +version = "0.32.0" dependencies = [ "gpui-kit", + "image", "kael_share", "libloading", "regex", diff --git a/Cargo.toml b/Cargo.toml index 0e92e2b..e06b88e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "edits" -version = "0.31.1" +version = "0.32.0" edition = "2021" description = "One small download (under 15 MB, with its desktop app) that turns any YouTube link, channel or topic into viral TikTok, Reels and Shorts edits: Alight Motion and Premiere presets, trending songs, beat-synced cuts, captions, colour looks, MCP server for AI agents." repository = "https://github.com/OnurByte/EditsMaker" @@ -14,12 +14,14 @@ license = "MIT" # cargo build --release --no-default-features [features] default = ["app"] -app = ["dep:gpui-kit", "dep:kael_share"] +app = ["dep:gpui-kit", "dep:kael_share", "dep:image"] [dependencies] gpui-kit = { version = "0.10.0", optional = true } # the system's own share sheet (macOS, Windows; mail on Linux), for Share on a clip or a pack; 0.4 pins a wasm-bindgen GPUI cannot share kael_share = { version = "=0.3.0", optional = true } +# already in the build through GPUI: a GIF's first frame, so the marketplace's cards stand still until one is opened +image = { version = "0.25", default-features = false, features = ["gif", "png"], optional = true } regex = "1" resvg = { version = "0.45.1", default-features = false, features = ["text", "system-fonts", "raster-images"] } libloading = "0.8" diff --git a/PACKS.md b/PACKS.md index 66a4538..4aec3fa 100644 --- a/PACKS.md +++ b/PACKS.md @@ -156,8 +156,9 @@ edits follow football --post tiktok # as posts come: RSS in, video made, posted ``` `edits packs make DIR --opml FILE` turns any RSS reader's export into a feed pack. The built-in ones (`edits.rss-*`) -come from [awesome-rss-feeds](https://github.com/plenaryapp/awesome-rss-feeds) (CC0), and `edits.rss-turkiye` from -Anadolu Ajansı, TRT Haber and BBC Türkçe. +and `edits.world` (25 countries) come from [awesome-rss-feeds](https://github.com/plenaryapp/awesome-rss-feeds) (CC0); +`turkiye` from Anadolu Ajansı, TRT Haber and BBC Türkçe; `edits.clubs` from Fotomaç, NTV Spor and the clubs' fan blogs; +`edits.rss-anime` from Anime News Network, MyAnimeList, Anime Corner, Otaku USA and Crunchyroll. ## Sources diff --git a/packs/README.md b/packs/README.md index ff0b493..d7aae9d 100644 --- a/packs/README.md +++ b/packs/README.md @@ -1,13 +1,16 @@ # Packs -15 built-in packs, each with a `manifest.json`, an agent skill and a picture. The marketplace: `edits packs browse`, `edits packs add ID`, or the app. The standard, and making one: [PACKS.md](../PACKS.md). +22 built-in packs, each with a `manifest.json`, an agent skill and a picture. The marketplace: `edits packs browse`, `edits packs add ID`, or the app. The standard, and making one: [PACKS.md](../PACKS.md). RSS in. Edits out. Each new post from BBC, CNN, The Guardian, NYT, Reddit, IGN, TechCrunch, NASA, Anadolu Ajansı or TRT Haber becomes an edit, and a flow posts it. ## RSS

+Football clubs News +Anime +World

## Presets @@ -36,5 +39,9 @@

What your agent knows +Embers +Sakura +Snow Stardust +Warp

diff --git a/packs/blur-reveal/manifest.json b/packs/blur-reveal/manifest.json index 98b3f4c..91aa9d3 100644 --- a/packs/blur-reveal/manifest.json +++ b/packs/blur-reveal/manifest.json @@ -11,17 +11,7 @@ ], "preview": "preview.gif", "tags": [ - "slow", - "medium", - "fast", - "9:16", - "4:5", - "blur", - "flash", - "rgb", - "shake", - "slide", - "velocity", - "zoom" + "anime", + "hype" ] } diff --git a/packs/character/manifest.json b/packs/character/manifest.json index 706bbcc..50cb368 100644 --- a/packs/character/manifest.json +++ b/packs/character/manifest.json @@ -11,12 +11,7 @@ ], "preview": "preview.gif", "tags": [ - "medium", - "9:16", - "1:1", - "flash", - "rgb", - "shake", - "zoom" + "hype", + "cinematic" ] } diff --git a/packs/cinematic/manifest.json b/packs/cinematic/manifest.json index 0164718..c157050 100644 --- a/packs/cinematic/manifest.json +++ b/packs/cinematic/manifest.json @@ -11,15 +11,7 @@ ], "preview": "preview.gif", "tags": [ - "slow", - "9:16", - "1:1", - "blur", - "cinema", - "fade", - "flash", - "retro", - "slide", - "zoom" + "cinematic", + "sad" ] } diff --git a/packs/clubs/SKILL.md b/packs/clubs/SKILL.md new file mode 100644 index 0000000..d19f396 --- /dev/null +++ b/packs/clubs/SKILL.md @@ -0,0 +1,33 @@ +--- +name: edits-clubs +description: "Make short videos from a football club's news with edits: 12 topics (galatasaray, fenerbahce, besiktas, trabzonspor, turkish-football, real-madrid, barcelona, arsenal, tottenham, bayern, juventus, fifa), each new story's headline cut from footage found for it and shown on screen. Use when the user wants videos from a football club's news, posts on autopilot, or an automation from RSS to video to social media." +--- + +# Football clubs + +Every club is read from the paper or the fans' blog that follows it closest; each new story becomes an edit. + +```sh +edits rss galatasaray --list # the newest posts (--json for programs) +edits rss galatasaray -n 3 # a video for each of the 3 newest +edits rss real-madrid --feed all -n 5 --preset sinema-bant +edits follow galatasaray --post tiktok --every 30 # RSS in, video made, posted out (edits watch runs it) +``` + +Topics: + +- `galatasaray`: Galatasaray, 1 feed (Fotomaç Galatasaray) +- `fenerbahce`: Fenerbahçe, 1 feed (Fotomaç Fenerbahçe) +- `besiktas`: Beşiktaş, 1 feed (Fotomaç Beşiktaş) +- `trabzonspor`: Trabzonspor, 1 feed (Fotomaç Trabzonspor) +- `turkish-football`: Türk futbolu, 2 feeds (Fotomaç Futbol, NTV Spor Futbol) +- `real-madrid`: Real Madrid, 1 feed (Managing Madrid) +- `barcelona`: Barcelona, 1 feed (Barça Blaugranes) +- `arsenal`: Arsenal, 1 feed (football.london Arsenal) +- `tottenham`: Tottenham, 1 feed (Cartilage Free Captain) +- `bayern`: Bayern Munich, 1 feed (Bavarian Football Works) +- `juventus`: Juventus, 1 feed (Black & White & Read All Over) +- `fifa`: FIFA, 1 feed (FIFA) + +Each video is footage found for the headline, with the headline on screen for its first seconds. Check a headline +before posting it, and say whose post it was. diff --git a/packs/clubs/manifest.json b/packs/clubs/manifest.json new file mode 100644 index 0000000..e21ed91 --- /dev/null +++ b/packs/clubs/manifest.json @@ -0,0 +1,143 @@ +{ + "schemaVersion": 1, + "id": "edits.clubs", + "name": "Football clubs", + "version": "1.0.0", + "author": "EditsMaker", + "description": "12 clubs, from Galatasaray to Real Madrid, each from the paper or the fans' blog that follows it closest. Every new story becomes an edit; a flow can post it for you.", + "kinds": [ + "skill", + "feed" + ], + "preview": "preview.svg", + "tags": [ + "news", + "automation" + ], + "topics": [ + { + "key": "galatasaray", + "name": "Galatasaray", + "feeds": [ + { + "name": "Fotomaç Galatasaray", + "url": "https://www.fotomac.com.tr/rss/galatasaray.xml" + } + ] + }, + { + "key": "fenerbahce", + "name": "Fenerbahçe", + "feeds": [ + { + "name": "Fotomaç Fenerbahçe", + "url": "https://www.fotomac.com.tr/rss/fenerbahce.xml" + } + ] + }, + { + "key": "besiktas", + "name": "Beşiktaş", + "feeds": [ + { + "name": "Fotomaç Beşiktaş", + "url": "https://www.fotomac.com.tr/rss/besiktas.xml" + } + ] + }, + { + "key": "trabzonspor", + "name": "Trabzonspor", + "feeds": [ + { + "name": "Fotomaç Trabzonspor", + "url": "https://www.fotomac.com.tr/rss/trabzonspor.xml" + } + ] + }, + { + "key": "turkish-football", + "name": "Türk futbolu", + "feeds": [ + { + "name": "Fotomaç Futbol", + "url": "https://www.fotomac.com.tr/rss/futbol.xml" + }, + { + "name": "NTV Spor Futbol", + "url": "https://www.ntvspor.net/rss/kategori/futbol" + } + ] + }, + { + "key": "real-madrid", + "name": "Real Madrid", + "feeds": [ + { + "name": "Managing Madrid", + "url": "https://www.managingmadrid.com/rss/index.xml" + } + ] + }, + { + "key": "barcelona", + "name": "Barcelona", + "feeds": [ + { + "name": "Barça Blaugranes", + "url": "https://www.barcablaugranes.com/rss/index.xml" + } + ] + }, + { + "key": "arsenal", + "name": "Arsenal", + "feeds": [ + { + "name": "football.london Arsenal", + "url": "https://www.football.london/arsenal-fc/?service=rss" + } + ] + }, + { + "key": "tottenham", + "name": "Tottenham", + "feeds": [ + { + "name": "Cartilage Free Captain", + "url": "https://cartilagefreecaptain.sbnation.com/rss/index.xml" + } + ] + }, + { + "key": "bayern", + "name": "Bayern Munich", + "feeds": [ + { + "name": "Bavarian Football Works", + "url": "https://www.bavarianfootballworks.com/rss/index.xml" + } + ] + }, + { + "key": "juventus", + "name": "Juventus", + "feeds": [ + { + "name": "Black & White & Read All Over", + "url": "https://www.blackwhitereadallover.com/rss/index.xml" + } + ] + }, + { + "key": "fifa", + "name": "FIFA", + "feeds": [ + { + "name": "FIFA", + "url": "https://www.youtube.com/feeds/videos.xml?channel_id=UCpcTrCXblq78GZrTUTLWeBw" + } + ] + } + ] +} diff --git a/packs/clubs/preview.svg b/packs/clubs/preview.svg new file mode 100644 index 0000000..6a9acb5 --- /dev/null +++ b/packs/clubs/preview.svg @@ -0,0 +1,9 @@ + + +RSS +Football clubs +12 clubs, from Galatasaray to Real Madrid, each from the paper +or the fans' blog that follows it closest. Every new story +becomes an edit; a flow can post it for you. +Galatasaray · Fenerbahçe · Beşiktaş · Trabzonspor · Türk futbolu +7 more + diff --git a/packs/edits/manifest.json b/packs/edits/manifest.json index 155ae45..c9e6777 100644 --- a/packs/edits/manifest.json +++ b/packs/edits/manifest.json @@ -10,8 +10,6 @@ ], "preview": "preview.gif", "tags": [ - "agent", - "mcp", - "skills" + "automation" ] } diff --git a/packs/embers/SKILL.md b/packs/embers/SKILL.md new file mode 100644 index 0000000..345864e --- /dev/null +++ b/packs/embers/SKILL.md @@ -0,0 +1,17 @@ +--- +name: edits-embers +description: "Lay the Embers 3D scene (three.js) over an edit with edits: sparks rising from a fire below, flickering orange to red as they climb, in 3D, looping. Use when the user wants embers, sparks, fire or a 3D overlay on a hype, phonk or villain edit." +--- + +# Embers + +Sparks rising from a fire below, flickering orange to red as they climb, in 3D. It loops every 5 seconds. + +```sh +edits --overlay embers +edits --overlay embers@2-6:0.8 # from 2 s to 6 s, at 80% +``` + +Its scene.js runs alone: in a browser of its own with no window, no files and nothing of the person's; only three.js +is loaded for it. A 3D scene pack of your own is one function in scene.js, `(THREE, scene, camera, opts) => (t) => {}` +(PACKS.md). diff --git a/packs/embers/manifest.json b/packs/embers/manifest.json new file mode 100644 index 0000000..09001fc --- /dev/null +++ b/packs/embers/manifest.json @@ -0,0 +1,21 @@ +{ + "schemaVersion": 1, + "id": "edits.embers", + "name": "Embers", + "version": "1.0.0", + "author": "EditsMaker", + "description": "Sparks rising from a fire below, flickering orange to red as they climb, in 3D. For hype and phonk edits; it loops.", + "kinds": [ + "skill", + "scene" + ], + "preview": "preview.svg", + "tags": [ + "3d", + "hype" + ], + "scene": { + "seconds": 5.0, + "fps": 30 + } +} diff --git a/packs/embers/preview.svg b/packs/embers/preview.svg new file mode 100644 index 0000000..788fa2f --- /dev/null +++ b/packs/embers/preview.svg @@ -0,0 +1,8 @@ + + +3D scene +Embers +Sparks rising from a fire below, flickering orange to red as +they climb, in 3D. For hype and phonk edits; it loops. +edits <link> --overlay embers + diff --git a/packs/embers/scene.js b/packs/embers/scene.js new file mode 100644 index 0000000..1a6d53d --- /dev/null +++ b/packs/embers/scene.js @@ -0,0 +1,45 @@ +// Embers: sparks rising out of a fire below, flickering orange to red and fading as they climb; one lap per loop. +(THREE, scene, camera, opts) => { + const count = 700, seconds = 5; + let s = 5; + const rand = () => ((s = (s * 16807) % 2147483647) / 2147483647); + const base = new Float32Array(count * 3), seed = new Float32Array(count), col = new Float32Array(count * 3); + for (let i = 0; i < count; i++) { + base[i * 3] = (rand() - 0.5) * 9; + base[i * 3 + 1] = rand(); + base[i * 3 + 2] = -1 - rand() * 8; + seed[i] = rand(); + } + const geo = new THREE.BufferGeometry(); + geo.setAttribute("position", new THREE.BufferAttribute(new Float32Array(count * 3), 3)); + geo.setAttribute("color", new THREE.BufferAttribute(col, 3)); + const c = document.createElement("canvas"); + c.width = c.height = 64; + const g = c.getContext("2d"); + const grad = g.createRadialGradient(32, 32, 0, 32, 32, 32); + grad.addColorStop(0, "rgba(255,255,255,1)"); + grad.addColorStop(0.25, "rgba(255,255,255,0.7)"); + grad.addColorStop(1, "rgba(255,255,255,0)"); + g.fillStyle = grad; + g.fillRect(0, 0, 64, 64); + const mat = new THREE.PointsMaterial({ size: 0.16, map: new THREE.CanvasTexture(c), vertexColors: true, transparent: true, depthWrite: false, blending: THREE.AdditiveBlending }); + scene.add(new THREE.Points(geo, mat)); + return (t) => { + const k = (t % seconds) / seconds; + const a = geo.attributes.position.array; + for (let i = 0; i < count; i++) { + // how far up this spark is, 0 at the fire to 1 at the top + const h = (base[i * 3 + 1] + k) % 1; + const w = (k * 2 + seed[i]) * Math.PI * 2; + a[i * 3] = base[i * 3] + Math.sin(w) * 0.3 * h; + a[i * 3 + 1] = -8 + h * 16; + a[i * 3 + 2] = base[i * 3 + 2]; + const fade = (1 - h) * (0.7 + 0.3 * Math.sin(w * 3)); + col[i * 3] = fade; + col[i * 3 + 1] = fade * (0.55 - 0.4 * h); + col[i * 3 + 2] = fade * 0.1; + } + geo.attributes.position.needsUpdate = true; + geo.attributes.color.needsUpdate = true; + }; +} diff --git a/packs/glitch/manifest.json b/packs/glitch/manifest.json index 01041fa..2c5b40e 100644 --- a/packs/glitch/manifest.json +++ b/packs/glitch/manifest.json @@ -11,16 +11,7 @@ ], "preview": "preview.gif", "tags": [ - "slow", - "fast", - "9:16", - "1:1", - "flash", - "rgb", - "shake", - "strobe", - "transition", - "velocity", - "zoom" + "glitch", + "hype" ] } diff --git a/packs/news/manifest.json b/packs/news/manifest.json index 2faa426..47dab52 100644 --- a/packs/news/manifest.json +++ b/packs/news/manifest.json @@ -12,7 +12,6 @@ "preview": "preview.gif", "tags": [ "news", - "rss", "automation" ], "topics": [ diff --git a/packs/playful/manifest.json b/packs/playful/manifest.json index c89e851..8b30aeb 100644 --- a/packs/playful/manifest.json +++ b/packs/playful/manifest.json @@ -11,13 +11,6 @@ ], "preview": "preview.gif", "tags": [ - "medium", - "9:16", - "comic", - "flash", - "shake", - "slide", - "split", - "zoom" + "meme" ] } diff --git a/packs/post/manifest.json b/packs/post/manifest.json index 3e3cb0f..728b3bf 100644 --- a/packs/post/manifest.json +++ b/packs/post/manifest.json @@ -11,10 +11,7 @@ ], "preview": "preview.gif", "tags": [ - "post", - "tiktok", - "instagram", - "youtube" + "automation" ], "sites": [ { diff --git a/packs/punch-whip/manifest.json b/packs/punch-whip/manifest.json index 3db4c96..119a28d 100644 --- a/packs/punch-whip/manifest.json +++ b/packs/punch-whip/manifest.json @@ -11,15 +11,7 @@ ], "preview": "preview.gif", "tags": [ - "medium", - "fast", - "9:16", - "4:5", - "1:1", - "wide", - "flash", - "shake", - "slide", - "zoom" + "hype", + "anime" ] } diff --git a/packs/rss-anime/SKILL.md b/packs/rss-anime/SKILL.md new file mode 100644 index 0000000..4e12aeb --- /dev/null +++ b/packs/rss-anime/SKILL.md @@ -0,0 +1,26 @@ +--- +name: edits-rss-anime +description: "Make short videos from Anime RSS (6 feeds, Anime News Network, Anime News Network (all), MyAnimeList News and more) with edits, each new post's headline cut from footage found for it and shown on screen. Use when the user wants Anime videos from the news, posts on autopilot, or an automation from RSS to video to social media." +--- + +# Anime + +Anime news as it breaks: Anime News Network, MyAnimeList, Anime Corner, Otaku USA and Crunchyroll's trailers. Each new story becomes an edit; a flow can post it for you. + +```sh +edits rss anime --list # the newest posts (--json for programs) +edits rss anime -n 3 # a video for each of the 3 newest +edits rss anime --feed all -n 5 --preset sinema-bant +edits follow anime --post tiktok --every 30 # RSS in, video made, posted out (edits watch runs it) +``` + +Feeds: + +- Anime News Network https://www.animenewsnetwork.com/news/rss.xml +- Anime News Network (all) https://www.animenewsnetwork.com/all/rss.xml +- MyAnimeList News https://myanimelist.net/rss/news.xml +- Anime Corner https://animecorner.me/feed/ +- Otaku USA https://otakuusamagazine.com/feed/ +- Crunchyroll https://www.youtube.com/feeds/videos.xml?user=crunchyroll + +Each video is footage found for the headline, with the headline on screen for its first seconds. Check a headline before posting it, and say whose post it was. diff --git a/packs/rss-anime/manifest.json b/packs/rss-anime/manifest.json new file mode 100644 index 0000000..0fbcf25 --- /dev/null +++ b/packs/rss-anime/manifest.json @@ -0,0 +1,44 @@ +{ + "schemaVersion": 1, + "id": "edits.rss-anime", + "name": "Anime", + "version": "1.0.0", + "author": "EditsMaker", + "description": "Anime news as it breaks: Anime News Network, MyAnimeList, Anime Corner, Otaku USA and Crunchyroll's trailers. Each new story becomes an edit; a flow can post it for you.", + "kinds": [ + "skill", + "feed" + ], + "preview": "preview.svg", + "tags": [ + "anime", + "news", + "automation" + ], + "feeds": [ + { + "name": "Anime News Network", + "url": "https://www.animenewsnetwork.com/news/rss.xml" + }, + { + "name": "Anime News Network (all)", + "url": "https://www.animenewsnetwork.com/all/rss.xml" + }, + { + "name": "MyAnimeList News", + "url": "https://myanimelist.net/rss/news.xml" + }, + { + "name": "Anime Corner", + "url": "https://animecorner.me/feed/" + }, + { + "name": "Otaku USA", + "url": "https://otakuusamagazine.com/feed/" + }, + { + "name": "Crunchyroll", + "url": "https://www.youtube.com/feeds/videos.xml?user=crunchyroll" + } + ] +} diff --git a/packs/rss-anime/preview.svg b/packs/rss-anime/preview.svg new file mode 100644 index 0000000..104275b --- /dev/null +++ b/packs/rss-anime/preview.svg @@ -0,0 +1,9 @@ + + +RSS +Anime +Anime news as it breaks: Anime News Network, MyAnimeList, +Anime Corner, Otaku USA and Crunchyroll's trailers. Each new +story becomes an edit; a flow can post it for you. +Anime News Network · Anime News Network (all) · MyAnimeList News +3 more + diff --git a/packs/sakura/SKILL.md b/packs/sakura/SKILL.md new file mode 100644 index 0000000..1db85fb --- /dev/null +++ b/packs/sakura/SKILL.md @@ -0,0 +1,17 @@ +--- +name: edits-sakura +description: "Lay the Sakura 3D scene (three.js) over an edit with edits: cherry petals drifting down on a breeze, tumbling as they fall, in 3D, looping. Use when the user wants sakura, cherry blossoms, falling petals or a 3D overlay on an anime, love or soft edit." +--- + +# Sakura + +Cherry petals drifting down on a breeze, tumbling as they fall, in 3D. It loops every 8 seconds. + +```sh +edits --overlay sakura +edits --overlay sakura@2-6:0.8 # from 2 s to 6 s, at 80% +``` + +Its scene.js runs alone: in a browser of its own with no window, no files and nothing of the person's; only three.js +is loaded for it. A 3D scene pack of your own is one function in scene.js, `(THREE, scene, camera, opts) => (t) => {}` +(PACKS.md). diff --git a/packs/sakura/manifest.json b/packs/sakura/manifest.json new file mode 100644 index 0000000..328d39a --- /dev/null +++ b/packs/sakura/manifest.json @@ -0,0 +1,22 @@ +{ + "schemaVersion": 1, + "id": "edits.sakura", + "name": "Sakura", + "version": "1.0.0", + "author": "EditsMaker", + "description": "Cherry petals drifting down on a breeze, tumbling as they fall, in 3D. For anime and soft edits; it loops.", + "kinds": [ + "skill", + "scene" + ], + "preview": "preview.svg", + "tags": [ + "3d", + "anime", + "sad" + ], + "scene": { + "seconds": 8.0, + "fps": 30 + } +} diff --git a/packs/sakura/preview.svg b/packs/sakura/preview.svg new file mode 100644 index 0000000..1c5633c --- /dev/null +++ b/packs/sakura/preview.svg @@ -0,0 +1,8 @@ + + +3D scene +Sakura +Cherry petals drifting down on a breeze, tumbling as they +fall, in 3D. For anime and soft edits; it loops. +edits <link> --overlay sakura + diff --git a/packs/sakura/scene.js b/packs/sakura/scene.js new file mode 100644 index 0000000..a90acf1 --- /dev/null +++ b/packs/sakura/scene.js @@ -0,0 +1,38 @@ +// Sakura: pink cherry petals drifting down on a breeze, each tumbling as it falls; one lap per loop. +(THREE, scene, camera, opts) => { + const count = 160, seconds = 8; + let s = 23; + const rand = () => ((s = (s * 16807) % 2147483647) / 2147483647); + // a petal: two curves meeting in a notch, drawn once on a canvas + const c = document.createElement("canvas"); + c.width = c.height = 128; + const g = c.getContext("2d"); + const grad = g.createLinearGradient(0, 0, 0, 128); + grad.addColorStop(0, "#ffe3ec"); + grad.addColorStop(1, "#f7a8c4"); + g.fillStyle = grad; + g.beginPath(); + g.moveTo(64, 120); + g.bezierCurveTo(8, 90, 12, 20, 50, 8); + g.lineTo(64, 22); + g.lineTo(78, 8); + g.bezierCurveTo(116, 20, 120, 90, 64, 120); + g.fill(); + const mat = new THREE.MeshBasicMaterial({ map: new THREE.CanvasTexture(c), transparent: true, side: THREE.DoubleSide, depthWrite: false }); + const geo = new THREE.PlaneGeometry(0.28, 0.28); + const petals = []; + for (let i = 0; i < count; i++) { + const m = new THREE.Mesh(geo, mat); + const p = { m, x: (rand() - 0.5) * 9, y: (rand() - 0.5) * 16, z: -1 - rand() * 8, seed: rand(), spin: 1 + Math.floor(rand() * 2) }; + scene.add(m); + petals.push(p); + } + return (t) => { + const k = (t % seconds) / seconds; + for (const p of petals) { + const w = (k + p.seed) * Math.PI * 2; + p.m.position.set(p.x + Math.sin(w) * 0.6 + k * 2 - 1, ((p.y + 8 - k * 16) % 16 + 16) % 16 - 8, p.z); + p.m.rotation.set(w * p.spin, w, Math.sin(w) * 0.8); + } + }; +} diff --git a/packs/series/manifest.json b/packs/series/manifest.json index c6024d2..a353f00 100644 --- a/packs/series/manifest.json +++ b/packs/series/manifest.json @@ -11,12 +11,6 @@ ], "preview": "preview.gif", "tags": [ - "slow", - "medium", - "1:1", - "wide", - "shake", - "slide", - "zoom" + "cinematic" ] } diff --git a/packs/shake-slide/manifest.json b/packs/shake-slide/manifest.json index 2ac95af..95e70b5 100644 --- a/packs/shake-slide/manifest.json +++ b/packs/shake-slide/manifest.json @@ -11,14 +11,7 @@ ], "preview": "preview.gif", "tags": [ - "slow", - "medium", - "fast", - "9:16", - "4:5", - "1:1", - "shake", - "slide", - "zoom" + "anime", + "hype" ] } diff --git a/packs/snow/SKILL.md b/packs/snow/SKILL.md new file mode 100644 index 0000000..61a7771 --- /dev/null +++ b/packs/snow/SKILL.md @@ -0,0 +1,17 @@ +--- +name: edits-snow +description: "Lay the Snow 3D scene (three.js) over an edit with edits: soft snow of three sizes falling and swaying in 3D, after three.js's points-sprites example, looping. Use when the user wants snow, winter, falling flakes or a 3D overlay on a sad, cold or night edit." +--- + +# Snow + +Soft snow of three sizes falling and swaying in 3D, after three.js's points-sprites example. It loops every 8 seconds. + +```sh +edits --overlay snow +edits --overlay snow@2-6:0.8 # from 2 s to 6 s, at 80% +``` + +Its scene.js runs alone: in a browser of its own with no window, no files and nothing of the person's; only three.js +is loaded for it. A 3D scene pack of your own is one function in scene.js, `(THREE, scene, camera, opts) => (t) => {}` +(PACKS.md). diff --git a/packs/snow/manifest.json b/packs/snow/manifest.json new file mode 100644 index 0000000..eaba672 --- /dev/null +++ b/packs/snow/manifest.json @@ -0,0 +1,21 @@ +{ + "schemaVersion": 1, + "id": "edits.snow", + "name": "Snow", + "version": "1.0.0", + "author": "EditsMaker", + "description": "Soft snow of three sizes falling and swaying in 3D, after three.js's points-sprites example. Lay it over a sad or winter edit; it loops.", + "kinds": [ + "skill", + "scene" + ], + "preview": "preview.svg", + "tags": [ + "3d", + "sad" + ], + "scene": { + "seconds": 8.0, + "fps": 30 + } +} diff --git a/packs/snow/preview.svg b/packs/snow/preview.svg new file mode 100644 index 0000000..0abd356 --- /dev/null +++ b/packs/snow/preview.svg @@ -0,0 +1,9 @@ + + +3D scene +Snow +Soft snow of three sizes falling and swaying in 3D, after +three.js's points-sprites example. Lay it over a sad or winter +edit; it loops. +edits <link> --overlay snow + diff --git a/packs/snow/scene.js b/packs/snow/scene.js new file mode 100644 index 0000000..662921d --- /dev/null +++ b/packs/snow/scene.js @@ -0,0 +1,43 @@ +// Snow, after three.js's webgl_points_sprites example (MIT): soft flakes of three sizes falling and swaying; each +// falls one full height per loop, so the last frame meets the first. +(THREE, scene, camera, opts) => { + const seconds = 8, layers = [[500, 0.12], [350, 0.2], [150, 0.32]]; + let s = 11; + const rand = () => ((s = (s * 16807) % 2147483647) / 2147483647); + const c = document.createElement("canvas"); + c.width = c.height = 64; + const g = c.getContext("2d"); + const grad = g.createRadialGradient(32, 32, 0, 32, 32, 32); + grad.addColorStop(0, "rgba(255,255,255,1)"); + grad.addColorStop(0.5, "rgba(240,246,255,0.6)"); + grad.addColorStop(1, "rgba(240,246,255,0)"); + g.fillStyle = grad; + g.fillRect(0, 0, 64, 64); + const tex = new THREE.CanvasTexture(c); + const sets = layers.map(([count, size], li) => { + const base = new Float32Array(count * 3), seed = new Float32Array(count); + for (let i = 0; i < count; i++) { + base[i * 3] = (rand() - 0.5) * 10; + base[i * 3 + 1] = (rand() - 0.5) * 16; + base[i * 3 + 2] = -1 - rand() * 10; + seed[i] = rand(); + } + const geo = new THREE.BufferGeometry(); + geo.setAttribute("position", new THREE.BufferAttribute(base.slice(), 3)); + const mat = new THREE.PointsMaterial({ size, map: tex, transparent: true, depthWrite: false, opacity: 0.55 + li * 0.15 }); + scene.add(new THREE.Points(geo, mat)); + return { geo, base, seed, count, laps: li + 1 }; + }); + return (t) => { + const k = (t % seconds) / seconds; + for (const { geo, base, seed, count, laps } of sets) { + const a = geo.attributes.position.array; + for (let i = 0; i < count; i++) { + // nearer flakes fall faster: a whole number of laps per loop + a[i * 3 + 1] = ((base[i * 3 + 1] + 8 - k * 16 * laps) % 16 + 16) % 16 - 8; + a[i * 3] = base[i * 3] + Math.sin((k * laps + seed[i]) * Math.PI * 2) * 0.25; + } + geo.attributes.position.needsUpdate = true; + } + }; +} diff --git a/packs/spin/manifest.json b/packs/spin/manifest.json index 3424118..d741c4f 100644 --- a/packs/spin/manifest.json +++ b/packs/spin/manifest.json @@ -11,17 +11,6 @@ ], "preview": "preview.gif", "tags": [ - "slow", - "medium", - "fast", - "9:16", - "4:5", - "1:1", - "blur", - "shake", - "slide", - "spin", - "velocity", - "zoom" + "anime" ] } diff --git a/packs/stardust/manifest.json b/packs/stardust/manifest.json index 6140d9d..d03c041 100644 --- a/packs/stardust/manifest.json +++ b/packs/stardust/manifest.json @@ -12,9 +12,7 @@ "preview": "preview.gif", "tags": [ "3d", - "overlay", - "dreamy", - "loop" + "sad" ], "scene": { "seconds": 6.0, diff --git a/packs/tape/manifest.json b/packs/tape/manifest.json index c8f37bc..ef40d00 100644 --- a/packs/tape/manifest.json +++ b/packs/tape/manifest.json @@ -11,12 +11,7 @@ ], "preview": "preview.gif", "tags": [ - "slow", - "9:16", - "flash", "retro", - "rgb", - "shake", - "zoom" + "sad" ] } diff --git a/packs/velocity/manifest.json b/packs/velocity/manifest.json index fa8637f..4232d7c 100644 --- a/packs/velocity/manifest.json +++ b/packs/velocity/manifest.json @@ -11,17 +11,7 @@ ], "preview": "preview.gif", "tags": [ - "slow", - "medium", - "fast", - "9:16", - "1:1", - "blur", - "flash", - "rgb", - "shake", - "slide", - "velocity", - "zoom" + "anime", + "hype" ] } diff --git a/packs/warp/SKILL.md b/packs/warp/SKILL.md new file mode 100644 index 0000000..68ba728 --- /dev/null +++ b/packs/warp/SKILL.md @@ -0,0 +1,17 @@ +--- +name: edits-warp +description: "Lay the Warp 3D scene (three.js) over an edit with edits: stars streaking past at light speed, out from the middle of the frame, in 3D, looping. Use when the user wants warp, hyperspace, light speed, speed lines or a 3D overlay on the drop of a hype edit." +--- + +# Warp + +Stars streaking past at light speed, out from the middle of the frame, in 3D. It loops every 4 seconds. + +```sh +edits --overlay warp +edits --overlay warp@2-6:0.8 # from 2 s to 6 s, at 80% +``` + +Its scene.js runs alone: in a browser of its own with no window, no files and nothing of the person's; only three.js +is loaded for it. A 3D scene pack of your own is one function in scene.js, `(THREE, scene, camera, opts) => (t) => {}` +(PACKS.md). diff --git a/packs/warp/manifest.json b/packs/warp/manifest.json new file mode 100644 index 0000000..ca6586f --- /dev/null +++ b/packs/warp/manifest.json @@ -0,0 +1,21 @@ +{ + "schemaVersion": 1, + "id": "edits.warp", + "name": "Warp", + "version": "1.0.0", + "author": "EditsMaker", + "description": "Stars streaking past at light speed, out from the middle of the frame, in 3D. For the drop; it loops.", + "kinds": [ + "skill", + "scene" + ], + "preview": "preview.svg", + "tags": [ + "3d", + "hype" + ], + "scene": { + "seconds": 4.0, + "fps": 30 + } +} diff --git a/packs/warp/preview.svg b/packs/warp/preview.svg new file mode 100644 index 0000000..7a479f0 --- /dev/null +++ b/packs/warp/preview.svg @@ -0,0 +1,8 @@ + + +3D scene +Warp +Stars streaking past at light speed, out from the middle of +the frame, in 3D. For the drop; it loops. +edits <link> --overlay warp + diff --git a/packs/warp/scene.js b/packs/warp/scene.js new file mode 100644 index 0000000..bb23926 --- /dev/null +++ b/packs/warp/scene.js @@ -0,0 +1,28 @@ +// Warp: stars streaking past as at light speed, out from the middle of the frame; each star makes whole laps of the +// depth per loop, so it loops. +(THREE, scene, camera, opts) => { + const count = 600, seconds = 4, depth = 40; + let s = 3; + const rand = () => ((s = (s * 16807) % 2147483647) / 2147483647); + const stars = []; + const pos = new Float32Array(count * 6); + for (let i = 0; i < count; i++) { + const a = rand() * Math.PI * 2, r = 0.4 + rand() * 6; + stars.push({ x: Math.cos(a) * r, y: Math.sin(a) * r * 1.6, z: rand() * depth, laps: 1 + Math.floor(rand() * 2) }); + } + const geo = new THREE.BufferGeometry(); + geo.setAttribute("position", new THREE.BufferAttribute(pos, 3)); + const mat = new THREE.LineBasicMaterial({ color: 0xdfe8ff, transparent: true, opacity: 0.8, blending: THREE.AdditiveBlending }); + scene.add(new THREE.LineSegments(geo, mat)); + return (t) => { + const k = (t % seconds) / seconds; + for (let i = 0; i < count; i++) { + const st = stars[i]; + const z = -((st.z + k * depth * st.laps) % depth) - 1; + // a streak: longer the nearer it is + const len = Math.min(4, 30 / -z); + pos.set([st.x, st.y, z, st.x, st.y, Math.min(z + len, -0.5)], i * 6); + } + geo.attributes.position.needsUpdate = true; + }; +} diff --git a/packs/world/SKILL.md b/packs/world/SKILL.md new file mode 100644 index 0000000..616808f --- /dev/null +++ b/packs/world/SKILL.md @@ -0,0 +1,46 @@ +--- +name: edits-world +description: "Make short videos from news from a country with edits: 25 topics (australia, bangladesh, brazil, canada, france, germany, hong-kong, india, indonesia, iran, ireland, italy and more), each new story's headline cut from footage found for it and shown on screen. Use when the user wants videos from news from a country, posts on autopilot, or an automation from RSS to video to social media." +--- + +# World + +Every country reads its own newspapers; each new story becomes an edit. + +```sh +edits rss japan --list # the newest posts (--json for programs) +edits rss japan -n 3 # a video for each of the 3 newest +edits rss brazil --feed all -n 5 --preset sinema-bant +edits follow japan --post tiktok --every 30 # RSS in, video made, posted out (edits watch runs it) +``` + +Topics: + +- `australia`: Australia, 16 feeds (Latest News and News Headlines | Daily Telegraph, Sydney Morning Herald - Latest News, Latest News and News Headlines | Herald Sun) +- `bangladesh`: Bangladesh, 8 feeds (The Daily Star, BD24Live.com, bdnews24.com - Home) +- `brazil`: Brazil, 7 feeds (Folha de S.Paulo - Em cima da hora - Principal, Portal EBC - RSS, R7 - Notícias) +- `canada`: Canada, 9 feeds (CBC | Top Stories News, CTVNews.ca - Top Stories - Public RSS, Financial Post) +- `france`: France, 11 feeds (france24.com, Mediapart, Paris Star) +- `germany`: Germany, 5 feeds (ZEIT ONLINE | Nachrichten, Hintergründe und Debatten, FOCUS Online, Aktuell - FAZ.NET) +- `hong-kong`: Hong Kong, 5 feeds (Hong Kong Free Press HKFP, The Standard - Latest News, 頭條日報 Headline Daily - 頭條網) +- `india`: India, 36 feeds (BBC News - India, India | The Guardian, SEBI RSS Feed) +- `indonesia`: Indonesia, 4 feeds (Republika Online RSS Feed, Tribunnews.com, Merdeka.com) +- `iran`: Iran, 7 feeds (خبرگزاری باشگاه خبرنگاران | آخرین اخبار ایران و جهان | YJC, تابناک | TABNAK, خبرگزاری ایسنا | صفحه اصلی | ISNA News Agency) +- `ireland`: Ireland, 6 feeds (TheJournal.ie, All: BreakingNews.ie, The42) +- `italy`: Italy, 13 feeds (RSS di - ANSA.it, The Local, RSS DiariodelWeb.it) +- `japan`: Japan, 8 feeds (Japan Times latest articles, Japan Today, News On Japan) +- `mexico`: Mexico, 14 feeds (Mexico | The Guardian, Excélsior - RSS, Reforma) +- `myanmar`: Myanmar, 3 feeds (Myanmar Gazette News Media Forum Network, DVB Multimedia Group, THIT HTOO LWIN (Daily News)) +- `nigeria`: Nigeria, 10 feeds (All Content, Nigeria News Links | Today's Updates - Nigerian Bulletin, Nigerian News. Latest Nigeria News. Your online Nigerian Newspaper.) +- `pakistan`: Pakistan, 7 feeds (The Express Tribune, The Nation - Top Stories, قومی خبریں) +- `philippines`: Philippines, 20 feeds (INQUIRER.net, Latest News | Philippine Information Agency, Interaksyon) +- `poland`: Poland, 8 feeds (Najnowsze, Newsweek Polska, Dziennik.pl Dziennik - dziennik.pl) +- `russia`: Russia, 13 feeds (Lenta.ru : Новости, Вести.Ru, Газета.Ru - Первая полоса) +- `south-africa`: South Africa, 11 feeds (SowetanLIVE, TechCentral, News24 Top Stories) +- `spain`: Spain, 9 feeds (The Local, EL PAÍS: el periódico global, España) +- `ukraine`: Ukraine, 12 feeds (News Agency UNIAN, ТЕЛЕГРАФ - последние новости Украины и мира, Последние новости на сайте korrespondent.net) +- `united-kingdom`: United Kingdom, 5 feeds (BBC News - Home, World news | The Guardian, Home | Mail Online) +- `united-states`: United States, 10 feeds (World News - Breaking News, Top Stories, NYT > Top Stories, FOX News) + +Each video is footage found for the headline, with the headline on screen for its first seconds. Check a headline +before posting it, and say whose post it was. The feeds come from awesome-rss-feeds (CC0). diff --git a/packs/world/manifest.json b/packs/world/manifest.json new file mode 100644 index 0000000..7dbc138 --- /dev/null +++ b/packs/world/manifest.json @@ -0,0 +1,1197 @@ +{ + "schemaVersion": 1, + "id": "edits.world", + "name": "World", + "version": "1.0.0", + "author": "EditsMaker", + "description": "25 countries, from Japan to Brazil, each read from its own newspapers. Every new story becomes an edit; a flow can post it for you.", + "kinds": [ + "skill", + "feed" + ], + "preview": "preview.svg", + "tags": [ + "news", + "automation" + ], + "topics": [ + { + "key": "australia", + "name": "Australia", + "feeds": [ + { + "name": "Latest News and News Headlines | Daily Telegraph", + "url": "https://www.dailytelegraph.com.au/news/breaking-news/rss" + }, + { + "name": "Sydney Morning Herald - Latest News", + "url": "https://www.smh.com.au/rss/feed.xml" + }, + { + "name": "Latest News and News Headlines | Herald Sun", + "url": "https://www.heraldsun.com.au/news/breaking-news/rss" + }, + { + "name": "ABC News", + "url": "https://www.abc.net.au/news/feed/1948/rss.xml" + }, + { + "name": "The Age - Latest News", + "url": "https://www.theage.com.au/rss/feed.xml" + }, + { + "name": "The Courier Mail", + "url": "https://www.couriermail.com.au/rss" + }, + { + "name": "PerthNow", + "url": "https://www.perthnow.com.au/news/feed" + }, + { + "name": "The Canberra Times - Local News", + "url": "https://www.canberratimes.com.au/rss.xml" + }, + { + "name": "Brisbane Times - Latest News", + "url": "https://www.brisbanetimes.com.au/rss/feed.xml" + }, + { + "name": "Independent Australia", + "url": "http://feeds.feedburner.com/IndependentAustralia" + }, + { + "name": "Business News - Latest Headlines", + "url": "https://www.businessnews.com.au/rssfeed/latest.rss" + }, + { + "name": "InDaily", + "url": "https://indaily.com.au/feed/" + }, + { + "name": "The Mercury", + "url": "https://www.themercury.com.au/rss" + }, + { + "name": "Crikey", + "url": "https://feeds.feedburner.com/com/rCTl" + }, + { + "name": "KUSA - News", + "url": "http://rssfeeds.9news.com/kusa/home&x=1" + }, + { + "name": "Michael West", + "url": "https://www.michaelwest.com.au/feed/" + } + ] + }, + { + "key": "bangladesh", + "name": "Bangladesh", + "feeds": [ + { + "name": "The Daily Star", + "url": "https://www.thedailystar.net/frontpage/rss.xml" + }, + { + "name": "BD24Live.com", + "url": "https://www.bd24live.com/feed" + }, + { + "name": "bdnews24.com - Home", + "url": "https://bdnews24.com/?widgetName=rssfeed&widgetId=1150&getXmlFeed=true" + }, + { + "name": "Bangla News", + "url": "https://www.banglanews24.com/rss/rss.xml" + }, + { + "name": "JUGANTOR", + "url": "https://www.jugantor.com/feed/rss.xml" + }, + { + "name": "jagonews24.com | rss Feed", + "url": "https://www.jagonews24.com/rss/rss.xml" + }, + { + "name": "kalerkantho Kantho", + "url": "https://www.kalerkantho.com/rss.xml" + }, + { + "name": "প্রথম আলো", + "url": "https://www.prothomalo.com/feed/" + } + ] + }, + { + "key": "brazil", + "name": "Brazil", + "feeds": [ + { + "name": "Folha de S.Paulo - Em cima da hora - Principal", + "url": "https://feeds.folha.uol.com.br/emcimadahora/rss091.xml" + }, + { + "name": "Portal EBC - RSS", + "url": "http://www.ebc.com.br/rss/feed.xml" + }, + { + "name": "R7 - Notícias", + "url": "https://noticias.r7.com/feed.xml" + }, + { + "name": "UOL", + "url": "http://rss.home.uol.com.br/index.xml" + }, + { + "name": "The Rio Times", + "url": "https://riotimesonline.com/feed/" + }, + { + "name": "Brasil Wire", + "url": "http://www.brasilwire.com/feed/" + }, + { + "name": "Jornal de Brasília", + "url": "https://jornaldebrasilia.com.br/feed/" + } + ] + }, + { + "key": "canada", + "name": "Canada", + "feeds": [ + { + "name": "CBC | Top Stories News", + "url": "https://www.cbc.ca/cmlink/rss-topstories" + }, + { + "name": "CTVNews.ca - Top Stories - Public RSS", + "url": "https://www.ctvnews.ca/rss/ctvnews-ca-top-stories-public-rss-1.822009" + }, + { + "name": "Financial Post", + "url": "https://business.financialpost.com/feed/" + }, + { + "name": "National Post", + "url": "https://nationalpost.com/feed/" + }, + { + "name": "Ottawa Citizen", + "url": "https://ottawacitizen.com/feed/" + }, + { + "name": "The Province", + "url": "https://theprovince.com/feed/" + }, + { + "name": "LaPresse.ca - Actualités", + "url": "https://www.lapresse.ca/actualites/rss" + }, + { + "name": "Toronto Star", + "url": "https://www.thestar.com/content/thestar/feed.RSSManagerServlet.articles.topstories.rss" + }, + { + "name": "Toronto Sun - RSS Feed", + "url": "https://torontosun.com/category/news/feed" + } + ] + }, + { + "key": "france", + "name": "France", + "feeds": [ + { + "name": "france24.com", + "url": "https://www.france24.com/en/rss" + }, + { + "name": "Mediapart", + "url": "https://www.mediapart.fr/articles/feed" + }, + { + "name": "Paris Star", + "url": "https://www.parisstaronline.com/feed" + }, + { + "name": "Le Monde.fr - Actualités et Infos en France et dans le monde", + "url": "https://www.lemonde.fr/rss/une.xml" + }, + { + "name": "L'Obs - A la une", + "url": "https://www.nouvelobs.com/a-la-une/rss.xml" + }, + { + "name": "Franceinfo - Les Titres", + "url": "https://www.francetvinfo.fr/titres.rss" + }, + { + "name": "Le Huffington Post", + "url": "https://www.huffingtonpost.fr/feeds/index.xml" + }, + { + "name": "La Dépêche du Midi : actualités et info en direct de la région Occitanie et des environs - ladepeche.fr", + "url": "https://www.ladepeche.fr/rss.xml" + }, + { + "name": "Ministry for Europe and Foreign Affairs - Actualités", + "url": "https://www.diplomatie.gouv.fr/spip.php?page=backend-fd&lang=en" + }, + { + "name": "L'essentiel", + "url": "https://www.sudouest.fr/essentiel/rss.xml" + }, + { + "name": "Ouest-France - Actualité", + "url": "https://www.ouest-france.fr/rss-en-continu.xml" + } + ] + }, + { + "key": "germany", + "name": "Germany", + "feeds": [ + { + "name": "ZEIT ONLINE | Nachrichten, Hintergründe und Debatten", + "url": "http://newsfeed.zeit.de/index" + }, + { + "name": "FOCUS Online", + "url": "https://rss.focus.de/fol/XML/rss_folnews.xml" + }, + { + "name": "Aktuell - FAZ.NET", + "url": "https://www.faz.net/rss/aktuell/" + }, + { + "name": "tagesschau.de - Die Nachrichten der ARD", + "url": "http://www.tagesschau.de/xml/rss2" + }, + { + "name": "Deutsche Welle", + "url": "https://rss.dw.com/rdf/rss-en-all" + } + ] + }, + { + "key": "hong-kong", + "name": "Hong Kong", + "feeds": [ + { + "name": "Hong Kong Free Press HKFP", + "url": "https://www.hongkongfp.com/feed/" + }, + { + "name": "The Standard - Latest News", + "url": "https://www.thestandard.com.hk/newsfeed/latest/news.xml" + }, + { + "name": "頭條日報 Headline Daily - 頭條網", + "url": "https://hd.stheadline.com/rss/news/daily/" + }, + { + "name": "香港新聞RSS - 香港經濟日報 hket.com", + "url": "https://www.hket.com/rss/hongkong" + }, + { + "name": "hongkongnews.net latest rss headlines", + "url": "http://feeds.hongkongnews.net/rss/b82693edf38ebff8" + } + ] + }, + { + "key": "india", + "name": "India", + "feeds": [ + { + "name": "BBC News - India", + "url": "http://feeds.bbci.co.uk/news/world/asia/india/rss.xml" + }, + { + "name": "India | The Guardian", + "url": "https://www.theguardian.com/world/india/rss" + }, + { + "name": "SEBI RSS Feed", + "url": "https://www.sebi.gov.in/sebirss.xml" + }, + { + "name": "Times of India", + "url": "https://timesofindia.indiatimes.com/rssfeedstopstories.cms" + }, + { + "name": "The Hindu - Home", + "url": "https://www.thehindu.com/feeder/default.rss" + }, + { + "name": "NDTV News - Topstories", + "url": "https://feeds.feedburner.com/ndtvnews-top-stories" + }, + { + "name": "India Today | Latest Stories", + "url": "https://www.indiatoday.in/rss/home" + }, + { + "name": "Front Page | The Indian Express", + "url": "http://indianexpress.com/print/front-page/feed/" + }, + { + "name": "Top World News- News18.com", + "url": "https://www.news18.com/rss/world.xml" + }, + { + "name": "India News", + "url": "https://www.dnaindia.com/feeds/india.xml" + }, + { + "name": "Firstpost India Latest News", + "url": "https://www.firstpost.com/rss/india.xml" + }, + { + "name": "Home Page", + "url": "https://www.business-standard.com/rss/home_page_top_stories.rss" + }, + { + "name": "Outlook India", + "url": "https://www.outlookindia.com/rss/main/magazine" + }, + { + "name": "Free Press Journal", + "url": "https://www.freepressjournal.in/stories.rss" + }, + { + "name": "Deccan Chronicle - Latest India news | Breaking news | Hyderabad News | World news | Business news | Politics | Technology news", + "url": "https://www.deccanchronicle.com/rss_feed/" + }, + { + "name": "Moneycontrol Latest News", + "url": "http://www.moneycontrol.com/rss/latestnews.xml" + }, + { + "name": "Economic Times", + "url": "https://economictimes.indiatimes.com/rssfeedsdefault.cms" + }, + { + "name": "News, Latest News, Today's News Headlines, Breaking News, LIVE News - Oneindia", + "url": "https://www.oneindia.com/rss/news-fb.xml" + }, + { + "name": "Scroll.in", + "url": "http://feeds.feedburner.com/ScrollinArticles.rss" + }, + { + "name": "The Financial Express", + "url": "https://www.financialexpress.com/feed/" + }, + { + "name": "Business Line - Home", + "url": "https://www.thehindubusinessline.com/feeder/default.rss" + }, + { + "name": "TechGenyz", + "url": "http://feeds.feedburner.com/techgenyz" + }, + { + "name": "Top Stories News - Gujarat Samachar : World's Leading Gujarati Newspaper", + "url": "https://www.gujaratsamachar.com/rss/top-stories" + }, + { + "name": "Marathi News: मराठी बातम्या, Latest News in Marathi, Breaking Marathi News, Marathi News Paper | Maharashtra Times", + "url": "https://maharashtratimes.com/rssfeedsdefault.cms" + }, + { + "name": "Loksattaदेश-विदेश – Loksatta", + "url": "https://www.loksatta.com/desh-videsh/feed/" + }, + { + "name": "Latest News program News18 Lokmat", + "url": "https://lokmat.news18.com/rss/program.xml" + }, + { + "name": "OpIndia", + "url": "https://feeds.feedburner.com/opindia" + }, + { + "name": "ThePrint", + "url": "https://theprint.in/feed/" + }, + { + "name": "Swarajya", + "url": "https://prod-qt-images.s3.amazonaws.com/production/swarajya/feed.xml" + }, + { + "name": "Latest And Breaking Hindi News Headlines, News In Hindi | अमर उजाला हिंदी न्यूज़ | - Amar Ujala", + "url": "https://www.amarujala.com/rss/breaking-news.xml" + }, + { + "name": "Navbharat Times", + "url": "https://navbharattimes.indiatimes.com/rssfeedsdefault.cms" + }, + { + "name": "Patrika : India's Leading Hindi News Portal", + "url": "http://api.patrika.com/rss/india-news" + }, + { + "name": "JansattaJansatta", + "url": "https://www.jansatta.com/feed/" + }, + { + "name": "Live Hindustan Rss feed", + "url": "https://feed.livehindustan.com/rss/3127" + }, + { + "name": "देश | दैनिक भास्कर", + "url": "https://www.bhaskar.com/rss-feed/1061/" + }, + { + "name": "ઈન્ડિયા | દિવ્ય ભાસ્કર", + "url": "https://www.divyabhaskar.co.in/rss-feed/1037/" + } + ] + }, + { + "key": "indonesia", + "name": "Indonesia", + "feeds": [ + { + "name": "Republika Online RSS Feed", + "url": "https://www.republika.co.id/rss/" + }, + { + "name": "Tribunnews.com", + "url": "https://www.tribunnews.com/rss" + }, + { + "name": "Merdeka.com", + "url": "https://www.merdeka.com/feed/" + }, + { + "name": "Suara.com", + "url": "https://www.suara.com/rss" + } + ] + }, + { + "key": "iran", + "name": "Iran", + "feeds": [ + { + "name": "خبرگزاری باشگاه خبرنگاران | آخرین اخبار ایران و جهان | YJC", + "url": "https://www.yjc.ir/fa/rss/allnews" + }, + { + "name": "تابناک | TABNAK", + "url": "https://www.tabnak.ir/fa/rss/allnews" + }, + { + "name": "خبرگزاری ایسنا | صفحه اصلی | ISNA News Agency", + "url": "https://www.isna.ir/rss" + }, + { + "name": "خبرگزاری مهر | اخبار ایران و جهان | Mehr News Agency", + "url": "https://www.mehrnews.com/rss" + }, + { + "name": "خبرگزاری خبرآنلاین - آخرین اخبار ایران و جهان | Khabaronline", + "url": "https://www.khabaronline.ir/rss" + }, + { + "name": "اخبار ایران و جهان", + "url": "https://www.tasnimnews.com/fa/rss/feed/0/8/0/%D9%85%D9%87%D9%85%D8%AA%D8%B1%DB%8C%D9%86-%D8%A7%D8%AE%D8%A8%D8%A7%D8%B1-%D8%AA%D8%B3%D9%86%DB%8C%D9%85" + }, + { + "name": "عصر ايران", + "url": "https://www.asriran.com/fa/rss/allnews" + } + ] + }, + { + "key": "ireland", + "name": "Ireland", + "feeds": [ + { + "name": "TheJournal.ie", + "url": "https://www.thejournal.ie/feed/" + }, + { + "name": "All: BreakingNews.ie", + "url": "https://feeds.breakingnews.ie/bntopstories" + }, + { + "name": "The42", + "url": "https://www.the42.ie/feed/" + }, + { + "name": "IrishExaminer.com", + "url": "https://feeds.feedburner.com/ietopstories" + }, + { + "name": "IrishCentral.com - Top Stories", + "url": "https://feeds.feedburner.com/IrishCentral" + }, + { + "name": "Irish Mirror - Home", + "url": "https://www.irishmirror.ie/?service=rss" + } + ] + }, + { + "key": "italy", + "name": "Italy", + "feeds": [ + { + "name": "RSS di - ANSA.it", + "url": "https://www.ansa.it/sito/ansait_rss.xml" + }, + { + "name": "The Local", + "url": "https://feeds.thelocal.com/rss/it" + }, + { + "name": "RSS DiariodelWeb.it", + "url": "https://www.diariodelweb.it/rss/home/" + }, + { + "name": "Fanpage", + "url": "https://www.fanpage.it/feed/" + }, + { + "name": "Libero Quotidiano", + "url": "https://www.liberoquotidiano.it/rss.xml" + }, + { + "name": "Il Mattino Web", + "url": "https://www.ilmattino.it/?sez=XML&args&p=search&args[box]=Home&limit=20&layout=rss" + }, + { + "name": "Adnkronos - ultimoratop", + "url": "http://rss.adnkronos.com/RSS_PrimaPagina.xml" + }, + { + "name": "Milan News", + "url": "https://www.milannews.it/rss/" + }, + { + "name": "Internazionale", + "url": "https://www.internazionale.it/sitemaps/rss.xml" + }, + { + "name": "Panorama", + "url": "https://www.panorama.it/feeds/feed.rss" + }, + { + "name": "Italy | The Guardian", + "url": "https://www.theguardian.com/world/italy/rss" + }, + { + "name": "Repubblica.it > Homepage", + "url": "https://www.repubblica.it/rss/homepage/rss2.0.xml" + }, + { + "name": "Il Post", + "url": "https://www.ilpost.it/feed/" + } + ] + }, + { + "key": "japan", + "name": "Japan", + "feeds": [ + { + "name": "Japan Times latest articles", + "url": "https://www.japantimes.co.jp/feed/topstories/" + }, + { + "name": "Japan Today", + "url": "https://japantoday.com/feed" + }, + { + "name": "News On Japan", + "url": "http://www.newsonjapan.com/rss/top.xml" + }, + { + "name": "All - Kyodo News+", + "url": "https://english.kyodonews.net/rss/all.xml" + }, + { + "name": "BRIDGE(ブリッジ)テクノロジー&スタートアップ情報", + "url": "http://feeds.feedburner.com/SdJapan" + }, + { + "name": "NYT > Japan", + "url": "https://www.nytimes.com/svc/collections/v1/publish/http://www.nytimes.com/topic/destination/japan/rss.xml" + }, + { + "name": "ライブドアニュース - 主要トピックス", + "url": "https://news.livedoor.com/topics/rss/top.xml" + }, + { + "name": "朝日新聞デジタル", + "url": "http://rss.asahi.com/rss/asahi/newsheadlines.rdf" + } + ] + }, + { + "key": "mexico", + "name": "Mexico", + "feeds": [ + { + "name": "Mexico | The Guardian", + "url": "https://www.theguardian.com/world/mexico/rss" + }, + { + "name": "Excélsior - RSS", + "url": "https://www.excelsior.com.mx/rss.xml" + }, + { + "name": "Reforma", + "url": "https://www.reforma.com/rss/portada.xml" + }, + { + "name": "Lo último en Vanguardia MX", + "url": "https://vanguardia.com.mx/rss.xml" + }, + { + "name": "Portada, El Siglo de Torreón", + "url": "https://www.elsiglodetorreon.com.mx/index.xml" + }, + { + "name": "El Financiero", + "url": "https://www.elfinanciero.com.mx/arc/outboundfeeds/rss/?outputType=xml" + }, + { + "name": "ElNorte", + "url": "https://www.elnorte.com/rss/portada.xml" + }, + { + "name": "El Informador :: Noticias de Jalisco, México, Deportes & Entretenimiento", + "url": "https://www.informador.mx/rss/ultimas-noticias.xml" + }, + { + "name": "24 Horas", + "url": "https://www.24-horas.mx/feed/" + }, + { + "name": "Tu Periódico Quequi", + "url": "https://quequi.com.mx/feed/" + }, + { + "name": "DEBATE", + "url": "https://www.debate.com.mx/rss/feed.xml" + }, + { + "name": "Mexico News Daily", + "url": "https://mexiconewsdaily.com/feed/" + }, + { + "name": "El Diario", + "url": "https://diario.mx/jrz/media/sitemaps/rss.xml" + }, + { + "name": "8 Columnas", + "url": "https://8columnas.com.mx/feed/" + } + ] + }, + { + "key": "myanmar", + "name": "Myanmar", + "feeds": [ + { + "name": "Myanmar Gazette News Media Forum Network", + "url": "http://myanmargazette.net/feed" + }, + { + "name": "DVB Multimedia Group", + "url": "http://www.dvb.no/feed" + }, + { + "name": "THIT HTOO LWIN (Daily News)", + "url": "http://www.thithtoolwin.com/feeds/posts/default" + } + ] + }, + { + "key": "nigeria", + "name": "Nigeria", + "feeds": [ + { + "name": "All Content", + "url": "http://saharareporters.com/feeds/latest/feed" + }, + { + "name": "Nigeria News Links | Today's Updates - Nigerian Bulletin", + "url": "https://www.nigerianbulletin.com/forums/-/index.rss" + }, + { + "name": "Nigerian News. Latest Nigeria News. Your online Nigerian Newspaper.", + "url": "http://feeds.feedburner.com/Nigerianeye" + }, + { + "name": "Legit.ng", + "url": "https://www.legit.ng/rss/all.rss" + }, + { + "name": "Latest Nigeria News, Nigerian Newspapers, Politics", + "url": "https://thenationonlineng.net/feed/" + }, + { + "name": "Daily Post Nigeria", + "url": "https://dailypost.ng/feed" + }, + { + "name": "Premium Times Nigeria", + "url": "https://www.premiumtimesng.com/feed" + }, + { + "name": "Information Nigeria", + "url": "https://www.informationng.com/feed" + }, + { + "name": "The Guardian Nigeria News – Nigeria and World News", + "url": "https://guardian.ng/feed/" + }, + { + "name": "Tribune Online", + "url": "http://tribuneonlineng.com/feed/" + } + ] + }, + { + "key": "pakistan", + "name": "Pakistan", + "feeds": [ + { + "name": "The Express Tribune", + "url": "https://tribune.com.pk/feed/home" + }, + { + "name": "The Nation - Top Stories", + "url": "https://nation.com.pk/rss/top-stories" + }, + { + "name": "قومی خبریں", + "url": "https://jang.com.pk/rss/1/1" + }, + { + "name": "The News International - Pakistan", + "url": "https://www.thenews.com.pk/rss/1/1" + }, + { + "name": "News Blog", + "url": "https://newsnblogs.com/feed/" + }, + { + "name": "UrduPoint.com All Urdu News", + "url": "https://www.urdupoint.com/rss/urdupoint.rss" + }, + { + "name": "ایکسپریس اردو", + "url": "https://www.express.pk/feed/" + } + ] + }, + { + "key": "philippines", + "name": "Philippines", + "feeds": [ + { + "name": "INQUIRER.net", + "url": "https://www.inquirer.net/fullfeed" + }, + { + "name": "Latest News | Philippine Information Agency", + "url": "https://pia.gov.ph/news/feed.rss" + }, + { + "name": "Interaksyon", + "url": "https://www.interaksyon.com/feed/" + }, + { + "name": "- The Manila Times", + "url": "https://www.manilatimes.net/rssfeed/" + }, + { + "name": "philstar.com - RSS Headlines", + "url": "https://www.philstar.com/rss/headlines" + }, + { + "name": "BusinessWorld", + "url": "https://www.bworldonline.com/feed/" + }, + { + "name": "https://www.sunstar.com.ph/", + "url": "https://www.sunstar.com.ph/rssFeed/selected" + }, + { + "name": "PhilNews.XYZ", + "url": "https://www.philnews.xyz/feeds/posts/default?alt=rss" + }, + { + "name": "Manila Standard", + "url": "https://manilastandard.net/feed/all" + }, + { + "name": "GMA News Online / News", + "url": "https://data.gmanews.tv/gno/rss/news/feed.xml" + }, + { + "name": "Current PH", + "url": "https://currentph.com/feed/" + }, + { + "name": "Top Gear: The Philippine authority on cars and the automotive industry", + "url": "https://www.topgear.com.ph/feed/rss1" + }, + { + "name": "Eagle News", + "url": "https://www.eaglenews.ph/feed/" + }, + { + "name": "UNBOX PH", + "url": "https://www.unbox.ph/feed/" + }, + { + "name": "Tempo – The Nation's Fastest Growing Newspaper", + "url": "http://tempo.com.ph/feed/" + }, + { + "name": "Abante Tonite", + "url": "https://tonite.abante.com.ph/feed/" + }, + { + "name": "BusinessMirror", + "url": "https://businessmirror.com.ph/feed/" + }, + { + "name": "Latest News | Philippine News Agency", + "url": "https://www.pna.gov.ph/latest.rss" + }, + { + "name": "TechPinas : Philippines' Technology News, Tips and Reviews Blog", + "url": "http://feeds.feedburner.com/Techpinas" + }, + { + "name": "BICOL STANDARD | Bicol News | Bicol Newspaper", + "url": "http://www.bicolstandard.com/feeds/posts/default?alt=rss" + } + ] + }, + { + "key": "poland", + "name": "Poland", + "feeds": [ + { + "name": "Najnowsze", + "url": "http://feeds.feedburner.com/wPolitycepl" + }, + { + "name": "Newsweek Polska", + "url": "https://www.newsweek.pl/rss.xml" + }, + { + "name": "Dziennik.pl Dziennik - dziennik.pl", + "url": "http://rss.dziennik.pl/Dziennik-PL/" + }, + { + "name": "www.wirtualnemedia.pl", + "url": "https://www.wirtualnemedia.pl/rss/wirtualnemedia_rss.xml" + }, + { + "name": "GazetaPrawna.pl - biznes, podatki, prawo, finanse, wiadomości, praca", + "url": "http://rss.gazetaprawna.pl/GazetaPrawna" + }, + { + "name": "https://www.rp.pl", + "url": "https://www.rp.pl/rss/1019" + }, + { + "name": "Polska Agencja Prasowa SA", + "url": "https://www.pap.pl/rss.xml" + }, + { + "name": "RMF24.pl", + "url": "https://www.rmf24.pl/feed" + } + ] + }, + { + "key": "russia", + "name": "Russia", + "feeds": [ + { + "name": "Lenta.ru : Новости", + "url": "https://lenta.ru/rss" + }, + { + "name": "Вести.Ru", + "url": "https://www.vesti.ru/vesti.rss" + }, + { + "name": "Газета.Ru - Первая полоса", + "url": "https://www.gazeta.ru/export/rss/first.xml" + }, + { + "name": "Все материалы - Московский Комсомолец", + "url": "https://www.mk.ru/rss/index.xml" + }, + { + "name": "Российская Газета", + "url": "https://rg.ru/xml/index.xml" + }, + { + "name": "NEWSru.com :: Главные новости", + "url": "https://rss.newsru.com/top/big/" + }, + { + "name": "RT - Daily news", + "url": "https://www.rt.com/rss/" + }, + { + "name": "Meduza.io", + "url": "https://meduza.io/rss/all" + }, + { + "name": "Russia Insider Daily Headlines", + "url": "https://russia-insider.com/en/all-content/rss" + }, + { + "name": "TASS", + "url": "http://tass.com/rss/v2.xml" + }, + { + "name": "The Moscow Times - Independent News From Russia", + "url": "https://www.themoscowtimes.com/rss/news" + }, + { + "name": "Газета", + "url": "https://www.kommersant.ru/RSS/main.xml" + }, + { + "name": "PravdaReport", + "url": "https://www.pravdareport.com/export.xml" + } + ] + }, + { + "key": "south-africa", + "name": "South Africa", + "feeds": [ + { + "name": "SowetanLIVE", + "url": "https://www.sowetanlive.co.za/rss/?publication=sowetan-live" + }, + { + "name": "TechCentral", + "url": "https://techcentral.co.za/feed" + }, + { + "name": "News24 Top Stories", + "url": "http://feeds.news24.com/articles/news24/TopStories/rss" + }, + { + "name": "Eyewitness News | Latest News", + "url": "https://ewn.co.za/RSS%20Feeds/Latest%20News" + }, + { + "name": "The Citizen", + "url": "https://citizen.co.za/feed/" + }, + { + "name": "Daily Maverick", + "url": "https://www.dailymaverick.co.za/dmrss/" + }, + { + "name": "Moneyweb", + "url": "https://www.moneyweb.co.za/feed/" + }, + { + "name": "IOL section feed for News", + "url": "http://rss.iol.io/iol/news" + }, + { + "name": "TimesLIVE", + "url": "https://www.timeslive.co.za/rss/" + }, + { + "name": "The South African", + "url": "https://www.thesouthafrican.com/feed/" + }, + { + "name": "Axios", + "url": "https://api.axios.com/feed/" + } + ] + }, + { + "key": "spain", + "name": "Spain", + "feeds": [ + { + "name": "The Local", + "url": "https://feeds.thelocal.com/rss/es" + }, + { + "name": "EL PAÍS: el periódico global", + "url": "https://feeds.elpais.com/mrss-s/pages/ep/site/elpais.com/portada" + }, + { + "name": "España", + "url": "https://rss.elconfidencial.com/espana/" + }, + { + "name": "ElDiario.es - ElDiario.es", + "url": "https://www.eldiario.es/rss/" + }, + { + "name": "Portada // expansion", + "url": "https://e00-expansion.uecdn.es/rss/portada.xml" + }, + { + "name": "El Periódico - portada", + "url": "https://www.elperiodico.com/es/rss/rss_portada.xml" + }, + { + "name": "huffingtonpost.es", + "url": "https://www.huffingtonpost.es/feeds/index.xml" + }, + { + "name": "Euro Weekly News Spain", + "url": "https://www.euroweeklynews.com/feed/" + }, + { + "name": "Agencia EFE | www.efe.com | English edition", + "url": "https://www.efe.com/efe/english/4/rss" + } + ] + }, + { + "key": "ukraine", + "name": "Ukraine", + "feeds": [ + { + "name": "News Agency UNIAN", + "url": "https://rss.unian.net/site/news_eng.rss" + }, + { + "name": "ТЕЛЕГРАФ - последние новости Украины и мира", + "url": "https://telegraf.com.ua/yandex-feed/" + }, + { + "name": "Последние новости на сайте korrespondent.net", + "url": "http://k.img.com.ua/rss/ru/all_news2.0.xml" + }, + { + "name": "Цензор.НЕТ - Новости", + "url": "https://censor.net.ua/includes/news_ru.xml" + }, + { + "name": "Новини на tsn.ua", + "url": "https://tsn.ua/rss/full.rss" + }, + { + "name": "Українська правда", + "url": "https://www.pravda.com.ua/rss/" + }, + { + "name": "Гордон - Самые популярные материалы", + "url": "https://gordonua.com/xml/rss_category/top.html" + }, + { + "name": "НВ", + "url": "https://nv.ua/rss/all.xml" + }, + { + "name": "Информационное агентство УНИАН", + "url": "https://rss.unian.net/site/news_rus.rss" + }, + { + "name": "Еспресо - український погляд на світ!", + "url": "https://espreso.tv/rss" + }, + { + "name": "Gazeta.ua", + "url": "https://gazeta.ua/rss" + }, + { + "name": "Вести.ua", + "url": "https://vesti.ua/feeds/partners" + } + ] + }, + { + "key": "united-kingdom", + "name": "United Kingdom", + "feeds": [ + { + "name": "BBC News - Home", + "url": "http://feeds.bbci.co.uk/news/rss.xml" + }, + { + "name": "World news | The Guardian", + "url": "https://www.theguardian.com/world/rss" + }, + { + "name": "Home | Mail Online", + "url": "https://www.dailymail.co.uk/home/index.rss" + }, + { + "name": "The Independent", + "url": "http://www.independent.co.uk/news/uk/rss" + }, + { + "name": "Daily Express :: News Feed", + "url": "http://feeds.feedburner.com/daily-express-news-showbiz" + } + ] + }, + { + "key": "united-states", + "name": "United States", + "feeds": [ + { + "name": "World News - Breaking News, Top Stories", + "url": "https://www.huffpost.com/section/world-news/feed" + }, + { + "name": "NYT > Top Stories", + "url": "https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml" + }, + { + "name": "FOX News", + "url": "http://feeds.foxnews.com/foxnews/latest" + }, + { + "name": "World", + "url": "http://feeds.washingtonpost.com/rss/world" + }, + { + "name": "WSJ.com: World News", + "url": "https://feeds.a.dj.com/rss/RSSWorldNews.xml" + }, + { + "name": "World & Nation", + "url": "https://www.latimes.com/world-nation/rss2.0.xml" + }, + { + "name": "CNN.com - RSS Channel - App International Edition", + "url": "http://rss.cnn.com/rss/edition.rss" + }, + { + "name": "Yahoo News - Latest News & Headlines", + "url": "https://news.yahoo.com/rss/mostviewed" + }, + { + "name": "US Top News and Analysis", + "url": "https://www.cnbc.com/id/100003114/device/rss/rss.html" + }, + { + "name": "Playbook", + "url": "https://rss.politico.com/playbook.xml" + } + ] + } + ] +} diff --git a/packs/world/preview.svg b/packs/world/preview.svg new file mode 100644 index 0000000..d08e90f --- /dev/null +++ b/packs/world/preview.svg @@ -0,0 +1,9 @@ + + +RSS +World +25 countries, from Japan to Brazil, each read from its own +newspapers. Every new story becomes an edit; a flow can post +it for you. +Australia · Bangladesh · Brazil · Canada · France +20 more + diff --git a/src/app/icons.rs b/src/app/icons.rs index 85b523b..9957352 100644 --- a/src/app/icons.rs +++ b/src/app/icons.rs @@ -6,7 +6,7 @@ use gpui_kit::{img, Hsla, Image, ImageFormat, Img, Rgba, Styled}; use std::sync::{Arc, LazyLock}; gpui_kit::assets::icon_assets!(pub Extra, [Trash, Rss, Film, Package, Download, Share2, Zap, Store, SquarePen, SlidersHorizontal, KeyRound, Brain, Library, PanelLeft, - Upload, FileDown, GitBranch, ExternalLink, Gauge, Box, ChevronDown, LockOpen, Lock, Check]); + Upload, FileDown, GitBranch, ExternalLink, Gauge, Box, ChevronDown, LockOpen, Lock, Check, RotateCcw, ChevronRight, Pause, Volume2, VolumeX]); #[derive(Clone, Copy, PartialEq, Eq, Hash)] pub enum Icon { @@ -35,8 +35,6 @@ pub enum Icon { Rss, Share, Key, - Sun, - Moon, Palette, Sliders, Github, @@ -52,6 +50,11 @@ pub enum Icon { Lock, Unlock, Check, + Reset, + ChevronRight, + Pause, + Volume, + Mute, } fn name(i: Icon) -> IconName { @@ -80,8 +83,6 @@ fn name(i: Icon) -> IconName { Icon::Rss => IconName::Rss, Icon::Share => IconName::Share2, Icon::Key => IconName::KeyRound, - Icon::Sun => IconName::Sun, - Icon::Moon => IconName::Moon, Icon::Palette => IconName::Palette, Icon::Sliders => IconName::SlidersHorizontal, Icon::Github => IconName::Github, @@ -97,6 +98,11 @@ fn name(i: Icon) -> IconName { Icon::Lock => IconName::Lock, Icon::Unlock => IconName::LockOpen, Icon::Check => IconName::Check, + Icon::Reset => IconName::RotateCcw, + Icon::ChevronRight => IconName::ChevronRight, + Icon::Pause => IconName::Pause, + Icon::Volume => IconName::Volume2, + Icon::Mute => IconName::VolumeX, } } @@ -155,21 +161,27 @@ pub fn logo(name: &str, color: Hsla, page: Hsla) -> Option { let (c, p) = (css(color), css(page)); let key = format!("{name}{c}{p}"); picture(&key, || { - let mut s = src.to_string(); - for dark in ["#000000", "#000", "currentColor", "black", "#9046FF"] { - s = s.replace(&format!("\"{dark}\""), &format!("\"{c}\"")); - } - for light in ["#ffffff", "#FFFFFF", "#fff", "#FFF", "white"] { - s = s.replace(&format!("\"{light}\""), &format!("\"{p}\"")); - } - // a logo with no colour of its own takes it on its root - if !s.contains(&c) { - s = s.replacen(" String { + let mut s = src.to_string(); + for dark in ["#000000", "#000", "currentColor", "black", "#9046FF"] { + s = s.replace(&format!("\"{dark}\""), "\"@INK@\""); + } + for light in ["#ffffff", "#FFFFFF", "#fff", "#FFF", "white"] { + s = s.replace(&format!("\"{light}\""), "\"@PAGE@\""); + } + // a logo with no colour of its own takes it on its root + if !s.contains("@INK@") { + s = s.replacen(" Img { @@ -224,6 +236,15 @@ mod tests { } } + #[test] + fn a_white_ink_stays_ink() { + // Omarchy's vantablack: white ink on a black page; the logo must not turn into the page + let s = super::recolor(r##""##, "#FFFFFF", "#0A0A0A"); + assert!(s.contains("fill=\"#FFFFFF\"") && !s.contains("#0A0A0A"), "{s}"); + let s = super::recolor("", "#FFFFFF", "#0A0A0A"); + assert!(s.starts_with(" img.size_full().object_fit(ObjectFit::Cover).into_any_element(), @@ -45,11 +46,11 @@ impl Workspace { .child(text(name, 14., BOLD, b.ink).truncate()) .child(text(format!("{} · {}", it.subject, it.age), 12., FontWeight::NORMAL, b.gray).truncate())) .child(div().flex().gap(px(2.)) - .child(icon_button(("lib-review", i), Icon::Eye, b).tooltip(|w, cx| gpui_kit::component::tooltip::Tooltip::new("Review").build(w, cx)) - .on_click(cx.listener(move |this, _, window, cx| { + .child(icon_button(("lib-play", i), Icon::Play, b).tooltip(|w, cx| gpui_kit::component::tooltip::Tooltip::new("Open in your player").build(w, cx)) + .on_click(move |_, _, cx| { cx.stop_propagation(); - this.open_review(review.clone(), window, cx); - }))) + cx.open_with_system(&play); + })) .child(icon_button(("lib-show", i), Icon::Folder, b).tooltip(|w, cx| gpui_kit::component::tooltip::Tooltip::new("Show in folder").build(w, cx)) .on_click(move |_, _, cx| { cx.stop_propagation(); @@ -82,7 +83,7 @@ impl Workspace { .child(icon(Icon::Library, b.gray).size(px(16.))) .child(text("Library", 14., BOLD, b.ink)) .child(text(if n == 1 { "1 clip".into() } else { format!("{n} clips") }, 13., FontWeight::NORMAL, b.gray).flex_1()) - .child(div().w(px(260.)).child(Input::new(&self.library_search).prefix(icon(Icon::Search, b.gray).size(px(14.))).cleanable(true))) + .child(div().w(px(260.)).child(Input::new(&self.library_search).prefix(icon(Icon::Search, b.gray).size(px(14.))).suffix(crate::app::sidebar::shortcut(&b)).cleanable(true))) .child(icon_button("lib-folder", Icon::Folder, &b).on_click(move |_, _, cx| cx.open_with_system(&out)))) .child(div().id("library").flex_1().min_h_0().overflow_y_scroll() .child(div().w_full().max_w(px(1120.)).mx_auto().p(px(24.)).flex().flex_col().gap(px(16.)).child(body))) diff --git a/src/app/marketplace.rs b/src/app/marketplace.rs index dde27e7..b2bb657 100644 --- a/src/app/marketplace.rs +++ b/src/app/marketplace.rs @@ -18,6 +18,22 @@ fn runs_something(kinds: &[String]) -> bool { kinds.iter().any(|k| k == "automation" || k == "source") } +/// A pack's cover standing still: a GIF's first frame. It moves only in the pack's own sheet. +fn still(p: &Pack) -> Option { + let gif = crate::packs::built_in_gif(&p.id).map(|g| g.to_vec()) + .or_else(|| p.preview_file.as_ref().filter(|f| f.extension().is_some_and(|e| e.eq_ignore_ascii_case("gif"))).and_then(|f| std::fs::read(f).ok())); + let Some(gif) = gif else { return picture(p) }; + icons::picture(&format!("{}:still", p.id), || Some((ImageFormat::Png, first_frame(&gif)?))) +} + +/// A GIF's first frame as a PNG. +pub fn first_frame(gif: &[u8]) -> Option> { + let img = image::load_from_memory_with_format(gif, image::ImageFormat::Gif).ok()?; + let mut out = std::io::Cursor::new(vec![]); + img.write_to(&mut out, image::ImageFormat::Png).ok()?; + Some(out.into_inner()) +} + fn picture(p: &Pack) -> Option { icons::picture(&p.id, || { // a built-in pack's moving cover @@ -88,7 +104,7 @@ impl Workspace { cx.notify(); })) .child(div().w_full().h(px(144.)).rounded(px(10.)).overflow_hidden().bg(b.hair).relative() - .children(picture(p).map(|img| img.size_full().object_fit(ObjectFit::Cover))) + .children(still(p).map(|img| img.size_full().object_fit(ObjectFit::Cover))) .when(!p.enabled, |d| d.child(div().absolute().top(px(8.)).right(px(8.)).px(px(8.)).h(px(22.)).flex().items_center().rounded(px(11.)).bg(black().opacity(0.6)).child(text("Off", 11., BOLD, white()))))) .child(text(p.name.clone(), 15., BOLD, b.ink).px(px(4.)).truncate()) .child(text(format!("{count} · {origin}"), 12., FontWeight::NORMAL, b.gray).px(px(4.)).truncate()) @@ -160,7 +176,7 @@ impl Workspace { .child(text(title, 24., BOLD, b.ink)) .child(text(about, 14., LIGHT, b.gray)) .child(div().pt(px(8.)).flex().flex_wrap().gap(px(8.)) - .child(Input::new(&self.market_search).prefix(icon(Icon::Search, b.gray).size(px(14.))).cleanable(true).w(px(320.))) + .child(Input::new(&self.market_search).prefix(icon(Icon::Search, b.gray).size(px(14.))).suffix(crate::app::sidebar::shortcut(b)).cleanable(true).w(px(320.))) .when(!automations, |d| d.child(pill("make-pack", Some(Icon::Package), "Make one from a video", false, b) .on_click(cx.listener(|this, _, window, cx| this.make_pack(window, cx))))))) } @@ -337,6 +353,13 @@ impl Workspace { #[cfg(test)] mod tests { + #[test] + fn a_gif_stands_still_on_its_card() { + let gif = crate::packs::built_in_gif("edits.stardust").expect("stardust has a moving cover"); + let png = super::first_frame(gif).expect("its first frame"); + assert!(png.starts_with(b"\x89PNG")); + } + #[test] fn search_reaches_into_styles_and_topics() { let packs: Vec = serde_json::from_value(crate::packs_json()).unwrap(); diff --git a/src/app/mod.rs b/src/app/mod.rs index 7ae5b70..65228f1 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -8,6 +8,7 @@ mod flows; mod library; mod icons; mod marketplace; +mod player; mod review; mod runs; pub mod settings; @@ -21,7 +22,7 @@ mod workspace; use gpui_kit::*; use std::path::PathBuf; -actions!(edits, [Quit, ToggleSidebar]); +actions!(edits, [Quit, ToggleSidebar, Search]); /// gpui-kit's own icons, and the Lucide ones the app adds. struct AppAssets; @@ -73,8 +74,8 @@ pub fn run(args: &[String]) { gpui_kit::init(cx); // Windows posts system notifications under the app's identity cx.set_app_identity("io.github.onurbyte.edits", "EditsMaker"); - let (q, b) = if cfg!(target_os = "macos") { ("cmd-q", "cmd-b") } else { ("ctrl-q", "ctrl-b") }; - cx.bind_keys([KeyBinding::new(q, Quit, None), KeyBinding::new(b, ToggleSidebar, None)]); + let (q, b, k) = if cfg!(target_os = "macos") { ("cmd-q", "cmd-b", "cmd-k") } else { ("ctrl-q", "ctrl-b", "ctrl-k") }; + cx.bind_keys([KeyBinding::new(q, Quit, None), KeyBinding::new(b, ToggleSidebar, None), KeyBinding::new(k, Search, None)]); cx.on_action(|_: &Quit, cx| cx.quit()); cx.on_window_closed(|cx, _| { if cx.windows().is_empty() { diff --git a/src/app/player.rs b/src/app/player.rs new file mode 100644 index 0000000..8c3b468 --- /dev/null +++ b/src/app/player.rs @@ -0,0 +1,248 @@ +//! The editor's video player. No GPUI player fits gpui-fast (alhazen-gpui and gpui-video-player are built on upstream +//! gpui, and alhazen-core's AV1 decoder needs nasm to build), so it plays on the ffmpeg edits already needs: one +//! ffmpeg decodes the picture, scaled to what the window shows, as raw BGRA frames on a pipe, each shown when the +//! clock reaches it; the sound plays beside it (ffplay with no window, else ffmpeg's own sound output). Seeking starts +//! both again at the new time; paused, one frame is taken at the playhead. +use gpui_kit::*; +use std::io::Read; +use std::path::{Path, PathBuf}; +use std::process::{Child, Command, Stdio}; +use std::sync::atomic::{AtomicU64, Ordering}; +use std::sync::{Arc, Mutex}; +use std::time::{Duration, Instant}; + +/// Frames a second the player shows; edits' clips are 30. +pub const FPS: f64 = 30.0; + +/// The newest decoded frame: which start it belongs to, its time, its pixels. +type Latest = Arc)>>>; + +pub struct Player { + pub clip: PathBuf, + /// the frame size it decodes at + pub w: u32, + pub h: u32, + pub total: f64, + /// where the playhead was when it last started or stopped + at: f64, + /// when it started playing, None when paused + since: Option, + pub muted: bool, + /// trim points picked by hand, for `edits cut` + pub mark_in: Option, + pub mark_out: Option, + latest: Latest, + /// bumped at every start or seek: an older decoder stops by itself + generation: Arc, + shown: Option<(f64, Arc)>, + /// images painted before, to drop from the sprite atlas (else it grows by a frame a frame) + retired: Vec>, + video: Option, + audio: Option, +} + +/// A frame size of at most `max` tall, even on both sides as ffmpeg's scaler wants, keeping the shape. +pub fn fit(w: u32, h: u32, max: u32) -> (u32, u32) { + if w == 0 || h == 0 { + return (max * 9 / 16 / 2 * 2, max / 2 * 2); + } + let s = (max as f64 / h as f64).min(1.0); + (((w as f64 * s) as u32 / 2 * 2).max(2), ((h as f64 * s) as u32 / 2 * 2).max(2)) +} + +/// The ffmpeg arguments that decode the picture from `t` on, as BGRA frames of `w` x `h` at FPS; `one` takes one. +pub fn video_args(clip: &Path, t: f64, w: u32, h: u32, one: bool) -> Vec { + let mut a: Vec = ["-v", "error", "-nostdin", "-ss"].iter().map(|s| s.to_string()).collect(); + a.extend([format!("{t:.3}"), "-i".into(), clip.display().to_string(), "-an".into(), "-vf".into(), format!("scale={w}:{h},fps={FPS}"), + "-pix_fmt".into(), "bgra".into(), "-f".into(), "rawvideo".into()]); + if one { + a.extend(["-frames:v".into(), "1".into()]); + } + a.push("-".into()); + a +} + +fn have(tool: &str) -> bool { + Command::new(tool).arg("-version").stdout(Stdio::null()).stderr(Stdio::null()).status().is_ok_and(|s| s.success()) +} + +/// The sound from `t` on, to the speakers. +fn play_sound(clip: &Path, t: f64) -> Option { + let c = clip.display().to_string(); + let t = format!("{t:.3}"); + let quiet = |cmd: &mut Command| cmd.stdin(Stdio::null()).stdout(Stdio::null()).stderr(Stdio::null()).spawn().ok(); + static FFPLAY: std::sync::OnceLock = std::sync::OnceLock::new(); + if *FFPLAY.get_or_init(|| have("ffplay")) { + return quiet(Command::new("ffplay").args(["-v", "quiet", "-nodisp", "-autoexit", "-ss", &t, &c])); + } + // no ffplay: ffmpeg's own sound output, where the system has one + let out: &[&str] = if cfg!(target_os = "macos") { &["-f", "audiotoolbox", "-"] } else if cfg!(target_os = "linux") { &["-f", "pulse", "edits"] } else { return None }; + quiet(Command::new("ffmpeg").args(["-v", "quiet", "-nostdin", "-re", "-ss", &t, "-i", &c, "-vn"]).args(out)) +} + +impl Player { + pub fn open(clip: &Path, total: f64) -> Self { + let (vw, vh) = crate::fetch::dims(clip); + let (w, h) = fit(vw, vh, 960); + let total = if total > 0.0 { total } else { crate::fetch::duration(clip).unwrap_or(0.0) }; + let mut p = Player { clip: clip.to_path_buf(), w, h, total, at: 0.0, since: None, muted: false, mark_in: None, mark_out: None, + latest: Default::default(), generation: Default::default(), shown: None, retired: vec![], video: None, audio: None }; + p.decode(0.0, true); + p + } + + pub fn playing(&self) -> bool { + self.since.is_some() + } + + /// Where the playhead is now. + pub fn position(&self) -> f64 { + let t = self.at + self.since.map_or(0.0, |s| s.elapsed().as_secs_f64()); + t.min(self.total.max(0.0)) + } + + fn stop_children(&mut self) { + for c in [self.video.take(), self.audio.take()].into_iter().flatten() { + let mut c = c; + let _ = c.kill(); + // reaped on a thread: a killed ffmpeg is gone at once, but wait() must still be called + std::thread::spawn(move || c.wait()); + } + } + + /// Starts a decoder at `t`: one frame when paused, else frames on the clock until the end. + fn decode(&mut self, t: f64, one: bool) { + let g = self.generation.fetch_add(1, Ordering::SeqCst) + 1; + let Ok(mut child) = Command::new("ffmpeg").args(video_args(&self.clip, t, self.w, self.h, one)).stdin(Stdio::null()).stdout(Stdio::piped()).stderr(Stdio::null()).spawn() else { return }; + let Some(mut out) = child.stdout.take() else { return }; + self.video = Some(child); + let (latest, generation, size, start) = (self.latest.clone(), self.generation.clone(), (self.w * self.h * 4) as usize, Instant::now()); + std::thread::spawn(move || { + let mut n = 0u64; + loop { + let mut buf = vec![0u8; size]; + if out.read_exact(&mut buf).is_err() || generation.load(Ordering::SeqCst) != g { + break; + } + let due = Duration::from_secs_f64(n as f64 / FPS); + // ahead of the clock: wait for it; behind it: show this one anyway, the next catches up + if !one { + if let Some(wait) = due.checked_sub(start.elapsed()) { + std::thread::sleep(wait); + } + } + if generation.load(Ordering::SeqCst) != g { + break; + } + *latest.lock().unwrap() = Some((g, t + n as f64 / FPS, buf)); + n += 1; + } + }); + } + + pub fn play(&mut self) { + if self.playing() { + return; + } + if self.at >= self.total - 0.05 { + self.at = 0.0; + } + self.stop_children(); + self.decode(self.at, false); + if !self.muted { + self.audio = play_sound(&self.clip, self.at); + } + self.since = Some(Instant::now()); + } + + pub fn pause(&mut self) { + self.at = self.position(); + self.since = None; + self.stop_children(); + self.generation.fetch_add(1, Ordering::SeqCst); + } + + pub fn toggle(&mut self) { + if self.playing() { self.pause() } else { self.play() } + } + + pub fn seek(&mut self, t: f64) { + let playing = self.playing(); + self.pause(); + self.at = t.clamp(0.0, self.total.max(0.0)); + if playing { + self.play(); + } else { + self.decode(self.at, true); + } + } + + pub fn set_muted(&mut self, m: bool) { + self.muted = m; + if self.playing() { + let t = self.position(); + self.seek(t); + } + } + + /// Called each frame the window draws: ends at the end, and hands the newest frame to paint. + pub fn frame(&mut self, window: &mut Window) -> Option> { + if self.playing() && self.position() >= self.total - 0.01 { + self.pause(); + self.at = self.total; + } + for old in self.retired.drain(..) { + let _ = window.drop_image(old); + } + let now = self.generation.load(Ordering::SeqCst); + let fresh = self.latest.lock().unwrap().take(); + if let Some((g, t, bgra)) = fresh { + // a frame from a decoder since stopped is still the right picture when it is the last one asked for + if g + 1 >= now { + if let Some(buf) = image::RgbaImage::from_raw(self.w, self.h, bgra) { + let img = Arc::new(RenderImage::new([image::Frame::new(buf)])); + if let Some((_, old)) = self.shown.replace((t, img)) { + self.retired.push(old); + } + } + } + } + self.shown.as_ref().map(|s| s.1.clone()) + } +} + +impl Drop for Player { + fn drop(&mut self) { + self.generation.fetch_add(1, Ordering::SeqCst); + self.stop_children(); + } +} + +/// "1:05.3" for a time in seconds. +pub fn clock(t: f64) -> String { + let t = t.max(0.0); + format!("{}:{:04.1}", (t / 60.0) as u64, t % 60.0) +} + +#[cfg(test)] +mod tests { + // not super::*: gpui_kit's own `test` attribute would come with it + use super::{clock, fit, video_args}; + use std::path::Path; + + #[test] + fn frames_keep_their_shape_and_stay_even() { + assert_eq!(fit(1080, 1920, 960), (540, 960)); + assert_eq!(fit(1080, 1080, 960), (960, 960)); + assert_eq!(fit(641, 361, 960), (640, 360), "never scaled up, always even"); + assert_eq!(fit(0, 0, 960), (540, 960)); + } + + #[test] + fn the_decoder_reads_from_the_playhead() { + let a = video_args(Path::new("/v/a b.mp4"), 2.5, 540, 960, true); + assert_eq!(&a[4..7], ["2.500", "-i", "/v/a b.mp4"]); + assert!(a.contains(&"scale=540:960,fps=30".to_string()) && a.ends_with(&["-frames:v".into(), "1".into(), "-".into()])); + assert_eq!(clock(65.3), "1:05.3"); + } +} diff --git a/src/app/review.rs b/src/app/review.rs index ba8ad92..cc672b8 100644 --- a/src/app/review.rs +++ b/src/app/review.rs @@ -1,6 +1,8 @@ -//! Reviewing a clip: its frames in a strip, the one picked large; point at a spot in it (a 3 x 3 grid), say what to -//! change there, add a word on the whole edit, and the notes go beside the clip for the agent (`edits review`). +//! The editor: the clip playing (player.rs) with its shots marked on the timeline, its frames in a strip; trim it by +//! hand (set in and out, Cut: `edits cut`), or point at a spot (a 3 x 3 grid), say what to change there, add a word on +//! the whole edit, and the notes go beside the clip for the agent (`edits review`). use crate::app::icons::{icon, Icon}; +use crate::app::player::clock; use crate::app::runs::{self, Note}; use crate::app::theme::{brand, Brand, BOLD, HEADER, LIGHT, SMALL}; use crate::app::ui::{card, pill, primary, text}; @@ -20,7 +22,10 @@ impl Workspace { pub fn add_note(&mut self, window: &mut Window, cx: &mut Context) { let Some(r) = self.review.as_mut() else { return }; let text = r.note.read(cx).value().trim().to_string(); - let t = r.sheet.as_ref().and_then(|s| s.as_ref().ok()).and_then(|s| s.frames.get(r.at)).map_or(0.0, |f| f.t); + let t = match &r.player { + Some(p) => p.position(), + None => r.sheet.as_ref().and_then(|s| s.as_ref().ok()).and_then(|s| s.frames.get(r.at)).map_or(0.0, |f| f.t), + }; if text.is_empty() { return; } @@ -44,15 +49,86 @@ impl Workspace { } } - fn frame_view(&self, b: &Brand, cx: &mut Context) -> AnyElement { + /// The player's controls: play, the time, the timeline (its shots, the trim, the playhead), sound, trim by hand. + fn controls(&self, cuts: &[f64], b: &Brand, cx: &mut Context) -> AnyElement { + let Some(p) = self.review.as_ref().and_then(|r| r.player.as_ref()) else { + return text("Opening the player...", 13., FontWeight::NORMAL, b.gray).into_any_element(); + }; + let (total, now) = (p.total.max(0.01), p.position()); + const STEPS: usize = 240; + let (mark_in, mark_out) = (p.mark_in, p.mark_out); + let (hover, accent, ink, hair) = (b.accent.opacity(0.5), b.accent, b.ink, b.hair); + // the timeline as many thin steps, each one a place to seek to + let steps = (0..STEPS).map(|i| { + let (a, z) = (total * i as f64 / STEPS as f64, total * (i + 1) as f64 / STEPS as f64); + let played = a < now; + let trimmed = mark_in.is_some_and(|x| a >= x) && mark_out.is_none_or(|x| a < x) || mark_out.is_some_and(|x| a < x) && mark_in.is_none(); + let cut = cuts.iter().any(|c| *c > 0.05 && *c >= a && *c < z); + div().id(("seek", i)).relative().flex_1().h_full().flex().items_center().cursor_pointer().hover(move |s| s.bg(hover)) + .child(div().w_full().h(px(6.)).bg(if played { accent } else { hair }).when(trimmed, |d| d.h(px(14.)).opacity(0.85))) + .when(cut, |d| d.child(div().absolute().w(px(2.)).h(px(18.)).bg(ink))) + .on_click(cx.listener(move |this, _, _, cx| { + if let Some(p) = this.review.as_mut().and_then(|r| r.player.as_mut()) { + p.seek(a); + } + cx.notify(); + })) + }); + let playing = p.playing(); + let set = |id: &'static str, label: &'static str, f: fn(&mut crate::app::player::Player), b: &Brand, cx: &mut Context| { + pill(id, None, label, false, b).on_click(cx.listener(move |this, _, _, cx| { + if let Some(p) = this.review.as_mut().and_then(|r| r.player.as_mut()) { + f(p); + } + cx.notify(); + })) + }; + let span = match (mark_in, mark_out) { + (Some(a), Some(z)) if z > a + 0.05 => Some((a, z)), + _ => None, + }; + div().flex().flex_col().gap(px(8.)) + .child(div().id("timeline").h(px(24.)).flex().items_center().children(steps)) + .child(div().flex().items_center().gap(px(8.)) + .child(crate::app::ui::icon_button("play", if playing { Icon::Pause } else { Icon::Play }, b) + .tooltip(|w, cx| gpui_kit::component::tooltip::Tooltip::new("Play or pause").build(w, cx)) + .on_click(cx.listener(|this, _, _, cx| { + if let Some(p) = this.review.as_mut().and_then(|r| r.player.as_mut()) { + p.toggle(); + } + cx.notify(); + }))) + .child(text(format!("{} / {} · shot {} of {}", clock(now), clock(p.total), shot(now, cuts), shot(p.total, cuts)), 13., FontWeight::NORMAL, b.gray).font_family(crate::app::theme::MONO)) + .child(crate::app::ui::icon_button("mute", if p.muted { Icon::Mute } else { Icon::Volume }, b) + .on_click(cx.listener(|this, _, _, cx| { + if let Some(p) = this.review.as_mut().and_then(|r| r.player.as_mut()) { + let m = !p.muted; + p.set_muted(m); + } + cx.notify(); + }))) + .child(div().flex_1()) + .child(set("mark-in", "Set in", |p| p.mark_in = Some(p.position()), b, cx)) + .child(set("mark-out", "Set out", |p| p.mark_out = Some(p.position()), b, cx)) + .when(mark_in.is_some() || mark_out.is_some(), |d| d.child(set("mark-clear", "Clear", |p| (p.mark_in, p.mark_out) = (None, None), b, cx))) + .children(span.map(|(a, z)| { + let clip = p.clip.display().to_string(); + primary("cut", format!("Cut {}-{}", clock(a), clock(z)), b).on_click(cx.listener(move |this, _, window, cx| { + this.launch(vec!["cut".into(), clip.clone(), format!("{a:.2}-{z:.2}")], window, cx); + })) + }))) + .into_any_element() + } + + fn frame_view(&self, pic: Option>, b: &Brand, cx: &mut Context) -> AnyElement { let Some(r) = self.review.as_ref() else { return div().into_any_element() }; let sheet = match &r.sheet { - None => return text("Taking the clip's frames...", 14., FontWeight::NORMAL, b.gray).p(px(24.)).into_any_element(), - Some(Err(e)) => return text(e.clone(), 14., FontWeight::NORMAL, b.red_text).p(px(24.)).into_any_element(), - Some(Ok(s)) => s, + Some(Ok(s)) => Some(s), + Some(Err(e)) if pic.is_none() => return text(e.clone(), 14., FontWeight::NORMAL, b.red_text).p(px(24.)).into_any_element(), + _ => None, }; - let Some(frame) = sheet.frames.get(r.at) else { return text("This clip has no frames", 14., FontWeight::NORMAL, b.gray).into_any_element() }; - // nine places to point at, over the frame + let cuts: Vec = sheet.map(|s| s.cuts.clone()).unwrap_or_default(); + // nine places to point at, over the picture let cells = (0..9usize).map(|k| { let (x, y) = ((k % 3) as f64 / 3.0 + 1.0 / 6.0, (k / 3) as f64 / 3.0 + 1.0 / 6.0); let on = r.spot == Some((x, y)); @@ -67,31 +143,54 @@ impl Workspace { cx.notify(); })) }); - let strip = sheet.frames.iter().enumerate().map(|(i, f)| { - let on = i == r.at; + let picture: AnyElement = match (&pic, sheet.and_then(|s| s.frames.get(r.at))) { + (Some(img_), _) => img(ImageSource::Render(img_.clone())).size_full().object_fit(ObjectFit::Contain).into_any_element(), + (None, Some(f)) => img(f.file.clone()).size_full().object_fit(ObjectFit::Contain).into_any_element(), + (None, None) => text("Opening the clip...", 14., FontWeight::NORMAL, b.gray).p(px(24.)).into_any_element(), + }; + let now = r.player.as_ref().map(|p| p.position()); + let strip = sheet.map(|sheet| sheet.frames.iter().enumerate().map(|(i, f)| { + // the frame the playhead is in + let on = match now { + Some(t) => t >= f.t && sheet.frames.get(i + 1).is_none_or(|n| t < n.t), + None => i == r.at, + }; let cut = i > 0 && shot(f.t, &sheet.cuts) != shot(sheet.frames[i - 1].t, &sheet.cuts); + let t = f.t; div().id(("frame", i)).flex_none().h(px(72.)).w(px(48.)).rounded(SMALL).overflow_hidden().cursor_pointer() .when(cut, |d| d.ml(px(8.))) - .border_2().border_color(if on { b.ink } else { transparent_black() }) + .border_2().border_color(if on { b.accent } else { transparent_black() }) .child(img(f.file.clone()).size_full().object_fit(ObjectFit::Cover)) .on_click(cx.listener(move |this, _, _, cx| { if let Some(r) = this.review.as_mut() { r.at = i; + if let Some(p) = r.player.as_mut() { + p.seek(t); + } } cx.notify(); })) - }); + .into_any_element() + }).collect::>()).unwrap_or_default(); div().flex_1().min_w_0().flex().flex_col().gap(px(16.)).p(px(24.)) - .child(div().flex_1().min_h_0().relative().rounded(SMALL).overflow_hidden().bg(b.card) - .child(img(frame.file.clone()).size_full().object_fit(ObjectFit::Contain)) + .child(div().flex_1().min_h_0().relative().rounded(SMALL).overflow_hidden().bg(black()) + .child(picture) .child(div().absolute().inset_0().flex().flex_wrap().children(cells))) - .child(text(format!("{:.1}s of {:.1}s · shot {} of {}", frame.t, sheet.total, shot(frame.t, &sheet.cuts), shot(sheet.total, &sheet.cuts)), 14., FontWeight::NORMAL, b.gray)) + .child(self.controls(&cuts, b, cx)) .child(div().id("strip").flex_none().overflow_x_scroll().flex().gap(px(4.)).children(strip)) .into_any_element() } - pub fn review_screen(&self, _: &mut Window, cx: &mut Context) -> impl IntoElement { + pub fn review_screen(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { let b = brand(cx); + // the newest frame; while it plays, drawn again each frame + let player = self.review.as_mut().and_then(|r| r.player.as_mut()); + let pic = player.and_then(|p| { + if p.playing() { + window.request_animation_frame(); + } + p.frame(window) + }); let Some(r) = self.review.as_ref() else { return div().into_any_element() }; let (name, about) = match &r.sheet { Some(Ok(s)) => (s.name.clone(), s.about.join(" · ")), @@ -119,10 +218,10 @@ impl Workspace { .child(text(about, 13., FontWeight::NORMAL, b.gray).flex_1().min_w_0().truncate()) .child(primary("send-notes", "Send notes", &b).on_click(cx.listener(|this, _, window, cx| this.send_notes(window, cx))))) .child(div().flex_1().min_h_0().flex() - .child(self.frame_view(&b, cx)) + .child(self.frame_view(pic, &b, cx)) .child(div().w(px(320.)).flex_none().border_l_1().border_color(b.hair).flex().flex_col().gap(px(16.)).p(px(24.)) .child(text("Notes", 19., BOLD, b.ink)) - .child(text("Pick a frame and a spot in it, then say what to change.", 13., LIGHT, b.gray)) + .child(text("Play it, stop where something is off, pick a spot in the picture, then say what to change. Or trim it yourself: Set in, Set out, Cut.", 13., LIGHT, b.gray)) .child(card(&b).p(px(8.)).child(Input::new(&r.note).appearance(false))) .child(pill("add-note", Some(Icon::Plus), "Add note", false, &b).on_click(cx.listener(|this, _, window, cx| this.add_note(window, cx)))) .child(div().id("notes").flex_1().min_h_0().overflow_y_scroll().flex().flex_col().gap(px(8.)).children(notes)) diff --git a/src/app/settings.rs b/src/app/settings.rs index 43d1199..383cb89 100644 --- a/src/app/settings.rs +++ b/src/app/settings.rs @@ -6,7 +6,7 @@ use crate::app::icons::{icon, Icon}; use crate::app::runs::{Provider, Settings}; use crate::app::theme::{self, brand, Brand, Prefs, BOLD, CARD, LIGHT, MONO, SMALL}; -use crate::app::ui::{card, pill, primary, tag, text}; +use crate::app::ui::{card, pill, primary, text}; use gpui_kit::component::switch::Switch; use crate::app::workspace::{Section, Workspace}; use gpui_kit::component::input::Input; @@ -17,13 +17,13 @@ use gpui_kit::*; /// The sections, their icons, and the words search finds them by (what their rows are about). const SECTIONS: &[(Section, &str, Icon, &str)] = &[ - (Section::General, "General", Icon::Settings, "folder where edits go output videos encoder gpu graphics card render updates discord rich presence playing status"), + (Section::General, "General", Icon::Settings, "folder where edits go output videos encoder gpu graphics card render discord rich presence playing status"), (Section::Ai, "AI", Icon::Brain, "ai provider model claude codex cursor grok gemini antigravity kiro opencode pi acp openai anthropic openrouter ollama key api"), (Section::Accounts, "Accounts", Icon::User, "accounts connect sign in tiktok youtube instagram bluesky facebook post"), (Section::Agents, "Agents", Icon::Terminal, "agents mcp server skills claude code chatgpt cursor tools"), (Section::Usage, "Usage", Icon::Usage, "usage how many edits clips space disk ai calls requests time spent stats"), (Section::Appearance, "Appearance", Icon::Palette, "appearance theme dark light system omarchy accent colour color chat width text size font"), - (Section::About, "About", Icon::Info, "about version github check doctor ffmpeg yt-dlp whisper terms of use privacy license legal"), + (Section::About, "About", Icon::Info, "about version github x twitter author issues program updates update rollback latest release check doctor ffmpeg yt-dlp whisper terms of use privacy license legal"), ]; /// What About links to, each a file in the repository on GitHub: (title, line, file). @@ -40,6 +40,14 @@ pub fn found(q: &str) -> Vec
{ SECTIONS.iter().filter(|s| q.is_empty() || s.1.to_lowercase().contains(&q) || q.split_whitespace().all(|w| s.3.contains(w))).map(|s| s.0).collect() } +/// An account as t3code shows it before a click: an email's name hidden, o•••@gmail.com; a plain name as it is. +pub fn masked(who: &str) -> String { + match who.split_once('@') { + Some((n, d)) => format!("{}•••@{d}", n.chars().next().unwrap_or('•')), + None => who.to_string(), + } +} + /// A SettingsRow: title and description on the left, the control on the right. fn row(title: &str, about: impl Into, control: impl IntoElement, first: bool, b: &Brand) -> impl IntoElement { div().px(px(16.)).py(px(16.)).flex().items_center().gap(px(16.)).when(!first, |d| d.border_t_1().border_color(b.hair)) @@ -56,9 +64,39 @@ fn group(title: &str, rows: Vec, b: &Brand) -> impl IntoElement { .child(div().flex().flex_col().bg(b.page).rounded(CARD).children(rows)) } -/// Colour dots for an appearance tile: page, card, ink. -fn dots(colors: [Hsla; 3], b: &Brand) -> Div { - div().flex().gap(px(4.)).children(colors.into_iter().map(|c| div().size(px(16.)).rounded_full().bg(c).border_1().border_color(b.hair))) +/// t3code's ThemeWireframe: a little window in a theme's colours, its sidebar, lines of text and the composer. +fn wireframe(c: &Brand) -> Div { + let line = |w: f32, o: f32| div().h(px(4.)).w(relative(w)).rounded(px(2.)).bg(c.ink.opacity(o)); + div().h(px(96.)).flex().rounded(SMALL).overflow_hidden().bg(c.page).border_1().border_color(c.hair) + .child(div().w(relative(0.3)).h_full().p(px(8.)).flex().flex_col().gap(px(6.)).bg(c.card) + .child(line(0.7, 0.5)).child(line(0.9, 0.25)).child(line(0.6, 0.25)).child(line(0.8, 0.25))) + .child(div().flex_1().p(px(10.)).flex().flex_col().gap(px(6.)) + .child(line(0.5, 0.6)).child(line(0.85, 0.25)).child(line(0.7, 0.25)) + .child(div().flex_1()) + .child(div().h(px(18.)).rounded(px(9.)).bg(c.card).border_1().border_color(c.hair).flex().items_center().justify_end().px(px(3.)) + .child(div().size(px(12.)).rounded_full().bg(c.accent)))) +} + +/// One of t3code's appearance mode tiles: the preview, its name under it, ringed in the accent when picked. +fn mode_tile(id: &'static str, preview: Div, label: &'static str, on: bool, b: &Brand) -> Stateful
{ + let hover = b.accent.opacity(0.06); + div().id(id).flex_1().flex_basis(px(0.)).min_w_0().p(px(8.)).flex().flex_col().gap(px(6.)).rounded(px(12.)).cursor_pointer() + .bg(if on { b.accent.opacity(0.14) } else { b.page }).border_1().border_color(if on { b.accent } else { b.hair }) + .when(!on, |d| d.hover(move |s| s.bg(hover))) + .child(preview) + .child(div().flex().justify_center().child(text(label, 12., if on { BOLD } else { FontWeight::NORMAL }, if on { b.ink } else { b.gray }))) +} + +/// t3code's select, as a segmented row: the current value filled; picking one saves `set(value)`. +fn segmented(id: &'static str, values: &[(&'static str, &'static str)], now: &str, b: &Brand, cx: &mut Context, set: fn(&str) -> Prefs) -> Div { + div().flex().p(px(2.)).gap(px(2.)).rounded(px(8.)).bg(b.card).children(values.iter().enumerate().map(|(i, &(v, label))| { + let on = v == now; + let hover = b.hair; + div().id((id, i)).h(px(26.)).px(px(10.)).flex().items_center().rounded(px(6.)).cursor_pointer() + .when(on, |d| d.bg(b.page)).when(!on, |d| d.hover(move |s| s.bg(hover))) + .child(text(label, 12., if on { BOLD } else { FontWeight::NORMAL }, if on { b.ink } else { b.gray })) + .on_click(cx.listener(move |_, _, window, cx| theme::save(&set(v), window, cx))) + })) } impl Workspace { @@ -148,52 +186,69 @@ impl Workspace { rows } - /// One of the providers here, as t3code's ProviderInstanceCard: its logo, name and line, its status, Select; open, + /// One of the providers here, as t3code's ProviderInstanceCard: its logo and name, then "Authenticated as ... · + /// its plan". A click selects it (an API provider needs a model first: its models open instead); the chevron opens /// what it runs, its key or server, its models. fn provider_card(&self, i: usize, p: &Provider, s: &Settings, b: &Brand, cx: &mut Context) -> AnyElement { let open = self.ai_open.as_deref() == Some(p.name.as_str()); let (name, kind_, base) = (p.name.clone(), p.kind.clone(), p.base.clone()); - let badge = if p.in_use { ("Selected", b.accent) } else { ("Ready", b.gray) }; - let select: AnyElement = if p.in_use { - div().into_any_element() - } else if p.kind == "subscription" || p.kind == "acp" || p.kind == "local" { + let select: Option> = (!p.in_use && p.kind != "api").then(|| { let mut cmd = vec!["ai".to_string(), p.name.clone()]; if p.kind != "subscription" { cmd.extend(["--endpoint".to_string(), if p.kind == "acp" { p.command.clone() } else { p.base.clone() }]); } - pill(("select", i), None, "Select", false, b).on_click(cx.listener(move |this, _, window, cx| this.change(cmd.clone(), window, cx))).into_any_element() - } else { - text("Pick a model to select", 12., FontWeight::NORMAL, b.gray).into_any_element() + cmd + }); + let status = match (p.account.is_empty(), p.plan.is_empty()) { + (false, false) => format!("Authenticated as {} · {}", masked(&p.account), p.plan), + (false, true) => format!("Authenticated as {}", masked(&p.account)), + (true, false) => p.plan.clone(), + _ => p.about.clone(), }; - let hover = b.hair; - let head = div().id(("provider", i)).px(px(16.)).py(px(16.)).flex().items_center().gap(px(16.)).cursor_pointer().hover(move |st| st.bg(hover)) + let (hover, toggle_name) = (b.hair, name.clone()); + let toggle = cx.listener(move |this: &mut Self, _: &ClickEvent, window: &mut Window, cx: &mut Context| { + cx.stop_propagation(); + this.toggle_provider(&toggle_name, &kind_, &base, window, cx); + }); + let (kind2, base2) = (p.kind.clone(), p.base.clone()); + let head = div().id(("provider", i)).px(px(16.)).py(px(12.)).flex().items_center().gap(px(12.)).cursor_pointer().hover(move |st| st.bg(hover)) + .when(p.in_use, |d| d.bg(b.accent.opacity(0.08))) .child(div().size(px(32.)).flex_none().flex().items_center().justify_center().rounded(SMALL).bg(b.card) .children(crate::app::icons::logo(&p.name, b.ink, b.card).map(|l| l.size(px(18.))))) .child(div().flex_1().min_w_0().flex().flex_col().gap(px(2.)) - .child(div().flex().items_center().gap(px(8.)) - .child(text(p.label.clone(), 14., BOLD, b.ink)) - .child(div().px(px(8.)).h(px(20.)).flex().items_center().rounded(px(10.)).bg(badge.1.opacity(0.16)).child(text(badge.0, 11., BOLD, badge.1))) - .when(!p.plan.is_empty(), |d| d.child(tag(&p.plan, b)))) - .child(text(if p.account.is_empty() { p.about.clone() } else { format!("Signed in as {}", p.account) }, 13., LIGHT, b.gray).truncate())) - .child(select) - .child(text(if open { "−" } else { "+" }, 18., LIGHT, b.gray)) - .on_click(cx.listener(move |this, _, window, cx| { - let opening = this.ai_open.as_deref() != Some(name.as_str()); - this.ai_open = opening.then(|| name.clone()); - this.ai_models = None; - if opening && (kind_ == "local" || kind_ == "acp") { - this.ai_endpoint.update(cx, |s, cx| s.set_value(base.clone(), window, cx)); - } - if opening && (kind_ == "api" || kind_ == "local") { - this.load_models(name.clone(), if kind_ == "local" { base.clone() } else { String::new() }, cx); - } - cx.notify(); + .child(text(p.label.clone(), 14., BOLD, b.ink)) + .child(text(status, 12., LIGHT, b.gray).truncate())) + .when(p.in_use, |d| d.child(div().flex().items_center().gap(px(4.)).child(icon(Icon::Check, b.accent).size(px(14.))).child(text("In use", 12., BOLD, b.accent)))) + .child(div().id(("provider-more", i)).size(px(28.)).flex().items_center().justify_center().rounded(SMALL).hover(move |st| st.bg(hover)) + .tooltip(|w, cx| gpui_kit::component::tooltip::Tooltip::new("Details").build(w, cx)) + .child(icon(if open { Icon::ChevronDown } else { Icon::ChevronRight }, b.gray).size(px(16.))) + .on_click(toggle)) + .on_click(cx.listener(move |this, _, window, cx| match &select { + Some(cmd) => this.change(cmd.clone(), window, cx), + // an API provider is picked with a model: its models, open + None if !this.ai_open.as_deref().is_some_and(|n| n == name) && kind2 == "api" => this.toggle_provider(&name, &kind2, &base2, window, cx), + None => {} })); div().flex().flex_col().when(i > 0, |d| d.border_t_1().border_color(b.hair)).child(head) .when(open, |d| d.child(div().pb(px(8.)).flex().flex_col().children(self.provider_setup(p, s, b, cx)))) .into_any_element() } + /// Opens or closes a provider's details, reading its server and models. + fn toggle_provider(&mut self, name: &str, kind_: &str, base: &str, window: &mut Window, cx: &mut Context) { + let opening = self.ai_open.as_deref() != Some(name); + self.ai_open = opening.then(|| name.to_string()); + self.ai_models = None; + if opening && (kind_ == "local" || kind_ == "acp") { + let base = base.to_string(); + self.ai_endpoint.update(cx, |s, cx| s.set_value(base, window, cx)); + } + if opening && (kind_ == "api" || kind_ == "local") { + self.load_models(name.to_string(), if kind_ == "local" { base.to_string() } else { String::new() }, cx); + } + cx.notify(); + } + /// t3code's Add provider: every provider not here yet, on a tile with its logo and line; picked, set up below. fn add_provider(&self, s: &Settings, b: &Brand, cx: &mut Context) -> AnyElement { let rest: Vec<&Provider> = s.providers.iter().filter(|p| !p.ready && !p.in_use).collect(); @@ -223,11 +278,11 @@ impl Workspace { None => div().into_any_element(), }; div().absolute().inset_0().flex().items_center().justify_center() - .child(div().id("add-backdrop").absolute().inset_0().bg(black().opacity(0.4)).on_click(cx.listener(|this, _, _, cx| { + .child(crate::app::ui::backdrop("add-backdrop", b).on_click(cx.listener(|this, _, _, cx| { this.ai_adding = false; cx.notify(); }))) - .child(div().id("add-provider").relative().w(relative(0.9)).max_h(relative(0.9)).p(px(24.)).flex().flex_col().gap(px(16.)).rounded(CARD).bg(b.card).overflow_y_scroll() + .child(div().id("add-provider").relative().occlude().shadow_2xl().w(relative(0.9)).max_h(relative(0.9)).p(px(24.)).flex().flex_col().gap(px(16.)).rounded(CARD).bg(b.card).overflow_y_scroll() .on_click(|_, _, cx| cx.stop_propagation()) .child(div().flex().items_center() .child(div().flex_1().flex().flex_col().gap(px(4.)).child(text("Add provider", 19., BOLD, b.ink)).child(text("Pick one; the agents you install show up by themselves.", 13., LIGHT, b.gray))) @@ -249,12 +304,10 @@ impl Workspace { match section { Section::General => { let out = s.out.clone(); - let updates = if s.updates { "on" } else { "off" }; vec![group("", vec![ row("Where edits go", s.out.display().to_string(), pill("out", Some(Icon::Folder), "Open", false, b).on_click(move |_, _, cx| cx.open_with_system(&out)), true, b).into_any_element(), row("What renders the video", "auto uses the graphics card when it works, else the processor.", self.choice("encoder", &s.encoders, &s.encoder, &["encoder"], b, cx), false, b).into_any_element(), - row("Updates", "Once a day, the newest release before a run.", self.choice("updates", &["on".into(), "off".into()], updates, &["update"], b, cx), false, b).into_any_element(), - row("Discord", "Shows Playing EditsMaker on your profile, with what you are making and a button to download it.", + row("Discord", "Shows Playing EditsMaker on your profile and what you are making. Your friends also see a Download button: Discord never shows you your own.", Switch::new("discord").checked(theme::prefs().discord).on_click(|on: &bool, window, cx| theme::save(&Prefs { discord: *on, ..theme::prefs() }, window, cx)), false, b).into_any_element(), ], b).into_any_element()] } @@ -323,21 +376,48 @@ impl Workspace { Section::Usage => self.usage_section(b), Section::Appearance => self.appearance(b, cx), Section::About => { - let doctor: AnyElement = match &self.doctor { - Some(d) => card(b).bg(b.page).gap(px(4.)).children(d.lines().map(|l| text(l.to_string(), 12., FontWeight::NORMAL, b.gray).font_family(MONO))).into_any_element(), - None => div().into_any_element(), + let doctor: Option = self.doctor.as_ref().map(|d| card(b).bg(b.page).gap(px(4.)).children(d.lines().map(|l| text(l.to_string(), 12., FontWeight::NORMAL, b.gray).font_family(MONO))).into_any_element()); + let link = |id: &'static str, i: Icon, label: &'static str, url: String, b: &Brand| pill(id, Some(i), label, false, b).on_click(move |_, _, cx| cx.open_url(&url)).into_any_element(); + let repo = format!("https://github.com/{}", crate::update::REPO); + let program = std::env::current_exe().unwrap_or_default(); + let (latest_line, newer): (String, bool) = match &self.latest { + None => ("Asking GitHub...".into(), false), + Some(Ok(t)) if crate::update::newer(t) => (format!("{t} is out; you have {}.", s.version), true), + Some(Ok(t)) => (format!("{t}: up to date."), false), + Some(Err(_)) => ("Unknown: GitHub did not answer (offline?).".into(), false), }; - vec![ + let update: AnyElement = if newer { + primary("update-now", "Update now", b).on_click(cx.listener(|this, _, window, cx| this.launch(vec!["update".into()], window, cx))).into_any_element() + } else { + pill("check-again", Some(Icon::Reset), "Check again", false, b).on_click(cx.listener(|this, _, _, cx| { + this.latest = None; + this.check_latest(cx); + })).into_any_element() + }; + let mut v = vec![ group("", vec![ - row("EditsMaker", format!("Version {}", s.version), pill("site", Some(Icon::Github), "GitHub", false, b).on_click(|_, _, cx| cx.open_url("https://github.com/OnurByte/EditsMaker")), true, b).into_any_element(), - row("Check this computer", "ffmpeg, yt-dlp, whisper and the AI, as edits doctor sees them.", primary("doctor", "Check", b).on_click(cx.listener(|this, _, _, cx| this.check(cx))), false, b).into_any_element(), + row("EditsMaker", format!("Version {}", s.version), link("site", Icon::Github, "GitHub", repo.clone(), b), true, b).into_any_element(), + row("Made by", "Onur Konuk, on GitHub and X.", div().flex().gap(px(8.)).child(link("author-gh", Icon::Github, "OnurByte", crate::update::GITHUB.into(), b)).child(link("author-x", Icon::External, "@onurbinary", crate::update::X.into(), b)), false, b).into_any_element(), + row("Issues", "Something broke, or an idea: say it on GitHub.", link("issues", Icon::External, "Open an issue", format!("{repo}/issues"), b), false, b).into_any_element(), + row("Program", program.display().to_string(), pill("program", Some(Icon::Folder), "Show", false, b).on_click(move |_, _, cx| cx.reveal_path(&program)), false, b).into_any_element(), ], b).into_any_element(), - group("Legal", LEGAL.iter().enumerate().map(|(i, &(title, about, file))| { - let url = format!("https://github.com/OnurByte/EditsMaker/blob/main/{file}"); - row(title, about, pill(("legal", i), Some(Icon::External), "Read", false, b).on_click(move |_, _, cx| cx.open_url(&url)), i == 0, b).into_any_element() - }).collect(), b).into_any_element(), - doctor, - ] + group("Updates", vec![ + row("Latest release", latest_line, update, true, b).into_any_element(), + row("Update by itself", "Once a day, the newest release before a run.", Switch::new("auto-update").checked(s.updates).on_click(cx.listener(|this, on: &bool, window, cx| { + this.change(vec!["update".into(), if *on { "on" } else { "off" }.into()], window, cx); + })), false, b).into_any_element(), + row("Roll back", "Back to the version the last update replaced.", self.button("rollback", "Roll back", &["update", "rollback"], b, cx), false, b).into_any_element(), + ], b).into_any_element(), + group("This computer", vec![ + row("Check this computer", "ffmpeg, yt-dlp, whisper and the AI, as edits doctor sees them.", primary("doctor", "Check", b).on_click(cx.listener(|this, _, _, cx| this.check(cx))), true, b).into_any_element(), + ], b).into_any_element(), + ]; + v.extend(doctor); + v.push(group("Legal", LEGAL.iter().enumerate().map(|(i, &(title, about, file))| { + let url = format!("https://github.com/OnurByte/EditsMaker/blob/main/{file}"); + row(title, about, pill(("legal", i), Some(Icon::External), "Read", false, b).on_click(move |_, _, cx| cx.open_url(&url)), i == 0, b).into_any_element() + }).collect(), b).into_any_element()); + v } } } @@ -372,55 +452,93 @@ impl Workspace { ] } - /// t3code's appearance: colours and themes (Omarchy's live one too), the interface, the type. + /// t3code's AppearanceSettingsPanel: the mode tiles (System, Light, Dark, each a little window in its colours), + /// the theme library (EditsMaker's own, and Omarchy's live one where it runs), then Interface and Typography rows, + /// each with a reset once it is off its default. fn appearance(&self, b: &Brand, cx: &mut Context) -> Vec { let p = theme::prefs(); - let hex = |v: u32| -> Hsla { rgb(v).into() }; - let mut modes: Vec<(&str, Icon, String, [Hsla; 3])> = vec![ - ("system", Icon::Sliders, "System".into(), [hex(0xFFFFFF), hex(0x0D1117), hex(0x9A958A)]), - ("light", Icon::Sun, "Light".into(), [hex(0xFFFFFF), hex(0xF6F4EF), hex(0x0B0B0C)]), - ("dark", Icon::Moon, "Dark".into(), [hex(0x0D1117), hex(0x161B22), hex(0xF4F1EA)]), - ]; - if theme::omarchy_dir().is_some() { + let d = Prefs::default(); + let omarchy = theme::omarchy_dir().is_some(); + let on_omarchy = p.mode == "omarchy" && omarchy; + let accent = theme::hex_of(&p.accent); + let (light, dark) = (theme::palette(false, accent), theme::palette(true, accent)); + let tiles = [("system", "System"), ("light", "Light"), ("dark", "Dark")].into_iter().map(|(m, label)| { + let on = !on_omarchy && p.mode == m; + let preview = match m { + "light" => wireframe(&light).w_full(), + "dark" => wireframe(&dark).w_full(), + // the light one, its right half covered by the dark one + _ => div().w_full().h(px(96.)).relative().overflow_hidden().rounded(SMALL) + .child(wireframe(&light).absolute().inset_0()) + .child(div().absolute().top_0().bottom_0().right_0().w(relative(0.5)).overflow_hidden() + .child(wireframe(&dark).absolute().top_0().right_0().h_full().w(relative(2.)))), + }; + mode_tile(m, preview, label, on, b).on_click(cx.listener(move |_, _, window, cx| { + theme::save(&Prefs { mode: m.into(), mode_picked: true, ..theme::prefs() }, window, cx); + })).into_any_element() + }).collect::>(); + // the theme library: EditsMaker's colours, and Omarchy's + let mut themes: Vec<(&'static str, String, String, Brand)> = vec![("edits", "EditsMaker".into(), "Ink and paper, one warm grey, your accent".into(), if theme::is_dark(cx) && !on_omarchy { dark } else { light })]; + if omarchy { let name = std::fs::read_to_string(crate::util::home().join(".local/state/omarchy/current/theme.name")).unwrap_or_default(); - let ob = if p.mode == "omarchy" { *b } else { theme::brand(cx) }; - modes.push(("omarchy", Icon::Palette, format!("Omarchy · {}", name.trim()), [ob.page, ob.card, ob.ink])); + if let Some(ob) = theme::omarchy_brand() { + themes.push(("omarchy", format!("Omarchy · {}", name.trim()), "Follows the theme you pick in Omarchy, live".into(), ob)); + } } - let tiles = modes.into_iter().map(|(m, i, label, colors)| { - let (on, hover) = (p.mode == m, b.hair); - div().id(m).w(px(160.)).p(px(16.)).flex().flex_col().gap(px(8.)).rounded(SMALL).cursor_pointer().bg(if on { b.accent.opacity(0.14) } else { b.page }).hover(move |st| st.bg(hover)) - .child(div().flex().items_center().justify_between().child(dots(colors, b)).child(icon(i, b.gray).size(px(16.)))) - .child(text(label, 13., if on { BOLD } else { FontWeight::NORMAL }, b.ink).truncate()) + let cards = themes.into_iter().map(|(id, label, about, c)| { + let on = if id == "omarchy" { on_omarchy } else { !on_omarchy }; + let hover = b.accent.opacity(0.06); + div().id(SharedString::from(format!("theme-{id}"))).flex_1().min_w(px(220.)).p(px(12.)).flex().items_center().gap(px(12.)).rounded(px(12.)).cursor_pointer() + .bg(if on { b.accent.opacity(0.14) } else { b.page }).border_1().border_color(if on { b.accent } else { b.hair }) + .when(!on, |d| d.hover(move |s| s.bg(hover))) + .child(div().size(px(40.)).flex_none().rounded_full().overflow_hidden().border_1().border_color(b.hair).flex() + .child(div().w(relative(0.5)).h_full().bg(c.page)).child(div().w(relative(0.5)).h_full().bg(c.card).flex().items_center().justify_center().child(div().size(px(8.)).rounded_full().bg(c.accent)))) + .child(div().flex_1().min_w_0().flex().flex_col().gap(px(2.)) + .child(text(label, 13., BOLD, b.ink).truncate()) + .child(text(about, 12., LIGHT, b.gray).truncate())) + .when(on, |d| d.child(icon(Icon::Check, b.accent).size(px(16.)))) .on_click(cx.listener(move |_, _, window, cx| { - theme::save(&Prefs { mode: m.into(), ..theme::prefs() }, window, cx); + let p = theme::prefs(); + // back from Omarchy: the mode picked before, else the system's + let mode = if id == "omarchy" { "omarchy".to_string() } else if p.mode == "omarchy" { "system".into() } else { p.mode.clone() }; + theme::save(&Prefs { mode, mode_picked: true, ..p }, window, cx); })) - }); - let width = div().flex().gap(px(8.)).children(["narrow", "normal", "wide"].into_iter().map(|w| { - pill(w, None, w, p.width == w, b).on_click(cx.listener(move |_, _, window, cx| theme::save(&Prefs { width: w.into(), ..theme::prefs() }, window, cx))) - })); + .into_any_element() + }).collect::>(); + let reset = |id: &'static str, show: bool, f: fn(Prefs) -> Prefs, b: &Brand, cx: &mut Context| -> AnyElement { + if !show { + return div().into_any_element(); + } + crate::app::ui::icon_button(id, Icon::Reset, b).size(px(24.)) + .tooltip(|w, cx| gpui_kit::component::tooltip::Tooltip::new("Reset to default").build(w, cx)) + .on_click(cx.listener(move |_, _, window, cx| theme::save(&f(theme::prefs()), window, cx))).into_any_element() + }; // t3code's accent; Omarchy's own when following Omarchy - let accent: AnyElement = if p.mode == "omarchy" && theme::omarchy_dir().is_some() { + let accents: AnyElement = if on_omarchy { text("Omarchy's accent", 13., FontWeight::NORMAL, b.gray).into_any_element() } else { - div().flex().gap(px(8.)).children(theme::ACCENTS.iter().enumerate().map(|(i, &(name, hexv))| { - let on = p.accent.eq_ignore_ascii_case(hexv); - div().id(("accent", i)).size(px(28.)).rounded_full().cursor_pointer().bg(theme::hex_of(hexv)) - .when(on, |d| d.border_2().border_color(b.ink)) - .tooltip(move |window, cx| gpui_kit::component::tooltip::Tooltip::new(name).build(window, cx)) - .on_click(cx.listener(move |_, _, window, cx| theme::save(&Prefs { accent: hexv.into(), ..theme::prefs() }, window, cx))) - })).into_any_element() + div().flex().items_center().gap(px(8.)).child(reset("reset-accent", p.accent != d.accent, |p| Prefs { accent: Prefs::default().accent, ..p }, b, cx)) + .children(theme::ACCENTS.iter().enumerate().map(|(i, &(name, hexv))| { + let on = p.accent.eq_ignore_ascii_case(hexv); + div().id(("accent", i)).size(px(24.)).rounded_full().cursor_pointer().bg(theme::hex_of(hexv)) + .when(on, |d| d.border_2().border_color(b.ink)) + .tooltip(move |window, cx| gpui_kit::component::tooltip::Tooltip::new(name).build(window, cx)) + .on_click(cx.listener(move |_, _, window, cx| theme::save(&Prefs { accent: hexv.into(), ..theme::prefs() }, window, cx))) + })).into_any_element() }; - let size = div().flex().gap(px(8.)).children([14.0f32, 15., 16.].into_iter().map(|z| { - pill(("size", z as usize), None, format!("{z}"), p.font_size == z, b).on_click(cx.listener(move |_, _, window, cx| theme::save(&Prefs { font_size: z, ..theme::prefs() }, window, cx))) - })); + let width = div().flex().items_center().gap(px(8.)).child(reset("reset-width", p.width != d.width, |p| Prefs { width: Prefs::default().width, ..p }, b, cx)) + .child(segmented("width", &[("narrow", "Narrow"), ("normal", "Comfortable"), ("wide", "Wide")], &p.width, b, cx, |v| Prefs { width: v.into(), ..theme::prefs() })); + let size = div().flex().items_center().gap(px(8.)).child(reset("reset-size", p.font_size != d.font_size, |p| Prefs { font_size: Prefs::default().font_size, ..p }, b, cx)) + .child(segmented("size", &[("13", "13"), ("14", "14"), ("15", "15"), ("16", "16"), ("17", "17")], &format!("{}", p.font_size), b, cx, |v| Prefs { font_size: v.parse().unwrap_or(15.), ..theme::prefs() })); vec![ - div().flex().flex_col().gap(px(8.)).child(text("Colors & themes", 13., BOLD, b.gray)).child(div().flex().flex_wrap().gap(px(8.)).children(tiles)) - .when(theme::omarchy_dir().is_some(), |d| d.child(text("Omarchy follows the theme you pick in Omarchy, as it changes.", 13., LIGHT, b.gray))).into_any_element(), + div().flex().flex_col().gap(px(12.)) + .child(div().flex().gap(px(12.)).children(tiles)) + .child(div().flex().flex_wrap().gap(px(8.)).children(cards)).into_any_element(), group("Interface", vec![ - row("Accent", "What is selected, on and focused, and the button that does the thing.", accent, true, b).into_any_element(), + row("Accent", "What is selected, on and focused, and the button that does the thing.", accents, true, b).into_any_element(), row("Chat width", "How wide the messages and the composer grow on a large screen.", width, false, b).into_any_element(), ], b).into_any_element(), - group("Typography", vec![row("Text size", "Everything but the frames and the log.", size, true, b).into_any_element()], b).into_any_element(), + group("Typography", vec![row("Interface font size", "Everything but the frames and the log.", size, true, b).into_any_element()], b).into_any_element(), ] } @@ -439,6 +557,9 @@ impl Workspace { if s == Section::Usage { this.usage = Some(crate::app::usage::read(&this.past)); } + if s == Section::About { + this.check_latest(cx); + } cx.notify(); })) .into_any_element() @@ -454,11 +575,11 @@ impl Workspace { _ => None, }; div().absolute().inset_0().flex().items_center().justify_center() - .child(div().id("backdrop").absolute().inset_0().bg(black().opacity(0.5)).on_click(cx.listener(|this, _, _, cx| { + .child(crate::app::ui::backdrop("backdrop", &b).on_click(cx.listener(|this, _, _, cx| { this.settings_open = None; cx.notify(); }))) - .child(div().id("settings-window").relative().w(px(920.)).max_w(relative(0.94)).h(relative(0.86)).max_h(px(680.)).flex().rounded(CARD).bg(b.card).overflow_hidden() + .child(div().id("settings-window").relative().occlude().shadow_2xl().w(px(920.)).max_w(relative(0.94)).h(relative(0.86)).max_h(px(680.)).flex().rounded(CARD).bg(b.card).overflow_hidden() .on_click(|_, _, cx| cx.stop_propagation()) .child(div().w(px(200.)).flex_none().p(px(16.)).flex().flex_col().gap(px(2.)) .child(div().px(px(8.)).pb(px(16.)).flex().items_center().gap(px(8.)).child(icon(Icon::Settings, b.gray).size(px(16.))).child(text("Settings", 15., BOLD, b.ink))) @@ -492,9 +613,12 @@ mod tests { assert_eq!(found("").len(), 7); assert_eq!(found("discord"), [Section::General]); assert_eq!(found("privacy"), [Section::About]); + assert_eq!(found("rollback"), [Section::About]); for (_, _, f) in super::LEGAL { assert!(std::path::Path::new(env!("CARGO_MANIFEST_DIR")).join(f).is_file(), "{f} is in the repository"); } assert!(found("zzz").is_empty()); + assert_eq!(super::masked("onur@gmail.com"), "o•••@gmail.com"); + assert_eq!(super::masked("onur"), "onur"); } } diff --git a/src/app/sidebar.rs b/src/app/sidebar.rs index 8f81a46..74b98ee 100644 --- a/src/app/sidebar.rs +++ b/src/app/sidebar.rs @@ -34,6 +34,12 @@ pub fn matches(q: &str, subject: &str, title: &str) -> bool { q.to_lowercase().split_whitespace().all(|w| hay.contains(w)) } +/// t3code's shortcut hint in the search: ⌘K on a Mac, Ctrl K elsewhere. +pub fn shortcut(b: &Brand) -> Div { + div().px(px(6.)).h(px(18.)).flex().items_center().rounded(px(4.)).border_1().border_color(b.hair) + .child(text(if cfg!(target_os = "macos") { "⌘K" } else { "Ctrl K" }, 11., FontWeight::NORMAL, b.gray)) +} + impl Workspace { fn place(&self, id: &'static str, i: Icon, label: &'static str, to: Route, b: &Brand, cx: &mut Context) -> Stateful
{ let on = self.route == to; @@ -116,7 +122,7 @@ impl Workspace { .child(text("EditsMaker", 15., BOLD, b.ink).flex_1()) .child(toggle)) .child(div().px(px(8.)).flex().flex_col().gap(px(2.)).children(places)) - .child(div().px(px(8.)).pt(px(16.)).child(Input::new(&self.thread_search).prefix(icon(Icon::Search, b.gray).size(px(14.))).cleanable(true))) + .child(div().px(px(8.)).pt(px(16.)).child(Input::new(&self.thread_search).prefix(icon(Icon::Search, b.gray).size(px(14.))).suffix(shortcut(&b)).cleanable(true))) .child(text("Edits", 12., FontWeight::NORMAL, b.gray).px(px(16.)).pt(px(16.)).pb(px(8.))) .child(div().id("threads").flex_1().min_h_0().overflow_y_scroll().px(px(8.)).pb(px(8.)).flex().flex_col().gap(px(2.)).children(list) .when(empty, |d| d.child(text(if q.trim().is_empty() { "Nothing made yet." } else { "No edit like that." }, 13., crate::app::theme::LIGHT, b.gray).px(px(8.))))) diff --git a/src/app/theme.rs b/src/app/theme.rs index 6fd71a4..f79b79d 100644 --- a/src/app/theme.rs +++ b/src/app/theme.rs @@ -56,6 +56,9 @@ pub struct Prefs { /// Discord shows "Playing EditsMaker" and what is being made; on unless turned off #[serde(default = "on")] pub discord: bool, + /// the mode was picked in Appearance; until then Omarchy's computers follow Omarchy, the rest the system + #[serde(default)] + pub mode_picked: bool, } fn red() -> String { @@ -68,7 +71,7 @@ fn on() -> bool { impl Default for Prefs { fn default() -> Self { - Prefs { mode: "system".into(), width: "normal".into(), font_size: 15., accent: red(), onboarded: false, discord: true } + Prefs { mode: "system".into(), width: "normal".into(), font_size: 15., accent: red(), onboarded: false, discord: true, mode_picked: false } } } @@ -77,7 +80,11 @@ fn prefs_file() -> PathBuf { } pub fn prefs() -> Prefs { - std::fs::read_to_string(prefs_file()).ok().and_then(|t| serde_json::from_str(&t).ok()).unwrap_or_default() + let mut p: Prefs = std::fs::read_to_string(prefs_file()).ok().and_then(|t| serde_json::from_str(&t).ok()).unwrap_or_default(); + if !p.mode_picked && omarchy_dir().is_some() { + p.mode = "omarchy".into(); + } + p } pub fn save(p: &Prefs, window: &mut Window, cx: &mut App) { @@ -117,6 +124,24 @@ fn omarchy() -> Option<(Brand, bool)> { ink: c("foreground")?, gray: c("muted").or(c("dark_foreground"))?, red_text: c("red")?, accent: c("accent").or(c("blue"))? }, dark)) } +/// Omarchy's theme as brand colours, for its card in Appearance. +pub fn omarchy_brand() -> Option { + omarchy().map(|x| x.0) +} + +pub fn is_dark(cx: &App) -> bool { + Theme::global(cx).is_dark() +} + +/// EditsMaker's own colours, dark or light, with an accent. +pub fn palette(dark: bool, accent: Hsla) -> Brand { + if dark { + Brand { page: hex(0x0D1117), card: hex(0x161B22), hair: hex(0x30363D), ink: hex(0xF4F1EA), gray: hex(0x9A958A), red_text: hex(0xF25247), accent } + } else { + Brand { page: hex(0xFFFFFF), card: hex(0xF6F4EF), hair: hex(0xE4E0D7), ink: hex(0x0B0B0C), gray: hex(0x6F6A60), red_text: hex(0xC8261E), accent } + } +} + pub fn brand(cx: &App) -> Brand { let p = prefs(); if p.mode == "omarchy" { @@ -124,12 +149,7 @@ pub fn brand(cx: &App) -> Brand { return b; } } - let accent = hex_of(&p.accent); - if Theme::global(cx).is_dark() { - Brand { page: hex(0x0D1117), card: hex(0x161B22), hair: hex(0x30363D), ink: hex(0xF4F1EA), gray: hex(0x9A958A), red_text: hex(0xF25247), accent } - } else { - Brand { page: hex(0xFFFFFF), card: hex(0xF6F4EF), hair: hex(0xE4E0D7), ink: hex(0x0B0B0C), gray: hex(0x6F6A60), red_text: hex(0xC8261E), accent } - } + palette(Theme::global(cx).is_dark(), hex_of(&p.accent)) } /// Helvetica, or the stand-in each system has. diff --git a/src/app/ui.rs b/src/app/ui.rs index 8d8c5f9..5249c82 100644 --- a/src/app/ui.rs +++ b/src/app/ui.rs @@ -51,10 +51,17 @@ pub fn tag(label: &str, b: &Brand) -> Div { .child(text(label.to_string(), 12., crate::app::theme::BOLD, c)) } -/// A modal sheet over the window: a dimmed backdrop that closes it, and the card in the middle. +/// What lies over the blurred page (Workspace::blurred) under a modal: a light veil, taking every click and scroll so +/// nothing behind moves. A click on it closes the modal. +pub fn backdrop(id: impl Into, b: &Brand) -> Stateful
{ + div().id(ElementId::Name(id.into())).absolute().inset_0().occlude().bg(b.page.opacity(0.25)) + .child(div().size_full().bg(black().opacity(0.25))) +} + +/// A modal sheet over the window: a frosted backdrop that closes it, and the card in the middle. pub fn sheet(id: &'static str, width: f32, b: &Brand, close: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static) -> (Stateful
, Stateful
) { - let backdrop = div().id(SharedString::from(format!("{id}-backdrop"))).absolute().inset_0().bg(black().opacity(0.45)).on_click(close); - let card = div().id(id).relative().w(px(width)).max_w(relative(0.94)).max_h(relative(0.9)).flex().flex_col().rounded(CARD).bg(b.card).overflow_y_scroll() + let backdrop = backdrop(format!("{id}-backdrop"), b).on_click(close); + let card = div().id(id).relative().occlude().shadow_2xl().w(px(width)).max_w(relative(0.94)).max_h(relative(0.9)).flex().flex_col().rounded(CARD).bg(b.card).overflow_y_scroll() .on_click(|_, _, cx| cx.stop_propagation()); (backdrop, card) } diff --git a/src/app/workspace.rs b/src/app/workspace.rs index 362f637..6a9a87d 100644 --- a/src/app/workspace.rs +++ b/src/app/workspace.rs @@ -6,7 +6,6 @@ use crate::app::theme::{self, brand}; use gpui_kit::component::input::{InputEvent, InputState, TextareaState}; use gpui_kit::component::notification::Notification; use gpui_kit::component::WindowExt; -use gpui_kit::prelude::FluentBuilder; use gpui_kit::*; use std::path::{Path, PathBuf}; use std::time::Duration; @@ -83,6 +82,8 @@ pub struct Review { pub notes: Vec, pub note: Entity, pub general: Entity, + /// the clip playing, once its size is read + pub player: Option, } pub struct Workspace { @@ -122,6 +123,8 @@ pub struct Workspace { pub ai_more: bool, /// what `edits doctor` said, in About pub doctor: Option, + /// the newest release, asked for when About opens + pub latest: Option>, /// the setting being changed pub changing: Option, pub review: Option, @@ -213,7 +216,7 @@ impl Workspace { .detach(); let mut this = Self { input, settings_open: None, ai_open: None, ai_key, ai_endpoint, ai_models: None, ai_adding: false, ai_more: false, settings_search, welcome: review.is_none() && !theme::prefs().onboarded, files: vec![], preset: None, overlay: None, post: vec![], picker: None, flows: None, flow_source: None, flow_post: vec![], flow_every: 60, jobs: vec![], past: runs::past(&runs::out_dir()), route: Route::New, show_log: false, - market: Market::default(), settings: None, doctor: None, changing: None, review: None, review_only: review.is_some(), + market: Market::default(), settings: None, doctor: None, latest: None, changing: None, review: None, review_only: review.is_some(), sidebar_open: true, thread_search, market_search, library_search, git_url, model_lists: Default::default(), welcome_step: 0, sign_in, usage: None, _subscriptions: subscriptions }; crate::app::discord::start(); // the composer's model picker shows the AI in use from the start @@ -228,6 +231,11 @@ impl Workspace { } pub fn go(&mut self, to: Route, cx: &mut Context) { + if to != Route::Review { + if let Some(p) = self.review.as_mut().and_then(|r| r.player.as_mut()) { + p.pause(); + } + } self.route = to; if matches!(to, Route::Market | Route::Automations) && self.market.packs.is_none() { self.load_market(cx); @@ -467,6 +475,9 @@ impl Workspace { /// The settings window, at a section. pub fn open_settings(&mut self, at: Section, cx: &mut Context) { self.settings_open = Some(at); + if at == Section::About { + self.check_latest(cx); + } if at == Section::Usage { self.usage = Some(crate::app::usage::read(&self.past)); } @@ -510,6 +521,22 @@ impl Workspace { .detach(); } + /// The newest release on GitHub, for About. + pub fn check_latest(&mut self, cx: &mut Context) { + if matches!(self.latest, Some(Ok(_))) { + return; + } + self.latest = None; + cx.spawn(async move |this, cx| { + let t = cx.background_executor().spawn(async { crate::update::latest() }).await; + let _ = this.update(cx, |this, cx| { + this.latest = Some(t); + cx.notify(); + }); + }) + .detach(); + } + /// `edits doctor`, for About. pub fn check(&mut self, cx: &mut Context) { self.doctor = Some("Checking...".into()); @@ -532,12 +559,29 @@ impl Workspace { this.add_note(window, cx); } })); - self.review = Some(Review { clip: clip.clone(), sheet: None, at: 0, spot: None, notes: vec![], note, general }); + self.review = Some(Review { clip: clip.clone(), sheet: None, at: 0, spot: None, notes: vec![], note, general, player: None }); self.route = Route::Review; + let c = clip.clone(); + cx.spawn(async move |this, cx| { + let p = cx.background_executor().spawn(async move { crate::app::player::Player::open(&c, 0.0) }).await; + let _ = this.update(cx, |this, cx| { + if let Some(r) = this.review.as_mut().filter(|r| r.clip == p.clip) { + r.player = Some(p); + } + cx.notify(); + }); + }) + .detach(); cx.spawn(async move |this, cx| { let sheet = cx.background_executor().spawn(async move { runs::sheet(&clip) }).await; let _ = this.update(cx, |this, cx| { if let Some(r) = this.review.as_mut() { + // the sheet knows the length too, should the player's probe not + if let (Some(p), Ok(sh)) = (r.player.as_mut(), &sheet) { + if p.total <= 0.0 { + p.total = sh.total; + } + } r.sheet = Some(sheet); } cx.notify(); @@ -548,9 +592,9 @@ impl Workspace { } } -impl Render for Workspace { - fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { - let b = brand(cx); +impl Workspace { + /// The window's page: the sidebar and the route in view. + fn page(&mut self, window: &mut Window, cx: &mut Context) -> Vec { let main = match self.route { Route::Market => self.marketplace(false, window, cx).into_any_element(), Route::Automations => self.marketplace(true, window, cx).into_any_element(), @@ -558,12 +602,53 @@ impl Render for Workspace { Route::Review => self.review_screen(window, cx).into_any_element(), _ => self.chat_view(window, cx).into_any_element(), }; - let settings = self.settings_open.map(|at| self.settings_window(at, window, cx)); + let mut v = vec![]; + if !self.review_only { + v.push(self.sidebar(cx).into_any_element()); + } + v.push(div().flex_1().min_w_0().h_full().flex().flex_col().child(main).into_any_element()); + v + } + + /// The page blurred, under a modal: GPUI has no blur filter, so the page is drawn again at small offsets on a + /// ring and the copies averaged (each one over the last at 1/(n+1)), a box blur. It sits under the modal's + /// backdrop, which takes every click and scroll. + fn blurred(&mut self, window: &mut Window, cx: &mut Context) -> AnyElement { + let page = brand(cx).page; + let mut layer = div().absolute().inset_0().overflow_hidden(); + for (i, (dx, dy)) in blur_offsets(6.).into_iter().enumerate() { + let copy = div().id(("blur", i)).absolute().top(px(dy)).left(px(dx)).size_full().flex().bg(page) + .opacity(1. / (i as f32 + 1.)).children(self.page(window, cx)); + layer = layer.child(copy); + } + layer.into_any_element() + } +} + +/// Where the blur's copies of the page go: the middle, a ring of eight `r` / 2 px out, then eight more `r` px out, +/// turned half a step so the two rings fill each other's gaps. +pub fn blur_offsets(r: f32) -> Vec<(f32, f32)> { + let mut v = vec![(0., 0.)]; + for (radius, turn) in [(r / 2., 0.), (r, 0.5)] { + v.extend((0..8).map(|k| { + let a = (k as f32 + turn) * std::f32::consts::FRAC_PI_4; + (radius * a.cos(), radius * a.sin()) + })); + } + v +} + +impl Render for Workspace { + fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl IntoElement { + let b = brand(cx); + let settings = self.settings_open.map(|at| self.settings_window(at, window, cx).into_any_element()); let pack = self.market.open.clone().and_then(|id| self.pack_sheet(&id, cx)); if self.welcome { return div().size_full().relative().flex().bg(b.page).text_color(b.ink).font_family(theme::FONT).font_weight(theme::LIGHT) .child(self.welcome(window, cx)).children(settings); } + let page = self.page(window, cx); + let blur = (settings.is_some() || pack.is_some()).then(|| self.blurred(window, cx)); div().size_full().relative().flex().bg(b.page).text_color(b.ink).font_family(theme::FONT).font_weight(theme::LIGHT) .on_drop(cx.listener(|this, paths: &ExternalPaths, window, cx| { if let Some(p) = paths.paths().first() { @@ -571,8 +656,21 @@ impl Render for Workspace { } })) .on_action(cx.listener(|this, _: &crate::app::ToggleSidebar, _, cx| this.toggle_sidebar(cx))) - .when(!self.review_only, |d| d.child(self.sidebar(cx))) - .child(div().flex_1().min_w_0().h_full().flex().flex_col().child(main)) + // t3code's search shortcut: the search of the page in view, else the edits' in the sidebar + .on_action(cx.listener(|this, _: &crate::app::Search, window, cx| { + let s = match this.route { + Route::Market | Route::Automations => this.market_search.clone(), + Route::Library => this.library_search.clone(), + _ => { + this.sidebar_open = true; + this.thread_search.clone() + } + }; + s.update(cx, |s, cx| s.focus(window, cx)); + cx.notify(); + })) + .children(page) + .children(blur) .children(pack) .children(settings) } @@ -603,7 +701,7 @@ fn copy_file(p: &Path) -> bool { #[cfg(test)] mod tests { // not super::*: gpui_kit's own `test` attribute would come with it - use super::{commands, file_uri}; + use super::{blur_offsets, commands, file_uri}; use std::path::PathBuf; fn s(v: &[&str]) -> Vec { @@ -618,6 +716,9 @@ mod tests { assert_eq!(commands("https://youtu.be/x --preset mine", &[], Some("akis-whip"), None), [s(&["https://youtu.be/x", "--preset", "mine"])], "a typed preset wins"); assert_eq!(commands("x", &[], None, Some("stardust")), [s(&["x", "--overlay", "stardust"])], "a 3D scene goes over it"); assert!(commands(" ", &[], None, None).is_empty()); + let ring = blur_offsets(5.); + assert_eq!(ring.len(), 17); + assert!(ring[9..].iter().all(|(x, y)| ((x * x + y * y).sqrt() - 5.).abs() < 1e-4), "the outer copies sit on a ring"); assert_eq!(file_uri(std::path::Path::new("/home/a/Videos/Halime Sultan'ın.mp4")), "file:///home/a/Videos/Halime%20Sultan%27%C4%B1n.mp4"); } diff --git a/src/main.rs b/src/main.rs index 8315015..b68389c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -835,7 +835,7 @@ pub fn packs_json() -> serde_json::Value { let preset = presets.first(); let file = m.preview.as_ref().map(|f| packs::dir().join(&m.id).join(f)).filter(|f| !built_in && f.is_file()); serde_json::json!({"id": m.id, "name": m.name, "version": m.version, "author": m.author, "description": m.description, - "kinds": m.kinds, "tags": m.tags, "trusted": packs::trusted(p), + "kinds": m.kinds, "tags": packs::tidy_tags(&m.tags), "trusted": packs::trusted(p), "site": p.automations().first().map(|a| a.0.site.clone()), "sites": p.automations().iter().map(|a| a.0.site.clone()).collect::>(), "preset": preset.map(|p| &p.name), "feeds": m.feeds, "presets": presets.iter().map(|p| serde_json::json!({"name": p.name, "about": p.about})).collect::>(), "topics": m.topics.iter().map(|t| serde_json::json!({"key": t.key, "name": t.name, "feeds": t.feeds})).collect::>(), diff --git a/src/packs.rs b/src/packs.rs index 6c7929f..86d126b 100644 --- a/src/packs.rs +++ b/src/packs.rs @@ -421,6 +421,37 @@ pub fn every() -> Vec { } /// The packs that are on: what presets, skills, feeds and automations come from. +/// The marketplace's tags: a few words a person would look for, not how a preset moves. A pack carries at most three. +pub const TAGS: [&str; 10] = ["hype", "sad", "anime", "cinematic", "glitch", "retro", "meme", "news", "3d", "automation"]; + +/// A pack's tags as the marketplace shows them: each word mapped onto TAGS (a preset's "velocity" is hype, "rgb" +/// glitch), the rest dropped, the first three kept. +pub fn tidy_tags>(raw: &[S]) -> Vec { + let mut out: Vec = vec![]; + for t in raw { + let t = t.as_ref().trim().to_lowercase(); + let m = match t.as_str() { + "fast" | "velocity" | "hype" | "phonk" | "drop" => "hype", + "sad" | "fade" | "dreamy" | "emotional" | "chill" => "sad", + "anime" => "anime", + "cinema" | "cinematic" | "letterbox" | "film" => "cinematic", + "glitch" | "rgb" | "strobe" => "glitch", + "retro" | "vhs" | "tape" => "retro", + "comic" | "split" | "meme" | "funny" => "meme", + "news" | "rss" | "feed" => "news", + "3d" | "scene" | "overlay" => "3d", + "automation" | "post" | "agent" | "mcp" | "skills" | "tiktok" | "instagram" | "youtube" => "automation", + _ => continue, + }; + debug_assert!(TAGS.contains(&m)); + if !out.iter().any(|x| x == m) { + out.push(m.into()); + } + } + out.truncate(3); + out +} + pub fn all() -> Vec { let off = disabled(); every().into_iter().filter(|p| !off.contains(&p.manifest.id)).collect() @@ -774,7 +805,7 @@ pub fn make(d: &Path, preset: Option<&str>, id: Option<&str>, opml: Option<&Path .or(p.as_ref().map(|p| p.about.clone()).filter(|a| !a.is_empty())).or(about).unwrap_or_default(), kinds, preview: Some(own_picture.clone().unwrap_or_else(|| "preview.svg".into())), - tags: old.as_ref().map(|m| m.tags.clone()).filter(|t| !t.is_empty()).unwrap_or_else(|| p.as_ref().map(|p| p.tags().iter().map(|t| t.to_string()).collect()).unwrap_or_default()), + tags: tidy_tags(&old.as_ref().map(|m| m.tags.clone()).filter(|t| !t.is_empty()).unwrap_or_else(|| p.as_ref().map(|p| p.tags().iter().map(|t| t.to_string()).collect()).unwrap_or_default())), license: old.as_ref().and_then(|m| m.license.clone()), source: old.as_ref().and_then(|m| m.source.clone()), settings: old.as_ref().map(|m| m.settings.clone()).unwrap_or_default(), @@ -931,6 +962,16 @@ pub fn gallery(d: &Path) -> Result { mod tests { use super::*; + #[test] + fn a_pack_carries_at_most_three_of_the_ten_tags() { + assert_eq!(tidy_tags(&["slow", "9:16", "velocity", "rgb", "fade", "comic"]), ["hype", "glitch", "sad"]); + for p in built_in() { + let t = tidy_tags(&p.manifest.tags); + assert_eq!(t, p.manifest.tags, "{}: its tags are already tidy", p.manifest.id); + assert!(t.len() <= 3 && t.iter().all(|x| TAGS.contains(&x.as_str())), "{}", p.manifest.id); + } + } + #[test] fn built_in_packs_are_whole() { assert!(BUILT_IN_PACKS.len() >= 15); diff --git a/src/update.rs b/src/update.rs index 2cc639b..0832035 100644 --- a/src/update.rs +++ b/src/update.rs @@ -29,7 +29,7 @@ pub fn latest() -> Result { v["tag_name"].as_str().map(String::from).ok_or("no release found".into()) } -fn newer(tag: &str) -> bool { +pub fn newer(tag: &str) -> bool { matches!((parse(tag), parse(env!("CARGO_PKG_VERSION"))), (Some(a), Some(b)) if a > b) }