diff options
author | Yuchen Pei <id@ypei.org> | 2023-07-10 12:03:38 +1000 |
---|---|---|
committer | Yuchen Pei <id@ypei.org> | 2023-07-10 12:03:38 +1000 |
commit | 35a15e183ced5cb9529d7e35433dcb26db548897 (patch) | |
tree | ff20338acf413ed93c16cd29d781397d1c77525b /wiki-engine.el | |
parent | 49fc5fa02bf06ccc419a8ec26abe3dcdf61a57b0 (diff) |
Add some more wikis and wiki-open-url
Diffstat (limited to 'wiki-engine.el')
-rw-r--r-- | wiki-engine.el | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/wiki-engine.el b/wiki-engine.el index a201c72..fb6fcba 100644 --- a/wiki-engine.el +++ b/wiki-engine.el @@ -90,13 +90,20 @@ The site name is passed as a symbol WIKI-SITE." (defun-wiki-fetchers) (defun wiki-open-url (url) - "Open the wiki corresponding to URL. + "Open the raw wiki corresponding to the URL of a html wiki page. -If URL points to html title, open the corresponding raw title. -If URL points to a raw title, open directly. -If URL points to a host, assume it is mediawiki try to open main page." +If URL points to html title, open the corresponding raw title." (interactive "sURL: ") - + (when-let + ((found-site + (seq-find + (lambda (site-pair) + (when-let ((base-url (plist-get (cdr site-pair) :base-url))) + (string-prefix-p base-url url))) + wiki-sites))) + (pcase-let ((`(,site-id . ,site-info) found-site)) + (funcall (wiki-site-fetcher site-id) + (string-remove-prefix (plist-get site-info :base-url) url)))) ) (provide 'wiki-engine) |