Package Updates 7 mesi fa
parent
commit
a7e0ee12aa
5 ha cambiato i file con 74 aggiunte e 61 eliminazioni
  1. 15 15
      Cargo.lock
  2. 1 1
      Cargo.toml
  3. 13 0
      README.md
  4. 7 7
      src/desktop_install.rs
  5. 38 38
      src/main.rs

+ 15 - 15
Cargo.lock

@@ -58,6 +58,21 @@ dependencies = [
  "windows-sys 0.61.2",
 ]
 
+[[package]]
+name = "appiphany"
+version = "0.1.0"
+dependencies = [
+ "clap",
+ "gtk4",
+ "image",
+ "libadwaita",
+ "scraper",
+ "sha2",
+ "ureq",
+ "url",
+ "webkit6",
+]
+
 [[package]]
 name = "autocfg"
 version = "1.5.0"
@@ -1858,21 +1873,6 @@ dependencies = [
  "rustls-pki-types",
 ]
 
-[[package]]
-name = "webruntime"
-version = "0.1.0"
-dependencies = [
- "clap",
- "gtk4",
- "image",
- "libadwaita",
- "scraper",
- "sha2",
- "ureq",
- "url",
- "webkit6",
-]
-
 [[package]]
 name = "weezl"
 version = "0.1.12"

+ 1 - 1
Cargo.toml

@@ -1,5 +1,5 @@
 [package]
-name = "webruntime"
+name = "appiphany"
 version = "0.1.0"
 edition = "2024"
 

+ 13 - 0
README.md

@@ -0,0 +1,13 @@
+# Appiphany
+
+
+Simple webruntime for gnome
+
+## Build
+
+cargo build --release
+
+## Run
+
+./target/release/appiphany
+

+ 7 - 7
src/desktop_install.rs

