Skip to content

Commit

Permalink
Merge pull request #123 from fosslife/master
Browse files Browse the repository at this point in the history
release: v3.2.0
  • Loading branch information
Sparkenstein authored Nov 14, 2024
2 parents 5c2c284 + 259556c commit 51850ab
Show file tree
Hide file tree
Showing 19 changed files with 677 additions and 907 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,3 @@ assets/vips/
.yarn
.eslintcache
.idea

src-tauri/gen
1 change: 0 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ export default {
singleQuote: false,
printWidth: 80,
tabWidth: 2,
endOfLine: "lf",
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "devtools-x",
"version": "3.1.0",
"version": "3.2.0",
"license": "MIT",
"type": "module",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
# will have compiled files and executables
/target/
WixTools
/gen/
gen/schemas
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "devtools-x"
version = "3.1.0"
version = "3.2.0"
description = "Developer tools desktop application"
authors = ["Sparkenstein"]
license = "MIT"
Expand Down
12 changes: 3 additions & 9 deletions src-tauri/capabilities/desktop.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
{
"identifier": "desktop-capability",
"platforms": [
"macOS",
"windows",
"linux"
],
"permissions": [
"updater:default"
]
}
"platforms": ["macOS", "windows", "linux"],
"permissions": ["updater:default"]
}
100 changes: 94 additions & 6 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ use commands::qr::qr::read_qr;

