Compare commits
2 commits
dac40537bf
...
c1ab31054c
Author | SHA1 | Date | |
---|---|---|---|
c1ab31054c | |||
dd44079987 |
9 changed files with 219 additions and 12 deletions
4
.envrc
4
.envrc
|
@ -1,4 +1,4 @@
|
|||
strict_env
|
||||
|
||||
export HOUHOU_SRC=$PWD
|
||||
export DATABASE_URL=$HOUHOU_SRC/src-tauri/SrsDatabase.sqlite
|
||||
|
||||
use flake
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -25,3 +25,4 @@ dist-ssr
|
|||
|
||||
houhou.db
|
||||
src/data/kanadata.json
|
||||
.direnv
|
||||
|
|
112
flake.lock
Normal file
112
flake.lock
Normal file
|
@ -0,0 +1,112 @@
|
|||
{
|
||||
"nodes": {
|
||||
"fenix": {
|
||||
"inputs": {
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-analyzer-src": "rust-analyzer-src"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1686464419,
|
||||
"narHash": "sha256-2hnB1rRENavNQRmroJqRJlAXJxaUxFuNKxWTHtXBUlE=",
|
||||
"owner": "nix-community",
|
||||
"repo": "fenix",
|
||||
"rev": "f7169edb93ce396ff1f0d94620241c6390f49f54",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"id": "fenix",
|
||||
"type": "indirect"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1685518550,
|
||||
"narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1686412476,
|
||||
"narHash": "sha256-inl9SVk6o5h75XKC79qrDCAobTD1Jxh6kVYTZKHzewA=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "21951114383770f96ae528d0ae68824557768e81",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1686544600,
|
||||
"narHash": "sha256-QRSZuGex5W+41zqm7NHXcokkgev8WULS8xGyQEpMXtI=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c1944ee51b8d6885aaa5470fbb010b86c01d6470",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"fenix": "fenix",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
}
|
||||
},
|
||||
"rust-analyzer-src": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1686406537,
|
||||
"narHash": "sha256-dLR+WVwKTwmzCVx0N91BkILXhNPlZ3uuUVg6GFvusME=",
|
||||
"owner": "rust-lang",
|
||||
"repo": "rust-analyzer",
|
||||
"rev": "68bdf609f37a74547d9fbdf28ed22c10f9bcca45",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "rust-lang",
|
||||
"ref": "nightly",
|
||||
"repo": "rust-analyzer",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
62
flake.nix
Normal file
62
flake.nix
Normal file
|
@ -0,0 +1,62 @@
|
|||
{
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, fenix }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs {
|
||||
inherit system;
|
||||
overlays = [ fenix.overlays.default ];
|
||||
};
|
||||
|
||||
toolchain = pkgs.fenix.stable;
|
||||
|
||||
libraries = with pkgs; [
|
||||
webkitgtk
|
||||
gtk3
|
||||
cairo
|
||||
gdk-pixbuf
|
||||
glib.out
|
||||
dbus.lib
|
||||
openssl.out
|
||||
libayatana-appindicator
|
||||
];
|
||||
|
||||
packages = with pkgs; [
|
||||
pkg-config
|
||||
dbus
|
||||
openssl
|
||||
glib
|
||||
gtk3
|
||||
libsoup
|
||||
webkitgtk
|
||||
appimagekit
|
||||
];
|
||||
in {
|
||||
devShell = pkgs.mkShell {
|
||||
buildInputs = packages;
|
||||
|
||||
packages = (with pkgs; [ ]) ++ (with toolchain; [
|
||||
rustc
|
||||
cargo
|
||||
# rust-analyzer
|
||||
# rust-src
|
||||
# rust-std
|
||||
|
||||
# Get the nightly version of rustfmt so we can wrap comments
|
||||
pkgs.fenix.default.rustfmt
|
||||
]);
|
||||
|
||||
shellHook = let
|
||||
joinLibs = libs:
|
||||
builtins.concatStringsSep ":" (builtins.map (x: "${x}/lib") libs);
|
||||
libs = joinLibs libraries;
|
||||
in ''
|
||||
export LD_LIBRARY_PATH=${libs}:$LD_LIBRARY_PATH
|
||||
'';
|
||||
};
|
||||
});
|
||||
}
|
|
@ -26,7 +26,7 @@ use crate::srs::SrsDb;
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let app_dir = dirs::config_dir().unwrap().join("houhou");
|
||||
let app_dir = dirs::state_dir().unwrap().join("houhou");
|
||||
fs::create_dir_all(&app_dir).await?;
|
||||
|
||||
// Open kanji db
|
||||
|
@ -60,6 +60,15 @@ async fn main() -> Result<()> {
|
|||
.manage(KanjiDb(kanji_pool))
|
||||
.manage(SrsDb(srs_pool))
|
||||
.system_tray(tray)
|
||||
.setup(|app| {
|
||||
let resource_path = app
|
||||
.path_resolver()
|
||||
.resolve_resource("./KanjiDatabase.sqlite")
|
||||
.expect("failed to resolve resource");
|
||||
println!("Resource path: {}", resource_path.display());
|
||||
|
||||
Ok(())
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![
|
||||
srs::get_srs_stats,
|
||||
srs::add_srs_item,
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
"icons/128x128@2x.png",
|
||||
"icons/icon.icns",
|
||||
"icons/icon.ico"
|
||||
],
|
||||
"resources": [
|
||||
"./KanjiDatabase.sqlite"
|
||||
]
|
||||
},
|
||||
"security": {
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
@use "sass:color";
|
||||
|
||||
$navLinkAccentColor: #09c;
|
||||
$navLinkColor: hsl(203, 91%, 91%);
|
||||
$navLinkTransparent: hsla(203, 91%, 91%, 0%);
|
||||
$grayed: #f4f4f4;
|
||||
$grayedTransparent: #f4f4f400;
|
||||
|
||||
.main {
|
||||
min-height: 0;
|
||||
|
@ -34,7 +39,7 @@ $navLinkColor: hsl(203, 91%, 91%);
|
|||
text-align: center;
|
||||
padding: 12px;
|
||||
border-top: 4px solid transparent;
|
||||
transition: background-color 0.1s ease-out, border-top-color 0.1s ease-out;
|
||||
transition: background 0.1s ease-out, border-top-color 0.1s ease-out;
|
||||
|
||||
// Make the top bar seem less web-ish
|
||||
user-select: none;
|
||||
|
@ -43,12 +48,17 @@ $navLinkColor: hsl(203, 91%, 91%);
|
|||
|
||||
&:not(.link-active):hover {
|
||||
border-top-color: #f4f4f4;
|
||||
background: linear-gradient(#f4f4f4, transparent);
|
||||
background: -moz-linear-gradient(180deg, $grayed 0%, $grayedTransparent 100%);
|
||||
background: -webkit-linear-gradient(180deg, $grayed 0%, $grayedTransparent 100%);
|
||||
background: linear-gradient(180deg, $grayed 0%, $grayedTransparent 100%);
|
||||
}
|
||||
}
|
||||
|
||||
.link-active {
|
||||
border-top-color: $navLinkAccentColor;
|
||||
// background-color: $navLinkColor;
|
||||
background: linear-gradient($navLinkColor, transparent);
|
||||
background: $navLinkColor;
|
||||
background: -moz-linear-gradient(180deg, $navLinkColor 0%, $navLinkTransparent 100%);
|
||||
background: -webkit-linear-gradient(180deg, $navLinkColor 0%, $navLinkTransparent 100%);
|
||||
background: linear-gradient(180deg, $navLinkColor 0%, $navLinkTransparent 100%);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,8 @@ import useSWR from "swr";
|
|||
import { invoke } from "@tauri-apps/api/tauri";
|
||||
import { Link } from "react-router-dom";
|
||||
import ConditionalWrapper from "./utils/ConditionalWrapper";
|
||||
import ReactTimeago from "react-timeago";
|
||||
import ReactTimeago, { Formatter } from "react-timeago";
|
||||
import { isValid } from "date-fns";
|
||||
|
||||
interface SrsStats {
|
||||
reviews_available: number;
|
||||
|
@ -46,7 +47,15 @@ export default function DashboardReviewStats() {
|
|||
const canReview = srsStats.reviews_available == 0;
|
||||
|
||||
const nextReviewDate = new Date(srsStats.next_review * 1_000);
|
||||
const nextReview = <ReactTimeago date={nextReviewDate} />;
|
||||
const nowFormatter: Formatter = (value, unit, suffix, epochMilliseconds, nextFormatter) => {
|
||||
if (epochMilliseconds < Date.now()) return "now";
|
||||
return nextFormatter?.(value, unit, suffix, epochMilliseconds);
|
||||
};
|
||||
const nextReview = srsStats.next_review ? (
|
||||
<ReactTimeago date={nextReviewDate} formatter={nowFormatter} />
|
||||
) : (
|
||||
"never"
|
||||
);
|
||||
|
||||
const generateStat = (stat: Stat) => {
|
||||
return (
|
||||
|
@ -83,7 +92,7 @@ export default function DashboardReviewStats() {
|
|||
)}
|
||||
elseWrapper={(children) => <Link to="/srs/review">{children}</Link>}
|
||||
>
|
||||
<Button isDisabled={canReview} colorScheme="blue">
|
||||
<Button isDisabled={canReview} cursor="pointer" colorScheme="blue">
|
||||
Start reviewing <ArrowRightIcon marginLeft={3} />
|
||||
</Button>
|
||||
</ConditionalWrapper>
|
||||
|
|
|
@ -35,6 +35,7 @@ $kanjiCharacterSize: 28px;
|
|||
.kanji-list-scroll {
|
||||
direction: rtl;
|
||||
overflow-y: scroll;
|
||||
overscroll-behavior-y: none;
|
||||
}
|
||||
|
||||
.kanji-list-inner {
|
||||
|
|
Loading…
Reference in a new issue