Some fixes
This commit is contained in:
parent
28fe1e42e5
commit
233c5aafed
11 changed files with 32 additions and 54 deletions
3
.vscode/extensions.json
vendored
3
.vscode/extensions.json
vendored
|
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"recommendations": ["tauri-apps.tauri-vscode", "rust-lang.rust-analyzer"]
|
|
||||||
}
|
|
||||||
2
src-tauri/Cargo.lock
generated
2
src-tauri/Cargo.lock
generated
|
|
@ -3348,7 +3348,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rufeed"
|
name = "rufeed"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cached",
|
"cached",
|
||||||
"feed-rs",
|
"feed-rs",
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[package]
|
[package]
|
||||||
name = "rufeed"
|
name = "rufeed"
|
||||||
version = "0.3.0"
|
version = "0.4.0"
|
||||||
description = "A Tauri App"
|
description = "A feed reader"
|
||||||
authors = ["Ahmed Nagi"]
|
authors = ["Ahmed Nagi"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"id": "17a52b7a-cb76-4d84-bc37-110537c2f7ca",
|
|
||||||
"title": "Rust Blog",
|
|
||||||
"url": "https://blog.rust-lang.org/",
|
|
||||||
"feed_url": "https://blog.rust-lang.org/feed.xml",
|
|
||||||
"icon": "https://blog.rust-lang.org/images/apple-touch-icon.png"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "c414b24b-c429-4d56-9be5-aa2e0c042fc0",
|
|
||||||
"title": "RSS feed for os.phil-opp.com",
|
|
||||||
"url": "https://os.phil-opp.com/",
|
|
||||||
"feed_url": "https://os.phil-opp.com/rss.xml",
|
|
||||||
"icon": "https://os.phil-opp.com/favicon.ico"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "e4a39047-3c64-4beb-9622-9fd02062cff5",
|
|
||||||
"title": "عالم الكمبيوتر- RSS",
|
|
||||||
"url": "https://www.computer-wd.com/",
|
|
||||||
"feed_url": "https://www.computer-wd.com/rss.xml",
|
|
||||||
"icon": "https://www.computer-wd.com/favicon.ico"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use once_cell::sync::Lazy;
|
use std::sync::LazyLock;
|
||||||
|
|
||||||
pub static CLIENT: Lazy<reqwest::Client> = Lazy::new(|| {
|
pub static CLIENT: LazyLock<reqwest::Client> = LazyLock::new(|| {
|
||||||
reqwest::Client::builder()
|
reqwest::Client::builder()
|
||||||
.timeout(std::time::Duration::from_secs(20))
|
.timeout(std::time::Duration::from_secs(20))
|
||||||
.connect_timeout(std::time::Duration::from_secs(10))
|
.connect_timeout(std::time::Duration::from_secs(10))
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,32 @@
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
use std::sync::OnceLock;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use tauri::Manager;
|
use tauri::Manager;
|
||||||
|
|
||||||
use crate::Error;
|
use crate::Error;
|
||||||
|
|
||||||
|
static CONFIG_PATH: OnceLock<PathBuf> = OnceLock::new();
|
||||||
|
|
||||||
fn get_config_path(app: &tauri::AppHandle) -> Result<PathBuf, String> {
|
pub fn init_config_path(app: &tauri::AppHandle) -> Result<(), String> {
|
||||||
let config_dir = app.path().app_config_dir()
|
let config_dir = app.path().app_config_dir().map_err(|e| e.to_string())?;
|
||||||
.map_err(|e| e.to_string())?;
|
|
||||||
|
|
||||||
// Create dir if not exist
|
|
||||||
fs::create_dir_all(&config_dir).map_err(|e| e.to_string())?;
|
fs::create_dir_all(&config_dir).map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
Ok(config_dir.join("config.json"))
|
let path = config_dir.join("feeds.json");
|
||||||
|
CONFIG_PATH
|
||||||
|
.set(path)
|
||||||
|
.map_err(|_| "Config path already initialized".to_string())?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_feeds_path() -> Result<&'static PathBuf, Error> {
|
||||||
|
CONFIG_PATH
|
||||||
|
.get()
|
||||||
|
.ok_or_else(|| Error::MissingField("Config path not initialized".to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
pub mod feed_config {
|
pub mod feed_config {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
@ -56,7 +67,7 @@ pub mod feed_config {
|
||||||
};
|
};
|
||||||
feeds.push(new_feed);
|
feeds.push(new_feed);
|
||||||
let json = serde_json::to_string_pretty(&feeds)?;
|
let json = serde_json::to_string_pretty(&feeds)?;
|
||||||
fs::write("feeds.json", json)?;
|
fs::write(get_feeds_path()?, json)?;
|
||||||
|
|
||||||
Ok(feeds.pop().unwrap())
|
Ok(feeds.pop().unwrap())
|
||||||
}
|
}
|
||||||
|
|
@ -70,13 +81,13 @@ pub mod feed_config {
|
||||||
|
|
||||||
let removed = feeds.remove(index);
|
let removed = feeds.remove(index);
|
||||||
let json = serde_json::to_string_pretty(&feeds)?;
|
let json = serde_json::to_string_pretty(&feeds)?;
|
||||||
fs::write("feeds.json", json)?;
|
fs::write(get_feeds_path()?, json)?;
|
||||||
|
|
||||||
Ok(removed)
|
Ok(removed)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_content() -> Result<Vec<Feed>, Error> {
|
fn get_content() -> Result<Vec<Feed>, Error> {
|
||||||
let path = std::path::Path::new("feeds.json");
|
let path = std::path::Path::new(get_feeds_path()?);
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
fs::write(path, "[]")?;
|
fs::write(path, "[]")?;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,18 +5,13 @@ pub mod parser;
|
||||||
|
|
||||||
use commands::feed::{add_feed, get_entry, get_feed_item, get_feeds, remove_feed};
|
use commands::feed::{add_feed, get_entry, get_feed_item, get_feeds, remove_feed};
|
||||||
|
|
||||||
pub async fn test_thing() -> Result<(), Error> {
|
|
||||||
// match get_entry("https://blog.rust-lang.org/", "https://blog.rust-lang.org/2026/03/20/rust-challenges/").await {
|
|
||||||
// Ok(feed) => println!("{:?}", feed),
|
|
||||||
// Err(e) => eprintln!("add_feed failed: {}", e),
|
|
||||||
// }
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||||
pub fn run() {
|
pub fn run() {
|
||||||
tauri::Builder::default()
|
tauri::Builder::default()
|
||||||
|
.setup(|app| {
|
||||||
|
config::init_config_path(&app.handle())?;
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
.plugin(tauri_plugin_opener::init())
|
.plugin(tauri_plugin_opener::init())
|
||||||
.invoke_handler(tauri::generate_handler![
|
.invoke_handler(tauri::generate_handler![
|
||||||
add_feed,
|
add_feed,
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,5 @@
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
// rufeed_lib::test_thing().await;
|
|
||||||
rufeed_lib::run()
|
rufeed_lib::run()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://schema.tauri.app/config/2",
|
"$schema": "https://schema.tauri.app/config/2",
|
||||||
"productName": "rufeed",
|
"productName": "rufeed",
|
||||||
"version": "0.1.0",
|
"version": "0.4.0",
|
||||||
"identifier": "com.army.rufeed",
|
"identifier": "com.mindfeq.rufeed",
|
||||||
"build": {
|
"build": {
|
||||||
"beforeDevCommand": "pnpm dev",
|
"beforeDevCommand": "pnpm dev",
|
||||||
"devUrl": "http://localhost:1420",
|
"devUrl": "http://localhost:1420",
|
||||||
|
|
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
error: manifest path `/home/army/Desktop/proj/rufeed/Cargo.toml` does not exist
|
|
||||||
Loading…
Add table
Reference in a new issue