added web launch for task juggler

This commit is contained in:
ndwarshuis 2019-04-25 23:24:15 -04:00
parent 70d6366ce4
commit 634a9dcdaf
1 changed files with 37 additions and 27 deletions

View File

@ -1184,18 +1184,6 @@ The default is XHTML for some reason (which few use and makes certain barbaric w
(setq org-html-doctype "html5")
#+END_SRC
** gantt charts
This is custom, non-MELPA package, so it must be loaded manually. See [[https://github.com/swillner/org-gantt/blob/master/org-gantt-manual.org][here]] for guide.
#+BEGIN_SRC emacs-lisp
;; (add-to-list 'load-path "~/.emacs.d/untracked/org-gantt/")
;; (require 'org-gantt)
#+END_SRC
It is also useful to define a block template for gantt chart creation
#+BEGIN_SRC emacs-lisp
;; (add-to-list 'org-structure-template-alist
;; '("og" . "org-gantt-chart"))
#+END_SRC
#+BEGIN_SRC emacs-lisp
(require 'ox-taskjuggler)
(setq org-taskjuggler-target-version 3.6
@ -1219,13 +1207,15 @@ It is also useful to define a block template for gantt chart creation
:candidates project-files
:action
;; TODO add load and view using function below
'(("Load" .
(lambda (s)
(call-process-shell-command
(format "tj3client -c /home/ndwar/.config/tj3/taskjugglerrc add %s" s)))))))
'(("Load" . #'nd/org-tj3-add-to-server))))
:buffer "*helm taskjuggler buffer*"
:prompt "Project: ")))
(defun nd/org-tj3-add-to-server (file)
"Add tj3 project FILE to web server."
(call-process-shell-command
(format "tj3client -c /home/ndwar/.config/tj3/taskjugglerrc add %s" file)))
(defun nd/org-tj3-open-in-browser (file)
(--> (with-temp-buffer (insert-file-contents file) (buffer-string))
(s-match "project \\([^[:space:]]+\\) " it)
@ -1233,23 +1223,26 @@ It is also useful to define a block template for gantt chart creation
;; TODO make port a variable
(browse-url (format "http://localhost:8081/taskjuggler?project=%s;report=report" it))))
(defun nd/org-taskjuggler-compile-advice (orig-fn &rest args)
(defun nd/org-tj3-compile-advice (orig-fn file)
"Advice to fix window placement in `org-fast-tags-selection'."
(let ((file (expand-file-name file)))
(nd/with-advice
;; don't make a reports directory
((#'make-directory :override #'ignore)
;; don't freak out when we have errors
;; (ruby likes to throw warnings)
(#'org-taskjuggler--collect-errors :override #'ignore))
(unwind-protect (apply orig-fn args))))
(funcall orig-fn file))
;; just return the file path when done
(list file)))
(advice-add #'org-taskjuggler-compile :around
#'nd/org-taskjuggler-compile-advice)
#'nd/org-tj3-compile-advice)
(defvar nd/org-taskjuggler-default-attributes
'(("timingresolution" . "5 min")))
(defun nd/org-taskjuggler-add-attributes (orig-fun &rest args)
(defun nd/org-tj3-add-attributes (orig-fun &rest args)
"Add extra attributes to exported projects."
;; assume the original list is a newline-delimited string
;; break this string into cons cells of keyval pairs
@ -1266,8 +1259,25 @@ It is also useful to define a block template for gantt chart creation
(--map (format "%s %s\n" (car it) (cdr it)) it)
(string-join it))))
(defun nd/org-tj3-add-project-attributes (orig-fun &rest args)
(nd/with-advice
((#'org-taskjuggler--build-attributes
:around #'nd/org-tj3-add-attributes))
(apply orig-fun args)))
(advice-add #'org-taskjuggler--build-attributes :around
#'nd/org-taskjuggler-add-attributes)
#'nd/org-tj3-add-project-attributes)
(defun nd/org-tj3-export-process-and-open-web (orig-fun &rest args)
(nd/with-advice
((#'org-open-file :override
(lambda (file)
(nd/org-tj3-add-to-server file)
(nd/org-tj3-open-in-browser file))))
(unwind-protect (apply orig-fun args))))
(advice-add #'org-taskjuggler-export-process-and-open :around
#'nd/org-tj3-export-process-and-open-web)
#+END_SRC
** gtd implementation
*** overview