-
-
Save xee5ch/5765756 to your computer and use it in GitHub Desktop.
This file contains 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
; call trello2org interactively | |
; or pragmatically like this: (trello2org "c:/Users/jfurtney/blo-up-2-7.json") | |
(require 'json) | |
(defun convert-trello-json-file-to-org (trello-json-file) | |
(let* ((board (json-read-file trello-json-file)) | |
(board-name (cdr (assoc 'name (cdr board)))) | |
(lists (cdr (assoc 'lists (cdr board)))) | |
(cards (cdr (assoc 'cards (cdr board)))) | |
list-map) | |
; get list IDs | |
(setq list-map (loop for l across lists collect | |
(let ((id (cdr (assoc 'id l))) | |
(name (cdr (assoc 'name l)))) | |
(list id name)))) | |
; add cards to list lists | |
(loop for card across cards do | |
(let* ((card-name (cdr (assoc 'name card))) | |
(card-list-id (cdr (assoc 'idList card))) | |
(closedp (cdr (assoc 'closed card))) | |
(list-name (cadr (assoc card-list-id list-map)))) | |
(when (equal closedp :json-false) | |
(setcdr (last (assoc card-list-id list-map)) | |
(list card-name))))) | |
; write output in a new buffer | |
(let ((new-buffer | |
(generate-new-buffer "*trello*"))) | |
(with-current-buffer new-buffer | |
(insert (format "\n* %s\n" board-name)) | |
(dolist (i list-map) | |
(insert (format "\n** %s\n" (cadr i))) | |
(dolist (card-name (cddr i)) | |
(insert (format "*** %s\n" card-name))))) | |
(switch-to-buffer new-buffer) | |
(org-mode) | |
(show-all)))) | |
(defun trello2org (trello-JSON-file) | |
"Convert a Trello board to org format. | |
Give the filename of a JSON file exported from Trello. The Trello | |
board, lists and cards are written in org-mode format to a new | |
*trello* buffer. Archived cards are ignored. | |
To export from Trello: Click the board name, choose Share, Print, | |
and Export; click the Export JSON button." | |
(interactive "fTrello JSON file: ") | |
(convert-trello-json-file-to-org trello-JSON-file)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment