From cbe3824c8414008f628c0015175ccab189c2b7f0 Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Wed, 10 Apr 2024 03:51:49 +0100 Subject: [PATCH] layouts: consistent data handling --- _includes/cask.html | 8 ++--- _includes/formula.html | 8 ++--- _includes/install_command.html | 2 +- _layouts/analytics.html | 16 ++++----- _layouts/cask.html | 48 ++++++++++++--------------- _layouts/formula.html | 60 ++++++++++++++++++++-------------- 6 files changed, 73 insertions(+), 69 deletions(-) diff --git a/_includes/cask.html b/_includes/cask.html index 09251ef485ab..6c05a5f4a8ec 100644 --- a/_includes/cask.html +++ b/_includes/cask.html @@ -1,11 +1,11 @@ {%- if site.data.cask[include.token] != nil -%} - {{ include.token }} + {{ include.token | escape }} {%- else -%} {{ include.token }} {%- endif -%} - {{ include.cask.version | truncate: 25 }} - {{ include.cask.desc | xml_escape }} - {{ include.cask.name.first }} + {{ include.cask.version | truncate: 25 | escape }} + {{ include.cask.desc | escape }} + {{ include.cask.name.first | escape }} diff --git a/_includes/formula.html b/_includes/formula.html index f13616278673..0d3a35d43767 100644 --- a/_includes/formula.html +++ b/_includes/formula.html @@ -1,8 +1,8 @@ - {{ include.formula.name }} - {{ include.formula.versions.stable }} - {{ include.formula.desc | xml_escape }} + >{{ include.formula.name | escape }} + {{ include.formula.versions.stable | escape }} + {{ include.formula.desc | escape }} diff --git a/_includes/install_command.html b/_includes/install_command.html index 2e1b6ab36ddd..c833c6f51f90 100644 --- a/_includes/install_command.html +++ b/_includes/install_command.html @@ -2,6 +2,6 @@
Install command:
- {%- highlight bash -%} brew install{{include.modifier}} {{include.item}} {%- endhighlight -%} + {%- highlight bash -%} brew install{{include.modifier}} {{include.item | escape}} {%- endhighlight -%}
diff --git a/_layouts/analytics.html b/_layouts/analytics.html index 614a6dc61f8d..b8aa209e9d5c 100644 --- a/_layouts/analytics.html +++ b/_layouts/analytics.html @@ -40,27 +40,27 @@

Total Events: {{ analytics_data.total_count }}

#{{ item.number }} {%- if page.category == "os-version" -%} - {{ item.os_version }} + {{ item.os_version | escape }} {%- elsif page.category == "homebrew-devcmdrun-developer" -%} - {{ item.devcmdrun_developer }} + {{ item.devcmdrun_developer | escape }} {%- elsif page.category == "homebrew-os-arch-ci" -%} - {{ item.os_arch_ci }} + {{ item.os_arch_ci | escape }} {%- elsif page.category == "homebrew-prefixes" -%} - {{ item.prefix }} + {{ item.prefix | escape }} {%- elsif page.category == "homebrew-versions" -%} - {{ item.version }} + {{ item.version | escape }} {%- elsif page.category == "cask-install" -%} {%- if site.data.cask[item.cask] != nil -%} - {{ item.cask }} + {{ item.cask | escape }} {%- else -%} - {{ item.cask }} + {{ item.cask | escape }} {%- endif -%} {%- else -%} {%- assign full_name = item.formula | split: " " | first -%} {%- assign data_name = full_name | remove: "@" | remove: "." | replace: "+", "_" -%} {%- assign formula = site.data.formula[data_name] -%} {%- if full_name == formula.name -%} - {{ item.formula | escape }} + {{ item.formula | escape }} {%- else -%} {{ item.formula | escape }} {%- endif -%} diff --git a/_layouts/cask.html b/_layouts/cask.html index 570c4ac58554..701e67f67526 100644 --- a/_layouts/cask.html +++ b/_layouts/cask.html @@ -6,11 +6,11 @@ {%- assign formula_path = "formula" -%} {%- assign c = site.data.cask[token] -%}

