Final edits to posting function (for now)

master
trémeur 3 years ago
parent 23ecdc57b1
commit bd7155ba59

@ -1,3 +1,14 @@
;; variables live here
(setq dw-username "tobli")
(setq dw-pin "0397")
(setq dw-defaultlocation "🏠")
(setq dw-iconfile "~/Documents/drive/org/iconchoose.el")
(setq lastfm-login t) ;; boolean
(setq lastfm-user "litrovers")
;;;;;;;;;;;;;;;;;;;;;;
(defun dwexport () (defun dwexport ()
(let ((org-export-with-author 'nil) (let ((org-export-with-author 'nil)
(org-export-with-creator 'nil) (org-export-with-creator 'nil)
@ -7,8 +18,8 @@
(org-export-with-toc 'nil) (org-export-with-toc 'nil)
(org-html-validation-link 'nil)) (org-html-validation-link 'nil))
(org-html-export-to-html)) (org-html-export-to-html))
(defvar oldname (concat (file-name-base) ".org")) (setq oldname (concat (file-name-base) ".org"))
(defvar newname (concat (file-name-base) ".html")) (setq newname (concat (file-name-base) ".html"))
(find-file-noselect newname) (find-file-noselect newname)
(with-current-buffer newname (with-current-buffer newname
(goto-line 1) (goto-line 1)
@ -53,7 +64,7 @@
(substring moodjunk 2 end))"\n")))) (substring moodjunk 2 end))"\n"))))
(defun dwmusic () (defun dwmusic ()
(setq music (lastfm-user-get-recent-tracks :user "litrovers" :from 1 :to 1)) (setq music (lastfm-user-get-recent-tracks :user lastfm-user :from 1 :to 1))
(setq music (replace-regexp-in-string (regexp-quote "\" \"") " " (format "%S" music) nil 'literal)) (setq music (replace-regexp-in-string (regexp-quote "\" \"") " " (format "%S" music) nil 'literal))
(sleep-for 1) (sleep-for 1)
(if (not music) (if (not music)
@ -68,20 +79,15 @@
(defun dwicon (thefile) (defun dwicon (thefile)
(setq icon "skip") (setq icon "skip")
(load-file dw-iconfile)
(with-current-buffer thefile (with-current-buffer thefile
(cond (iconchoose))
((string-match-p "\\bbraska\\b" (buffer-substring (point-min) (point-max))) (setq icon "braska"))
((string-match-p "\\bffx[^-]\\b" (buffer-substring (point-min) (point-max))) (setq icon "ffx"))
((string-match-p "\\bffx-2\\b" (buffer-substring (point-min) (point-max))) (setq icon "ffx-2"))
((string-match-p "\\belp\\b" (buffer-substring (point-min) (point-max))) (setq icon "elp"))
((string-match-p "\\bprog\\b" (buffer-substring (point-min) (point-max))) (setq icon "prog"))
((string-match-p "\\btarkus\\b" (buffer-substring (point-min) (point-max))) (setq icon "tarkus"))))
(if (equal icon "skip") (if (equal icon "skip")
(sleep-for 0) (sleep-for 0)
(insert (concat "post-icon: "icon "\n")))) (insert (concat "post-icon: "icon "\n"))))
(defun dwlocation () (defun dwlocation ()
(setq location (read-string "Location: " "🏠")) (setq location (read-string "Location: " dw-defaultlocation))
(if (equal location "") (if (equal location "")
(sleep-for 0) (sleep-for 0)
(insert (concat "post-location: " location "\n")))) (insert (concat "post-location: " location "\n"))))
@ -96,18 +102,20 @@
(interactive (list (read-string "Post title (REQUIRED): ") (interactive (list (read-string "Post title (REQUIRED): ")
(read-string "Tags (comma-separated): "))) (read-string "Tags (comma-separated): ")))
(dwexport) (dwexport)
(compose-mail "tobli+0397@post.dreamwidth.org" psubject) (compose-mail (concat dw-username "+" dw-pin "@post.dreamwidth.org") psubject)
(with-current-buffer "*unsent mail to tobli*" (with-current-buffer (concat "*unsent mail to " dw-username "*")
(insert (concat "post-tags: org-export, " tags "\n")) (insert (concat "post-tags: org-export, " tags "\n"))
(dwsecurity) (dwsecurity)
(dwlocation) (dwlocation)
(dwicon newname) (dwicon newname)
(cond
(lastfm-login t (dwmusic))
((dwmusic-manual)))
(dwmood) (dwmood)
(dwmusic)
(insert (concat "\n")) (insert (concat "\n"))
(insert-file-contents newname) (insert-file-contents newname)
(message-send-and-exit)) (message-send-and-exit))
(kill-buffer newname) (kill-buffer newname)
(kill-buffer "*sent mail to tobli*") (kill-buffer (concat "*sent mail to " dw-username "*"))
(with-current-buffer oldname (with-current-buffer oldname
(delete-file newname))) (delete-file newname)))

Loading…
Cancel
Save