From 89c0a9e4cfea8c4a80dd8b2a6168f20f9ee290bb Mon Sep 17 00:00:00 2001
From: Eric Knibbe
Date: Fri, 3 May 2024 06:12:01 -0400
Subject: [PATCH] rework setup of cask includes
---
_includes/cask.html | 16 ++++++++++------
_includes/casks.html | 8 ++++----
_layouts/cask.html | 20 +++++++++++---------
_layouts/cask_json.json | 24 +++++++++++-------------
cask_index.html | 8 ++++----
5 files changed, 40 insertions(+), 36 deletions(-)
diff --git a/_includes/cask.html b/_includes/cask.html
index 1c82850308d3..8b8ad1dfbdf3 100644
--- a/_includes/cask.html
+++ b/_includes/cask.html
@@ -1,11 +1,15 @@
-{%- if site.data.cask[include.sort_key] != nil -%}
- {{ include.cask.token | escape }}
+{%- assign include_cdata = site.data.cask[include.data_token] -%}
+{%- if include_cdata != nil -%}
+ {{ include.token | escape }} |
+ {{ include_cdata.version | truncate: 25 | escape }} |
+ {{ include_cdata.desc | escape }} |
+ {{ include_cdata.name.first | escape }}
{%- else -%}
- {{ include.cask.token | escape }}
+ {{ include.token | escape }} |
+ |
+ |
+
{%- endif -%}
|
- {{ include.cask.version | truncate: 25 | escape }} |
- {{ include.cask.desc | escape }} |
- {{ include.cask.name.first | escape }} |
diff --git a/_includes/casks.html b/_includes/casks.html
index c7bba427cbfa..611e43dc111f 100644
--- a/_includes/casks.html
+++ b/_includes/casks.html
@@ -1,10 +1,10 @@
-{%- if include.casks.size > 0 %}
+{%- if include.tokens.size > 0 %}
{{ include.description }}:
- {%- for token in include.casks -%}
+ {%- for include_token in include.tokens -%}
- {%- assign cask = site.data.cask[token] -%}
- {%- include cask.html token=token cask=cask -%}
+ {%- assign include_data_token = include_token | remove: "@" | remove: "." | replace: "+", "_" -%}
+ {%- include cask.html data_token=include_data_token token=include_token -%}
{%- endfor -%}
diff --git a/_layouts/cask.html b/_layouts/cask.html
index 21ab8cc0b52a..f81509a8bd4a 100644
--- a/_layouts/cask.html
+++ b/_layouts/cask.html
@@ -2,9 +2,9 @@
layout: default
permalink: :title
---
-{%- assign full_name = page.title -%}
-{%- assign data_name = full_name | remove: "@" | remove: "." | replace: "+", "_" -%}
-{%- assign c = site.data.cask[data_name] -%}
+{%- assign token = page.title -%}
+{%- assign data_token = token | remove: "@" | remove: "." | replace: "+", "_" -%}
+{%- assign c = site.data.cask[data_token] -%}
{%- if c.depends_on.size > 0 -%}
- {%- include casks.html casks=c.depends_on.cask description="Depends on casks" -%}
+ {%- include casks.html tokens=c.depends_on.cask description="Depends on casks" -%}
{%- include formulae.html formulae=c.depends_on.formula description="Depends on" -%}
{%- assign requirements = "" -%}
{%- if c.depends_on.macos -%}
@@ -61,10 +61,12 @@
{%- endif -%}
{%- endif -%}
-{%- include casks.html casks=c.conflicts_with.cask description="Conflicts with casks" -%}
+{%- if c.conflicts_with.size > 0 -%}
+ {%- include casks.html tokens=c.conflicts_with.cask description="Conflicts with casks" -%}
-{%- assign conflicts_with_formula = c.conflicts_with.formula | where_exp: "f", "site.data.formula[f]" -%}
-{%- include formulae.html formulae=conflicts_with_formula description="Conflicts with" -%}
+ {%- assign conflicts_with_formula = c.conflicts_with.formula | where_exp: "f", "site.data.formula[f]" -%}
+ {%- include formulae.html formulae=conflicts_with_formula description="Conflicts with" -%}
+{%- endif -%}
{%- if c.caveats -%}
{%- capture soft_indent %}
@@ -142,14 +144,14 @@
Installs ({{ interval.name }}) |
- {%- for fa in site.data.analytics.cask-install.homebrew-cask[interval.path].formulae[full_name] -%}
+ {%- for fa in site.data.analytics.cask-install.homebrew-cask[interval.path].formulae[token] -%}
{{ fa.cask | escape }} |
{{ fa.count }} |
{%- else -%}
- {{ full_name | escape }} |
+ {{ token | escape }} |
0 |
{%- endfor -%}
diff --git a/_layouts/cask_json.json b/_layouts/cask_json.json
index df10c049c034..c36e5b0695c9 100644
--- a/_layouts/cask_json.json
+++ b/_layouts/cask_json.json
@@ -1,27 +1,25 @@
---
---
-{%- assign full_name = page.name | remove: ".json" -%}
-{%- assign data_name = full_name | remove: "@" | remove: "." | replace: "+", "_" -%}
-{%- assign cask = site.data.cask[data_name] -%}
+{%- assign token = page.name | remove: ".json" -%}
+{%- assign data_token = token | remove: "@" | remove: "." | replace: "+", "_" -%}
+{%- assign cdata = site.data.cask[data_token] -%}
{
-{%- for key_value in cask -%}
+{%- for key_value in cdata -%}
{{ key_value[0] | jsonify }}:{{ key_value[1] | jsonify }},
{%- endfor -%}
"analytics":{"install":{
{%- for interval in site.analytics.intervals -%}
"{{ interval.path }}":{
- {%- if site.data.analytics.cask-install.homebrew-cask[interval.path].formulae[full_name].size > 0 -%}
- {%- for fa in site.data.analytics.cask-install.homebrew-cask[interval.path].formulae[full_name] -%}
- {{ fa.cask | jsonify }}:{{ fa.count | remove: "," | plus: 0 }}
- {%- unless forloop.last -%}
- ,
- {%- endunless -%}
- {%- endfor -%}
+ {%- for fa in site.data.analytics.cask-install.homebrew-cask[interval.path].formulae[token] -%}
+ {{ fa.cask | jsonify }}:{{ fa.count | remove: "," | plus: 0 }}
+ {%- unless forloop.last -%}
+ ,
+ {%- endunless -%}
{%- else -%}
- {{ full_name | jsonify }}:0
- {%- endif -%}
+ {{ token | jsonify }}:0
+ {%- endfor -%}
}
{%- unless forloop.last -%}
,
diff --git a/cask_index.html b/cask_index.html
index b9f2b5540e36..deaa9095337a 100644
--- a/cask_index.html
+++ b/cask_index.html
@@ -9,11 +9,11 @@
{%- assign sorted_casks = site.data.cask | sort -%}
- {%- for c in sorted_casks -%}
+ {%- for cask in sorted_casks -%}
- {%- assign sort_key = c[0] -%}
- {%- assign cask = c[1] -%}
- {%- include cask.html sort_key=sort_key cask=cask -%}
+ {%- assign data_token = cask[0] -%}
+ {%- assign token = cask[1].token -%}
+ {%- include cask.html data_token=data_token token=token -%}
{%- endfor -%}