Browse Source

Add support for mailto, xmpp, irc links

openbsd
Ciarán Ainsworth 6 months ago
parent
commit
b41aef9608
2 changed files with 36 additions and 0 deletions
  1. 30
    0
      src/draw.rs
  2. 6
    0
      src/gemini/link.rs

+ 30
- 0
src/draw.rs View File

@@ -280,6 +280,36 @@ pub fn gemini_link(gui: &Arc<Gui>, link_item: String) {
280 280
 
281 281
             insert_external_button(&gui, url, &www_label);
282 282
         }
283
+        Ok(GeminiLink::Email(url, label)) => {
284
+            let button_label = if label.is_empty() {
285
+                url.to_string()
286
+            } else {
287
+                label
288
+            };
289
+            let email_label = format!("{} [MAILTO]", button_label);
290
+
291
+            insert_external_button(&gui, url, &email_label);
292
+        }
293
+        Ok(GeminiLink::XMPP(url, label)) => {
294
+            let button_label = if label.is_empty() {
295
+                url.to_string()
296
+            } else {
297
+                label
298
+            };
299
+            let xmpp_label = format!("{} [XMPP]", button_label);
300
+
301
+            insert_external_button(&gui, url, &xmpp_label);
302
+        }
303
+        Ok(GeminiLink::IRC(url, label)) => {
304
+            let button_label = if label.is_empty() {
305
+                url.to_string()
306
+            } else {
307
+                label
308
+            };
309
+            let irc_label = format!("{} [IRC]", button_label);
310
+
311
+            insert_external_button(&gui, url, &irc_label);
312
+        }
283 313
         Ok(GeminiLink::Relative(url, label)) => {
284 314
             let new_url = Gemini { source: url }.to_absolute_url().unwrap();
285 315
             insert_button(&gui, new_url, label);

+ 6
- 0
src/gemini/link.rs View File

@@ -9,6 +9,9 @@ pub enum Link {
9 9
     Gemini(Url, String),
10 10
     Gopher(Url, String),
11 11
     Http(Url, String),
12
+    Email(Url, String),
13
+    IRC(Url, String),
14
+    XMPP(Url, String),
12 15
     Relative(String, String),
13 16
     Unknown(Url, String),
14 17
 }
@@ -56,6 +59,9 @@ fn make_link(url: String, label: String) -> Option<Link> {
56 59
             "gopher" => Some(Link::Gopher(url, label)),
57 60
             "http" => Some(Link::Http(url, label)),
58 61
             "https" => Some(Link::Http(url, label)),
62
+            "mailto" => Some(Link::Email(url, label)),
63
+            "xmpp" => Some(Link::XMPP(url, label)),
64
+            "irc" => Some(Link::IRC(url, label)),
59 65
             _ => Some(Link::Unknown(url, label)),
60 66
         },
61 67
         Err(url::ParseError::RelativeUrlWithoutBase) => Some(Link::Relative(url, label)),

Loading…
Cancel
Save