Code drill feature parity, downloading snippets from github

Phase 1 and 2. Phase 3 will allow custom github repo input.
This commit is contained in:
2026-02-18 05:12:01 +00:00
parent 2d63cffb33
commit d0605f8426
11 changed files with 4520 additions and 372 deletions

View File

@@ -3,10 +3,12 @@ use std::fs;
use std::io::Read;
use std::path::PathBuf;
#[allow(dead_code)]
pub struct DiskCache {
base_dir: PathBuf,
}
#[allow(dead_code)]
impl DiskCache {
pub fn new(subdir: &str) -> Option<Self> {
let base = dirs::data_dir()?.join("keydr").join(subdir);
@@ -37,6 +39,7 @@ impl DiskCache {
}
}
#[allow(dead_code)]
#[cfg(feature = "network")]
pub fn fetch_url(url: &str) -> Option<String> {
let client = reqwest::blocking::Client::builder()
@@ -51,6 +54,7 @@ pub fn fetch_url(url: &str) -> Option<String> {
}
}
#[allow(dead_code)]
#[cfg(not(feature = "network"))]
pub fn fetch_url(_url: &str) -> Option<String> {
None

File diff suppressed because it is too large Load Diff

View File

@@ -1,41 +0,0 @@
use crate::engine::filter::CharFilter;
use crate::generator::TextGenerator;
#[allow(dead_code)]
pub struct GitHubCodeGenerator {
cached_snippets: Vec<String>,
current_idx: usize,
}
impl GitHubCodeGenerator {
#[allow(dead_code)]
pub fn new() -> Self {
Self {
cached_snippets: Vec::new(),
current_idx: 0,
}
}
}
impl Default for GitHubCodeGenerator {
fn default() -> Self {
Self::new()
}
}
impl TextGenerator for GitHubCodeGenerator {
fn generate(
&mut self,
_filter: &CharFilter,
_focused: Option<char>,
_word_count: usize,
) -> String {
if self.cached_snippets.is_empty() {
return "// GitHub code fetching not yet configured. Use settings to add a repository."
.to_string();
}
let snippet = self.cached_snippets[self.current_idx % self.cached_snippets.len()].clone();
self.current_idx += 1;
snippet
}
}

View File

@@ -3,7 +3,6 @@ pub mod capitalize;
pub mod code_patterns;
pub mod code_syntax;
pub mod dictionary;
pub mod github_code;
pub mod numbers;
pub mod passage;
pub mod phonetic;