tumashu / org2web

A static site generator based on org-mode
http://tumashu.github.io/org2web
89 stars 10 forks source link

Script generation for rclone not working! #9

Closed shackra closed 8 years ago

shackra commented 8 years ago

I'll take care of this, hopefully I figure it out what I'm doing wrong, here the error:

Debugger entered--Lisp error: (wrong-number-of-arguments #[(template context) "\302    \"\207" [template context mst--render] 3 ("/home/jorge/.emacs.d/elpa/mustache-20131117.1407/mustache.elc" . 438)] 3)
  mustache-render("#!/bin/bash\n\nset -e\n\nexport_dir=\"{{export-dir}}\"\npublish_dir=\"{{publish-dir}}\"\nremote_name=\"{{remote-name}}\"\n\necho '###########################################################'\necho '##         Org-webpage upload script using rclone        ##'\necho '###########################################################'\n\necho ''\necho \"Export     Directory: $export_dir\"\necho \"Publish    Directory: $publish_dir\"\necho \"Remote location name: $remote_dir\"\n\n# check if rclone even exists\necho 'Checking of rclone is installed and can be found in $PATH'\ncommand -v rclone >/dev/null 2>&1 || {\n    echo >&2 \"I require rclone but it's not installed.\";\n    echo >&2 \"Install Go from https://golang.org/dl/ and then\";\n    echo >&2 \"Install rclone with:\";\n    echo >&2 \" go get github.com/ncw/rclone\";\n    echo >&2 \"An alternative to this would be downloading rclone\";\n    echo >&2 \"directly from http://rclone.org/downloads/. Aborting upload.\";\n    exit 1;\n}\n\n# Just upload the stuff, for now\necho 'Uploading'\nif [ $remote_name == \"local\" ]; then\n    rclone sync \"${export_dir}\" \"${publish_dir}\"\nelse\n    rclone sync \"${export_dir}\" $remote_name:\"${publish_dir}\"\nfi\n" nil #s(hash-table size 65 test equal rehash-size 1.5 rehash-threshold 0.8 data ("export-dir" "/export-dir" "publish-dir" "/publish-dir" "remote-name" "rscf" ...)))
  (owp/string-to-file (mustache-render (save-current-buffer (set-buffer "rclone.mustache") (buffer-substring-no-properties (point-min) (point-max))) (if (eq (nth 0 remote) (quote git)) (progn (let ((ht-temp (ht-create))) (ht-set! ht-temp "export-dir" (expand-file-name export-dir)) (ht-set! ht-temp "history-dir" (expand-file-name history-dir)) (ht-set! ht-temp "publish-dir" (expand-file-name publish-dir)) (ht-set! ht-temp "remote-url" (nth 1 remote)) (ht-set! ht-temp "remote-branch" (nth 2 remote)) (ht-set! ht-temp "partial-update" (if partial-update "yes" "no")) ht-temp))) (if (eq (nth 0 remote) (quote rclone)) (progn (let ((ht-temp (ht-create))) (ht-set! ht-temp "export-dir" (expand-file-name "/export-dir")) (ht-set! ht-temp "publish-dir" (expand-file-name "/publish-dir")) (ht-set! ht-temp "remote-name" (nth 1 remote)) ht-temp)))) script-file)
  (let* ((remote (quote (rclone "rscf")))) (owp/string-to-file (mustache-render (save-current-buffer (set-buffer "rclone.mustache") (buffer-substring-no-properties (point-min) (point-max))) (if (eq (nth 0 remote) (quote git)) (progn (let ((ht-temp ...)) (ht-set! ht-temp "export-dir" (expand-file-name export-dir)) (ht-set! ht-temp "history-dir" (expand-file-name history-dir)) (ht-set! ht-temp "publish-dir" (expand-file-name publish-dir)) (ht-set! ht-temp "remote-url" (nth 1 remote)) (ht-set! ht-temp "remote-branch" (nth 2 remote)) (ht-set! ht-temp "partial-update" (if partial-update "yes" "no")) ht-temp))) (if (eq (nth 0 remote) (quote rclone)) (progn (let ((ht-temp ...)) (ht-set! ht-temp "export-dir" (expand-file-name "/export-dir")) (ht-set! ht-temp "publish-dir" (expand-file-name "/publish-dir")) (ht-set! ht-temp "remote-name" (nth 1 remote)) ht-temp)))) script-file))
  eval((let* ((remote (quote (rclone "rscf")))) (owp/string-to-file (mustache-render (save-current-buffer (set-buffer "rclone.mustache") (buffer-substring-no-properties (point-min) (point-max))) (if (eq (nth 0 remote) (quote git)) (progn (let ((ht-temp ...)) (ht-set! ht-temp "export-dir" (expand-file-name export-dir)) (ht-set! ht-temp "history-dir" (expand-file-name history-dir)) (ht-set! ht-temp "publish-dir" (expand-file-name publish-dir)) (ht-set! ht-temp "remote-url" (nth 1 remote)) (ht-set! ht-temp "remote-branch" (nth 2 remote)) (ht-set! ht-temp "partial-update" (if partial-update "yes" "no")) ht-temp))) (if (eq (nth 0 remote) (quote rclone)) (progn (let ((ht-temp ...)) (ht-set! ht-temp "export-dir" (expand-file-name "/export-dir")) (ht-set! ht-temp "publish-dir" (expand-file-name "/publish-dir")) (ht-set! ht-temp "remote-name" (nth 1 remote)) ht-temp)))) script-file)) nil)
  eval-last-sexp-1(nil)
  eval-last-sexp(nil)
  call-interactively(eval-last-sexp nil nil)
  command-execute(eval-last-sexp)

And here is some elisp that can help reproduce/debug it:

(let* ((remote '(rclone "rscf")))
  (owp/string-to-file
   (mustache-render
    (with-current-buffer "rclone.mustache"
      (buffer-substring-no-properties (point-min) (point-max)))
    (when (eq (nth 0 remote) 'git)
      (ht ("export-dir" (expand-file-name export-dir))
          ("history-dir" (expand-file-name history-dir))
          ("publish-dir" (expand-file-name publish-dir))
          ("remote-url" (nth 1 remote))
          ("remote-branch" (nth 2 remote))
          ("partial-update" (if partial-update "yes" "no"))))
    (when (eq (nth 0 remote) 'rclone)
      (ht ("export-dir" (expand-file-name "/export-dir"))
          ("publish-dir" (expand-file-name "/publish-dir"))
          ("remote-name" (nth 1 remote)))))
   script-file))

Here is the script, a little modified btw:

#!/bin/bash

set -e

export_dir="{{export-dir}}"
publish_dir="{{publish-dir}}"
remote_name="{{remote-name}}"

echo '###########################################################'
echo '##         Org-webpage upload script using rclone        ##'
echo '###########################################################'

echo ''
echo "Export     Directory: $export_dir"
echo "Publish    Directory: $publish_dir"
echo "Remote location name: $remote_dir"

# check if rclone even exists
echo 'Checking of rclone is installed and can be found in $PATH'
command -v rclone >/dev/null 2>&1 || {
    echo >&2 "I require rclone but it's not installed.";
    echo >&2 "Install Go from https://golang.org/dl/ and then";
    echo >&2 "Install rclone with:";
    echo >&2 " go get github.com/ncw/rclone";
    echo >&2 "An alternative to this would be downloading rclone";
    echo >&2 "directly from http://rclone.org/downloads/. Aborting upload.";
    exit 1;
}

# Just upload the stuff, for now
echo 'Uploading'
if [ $remote_name == "local" ]; then
    rclone sync "${export_dir}" "${publish_dir}"
else
    rclone sync "${export_dir}" $remote_name:"${publish_dir}"
fi
shackra commented 8 years ago

Seems like when doesn't return what I'm expecting it to return, this code works with no issues when the when conditionals are remove:

(let* ((remote '(rclone "rscf"))
       (script-file "owp-upload-script.sh"))
  (owp/string-to-file
   (mustache-render
    (with-current-buffer "rclone.mustache"
      (buffer-substring-no-properties (point-min) (point-max))) 
    (ht ("export-dir" (expand-file-name "/export-dir"))
        ("publish-dir" (expand-file-name "/publish-dir"))
        ("remote-name" (nth 1 remote))))
   script-file))
tumashu commented 8 years ago

Thank you for your hard work!

shackra commented 8 years ago

No! Thanks to you!!

El martes 09 de agosto del 2016 a las 1823 horas, tumashu escribió:

Thank you for your hard work!

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.

👋 Pax et bonum. Jorge Araya Navarro https://es.gravatar.com/shackra

tumashu commented 8 years ago

I have refacter the uploader‘s code, which make adding a new upload-method easier, I upgrade your code too, but I wish you to test rclone feature again, thanks, by the way, rclone.mustache may need future improve.

tumashu commented 8 years ago

When you want to edit README, you should EDIT commentary of org-webpage.el , README.md is a generated file and will be override

shackra commented 8 years ago

Ouh, I didn't know that! Sorry!

El 10 de agosto de 2016 3:59:44 GMT-06:00, tumashu notifications@github.com escribió:

When you want to edit README, you should EDIT commentary of org-webpage.el , README.md is a generated file and will be override


You are receiving this because you modified the open/close state. Reply to this email directly or view it on GitHub: https://github.com/tumashu/org-webpage/issues/9#issuecomment-238821163

Sent from my Android device with K-9 Mail. Please excuse my brevity.