From 634a9dcdafd13aec03bb215bd7156af2dd61c9b2 Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Thu, 25 Apr 2019 23:24:15 -0400 Subject: [PATCH] added web launch for task juggler --- conf.org | 64 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/conf.org b/conf.org index b5b744f..471537e 100644 --- a/conf.org +++ b/conf.org @@ -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'." - (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)))) + (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)) + (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