(defvar ee-mip-dir-local)
(defvar ee-mip-dir-remote)
(defvar ee-mip-user-remote)
(defvar ee-mip-http-remote)
(defvar ee-mip-http-port)

(defun ee-mip-edrx ()
  (setq ee-mip-dir-local   "/tmp/linode-p/")
  (setq ee-mip-dir-remote  "/tmp/p/")
  (setq ee-mip-user-remote "edrx@linode")
  (setq ee-mip-http-remote "http://linode:8002/")
  (setq ee-mip-http-port   "8002"))

;; Bruno, ajusta isso aqui pfavor...
(defun ee-mip-brnm ()
  (setq ee-mip-dir-local   "/tmp/mip/")
  (setq ee-mip-dir-remote  "/tmp/mip/")
  (setq ee-mip-user-remote "redner_vps@justclaymoving.xyz")
  (setq ee-mip-http-remote "http://justclaymoving.xyz/")
  (setq ee-mip-http-port   "80"))

(defun ee-mip-dir-local     () ee-mip-dir-local)
(defun ee-mip-dir-remote    () ee-mip-dir-remote)
(defun ee-mip-user-remote   () ee-mip-user-remote)
(defun ee-mip-http-remote   () ee-mip-http-remote)
(defun ee-mip-http-port     () ee-mip-http-port)
(defun ee-mip-ssh-remote-hs () (format "ssh %s (hs)" (ee-mip-user-remote)))
(defun ee-mip-ssh-remote    () (format "ssh %s"      (ee-mip-user-remote)))

;; Test: (eepitch-mip-hs)
(defun eepitch-mip-hs ()
  (interactive)
  (eepitch-comint (ee-mip-ssh-remote-hs)
		  (ee-mip-ssh-remote)))

;; Test: (ee-mip-edrx)
;;       (ee-mip-brnm)
;;       (find-estring-sh (ee-mip-links-body "o"))
(defun ee-mip-links-body (file)
  (let* ((dir-local   (ee-mip-dir-local))
         (dir-remote  (ee-mip-dir-remote))
         (user@remote (ee-mip-user-remote))
         (http-remote (ee-mip-http-remote))
         (port        (ee-mip-http-port))
	 (wgets       (ee-minipaste-find-wgets http-remote file)))
    (ee-template0 "\
 Scp to the remote machine.
 Uncomment the \"date ...\" for a simple test.
 (eepitch-shell2)
 (eepitch-kill)
 (eepitch-shell2)
mkdir -p     {dir-local}
# date | tee {dir-local}{file}
ssh {user@remote} \"mkdir -pv {dir-remote}\"
scp {dir-local}{file} {user@remote}:{dir-remote}

{wgets}



 Inspect/restart the http server
 (eepitch-mip-hs)
 (eepitch-kill)
 (eepitch-mip-hs)
mkdir -p {dir-remote}
# Choose one:
sudo python3 -m http.server --directory {dir-remote} {port}
     python3 -m http.server --directory {dir-remote} {port}
")))



;; <find-mip-links>
;; Skel: (find-find-links-links-new "mip" "file" "")
;; Test: (ee-mip-edrx)
;;       (ee-mip-brnm)
;;       (find-mip-links)
;;
(defun find-mip-links (&optional file &rest pos-spec-list)
"Visit a temporary buffer containing hyperlinks for mip."
  (interactive)
  (setq file (or file "{file}"))
  (apply
   'find-elinks-sh
   `((find-mip-links ,file ,@pos-spec-list)
     (find-mip-links "o")
     ;; Convention: the first sexp always regenerates the buffer.
     (find-efunction 'find-mip-links)
     ""
     ,(ee-mip-links-body file)
     ,(ee-template0 "\
")
     )
   pos-spec-list))
