Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] support/scripts/pkg-stats: add linebreak opportunity in CPE ID
@ 2022-08-03 15:33 Sen Hastings
  2022-08-03 16:20 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 2+ messages in thread
From: Sen Hastings @ 2022-08-03 15:33 UTC (permalink / raw)
  To: buildroot; +Cc: Sen Hastings

This adds an optional linebreak at the vendor attribute in the CPE ID.

It should be noted this is purely for formatting/layout purposes
and does not actually insert any additional characters
(newline or otherwise) into the rendered text.

This means that even though the text renders across two lines,
copy-pasting will still yield one line of text.

example: https://sen-h.github.io/pkg-stats/c245575.html

see also: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/wbr

Signed-off-by: Sen Hastings <sen@phobosdpl.com>
---
 support/scripts/pkg-stats | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index 91d42206ca..d32abd7225 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -1102,7 +1102,9 @@ def dump_html_pkg(f, pkg):
         div_class.append("cpe-unknown")
     f.write(f'  <div id=\"{data_field_id}\" class=\"{" ".join(div_class)}\">\n')
     if pkg.cpeid:
-        f.write("  <code>%s</code>\n" % pkg.cpeid)
+        cpeid_begin = ":".join(pkg.cpeid.split(":")[0:4]) + ":"
+        cpeid_formatted = pkg.cpeid.replace(cpeid_begin, cpeid_begin + "<wbr>")
+        f.write("  <code>%s</code>\n" % cpeid_formatted)
     if not pkg.is_status_ok("cpe"):
         if pkg.is_actual_package and pkg.current_version:
             if pkg.cpeid:
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Buildroot] [PATCH 1/1] support/scripts/pkg-stats: add linebreak opportunity in CPE ID
  2022-08-03 15:33 [Buildroot] [PATCH 1/1] support/scripts/pkg-stats: add linebreak opportunity in CPE ID Sen Hastings
@ 2022-08-03 16:20 ` Thomas Petazzoni via buildroot
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni via buildroot @ 2022-08-03 16:20 UTC (permalink / raw)
  To: Sen Hastings; +Cc: buildroot

On Wed,  3 Aug 2022 10:33:24 -0500
Sen Hastings <sen@phobosdpl.com> wrote:

> This adds an optional linebreak at the vendor attribute in the CPE ID.
> 
> It should be noted this is purely for formatting/layout purposes
> and does not actually insert any additional characters
> (newline or otherwise) into the rendered text.
> 
> This means that even though the text renders across two lines,
> copy-pasting will still yield one line of text.
> 
> example: https://sen-h.github.io/pkg-stats/c245575.html
> 
> see also: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/wbr
> 
> Signed-off-by: Sen Hastings <sen@phobosdpl.com>
> ---
>  support/scripts/pkg-stats | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Applied to master, thanks.

I had initially thought we would add a <wbr> at every : separator in
the CPE ID. Your choice to add only one after the 4th field makes the
code slightly more complex, but probably avoids wrapping occurring at
too many different locations. So I've applied as-is, we can always
revisit/improve if needed later.

Thanks a lot!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-08-03 16:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-03 15:33 [Buildroot] [PATCH 1/1] support/scripts/pkg-stats: add linebreak opportunity in CPE ID Sen Hastings
2022-08-03 16:20 ` Thomas Petazzoni via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox