Skip to content

Commit d53616f

Browse files
ndbroadbentclaude
andcommitted
Add COPYING symlink and Open Source Licenses menu item
GPL compliance improvements: - Add COPYING symlink pointing to LICENSE - Add Help > "Open Source Licenses" menu item - Opens CREDITS.md in default application - Falls back to GitHub URL if local file not found - Bundle CREDITS.md and LICENSE in macOS app - Update file length check to skip symlinks 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 48eb4df commit d53616f

File tree

4 files changed

+57
-2
lines changed

4 files changed

+57
-2
lines changed

COPYING

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
LICENSE

scripts/check_file_length.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ check_file() {
1818
local file="$1"
1919
local line_count
2020

21-
# Skip if file doesn't exist
21+
# Skip if file doesn't exist or is a symlink
2222
[[ ! -f "$file" ]] && return 0
23+
[[ -L "$file" ]] && return 0
2324

2425
# Skip excluded patterns
2526
case "$file" in
26-
*.md|*.json|*.yml|*.yaml|*.toml|*.txt|*.lock|*.css|*.html|LICENSE|CREDITS*)
27+
*.md|*.json|*.yml|*.yaml|*.toml|*.txt|*.lock|*.css|*.html|LICENSE|COPYING|CREDITS*)
2728
return 0
2829
;;
2930
*.png|*.jpg|*.jpeg|*.gif|*.ico|*.icns|*.svg|*.webp)

src-tauri/src/main.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use chat_to_map_desktop::{
1414
use clap::Parser;
1515
use imessage_database::{tables::table::get_connection, util::dirs::default_db_path};
1616
use serde::{Deserialize, Serialize};
17+
use tauri::menu::{MenuBuilder, MenuItemBuilder, SubmenuBuilder};
1718
use tauri::Emitter;
1819

1920
/// CLI arguments for the desktop app
@@ -242,6 +243,33 @@ fn get_screenshot_config(state: tauri::State<AppState>) -> ScreenshotConfigRespo
242243
}
243244
}
244245

246+
/// Open the Open Source Licenses (CREDITS.md)
247+
#[tauri::command]
248+
fn open_licenses() -> Result<(), String> {
249+
// Get path to CREDITS.md relative to the executable
250+
let exe_path = std::env::current_exe().map_err(|e| e.to_string())?;
251+
let app_dir = exe_path.parent().ok_or("No parent directory")?;
252+
253+
// In development, CREDITS.md is at the repo root
254+
// In production bundle, it's in Resources
255+
let credits_paths = vec![
256+
app_dir.join("../Resources/CREDITS.md"), // macOS bundle
257+
app_dir.join("../../CREDITS.md"), // Development (src-tauri/target/debug)
258+
app_dir.join("../../../CREDITS.md"), // Development (nested)
259+
std::path::PathBuf::from("CREDITS.md"), // Current dir fallback
260+
];
261+
262+
for path in credits_paths {
263+
if path.exists() {
264+
return open::that(&path).map_err(|e| format!("Failed to open CREDITS.md: {e}"));
265+
}
266+
}
267+
268+
// Fallback: open GitHub repo
269+
open::that("https://github.com/DocSpring/chat_to_map_desktop/blob/main/CREDITS.md")
270+
.map_err(|e| format!("Failed to open URL: {e}"))
271+
}
272+
245273
/// Take a screenshot and save it to the specified filename
246274
#[tauri::command]
247275
fn take_screenshot(state: tauri::State<AppState>, filename: String) -> Result<String, String> {
@@ -282,13 +310,37 @@ fn main() {
282310
tauri::Builder::default()
283311
.plugin(tauri_plugin_shell::init())
284312
.manage(app_state)
313+
.setup(|app| {
314+
// Build Help menu with Open Source Licenses item
315+
let licenses_item = MenuItemBuilder::new("Open Source Licenses")
316+
.id("open_licenses")
317+
.build(app)?;
318+
319+
let help_menu = SubmenuBuilder::new(app, "Help")
320+
.item(&licenses_item)
321+
.build()?;
322+
323+
let menu = MenuBuilder::new(app).item(&help_menu).build()?;
324+
325+
app.set_menu(menu)?;
326+
327+
Ok(())
328+
})
329+
.on_menu_event(|_app, event| {
330+
if event.id().as_ref() == "open_licenses" {
331+
if let Err(e) = open_licenses() {
332+
eprintln!("Failed to open licenses: {e}");
333+
}
334+
}
335+
})
285336
.invoke_handler(tauri::generate_handler![
286337
list_chats,
287338
export_and_upload,
288339
check_full_disk_access,
289340
open_full_disk_access_settings,
290341
get_screenshot_config,
291342
take_screenshot,
343+
open_licenses,
292344
])
293345
.run(tauri::generate_context!())
294346
.expect("error while running tauri application");

src-tauri/tauri.conf.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"bundle": {
2929
"active": true,
3030
"targets": "all",
31+
"resources": ["../CREDITS.md", "../LICENSE"],
3132
"icon": [
3233
"icons/32x32.png",
3334
"icons/128x128.png",

0 commit comments

Comments
 (0)