Skip to content

Commit 245e268

Browse files
authored
Adding implicit ACL categories to be displayed on website (#258)
### Description Currently implicit categories aren't shown on the website. This pr parses the command flags and adds the implicit categories based on this Example images ![image](https://github.com/user-attachments/assets/26c29d51-4259-41bc-ab0f-61e03702c43d) ![image](https://github.com/user-attachments/assets/8fa6cfe2-a257-48bb-ac8c-ced4b1c1b7f1) ![image](https://github.com/user-attachments/assets/70284ade-63dc-401e-b332-d1847ddc305b) If more screenshots are needed I can add to display all categories. ### Issues Resolved This will fully finish valkey-io/valkey-doc#272 (comment) ### Check List - [x] Commits are signed per the DCO using `--signoff` By submitting this pull request, I confirm that my contribution is made under the terms of the BSD-3-Clause License. Signed-off-by: zackcam <[email protected]>
1 parent 68ce25c commit 245e268

File tree

1 file changed

+46
-4
lines changed

1 file changed

+46
-4
lines changed

templates/command-page.html

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,54 @@
7878
<dd>{{ command_data_obj.since }}</dd>
7979
<dl>
8080
{% endif %}
81-
{% if command_data_obj.acl_categories %}
81+
{% if command_data_obj.acl_categories or command_data_obj.command_flags %}
8282
<dl>
8383
<dt>ACL Categories:</dt>
84-
<dd>
85-
{% for category in command_data_obj.acl_categories %}
86-
@{{ category|lower }}{% if not loop.last %}, {% endif %}
84+
<dd>
85+
{% set all_categories = [] %}
86+
87+
{% if command_data_obj.acl_categories %}
88+
{% set all_categories = command_data_obj.acl_categories %}
89+
{% endif %}
90+
91+
{% if command_data_obj.command_flags %}
92+
{# Command flag WRITE implies ACL category WRITE #}
93+
{% if "WRITE" in command_data_obj.command_flags %}
94+
{% set all_categories = all_categories | concat(with="WRITE") %}
95+
{% endif %}
96+
97+
{# Command flag READONLY and not ACL category SCRIPTING implies ACL category READ #}
98+
{% if "READONLY" in command_data_obj.command_flags and (not command_data_obj.acl_categories or not "SCRIPTING" in command_data_obj.acl_categories) %}
99+
{% set all_categories = all_categories | concat(with="READ") %}
100+
{% endif %}
101+
102+
{# Command flag ADMIN implies ACL categories ADMIN and DANGEROUS #}
103+
{% if "ADMIN" in command_data_obj.command_flags %}
104+
{% set all_categories = all_categories | concat(with="ADMIN") | concat(with="DANGEROUS") %}
105+
{% endif %}
106+
107+
{% if "FAST" in command_data_obj.command_flags %}
108+
{% set all_categories = all_categories | concat(with="FAST") %}
109+
{% endif %}
110+
111+
{# Command flag PUBSUB implies ACL category PUBSUB #}
112+
{% if "PUBSUB" in command_data_obj.command_flags %}
113+
{% set all_categories = all_categories | concat(with="PUBSUB") %}
114+
{% endif %}
115+
116+
{# Command flag BLOCKING implies ACL category BLOCKING #}
117+
{% if "BLOCKING" in command_data_obj.command_flags %}
118+
{% set all_categories = all_categories | concat(with="BLOCKING") %}
119+
{% endif %}
120+
{% endif %}
121+
122+
{# Not ACL category FAST implies ACL category SLOW. "If it's not fast, it's slow." #}
123+
{% if "FAST" not in all_categories %}
124+
{% set all_categories = all_categories | concat(with="SLOW") %}
125+
{% endif %}
126+
127+
{% for category in all_categories %}
128+
@{{ category|lower }}{% if not loop.last %}, {% endif %}
87129
{% endfor %}
88130
</dd>
89131
<dl>

0 commit comments

Comments
 (0)