Created
January 26, 2011 17:11
-
-
Save kiwanami/797026 to your computer and use it in GitHub Desktop.
get a diagram from websequencediagrams.com via API
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(require 'deferred) | |
(deferred:$ | |
(deferred:url-post "http://www.websequencediagrams.com/" '((message | |
"Alice->Bob: Authentication Request | |
note right of Bob: Bob thinks about it. | |
Bob-->Alice: Authentication Response | |
note over A,B: text1 | |
note left of A: text2 | |
note right of A | |
multiline | |
text | |
end note | |
A->B: text | |
activate B | |
B-->A: text | |
deactivate B") (style "default"))) | |
(deferred:nextc it | |
(lambda (buf) | |
(let* ((line (with-current-buffer buf (buffer-string))) url) | |
(when (string-match "\\?img=[a-zA-Z0-9]+" line) | |
(setq url (concat "http://www.websequencediagrams.com/" (match-string 0 line)))) | |
(kill-buffer buf) | |
(message "GET -> %s" url) | |
(deferred:process "wget" "-O" "a.png" url)))) | |
(deferred:nextc it | |
(lambda () (clear-image-cache) (insert-image (create-image (expand-file-name "a.png") 'png)))) | |
(deferred:watch it | |
(lambda () (delete-file "a.png")))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment