diff options
author | Sacha Chua <sacha@sachachua.com> | 2022-09-21 14:08:08 -0400 |
---|---|---|
committer | Sacha Chua <sacha@sachachua.com> | 2022-09-21 14:08:08 -0400 |
commit | 119a654f08fc335f3f894db22e22d45288e13243 (patch) | |
tree | 672aedf670be82c3c7eee97321d7b5912fa4e2b5 | |
parent | f7cc8a984fa9cc6e33287ba53d604146a3f08150 (diff) | |
download | emacsconf-el-119a654f08fc335f3f894db22e22d45288e13243.tar.xz emacsconf-el-119a654f08fc335f3f894db22e22d45288e13243.zip |
Update code for publishing
-rw-r--r-- | emacsconf-publish.el | 145 | ||||
-rw-r--r-- | emacsconf.el | 24 |
2 files changed, 105 insertions, 64 deletions
diff --git a/emacsconf-publish.el b/emacsconf-publish.el index cebcf70..b3fed02 100644 --- a/emacsconf-publish.el +++ b/emacsconf-publish.el @@ -208,44 +208,65 @@ ${chapter-list} (when (featurep 'memoize) (memoize #'compile-media-get-file-duration-ms)) -(defun emacsconf-create-talk-pages (emacsconf-info) - (interactive (list (emacsconf-get-talk-info))) - "Populate year/talks/*.md files. -These should include the nav and schedule files, which will be -rewritten as needed. After they are generated, they should be all -right to manually edit to include things like additional -resources." - ;; TODO: No longer necessary? - (require 's) - (mapc (lambda (o) - (when (plist-get o :talk-id) - (let ((filename (expand-file-name (format "%s.md" (plist-get o :slug)) - (expand-file-name "talks" (expand-file-name emacsconf-year emacsconf-directory))))) - (unless (file-exists-p filename) - (with-temp-file filename - (let ((meta "!meta") - (title (or (plist-get o :title) "")) - (speakers (or (plist-get o :speakers) "")) - (talk-id (or (plist-get o :talk-id) "")) - (slug (or (plist-get o :slug) "")) - (info (or (plist-get o :info) ""))) - (insert - (s-lex-format "[[${meta} title=\"${title}\"]] -[[${meta} copyright=\"Copyright © ${emacsconf-year} ${speakers}\"]] -[[!inline pages=\"internal(${emacsconf-year}/info/${slug}-nav)\" raw=\"yes\"]] +(defun emacsconf-format-speaker-info (o) + (let ((extra-info (mapconcat #'identity + (delq nil (list + (plist-get o :pronunciation) + (plist-get o :pronouns) + (when (plist-get o :public-email) + (replace-regexp-in-string "@" " at " (plist-get o :public-email))))) + ", "))) + (concat (plist-get o :speakers) + (if (> (length extra-info) 0) + (concat " (" extra-info ")") + "")))) +(defun emacsconf-generate-talk-page (o &optional force) + "Draft the talk page for O unless the page already exists or FORCE is non-nil." + (interactive (list (emacsconf-get-talk-info-for-subtree) (> (prefix-numeric-value current-prefix-arg) 1))) + (let ((filename (expand-file-name (format "%s.md" (plist-get o :slug)) + (expand-file-name "talks" (expand-file-name emacsconf-year emacsconf-directory))))) + (unless (file-directory-p (expand-file-name "talks" (expand-file-name emacsconf-year emacsconf-directory))) + (mkdir (expand-file-name "talks" (expand-file-name emacsconf-year emacsconf-directory)))) + (when (or force (null (file-exists-p filename))) + (with-temp-file filename + (insert + (emacsconf-replace-plist-in-string + (emacsconf-convert-talk-abstract-to-markdown + (append o (list + :meta "!meta" + :speaker-info (emacsconf-format-speaker-info o)))) + "[[${meta} title=\"${title}\"]] +[[${meta} copyright=\"Copyright © ${year} ${speakers}\"]] +[[!inline pages=\"internal(${year}/info/${slug}-nav)\" raw=\"yes\"]] + +<!-- Initially generated with emacsconf-generate-talk-page and then left alone for manual editing --> <!-- You can manually edit this file to update the abstract, add links, etc. --->\n # ${title} -${speakers} +${speaker-info} -${info} +<!-- tags go here like !taglink CategoryOrgMode --> -[[!inline pages=\"internal(${emacsconf-year}/info/${slug}-schedule)\" raw=\"yes\"]] +${abstract-md} -[[!inline pages=\"internal(${emacsconf-year}/info/${slug}-nav)\" raw=\"yes\"]] -")))))))) - emacsconf-info)) +# Links + +# Discussion + +[[!inline pages=\"internal(${year}/info/${slug}-schedule)\" raw=\"yes\"]] + +[[!inline pages=\"internal(${year}/info/${slug}-nav)\" raw=\"yes\"]] +")))))) + +(defun emacsconf-generate-talk-pages (emacsconf-info force) + (interactive (list (emacsconf-get-talk-info) (> (prefix-numeric-value current-prefix-arg) 1))) + "Populate year/talks/*.md files. +These should include the nav and schedule files, which will be +rewritten as needed. After they are generated, they should be all +right to manually edit to include things like additional +resources." + (mapc (lambda (o) (emacsconf-generate-talk-page o force)) (emacsconf-filter-talks emacsconf-info))) (defun emacsconf-wiki-talk-resources (o) (setq o (append (list :format 'wiki @@ -307,25 +328,26 @@ ${info} (interactive (list (emacsconf-get-talk-info-for-subtree))) (with-temp-file (expand-file-name (format "%s-schedule.md" (plist-get talk :slug)) (expand-file-name "info" (expand-file-name emacsconf-year emacsconf-directory))) - (insert - "<!-- Automatically generated by conf-create-info-pages -->\n\n" - (emacsconf-format-talk-schedule-info talk) "\n"))) + + (unless (eq emacsconf-publishing-phase 'process) + (insert + "<!-- Automatically generated by emacsconf-generate-schedule-page -->\n\n" + (emacsconf-format-talk-schedule-info talk) "\n")))) (defun emacsconf-generate-info-pages () (interactive) "Populate year/info/*-nav and *-schedule.md files." - ;; TODO: No longer necessary? - (require 's) (let* ((talks (seq-remove (lambda (o) (string= (plist-get o :status) "CANCELLED")) (emacsconf-filter-talks (emacsconf-get-talk-info)))) (next-talks (cdr talks)) (prev-talks (cons nil talks))) + (unless (file-directory-p (expand-file-name "info" (expand-file-name emacsconf-year emacsconf-directory))) + (mkdir (expand-file-name "info" (expand-file-name emacsconf-year emacsconf-directory)))) (while talks (let* ((o (pop talks)) (next-talk (emacsconf-format-talk-link (pop next-talks))) (prev-talk (emacsconf-format-talk-link (pop prev-talks))) - (friendly (concat "/" emacsconf-year "/talks/" (plist-get o :slug) )) - (nav-links (format "Back to the [[schedule]] \n%s%s" + (nav-links (format "Back to the [[talks]] \n%s%s" (if prev-talk (format "Previous: %s \n" prev-talk) "") (if next-talk (format "Next: %s \n" next-talk) "")))) (with-temp-file (expand-file-name (format "%s-nav.md" (plist-get o :slug)) @@ -344,7 +366,7 @@ ${info} (lambda (o) (let* ((title (plist-get o :title)) (speakers (plist-get o :speakers))) - (if (null (plist-get o :talk-id)) + (if (null (plist-get o :slug)) (format "<tr><td colspan=\"3\">%s</td></tr>" (emacsconf-format-talk-link o)) (format "<tr><td>%s</td><td>%s</td><td>%s</td><tr>" (plist-get o :duration) @@ -356,38 +378,39 @@ ${info} (defun emacsconf-generate-main-schedule (&optional filename) (interactive) (with-temp-file (expand-file-name "schedule-details.md" (expand-file-name emacsconf-year emacsconf-directory)) - (insert (emacsconf-format-talk-info-as-schedule (emacsconf-get-talk-info))))) + (insert (emacsconf-format-main-schedule (emacsconf-get-talk-info))))) (defun emacsconf-format-talk-link (talk) - (and talk (if (plist-get talk :talk-id) + (and talk (if (plist-get talk :slug) (format "<a href=\"/%s/talks/%s\">%s</a>" emacsconf-year (plist-get talk :slug) (plist-get talk :title)) (plist-get talk :title)))) - -(defun emacsconf-format-talk-info-as-schedule (info) +(defun emacsconf-summarize-caption-status (info) (let* ((talks (seq-filter (lambda (o) (and (not (string= (plist-get o :status) "CANCELLED")) (plist-get o :speakers))) (emacsconf-filter-talks info))) (captioned (seq-filter (lambda (o) (plist-get o :captioner)) talks)) - (cancelled (seq-filter (lambda (o) (string= (plist-get o :status) "CANCELLED")) info)) (received (seq-remove (lambda (o) (plist-get o :captioner)) talks))) - (format "<div>%d talks total: %d captioned (%d min), %d waiting for captions (%d min)</div> -<table width=\"100%%\">%s%s</table>%s" - (length talks) - (length captioned) - (apply '+ (mapcar (lambda (info) (string-to-number (plist-get info :duration))) captioned)) - (length received) - (apply '+ (mapcar (lambda (info) (string-to-number (plist-get info :duration))) - received)) + (format "<div>%d talks total: %d captioned (%d min), %d waiting for captions (%d min)</div>" + (length talks) + (length captioned) + (apply '+ (mapcar (lambda (info) (string-to-number (plist-get info :duration))) captioned)) + (length received) + (apply '+ (mapcar (lambda (info) (string-to-number (plist-get info :duration))) + received))))) + +(defun emacsconf-format-main-schedule (info) + (let* ((cancelled (seq-filter (lambda (o) (string= (plist-get o :status) "CANCELLED")) info))) + (format "<table width=\"100%%\">%s%s</table>%s" (pcase emacsconf-publishing-phase - ('program "<tr><th>Status</th><th>Title<th><th>Speaker(s)</th></tr>") + ('program "<tr><th>Title</th><th>Speaker(s)</th></tr>") ('schedule "<tr><th>Status</th><th>Start</th><th>Title</th><th>Speaker(s)</th></tr>") ('resources "<tr><th>Title</th><th>Speaker(s)</th><th>Resources</th></tr>")) (mapconcat @@ -395,7 +418,7 @@ ${info} (let* ((time-fmt "%l:%M %p") (timestamp (org-timestamp-from-string (plist-get o :scheduled))) (start (if timestamp (format-time-string time-fmt (org-timestamp-to-time (org-timestamp-split-range timestamp))) "")) - (end (if timestamp (format-time-string time-fmt (org-timestamp-to-time (org-timestamp-split-range timestamp t))) "")) + ;; (end (if timestamp (format-time-string time-fmt (org-timestamp-to-time (org-timestamp-split-range timestamp t))) "")) (title (plist-get o :title)) (status (pcase (plist-get o :status) ("CAPTIONED" "captioned") @@ -407,13 +430,13 @@ ${info} (pcase emacsconf-publishing-phase ('program (if (eq (plist-get o :type) 'headline) - (format "<tr><td colspan=\"3\"><strong>%s<strong></td></tr>" + (format "<tr><td colspan=\"2\"><strong>%s<strong></td></tr>" (if (plist-get o :slug) (emacsconf-format-talk-link o) title)) - (format "<tr><td>%s</td><td>%s</td><td>%s</td></tr>" - status - (emacsconf-format-talk-link o) speakers))) + (format "<tr><td>%s</td><td>%s</td></tr>" + (emacsconf-format-talk-link o) + speakers))) ('schedule (if (eq (plist-get o :type) 'headline) (format "<tr><td colspan=\"4\"><strong>%s<strong></td></tr>" @@ -438,7 +461,7 @@ ${info} (append emacsconf-main-extensions '("--main.webm"))) ""))))))) (seq-remove (lambda (o) (string= (plist-get o :status) "CANCELLED")) - (cdr info)) + info) "\n") (if (> (length cancelled) 0) (format "<div class=\"cancelled\">Cancelled:<ul>%s</ul></div>" @@ -743,7 +766,7 @@ Columns are: slug,title,speakers,talk page url,video url,duration,sha." " (mapconcat (lambda (o) - (let ((url (format "https://emacsconf.org/%s/schedule/%s" emacsconf-year (plist-get o :talk-id)))) + (let ((url (format "https://emacsconf.org/%s/talks/%s" emacsconf-year (plist-get o :slug)))) (format "-------------------------------------------------------------------------------------------------<br/><strong>Talk%s: %s</strong><br /> Speaker(s): %s<br /> Talk page: <a href=\"%s\">%s</a><br /> @@ -764,7 +787,7 @@ Columns are: slug,title,speakers,talk page url,video url,duration,sha." <li>sample text</li> <li>sample text</li> </ul> - " (plist-get o :talk-id) (plist-get o :title) (plist-get o :speakers) url url))) talks "<br/><br/>\n") + " (plist-get o :slug) (plist-get o :title) (plist-get o :speakers) url url))) talks "<br/><br/>\n") "<br/><br/>-------------------------------------------------------------------------------------------------<br/> <strong>General Feedback: What went well?</strong><br/><br/> <ul> diff --git a/emacsconf.el b/emacsconf.el index 4771255..5737616 100644 --- a/emacsconf.el +++ b/emacsconf.el @@ -27,7 +27,7 @@ (defgroup emacsconf nil "EmacsConf" :group 'multimedia) (defcustom emacsconf-name "EmacsConf" - "Name of emacsconference" + "Name of conference" :group 'emacsconf :type 'string) (defcustom emacsconf-year "2022" @@ -51,7 +51,7 @@ (defcustom emacsconf-base-url "https://emacsconf.org/" "Includes trailing slash" :group 'emacsconf :type 'string) -(defcustom emacsconf-publishing-phase 'resources +(defcustom emacsconf-publishing-phase 'program "Controls what information to include. 'program - don't include times 'schedule - include times; use this leading up to the emacsconference @@ -194,6 +194,7 @@ (:qa-toobnix "QA_TOOBNIX") (:pronunciation "PRONUNCIATION") (:pronouns "PRONOUNS") + (:public-email "PUBLIC_EMAIL") (:buffer "BUFFER") (:time "TIME") (:time "MAX_TIME") @@ -209,6 +210,7 @@ 'append o (list + :year emacsconf-year :type (if (org-entry-get (point) "SLUG") 'talk 'headline) :status (elt heading 2) :level (car heading) @@ -244,6 +246,22 @@ nil 'tree) o) +(defun emacsconf-convert-talk-abstract-to-markdown (o) + (plist-put o :abstract-md (org-export-string-as (or (plist-get o :abstract) "") 'md t))) + +(defun emacsconf-summarize-times (time timezones) + (let (prev-day) + (mapconcat + (lambda (tz) + (let ((cur-day (format-time-string "%a %b %-e" time tz)) + (cur-time (format-time-string "%H%MH %Z" time tz))) + (if (equal prev-day cur-day) + cur-time + (setq prev-day cur-day) + (concat cur-day " " cur-time)))) + timezones + " / "))) + (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 (") @@ -361,7 +379,7 @@ (while a (setq string (replace-regexp-in-string (regexp-quote (concat "${" (substring (symbol-name (pop a)) 1) "}")) - (pop a) + (or (pop a) "") string t t))) string)) |