From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id KENvOfZtxmOgDgEAbAwnHQ (envelope-from ) for ; Tue, 17 Jan 2023 10:44:23 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id 6F2POfZtxmNBkQAA9RJhRA (envelope-from ) for ; Tue, 17 Jan 2023 10:44:22 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id B00D3231B2 for ; Tue, 17 Jan 2023 10:44:22 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pHiUf-0007qz-4Q; Tue, 17 Jan 2023 04:43:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHiUa-0007nE-UW for emacs-orgmode@gnu.org; Tue, 17 Jan 2023 04:42:59 -0500 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pHiUY-0005Bk-2g for emacs-orgmode@gnu.org; Tue, 17 Jan 2023 04:42:56 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id B76582401FF for ; Tue, 17 Jan 2023 10:42:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1673948571; bh=rNEo16fvrCQOAQ/j70i8eENBkHI3yQAAOUDvYCzh6bQ=; h=From:To:Cc:Subject:Date:From; b=glo3jX3wb6fCH8VJUCvTpeG/3/rkmu63msmiaa6uhqKY5/0Tq/wPV091+o9pwgtPP m2cSY0N9RjGVFaQ5hJRjoBzlazACZVsfSB7wchgeT4wl7jwIzw3doh7PppEvtAQOHl ifbI0zACX6Tdc2lSHQO6WPvN8un1b+8+/139Rw7zlTPpGFu4CwkBkehs2leN9rh/5V C1AtCL3ZxEJEyzr5hO7qhmGWSHC2/PNsxa0TDgwJo4re8ODQEl83nFITjUritloC9K EnxL85ED7uFs2lfRhOkc7dN9egJesU1YaW8BVo37p0NbUmYxvoJDf3CU0MaLUu0RNO IrGiy57VSuKag== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4Nx3pc1lgzz6tpD; Tue, 17 Jan 2023 10:42:48 +0100 (CET) From: Ihor Radchenko To: Detlef Steuer Cc: emacs-orgmode@gnu.org Subject: Re: [patch] improved: add TTL as defcustom to ox-icalendar In-Reply-To: <20230116234230.5080fb07@linux.fritz.box> References: <20211230225919.1a660666@hsu-hh.de> <20220102142849.0af72bcb@hsu-hh.de> <20220103084141.72d2f384@hsu-hh.de> <20220103123253.6bb48655@hsu-hh.de> <87o7tgaa42.fsf@localhost> <20221109082520.066dc4c6@linux.fritz.box> <20230113181035.1469ab37@hsu-hh.de> <878ri52z06.fsf@localhost> <20230116234230.5080fb07@linux.fritz.box> Date: Tue, 17 Jan 2023 09:43:18 +0000 Message-ID: <87lem1ijih.fsf@localhost> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-TUID: Ik+5Ky32UeJU --=-=-= Content-Type: text/plain Detlef Steuer writes: > I tried to follow your advice to improve the patch accordingly. > New version attached. I have amended your patch fixing some of the spelling issues and indentation. See the attached. Note that I used "time to live" consistently instead of "time to life". The former is the right abbreviation meaning, AFAIU (https://www.cloudflare.com/learning/cdn/glossary/time-to-live-ttl/) I also have a more general comment. The patch only allows to the TTL globally for all the calendars. However, it would make sense to specify TTL on per-file basis. WDYT? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=v2-0001-lisp-ox-icalendar.el-Add-customize-option-org-ica.patch >From 04174d53b84e32a2a73eb19ce9a1e12dff69d071 Mon Sep 17 00:00:00 2001 Message-Id: <04174d53b84e32a2a73eb19ce9a1e12dff69d071.1673948403.git.yantar92@posteo.net> From: Detlef Steuer Date: Mon, 16 Jan 2023 23:27:33 +0100 Subject: [PATCH v2] lisp/ox-icalendar.el: Add customize option `org-icalendar-ttl' * ox-icalendar.el: New option `org-icalendar-ttl' to add en entry for the X-PUBLISHED-TTL option to ox-icalendar. Default value is nil, what means no such entry is exported. If non nil the value must be formated according to https://icalendar.org/iCalendar-RFC-5545/3-8-2-5-duration.html. --- etc/ORG-NEWS | 15 +++++++++++ lisp/ox-icalendar.el | 62 ++++++++++++++++++++++++++++++++++---------- 2 files changed, 64 insertions(+), 13 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index c5d9bdf6e..fd44198ab 100644 --- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -13,6 +13,21 @@ Please send Org bug reports to mailto:emacs-orgmode@gnu.org. * Version 9.7 (not released yet) ** New options +*** New custom setting ~org-icalendar-ttl~ for the ~ox-icalendar~ backend + +The option ~org-icalendar-ttl~ allows to advise a subscriber to the +exported =.ics= file to reload after the given time interval. + +This is useful i.e. if a calendar server subscribes to your exported +file and that is updated regularly. + +See IETF RFC 5545, Section 3.3.6 Duration and +https://en.wikipedia.org/wiki/ICalendar#Other_component_types for +details. + +Default for ~org-icalendar-ttl~ is ~nil~. In that case the setting +will not be used in the exported ICS file. + *** New options for the "csl" citation export processor's LaTeX output The ~org-cite-csl-latex-label-separator~ and diff --git a/lisp/ox-icalendar.el b/lisp/ox-icalendar.el index 81a77a770..081a0a516 100644 --- a/lisp/ox-icalendar.el +++ b/lisp/ox-icalendar.el @@ -297,6 +297,30 @@ (defcustom org-icalendar-date-time-format ":%Y%m%dT%H%M%S" (const :tag "Universal time" ":%Y%m%dT%H%M%SZ") (string :tag "Explicit format"))) +(defcustom org-icalendar-ttl nil + "Time to live for the exported calendar. + +Subscribing clients to the exported ics file can derive the time +interval to read the file again from the server. One example of such +client is Nextcloud calendar, which respects the setting of +X-PUBLISHED-TTL in ICS files. Setting `org-icalendar-ttl' to \"PT1H\" +would advise a server to reload the file every hour. + +See https://icalendar.org/iCalendar-RFC-5545/3-8-2-5-duration.html for +a complete description of possible specifications of this option. For +example, \"PT1H\" stands for 1 hour and \"PT0H27M34S\" stands for 0 +hours, 27 minutes and 34 seconds. + +The default value is nil, which means no such option is set in the ICS +file." + :group 'org-export-icalendar + :type '(choice + (const :tag "No refresh period" nil) + (const :tag "One day" "PT1D") + (const :tag "One week" "PT7D") + (string :tag "Other")) + :package-version '(Org . "9.7")) + (defvar org-icalendar-after-save-hook nil "Hook run after an iCalendar file has been saved. This hook is run with the name of the file as argument. A good @@ -334,7 +358,8 @@ (org-export-define-derived-backend 'icalendar 'ascii (:icalendar-use-deadline nil nil org-icalendar-use-deadline) (:icalendar-use-scheduled nil nil org-icalendar-use-scheduled) (:icalendar-scheduled-summary-prefix nil nil org-icalendar-scheduled-summary-prefix) - (:icalendar-deadline-summary-prefix nil nil org-icalendar-deadline-summary-prefix)) + (:icalendar-deadline-summary-prefix nil nil org-icalendar-deadline-summary-prefix) + (:icalendar-ttl nil nil org-icalendar-ttl)) :filters-alist '((:filter-headline . org-icalendar-clear-blank-lines)) :menu-entry @@ -872,26 +897,34 @@ (defun org-icalendar-template (contents info) (or (org-string-nw-p org-icalendar-timezone) (format-time-string "%Z")) ;; Description. (org-export-data (plist-get info :title) info) + ;; TTL + (plist-get info :icalendar-ttl) contents)) -(defun org-icalendar--vcalendar (name owner tz description contents) +(defun org-icalendar--vcalendar (name owner tz description ttl contents) "Create a VCALENDAR component. -NAME, OWNER, TZ, DESCRIPTION and CONTENTS are all strings giving, +NAME, OWNER, TZ, DESCRIPTION, TTL and CONTENTS are all strings giving, respectively, the name of the calendar, its owner, the timezone -used, a short description and the other components included." - (concat (format "BEGIN:VCALENDAR +used, a short description, time to live resp. refresh period and +the other components included." + (concat + (format + (concat + "BEGIN:VCALENDAR VERSION:2.0 X-WR-CALNAME:%s PRODID:-//%s//Emacs with Org mode//EN X-WR-TIMEZONE:%s -X-WR-CALDESC:%s -CALSCALE:GREGORIAN\n" - (org-icalendar-cleanup-string name) - (org-icalendar-cleanup-string owner) - (org-icalendar-cleanup-string tz) - (org-icalendar-cleanup-string description)) - contents - "END:VCALENDAR\n")) +X-WR-CALDESC:%s\n" + (when ttl "X-PUBLISHED-TTL:%s\n") + "CALSCALE:GREGORIAN\n") + (org-icalendar-cleanup-string name) + (org-icalendar-cleanup-string owner) + (org-icalendar-cleanup-string tz) + (org-icalendar-cleanup-string description) + (org-icalendar-cleanup-string ttl)) + contents + "END:VCALENDAR\n")) @@ -1018,6 +1051,7 @@ (defun org-icalendar-export-current-agenda (file) user-full-name (or (org-string-nw-p org-icalendar-timezone) (format-time-string "%Z")) org-icalendar-combined-description + org-icalendar-ttl contents))) (run-hook-with-args 'org-icalendar-after-save-hook file))) @@ -1042,6 +1076,8 @@ (defun org-icalendar--combine-files (&rest files) (format-time-string "%Z")) ;; Description. org-icalendar-combined-description + ;; TTL (Refresh period) + org-icalendar-ttl ;; Contents. (concat ;; Agenda contents. -- 2.39.0 --=-=-= Content-Type: text/plain -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at --=-=-=--