Add 2012 to FSF copyright years for Emacs files
[bpt/emacs.git] / lisp / url / url-about.el
CommitLineData
8c8b8430 1;;; url-about.el --- Show internal URLs
d3c91027 2
acaf905b 3;; Copyright (C) 2001, 2004-2012 Free Software Foundation, Inc.
d3c91027 4
8c8b8430
SM
5;; Keywords: comm, data, processes, hypermedia
6
d3c91027
SM
7;; This file is part of GNU Emacs.
8;;
4936186e 9;; GNU Emacs is free software: you can redistribute it and/or modify
d3c91027 10;; it under the terms of the GNU General Public License as published by
4936186e
GM
11;; the Free Software Foundation, either version 3 of the License, or
12;; (at your option) any later version.
13
d3c91027
SM
14;; GNU Emacs is distributed in the hope that it will be useful,
15;; but WITHOUT ANY WARRANTY; without even the implied warranty of
16;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17;; GNU General Public License for more details.
4936186e 18
d3c91027 19;; You should have received a copy of the GNU General Public License
4936186e 20;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
d3c91027
SM
21
22;;; Commentary:
23
24;;; Code:
25
8c8b8430
SM
26(require 'url-util)
27(require 'url-parse)
28
29(defun url-probe-protocols ()
d3c91027 30 "Return a list of all potential URL schemes."
8c8b8430
SM
31 (or (get 'url-extension-protocols 'probed)
32 (mapc (lambda (s) (url-scheme-get-property s 'name))
33 (or (get 'url-extension-protocols 'schemes)
34 (let ((schemes '("info" "man" "rlogin" "telnet"
35 "tn3270" "data" "snews")))
36 (mapc (lambda (d)
37 (mapc (lambda (f)
38 (if (string-match "url-\\(.*\\).el$" f)
39 (push (match-string 1 f) schemes)))
40 (directory-files d nil "^url-.*\\.el$")))
41 load-path)
42 (put 'url-extension-protocols 'schemes schemes)
43 schemes)))))
44
d3c91027
SM
45(defvar url-scheme-registry)
46
8c8b8430
SM
47(defun url-about-protocols (url)
48 (url-probe-protocols)
49 (insert "<html>\n"
50 " <head>\n"
51 " <title>Supported Protocols</title>\n"
52 " </head>\n"
53 " <body>\n"
54 " <h1>Supported Protocols - URL v" url-version "</h1>\n"
55 " <table width='100%' border='1'>\n"
56 " <tr>\n"
57 " <td>Protocol\n"
58 " <td>Properties\n"
59 " <td>Description\n"
60 " </tr>\n")
61 (mapc (lambda (k)
62 (if (string= k "proxy")
63 ;; Ignore the proxy setting... its magic!
64 nil
65 (insert " <tr>\n")
66 ;; The name of the protocol
67 (insert " <td valign=top>" (or (url-scheme-get-property k 'name) k) "\n")
68
69 ;; Now the properties. Currently just asynchronous
70 ;; status, default port number, and proxy status.
71 (insert " <td valign=top>"
72 (if (url-scheme-get-property k 'asynchronous-p) "As" "S")
73 "ynchronous<br>\n"
74 (if (url-scheme-get-property k 'default-port)
75 (format "Default Port: %d<br>\n"
76 (url-scheme-get-property k 'default-port)) "")
77 (if (assoc k url-proxy-services)
78 (format "Proxy: %s<br>\n" (assoc k url-proxy-services)) ""))
79 ;; Now the description...
80 (insert " <td valign=top>"
81 (or (url-scheme-get-property k 'description) "N/A"))))
82 (sort (let (x) (maphash (lambda (k v) (push k x)) url-scheme-registry) x) 'string-lessp))
83 (insert " </table>\n"
84 " </body>\n"
85 "</html>\n"))
86
87(defun url-about (url)
88 "Show internal URLs."
89 (let* ((item (downcase (url-filename url)))
90 (func (intern (format "url-about-%s" item))))
91 (if (fboundp func)
92 (progn
93 (set-buffer (generate-new-buffer " *about-data*"))
d3c91027 94 (insert "Content-type: text/plain\n\n")
8c8b8430
SM
95 (funcall func url)
96 (current-buffer))
97 (error "URL does not know about `%s'" item))))
98
99(provide 'url-about)
e5566bd5 100
d3c91027 101;;; url-about.el ends here