@@ -20,7 +20,7 @@ pub fn run_install(
 ) -> Result<(), String> {
     let url = normalize_url(url_arg)?;
     let id = stable_id(&url);
-    let icon_name = format!("webruntime-{id}");
+    let icon_name = format!("appiphany-{id}");
     let data_home = xdg_data_home();
     let apps_dir = data_home.join("applications");
     let icon_dir = data_home
@@ -28,7 +28,7 @@ pub fn run_install(
         .join("hicolor")
         .join(format!("{ICON_SIZE}x{ICON_SIZE}"))
         .join("apps");
-    let desktop_path = apps_dir.join(format!("webruntime-{id}.desktop"));
+    let desktop_path = apps_dir.join(format!("appiphany-{id}.desktop"));
     let icon_path = icon_dir.join(format!("{icon_name}.png"));
 
     if desktop_path.exists() && !force {
@@ -58,7 +58,7 @@ pub fn run_install(
             true
         }
         Err(e) => {
-            eprintln!("webruntime: favicon: {e} (launcher will use a generic icon name)");
+            eprintln!("appiphany: favicon: {e} (launcher will use a generic icon name)");
             false
         }
     };
@@ -96,13 +96,13 @@ pub fn run_uninstall(
     let data_home = xdg_data_home();
     let desktop_path = data_home
         .join("applications")
-        .join(format!("webruntime-{id}.desktop"));
+        .join(format!("appiphany-{id}.desktop"));
     let icon_path = data_home
         .join("icons")
         .join("hicolor")
         .join(format!("{ICON_SIZE}x{ICON_SIZE}"))
         .join("apps")
-        .join(format!("webruntime-{id}.png"));
+        .join(format!("appiphany-{id}.png"));
 
     let mut removed = false;
     if desktop_path.exists() {
@@ -176,7 +176,7 @@ fn build_desktop_file(name: &str, exe: &str, page_url: &str, icon: &str) -> Stri
         "Categories=Network;WebBrowser;",
         &format!("Name={}", escape_desktop_value(name)),
         &format!(
-            "Comment=Open {} in Webruntime",
+            "Comment=Open {} in Appiphany",
             escape_desktop_value(page_url)
         ),
         &format!("Exec={exec_line}"),
@@ -199,7 +199,7 @@ fn ureq_agent() -> ureq::Agent {
 fn fetch_bytes(agent: &ureq::Agent, url: &str) -> Result<Vec<u8>, String> {
     let resp = agent
         .get(url)
-        .set("User-Agent", "webruntime/1.0 (desktop-install)")
+        .set("User-Agent", "appiphany/1.0 (desktop-install)")
         .call()
         .map_err(|e| e.to_string())?;
     if !(200..300).contains(&resp.status()) {

+ 38 - 38
src/main.rs

@@ -1,5 +1,5 @@
-//! GTK/WebKit shell for a URL. Webapps can detect this host with `html[data-webruntime]` (CSS),
-//! `window.webruntime.version`, or `navigator.userAgent` (application details append `webruntime`
+//! GTK/WebKit shell for a URL. Webapps can detect this host with `html[data-appiphany]` (CSS),
+//! `window.appiphany.version`, or `navigator.userAgent` (application details append `appiphany`
 //! and the crate version). See the `HOST_MARKER_ATTR` constant below.
 
 mod desktop_install;
@@ -26,31 +26,31 @@ use webkit6::{
 };
 
 /// JavaScript `window.webkit.messageHandlers.<name>` must match this identifier.
-const WINDOW_DRAG_MESSAGE_HANDLER: &str = "webruntimeWindowDrag";
+const WINDOW_DRAG_MESSAGE_HANDLER: &str = "appiphanyWindowDrag";
 
-/// Mark draggable chrome in your HTML, e.g. `<div data-webruntime-window-drag>…</div>`.
-const WINDOW_DRAG_ATTR: &str = "data-webruntime-window-drag";
+/// Mark draggable chrome in your HTML, e.g. `<div data-appiphany-window-drag>…</div>`.
+const WINDOW_DRAG_ATTR: &str = "data-appiphany-window-drag";
 
 /// Host detection for embedded webapps (set on `<html>` at document start).
 ///
-/// **Stable API:** Pages can target webruntime with CSS, e.g. `html[data-webruntime] { … }`,
-/// read `document.documentElement.hasAttribute("data-webruntime")`, or use
-/// `window.webruntime.version`. The User-Agent also includes application details
-/// (`set_user_agent_with_application_details("webruntime", version)`), so
-/// `navigator.userAgent` contains a webruntime token for JS or server-side checks.
-const HOST_MARKER_ATTR: &str = "data-webruntime";
+/// **Stable API:** Pages can target appiphany with CSS, e.g. `html[data-appiphany] { … }`,
+/// read `document.documentElement.hasAttribute("data-appiphany")`, or use
+/// `window.appiphany.version`. The User-Agent also includes application details
+/// (`set_user_agent_with_application_details("appiphany", version)`), so
+/// `navigator.userAgent` contains an appiphany token for JS or server-side checks.
+const HOST_MARKER_ATTR: &str = "data-appiphany";
 
 /// Lazily created shared profile; one store for every origin (WebKit partitions internally).
-const APP_NETWORK_SESSION_KEY: &str = "webruntime-network-session";
+const APP_NETWORK_SESSION_KEY: &str = "appiphany-network-session";
 
-/// Injected at document start: sets `html[data-webruntime]`, `window.webruntime`, and the
-/// window-drag bridge (mousedown inside `[data-webruntime-window-drag]` …).
-fn webruntime_document_start_script_source() -> String {
+/// Injected at document start: sets `html[data-appiphany]`, `window.appiphany`, and the
+/// window-drag bridge (mousedown inside `[data-appiphany-window-drag]` …).
+fn appiphany_document_start_script_source() -> String {
     format!(
         r#"(function () {{
   try {{
     document.documentElement.setAttribute("{host_attr}", "");
-    window.webruntime = {{ version: "{version}" }};
+    window.appiphany = {{ version: "{version}" }};
   }} catch (_) {{}}
   const attr = "{attr}";
   const interactive = "A,BUTTON,INPUT,TEXTAREA,SELECT,LABEL,SUMMARY,DETAILS,AUDIO,VIDEO";
@@ -81,7 +81,7 @@ fn webruntime_document_start_script_source() -> String {
     )
 }
 
-/// Called when embedded JS reports a press on `[data-webruntime-window-drag]`.
+/// Called when embedded JS reports a press on `[data-appiphany-window-drag]`.
 fn begin_move_from_pointer_on_window(window: &ApplicationWindow) {
     let Some(display) = gdk::Display::default() else {
         return;
@@ -115,14 +115,14 @@ fn begin_move_from_pointer_on_window(window: &ApplicationWindow) {
 }
 
 /// WebView with injected bridge + script handler; call after `window` exists so moves target it.
-fn build_webruntime_webview(window: &ApplicationWindow, network_session: &NetworkSession) -> WebView {
+fn build_appiphany_webview(window: &ApplicationWindow, network_session: &NetworkSession) -> WebView {
     let ucm = UserContentManager::new();
     if !ucm.register_script_message_handler(WINDOW_DRAG_MESSAGE_HANDLER, None) {
-        eprintln!("webruntime: failed to register `{WINDOW_DRAG_MESSAGE_HANDLER}` message handler");
+        eprintln!("appiphany: failed to register `{WINDOW_DRAG_MESSAGE_HANDLER}` message handler");
     }
 
     let script = UserScript::new(
-        &webruntime_document_start_script_source(),
+        &appiphany_document_start_script_source(),
         UserContentInjectedFrames::AllFrames,
         UserScriptInjectionTime::Start,
         &[],
@@ -142,7 +142,7 @@ fn build_webruntime_webview(window: &ApplicationWindow, network_session: &Networ
 
     if let Some(settings) = WebViewExt::settings(&webview) {
         settings.set_user_agent_with_application_details(
-            Some("webruntime"),
+            Some("appiphany"),
             Some(env!("CARGO_PKG_VERSION")),
         );
     }
@@ -195,12 +195,12 @@ fn build_persistent_network_session() -> NetworkSession {
         Ok((data_dir, cache_dir)) => match (data_dir.to_str(), cache_dir.to_str()) {
             (Some(data), Some(cache)) => NetworkSession::new(Some(data), Some(cache)),
             _ => {
-                eprintln!("webruntime: non-UTF8 storage path, using ephemeral session");
+                eprintln!("appiphany: non-UTF8 storage path, using ephemeral session");
                 NetworkSession::new_ephemeral()
             }
         },
         Err(e) => {
-            eprintln!("webruntime: could not create storage dirs ({e}), using ephemeral session");
+            eprintln!("appiphany: could not create storage dirs ({e}), using ephemeral session");
             NetworkSession::new_ephemeral()
         }
     };
@@ -241,7 +241,7 @@ fn load_uri_into_overlay_webview(win: &ApplicationWindow, url: &str) {
         return;
     };
     let session = network_session_for_app(&app);
-    let webview = build_webruntime_webview(win, &session);
+    let webview = build_appiphany_webview(win, &session);
     webview.set_hexpand(true);
     webview.set_vexpand(true);
     overlay.set_child(Some(&webview));
@@ -264,7 +264,7 @@ fn normalize_url(arg: &str) -> Result<String, &'static str> {
 }
 
 #[derive(Parser)]
-#[command(name = "webruntime", version, about = "Minimal WebKit wrapper around a URL")]
+#[command(name = "appiphany", version, about = "Minimal WebKit wrapper around a URL")]
 struct Args {
     #[command(subcommand)]
     cmd: Option<Cmd>,
@@ -294,11 +294,11 @@ enum Cmd {
 
 fn persistent_profile_paths() -> Result<(PathBuf, PathBuf), std::io::Error> {
     let data_dir: PathBuf = glib::user_data_dir()
-        .join("webruntime")
+        .join("appiphany")
         .join("profile")
         .join("data");
     let cache_dir: PathBuf = glib::user_cache_dir()
-        .join("webruntime")
+        .join("appiphany")
         .join("profile")
         .join("cache");
     std::fs::create_dir_all(&data_dir)?;
@@ -314,11 +314,11 @@ fn main() -> glib::ExitCode {
 
     match (&parsed.cmd, &parsed.url) {
         (Some(_), Some(_)) => {
-            eprintln!("webruntime: cannot pass a URL together with a subcommand");
+            eprintln!("appiphany: cannot pass a URL together with a subcommand");
             return glib::ExitCode::from(2);
         }
         (None, None) => {
-            eprintln!("webruntime: expected <URL> or a subcommand (see --help)");
+            eprintln!("appiphany: expected <URL> or a subcommand (see --help)");
             return glib::ExitCode::from(2);
         }
         _ => {}
@@ -336,24 +336,24 @@ fn main() -> glib::ExitCode {
         return match result {
             Ok(()) => glib::ExitCode::SUCCESS,
             Err(msg) => {
-                eprintln!("webruntime: {msg}");
+                eprintln!("appiphany: {msg}");
                 glib::ExitCode::from(1)
             }
         };
     }
 
     if let Err(msg) = normalize_url(parsed.url.as_ref().expect("validated")) {
-        eprintln!("webruntime: {msg}");
+        eprintln!("appiphany: {msg}");
         return glib::ExitCode::from(2);
     }
 
     if let Err(e) = adw::init() {
-        eprintln!("webruntime: failed to initialize libadwaita: {e}");
+        eprintln!("appiphany: failed to initialize libadwaita: {e}");
         return glib::ExitCode::from(1);
     }
 
     let app = Application::builder()
-        .application_id("dev.webruntime.app")
+        .application_id("dev.appiphany.app")
         .flags(ApplicationFlags::HANDLES_COMMAND_LINE)
         .build();
 
@@ -366,20 +366,20 @@ fn main() -> glib::ExitCode {
         {
             Ok(a) => a,
             Err(_) => {
-                eprintln!("webruntime: arguments must be valid UTF-8");
+                eprintln!("appiphany: arguments must be valid UTF-8");
                 return glib::ExitCode::from(2);
             }
         };
 
         if args.len() != 2 {
-            eprintln!("Usage: webruntime <url>");
+            eprintln!("Usage: appiphany <url>");
             return glib::ExitCode::from(2);
         }
 
         let url = match normalize_url(&args[1]) {
             Ok(u) => u,
             Err(msg) => {
-                eprintln!("webruntime: {msg}");
+                eprintln!("appiphany: {msg}");
                 return glib::ExitCode::from(2);
             }
         };
@@ -394,13 +394,13 @@ fn main() -> glib::ExitCode {
 
         let window = ApplicationWindow::builder()
             .application(app)
-            .title("Webruntime")
+            .title("Appiphany")
             .default_width(1024)
             .default_height(768)
             .build();
 
         let network_session = network_session_for_app(app);
-        let webview = build_webruntime_webview(&window, &network_session);
+        let webview = build_appiphany_webview(&window, &network_session);
         let shell = build_overlay_with_webview(&webview);
         window.set_content(Some(&shell));
         webview.load_uri(&url);