new capability

This commit is contained in:
artin rebekale 2025-02-20 06:52:28 -08:00
parent 67f83875c1
commit 8192430563
5 changed files with 189 additions and 174 deletions

View File

@ -0,0 +1,58 @@
{
"identifier": "bw:bulk",
"description": "",
"local": true,
"windows": [
"main"
],
"permissions": [
"core:event:default",
"fs:allow-video-write-recursive",
"fs:allow-open",
"fs:allow-read",
"fs:allow-stat",
"fs:allow-write",
"fs:read-files",
"fs:allow-picture-write-recursive",
"fs:allow-home-write-recursive",
"fs:allow-public-write-recursive",
"fs:allow-lstat",
"fs:allow-read-file",
"fs:allow-audio-write-recursive",
"core:image:default",
"fs:allow-temp-write-recursive",
"fs:allow-create",
"fs:allow-read-dir",
"fs:allow-write-file",
"fs:allow-exe-write-recursive",
"fs:allow-document-write-recursive",
"fs:allow-appconfig-write-recursive",
"fs:allow-config-write-recursive",
"fs:allow-exists",
"fs:allow-app-write-recursive",
"fs:allow-applocaldata-write-recursive",
"core:default",
"fs:default",
"fs:allow-data-write",
"fs:allow-font-write-recursive",
"core:resources:default",
"core:webview:default",
"fs:allow-template-write-recursive",
"fs:allow-copy-file",
"fs:allow-cache-write-recursive",
"core:window:default",
"fs:allow-mkdir",
"core:app:default",
"fs:allow-download-write-recursive",
"fs:allow-fstat",
"fs:allow-desktop-write-recursive",
"fs:allow-appdata-write-recursive",
"fs:allow-runtime-write-recursive",
"fs:allow-resource-write-recursive",
"fs:allow-log-write-recursive",
"fs:allow-appcache-write-recursive",
"fs:allow-applog-write-recursive",
"fs:allow-localdata-write-recursive",
"core:path:default"
]
}

View File

