From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id YDmoHWRsl1+iUAAA0tVLHw (envelope-from ) for ; Tue, 27 Oct 2020 00:40:04 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id VAh/GWRsl1+BcQAAbx9fmQ (envelope-from ) for ; Tue, 27 Oct 2020 00:40:04 +0000 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 C502E94065D for ; Tue, 27 Oct 2020 00:40:03 +0000 (UTC) Received: from localhost ([::1]:59868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kXD1t-0007Nz-9o for larch@yhetil.org; Mon, 26 Oct 2020 20:40:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42312) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXD12-0007Nc-6X for emacs-orgmode@gnu.org; Mon, 26 Oct 2020 20:39:08 -0400 Received: from memebeam.org ([80.68.89.71]:57725 helo=jvb.vm.bytemark.co.uk) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kXD0z-0008Am-LZ; Mon, 26 Oct 2020 20:39:07 -0400 Received: from [192.168.1.27] (dhcp-68-142-39-249.greenmountainaccess.net [::ffff:68.142.39.249]) (AUTH: LOGIN acarrico@memebeam.org, TLS: TLS1.3, 128bits, ECDHE_RSA_AES_128_GCM_SHA256) by jvb.vm.bytemark.co.uk with ESMTPSA id 00000000001A80FD.5F976C01.00002C5E; Mon, 26 Oct 2020 20:38:25 -0400 Subject: Re: [PATCH] Include missing files when sitemap style is tree To: Bastien References: <393d0ddf-894a-6183-c1fd-d8ab23a2163a@memebeam.org> <87blgrke6b.fsf@gnu.org> From: Anthony Carrico Message-ID: Date: Mon, 26 Oct 2020 20:38:16 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <87blgrke6b.fsf@gnu.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Received-SPF: pass client-ip=80.68.89.71; envelope-from=acarrico@memebeam.org; helo=jvb.vm.bytemark.co.uk X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/26 20:38:26 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-2.167, 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.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.01 X-TUID: vTIpEZUWw3hO On 10/24/20 8:21 AM, Bastien wrote: > Anthony Carrico writes: > >> * ox-publish.el (org-publish-sitemap): Include files that have an >> ancestor below base-directory with no published files and sitemap style >> is tree. > > thanks for the patch and sorry for the delay in replying. I'm not > sure I understand the bug it fixes: can you briefly describe it or > provide a reproducible recipe? #!/run/current-system/sw/bin/emacs --script (require 'org) (require 'ox-publish) ;;; create a source directory tree: (make-directory "test-export/src/level1/level2/level3" t) ;;; create two source files, with an empty directory between: (with-temp-file "test-export/src/level1/one.org" (insert "#+TITLE one")) (with-temp-file "test-export/src/level1/level2/level3/three.org" (insert "#+TITLE three")) ;;; create a destination directory trees: (make-directory "test-export/dest" t) ;;; publish the test-export: (setq org-publish-project-alist `(("test-export" :base-directory "test-export/src" :publishing-directory "test-export/dest" :publishing-function org-html-publish-to-html :sitemap-filename "index.org" :sitemap-title "test-export" :sitemap-style tree :auto-sitemap t :recursive t))) ;; ISSUE: Even with the force argument, org-publish still seems to generate a cache in ~/.org-timestamps which creates a sitemap with old titles and breaks reproducible builds. To avoid this problem delete the cache when publishing: (defun org-publish-delete-cache-file (project-name) (let* ((cache-file (concat (expand-file-name org-publish-timestamp-directory) project-name ".cache")) (cexists (file-exists-p cache-file))) (when (file-exists-p cache-file) (delete-file cache-file)))) (org-publish-delete-cache-file "test-export") (org-publish "test-export" t) (org-publish-delete-cache-file "test-export") ;; Now run: ;; ;; $ firefox test-export/dest/index.html ;; ;; You should see something like this: ;; ;; ;; test-export ;; ;; level1 ;; one ;; ;; Now run again with my patch, and you will see something like this: ;; ;; test-export ;; ;; level1 ;; one ;; level2 ;; level3 ;; three ;; ;; As you can see, without the patch, "three" is missing from the index. >> +(defun org-publish-dir-name-parent (dir-name) >> + (file-name-as-directory (expand-file-name (concat dir-name "..")))) >> + >> +(defun org-publish-dir-name-and-parents (dir-name root-dir-name) >> + (pcase dir-name >> + ("" nil) >> + ((or "./" "/" (pred (string= root-dir-name))) (list dir-name)) >> + (_ (cons dir-name (org-publish-dir-name-and-parents >> + (org-publish-dir-name-parent dir-name) root-dir-name))))) >> + >> +(defun org-publish-file-name-parents (file root) >> + (org-publish-dir-name-and-parents (file-name-directory file) >> + (file-name-as-directory root))) >> + > > You would need to add docstrings for each of the new functions. I've run out of time today. These /seem/ like they should be standard procedures in elisp, not something in org-publish, but I couldn't find them in the manual. I'm not very experienced with elisp though. I've run out of time today. Tell me if you have trouble with the test case. Thank you Bastien. -- Anthony Carrico