Skip to content

Commit

Permalink
Fixing arc links for devportal
Browse files Browse the repository at this point in the history
  • Loading branch information
SudoWeezy committed Oct 2, 2024
1 parent 3041a22 commit a8446b6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
4 changes: 4 additions & 0 deletions _devportal/scripts/index_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ Welcome to the Algorand ARCs (Algorand Request for Comments) page. Here you'll f
number. If the idea is pursued at a later date it is considered a new
proposal.
</li>
<li>
<strong>Deprecated</strong> - This ARC has been deprecated.
It has been replaced by another one or is now obsolete.
</li>
<li>
<strong>Living</strong> - A special status for ARCs that are designed to be
continually updated and not reach a state of finality.
Expand Down
8 changes: 4 additions & 4 deletions _devportal/scripts/update-arcs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ for file in arc-*.md; do
continue
fi

# 2. Replace links like [ARC-1](./arc-0001.md) with [ARC-1](/standards/arcs/arc-0001)
sed -i $SED_INLINE -E 's|\(\./arc-([0-9]{4})\.md\)|(/standards/arcs/arc-\1)|g' "$file"
# 2. Replace links like [ARC-1](./arc-0001.md) or [ARC-1](arc-0001.md) with [ARC-1](/standards/arcs/arc-0001)
sed -i $SED_INLINE -E 's|\(\.?/arc-([0-9]{4})\.md\)|(/standards/arcs/arc-\1)|g' "$file"
if [[ $? -ne 0 ]]; then
echo "Failed to update links in $file"
continue
Expand All @@ -65,8 +65,8 @@ for file in arc-*.md; do
continue
fi

# 3a. Handle anchors like [ARC-1](./arc-0001.md#interface-signtxnsopts) -> [ARC-1](/standards/arcs/arc-0001#interface-signtxnsopts)
sed -i $SED_INLINE -E 's|\(\./arc-([0-9]{4})\.md(\#[a-zA-Z0-9_-]+)?\)|(/standards/arcs/arc-\1\2)|g' "$file"
# 3a. Handle anchors like [ARC-1](./arc-0001.md#interface-signtxnsopts) or [ARC-1](arc-0001.md#interface-signtxnsopts)
sed -i $SED_INLINE -E 's|\(\.?/arc-([0-9]{4})\.md(\#[a-zA-Z0-9_-]+)?\)|(/standards/arcs/arc-\1\2)|g' "$file"
if [[ $? -ne 0 ]]; then
echo "Failed to update anchored links in $file"
continue
Expand Down
22 changes: 14 additions & 8 deletions _devportal/scripts/update-index.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
# Exit if any command fails
set -e


# Define directories and files
SRC_DIR="_devportal/content"
TEMPLATE_FILE="_devportal/scripts/index_template.md"
Expand Down Expand Up @@ -38,11 +37,14 @@ for file in "$SRC_DIR"/arc-*.md; do
description=$(extract_field "$file" "description")
status=$(extract_field "$file" "status")

# Prepare the formatted output for each ARC in an HTML row
# Format the ARC number to be 4 digits only for the href
arc_href=$(printf "%04d" "$arc")

# Prepare the formatted output for each ARC in an HTML row, adding / to hrefs and keeping ARC number as-is elsewhere
arc_output="<tr>
<td><a href=\"/standards/arcs/$arc\" style='display: block; text-decoration: none; color: inherit;'>$arc</a></td>
<td><a href=\"/standards/arcs/$arc\" style='display: block; text-decoration: none; color: inherit;'>$title</a></td>
<td><a href=\"/standards/arcs/$arc\" style='display: block; text-decoration: none; color: inherit;'>$description</a></td>
<td><a href=\"/standards/arcs/$arc_href/\" style='display: block; text-decoration: none; color: inherit;'>$arc</a></td>
<td><a href=\"/standards/arcs/$arc_href/\" style='display: block; text-decoration: none; color: inherit;'>$title</a></td>
<td><a href=\"/standards/arcs/$arc_href/\" style='display: block; text-decoration: none; color: inherit;'>$description</a></td>
</tr>"

# Group the ARCs by status
Expand All @@ -62,9 +64,12 @@ for file in "$SRC_DIR"/arc-*.md; do
"Draft")
draft_arcs+=("$arc_output")
;;
"Stagnant")
stagnant_arcs+=("$arc_output")
;;
"Stagnant")
stagnant_arcs+=("$arc_output")
;;
"Deprecated")
deprecated_arcs+=("$arc_output")
;;
"Review")
review_arcs+=("$arc_output")
;;
Expand Down Expand Up @@ -114,6 +119,7 @@ sed '/<ArcsList>/,$d' "$TEMPLATE_FILE" > "$OUTPUT_FILE"
generate_arcs_table "Final Arcs" "${final_arcs[@]}"
generate_arcs_table "Last Call Arcs" "${last_call_arcs[@]}"
generate_arcs_table "Withdrawn Arcs" "${withdrawn_arcs[@]}"
generate_arcs_table "Deprecated Arcs" "${deprecated_arcs[@]}"
generate_arcs_table "Draft Arcs" "${draft_arcs[@]}"
generate_arcs_table "Stagnant Arcs" "${stagnant_arcs[@]}"
generate_arcs_table "Review Arcs" "${review_arcs[@]}"
Expand Down

0 comments on commit a8446b6

Please sign in to comment.