Update dwpost

This commit is contained in:
trémeur 2022-04-30 18:54:07 +01:00
parent ff4628b2fc
commit e56299d08c
2 changed files with 43 additions and 123 deletions

View file

@ -1,5 +1,4 @@
(defun dwdraft () (defun dwexport ()
(interactive)
(let ((org-export-with-author 'nil) (let ((org-export-with-author 'nil)
(org-export-with-creator 'nil) (org-export-with-creator 'nil)
(org-export-with-date 'nil) (org-export-with-date 'nil)
@ -18,137 +17,52 @@
(delete-region (line-beginning-position) (line-end-position)) (delete-region (line-beginning-position) (line-end-position))
(goto-line 3) (goto-line 3)
(delete-region (line-beginning-position) (line-end-position)) (delete-region (line-beginning-position) (line-end-position))
(write-file newname) (write-file newname)))
(defun dwdraft ()
(interactive)
(dwexport)
(with-current-buffer newname
(kill-ring-save (point-min) (point-max))) (kill-ring-save (point-min) (point-max)))
(kill-buffer newname) (kill-buffer newname)
(with-current-buffer oldname (with-current-buffer oldname
(delete-file newname))) (delete-file newname)))
(defun dwpost (psubject tags icon) (defun dwpost (psubject tags icon location)
(interactive "MPost title (REQUIRED): \nMTags (comma-separated): \nMIcon: ") (interactive (list (read-string "Post title (REQUIRED): ")
(let ((org-export-with-author 'nil) (read-string "Tags (comma-separated): ")
(org-export-with-creator 'nil) (read-string "Icon: ")
(org-export-with-date 'nil) (read-string "Location: " "🏠")))
(org-export-with-section-numbers 'nil) (setq security (completing-read-multiple "Security (public, access, private): " '("public" "access" "private")))
(org-export-time-stamp-file 'nil) (if (not security)
(org-export-with-toc 'nil) (setq security "xpublicx"))
(org-html-validation-link 'nil)) (setq mood (completing-read-multiple "Mood: " '("accomplished" "aggravated" "amused" "angry" "annoyed" "anxious" "apathetic" "artistic" "awake" "bitchy" "blah" "blank" "bored" "bouncy" "busy" "calm" "cheerful" "chipper" "cold" "complacent" "confused" "contemplative" "content" "cranky" "crappy" "crazy" "creative" "crushed" "curious" "cynical" "depressed" "determined" "devious" "dirty" "disappointed" "discontent" "distressed" "ditzy" "dorky" "drained" "drunk" "ecstatic" "embarrassed" "energetic" "enraged" "enthralled" "envious" "exanimate" "excited" "exhausted" "flirty" "frustrated" "full" "geeky" "giddy" "giggly" "gloomy" "good" "grateful" "groggy" "grumpy" "guilty" "happy" "high" "hopeful" "horny" "hot" "hungry" "hyper" "impressed" "indescribable" "indifferent" "infuriated" "intimidated" "irate" "irritated" "jealous" "jubilant" "lazy" "lethargic" "listless" "lonely" "loved" "melancholy" "mellow" "mischievous" "moody" "morose" "naughty" "nauseated" "nerdy" "nervous" "nostalgic" "numb" "okay" "optimistic" "peaceful" "pensive" "pessimistic" "pissed off" "pleased" "predatory" "productive" "quixotic" "recumbent" "refreshed" "rejected" "rejuvenated" "relaxed" "relieved" "restless" "rushed" "sad" "satisfied" "scared" "shocked" "sick" "silly" "sleepy" "sore" "stressed" "surprised" "sympathetic" "thankful" "thirsty" "thoughtful" "tired" "touched" "uncomfortable" "weird" "working" "worried")))
(org-html-export-to-html)) (if (not mood)
(defvar oldname (concat (file-name-base) ".org")) (setq mood "xnonex"))
(defvar newname (concat (file-name-base) ".html")) (dwexport)
(find-file-noselect newname)
(with-current-buffer newname
(goto-line 1)
(delete-region (line-beginning-position) (line-end-position))
(goto-line 2)
(delete-region (line-beginning-position) (line-end-position))
(goto-line 3)
(delete-region (line-beginning-position) (line-end-position))
(write-file newname))
(kill-buffer newname) (kill-buffer newname)
(compose-mail "tobli+0397@post.dreamwidth.org" psubject) (compose-mail "tobli+0397@post.dreamwidth.org" psubject)
(with-current-buffer "*unsent mail to tobli*" (with-current-buffer "*unsent mail to tobli*"
(insert (concat "post-tags: org-export, "tags "\n\n")) (insert (concat "post-tags: org-export, "tags "\n\n"))
(insert (concat "post-security: "
(let* ((stringjunk
(format "%S" security))
(end (- (length stringjunk) 2)))
(substring stringjunk 2 end))"\n\n"))
(insert (concat "post-icon: "icon "\n\n")) (insert (concat "post-icon: "icon "\n\n"))
(insert-file-contents newname) (insert (concat "post-mood: "
(message-send-and-exit)) (let* ((moodjunk
(kill-buffer "*sent mail to tobli*") (format "%S" mood))
(with-current-buffer oldname (end (- (length moodjunk) 2)))
(delete-file newname))) (substring moodjunk 2 end))"\n\n"))
(insert (concat "post-location: "location "\n\n"))
(defun dwpost-public (psubject tags icon) (setq music (lastfm-user-get-recent-tracks :user "litrovers" :from 1 :to 1))
(interactive "MPost title (REQUIRED): \nMTags (comma-separated): \nMIcon: ") (setq music (replace-regexp-in-string (regexp-quote "\" \"") " " (format "%S" music) nil 'literal))
(let ((org-export-with-author 'nil) (insert (concat "post-music: "
(org-export-with-creator 'nil) (let* ((musicjunk
(org-export-with-date 'nil) (format "%S" music))
(org-export-with-section-numbers 'nil) (end (- (length musicjunk) 4)))
(org-export-time-stamp-file 'nil) (substring musicjunk 4 end))"\n\n"))
(org-export-with-toc 'nil)
(org-html-validation-link 'nil))
(org-html-export-to-html))
(defvar oldname (concat (file-name-base) ".org"))
(defvar newname (concat (file-name-base) ".html"))
(find-file-noselect newname)
(with-current-buffer newname
(goto-line 1)
(delete-region (line-beginning-position) (line-end-position))
(goto-line 2)
(delete-region (line-beginning-position) (line-end-position))
(goto-line 3)
(delete-region (line-beginning-position) (line-end-position))
(write-file newname))
(kill-buffer newname)
(compose-mail "tobli+0397@post.dreamwidth.org" psubject)
(with-current-buffer "*unsent mail to tobli*"
(insert "post-security: public\n")
(insert (concat "post-tags: org-export, "tags "\n\n"))
(insert (concat "post-icon: "icon "\n\n"))
(insert-file-contents newname)
(message-send-and-exit))
(kill-buffer "*sent mail to tobli*")
(with-current-buffer oldname
(delete-file newname)))
(defun dwpost-access (psubject tags icon)
(interactive "MPost title (REQUIRED): \nMTags (comma-separated): \nMIcon: ")
(let ((org-export-with-author 'nil)
(org-export-with-creator 'nil)
(org-export-with-date 'nil)
(org-export-with-section-numbers 'nil)
(org-export-time-stamp-file 'nil)
(org-export-with-toc 'nil)
(org-html-validation-link 'nil))
(org-html-export-to-html))
(defvar oldname (concat (file-name-base) ".org"))
(defvar newname (concat (file-name-base) ".html"))
(find-file-noselect newname)
(with-current-buffer newname
(goto-line 1)
(delete-region (line-beginning-position) (line-end-position))
(goto-line 2)
(delete-region (line-beginning-position) (line-end-position))
(goto-line 3)
(delete-region (line-beginning-position) (line-end-position))
(write-file newname))
(kill-buffer newname)
(compose-mail "tobli+0397@post.dreamwidth.org" psubject)
(with-current-buffer "*unsent mail to tobli*"
(insert "post-security: access\n")
(insert (concat "post-tags: org-export, "tags "\n\n"))
(insert (concat "post-icon: "icon "\n\n"))
(insert-file-contents newname)
(message-send-and-exit))
(kill-buffer "*sent mail to tobli*")
(with-current-buffer oldname
(delete-file newname)))
(defun dwpost-me (psubject tags icon)
(interactive "MPost title (REQUIRED): \nMTags (comma-separated): \nMIcon: ")
(let ((org-export-with-author 'nil)
(org-export-with-creator 'nil)
(org-export-with-date 'nil)
(org-export-with-section-numbers 'nil)
(org-export-time-stamp-file 'nil)
(org-export-with-toc 'nil)
(org-html-validation-link 'nil))
(org-html-export-to-html))
(defvar oldname (concat (file-name-base) ".org"))
(defvar newname (concat (file-name-base) ".html"))
(find-file-noselect newname)
(with-current-buffer newname
(goto-line 1)
(delete-region (line-beginning-position) (line-end-position))
(goto-line 2)
(delete-region (line-beginning-position) (line-end-position))
(goto-line 3)
(delete-region (line-beginning-position) (line-end-position))
(write-file newname))
(kill-buffer newname)
(compose-mail "tobli+0397@post.dreamwidth.org" psubject)
(with-current-buffer "*unsent mail to tobli*"
(insert "post-security: private\n")
(insert (concat "post-tags: org-export, "tags "\n\n"))
(insert (concat "post-icon: "icon "\n\n"))
(insert-file-contents newname) (insert-file-contents newname)
(message-send-and-exit)) (message-send-and-exit))
(kill-buffer "*sent mail to tobli*") (kill-buffer "*sent mail to tobli*")

6
snippets/org-mode/player Normal file
View file

@ -0,0 +1,6 @@
# name: audio-player
# key: player
# --
#+HTML: <audio controls=""><source src="$1" type="audio/mp3"></source> Your browser does not support the audio element. </audio>
$0