Skip to content

Commit

Permalink
Merge pull request #336 from shubham251972/shubham251972-fix-csvtable
Browse files Browse the repository at this point in the history
Fix permission table having extra column
  • Loading branch information
dragon-slayer875 authored Jul 27, 2024
2 parents b2f9d3f + 57cb618 commit fa0e957
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 111 deletions.
35 changes: 20 additions & 15 deletions layouts/shortcodes/csvtable.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{ $data := "" }}

{{ $p := "static/data/csv/keys.csv" }}
{{ $excludedColumns := slice 0 10 11 12 13 14 15 16 17 18 }}
{{ $excludedColumns := slice "Category" "Keychain ID" "Key ID" "Inserted" "Local Provider" }} <!-- Add the names of the columns to exclude -->

{{ if os.FileExists $p }}
{{ $opts := dict "delimiter" "," }}
Expand All @@ -10,9 +10,14 @@
{{ errorf "Unable to get resource %q" $p }}
{{ end }}


{{ if $data }}
{{ $uniqueCategories := slice }}
{{ $header := index $data 1 }}
{{ $headerMap := dict }}

{{ range $i, $col := $header }}
{{ $headerMap = merge $headerMap (dict $col $i) }}
{{ end }}

{{ range $i, $row := $data }}
{{ if gt $i 1 }}
Expand All @@ -28,28 +33,28 @@ <h2>{{ $category }} Permissions</h2>
<table class="csvtable td-initial">
<thead>
<tr>
{{ range $i, $col := index $data 1 }}
{{ if and (not (in $excludedColumns $i)) (or (eq $i 0) (ne $i 1) (ne $i 2)) }}
{{ if and (eq $i 1) }}
<th>Permission</th>
{{ else }}
{{ if and (eq $i 2) }}
<th>Description</th>
{{ else }}
<th>{{ $col }}</th>
{{ end }}{{ end }}
{{ range $i, $col := $header }}
{{ if not (in $excludedColumns $col) }}
{{ if eq $col "Function" }}
<th>Permission</th>
{{ else if eq $col "Feature" }}
<th>Description</th>
{{ else }}
<th>{{ $col }}</th>
{{ end }}
{{ end }}
{{ end }}
</tr>
</thead>
<tbody>
{{ range $i, $row := $data }}
{{ if and (gt $i 0) (eq (trim (index $row 0) " ") $category) }}
{{ if and (gt $i 1) (eq (trim (index $row 0) " ") $category) }}
<tr>
{{ range $j, $cell := $row }}
{{ if and (not (in $excludedColumns $j)) (or (gt $j 2) (lt $j 10)) }}
{{ $col := index $header $j }}
{{ if not (in $excludedColumns $col) }}
<td>
{{ if and (gt $j 2) (lt $j 10) }}
{{ if and (gt $j 2) (lt $j 10) }}
{{ if eq $cell "X" }}
{{ else if eq $cell "X*" }}
Expand Down
Loading

0 comments on commit fa0e957

Please sign in to comment.