mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-20 03:35:51 +00:00
Dactyl - solution for different image paths by target
This commit is contained in:
@@ -29,15 +29,20 @@ targets:
|
||||
- multicode_tabs
|
||||
- standardize_header_ids
|
||||
- buttonize
|
||||
|
||||
- name: ripple.com
|
||||
filters:
|
||||
- multicode_tabs
|
||||
- standardize_header_ids
|
||||
- buttonize
|
||||
|
||||
- name: printable
|
||||
filters:
|
||||
- standardize_header_ids
|
||||
image_subs:
|
||||
"img/funds_flow_diagram.png": https://ripple.com/wp-content/uploads/2016/03/funds_flow_diagram.png
|
||||
"img/e2g-01.png": https://ripple.com/wp-content/themes/ripple-beta/assets/img/e2g-01.png
|
||||
"img/e2g-02.png": https://ripple.com/wp-content/themes/ripple-beta/assets/img/e2g-02.png
|
||||
"img/e2g-03.png": https://ripple.com/wp-content/themes/ripple-beta/assets/img/e2g-03.png
|
||||
"img/ledger-process.png": https://ripple.com/wp-content/themes/ripple-beta/assets/img/ledger-process.png
|
||||
"img/ledger-components.png": https://ripple.com/wp-content/themes/ripple-beta/assets/img/ledger-components.png
|
||||
"img/ledger-indexes.png": https://ripple.com/wp-content/themes/ripple-beta/assets/img/ledger-indexes.png
|
||||
|
||||
- name: rippled-setup
|
||||
filters:
|
||||
@@ -216,8 +221,7 @@ pages:
|
||||
category: Best Practices
|
||||
html: concept-issuing-and-operational-addresses.html
|
||||
md: concept-issuing-and-operational-addresses.md
|
||||
# TODO publish this article separately on the website
|
||||
ripple.com: https://ripple.com/build/gateway-guide/#hot-and-cold-wallets
|
||||
ripple.com: https://ripple.com/knowledge_center/issuing-operational-addresses/
|
||||
sidebar: true
|
||||
targets:
|
||||
- local
|
||||
@@ -283,8 +287,6 @@ ignore_anchors_in:
|
||||
known_broken_links:
|
||||
# Strangely, Python doesn't like the cert here. Firefox is OK with it.
|
||||
- https://validators.ripple.com
|
||||
# Zendesk hasn't updated the cert. See ticket IN-1168
|
||||
- https://support.ripplelabs.com/hc/en-us/categories/200194196-Set-Up-Activation
|
||||
|
||||
# Style Checker Config ------------------------------------------------------ #
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ def load_config(config_file=DEFAULT_CONFIG_FILE):
|
||||
|
||||
def substitute_links_for_target(soup, target):
|
||||
"""Replaces local-html-links with appropriate substitutions
|
||||
for the given target"""
|
||||
for the given target, and images likewise"""
|
||||
target = get_target(target)
|
||||
|
||||
logger.info("... modifying links for target: %s" % target["name"])
|
||||
@@ -92,6 +92,25 @@ def substitute_links_for_target(soup, target):
|
||||
link["href"] = link["href"].replace(local_url,
|
||||
target_url)
|
||||
|
||||
|
||||
if "image_subs" in target:
|
||||
images = soup.find_all("img")
|
||||
for img in images:
|
||||
local_path = img["src"]
|
||||
if local_path in target["image_subs"]:
|
||||
logger.info("... replacing image path '%s' with '%s'" %
|
||||
(local_path, target["image_subs"][local_path]))
|
||||
img["src"] = target["image_subs"][local_path]
|
||||
|
||||
image_links = soup.find_all("a",
|
||||
href=re.compile(r"^[^.]+\.(png|jpg|jpeg|gif|svg)"))
|
||||
for img_link in image_links:
|
||||
local_path = img_link["href"]
|
||||
if local_path in target["image_subs"]:
|
||||
logger.info("... replacing image link '%s' with '%s'" %
|
||||
(local_path, target["image_subs"][local_path]))
|
||||
img_link["href"] = target["image_subs"][local_path]
|
||||
|
||||
def get_target(target):
|
||||
"""Get a target by name, or return the default target object.
|
||||
We can't use default args in function defs because the default is
|
||||
|
||||
Reference in New Issue
Block a user