diff --git a/Q-Apps.md b/Q-Apps.md index eaca2e5c..2accbb4d 100644 --- a/Q-Apps.md +++ b/Q-Apps.md @@ -77,6 +77,7 @@ Here is a list of currently supported actions: - FETCH_BLOCK_RANGE - SEARCH_TRANSACTIONS - GET_PRICE +- GET_QDN_RESOURCE_URL - LINK_TO_QDN_RESOURCE More functionality will be added in the future. @@ -404,6 +405,36 @@ let res = await qortalRequest({ }); ``` +### Get URL to load a QDN resource +``` +let url = await qortalRequest({ + action: "GET_QDN_RESOURCE_URL", + service: "THUMBNAIL", + name: "QortalDemo", + identifier: "qortal_avatar" + // path: "filename.jpg" // optional - not needed if resource contains only one file +}); +``` + +### Get URL to load a QDN website +``` +let url = await qortalRequest({ + action: "GET_QDN_RESOURCE_URL", + service: "WEBSITE", + name: "QortalDemo", +}); +``` + +### Get URL to load a specific file from a QDN website +``` +let url = await qortalRequest({ + action: "GET_QDN_RESOURCE_URL", + service: "WEBSITE", + name: "AlphaX", + path: "/assets/img/logo.png" +}); +``` + ### Link/redirect to another QDN website Note: an alternate method is to include `link text` within your HTML code. ``` diff --git a/src/main/resources/q-apps/q-apps.js b/src/main/resources/q-apps/q-apps.js index 5e2b1b31..4e73931f 100644 --- a/src/main/resources/q-apps/q-apps.js +++ b/src/main/resources/q-apps/q-apps.js @@ -134,6 +134,10 @@ window.addEventListener("message", (event) => { response = httpGet("/names/" + data.name); break; + case "GET_QDN_RESOURCE_URL": + response = buildResourceUrl(data.service, data.name, data.identifier, data.path); + break; + case "LINK_TO_QDN_RESOURCE": if (data.service == null) data.service = "WEBSITE"; // Default to WEBSITE window.location = buildResourceUrl(data.service, data.name, data.identifier, data.path);