- {{ token }} + {{ token | escape }} {%- if c.disabled %} (disabled) {%- elsif c.deprecated %} (deprecated) {%- endif -%} @@ -19,19 +19,19 @@ {%- include install_command.html item=token modifier=" --cask" %}

Name{%- if c.name.size > 1 -%}s{%- endif -%}: {%- for name in c.name %} - {{ name }} + {{ name | escape }} {%- unless forloop.last -%}, {% endunless %} {%- endfor -%}

{%- if c.desc %} -

{{ c.desc }}

+

{{ c.desc | escape }}

{%- endif %} -

{{ c.homepage }}

+

{{ c.homepage | escape }}

-

/api/cask/{{ token }}.json (JSON API)

-

Cask code on GitHub

+

/api/cask/{{ token | escape }}.json (JSON API)

+

Cask code on GitHub

-

Current version: {{ c.version }}

+

Current version: {{ c.version | escape }}

{%- if c.depends_on.size > 0 -%} {%- include casks.html casks=c.depends_on.cask description="Depends on casks" -%} @@ -40,7 +40,7 @@ {%- if c.depends_on.macos -%} {%- capture requirements -%} macOS {% for x in c.depends_on.macos -%} - {{ x.first | xml_escape }} {{ c.depends_on.macos[x.first] | join: " / " }} + {{ x.first | escape }} {{ c.depends_on.macos[x.first] | join: " / " }} {%- unless forloop.last %} and {% endunless -%} {%- endfor -%} {%- endcapture -%} @@ -50,20 +50,14 @@ {%- assign requirements = requirements | append: ", " -%} {%- endif -%} {%- capture requirements -%} - {{ requirements }}{% for a in c.depends_on.arch -%} + {{ requirements | escape }}{% for a in c.depends_on.arch -%} {{ a.type | capitalize }} {{ a.bits }}-bit {%- unless forloop.last %} or {% endunless -%} {%- endfor %} architecture {%- endcapture -%} {%- endif -%} - {%- if c.depends_on.x11 -%} - {%- if requirements.size > 0 -%} - {%- assign requirements = requirements | append: ", " -%} - {%- endif -%} - {%- capture requirements -%}{{ requirements }}X11{%- endcapture -%} - {%- endif -%} {%- if requirements.size > 0 %} -

Requires: {{ requirements }}

+

Requires: {{ requirements | escape }}

{%- endif -%} {%- endif -%} @@ -79,7 +73,7 @@     {% endcapture %} - +
{{ c.caveats | xml_escape | replace: soft_indent, hard_indent | strip | newline_to_br }}{{ c.caveats | escape | replace: soft_indent, hard_indent | strip | newline_to_br }}
{%- endif %} @@ -110,9 +104,9 @@ {%- assign subsequent = true -%} - - {{ variation[1].version | default: c.version }} + + {{ variation[1].version | default: c.version | escape }} @@ -131,9 +125,9 @@ {%- assign subsequent = true -%} - - {{ variation[1].version | default: c.version }} + + {{ variation[1].version | default: c.version | escape }} @@ -150,12 +144,12 @@ {%- for fa in site.data.analytics.cask-install.homebrew-cask[interval.path].formulae[token] -%} - {{ fa.cask }} + {{ fa.cask | escape }} {{ fa.count }} {%- else -%} - {{ token }} + {{ token | escape }} 0 {%- endfor -%} diff --git a/_layouts/formula.html b/_layouts/formula.html index 88d0f70eb953..25fa694f35c7 100644 --- a/_layouts/formula.html +++ b/_layouts/formula.html @@ -7,11 +7,11 @@ {%- assign data_name = full_name | remove: "@" | remove: "." | replace: "+", "_" -%} {%- assign f = site.data[formula_path][data_name] -%}

