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") (setq org-html-doctype "html5")
#+END_SRC #+END_SRC
** gantt charts ** 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 #+BEGIN_SRC emacs-lisp
(require 'ox-taskjuggler) (require 'ox-taskjuggler)
(setq org-taskjuggler-target-version 3.6 (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 :candidates project-files
:action :action
;; TODO add load and view using function below ;; TODO add load and view using function below
'(("Load" . '(("Load" . #'nd/org-tj3-add-to-server))))
(lambda (s)
(call-process-shell-command
(format "tj3client -c /home/ndwar/.config/tj3/taskjugglerrc add %s" s)))))))
:buffer "*helm taskjuggler buffer*" :buffer "*helm taskjuggler buffer*"
:prompt "Project: "))) :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) (defun nd/org-tj3-open-in-browser (file)
(--> (with-temp-buffer (insert-file-contents file) (buffer-string)) (--> (with-temp-buffer (insert-file-contents file) (buffer-string))
(s-match "project \\([^[:space:]]+\\) " it) (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 ;; TODO make port a variable
(browse-url (format "http://localhost:8081/taskjuggler?project=%s;report=report" it)))) (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'." "Advice to fix window placement in `org-fast-tags-selection'."
(nd/with-advice (let ((file (expand-file-name file)))
;; don't make a reports directory (nd/with-advice
((#'make-directory :override #'ignore) ;; don't make a reports directory
;; don't freak out when we have errors ((#'make-directory :override #'ignore)
;; (ruby likes to throw warnings) ;; don't freak out when we have errors
(#'org-taskjuggler--collect-errors :override #'ignore)) ;; (ruby likes to throw warnings)
(unwind-protect (apply orig-fn args)))) (#'org-taskjuggler--collect-errors :override #'ignore))
(funcall orig-fn file))
;; just return the file path when done
(list file)))
(advice-add #'org-taskjuggler-compile :around (advice-add #'org-taskjuggler-compile :around
#'nd/org-taskjuggler-compile-advice) #'nd/org-tj3-compile-advice)
(defvar nd/org-taskjuggler-default-attributes (defvar nd/org-taskjuggler-default-attributes
'(("timingresolution" . "5 min"))) '(("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." "Add extra attributes to exported projects."
;; assume the original list is a newline-delimited string ;; assume the original list is a newline-delimited string
;; break this string into cons cells of keyval pairs ;; 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) (--map (format "%s %s\n" (car it) (cdr it)) it)
(string-join 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 (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 #+END_SRC
** gtd implementation ** gtd implementation
*** overview *** overview