From 119a654f08fc335f3f894db22e22d45288e13243 Mon Sep 17 00:00:00 2001 From: Sacha Chua Date: Wed, 21 Sep 2022 14:08:08 -0400 Subject: Update code for publishing --- emacsconf-publish.el | 145 +++++++++++++++++++++++++++++---------------------- 1 file changed, 84 insertions(+), 61 deletions(-) (limited to 'emacsconf-publish.el') 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\"]] + + \n # ${title} -${speakers} +${speaker-info} -${info} + -[[!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 - "\n\n" - (emacsconf-format-talk-schedule-info talk) "\n"))) + + (unless (eq emacsconf-publishing-phase 'process) + (insert + "\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 "%s" (emacsconf-format-talk-link o)) (format "%s%s%s" (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 "%s" 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 "
%d talks total: %d captioned (%d min), %d waiting for captions (%d min)
-%s%s
%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 "
%d talks total: %d captioned (%d min), %d waiting for captions (%d min)
" + (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 "%s%s
%s" (pcase emacsconf-publishing-phase - ('program "StatusTitleSpeaker(s)") + ('program "TitleSpeaker(s)") ('schedule "StatusStartTitleSpeaker(s)") ('resources "TitleSpeaker(s)Resources")) (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 "%s" + (format "%s" (if (plist-get o :slug) (emacsconf-format-talk-link o) title)) - (format "%s%s%s" - status - (emacsconf-format-talk-link o) speakers))) + (format "%s%s" + (emacsconf-format-talk-link o) + speakers))) ('schedule (if (eq (plist-get o :type) 'headline) (format "%s" @@ -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 "
Cancelled:
    %s
" @@ -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 "-------------------------------------------------------------------------------------------------
Talk%s: %s
Speaker(s): %s
Talk page: %s
@@ -764,7 +787,7 @@ Columns are: slug,title,speakers,talk page url,video url,duration,sha."
  • sample text
  • sample text
  • - " (plist-get o :talk-id) (plist-get o :title) (plist-get o :speakers) url url))) talks "

    \n") + " (plist-get o :slug) (plist-get o :title) (plist-get o :speakers) url url))) talks "

    \n") "

    -------------------------------------------------------------------------------------------------
    General Feedback: What went well?

      -- cgit v1.2.3