- {{ f.name }} + {{ f.name | escape }} {%- if f.disabled %} (disabled) {%- elsif f.deprecated %} (deprecated) {%- endif -%} @@ -19,20 +19,30 @@ {%- include install_command.html item=f.name %} {%- if f.aliases.size > 0 %} -

Also known as: {{ f.aliases | join: ", " }}

+

Also known as: + {%- for alias in f.aliases -%} + {{ alias | escape }} + {%- unless forloop.last -%}, {% endunless -%} + {%- endfor %} +

{%- endif -%} {%- if f.oldname %} -

Formerly known as: {{ f.oldname }}

+

Formerly known as: {{ f.oldname | escape }}

{%- endif %} -

{{ f.desc | xml_escape }}

-

{{ f.homepage }}

+

{{ f.desc | escape }}

+

{{ f.homepage | escape }}

{%- if f.license.size > 0 %} -

License: {{ f.license | join: ", " | replace: "_", " " }}

+

License: + {%- for license in f.license -%} + {{ license | replace: "_", " " | escape }} + {%- unless forloop.last -%}, {% endunless -%} + {%- endfor %} +

{%- endif %} -

Formula JSON API: /api/{{ formula_path }}/{{ f.name }}.json

+

Formula JSON API: /api/{{ formula_path }}/{{ f.name | escape }}.json

-

Formula code: {{ f.name }}.rb on GitHub

+

Formula code: {{ f.name | escape }}.rb on GitHub

Bottle (binary package) {%- assign bottles = false -%} @@ -95,13 +105,13 @@ stable ✅ - {{ f.versions.stable }} + {{ f.versions.stable | escape }} {%- if f.versions.head %} head ⚡️ - {{ f.versions.head }} + {{ f.versions.head | escape }} {%- endif %} @@ -121,8 +131,8 @@ {%- for o in f.options -%} - - + + {%- endfor %}
{{ o.option }}{{ o.description }}{{ o.option | escape }}{{ o.description | escape }}
@@ -140,34 +150,34 @@ {%- capture requirement -%} {%- case r.name -%} {%- when "arch" -%} - {{ r.version }} + {{ r.version | escape }} {%- when "macos" or "maximum_macos" -%} macOS {%- when "osxfuse" -%} FUSE {%- else -%} - {{ r.name | capitalize }} + {{ r.name | capitalize | escape }} {%- endcase -%} {%- endcapture -%} {%- if r.cask and formula_path == "formula" -%} {%- unless r.cask contains "/" -%} - {{ requirement }} + {{ requirement | escape }} {%- else -%} - {{ requirement }} + {{ requirement | escape }} {%- endunless -%} {%- else -%} - {{ requirement }} + {{ requirement | escape }} {%- endif -%} {%- if r.version -%} {%- if r.name == "arch" %} architecture - {%- elsif r.name contains "maximum" %} <= {{ r.version }} - {%- else %} >= {{ r.version }} + {%- elsif r.name contains "maximum" %} <= {{ r.version | escape }} + {%- else %} >= {{ r.version | escape }} {%- endif -%} {%- endif -%} {%- for c in r.contexts -%} {%- if forloop.first %} ( {%- endif -%} - {{ c }} + {{ c | escape }} {%- unless forloop.last -%}, {% endunless -%} {%- if forloop.last -%} ) {%- endif -%} {%- endfor -%} @@ -179,7 +189,7 @@ {%- if f.conflicts_with.size > 0 %}

Conflicts with: {%- for c in f.conflicts_with %} - {{ c }} + {{ c | escape }} {%- unless forloop.last -%}, {% endunless -%} {%- endfor %}

@@ -192,7 +202,7 @@     {% endcapture %} - +
{{ f.caveats | xml_escape | replace: soft_indent, hard_indent | strip | newline_to_br }}{{ f.caveats | escape | replace: soft_indent, hard_indent | strip | newline_to_br }}
{%- endif -%} @@ -214,7 +224,7 @@ {%- else -%} - {{ full_name }} + {{ full_name | escape }} 0 {%- endfor -%}