[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa-admin e3683d9 426/439: elpa-admin.el: Improve the badge ge
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa-admin e3683d9 426/439: elpa-admin.el: Improve the badge generation code |
Date: |
Sun, 17 Oct 2021 15:48:50 -0400 (EDT) |
branch: elpa-admin
commit e3683d997a5887c70bd2e2a79796a21d7afd02b6
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>
elpa-admin.el: Improve the badge generation code
(elpaa--add-badge-link): New function.
(elpaa--string-width): Remove superfluous `save-match-data`.
(elpaa--html-make-pkg): Call `elpaa--make-badge`.
(elpaa--make-one-package): Call `elpaa--make-badge` and
`elpaa--add-badge-link`
to generate missing badges and add missing badge links.
---
elpa-admin.el | 57 ++++++++++++++++++++++++++++++++++++---------------------
1 file changed, 36 insertions(+), 21 deletions(-)
diff --git a/elpa-admin.el b/elpa-admin.el
index 64e37dc..ac25541 100644
--- a/elpa-admin.el
+++ b/elpa-admin.el
@@ -653,11 +653,10 @@ Return non-nil if a new tarball was created."
(elpaa--call (current-buffer)
"convert" "-debug" "annotate" "xc:" "-font" "DejaVu-Sans"
"-pointsize" "110" "-annotate" "0" str "null:")
- (save-match-data ;;FIXME: Why?
- (goto-char (point-min))
- (if (re-search-forward "Metrics:.*?width: \\([0-9]+\\)")
- (string-to-number (match-string 1))
- (error "Could not determine string width")))))
+ (goto-char (point-min))
+ (if (re-search-forward "Metrics:.*?width: \\([0-9]+\\)")
+ (string-to-number (match-string 1))
+ (error "Could not determine string width"))))
(defun elpaa--make-badge (file left right)
"Make badge svg FILE with LEFT and RIGHT string."
@@ -735,6 +734,20 @@ Return non-nil if a new tarball was created."
</svg>"))))
(write-region (point-min) (point-max) file))))
+(defun elpaa--add-badge-link (file name)
+ "Add badge link to FILE for package NAME."
+ (with-temp-buffer
+ (insert-file-contents file)
+ (let ((contents (buffer-string)))
+ (unless (string-match-p "<dt>Badge</dt>" contents)
+ (erase-buffer)
+ (insert
+ (replace-regexp-in-string "</dl>"
+ (format "<dt>Badge</dt><dd><img
src=\"%s.svg\"/></dd>\n</dl>"
+ (elpaa--html-quote name))
+ contents))
+ (write-region (point-min) (point-max) file)))))
+
(defun elpaa--make-one-package (pkg-spec &optional one-tarball)
"Build the new tarballs (if needed) for PKG-SPEC.
If ONE-TARBALL is non-nil, don't try and select some other revision and
@@ -767,8 +780,6 @@ place the resulting tarball into the file named
ONE-TARBALL."
(devel-vers
(concat vers (if (string-match "[0-9]\\'" vers) ".")
"0." date-version))
- (release-badge (format "%s/%s.svg" elpaa--release-subdir pkgname))
- (devel-badge (format "%s/%s.svg" elpaa--devel-subdir pkgname))
(tarball (or one-tarball
(concat elpaa--devel-subdir
(format "%s-%s.tar" pkgname devel-vers))))
@@ -815,22 +826,23 @@ place the resulting tarball into the file named
ONE-TARBALL."
(elpaa--get-release-revision
dir pkg-spec vers
(plist-get (cdr pkg-spec) :version-map))))
- (elpaa--make-badge release-badge
- (format "%s ELPA" elpaa--name)
- (format "%s %s" pkgname vers))
(elpaa--release-email pkg-spec metadata dir)))))
- ;; Generate missing badges
- ;; FIXME: Why here?
- (unless (and (not new) (file-exists-p devel-badge))
- (elpaa--make-badge devel-badge
- (format "%s-devel ELPA" elpaa--name)
- (format "%s %s" pkgname devel-vers)))
- ;; FIXME: Shouldn't it be made already above?
- (unless (file-exists-p release-badge)
- (elpaa--make-badge release-badge
- (format "%s ELPA" elpaa--name)
- (format "%s %s" pkgname vers)))))))
+ ;; Generate missing badges (temporary code)
+ (let ((release-badge (format "%s/%s.svg" elpaa--release-subdir
pkgname))
+ (devel-badge (format "%s/%s.svg" elpaa--devel-subdir pkgname))
+ (release-html (format "%s/%s.html" elpaa--release-subdir
pkgname))
+ (devel-html (format "%s/%s.html" elpaa--devel-subdir pkgname)))
+ (unless (file-exists-p devel-badge)
+ (elpaa--make-badge devel-badge
+ (format "%s-devel ELPA" elpaa--name)
+ (format "%s %s" pkgname devel-vers))
+ (elpaa--add-badge-link devel-html pkgname))
+ (unless (file-exists-p release-badge)
+ (elpaa--make-badge release-badge
+ (format "%s ELPA" elpaa--name)
+ (format "%s %s" pkgname vers))
+ (elpaa--add-badge-link release-html pkgname)))))))
(defun elpaa--call (destination program &rest args)
"Like ‘call-process’ for PROGRAM, DESTINATION, ARGS.
@@ -1218,6 +1230,9 @@ Rename DIR/ to PKG-VERS/, and return the descriptor."
(mainsrcfile (expand-file-name (elpaa--main-file pkg-spec) srcdir))
(desc (aref (cdr pkg) 2)))
(cl-assert (equal name (car pkg-spec)))
+ (elpaa--make-badge (concat name ".svg")
+ (format "%s ELPA" elpaa--name)
+ (format "%s %s" name latest))
(with-temp-buffer
(insert (elpaa--html-header
(format "%s ELPA - %s" elpaa--name name)
- [nongnu] elpa-admin d10026f 419/439: * elpa-admin.el: Preserve release tarballs at least 2 years, (continued)
- [nongnu] elpa-admin d10026f 419/439: * elpa-admin.el: Preserve release tarballs at least 2 years, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin 97ebbd5 405/439: * elpa-admin.el (elpaa--prune-old-tarballs): "(Re)move" the non-kept files, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin 8ed7b88 354/439: Rename vars and functions with `elpaa-` prefix, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin d8903b6 358/439: * elpa-admin.el: Add some of the support needed to build Org packages, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin 7e5b75b 359/439: * elpa-admin.el: Add support for checking copyright notices, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin c26df96 392/439: * elpa-admin.el: Allow `:doc` to specify several doc files, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin 396a74b 421/439: Bump license for package pages to CC BY-ND 4.0, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin c29da22 424/439: * elpa-admin.el: Generate SVG badges, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin fa18a66 413/439: * elpa-admin.el: Improve doc build for the :core packages, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin de2fd22 418/439: * elpa-admin.el (elpaa-read-config): Allow lists of strings, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin e3683d9 426/439: elpa-admin.el: Improve the badge generation code,
Philip Kaludercic <=
- [nongnu] elpa-admin 8e351cc 425/439: * elpa-admin.el (elpaa--string-width): Use `elpaa--call`, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin e850286 428/439: Merge branch 'elpa-admin' of git+ssh://git.sv.gnu.org/srv/git/emacs/elpa into elpa-admin, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin 6b5c39d 423/439: ; * elpa-admin.el (elpaa--html-footer): Fix LibreJS support., Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin 4541ebe 430/439: * elpa-admin.el (elpaa--get-release-revision): Workaround for git bug, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin 1beeffd 433/439: * elpa-admin.el (elpaa--make-one-tarball): Return nil on error!, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin 005c37e 434/439: * README (Configuration (elpa-config)): Document `elpa-config`, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin 97d2765 436/439: * elpa-admin.el (ignore-error): Add backward compatibility definition, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin 9b28c79 432/439: * elpa-admin.el (elpaa--make-one-tarball-1): Return non-nil when built, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin d4c962a 438/439: * elpa-admin.el (elpaa--get-section): Add docstring, rename vars, Philip Kaludercic, 2021/10/17
- [nongnu] elpa-admin 6734638 244/439: Merge commit 'd7bac581f04756582078cd9ea45e5a28406ee05c', Philip Kaludercic, 2021/10/17