-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemacsconf-publish.el
More file actions
3255 lines (3075 loc) · 154 KB
/
Copy pathemacsconf-publish.el
File metadata and controls
3255 lines (3075 loc) · 154 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;;; emacsconf-publish.el --- Publishing -*- lexical-binding: t; -*-
;; Copyright (C) 2021 Sacha Chua
;; Author: Sacha Chua <sacha@sachachua.com>
;; 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 <https://www.gnu.org/licenses/>.
;;; Commentary:
;;
;;; Code:
(require 'emacsconf-schedule)
(defcustom emacsconf-media-base-url "https://media.emacsconf.org/" "Base URL for published media files."
:type 'string
:group 'emacsconf)
(defcustom emacsconf-main-extensions '("--main.webm" "--main.opus" "--main.org" ".org" ".odp" ".pdf" ".pptx" ".el" "--compressed56.webm" "--main.vtt" "--main_fr.vtt" "--main_ja.vtt" "--main_es.vtt" "--main--chapters.vtt" "--script.fountain" "--main.pdf" "--slides.pdf" "--answers.vtt" "--answers.webm")
"Extensions to list on public pages."
:type '(repeat string)
:group 'emacsconf)
(defcustom emacsconf-publish-backstage-extensions '(".en.srv2" ".srt" "--original.mp4")
"Extensions to list in the staging area."
:group 'emacsconf)
(defcustom emacsconf-public-media-directory (concat "/ssh:orga@media.emacsconf.org:/var/www/media.emacsconf.org/" emacsconf-year "/")
"Can be over TRAMP" :type 'string :group 'emacsconf)
(defun emacsconf-publish-info-pages-for-talk (talk)
"Publish the before and after pages for this talk."
(interactive (list (emacsconf-complete-talk-info)))
(let ((info (emacsconf-get-talk-info)))
(emacsconf-publish-before-page talk info)
(emacsconf-publish-after-page talk info)
(unless (emacsconf-publish-talk-p talk)
(emacsconf-publish-cancelled-nav-page talk))))
(defun emacsconf-publish-update-talk (talk)
"Publish the schedule page and the page for this talk."
(interactive (list (emacsconf-complete-talk-info)))
(when (stringp talk) (setq talk (emacsconf-resolve-talk talk)))
(when (functionp 'emacsconf-upcoming-insert-or-update)
(emacsconf-upcoming-insert-or-update))
(emacsconf-publish-with-wiki-change
(let ((info (emacsconf-publish-prepare-for-display (emacsconf-get-talk-info))))
(emacsconf-publish-before-page talk info)
(emacsconf-publish-after-page talk info)
(emacsconf-publish-schedule info))))
(defun emacsconf-publish-add-talk ()
"Add the current talk to the wiki."
(interactive)
(emacsconf-current-org-notebook-refresh-schedule)
(emacsconf-publish-talk-page (emacsconf-get-talk-info-for-subtree))
(emacsconf-publish-info-pages)
(emacsconf-publish-schedule)
(magit-status-setup-buffer emacsconf-directory))
(defun emacsconf-publish-update-conf-html ()
"Update the schedules and export the page so I can easily review it."
(interactive)
(cl-letf* ((new-org (>= (string-to-number (org-version)) 9.5))
;; Fix bug probably introduced by org 9.5, but not investigated
;; thoroughly.
((symbol-function 'org-src-mode--maybe-disable-indent-tabs-mode)
(eval `(lambda ()
(when (or ,(when new-org
'(not org-src--tab-width))
(= org-src--tab-width 0))
(setq indent-tabs-mode nil))))))
(let ((org-confirm-babel-evaluate (or (null emacsconf-allow-dangerous-stuff)
org-confirm-babel-evaluate)))
(org-update-all-dblocks)
(org-babel-execute-buffer)
(org-html-export-to-html))))
(defun emacsconf-publish-regenerate-wiki (&optional force)
(interactive)
(when
(let ((info (emacsconf-get-talk-info))
(force (or force (yes-or-no-p "Overwrite existing talk pages? "))))
(emacsconf-publish-info-pages info)
(emacsconf-publish-schedule info)
(magit-status emacsconf-directory))))
(declare-function 'emacsconf-ical-generate-all "emacsconf-ical")
(defun emacsconf-update-schedule ()
"Change times for talks."
(interactive)
(emacsconf-publish-with-wiki-change
(emacsconf-publish-info-pages)
(emacsconf-publish-schedule)
(emacsconf-ical-generate-all)
(emacsconf-publish-schedule-org-files)
(emacsconf-publish-watch-pages)
(emacsconf-pad-prepopulate-all-talks)
(emacsconf-pad-prepopulate-hyperlists)
(when (functionp 'emacsconf-pentabarf-generate)
(emacsconf-pentabarf-generate))))
(defun emacsconf-update-and-publish ()
(interactive)
(with-current-buffer (find-file-noselect emacsconf-org-file)
(emacsconf-update-schedules)
(emacsconf-upcoming-update-file)
(emacsconf-update-schedules-in-wiki)
(emacsconf-publish-update-conf-html)
(setq emacsconf-info (emacsconf-get-talk-info))))
(defun emacsconf-publish-update-media ()
"Update public media.emacsconf.org directory."
(interactive)
(emacsconf-publish-public-index-on-wiki)
(when emacsconf-public-media-directory
(emacsconf-publish-public-index (expand-file-name "index.html" emacsconf-public-media-directory))
(emacsconf-publish-playlist (expand-file-name "index.m3u" emacsconf-public-media-directory)
(concat emacsconf-name emacsconf-year)
(emacsconf-publish-prepare-for-display (emacsconf-get-talk-info))
(format "https://media.emacsconf.org/%s/" emacsconf-year)))
(when emacsconf-backstage-dir
(emacsconf-publish-backstage-index (expand-file-name "index.html" emacsconf-backstage-dir)))
(emacsconf-publish-playlist (expand-file-name "index.m3u" emacsconf-backstage-dir)
(concat emacsconf-name emacsconf-year)
(emacsconf-publish-prepare-for-display (emacsconf-get-talk-info))
(format "https://media.emacsconf.org/%s/backstage/" emacsconf-year)))
(defun emacsconf-publish-index-card (talk)
"Format an HTML card for TALK."
(let* ((file-prefix (plist-get talk :file-prefix))
(video-file (plist-get talk :video-file))
(video (and file-prefix
(emacsconf-publish-index-card-video
(or (plist-get talk :video-id)
(concat "mainVideo-" (plist-get talk :slug)))
video-file talk))))
;; Add extra information to the talk
(setq talk
(append
talk
(list
:video-type (or (plist-get talk :video-type) "mainVideo")
:time-info (emacsconf-surround "Duration: " (plist-get talk :video-duration) " minutes" "")
:video-html (or (plist-get video :video) "")
:audio-html (or (plist-get video :audio) "")
:chapter-list (or (plist-get video :chapter-list) "")
:resources (or (plist-get video :resources) "")
:extra
(concat
(if (plist-get talk :backstage)
;; include schedule
(concat
"Starts: "
(format-time-string "%-I:%M %#p"
(plist-get talk :start-time))
" - Q&A: " (plist-get talk :q-and-a) "\n")
"")
(or (plist-get talk :extra) ""))
:speaker-info (or (plist-get talk :speakers-with-pronouns) ""))))
(emacsconf-replace-plist-in-string
talk
"<div class=\"vid ${video-type}\">${video-html}${audio-html}<div>${extra}</div>${time-info}${resources}${chapter-list}</div>")))
;; (emacsconf-publish-format-track-as-org (car emacsconf-tracks) "US/Eastern")
;; (emacsconf-get-talk-info)
(defun emacsconf-publish-format-track-as-org (track tz &optional info)
(let ((emacsconf-talk-info-functions (append emacsconf-talk-info-functions (list 'emacsconf-get-abstract-from-wiki))))
(setq info (or info (emacsconf-publish-prepare-for-display (emacsconf-get-talk-info)))))
(concat
"** " (plist-get track :name) " :" (plist-get track :id) ":\n:PROPERTIES:\n:CATEGORY: " (plist-get track :id) "\n:END:\n"
(mapconcat
(lambda (talk)
(with-temp-buffer
(org-mode)
(concat
"*** " (plist-get talk :title) "\n"
"<"
(format-time-string
(cdr org-time-stamp-formats)
(plist-get talk :start-time)
tz)
">--<"
(format-time-string
(cdr org-time-stamp-formats)
(plist-get talk :end-time)
tz)
">\n"
(emacsconf-surround "- " (plist-get talk :speakers-with-pronouns) "\n" "")
(emacsconf-surround "- " (plist-get talk :absolute-url) "\n" "")
"- Watch live: "
(mapconcat (lambda (player)
(org-link-make-string
(concat "shell:" player " " (plist-get track :stream) " &")
player))
'("mpv" "vlc" "ffplay")
" or ")
" or "
(org-link-make-string
(plist-get track :watch)
"web-based player")
"\n"
"- You can also watch it in VLC by choosing menu - Media - Open Network Stream and putting in " (plist-get track :stream) "\n"
(emacsconf-surround "- Q&A: "
(if (plist-get talk :qa-url)
(org-make-link-string
(plist-get talk :qa-url)
(plist-get talk :qa-info))
(plist-get talk :qa-info))
"\n" "")
(emacsconf-surround "- Etherpad: " (plist-get talk :pad-url) "\n" "")
(emacsconf-surround " - Text version (no JS): " (plist-get talk :pad-url) "/export/txt\n" "")
(emacsconf-surround " - HTML version (no JS): " (plist-get talk :pad-url) "/export/html\n" "")
(emacsconf-surround "- Chat: "
(org-link-make-string
(plist-get talk :webchat-url)
(concat "#" (plist-get talk :channel)))
"\n" "")
"- " (org-link-make-string
(plist-get talk :video-url)
(if (plist-get talk :video-time)
"Talk recording (posted soon after the talk starts)"
"Recording for live talk (posted in a week or two)")) "\n"
"- "
(org-link-make-string
(plist-get talk :captions-url)
(if (plist-get talk :video-time)
"Captions (posted soon after the talk starts)"
"Captions for live talk (posted in a week or two)"))
"\n"
"- Email for questions: "
(let ((email (or (plist-get talk :public-email)
emacsconf-fallback-email)))
(org-link-make-string
(concat "mailto:"
email
"?body=&subject="
(url-hexify-string
(format "%s %s: %s"
emacsconf-name
emacsconf-year
(plist-get talk :title))))
email))
"\n"
(let ((other-files
(seq-remove (lambda (o)
(string-match "--main\\.\\(vtt\\|webm\\)"))
(emacsconf-publish-filter-public-files talk))))
(if other-files
(concat "- Other files:\n"
(mapconcat
(lambda (file)
(concat " - "
(org-link-make-string
(format "%s%s/%s"
emacsconf-media-base-url
(file-name-nondirectory file))
(replace-regexp-in-string
(concat "^" (regexp-quote (plist-get talk :file-prefix))) ""
(file-name-nondirectory file)))))
other-files "\n")
"\n")
""))
(emacsconf-surround "\n" (plist-get talk :intro-note) "\n" "")
(emacsconf-surround "\nDescription:\n\n"
(when (plist-get talk :org-description)
(with-temp-buffer
(if (org-kill-is-subtree-p (plist-get talk :org-description))
(org-paste-subtree 3 (plist-get talk :org-description))
(insert (plist-get talk :org-description)))
(buffer-string)))
"\n" ""))))
(emacsconf-filter-talks-by-track track info)
"\n")))
(defun emacsconf-publish-schedule-org-for-timezone (timezone &optional info)
(interactive (list (completing-read "Time zone: " emacsconf-timezones)))
(let ((new-filename (expand-file-name
(concat "schedule-"
(replace-regexp-in-string
"[^-+a-z0-9]+" "-"
(downcase
(emacsconf-schedule-rename-etc-timezone timezone)))
".org")
(expand-file-name "schedules"
emacsconf-public-media-directory))))
(unless (file-directory-p (file-name-directory new-filename))
(make-directory (file-name-directory new-filename)))
(with-temp-file new-filename
(insert
"* " emacsconf-name " " emacsconf-year "\n\nTimes are in "
(emacsconf-schedule-rename-etc-timezone timezone) " time zone. You can find this file and other calendars at "
emacsconf-media-base-url emacsconf-year "/schedules/ .\n\n"
(mapconcat (lambda (track)
(emacsconf-publish-format-track-as-org track timezone info))
emacsconf-tracks
"\n")))))
(defun emacsconf-publish-schedule-org-files (&optional info)
(interactive)
(let ((emacsconf-talk-info-functions (append emacsconf-talk-info-functions (list 'emacsconf-get-abstract-from-wiki))))
(setq info (or info (emacsconf-publish-prepare-for-display (emacsconf-get-talk-info)))))
(mapc (lambda (tz) (emacsconf-publish-schedule-org-for-timezone tz info))
(append
emacsconf-timezones
(cl-loop for offset from -12 upto 14
collect
(format "Etc/GMT%s%d" (if (< offset 0) "+" "-") (abs offset))))))
(defun emacsconf-publish-format-res-talks (info)
"Format lines for the backstage index."
(mapconcat
(lambda (o)
(concat
(format "<tr id=\"%s\">" (plist-get o :slug))
"<td>" (format-time-string "%-l:%M" (plist-get o :start-time) emacsconf-timezone) "</td>"
"<td><strong>"
(cond
((not (emacsconf-talk-recorded-p o))
(format-time-string "%-l:%M" (plist-get o :start-time) emacsconf-timezone))
((string-match "live" (plist-get o :qa-type))
(format-time-string "%-l:%M" (plist-get o :qa-time) emacsconf-timezone))
(t ""))
"</strong></td>"
"<td>" (format "<a href=\"%s%s/talks/%s\" target=\"_blank\" rel=\"noreferrer\">%s</a>"
emacsconf-base-url
emacsconf-year
(plist-get o :slug)
(plist-get o :slug))
"</td>"
"<td>" (if (emacsconf-talk-recorded-p o) (plist-get o :qa-type) "(live talk)") "</td>"
(if (plist-get o :bbb-room)
(format "<td><button class=\"copy\" data-copy=\"%s\" data-label=\"Copy mod code\">Copy mod code</button></td>"
(plist-get o :bbb-mod-code))
"<td></td>")
(concat "<td>"
(if (plist-get o :bbb-room)
(format "<a href=\"%s\" target=\"_blank\" rel=\"noreferrer\">Join Q&A</a>" (plist-get o :bbb-room)
""))
"</td>")
"<td>" (if (plist-get o :pad-url)
(format "<a href=\"%s\" target=\"_blank\" rel=\"noreferrer\">Pad</a>" (plist-get o :pad-url))
"")
"</td>"
"<td>" (format "<a href=\"%s\" target=\"_blank\" rel=\"noreferrer\">Chat</a>" (plist-get o :webchat-url))
""
"</td>"
"<td>" (or (plist-get o :title) "") "</td>"
"<td>" (or (plist-get o :speakers) "") (emacsconf-surround " (" (plist-get o :irc) ")" "") "</td>"
"</tr>"))
info
"\n"))
(defun emacsconf-publish-backstage-talk-index ()
"Publish BBB room URLs and pad links for volunteer convenience."
(interactive)
(let* ((emacsconf-publishing-phase 'conference)
(info (mapcar (lambda (o)
(append (list
:url (concat "#" (plist-get o :slug)))
o))
(emacsconf-publish-prepare-for-display (emacsconf-get-talk-info)))))
(mapc
(lambda (track)
(let*
((track-talks (seq-filter (lambda (o) (string= (plist-get o :track)
(plist-get track :name)))
info))
(result
(concat
"<html><head><meta charset=\"utf-8\" /><link rel=\"stylesheet\" href=\"style.css\"></head><body>
<div>"
(let ((emacsconf-use-absolute-url t)
(emacsconf-schedule-svg-modify-functions '(emacsconf-schedule-svg-color-by-status))
(emacsconf-base-url ""))
(with-temp-buffer
(svg-print (emacsconf-schedule-svg 800 300 info))
(buffer-string)))
"</div><h1>"
(plist-get track :name)
"</h1><table>"
(mapconcat
(lambda (day)
(format
"<tr><th colspan=\"7\" style=\"text-align: left\">%s</th></tr>
<tr><th>Talk start</th><th>BBB start</th><th>Talk ID</th><th>Q&A type</th><th>Mod code</th><th>BBB</th><th>Pad</th><th>Chat</th><th>Title</th><th>Speakers</th></tr>
%s"
(car day) (emacsconf-publish-format-res-talks (cdr day))))
(seq-group-by
(lambda (o) (format-time-string "%A, %b %-e" (plist-get o :start-time)))
track-talks)
"\n")
"</table></body>"
(with-temp-buffer
(insert-file-contents (expand-file-name "include-in-index-footer.html" emacsconf-cache-dir))
(buffer-string))
"</html>")))
(with-temp-file (expand-file-name (format "index-%s.html" (plist-get track :id)) emacsconf-backstage-dir)
(insert result))))
emacsconf-tracks)))
(defun emacsconf-publish-index-card-video (video-id video-file talk)
(let* ((video-base (and (stringp video-file) (replace-regexp-in-string "reencoded\\|original" "main" (file-name-base video-file))))
(chapter-info (and (stringp video-file)
(emacsconf-make-chapter-strings
(or (plist-get talk :chapter-file)
(expand-file-name
(concat (file-name-sans-extension video-base) "--chapters.vtt")
emacsconf-cache-dir))
(plist-get talk :track-base-url)
video-id)))
(info
(append
(list
:source-src
(when (stringp video-file)
(if (plist-get talk (if (string-match "--answers" video-file) :qa-public :public))
(format "%s%s/%s" emacsconf-media-base-url (plist-get talk :conf-year)
(file-name-nondirectory video-file))
(file-name-nondirectory video-file)))
:captions
(or
(and (stringp video-file)
(or (plist-get talk :captions-edited)
(and
(plist-get talk :caption-file)
;; Let's try always including the captions even if they're not edited
;; (emacsconf-captions-edited-p
;; (expand-file-name (plist-get talk :caption-file) emacsconf-cache-dir))
))
(let ((tracks
(emacsconf-video-subtitle-tracks
(plist-get talk :caption-file)
(or (plist-get talk :track-base-url)
(plist-get talk :base-url))
(plist-get talk :files))))
(cond
((zerop (length tracks)) "")
((eq (plist-get talk :format) 'wiki) (format "captions=\"\"\"%s\"\"\"" tracks))
(t tracks))))
"")
:chapter-track (or (plist-get chapter-info :track) "")
:chapter-list
(if chapter-info
(if (eq (plist-get talk :format) 'wiki)
(format "[[!template id=\"chapters\" vidid=\"%s\" data=\"\"\"\n%s\n\"\"\"]]"
video-id
(plist-get chapter-info :md))
(plist-get chapter-info :html))
"")
:video-id video-id
:video-file-size (if (and (stringp video-file)
(file-exists-p
(expand-file-name video-file emacsconf-cache-dir)))
(file-size-human-readable (file-attribute-size (file-attributes (expand-file-name video-file emacsconf-cache-dir)))))
:links
(concat
(emacsconf-surround "<li><a href=\""
(unless (eq emacsconf-publishing-phase 'resources)
(if (plist-get talk :backstage)
(emacsconf-backstage-url (plist-get talk :pad-url))
(plist-get talk :pad-url)))
"\">Open Etherpad</a></li>" "")
(emacsconf-surround "<li><a href=\""
(and (plist-get talk :backstage)
(plist-get talk :bbb-backstage))
"\">Open backstage BigBlueButton</a></li>" "")
(emacsconf-surround "<li>BBB mod code: "
(and (plist-get talk :backstage)
(plist-get talk :bbb-mod-code))
"</li>" "")
(emacsconf-surround "<li><a href=\""
(and (member emacsconf-publishing-phase '(schedule conference))
(plist-get talk :qa-url))
"\">Open public Q&A</a></li>" "")
(emacsconf-surround "<li><a href=\""
(and (not (eq emacsconf-publishing-phase 'resources)) (plist-get talk :bbb-rec))
"\">Play recording from BigBlueButton</a></li>" ""))
:other-files
(mapconcat
(lambda (s)
(concat "<li>" s "</li>"))
(emacsconf-publish-link-file-formats-as-list
talk
(seq-filter (lambda (o) (string-match "--answers" o))
(emacsconf-publish-filter-public-files talk)))
"")
:youtube-info (if (plist-get talk :youtube-url)
(format
"<li><a href=\"%s\">View on Youtube</a></li>"
(plist-get talk :youtube-url))
"")
:toobnix-info (if (plist-get talk :toobnix-url)
(format
"<li><a href=\"%s\">View on Toobnix</a></li>"
(plist-get talk :toobnix-url))
"")
:transcript-link
(if (plist-get talk :public)
(format "[View transcript](%s#%s-transcript) \n" (plist-get talk :absolute-url) video-id)
""))
talk)))
(list
:video
(emacsconf-replace-plist-in-string
info
(if (stringp video-file)
"<video controls preload=\"none\" id=\"${video-id}\"><source src=\"${source-src}\" />${captions}${chapter-track}<p><em>Your browser does not support the video tag. Please download the video instead.</em></p></video>${chapter-list}"
(or (plist-get talk :video-note) "")))
:audio
(if (and (plist-get talk :audio-file) (plist-get talk :public))
(format "<div>Listen to just the audio:<br /><audio controls preload=\"none\" id=\"%s-audio\" src=\"%s\"></audio></div>"
video-id
(if (plist-get talk :public)
(format "%s%s/%s" emacsconf-media-base-url (plist-get talk :conf-year)
(file-name-nondirectory (plist-get talk :audio-file)))
(file-name-nondirectory (plist-get talk :audio-file))))
"")
:resources
(emacsconf-replace-plist-in-string
info
"<div class=\"files resources\"><ul>${links}${other-files}${toobnix-info}${youtube-info}</ul></div>"))))
(defun emacsconf-publish-format-public-email (o &optional email)
(format "[%s](mailto:%s?subject=%s)"
(or email (plist-get o :public-email))
(or email (plist-get o :public-email))
(url-hexify-string (format "Comment for EmacsConf 2023 %s: %s" (plist-get o :slug) (plist-get o :title)))))
(defun emacsconf-publish-format-speaker-info (o)
(let ((extra-info (mapconcat #'identity
(delq nil (list
(unless (string= (plist-get o :pronunciation) "nil")
(emacsconf-surround "Pronunciation: "
(if (string-match "\\[" (or (plist-get o :pronunciation) ""))
(org-export-string-as (plist-get o :pronunciation) 'md t)
(plist-get o :pronunciation))
""))
(when (plist-get o :irc) (format "IRC: %s" (plist-get o :irc)))
(if (string-match "\\[" (or (plist-get o :public-contact) ""))
(org-export-string-as (plist-get o :public-contact) 'md t)
(plist-get o :public-contact))
(when (plist-get o :public-email) (format "<mailto:%s>" (plist-get o :public-email)))))
", ")))
(concat (plist-get o :speakers-with-pronouns)
(if (> (length extra-info) 0)
(concat " - " extra-info)
""))))
(defun emacsconf-publish-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
:speaker-info (emacsconf-publish-format-speaker-info o)
:meta "!meta"
:categories (if (plist-get o :categories)
(mapconcat (lambda (o) (format "[[!taglink %s]]" o))
(plist-get o :categories)
" ")
""))))
"[[${meta} title=\"${title}\"]]
[[${meta} copyright=\"Copyright © ${year} ${speakers}\"]]
[[!inline pages=\"internal(${year}/info/${slug}-nav)\" raw=\"yes\"]]
<!-- Initially generated with emacsconf-publish-talk-page and then left alone for manual editing -->
<!-- You can manually edit this file to update the abstract, add links, etc. --->\n
# ${title}
${speaker-info}
[[!inline pages=\"internal(${year}/info/${slug}-before)\" raw=\"yes\"]]
${abstract-md}
[[!inline pages=\"internal(${year}/info/${slug}-after)\" raw=\"yes\"]]
[[!inline pages=\"internal(${year}/info/${slug}-nav)\" raw=\"yes\"]]
${categories}
"))))))
(defun emacsconf-publish-talk-p (talk)
"Return non-nil if the talk is ready to be published.
Talks that are pending review will not be published yet."
(pcase (plist-get talk :status)
('nil nil)
("TODO" nil)
("TO_REVIEW" nil)
;; ("TO_ACCEPT" nil)
("CANCELLED" nil)
(_ t)))
(defun emacsconf-publish-talk-pages (emacsconf-info &optional force)
"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."
(interactive (list (emacsconf-get-talk-info) (> (prefix-numeric-value current-prefix-arg) 1)))
(mapc (lambda (o) (emacsconf-publish-talk-page o force))
(emacsconf-filter-talks emacsconf-info)))
(defun emacsconf-wiki-talk-resources (o)
(setq o (append (list :format 'wiki
:base-url
(concat emacsconf-media-base-url (plist-get o :conf-year) "/")
:track-base-url
(format "/%s/captions/" (plist-get o :conf-year))
:chapter-file (emacsconf-talk-file o "--main--chapters.vtt"))
o))
(concat
(if (plist-get o :qa-public) "# Talk\n\n" "")
(emacsconf-publish-index-card
(append o
(list
:caption-file (emacsconf-talk-file o "--main.vtt")
:files (seq-remove (lambda (f) (string-match "--answers" f))
(emacsconf-publish-filter-public-files o)))))
(if (plist-get o :qa-public)
(concat "\n\n# Q&A\n\n"
(emacsconf-publish-index-card (append
(list
:public 1
:video-type "qanda"
:video-id (concat "qanda-" (plist-get o :slug))
:youtube-url (plist-get o :qa-youtube-url)
:toobnix-url (plist-get o :qa-toobnix-url)
:captions-edited (plist-get o :qa-captions-edited)
:caption-file (emacsconf-talk-file o "--answers.vtt")
:video-file (plist-get o :qa-video-file)
:video-duration (plist-get o :qa-video-duration)
:audio-file (emacsconf-talk-file o "--answers.opus")
:chapter-file (emacsconf-talk-file o "--answers--chapters.vtt")
:files (emacsconf-publish-filter-public-files o "answers"))
o)))
"")))
(defun emacsconf-publish-webchat-link (o)
(let ((track (emacsconf-get-track (plist-get o :track))))
(format "<a href=\"%s\">#%s</a>"
(plist-get track :webchat-url)
(plist-get track :channel))))
(defun emacsconf-publish-format-talk-schedule-info (o)
"Format schedule information for O."
(let ((friendly (concat "/" emacsconf-year "/talks/" (plist-get o :slug) ))
(timestamp (org-timestamp-from-string (plist-get o :scheduled)))
(talk-p (emacsconf-publish-talk-p o)))
(emacsconf-replace-plist-in-string
(append o
(list
:format
(if talk-p
(concat (or (plist-get o :video-time)
(plist-get o :time))
"-min talk ; Q&A: "
(pcase (plist-get o :qa-type)
("none" "ask questions via Etherpad/IRC; we'll e-mail the speaker and post answers on this wiki page after the conference")
("live" "BigBlueButton conference room")
("pad" "Etherpad")
("irc" "IRC")
(_ (plist-get o :qa-type)))
(emacsconf-surround " <" (and (member emacsconf-publishing-phase '(schedule conference))
(plist-get o :qa-url)) ">" "")
(if (string= (plist-get o :qa-type) "pad")
""
(format " Etherpad: <%s>"
(plist-get o :pad-url)
)
))
(concat (or (plist-get o :video-time)
(plist-get o :time))
(if (string= (plist-get o :status) "CANCELLED")
"-min talk cancelled"
"-min talk")))
:pad-info
(if (and talk-p emacsconf-publish-include-pads (not (and (member emacsconf-publishing-phase '(schedule conference))
(string= (plist-get o :qa-type) "etherpad"))))
(format "Etherpad: <https://pad.emacsconf.org/%s-%s> \n" emacsconf-year (plist-get o :slug))
"")
:irc-info
(if (member emacsconf-publishing-phase '(schedule conference))
(format "Discuss on IRC: [#%s](%s) \n" (plist-get o :channel)
(plist-get o :webchat-url))
"")
:status-info
(format "Status: %s \n" (plist-get o :status-label))
:alternate-apac-info
(if (plist-get o :alternate-apac)
(format "[[!inline pages=\"internal(%s/inline-alternate)\" raw=\"yes\"]] \n" emacsconf-year)
"")
:schedule-info
(if (and (member emacsconf-publishing-phase '(schedule conference))
(not (emacsconf-talk-all-done-p o))
(not (string= (plist-get o :status) "CANCELLED")))
(let* ((end
(org-timestamp-to-time
(org-timestamp-split-range
(org-timestamp-from-string (plist-get o :scheduled)) t)))
(start (org-timestamp-to-time
(org-timestamp-split-range
(org-timestamp-from-string (plist-get o :scheduled))))))
(format
"<div>Times in different time zones:</div><div class=\"times\" start=\"%s\" end=\"%s\"><div class=\"conf-time\">%s</div><div class=\"others\"><div>which is the same as:</div>%s</div></div><div><strong><a href=\"/%s/watch/%s/\">Find out how to watch and participate</a></strong></div>"
(format-time-string "%Y-%m-%dT%H:%M:%SZ" start t)
(format-time-string "%Y-%m-%dT%H:%M:%SZ" end t)
(emacsconf-timezone-string o emacsconf-timezone)
(string-join (emacsconf-timezone-strings
o
(seq-remove (lambda (zone) (string= emacsconf-timezone zone))
emacsconf-timezones)) "<br />")
emacsconf-year
(plist-get (emacsconf-get-track (plist-get o :track)) :id)))
"")))
"[[!toc ]]
Format: ${format} \n${pad-info}${irc-info}${status-info}${schedule-info}\n
${alternate-apac-info}\n")))
(defun emacsconf-publish-format-email-questions-and-comments (talk)
"Invite people to e-mail either the public contact for TALK or the private list."
(format "Questions or comments? Please e-mail %s"
(emacsconf-publish-format-public-email talk
(or
(and (string= (plist-get talk :public-email) "t")
(plist-get talk :email))
(plist-get talk :public-email)
emacsconf-fallback-email))))
(defun emacsconf-publish-captions-in-wiki (talk)
"Copy the captions file."
(interactive (list (emacsconf-complete-talk-info)))
(unless (file-directory-p (expand-file-name "captions" (expand-file-name emacsconf-year emacsconf-directory)))
(make-directory (expand-file-name "captions" (expand-file-name emacsconf-year emacsconf-directory))))
(let ((default-directory emacsconf-directory))
(mapc
(lambda (ext)
(let ((filename (expand-file-name (concat (plist-get talk :file-prefix) ext)
(expand-file-name "captions" (expand-file-name emacsconf-year emacsconf-directory))))
(cached-file (expand-file-name (concat (plist-get talk :file-prefix) ext) emacsconf-cache-dir)))
(when (and (file-exists-p cached-file)
(or
(not (file-exists-p filename))
(file-newer-than-file-p cached-file filename)))
(copy-file cached-file filename t)
(shell-command (concat "git add " (shell-quote-argument filename))))))
(seq-filter (lambda (o) (string-match "vtt$" o))
emacsconf-main-extensions))))
(defun emacsconf-publish-format-talk-schedule-image (talk info)
"Add the schedule image for TALK based on INFO."
(concat
"\nThe following image shows where the talk is in the schedule for "
(format-time-string "%a %Y-%m-%d" (plist-get talk :start-time) emacsconf-timezone) ". Solid lines show talks with Q&A via BigBlueButton. Dashed lines show talks with Q&A via IRC or Etherpad."
(format "<div class=\"schedule-in-context schedule-svg-container\" data-slug=\"%s\">\n" (plist-get talk :slug))
(let* ((width 700) (height 150)
(talk-date (format-time-string "%Y-%m-%d" (plist-get talk :start-time) emacsconf-timezone))
(start (date-to-time (concat talk-date "T" emacsconf-schedule-start-time emacsconf-timezone-offset)))
(end (date-to-time (concat talk-date "T" emacsconf-schedule-end-time emacsconf-timezone-offset)))
svg)
(with-temp-buffer
(setq svg (emacsconf-schedule-svg-day
(svg-create width height)
(format-time-string "%A" (plist-get talk :start-time) emacsconf-timezone)
width height
start end
(emacsconf-by-track
(seq-filter (lambda (o) (string= (format-time-string "%Y-%m-%d" (plist-get o :start-time) emacsconf-timezone)
talk-date))
info))))
(mapc (lambda (node)
(let ((rect (car (dom-by-tag node 'rect))))
(if (string= (dom-attr node 'data-slug) (plist-get talk :slug))
(progn
(dom-set-attribute rect 'opacity "0.8")
(dom-set-attribute rect 'stroke-width "3")
(dom-set-attribute (car (dom-by-tag node 'text)) 'font-weight "bold"))
(dom-set-attribute rect 'opacity "0.5"))))
(dom-by-tag svg 'a))
(svg-print svg)
(buffer-string)))
"\n</div>\n\n"))
(defun emacsconf-publish-before-page (talk &optional info)
"Generate the page that has the info included before the abstract.
This includes the intro note, the schedule, and talk resources."
(interactive (list (emacsconf-complete-talk-info)))
(setq info (or info (emacsconf-publish-prepare-for-display (emacsconf-get-talk-info))))
(with-temp-file (expand-file-name (format "%s-before.md" (plist-get talk :slug))
(expand-file-name "info" (expand-file-name emacsconf-year emacsconf-directory)))
(hack-dir-local-variables-non-file-buffer)
(insert "<!-- Automatically generated by emacsconf-publish-before-page -->\n")
(insert (emacsconf-surround "" (plist-get talk :intro-note) "\n\n" ""))
(let ((is-live (emacsconf-talk-live-p talk)))
(when is-live (emacsconf-publish-captions-in-wiki talk))
(when (emacsconf-publish-talk-p talk)
(when (member emacsconf-publishing-phase '(schedule conference))
(insert (emacsconf-publish-format-talk-schedule-image talk info))))
(insert (emacsconf-publish-format-talk-schedule-info talk) "\n\n")
(insert
(if (plist-get talk :public) (emacsconf-wiki-talk-resources talk) "")
"\n# Description\n"))
(insert "<!-- End of emacsconf-publish-before-page -->")))
(defun emacsconf-format-transcript-from-list (subtitles video-id &optional lang)
"Return subtitle directives for SUBTITLES."
(let ((subed-sanitize-functions nil))
(when (stringp subtitles) (setq subtitles (subed-parse-file subtitles))))
(mapconcat
(lambda (sub)
(let ((msecs (elt sub 1)))
(concat
(if (and (elt sub 4) (not (string= (elt sub 4) "")))
(format "\n<div class=\"transcript-heading\">[[!template new=\"1\" text=\"\"\"%s\"\"\" start=\"%s\" video=\"%s\" id=\"subtitle\"%s]]</div>"
(replace-regexp-in-string "\\." "\\\\." (string-trim (replace-regexp-in-string "^NOTE[ \n]" "" (elt sub 4))))
(concat (format-seconds "%02h:%02m:%02s" (/ (floor msecs) 1000))
"." (format "%03d" (mod (floor msecs) 1000)))
video-id
(emacsconf-surround " lang=\"" lang "\"" ""))
"")
(format
"[[!template text=\"\"\"%s\"\"\" start=\"%s\" video=\"%s\" id=\"subtitle\"%s]]"
(replace-regexp-in-string
"^#" "\\\\#"
(replace-regexp-in-string
"*" "\\\\*"
(replace-regexp-in-string "\"" """ (elt sub 3))))
(concat (format-seconds "%02h:%02m:%02s" (/ (floor msecs) 1000))
"." (format "%03d" (mod (floor msecs) 1000)))
video-id
(emacsconf-surround " lang=\"" lang "\"" "")))))
subtitles "\n"))
(defun emacsconf-publish-format-transcript (talk &optional video-id lang title)
"Format the transcript for TALK, adding paragraph markers when possible."
(require 'subed)
(setq video-id (or video-id "mainVideo"))
(let* ((subed-sanitize-functions nil)
(subtitles
(subed-parse-file (if lang
(format "%s_%s.vtt"
(file-name-sans-extension
(plist-get talk :caption-file))
lang)
(plist-get talk :caption-file)))))
(if subtitles
(format "<div class=\"transcript%s\"><a name=\"%s-%s-transcript%s\"></a><h1>%s%s</h1>
%s
</div>"
(if video-id (concat " transcript-" video-id) "")
(plist-get talk :slug)
video-id
(emacsconf-surround "-" lang "" "")
(if lang (assoc-default lang emacsconf-publish-subtitle-languages) (or title "Transcript"))
(if (emacsconf-captions-edited-p (plist-get talk :caption-file))
""
" (unedited)")
(emacsconf-format-transcript-from-list
subtitles (concat video-id "-" (plist-get talk :slug))))
"")))
(defun emacsconf-publish-format-captions (talk)
(let ((transcripts
(mapconcat
(lambda (lang)
(let ((filename
(emacsconf-talk-file
talk
(if lang
(format "--main_%s.vtt" lang)
"--main.vtt"))))
(if filename
;; (and filename (emacsconf-captions-edited-p filename))
; todo: cache this somewhere
(emacsconf-publish-format-transcript
(append
(list :chapter-file (emacsconf-talk-file talk "--main--chapters.vtt")
:caption-file (emacsconf-talk-file talk "--main.vtt"))
talk)
"mainVideo" lang)
"")))
(cons nil (mapcar 'car emacsconf-publish-subtitle-languages))
"")))
(if (> (length transcripts) 0)
(concat transcripts
(emacsconf-surround
(if (string-match "[,;]" (or (plist-get talk :captioner) ""))
"\n\nCaptioners: "
"\n\nCaptioner: ")
(plist-get talk :captioner)
"\n\n"))
"")))
(defun emacsconf-publish-after-page (talk &optional info)
"Generate the page with info included after the abstract.
This includes captions, contact, and an invitation to participate."
(interactive (list (emacsconf-complete-talk-info)))
;; Contact information
(with-temp-file (expand-file-name (format "%s-after.md" (plist-get talk :slug))
(expand-file-name "info" (expand-file-name emacsconf-year emacsconf-directory)))
(hack-dir-local-variables-non-file-buffer)
(insert
"<!-- Automatically generated by emacsconf-publish-after-page -->\n"
"\n\n"
;; main transcript
(if (plist-get talk :public) (emacsconf-publish-format-captions talk) "")
(if (and (plist-get talk :qa-public) (emacsconf-talk-file talk "--answers.vtt"))
(emacsconf-publish-format-transcript
(append
(list :chapter-file (emacsconf-talk-file talk "--answers--chapters.vtt")
:caption-file (emacsconf-talk-file talk "--answers.vtt"))
talk)
"qanda" nil "Q&A transcript")
"")
(emacsconf-publish-format-email-questions-and-comments talk) "\n"
(if (eq emacsconf-publishing-phase 'cfp)
(format "\n----\nGot an idea for an EmacsConf talk or session? We'd love to hear from you! Check out the [[Call for Participation|/%s/cfp]] for details.\n" emacsconf-year)
"")
"\n\n<!-- End of emacsconf-publish-after-page -->\n")))
(defun emacsconf-sort-by-track-then-schedule (a b)
;; Gen,Dev; then by time
(cond
((and (plist-get a :speakers)
(not (plist-get b :speakers))) t)
((and (plist-get b :speakers)
(not (plist-get a :speakers))) nil)
((string< (plist-get a :track)
(plist-get b :track)) nil)
((string< (plist-get b :track)
(plist-get a :track)) t)
((time-less-p (plist-get a :start-time)
(plist-get b :start-time)) t)
(t nil)))
(defun emacsconf-publish-cancelled-nav-page (talk)
(with-temp-file (expand-file-name (format "%s-nav.md" (plist-get talk :slug))
(expand-file-name "info" (expand-file-name emacsconf-year emacsconf-directory)))
(insert "\n<div class=\"talk-nav\">
Back to the [[talks]] \n</div>")))
(defun emacsconf-publish-nav-pages (&optional talks)
"Generate links to the next and previous talks.
During the schedule and conference phase, the talks are sorted by time.
Otherwise, they're sorted by track and then schedule."
(interactive (list (emacsconf-publish-prepare-for-display (or emacsconf-schedule-draft (emacsconf-get-talk-info)))))
(let* ((next-talks (cdr talks))
(prev-talks (cons nil talks))
(label (if (member emacsconf-publishing-phase '(schedule conference))
"time"
"track")))
(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))))
(with-temp-file (expand-file-name (format "%s-nav.md" (plist-get o :slug))
(expand-file-name "info" (expand-file-name emacsconf-year emacsconf-directory)))
(insert (concat "\n<div class=\"talk-nav\">
Back to the [[talks]] \n"
(if prev-talk (format "Previous by %s: %s \n" label prev-talk) "")
(if next-talk (format "Next by %s: %s \n" label next-talk) "")
(if (plist-get o :track) ; tagging doesn't work here because ikiwiki will list the nav page
(if (member emacsconf-publishing-phase '(schedule conference))
(format "Track: <span class=\"sched-track %s\">%s</span> - <strong><a href=\"%s\">Watch</a></strong> \n"
(plist-get o :track)
(plist-get o :track)
(plist-get o :watch-url))
(format "Track: <span class=\"sched-track %s\">%s</span> \n"
(plist-get o :track)
(plist-get o :track)))