Skip to content

Commit 5908608

Browse files
committed
make missing requirements page show those requirements
1 parent 8cf93de commit 5908608

File tree

3 files changed

+71
-9
lines changed

3 files changed

+71
-9
lines changed

_includes/mod-info.json

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Args:
88
{%- endcomment -%}
99

1010
{
11-
{%- assign first = true -%}
11+
{%- assign first_mod = true -%}
1212
{%- for mod in site[include.collection] -%}
1313
{%- if mod.legacy -%}
1414
{%- assign name = mod.title -%}
@@ -17,14 +17,55 @@ Args:
1717
{%- endif -%}
1818

1919
{%- if name -%}
20-
{%- unless first -%}
20+
{%- unless first_mod -%}
2121
,
2222
{%- endunless -%}
23-
{%- assign first = false -%}
23+
{%- assign first_mod = false -%}
2424

2525
{{- name | jsonify -}}:{
2626
{{-""-}} "title": {{- mod.title | decode | jsonify -}},
2727
{{-""-}} "url": {{- mod.url | relative_url | jsonify -}}
28+
29+
{%- assign dependencies = mod.dependencies | default: mod.pyproject.project.dependencies -%}
30+
{%- if dependencies.size > 0 -%}
31+
{{-""-}} ,"dependencies":[
32+
33+
{%- assign first_dep = true -%}
34+
{%- for item in dependencies -%}
35+
{%- unless first_dep -%}
36+
,
37+
{%- endunless -%}
38+
{%- assign first_dep = false -%}
39+
40+
{%- if mod.legacy -%}
41+
{%- assign dep_name = item | regex_match: "^\s*([A-Z0-9][A-Z0-9 ._-]*[A-Z0-9]|[A-Z0-9])" -%}
42+
{%- else -%}
43+
{%- assign dep_name = item | regex_match: "^\s*([A-Z0-9][A-Z0-9._-]*[A-Z0-9]|[A-Z0-9])" -%}
44+
{%- endif -%}
45+
46+
{%- unless dep_name -%}
47+
{%- continue -%}
48+
{%- endunless -%}
49+
50+
{%- assign required_mod_name = dep_name -%}
51+
{%- for inner_mod in site[include.collection] -%}
52+
{%- if inner_mod.legacy -%}
53+
{%- assign iter_mod_name = inner_mod.title -%}
54+
{%- else -%}
55+
{%- assign iter_mod_name = inner_mod.pyproject.project.name -%}
56+
{%- endif -%}
57+
58+
{%- if dep_name == iter_mod_name -%}
59+
{%- assign required_mod_name = iter_mod_name -%}
60+
{%- break -%}
61+
{%- endif -%}
62+
{%- endfor -%}
63+
64+
{{-""-}} {{- required_mod_name | jsonify -}}
65+
{%- endfor -%}
66+
{{-""-}} ]
67+
{%- endif -%}
68+
2869
}
2970
{%- endif -%}
3071
{%- endfor -%}

_layouts/requirements.html

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,20 @@
3838
const info = MOD_INFO[mod_name];
3939
mod_link.textContent = strip_decode_html(info.title);
4040
mod_link.href = info.url;
41+
42+
const dependencies = info?.dependencies?.map((dep) => {
43+
const url = MOD_INFO?.[dep]?.url;
44+
const link = document.createElement(url == undefined ? "span" : "a");
45+
if (url != undefined) {
46+
link.href = url;
47+
}
48+
link.innerText = strip_decode_html(MOD_INFO?.[dep]?.title ?? dep);
49+
50+
const li = document.createElement("li");
51+
li.replaceChildren(link);
52+
return li;
53+
}) ?? [];
54+
document.querySelector("#list").replaceChildren(...dependencies);
4155
}
4256
}
4357
});
@@ -49,9 +63,10 @@ <h1>Missing Requirements</h1>
4963
<p>
5064
<a id="mod" href="{{ "404.html" | relative_url }}">Unknown Mod Name</a> has missing or outdated
5165
requirements.
52-
<br><br>
53-
It requires these other mods to be able to load - visit the mod page and make sure you have the
54-
latest versions of each.
66+
67+
<ul id="list"></ul>
68+
69+
These other mods are required for it to load - make sure you have the latest versions of each.
5570
</p>
5671

5772
{%- assign parent_url = page.url | split: "/" | pop | join: "/" -%}

developing/index.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,11 +197,17 @@ need to touch the db again, changes will be picked up automatically.
197197

198198
There are a few exceptions to this, which are not automatically updated:
199199
- The title used in the sidebar and tab title (the header on the mod page does get updated).
200+
200201
- `project.name`, which is used for matching dependencies to their mod page.
202+
203+
- The dependencies displayed on the missing requirements page.
204+
201205
- The data powering the searchbar.
202-
- The fields which are always displayed will not be set to unknown if you completely delete their
203-
section in your pyproject, the old data is preferred. Requirements and Misc URLs are already
204-
hidden when not in use, so the updates *will* delete them.
206+
207+
- The fields which are always displayed (e.g. Title, Author) will not be set to unknown if you
208+
completely delete their section in your pyproject, the old data is preferred.
209+
210+
Requirements and Misc URLs are already hidden when not in use, so the updates *will* delete them.
205211

206212
If you make significant changes to your pyproject, it may be worth kicking off another build to
207213
update the static versions of these. Do note that this data is updated anytime the site is

0 commit comments

Comments
 (0)