@ -12,8 +12,8 @@ struct Book {
}
#[tauri::command]
fn search(q: &str) -> Vec<Book> {
searchdb(q).unwrap()
fn search(db: &str, q: &str) -> Vec<Book> {
searchdb(db,q).unwrap()
}
#[tauri::command]
fn initdb() {
@ -33,12 +33,12 @@ fn initdb() {
//let _ = file.write_all(&contents);
}
#[tauri::command]
fn copybook(bookid: i32) {
println!("copygins {}", bookid);
let _ = copybook_background(bookid);
fn copybook(db :&str, path:&str, bookid: i32) {
println!("copy {} from {} -> {}", bookid, db, path);
let _ = copybook_background(db,path,bookid);
}
fn copybook_background(bookid: i32) -> Result<()> {
let conn = Connection::open("/storage/emulated/0/Download/ebooks.db")?;
fn copybook_background(db: &str, path: &str,bookid: i32) -> Result<()> {
let conn = Connection::open(db)?;
//let conn = Connection::open("/home/artin/Documents/ebooksol/index.db")?;
let mut stmt = conn.prepare("SELECT books.title, data.format , book_content.content FROM books, book_content ,data where books.id = book_content.id and books.id = data.book and books.id = ?1 ")?;
let mut rows = stmt.query([bookid])?;
@ -46,7 +46,7 @@ fn copybook_background(bookid: i32) -> Result<()> {
let fname: String = row.get(0)?;
let ext: String = row.get(1)?;
// let filename = format!("{}.{}", row.get(0)?, row.get(1)?);
let filename = format!("{}.{}", fname, ext);
let filename = format!("{}/{}.{}", path, fname, ext);
let mut content = Vec::new();
println!("loading");
@ -58,8 +58,8 @@ fn copybook_background(bookid: i32) -> Result<()> {
}
Ok(())
}
fn searchdb(q: &str) -> Result<Vec<Book>> {
let conn = Connection::open("/storage/emulated/0/Download/ebooks.db")?;
fn searchdb(db:&str, q: &str) -> Result<Vec<Book>> {
let conn = Connection::open(db)?;
//let conn = Connection::open("/home/artin/Documents/ebooksol/index.db")?;
let mut stmt = conn.prepare("SELECT books.id, books.title, books.author_sort as authors FROM books, book_content where books.id = book_content.id and (title like ?1 or author_sort like ?2) ")?;

View File

@ -14,7 +14,12 @@
<h1>BookMobile</h1>
<details id="details">
<summary>Details</summary>
<summary>Config</summary>
<form class="row" id="config-form">
<label>Path to DB</label><input id="db-config" placeholder="path to db"/><br>
<label>Ouput Path</label><input id="output-config" placeholder="output path"/>
</form>
<textarea id="logtext">
Something small enough to escape casual notice.</textarea>
</details>

View File

@ -5,14 +5,15 @@ console.log("testing TESTING");
let greetInputEl;
let greetMsgEl;
let configDb;
let configPath;
let slocate;
let bookid;
let tb;
let logs;
let logtext;
async function k() {
return await invoke("search", { q: greetInputEl.value });
async function k(configDb) {
return await invoke("search", { db: configDb.value, q: greetInputEl.value });
}
async function greet() {
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
@ -23,29 +24,31 @@ async function init_db() {
}
async function platform() {
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
let plat = await invoke("getplatform" );
let plat = await invoke("getplatform");
mylog(plat);
console.log(plat);
console.log(plat);
}
async function cb2() {
console.log(this.id);
console.log(this);
await copybook(parseInt(bookid.value));
await copybook(configDb, configPath, parseInt(bookid.value));
}
async function mylog(msg){
async function mylog(msg) {
logtext.value += msg + "\n";
}
async function cb() {
await copybook(parseInt(bookid.value));
await copybook(configDb, configPath, parseInt(bookid.value));
}
async function copybook(bookid) {
async function copybook(configDb,configPath,bookid) {
console.log(`in copybook bookid: ${bookid}`);
await invoke("copybook", { bookid: bookid });
await invoke("copybook", { db: configDb.value, path: configPath.value, bookid: bookid });
}
window.addEventListener("DOMContentLoaded", () => {
greetInputEl = document.querySelector("#greet-input");
greetMsgEl = document.querySelector("#greet-msg");
configDb = document.querySelector("#db-config");
configPath = document.querySelector("#path-config");
bookid = document.querySelector("#bookid");
logs = document.querySelector("#details");
logtext = document.querySelector("#logtext");
@ -71,40 +74,54 @@ window.addEventListener("DOMContentLoaded", () => {
});
async function search() {
slocate = await k();
console.log(configDb);
slocate = await k(configDb);
console.log(slocate);
tb = document.querySelector("#thebooks");
let table = document.createElement("table");
let th1 = document.createElement("th");
let th2 = document.createElement("th");
let th3 = document.createElement("th");
th1.innerHTML = 'Title';
th2.innerHTML = 'Author(s)';
th3.innerHTML = 'Book Id';
table.appendChild(th1);
table.appendChild(th2);
table.appendChild(th3);
let th1 = document.createElement("th");
let th2 = document.createElement("th");
let th3 = document.createElement("th");
th1.innerHTML = "Title";
th2.innerHTML = "Author(s)";
th3.innerHTML = "Book Id";
table.appendChild(th1);
//table.appendChild(th2);
table.appendChild(th3);
slocate.forEach(function (book) {
let tr = document.createElement("tr");
let tr2 = document.createElement("tr");
let td1 = document.createElement("td");
let td2 = document.createElement("td");
let td3 = document.createElement("td");
td1.innerHTML = `${book['title']}`;
td2.innerHTML = `${book['authors']}`;
td3.style.height = '100%';
td1.innerHTML = `${book["title"]}<br><span style="font-size:8px"><b>(${book["authors"]})</b></span>`;
let button = document.createElement("input");
button.type = "button";
button.onclick=function(){ copybook(book['id'])};
button.style.width = '100%';
button.style.height = '100%';
button.value = `Pull Book ${book["id"]}`;
button.onclick = function () {
copybook(book["id"]);
};
//td3.innerHTML = "<form><button id=26849 onclick=cb2()> test </button></form>";
td3.appendChild(button);
td3.style.border="1px solid white";
td1.style.borderBottom="1px solid white";
//td1.style.fontSize = "8px";
td3.style.borderBottom="1px solid white";
//td3.innerHTML = `<button id=${book['id']} onclick={() => copybook()}> A </button>`;
//let span = document.createElement("span"uu
//span.innerHTML += `${book['title']} ${book['authors']} ${book['id']} <button id=${book['id']} onclick="copybook(${book['id']}uu" >${book['id']}</button><br>`;
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
tr.style.borderBottom = "1px solid white";
//tr2.appendChild(td2);
table.appendChild(tr);
//table.appendChild(tr2);
});
tb.appendChild(table);
table.style.border = "3px solid white";
tb.appendChild(table);
}

209
yarn.lock
View File

@ -1,153 +1,88 @@
# This file is generated by running "yarn install" inside your project.
# Manual changes might be lost - proceed with caution!
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
__metadata:
version: 8
cacheKey: 10c0
"@tauri-apps/api@npm:^2.0.0, @tauri-apps/api@npm:^2.2.0":
version: 2.2.0
resolution: "@tauri-apps/api@npm:2.2.0"
checksum: 10c0/0ff0d9735c33d71c934e34045ef3077831fa98de25a42dc4c343120b482c8c114b87ef83dc02195923c23226fe6b8cb3e6bbaa099ab64d741346ba80c164435a
languageName: node
linkType: hard
"@tauri-apps/api@^2.0.0", "@tauri-apps/api@^2.2.0":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/api/-/api-2.2.0.tgz#daaff2515b1a4ff1e763cf84a414548b02b566c5"
integrity sha512-R8epOeZl1eJEl603aUMIGb4RXlhPjpgxbGVEaqY+0G5JG9vzV/clNlzTeqc+NLYXVqXcn8mb4c5b9pJIUDEyAg==
"@tauri-apps/cli-darwin-arm64@npm:2.2.7":
version: 2.2.7
resolution: "@tauri-apps/cli-darwin-arm64@npm:2.2.7"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard
"@tauri-apps/cli-darwin-arm64@2.2.7":
version "2.2.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-arm64/-/cli-darwin-arm64-2.2.7.tgz#42ec056eb19309aa50b11c9568b6c0e6637f41ca"
integrity sha512-54kcpxZ3X1Rq+pPTzk3iIcjEVY4yv493uRx/80rLoAA95vAC0c//31Whz75UVddDjJfZvXlXZ3uSZ+bnCOnt0A==
"@tauri-apps/cli-darwin-x64@npm:2.2.7":
version: 2.2.7
resolution: "@tauri-apps/cli-darwin-x64@npm:2.2.7"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard
"@tauri-apps/cli-darwin-x64@2.2.7":
version "2.2.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-darwin-x64/-/cli-darwin-x64-2.2.7.tgz#60cb5806e7bec9af2e22ae38a6bd2a769b0a61b0"
integrity sha512-Vgu2XtBWemLnarB+6LqQeLanDlRj7CeFN//H8bVVdjbNzxcSxsvbLYMBP8+3boa7eBnjDrqMImRySSgL6IrwTw==
"@tauri-apps/cli-linux-arm-gnueabihf@npm:2.2.7":
version: 2.2.7
resolution: "@tauri-apps/cli-linux-arm-gnueabihf@npm:2.2.7"
conditions: os=linux & cpu=arm
languageName: node
linkType: hard
"@tauri-apps/cli-linux-arm-gnueabihf@2.2.7":
version "2.2.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm-gnueabihf/-/cli-linux-arm-gnueabihf-2.2.7.tgz#451029b68b50486e0553adf1a45cbd27c00eb3f9"
integrity sha512-+Clha2iQAiK9zoY/KKW0KLHkR0k36O78YLx5Sl98tWkwI3OBZFg5H5WT1plH/4sbZIS2aLFN6dw58/JlY9Bu/g==
"@tauri-apps/cli-linux-arm64-gnu@npm:2.2.7":
version: 2.2.7
resolution: "@tauri-apps/cli-linux-arm64-gnu@npm:2.2.7"
conditions: os=linux & cpu=arm64 & libc=glibc
languageName: node
linkType: hard
"@tauri-apps/cli-linux-arm64-gnu@2.2.7":
version "2.2.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-gnu/-/cli-linux-arm64-gnu-2.2.7.tgz#74f28cc303b0f476209c6117325fc235a3d5ad0f"
integrity sha512-Z/Lp4SQe6BUEOays9BQAEum2pvZF4w9igyXijP+WbkOejZx4cDvarFJ5qXrqSLmBh7vxrdZcLwoLk9U//+yQrg==
"@tauri-apps/cli-linux-arm64-musl@npm:2.2.7":
version: 2.2.7
resolution: "@tauri-apps/cli-linux-arm64-musl@npm:2.2.7"
conditions: os=linux & cpu=arm64 & libc=musl
languageName: node
linkType: hard
"@tauri-apps/cli-linux-arm64-musl@2.2.7":
version "2.2.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.2.7.tgz#c51890295186395effd2a751739b88c9689eea6c"
integrity sha512-+8HZ+txff/Y3YjAh80XcLXcX8kpGXVdr1P8AfjLHxHdS6QD4Md+acSxGTTNbplmHuBaSHJvuTvZf9tU1eDCTDg==
"@tauri-apps/cli-linux-x64-gnu@npm:2.2.7":
version: 2.2.7
resolution: "@tauri-apps/cli-linux-x64-gnu@npm:2.2.7"
conditions: os=linux & cpu=x64 & libc=glibc
languageName: node
linkType: hard
"@tauri-apps/cli-linux-x64-gnu@2.2.7":
version "2.2.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-gnu/-/cli-linux-x64-gnu-2.2.7.tgz#14959a065858dcc6bff87ca8eb4525b071ab4ffe"
integrity sha512-ahlSnuCnUntblp9dG7/w5ZWZOdzRFi3zl0oScgt7GF4KNAOEa7duADsxPA4/FT2hLRa0SvpqtD4IYFvCxoVv3Q==
"@tauri-apps/cli-linux-x64-musl@npm:2.2.7":
version: 2.2.7
resolution: "@tauri-apps/cli-linux-x64-musl@npm:2.2.7"
conditions: os=linux & cpu=x64 & libc=musl
languageName: node
linkType: hard
"@tauri-apps/cli-linux-x64-musl@2.2.7":
version "2.2.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-linux-x64-musl/-/cli-linux-x64-musl-2.2.7.tgz#6199c671d760b39c75ad13228cc422fadbbd0b15"
integrity sha512-+qKAWnJRSX+pjjRbKAQgTdFY8ecdcu8UdJ69i7wn3ZcRn2nMMzOO2LOMOTQV42B7/Q64D1pIpmZj9yblTMvadA==
"@tauri-apps/cli-win32-arm64-msvc@npm:2.2.7":
version: 2.2.7
resolution: "@tauri-apps/cli-win32-arm64-msvc@npm:2.2.7"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard
"@tauri-apps/cli-win32-arm64-msvc@2.2.7":
version "2.2.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-arm64-msvc/-/cli-win32-arm64-msvc-2.2.7.tgz#e83f3efda339f8315a54c6b3a105bb16c1d78d66"
integrity sha512-aa86nRnrwT04u9D9fhf5JVssuAZlUCCc8AjqQjqODQjMd4BMA2+d4K9qBMpEG/1kVh95vZaNsLogjEaqSTTw4A==
"@tauri-apps/cli-win32-ia32-msvc@npm:2.2.7":
version: 2.2.7
resolution: "@tauri-apps/cli-win32-ia32-msvc@npm:2.2.7"
conditions: os=win32 & cpu=ia32
languageName: node
linkType: hard
"@tauri-apps/cli-win32-ia32-msvc@2.2.7":
version "2.2.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-ia32-msvc/-/cli-win32-ia32-msvc-2.2.7.tgz#6e9cdc615cf1f86469e067e65493a85470c4d6c7"
integrity sha512-EiJ5/25tLSQOSGvv+t6o3ZBfOTKB5S3vb+hHQuKbfmKdRF0XQu2YPdIi1CQw1DU97ZAE0Dq4frvnyYEKWgMzVQ==
"@tauri-apps/cli-win32-x64-msvc@npm:2.2.7":
version: 2.2.7
resolution: "@tauri-apps/cli-win32-x64-msvc@npm:2.2.7"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard
"@tauri-apps/cli-win32-x64-msvc@2.2.7":
version "2.2.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli-win32-x64-msvc/-/cli-win32-x64-msvc-2.2.7.tgz#c561efac129b386be35a936b0080a4cd2cd01b6d"
integrity sha512-ZB8Kw90j8Ld+9tCWyD2fWCYfIrzbQohJ4DJSidNwbnehlZzP7wAz6Z3xjsvUdKtQ3ibtfoeTqVInzCCEpI+pWg==
"@tauri-apps/cli@npm:^2":
version: 2.2.7
resolution: "@tauri-apps/cli@npm:2.2.7"
"@tauri-apps/cli@^2":
version "2.2.7"
resolved "https://registry.yarnpkg.com/@tauri-apps/cli/-/cli-2.2.7.tgz#4aedaf941f58bf2839fec38aa8191c5aefc7bb45"
integrity sha512-ZnsS2B4BplwXP37celanNANiIy8TCYhvg5RT09n72uR/o+navFZtGpFSqljV8fy1Y4ixIPds8FrGSXJCN2BerA==
optionalDependencies:
"@tauri-apps/cli-darwin-arm64" "2.2.7"
"@tauri-apps/cli-darwin-x64" "2.2.7"
"@tauri-apps/cli-linux-arm-gnueabihf" "2.2.7"
"@tauri-apps/cli-linux-arm64-gnu" "2.2.7"
"@tauri-apps/cli-linux-arm64-musl" "2.2.7"
"@tauri-apps/cli-linux-x64-gnu" "2.2.7"
"@tauri-apps/cli-linux-x64-musl" "2.2.7"
"@tauri-apps/cli-win32-arm64-msvc" "2.2.7"
"@tauri-apps/cli-win32-ia32-msvc" "2.2.7"
"@tauri-apps/cli-win32-x64-msvc" "2.2.7"
"@tauri-apps/plugin-log@~2":
version "2.2.1"
resolved "https://registry.yarnpkg.com/@tauri-apps/plugin-log/-/plugin-log-2.2.1.tgz#e837826f15f3d5e83ee964ccb6cf72f1ae5acca0"
integrity sha512-bOz9w0hhlXLGLc1ZR37GqkXvTqkykl4A3GEKLjRIs0dq3n0BzLyoRDMPcpt7PdUHqaq6WISME+zEX2bqjSbJ2A==
dependencies:
"@tauri-apps/cli-darwin-arm64": "npm:2.2.7"
"@tauri-apps/cli-darwin-x64": "npm:2.2.7"
"@tauri-apps/cli-linux-arm-gnueabihf": "npm:2.2.7"
"@tauri-apps/cli-linux-arm64-gnu": "npm:2.2.7"
"@tauri-apps/cli-linux-arm64-musl": "npm:2.2.7"
"@tauri-apps/cli-linux-x64-gnu": "npm:2.2.7"
"@tauri-apps/cli-linux-x64-musl": "npm:2.2.7"
"@tauri-apps/cli-win32-arm64-msvc": "npm:2.2.7"
"@tauri-apps/cli-win32-ia32-msvc": "npm:2.2.7"
"@tauri-apps/cli-win32-x64-msvc": "npm:2.2.7"
dependenciesMeta:
"@tauri-apps/cli-darwin-arm64":
optional: true
"@tauri-apps/cli-darwin-x64":
optional: true
"@tauri-apps/cli-linux-arm-gnueabihf":
optional: true
"@tauri-apps/cli-linux-arm64-gnu":
optional: true
"@tauri-apps/cli-linux-arm64-musl":
optional: true
"@tauri-apps/cli-linux-x64-gnu":
optional: true
"@tauri-apps/cli-linux-x64-musl":
optional: true
"@tauri-apps/cli-win32-arm64-msvc":
optional: true
"@tauri-apps/cli-win32-ia32-msvc":
optional: true
"@tauri-apps/cli-win32-x64-msvc":
optional: true
bin:
tauri: tauri.js
checksum: 10c0/ec09fadf47571c92b77d0ff72423c23b847b094dd2aa186f320947d372982778b5e17daaa7340f46a82803de5272bb149ba5801ce30a745ae48a662c3671ce68
languageName: node
linkType: hard
"@tauri-apps/api" "^2.0.0"
"@tauri-apps/plugin-log@npm:~2":
version: 2.2.1
resolution: "@tauri-apps/plugin-log@npm:2.2.1"
"@tauri-apps/plugin-os@~2":
version "2.2.0"
resolved "https://registry.yarnpkg.com/@tauri-apps/plugin-os/-/plugin-os-2.2.0.tgz#ef5511269f59c0ccc580a9d09600034cfaa9743b"
integrity sha512-HszbCdbisMlu5QhCNAN8YIWyz2v33abAWha6+uvV2CKX8P5VSct/y+kEe22JeyqrxCnWlQ3DRx7s49Byg7/0EA==
dependencies:
"@tauri-apps/api": "npm:^2.0.0"
checksum: 10c0/5f5128751b8f23447d6cd19749ac5f398abeec7f8ca63b1cc7632615454522b8b7fc6706572530c937df9f86a6071fdabfacf90f851c99b20e982124dddf7406
languageName: node
linkType: hard
"@tauri-apps/plugin-os@npm:~2":
version: 2.2.0
resolution: "@tauri-apps/plugin-os@npm:2.2.0"
dependencies:
"@tauri-apps/api": "npm:^2.0.0"
checksum: 10c0/9440a6bc85be975a2c9f55b4da302531be68ea45d06e6d049c30395dd71749b0d975d4ec56bd6c86ceab0bbfd732dd8bc482772da63f13aa10792fa4ac7b8c64
languageName: node
linkType: hard
"bookmobile@workspace:.":
version: 0.0.0-use.local
resolution: "bookmobile@workspace:."
dependencies:
"@tauri-apps/api": "npm:^2.2.0"
"@tauri-apps/cli": "npm:^2"
"@tauri-apps/plugin-log": "npm:~2"
"@tauri-apps/plugin-os": "npm:~2"
languageName: unknown
linkType: soft
"@tauri-apps/api" "^2.0.0"