fn main() {
// Todo move to different file
let migrations = vec![Migration {
version: 1,
description: "create_initial_tables",
sql: "
let migrations = vec![
Migration {
version: 1,
description: "create_initial_tables",
sql: "
CREATE TABLE IF NOT EXISTS snippets (
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
Expand Down Expand Up @@ -56,8 +57,95 @@ fn main() {
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY(snippet_id) REFERENCES snippets (id)
);",
kind: MigrationKind::Up,
}];
kind: MigrationKind::Up,
},
Migration {
version: 2,
description: "new_structure",
sql: "
-- First create a temporary table with the new structure
CREATE TABLE snippets_new (
id INTEGER PRIMARY KEY AUTOINCREMENT,
title TEXT NOT NULL,
code TEXT NOT NULL,
language TEXT NOT NULL,
tags TEXT,
note TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Delete the sqlite_sequence entry for snippets_new to reset AUTOINCREMENT
DELETE FROM sqlite_sequence WHERE name = 'snippets_new';
-- Copy and transform data from old tables to new structure
INSERT INTO snippets_new (id, title, code, language, tags, note, created_at)
SELECT
s.id,
s.name as title,
COALESCE(sf.content, '') as code,
COALESCE(sf.filetype, 'text') as language,
(SELECT GROUP_CONCAT(tag, ',') FROM snippets_tags WHERE snippet_id = s.id) as tags,
(SELECT GROUP_CONCAT(note, '\n') FROM snippets_notes WHERE snippet_id = s.id) as note,
s.created_at
FROM snippets s
LEFT JOIN snippets_files sf ON s.id = sf.snippet_id
GROUP BY s.id;
-- Drop old tables
DROP TABLE snippets_files;
DROP TABLE snippets_notes;
DROP TABLE snippets_tags;
DROP TABLE snippets;
-- Rename new table to snippets
ALTER TABLE snippets_new RENAME TO snippets;
-- Update the sqlite_sequence to continue from the last used id
UPDATE sqlite_sequence
SET seq = (SELECT MAX(id) FROM snippets)
WHERE name = 'snippets';
",
kind: MigrationKind::Up,
},
Migration {
version: 3,
description: "add_fts_search",
sql: "
-- Create FTS virtual table with multiple columns
CREATE VIRTUAL TABLE IF NOT EXISTS snippets_fts USING fts5(
title,
code,
note,
tags,
content='snippets',
content_rowid='id'
);
-- Populate FTS table with existing data
INSERT INTO snippets_fts(rowid, title, code, note, tags)
SELECT id, title, code, note, tags FROM snippets;
-- Create triggers to keep FTS index up to date
CREATE TRIGGER snippets_ai AFTER INSERT ON snippets BEGIN
INSERT INTO snippets_fts(rowid, title, code, note, tags)
VALUES (new.id, new.title, new.code, new.note, new.tags);
END;
CREATE TRIGGER snippets_ad AFTER DELETE ON snippets BEGIN
INSERT INTO snippets_fts(snippets_fts, rowid, title, code, note, tags)
VALUES('delete', old.id, old.title, old.code, old.note, old.tags);
END;
CREATE TRIGGER snippets_au AFTER UPDATE ON snippets BEGIN
INSERT INTO snippets_fts(snippets_fts, rowid, title, code, note, tags)
VALUES('delete', old.id, old.title, old.code, old.note, old.tags);
INSERT INTO snippets_fts(rowid, title, code, note, tags)
VALUES (new.id, new.title, new.code, new.note, new.tags);
END;
",
kind: MigrationKind::Up,
},
];

tauri::Builder::default()
.plugin(
Expand Down
7 changes: 6 additions & 1 deletion src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,14 @@
},
"productName": "devtools-x",
"mainBinaryName": "devtools-x",
"version": "3.1.0",
"version": "3.2.0",
"identifier": "com.fosslife.devtoolsx",
"plugins": {
"sql": {
"preload": [
"sqlite:devtools.db"
]
},
"updater": {
"endpoints": [
"https://github.com/fosslife/devtools-x/releases/latest/download/latest.json"
Expand Down
8 changes: 6 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ const Base64Image = loadable(() => import("./Features/base64/Base64Image"));
const Base64Text = loadable(() => import("./Features/base64/Base64Text"));
const Quicktpe = loadable(() => import("./Features/quicktype/Quicktype"));
const Ping = loadable(() => import("./Features/ping/Ping"));
const Minify = loadable(() => import("./Features/minifiers/Minify"));
const HtmlMinifier = loadable(() => import("./Features/minifiers/html"));
const CssMinifier = loadable(() => import("./Features/minifiers/css"));
const JsMinifier = loadable(() => import("./Features/minifiers/js"));
const UrlParser = loadable(() => import("./Features/url/UrlParser"));
const UrlEncoder = loadable(() => import("./Features/url/UrlEncoder"));
const HtmlPreview = loadable(
Expand Down Expand Up @@ -252,7 +254,9 @@ function App() {
<Route path="/base64-text" element={<Base64Text />}></Route>
<Route path="/quicktype" element={<Quicktpe />}></Route>
<Route path="/ping" element={<Ping />}></Route>
<Route path="/minify" element={<Minify />}></Route>
<Route path="/html-minifier" element={<HtmlMinifier />}></Route>
<Route path="/css-minifier" element={<CssMinifier />}></Route>
<Route path="/js-minifier" element={<JsMinifier />}></Route>
<Route path="/url-parser" element={<UrlParser />}></Route>
<Route path="/url-encoder" element={<UrlEncoder />}></Route>
<Route path="/html-preview" element={<HtmlPreview />}></Route>
Expand Down
14 changes: 7 additions & 7 deletions src/Components/Copy.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { Button, CopyButton, Tooltip } from "@mantine/core";
import { Button, CopyButton, MantineSize, Tooltip } from "@mantine/core";
import {} from "@tauri-apps/api";
import { IconCheck, IconCopy } from "@tabler/icons-react";
import * as clipboard from "@tauri-apps/plugin-clipboard-manager";

export function Copy({
value,
label,
}: {
type CopyProps = {
value: number | string;
label: string;
}) {
size?: MantineSize;
};

export function Copy({ value, label, size }: CopyProps) {
return (
<CopyButton value={value.toString()} timeout={2400}>
{({ copied, copy }) => (
Expand All @@ -18,7 +18,7 @@ export function Copy({
leftSection={
copied ? <IconCheck size={16} /> : <IconCopy size={16} />
}
size="xs"
size={size ?? "xs"}
fullWidth
onClick={() => {
copy(); // copy doesn't work but need this function for animation.
Expand Down
Loading

0 comments on commit 51850ab

Please sign in to comment.