From f7cc8a984fa9cc6e33287ba53d604146a3f08150 Mon Sep 17 00:00:00 2001
From: Sacha Chua
Date: Tue, 20 Sep 2022 20:00:10 -0400
Subject: Bring in more code from 2021
---
emacsconf-erc.el | 320 +++++++++++++++++++++++++++++++++++++++++++++++++
emacsconf-ical.el | 110 +++++++++++++++++
emacsconf-pentabarf.el | 125 +++++++++++++++++++
emacsconf-publish.el | 208 ++++++++++++++++++++++++++++++++
emacsconf-subed.el | 4 +-
emacsconf.el | 168 ++++++++++++++++++++++++--
6 files changed, 924 insertions(+), 11 deletions(-)
create mode 100644 emacsconf-erc.el
create mode 100644 emacsconf-ical.el
create mode 100644 emacsconf-pentabarf.el
diff --git a/emacsconf-erc.el b/emacsconf-erc.el
new file mode 100644
index 0000000..2040db3
--- /dev/null
+++ b/emacsconf-erc.el
@@ -0,0 +1,320 @@
+;;; emacsconf-erc.el --- Integrate with Emacs Relay Chat -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2022 Sacha Chua
+
+;; Author: Sacha Chua
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see .
+
+;;; Commentary:
+
+;; - /announce slug
+;; - /broadcast message
+;; - /conftopic message
+;; - /checkin ROOM nick
+;; - /ready ROOM slug
+
+;;; Code:
+
+(defcustom emacsconf-collaborative-pad
+ (concat "https://etherpad.wikimedia.org/p/emacsconf-" emacsconf-year)
+ "URL for the pad that will have questions."
+ :group 'emacsconf
+ :type 'string)
+
+(defcustom emacsconf-streaming-nick nil "Set to the host's IRC nick in order to notify them."
+ :group 'emacsconf
+ :type 'string)
+
+(defcustom emacsconf-topic-templates
+ '(("#emacsconf" "EmacsConf 2022 | Subscribe to https://lists.gnu.org/mailman/listinfo/emacsconf-discuss for updates")
+ ("#emacsconf-accessible" "EmacsConf 2022 accessibility - help by describing what's happening | Subscribe to https://lists.gnu.org/mailman/listinfo/emacsconf-discuss for updates")
+ ("#emacsconf-org" "EmacsConf 2022 | Dedicated channel for EmacsConf organizers and speakers | this is intended as an internal, low-traffic channel; for main discussion around EmacsConf, please join #emacsconf | Subscribe to https://lists.gnu.org/mailman/listinfo/emacsconf-discuss for updates")
+ ("#emacsconf-questions" "EmacsConf 2022 | Low-traffic channel for questions if speakers prefer IRC and need help focusing; for main discussion around EmacsConf, please join #emacsconf | Subscribe to https://lists.gnu.org/mailman/listinfo/emacsconf-discuss for updates"))
+ "List of (channel topic-template) entries for mass-setting channel topics."
+ :group 'emacsconf
+ :type '(repeat (list (string :tag "Channel")
+ (string :tag "Topic suffix"))))
+
+;; For testing: (setq emacsconf-topic-templates '(("#emacsconf-test" "EmacsConf 2021 | Dedicated channel for EmacsConf organizers and speakers | this is intended as an internal, low-traffic channel; for main discussion around EmacsConf, please join #emacsconf | Subscribe to https://lists.gnu.org/mailman/listinfo/emacsconf-discuss for updates")))
+
+(defcustom emacsconf-rooms
+ '(("A" "http://example.org?room=a")
+ ("B" "http://example.org?room=b")
+ ("C" "http://example.org?room=c"))
+ "Room IDs and URLs."
+ :group 'emacsconf
+ :type '(repeat (list (string :tag "ID")
+ (string :tag "URL"))))
+
+ (defmacro emacsconf-erc-with-channels (channel-list &rest forms)
+ (declare (indent 1) (debug (form form body)))
+ `(mapcar (lambda (channel)
+ (with-current-buffer (erc-get-buffer channel)
+ ,@forms))
+ ,channel-list))
+
+ (defun emacsconf-get-room (room)
+ (cadr (assoc (upcase room) emacsconf-rooms)))
+
+ (defun erc-cmd-CONFTOPIC (&rest message)
+ "Set the topic to MESSAGE | template in the emacsconference channels.
+ If MESSAGE is not specified, reset the topic to the template."
+ (mapc (lambda (template)
+ (with-current-buffer (erc-get-buffer (car template))
+ (erc-cmd-TOPIC (if message (concat (if (stringp message) message (s-join " " message)) " | " (cadr template))
+ (cadr template)))))
+ emacsconf-topic-templates))
+
+(defun erc-cmd-CHECKIN (nick &optional q-and-a)
+ (let ((talk (emacsconf-complete-talk))
+ info)
+ (save-excursion
+ (emacsconf-with-talk-heading talk
+ (org-entry-put (point) "IRC" nick)
+ (org-entry-put (point) "CHECK_IN" (format-time-string "%H:%M"))
+ (setq info (emacsconf-get-talk-info-for-subtree))))
+ (setq q-and-a (or q-and-a (plist-get info :q-and-a) ""))
+ (cond
+ ((string-match "live" q-and-a)
+ (erc-send-message (format "%s: Thanks for checking in! I'll send you some private messages with instructions, so please check there. Let me know if you don't get them." nick))
+ (erc-cmd-BBB (completing-read "Room: " emacsconf-rooms) nick talk))
+ ((string-match "pad" q-and-a)
+ (erc-send-message (format "%s: Thanks for checking in! The collaborative pad we'll be using for questions is at %s . We'll collect questions from #emacsconf and put them there. If you'd like to jump to your part of the document, you might be able to keep an eye on questions. Please let us know if you need help, or if you want to switch to live Q&A." nick emacsconf-collaborative-pad)))
+ ((string-match "IRC" q-and-a)
+ (erc-send-message (format "%s: Thanks for checking in! Feel free to keep an eye on #emacsconf for questions and discussion, and we'll copy things from the pad to there. If the volume gets overwhelming, let us know and we can forward questions to #emacsconf-questions for you. If you'd like to try Q&A over live video or the collaborative pad instead, or if you need help, please let us know." nick emacsconf-collaborative-pad)))
+ (t (erc-send-message (format "%s: Thanks for checking in! How would you like to handle Q&A today - live video, the collaborative Etherpad at %s , or IRC (like this)?" nick emacsconf-collaborative-pad))))
+ (emacsconf-with-talk-heading talk
+ (emacsconf-upcoming-insert-or-update nil t))))
+
+(defun erc-cmd-BBB (room nick &optional talk)
+ "Send instructions for ROOM and `conf-collaborative-pad' to NICK."
+ (let ((room-url (emacsconf-get-room room)))
+ (unless room-url (error "Please specify nick and room name"))
+ (erc-message "PRIVMSG" (format "%s You can use this BBB room: %s . I'll join you there shortly to set up the room and do the last-minute tech check." nick room-url))
+ (erc-message "PRIVMSG" (format "%s The collaborative pad we'll be using for questions is at %s . We'll collect questions from #emacsconf and put them there. If you'd like to jump to your part of the document, you might be able to keep an eye on questions. Alternatively, we can read questions to you." nick emacsconf-collaborative-pad))
+ (erc-message "PRIVMSG" (format "%s The host will join and give you the go-ahead when it's time to present. See you in the BBB room!" nick))
+ (setq talk (or talk (emacsconf-complete-talk)))
+ (emacsconf-with-talk-heading talk
+ (let ((talk-info (emacsconf-get-talk-info-for-subtree)))
+ (org-entry-put (point) "BBB_ROOM" room-url)
+ (when emacsconf-tasks-file
+ (with-current-buffer (find-file-noselect emacsconf-tasks-file)
+ (goto-char (point-min))
+ (insert (emacsconf-replace-plist-in-string
+ (append info (list :current-time (format-time-string "[%Y-%m-%d %a %H:%M]")))
+ "* WAITING [#A] Check in ${nick} (${speakers}) for %s at %s
+:PROPERTIES:
+:CREATED: ${current-time}
+:END:
+[[file:~/vendor/emacsconf-wiki/playbook.org::#check-in][file:~/vendor/emacsconf-wiki/playbook.org::#check-in]]
+
+"))))))))
+
+(defun erc-cmd-READY (code &rest filter)
+ "Notify #emacsconf-org and `conf-streaming-nick' that CODE is ready for the talk specified by FILTER.
+FILTER can be the talk ID or strings to match against the title or speaker names."
+ (let ((room-url (emacsconf-get-room code))
+ (talk (emacsconf-find-talk-info filter))
+ pronouns pronunciation)
+ (unless room-url (error "Could not find room"))
+ (unless talk (error "Could not find talk"))
+ (emacsconf-with-talk-heading (plist-get talk :slug)
+ (setq pronouns (org-entry-get (point) "PRONOUNS")
+ pronunciation (org-entry-get (point) "PRONUNCIATION")))
+ (with-current-buffer (erc-get-buffer "#emacsconf-org")
+ (erc-send-message (format "Ready in Room %s: %s (%s)"
+ (upcase code)
+ (plist-get talk :title)
+ (plist-get talk :speakers))))
+ (mapc (lambda (nick)
+ (erc-message "PRIVMSG"
+ (format "%s Ready in Room %s ( %s ): %s (%s) %s %s"
+ emacsconf-nick
+ (upcase code)
+ room-url
+ (plist-get talk :title)
+ (plist-get talk :speakers)
+ (or pronouns "")
+ (or pronunciation ""))))
+ (if (listp emacsconf-streaming-nick) emacsconf-streaming-nick (list emacsconf-streaming-nick)))))
+
+
+(defun erc-cmd-ANNOUNCE (filter)
+ "Set the channel topics to announce the talk specified by FILTER.
+ FILTER can be the talk ID or strings to match against the title or speaker names."
+ (let ((info
+ (if (listp filter)
+ (car filter)
+ (emacsconf-find-talk-info filter))))
+ (unless info (error "Could not find talk."))
+ (erc-cmd-CONFTOPIC (format "%s: %s (%s)"
+ (plist-get info :slug)
+ (plist-get info :title)
+ (plist-get info :speakers)))
+ (erc-cmd-BROADCAST (format "---- %s (%s, https://emacsconf.org/%s/talks/%s) ----"
+ (plist-get info :title)
+ (plist-get info :speakers)
+ emacsconf-year
+ (plist-get info :slug)))))
+
+(defun erc-cmd-OPALL ()
+ (emacsconf-erc-with-channels (mapcar 'car emacsconf-topic-templates)
+ (erc-cmd-OPME)))
+
+(defun erc-cmd-BROADCAST (&rest message)
+ "Say MESSAGE in all the emacsconference channels."
+ (emacsconf-erc-with-channels (mapcar 'car emacsconf-topic-templates)
+ (erc-send-message (s-join " " message))))
+
+(defun erc-cmd-JUMP (talk)
+ (emacsconf-go-to-talk talk))
+
+(defun erc-cmd-SETPROP (property talk value)
+ (save-window-excursion
+ (emacsconf-with-talk-heading talk
+ (org-entry-put (point) (upcase property) value))))
+
+(defun erc-cmd-GETPROP (property talk)
+ (save-window-excursion
+ (emacsconf-with-talk-heading talk
+ (message "%s" (org-entry-get (point) (upcase property))))))
+
+(defun emacsconf-set-start-time-for-slug (slug time)
+ (interactive (list (emacsconf-complete-talk) (read-string "Start: ")))
+ (emacsconf-with-talk-heading slug
+ (emacsconf-org-set-start-time (emacsconf-time-or-offset-to-time time))))
+
+(defun emacsconf-org-set-qa-end (slug time)
+ (interactive (list (emacsconf-complete-talk) (read-string "Q&A end: ")))
+ (emacsconf-with-talk-heading slug
+ (org-entry-put (point) "Q_AND_A_END"
+ (org-format-time-string (cdr org-time-stamp-formats) (emacsconf-time-or-offset-to-time time)))
+ (let ((info (list :title (org-entry-get (point) "ITEM"))))
+ (when emacsconf-tasks-file
+ (with-current-buffer (find-file-noselect emacsconf-tasks-file)
+ (goto-char (point-max))
+ (insert (emacsconf-replace-plist-in-string info "\n* TODO [#C] Process Q&A for ${title}
+
+")))))))
+
+(defun emacsconf-end-current-talk (time)
+ (interactive (read-string "Time: "))
+ (with-current-buffer (find-file-noselect emacsconf-org-file)
+ (org-map-entries
+ (lambda ()
+ (org-todo "DONE")
+ (when (and (string-match "live" (org-entry-get (point) "Q_AND_A"))
+ (null (org-entry-get (point) "Q_AND_A_END")))
+ (save-excursion
+ (emacsconf-org-set-qa-end
+ (org-entry-get (point) "SLUG")
+ time)))
+ (emacsconf-update-talk))
+ "SLUG=.+TODO=\"STARTED\"")))
+
+(defun emacsconf-announce (slug time)
+ "Announce that the talk SLUG has started. Optionally, set the start time to TIME."
+ (interactive (list (emacsconf-complete-talk) (read-string "Start: ")))
+ ;; mark the previous talk done
+ (emacsconf-end-current-talk time)
+ ;; mark the current talk started
+ (emacsconf-with-talk-heading slug
+ (erc-cmd-ANNOUNCE (org-entry-get (point) "SLUG"))
+ (emacsconf-org-set-start-time (emacsconf-time-or-offset-to-time time))))
+
+(defun emacsconf-org-set-start-time (time)
+ "Set the start time of the current entry to TIME.
+TIME can be hh:mm or an offset such as -2 (two minutes ago) based on current time."
+ (interactive "MStart: ")
+ (let ((sched (org-timestamp-from-string (org-entry-get (point) "SCHEDULED")))
+ info)
+ (org-todo "STARTED")
+ (org-set-property "SCHEDULED"
+ (org-format-time-string "%Y-%m-%d %H:%M" (emacsconf-time-or-offset-to-time time)))
+ (org-entry-put (point) "FIXED_TIME" "1")
+ (org-entry-put (point) "PUBLIC" "1")
+ (setq info (emacsconf-get-talk-info-for-subtree))
+ (setq info (append info
+ (list :video-description (emacsconf-video-description info)
+ :conf-year emacsconf-year
+ :conf-directory emacsconf-directory)))
+ (emacsconf-update-talk)
+ (when emacsconf-tasks-file
+ (with-current-buffer (find-file-noselect emacsconf-tasks-file)
+ (goto-char (point-max))
+ (unless (re-search-backward "TODO.*Update schedule on wiki" nil t)
+ (insert "\n* TODO [#B] Update schedule on wiki\n"))
+ (goto-char (point-max))
+ (insert (emacsconf-replace-plist-in-string info
+"\n* TODO [#B] Check ${title} on https://media.emacsconf.org/${conf-year}
+
+,* TODO [#B] Commit the page update for ${title} and check https://emacsconf.org/${conf-year}/talks/${slug}/
+
+[[elisp:(magit-status-setup-buffer \"${conf-directory}\"]]
+
+,* TODO [#C] Publish ${title} on YouTube and ToobNix
+
+${video-description}
+
+"))))
+ (emacsconf-publish-files)
+ (emacsconf-update-media)))
+
+
+(defun erc-cmd-START (talk &optional time)
+ "Adjusts the start time and sets the FIXED_TIME property.
+/FIXSTART news 9:03 - set it to start at that time
+/FIXSTART news -2 - two minutes ago"
+ (save-window-excursion
+ (emacsconf-with-talk-heading talk
+ (emacsconf-org-set-start-time time))))
+
+(defun emacsconf-org-log-note (note)
+ "Add NOTE to the current entry's logbook."
+ (interactive "MNote: ")
+ (setq org-log-note-window-configuration (current-window-configuration))
+ (move-marker org-log-note-return-to (point))
+ (move-marker org-log-note-marker (point))
+ (setq org-log-note-purpose 'note)
+ (with-temp-buffer
+ (insert note)
+ (org-store-log-note)))
+
+(defun erc-cmd-CONFLOG (talk &rest notes)
+ "Go to TALK and store NOTES in the :LOGBOOK:.
+Usage: /conflog keyword notes go here"
+ (save-window-excursion
+ (emacsconf-with-talk-heading talk (emacsconf-org-log-note (s-join " " notes)))))
+
+(defun erc-cmd-GIT (&optional location)
+ (if (string= location "conf")
+ (magit-status (file-name-directory emacsconf-org-file))
+ (magit-status emacsconf-directory)))
+
+(defun erc-cmd-CONF (&rest args)
+ (cond
+ ((string= (car args) "checkin")
+ (apply 'erc-cmd-CHECKIN (cdr args)))
+ ((string= (car args) "start")
+ (apply 'erc-cmd-START (cdr args)))
+ ((string= (car args) "git")
+ (apply 'erc-cmd-GIT (cdr args)))
+ ((string= (car args) "log")
+ (apply 'erc-cmd-CONFLOG (cdr args)))
+ (t (message "checkin start git log"))))
+
+(provide 'emacsconf-erc)
+;;; emacsconf-erc.el ends here
diff --git a/emacsconf-ical.el b/emacsconf-ical.el
new file mode 100644
index 0000000..c0cf4e4
--- /dev/null
+++ b/emacsconf-ical.el
@@ -0,0 +1,110 @@
+;;; emacsconf-ical.el --- ical export -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2021 Sacha Chua
+
+;; Author: Sacha Chua
+;; Keywords: multimedia
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see .
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(defun emacsconf-ical-send-via-email ()
+ (interactive)
+ (let ((ical-file (expand-file-name
+ (concat (org-entry-get (point) "SLUG") ".ics")
+ (expand-file-name "ics" (file-name-directory emacsconf-org-file))))
+ (ical-entry (emacsconf-ical-convert-entry-to-string (format-time-string "%Y%m%dT%H%M%SZ" nil t))))
+ (with-temp-file ical-file
+ (insert ical-entry))
+ (emacsconf-mail-speaker "Calendar entry")
+ (mml-attach-file ical-file)))
+
+(defun emacsconf-ical-convert-entry-to-string (&optional updated)
+ (string-join
+ (list
+ "BEGIN:VCALENDAR"
+ "VERSION:2.0"
+ "PRODID:EmacsConf"
+ (concat "X-WR-CALNAME:EmacsConf " emacsconf-year)
+ "X-WR-CALNAME:EmacsConf"
+ "CALSCALE:GREGORIAN"
+ "METHOD:PUBLISH"
+ (emacsconf-ical-format-talk (emacsconf-get-talk-info-for-subtree) updated)
+ "END:VCALENDAR")
+ "\r\n"))
+
+(defun emacsconf-ical-format-talk (o &optional updated)
+ (string-join
+ (delq
+ nil
+ (list
+ "BEGIN:VEVENT"
+ (string-trim (org-icalendar-fold-string
+ (org-icalendar-cleanup-string
+ (concat "SUMMARY:" (plist-get o :title)
+ (if (plist-get o :speakers)
+ (concat " - " (plist-get o :speakers))
+ "")))))
+ "ORGANIZER:EmacsConf"
+ (concat "LOCATION:" "https://emacsconf.org/")
+ ;; (concat "UID:emacsconf-" emacsconf-year "-" (plist-get o :slug))
+ (concat "UID:" (plist-get o :uuid))
+ (concat "URL:" "https://emacsconf.org/" emacsconf-year "/talks/" (plist-get o :slug))
+ (concat "DTSTART:" (format-time-string "%Y%m%dT%H%M%SZ" (plist-get o :start-time) t))
+ (concat "DTEND:" (format-time-string "%Y%m%dT%H%M%SZ" (plist-get o :end-time) t))
+ (if updated (concat "DTSTAMP:" updated))
+ (if (plist-get o :speakers)
+ (mapconcat
+ (lambda (s)
+ (format "ATTENDEE;ROLE=REQ-PARTICIPANT;CUTYPE=INDIVIDUAL;CN=\"%s\":invalid:nomail" s))
+ (split-string (plist-get o :speakers) ", +")
+ "\r\n")
+ nil)
+ (string-trim
+ (org-icalendar-fold-string
+ (org-icalendar-cleanup-string
+ (concat "DESCRIPTION: Times are approximate and will probably change.\n"
+ "https://emacsconf.org/" emacsconf-year "/talks/" (plist-get o :slug) "\n"
+ (plist-get o :markdown)))))
+ "END:VEVENT"))
+ "\r\n"))
+
+(defun emacsconf-format-as-ical (emacsconf-info)
+ (require 'ox-icalendar)
+ (let ((updated (format-time-string "%Y%m%dT%H%M%SZ" nil t)))
+ (string-join
+ (list
+ "BEGIN:VCALENDAR"
+ "VERSION:2.0"
+ "PRODID:EmacsConf"
+ (concat "X-WR-CALNAME:EmacsConf " emacsconf-year)
+ "X-WR-CALNAME:EmacsConf"
+ "CALSCALE:GREGORIAN"
+ "METHOD:PUBLISH"
+ (mapconcat (lambda (o) (emacsconf-ical-format-talk o updated))
+ (seq-remove (lambda (o) (string= (plist-get o :status) "CANCELLED"))
+ (emacsconf-filter-talks emacsconf-info))
+ "\r\n")
+ "END:VCALENDAR")
+ "\r\n")))
+
+(defun emacsconf-generate-ical ()
+ (unless (file-directory-p emacsconf-directory) (error "Please specify the wiki directory in the emacsconf-directory variable."))
+ (with-temp-file (expand-file-name "emacsconf.ics" (expand-file-name emacsconf-year emacsconf-directory))
+ (insert (emacsconf-format-as-ical (emacsconf-get-talk-info)))))
diff --git a/emacsconf-pentabarf.el b/emacsconf-pentabarf.el
new file mode 100644
index 0000000..6920845
--- /dev/null
+++ b/emacsconf-pentabarf.el
@@ -0,0 +1,125 @@
+;;; emacsconf-pentabarf.el --- pentabarf XML export -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2022 Sacha Chua
+
+;; Author: Sacha Chua
+;; Keywords:
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see .
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+(defun emacsconf-assign-talk-uuids ()
+ (interactive)
+ (require 'uuid)
+ (org-map-entries (lambda ()
+ (when (and (org-entry-get (point) "SLUG")
+ (not (org-entry-get (point) "UUID")))
+ (org-entry-put (point) "UUID" (uuid-string))))))
+
+(defun emacsconf-talk-info-as-pentabarf-xml (o)
+ (require 'svg)
+ (dom-node
+ 'event `((id . ,(plist-get o :slug))
+ (guid . ,(plist-get o :uuid)))
+ (dom-node 'date nil (emacsconf-pentabarf-format-datetime (plist-get o :start-time)))
+ (dom-node 'start nil (format-time-string "%H:%M" (plist-get o :start-time)))
+ (dom-node 'language nil "en")
+ (dom-node 'room nil "Main")
+ (dom-node 'subtitle)
+ (dom-node 'type nil "Talk")
+ (dom-node 'track nil "Main")
+ (dom-node 'slug nil (concat "emacsconf-" emacsconf-year "-talk-" (plist-get o :slug)))
+ (dom-node 'duration nil (format-seconds "%h:%.2m"
+ (time-to-seconds
+ (time-subtract
+ (plist-get o :end-time)
+ (plist-get o :start-time)))))
+ ;; (dom-node 'slug nil (plist-get o :slug))
+ (dom-node 'title nil (plist-get o :title))
+ (dom-node 'abstract)
+ (dom-node 'description nil (svg--encode-text (concat "Times are approximate and will probably change.\n\n" (plist-get o :markdown))))
+ (dom-node 'url nil (concat "https://emacsconf.org/" emacsconf-year "/talks/" (plist-get o :slug)))
+ (apply 'dom-node 'persons
+ nil
+ (seq-map (lambda (p)
+ (dom-node 'person nil p))
+ (split-string (or (plist-get o :speakers) "EmacsConf") ", ")))))
+
+(defun emacsconf-pentabarf-format-datetime (time)
+ (format-time-string "%Y-%m-%dT%H:%M:%SZ" time t))
+(defun emacsconf-pentabarf-days (talks)
+ (seq-map-indexed
+ (lambda (day i)
+ (dom-node
+ 'day
+ `((date . ,(car day))
+ (start . ,(emacsconf-pentabarf-format-datetime (plist-get (cadr day) :start-time)))
+ (end . ,(emacsconf-pentabarf-format-datetime (plist-get (car (last day)) :end-time)))
+ (index . ,(1+ i)))
+ (apply
+ 'dom-node 'room
+ '((name . "Main"))
+ (seq-map #'conf-talk-info-as-pentabarf-xml
+ (cdr day)))))
+ (seq-group-by
+ (lambda (o) (format-time-string "%Y-%m-%d" (plist-get o :start-time)))
+ talks)))
+;; (emacsconf-pentabarf-days (seq-take (emacsconf-filter-talks emacsconf-info) 3))
+;; based on svg-print, but without spaces
+(defun emacsconf-pentabarf-print (dom)
+ "Convert DOM into a string containing the xml representation."
+ (if (stringp dom)
+ (insert dom)
+ (insert (format "<%s" (car dom)))
+ (dolist (attr (nth 1 dom))
+ ;; Ignore attributes that start with a colon.
+ (unless (= (aref (format "%s" (car attr)) 0) ?:)
+ (insert (format " %s=\"%s\"" (car attr) (cdr attr)))))
+ (insert ">")
+ (dolist (elem (nthcdr 2 dom))
+ (emacsconf-pentabarf-print elem))
+ (insert (format "%s>" (car dom)))))
+
+(defun emacsconf-pentabarf (emacsconf-info)
+ (require 'svg)
+ (apply
+ 'dom-node
+ 'schedule
+ nil
+ (append
+ (list
+ (dom-node 'generator '((name . "EmacsConf") (version . "0.1")))
+ (dom-node 'version nil (format-time-string "%Y%m%d%H%M%S"))
+ (dom-node 'conference nil
+ (dom-node 'acronym nil "emacsconf" emacsconf-year)
+ (dom-node 'title nil (concat "EmacsConf " emacsconf-year))
+ (dom-node 'start nil "2021-11-27")
+ (dom-node 'end nil "2021-11-28")
+ (dom-node 'time_zone_name nil "America/Toronto")
+ (dom-node 'base_url nil (concat "https://emacsconf.org/" emacsconf-year))))
+ (emacsconf-pentabarf-days (emacsconf-filter-talks emacsconf-info)))))
+
+;; (emacsconf-pentabarf-days (seq-take (emacsconf-filter-talks emacsconf-info) 3))
+;;
+
+(defun emacsconf-pentabarf-generate ()
+ (unless (file-directory-p emacsconf-directory) (error "Please specify the wiki directory in the emacsconf-directory variable."))
+ (with-temp-file (expand-file-name "emacsconf-pentabarf.xml" (expand-file-name emacsconf-year emacsconf-directory))
+ (emacsconf-pentabarf-print (emacsconf-pentabarf (emacsconf-filter-talks (emacsconf-get-talk-info 'wiki))))))
+
+;;; emacsconf-pentabarf.el ends here
diff --git a/emacsconf-publish.el b/emacsconf-publish.el
index 17d8122..cebcf70 100644
--- a/emacsconf-publish.el
+++ b/emacsconf-publish.el
@@ -719,4 +719,212 @@ Columns are: slug,title,speakers,talk page url,video url,duration,sha."
results)
nil)))))
+(defun emacsconf-generate-pad-template (emacsconf-info)
+ "Generate a template for copying and pasting into the pad.
+ Writes it to pad-template.html."
+ (interactive (list (emacsconf-get-talk-info)))
+ (let* ((talks (emacsconf-filter-talks emacsconf-info))
+ (text (concat
+ "Conference info, how to watch/participate: https://emacsconf.org/2021/
+ Guidelines for conduct: https://emacsconf.org/conduct/
+
+ Except where otherwise noted, the material on the EmacsConf pad are dual-licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0 International Public License; and the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) an later version.
+ Copies of these two licenses are included in the EmacsConf wiki repository, in the COPYING.GPL and COPYING.CC-BY-SA files (https://emacsconf.org/COPYING/).
+
+ By contributing to this pad, you agree to make your contributions available under the above licenses. You are also promising that you are the author of your changes, or that you copied them from a work in the public domain or a work released under a free license that is compatible with the above two licenses. DO NOT SUBMIT COPYRIGHTED WORK WITHOUT PERMISSION.
+
+
+ This pad is here to be curated by everybody and its rough structure is like this:
+
- General info and license
+
- A section for each talk -> please do add questions and notes
+
- A general feedback section
+
+
+ "
+ (mapconcat
+ (lambda (o)
+ (let ((url (format "https://emacsconf.org/%s/schedule/%s" emacsconf-year (plist-get o :talk-id))))
+ (format "-------------------------------------------------------------------------------------------------
Talk%s: %s
+ Speaker(s): %s
+ Talk page: %s
+ Actual start of talk EST: Start of Q&A: End of Q&A:
+ Questions:
+ Speakers may answer in any order or skip questions. As much as possible, put your questions at the top level instead of under another question. If adding an answer, please indicate [speaker] or your nick accordingly. Volunteers, please add new slots as ones get filled.
+
+ - Q1:
+ - Q2:
+ - Q3:
+ - Q4:
+
+
+ Links and other notes:
+
+ - sample text
+ - sample text
+ - sample text
+ - sample text
+
+ " (plist-get o :talk-id) (plist-get o :title) (plist-get o :speakers) url url))) talks "
\n")
+ "
-------------------------------------------------------------------------------------------------
+ General Feedback: What went well?
+
+ - sample text
+ - sample text
+ - sample text
+ - sample text
+
+
+ -------------------------------------------------------------------------------------------------
+ General Feedback: What to improve?
+
+ - sample text
+ - sample text
+ - sample text
+ - sample text
+
+
+ -------------------------------------------------------------------------------------------------
+ Colophon:
+ ")))
+ (with-current-buffer (find-file "pad-template.html")
+ (erase-buffer)
+ (insert text)
+ (save-buffer)))
+ (browse-url-of-file "pad-template.html"))
+
+
+(defun emacsconf-generate-playlist (filename playlist-name talks &optional base-url)
+ (with-temp-file filename
+ (insert (format "#EXTM3U\n#PLAYLIST: %s\n#EXTALB: %s\n#EXTGENRE: Speech\n%s"
+ playlist-name playlist-name
+ (mapconcat
+ (lambda (talk)
+ (let* ((slug (plist-get talk :video-slug))
+ (filename (concat (plist-get talk :video-slug) "--main.webm")))
+ (if (and slug (file-exists-p (expand-file-name filename emacsconf-captions-directory)))
+ (format "#EXTINF:-1,%s - %s\n%s%s\n"
+ (plist-get talk :title)
+ (plist-get talk :speakers)
+ base-url
+ filename)
+ "")))
+ talks
+ "")))))
+
+(defun emacsconf-get-preferred-video (video-slug)
+ (or
+ (seq-find
+ 'file-exists-p
+ (seq-map (lambda (suffix)
+ (expand-file-name (concat video-slug "--" suffix ".webm")
+ emacsconf-captions-directory))
+ '("main" "captioned" "normalized" "compressed")))
+ (car (directory-files emacsconf-captions-directory
+ nil
+ (concat (regexp-quote video-slug)
+ "\\."
+ (regexp-opt subed-video-extensions))))))
+
+(defun emacsconf-check-video-formats ()
+ (interactive)
+ (with-current-buffer (get-buffer-create "*Video check*")
+ (erase-buffer)
+ (mapc
+ (lambda (filename)
+ (insert "* " (if (string-match "--\\(main\\|compressed\\|normalized\\|captioned\\)\\.webm$" filename)
+ (match-string 1 filename)
+ "")
+ ": "
+ filename "\n"
+ (shell-command-to-string (format "ffprobe %s 2>&1 | grep -E '(Duration|Stream)'"
+ (shell-quote-argument filename)))
+ "\n"))
+ (delq nil
+ (mapcar (lambda (talk) (emacsconf-get-preferred-video (plist-get talk :video-slug)))
+ emacsconf-info)))
+ (switch-to-buffer (current-buffer))))
+
+;;; Video services
+
+(defun emacsconf-cache-all-video-data ()
+ (interactive)
+ (org-map-entries (lambda () (when (and (org-entry-get (point) "VIDEO_SLUG") (null (org-entry-get (point) "VIDEO_FILE_SIZE"))) (emacsconf-cache-video-data-for-entry)))))
+(defun emacsconf-cache-video-data-for-entry ()
+ (interactive)
+ (let* ((video-file (emacsconf-get-preferred-video (org-entry-get (point) "VIDEO_SLUG")))
+ (duration (/ (compile-media-get-file-duration-ms video-file) 1000)))
+ (org-entry-put (point) "VIDEO_FILE" (file-name-nondirectory video-file))
+ (org-entry-put (point) "VIDEO_FILE_SIZE" (file-size-human-readable (file-attribute-size (file-attributes video-file))))
+ (org-entry-put (point) "VIDEO_DURATION" (format-seconds "%m:%.2s" duration))
+ (org-entry-put (point) "TIME" (number-to-string (ceiling (/ duration 60))))))
+
+(defvar emacsconf-youtube-channel-id "UCwuyodzTl_KdEKNuJmeo99A")
+(defun emacsconf-youtube-edit ()
+ (interactive)
+ (let ((url (org-entry-get (point) "YOUTUBE_URL")))
+ (if url
+ (when (or (string-match "youtu\\.be/\\([-A-Za-z0-9_]+\\)" url)
+ (string-match "watch\\?v=\\([-A-Za-z0-9_]+\\)" url))
+ (browse-url (format "https://studio.youtube.com/video/%s/edit" (match-string 1 url))))
+ (browse-url (concat "https://studio.youtube.com/channel/" emacsconf-youtube-channel-id)))))
+
+(defun emacsconf-toobnix-edit ()
+ (interactive)
+ (let ((url (org-entry-get (point) "TOOBNIX_URL")))
+ (if url
+ (when (string-match "/w/\\([A-Za-z0-9]+\\)" url)
+ (browse-url (format "https://toobnix.org/videos/update/%s" (match-string 1 url))))
+ (when (> (length (org-entry-get (point) "VIDEO_SLUG")) 80)
+ (copy-file (expand-file-name (concat (org-entry-get (point) "VIDEO_SLUG") "--main.webm") emacsconf-captions-directory)
+ (expand-file-name (concat "emacsconf-" emacsconf-year "-" (org-entry-get (point) "SLUG") ".webm") emacsconf-captions-directory) t))
+ (browse-url "https://toobnix.org/videos/upload#upload"))))
+
+(defun emacsconf-publish-files ()
+ (interactive)
+ (let* ((slug (org-entry-get (point) "VIDEO_SLUG"))
+ (video-file (emacsconf-get-preferred-video slug))
+ (wiki-captions-directory (expand-file-name "captions" (expand-file-name emacsconf-year emacsconf-directory)))
+ (new-captions-file (expand-file-name (concat slug "--main.vtt") wiki-captions-directory)))
+ (org-entry-put (point) "PUBLIC" "1")
+ (when (file-exists-p video-file)
+ (emacsconf-youtube-edit)
+ (emacsconf-toobnix-edit)
+ (emacsconf-cache-video-data-for-entry)
+ (emacsconf-update-talk)
+ (when (file-exists-p (expand-file-name (concat slug ".md") wiki-captions-directory))
+ (with-current-buffer (find-file-noselect (file-exists (expand-file-name (concat slug ".md") wiki-captions-directory)))
+ (magit-stage-file (buffer-file-name))))
+ (mapc
+ (lambda (suffix)
+ (when (file-exists-p (expand-file-name (concat slug suffix) emacsconf-captions-directory))
+ (copy-file (expand-file-name (concat slug suffix) emacsconf-captions-directory)
+ (expand-file-name (concat slug suffix) wiki-captions-directory)t)
+ (with-current-buffer (find-file-noselect (expand-file-name (concat slug suffix) wiki-captions-directory))
+ (magit-stage-file (buffer-file-name)))))
+ '("--main.vtt" "--chapters.vtt" "--main_ja.vtt" "--main_fr.vtt"))
+ (magit-status-setup-buffer emacsconf-directory)
+ (when (and emacsconf-public-media-directory slug (> (length (string-trim slug)) 0)
+ ;; TODO: make this customizable
+ (shell-command
+ (format "ssh front -- 'rm /var/www/media.emacsconf.org/%s/%s*; cp -n -l /var/www/media.emacsconf.org/%s/protected/%s* /var/www/media.emacsconf.org/%s/; chmod ugo+r /var/www/media.emacsconf.org/%s/ -R'"
+ emacsconf-year slug
+ emacsconf-year slug
+ emacsconf-year
+ emacsconf-year)))
+ (when emacsconf-public-media-directory
+ (emacsconf-make-public-index (expand-file-name "index.html" emacsconf-public-media-directory))
+ (emacsconf-generate-playlist (expand-file-name "index.m3u" emacsconf-public-media-directory)
+ "EmacsConf 2021"
+ (emacsconf-public-talks (emacsconf-get-talk-info))))))
+ ;; (copy-file (emacsconf-get-preferred-video slug) emacsconf-public-media-directory t)
+ ;; (mapc (lambda (ext)
+ ;; (when (file-exists-p (expand-file-name (concat slug ext) emacsconf-captions-directory))
+ ;; (copy-file (expand-file-name (concat slug ext) emacsconf-captions-directory)
+ ;; emacsconf-public-media-directory
+ ;; t)))
+ ;; emacsconf-published-extensions)
+ ))
+
+
+
(provide 'emacsconf-publish)
diff --git a/emacsconf-subed.el b/emacsconf-subed.el
index efddcb8..93542ac 100644
--- a/emacsconf-subed.el
+++ b/emacsconf-subed.el
@@ -71,7 +71,7 @@
(save-buffer))))
(defun emacsconf-subed-convert-transcript-to-directives (id &optional chapters)
- (interactive (read-string "ID: " "mainVideo"))
+ (interactive (list (read-string "ID: " "mainVideo")))
(goto-char (point-min))
(let* ((chapter-starts (mapcar 'car chapters))
(result (concat
@@ -87,7 +87,7 @@
(replace-regexp-in-string
"\"" "" ;"
(replace-regexp-in-string "[][]" "" (subed-subtitle-text))))
- (subed-vtt--msecs-to-timestamp (subed-subtitle-msecs-start))
+ (subed-msecs-to-timestamp (subed-subtitle-msecs-start))
id)))))
(when (called-interactively-p 'any)
(kill-new result))
diff --git a/emacsconf.el b/emacsconf.el
index b3a77c2..4771255 100644
--- a/emacsconf.el
+++ b/emacsconf.el
@@ -27,7 +27,7 @@
(defgroup emacsconf nil "EmacsConf" :group 'multimedia)
(defcustom emacsconf-name "EmacsConf"
- "Name of conference"
+ "Name of emacsconference"
:group 'emacsconf
:type 'string)
(defcustom emacsconf-year "2022"
@@ -54,7 +54,7 @@
(defcustom emacsconf-publishing-phase 'resources
"Controls what information to include.
'program - don't include times
-'schedule - include times; use this leading up to the conference
+'schedule - include times; use this leading up to the emacsconference
'resources - after the emacsconference, don't need status"
:group 'emacsconf
:type '(choice
@@ -63,7 +63,7 @@
(const :tag "Resources: Don't include status" resources)))
(defcustom emacsconf-org-file nil
- "Path to the Org file with conference information."
+ "Path to the Org file with emacsconference information."
:type 'file
:group 'emacsconf)
@@ -91,7 +91,7 @@
(find-file (expand-file-name (concat search ".md")
(expand-file-name "talks" (expand-file-name emacsconf-year emacsconf-directory)))))
-(defun conf-find-caption-directives-from-slug (search)
+(defun emacsconf-find-caption-directives-from-slug (search)
(interactive (list (emacsconf-complete-talk)))
(setq search (emacsconf-get-slug-from-string search))
(find-file (expand-file-name (concat search ".md")
@@ -104,7 +104,7 @@
(browse-url (concat emacsconf-base-url "/" emacsconf-year "/talks/" search "/")))
(defun emacsconf-set-property-from-slug (search prop value)
- (interactive (list (conf-complete-talk) nil nil))
+ (interactive (list (emacsconf-complete-talk) nil nil))
(save-window-excursion
(emacsconf-with-talk-heading search
(setq prop (or prop (org-read-property-name)))
@@ -195,7 +195,8 @@
(:pronunciation "PRONUNCIATION")
(:pronouns "PRONOUNS")
(:buffer "BUFFER")
- (:time "MIN_TIME")
+ (:time "TIME")
+ (:time "MAX_TIME")
(:present "PRESENT")
(:speakers "NAME")
(:speakers-short "NAME_SHORT")
@@ -233,6 +234,22 @@
(lambda (o) (list (car o) (org-entry-get (point) (cadr o))))
field-props))))
+(defvar emacsconf-abstract-heading-regexp "abstract" "Regexp matching heading for talk abstract.")
+(defun emacsconf-get-talk-abstract-from-subtree (o)
+ "Add the abstract from a subheading with a title matching Abstract."
+ (org-map-entries
+ (lambda ()
+ (when (string-match "abstract" (org-entry-get (point) "ITEM"))
+ (plist-put o :abstract (org-get-entry))))
+ nil 'tree)
+ o)
+
+(defun emacsconf-add-timezone-conversions (o)
+ (plist-put o :scheduled-tzs
+ (concat (org-timestamp-format (plist-get o :start-time) "%a %b %e %l:%M%p Toronto time (")
+ (emacsconf-summarize-times (plist-get o :start-time) emacsconf-timezones)
+ ")")))
+
(defun emacsconf-get-abstract-from-wiki (o)
(plist-put o :markdown (emacsconf-talk-markdown-from-wiki (plist-get o :slug))))
@@ -241,7 +258,7 @@
(assoc-default (plist-get o :status)
(emacsconf-status-types) 'string= "")))
-(defvar emacsconf-talk-info-functions '(emacsconf-get-talk-info-from-properties emacsconf-add-talk-status))
+(defvar emacsconf-talk-info-functions '(emacsconf-get-talk-info-from-properties emacsconf-get-talk-abstract-from-subtree emacsconf-add-talk-status emacsconf-add-timezone-conversions))
(defun emacsconf-get-talk-info-for-subtree ()
(seq-reduce (lambda (prev val) (funcall val prev))
@@ -267,6 +284,18 @@
(lambda (talk) (eq (plist-get talk :type) 'talk))
list))
+(defun emacsconf-collect-field-for-status (status field &optional info)
+ (seq-map
+ (lambda (o)
+ (plist-get o field))
+ (seq-filter
+ (lambda (o)
+ (if (listp status)
+ (member (plist-get o :status) status)
+ (string= status (plist-get o :status))))
+ (emacsconf-filter-talks (or info (emacsconf-get-talk-info))))))
+
+
(defun emacsconf-get-talk-info-from-file (&optional filename)
(with-temp-buffer
(insert-file-contents (or filename "conf.org"))
@@ -289,9 +318,28 @@
nil))))
info)))
+(defun emacsconf-combine-plist (list-of-talks separator)
+ (let (result entry)
+ (while list-of-talks
+ (setq entry (car list-of-talks))
+ (while entry
+ (unless (equal (plist-get result (car entry))
+ (cadr entry))
+ (setq result
+ (plist-put result
+ (car entry)
+ (cons (cadr entry)
+ (or (plist-get result (car entry)))))))
+ (setq entry (cddr entry)))
+ (setq list-of-talks (cdr list-of-talks)))
+ result))
+
(defun emacsconf-goto-talk-id (id)
(goto-char (org-find-property "TALK_ID" id)))
+(defun emacsconf-goto-slug (slug)
+ (goto-char (org-find-property "SLUG" id)))
+
(defun emacsconf-talk-markdown-from-wiki (slug)
"Return the markdown from SLUG."
(when (file-exists-p (expand-file-name (format "%s/talks/%s.md" emacsconf-year slug) emacsconf-directory))
@@ -321,7 +369,7 @@
(seq-filter (lambda (f) (plist-get f :public)) info))
;;; Schedule summary
-(defun emacsconf-update-schedules ()
+(defun emacsconf-update-schedules (&optional modify-func)
"Schedule the talks based on TIME and BUFFER.
Talks with a FIXED_TIME property are not moved."
(interactive)
@@ -338,6 +386,9 @@ Talks with a FIXED_TIME property are not moved."
end-time (time-add current-time (seconds-to-time duration)))
(org-set-property "SCHEDULED" (format "%s-%s" (org-format-time-string "%Y-%m-%d %H:%M" current-time)
(org-format-time-string "%H:%M" end-time)))
+ (when (functionp modify-func)
+ (funcall modify-func))
+ (setq end-time (time-add (org-get-scheduled-time (point)) (seconds-to-time duration)))
(setq current-time (time-add end-time (* (string-to-number (org-entry-get (point) "BUFFER")) 60))))))))))
(defun emacsconf-format-short-time (string &optional omit-end-time)
@@ -416,7 +467,7 @@ Talks with a FIXED_TIME property are not moved."
(with-eval-after-load 'embark
(add-to-list 'embark-target-finders 'emacsconf-embark-finder)
(embark-define-keymap embark-emacsconf-actions
- "Keymap for conference-related things"
+ "Keymap for emacsconference-related things"
("a" emacsconf-announce)
("c" emacsconf-find-captions-from-slug)
("d" emacsconf-find-caption-directives-from-slug)
@@ -432,5 +483,104 @@ Talks with a FIXED_TIME property are not moved."
("RET" emacsconf-go-to-talk))
(add-to-list 'embark-keymap-alist '(emacsconf . embark-emacsconf-actions)))
+;;; Mail merge
+
+(defun emacsconf-mail-speaker (&optional subject body)
+ "Compose a message to the speaker of the current talk."
+ (interactive)
+ (compose-mail (format "%s <%s>" (org-entry-get (point) "NAME") (org-entry-get (point) "EMAIL")) subject)
+ (when body (message-goto-body) (insert body)))
+
+(defun emacsconf-mail-speaker-schedule (&optional subject body)
+ (interactive (list (read-string "Subject: ") nil))
+ (let ((info (emacsconf-get-talk-info-for-subtree)))
+ (emacsconf-mail-speaker subject body)
+ (when body (message-goto-body) (insert body))
+ (goto-char (point-max))
+ (insert (string-join (emacsconf-timezone-strings info) "\n"))))
+
+(defvar emacsconf-submit-email "emacsconf-submit@gnu.org" "E-mail address for submissions.")
+
+(defun emacsconf-mail-speaker-cc-submit (&optional subject body)
+ "Compose a message to the speaker of the current talk."
+ (interactive)
+ (compose-mail (format "%s <%s>" (org-entry-get (point) "NAME") (org-entry-get (point) "EMAIL"))
+ subject '(("Reply-To" . emacsconf-submit-email) ("Cc" . emacsconf-submit-email)))
+ (message-goto-body)
+ (when body (insert body))
+ (save-excursion (insert "Please keep " emacsconf-submit-email " in the To: or Cc: when replying. Thank you!")))
+
+(defun emacsconf-show-talk-info-for-mail ()
+ (interactive)
+ (let ((email (or (mail-fetch-field "reply-to") (mail-fetch-field "from"))))
+ (when (string-match "<\\(\\(\\sw\\|\\s_\\|\\s.\\)+@\\(\\sw\\|\\s_\\|\\s.\\)+\\)>" email)
+ (setq email (match-string 1 email)))
+ (pop-to-buffer (find-file-noselect emacsconf-org-file))
+ (goto-char (point-min))
+ (goto-char
+ (or (org-find-property "EMAIL" email)
+ (org-find-property "NAME"
+ (completing-read "Name: " (delq nil (org-map-entries (lambda () (org-entry-get "NAME"))))))))))
+
+(defun emacsconf-mail-merge-get-template (id)
+ "Return the information for the e-mail template with EMAIL_ID set to ID."
+ (save-excursion
+ (goto-char (org-find-property "EMAIL_ID" id))
+ (list :subject (org-entry-get-with-inheritance "SUBJECT")
+ :cc (org-entry-get-with-inheritance "CC")
+ :reply-to (org-entry-get-with-inheritance "REPLY_TO")
+ :mail-followup-to (org-entry-get-with-inheritance "MAIL_FOLLOWUP_TO")
+ :body (replace-regexp-in-string "\n *," "\n" (buffer-substring-no-properties
+ (progn (org-end-of-meta-data) (point))
+ (org-end-of-subtree))))))
+
+(defun emacsconf-mail-merge-fill (string)
+ "Fill in the values for STRING using the properties at point.
+Include some other things, too, such as emacsconf-year, title, name, email, url, and duration."
+ (let (start (values `(("year" . ,emacsconf-year)
+ ("title" . ,(org-entry-get (point) "ITEM"))
+ ("name" . ,(org-entry-get (point) "NAME"))
+ ("email" . ,(org-entry-get (point) "EMAIL"))
+ ("url" . ,(format "%s%s/talks/%s" emacsconf-base-url emacsconf-year (org-entry-get (point) "SLUG")))
+ ("duration" . ,(org-entry-get (point) "TIME")))))
+ (while (string-match "\\${\\([-a-zA-Z_]+?\\)}" string start)
+ (if (assoc-default (match-string 1 string) values)
+ (setq string (replace-match (assoc-default (match-string 1 string) values) t t string))
+ (setq string (replace-match (save-match-data (org-entry-get (point) (match-string 1 string))) t t string)))
+ (setq start (1+ (match-beginning 0))))
+ string))
+
+(defun emacsconf-mail-merge-format-email-address-for-subtree ()
+ (if (string-match "," (org-entry-get (point) "EMAIL"))
+ (org-entry-get (point) "EMAIL")
+ (format "%s <%s>" (org-entry-get (point) "NAME") (org-entry-get (point) "EMAIL"))))
+
+(defun emacsconf-mail-merge-for-subtree (id note-field)
+ (let* ((template (emacsconf-mail-merge-get-template id))
+ (body (emacsconf-mail-merge-fill (plist-get template :body)))
+ (subject (emacsconf-mail-merge-fill (plist-get template :subject)))
+ (note (org-entry-get (point) note-field)))
+ (compose-mail (emacsconf-mail-merge-format-email-address-for-subtree)
+ subject
+ `(("Reply-To" . ,(plist-get template :reply-to))
+ ("Mail-Followup-To" . ,(plist-get template :mail-followup-to))
+ ("Cc" . ,(plist-get template :cc))))
+ (message-goto-body)
+ (save-excursion
+ (when note (insert "#+NOTE: " note "\n======== Delete above before sending =============\n\n"))
+ (insert body))))
+
+;;; Status updates
+
+(defun emacsconf-status-update ()
+ (interactive)
+ (let ((emacsconf-info (emacsconf-get-talk-info)))
+ (kill-new
+ (format "%d captioned (%d minutes), %d received and waiting to be captioned (%d minutes)"
+ (length (emacsconf-collect-field-for-status "CAPTIONED" :title))
+ (apply '+ (seq-map 'string-to-number (conf-collect-field-for-status "CAPTIONED" :duration)))
+ (length (emacsconf-collect-field-for-status "PREREC_RECEIVED" :title))
+ (apply '+ (seq-map 'string-to-number (conf-collect-field-for-status "PREREC_RECEIVED" :duration)))))))
+
(provide 'emacsconf)
;;; emacsconf.el ends here
--
cgit v1.2.3