Browse Source

new generic function in iorg-projects.el to extract project
information from the customizable variable iorg-projects-config.

tj 8 years ago
parent
commit
1266fd0890
3 changed files with 33 additions and 20 deletions
  1. 1 1
      TASKS.org
  2. 4 3
      iorg/lisp/iorg-controller.el
  3. 28 16
      iorg/lisp/iorg-projects.el

+ 1 - 1
TASKS.org

@@ -60,7 +60,7 @@ No special considerations, defcustom variables are just like any other
 variables except that the Emacs customization interface will be
 available for users who want to change the variable's values.
 #+end_quote
-
+ 
 What, if I actually want to customize several projects in that
 variable, I want a key "project1" and then a alist of values for that
 project, and then another key "project2" and then another alist of

+ 4 - 3
iorg/lisp/iorg-controller.el

@@ -105,9 +105,10 @@ their counterparts in 'iorg-projects-config'"
        ;;:docroot (or docroot (cdr (assoc :port proj-config)))
        ))))
 
-(defun iorg-initialize-iorg-controller-handler (httpcon)
-  "Serves the start-page of the 'simple' app"
-  (elnode-send-file httpcon (iorg--org-to-html "simple.org")))
+(defun iorg-controller-init-handler (httpcon)
+  "Serves the start-page of the iOrg application"
+  (elnode-send-file httpcon (iorg--org-to-html
+                             ".org")))
 
  (defun iorg-change-state-handler (httpcon)
   "Called by the elnode form handler to update task state."

+ 28 - 16
iorg/lisp/iorg-projects.el

@@ -45,18 +45,24 @@
   :type 'plist)
 
 
-(defun iorg-projects--get-docroot (project)
-  "Return the normalized directory name of PROJECTs document root."
+(defun iorg-projects--get-project-info (project key)
+  "Return the value of KEY for PROJECT."
   (if (not (and (non-empty-string-p project)
                 (assoc project iorg-projects-config)))
       (error (concat "Project not registered in customizable "
                      "variable 'iorg-projects-config'"))
-    (concat (iorg-server-(cdr (assoc :dir iorg-projects-config
-                        (cdr (assoc project iorg-projects-config))))
-            (
-
-
-
+    (cond 
+     ((member
+       key '(:docroot :model :view :controller :persistence :doc :test))
+      (iorg-projects--normalize-existing-dir-name
+       (concat
+        (iorg-projects--normalize-existing-dir-name
+         (cdr (assoc :dir (cdr (assoc project iorg-projects-config)))))
+        (cdr (assoc key (cdr (assoc project iorg-projects-config)))))))
+     ((or (member key '(:dir :host :port))
+          (assoc key (cdr (assoc project iorg-projects-config))))
+      (cdr (assoc key (cdr (assoc project iorg-projects-config)))))
+     (t (error "KEY not found or wrong format - missing leading colon?")))))
 
 
 
@@ -107,14 +113,20 @@ as 'http://HOST:PORT', e.g. 'http://localhost:8008'"
 
 
 (defcustom iorg-projects-urls
-  '(("bugpile" . (("^$"      . iorg-initialize-simple-handler)
-                  ("^edit/$" . iorg-change-state-handler)
-                  ("^send/$" . iorg-change-state-handler)
-                  ("^reset/$" . iorg-edit-headline-handler)))
-    ("test" . (("^$"      . iorg-initialize-simple-handler)
-               ("^edit/$" . iorg-change-state-handler)
-               ("^send/$" . iorg-change-state-handler)
-               ("^reset/$" . iorg-edit-headline-handler))))
+  '(("bugpile" . (("^$"      . iorg-controller-init-handler)
+                  ("^edit/$" . iorg-controller-edit-handler)
+                  ("^send/$" . iorg-controller-send-handler)
+                  ("^reset/$" . iorg-controller-reset-handler)))
+    ("test" .  (("^$"      . iorg-controller-init-handler)
+                  ("^edit/$" . iorg-controller-edit-handler)
+                  ("^send/$" . iorg-controller-send-handler)
+                  ("^reset/$" . iorg-controller-reset-handler))))
+
+
+               ;; (("^$" . iorg-initialize-simple-handler)
+               ;; ("^edit/$" . iorg-change-state-handler)
+               ;; ("^send/$" . iorg-change-state-handler)
+               ;; ("^reset/$" . iorg-edit-headline-handler))))
 
   
   "Alist of iOrg projects with urls.