|
| 1 | +// filename: ./src/htmlContentProcessingNew.js |
| 2 | + |
| 3 | +export function gethtmlContentProcessingNew(processing_results, data) { |
| 4 | + // check processing_results and generate the HTML |
| 5 | + // then process the variables via data |
| 6 | + |
| 7 | + html_content = {}; |
| 8 | + |
| 9 | + html_content["header"] = ` |
| 10 | + <!DOCTYPE html> |
| 11 | + <html lang="en"> |
| 12 | + <head> |
| 13 | + <meta charset="utf-8"> |
| 14 | + <title>webfinger.io (a Cloud Security Alliance Research project)</title> |
| 15 | + <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 16 | + <link rel="icon" href="https://assetswebfingerio.pages.dev/favicon.ico"/> |
| 17 | + <link rel="stylesheet" href="https://assetswebfingerio.pages.dev/fonts.googleapis.com-css-family-Roboto-300-300italic-700-700italic.txt"/> |
| 18 | + <link rel="stylesheet" href="https://assetswebfingerio.pages.dev/normalize.css"/> |
| 19 | + <link rel="stylesheet" href="https://assetswebfingerio.pages.dev/milligram.min.css"/> |
| 20 | + <link rel="stylesheet" href="https://assetswebfingerio.pages.dev/main.css"/> |
| 21 | + </head> |
| 22 | + <body> |
| 23 | + <main> |
| 24 | + <section class="container" id="registration"> |
| 25 | + <h3>webfinger.io is a <a href="https://cloudsecurityalliance.org/">Cloud Security Alliance</a> Research project</h3> |
| 26 | + |
| 27 | + ` |
| 28 | + |
| 29 | + html_content["badinput"] = ` |
| 30 | + <p>We cannot process your request at this time, please try again later. |
| 31 | + Please check that your email and Mastodon ID were entered correctly.</p> |
| 32 | + `; |
| 33 | + |
| 34 | + html_content["link_mastodon_id_email"] = ` |
| 35 | + <p>We have processed your request to link MASTODON_ID to EMAIL_ADDRESS, you should check |
| 36 | + for an email shortly, please check your spam folders if it doesn't show up. |
| 37 | + It will be valid for one hour, and then the link expires.</p> |
| 38 | + `; |
| 39 | + |
| 40 | + html_content["link_mastodon_id_social"] = ` |
| 41 | + <p>We have processed your request to link MASTODON_ID to SOCIAL_ID (please wait about 10 seconds and then click to ensure it works, you should see a success and a link to your GitHub profile). </p> |
| 42 | + `; |
| 43 | + |
| 44 | + html_content["block_email"] = ` |
| 45 | + <p>We have processed your request to unsubscribe and block any more email to EMAIL_ADDRESS. |
| 46 | + In order to prevent abuse we've sent an email with a confirmation link, |
| 47 | + please check your spam folders if it doesn't show up. It will be valid |
| 48 | + for one hour, and then the link expires.</p> |
| 49 | + `; |
| 50 | + |
| 51 | + html_content["delete_record"] = ` |
| 52 | + <p>We have processed your request to delete the record for SOCIAL_ID, you should check for |
| 53 | + an email shortly, please check your spam folders if it doesn't show up. It will be valid |
| 54 | + for one hour, and then the link expires.</p> |
| 55 | + `; |
| 56 | + |
| 57 | + html_content["footer"] = ` |
| 58 | + <p>The Cloud Security Alliance privacy policy is available |
| 59 | + <a href="https://cloudsecurityalliance.org/legal/privacy-notice/">here</a>.</p> |
| 60 | + </section> |
| 61 | + |
| 62 | + </body> |
| 63 | + </html> |
| 64 | + `; |
| 65 | + |
| 66 | + |
| 67 | + |
| 68 | + new_content = html_content["header"]; |
| 69 | + |
| 70 | + // Email processing |
| 71 | + |
| 72 | + if (processing_results["email_address"]){ |
| 73 | + if (processing_results["email_address"] == "SUCCESS:LINK_MASTODON_ID") { |
| 74 | + new_content = new_content + html_content["link_mastodon_id_email"]; |
| 75 | + } |
| 76 | + else if (processing_results["email_address"] == "SUCCESS:BLOCK_EMAIL") { |
| 77 | + new_content = new_content + html_content["block_email"]; |
| 78 | + } |
| 79 | + else if (processing_results["email_address"] == "SUCCESS:DELETE_RECORD") { |
| 80 | + new_content = new_content + html_content["delete_record"]; |
| 81 | + } |
| 82 | + // replacements go later since email is special |
| 83 | + } |
| 84 | + |
| 85 | + |
| 86 | + // Twitter processing |
| 87 | + if (processing_results["twitter_id"]){ |
| 88 | + if (processing_results["twitter_id"] == "SUCCESS:LINK_MASTODON_ID") { |
| 89 | + new_content = new_content + html_content["link_mastodon_id_social"]; |
| 90 | + } |
| 91 | + else if (processing_results["twitter_id"] == "SUCCESS:DELETE_RECORD") { |
| 92 | + new_content = new_content + html_content["delete_record"]; |
| 93 | + } |
| 94 | + new_content = new_content.replace(/SOCIAL_ID/g, "<a target=\"_blank\" href=\"https://webfinger.io/@TWITTER_ID\">https://webfinger.io/@TWITTER_ID</a>"); |
| 95 | + } |
| 96 | + |
| 97 | + // GitHub processing |
| 98 | + if (processing_results["github_id"]){ |
| 99 | + if (processing_results["github_id"] == "SUCCESS:LINK_MASTODON_ID") { |
| 100 | + new_content = new_content + html_content["link_mastodon_id_social"]; |
| 101 | + } |
| 102 | + else if (processing_results["github_id"] == "SUCCESS:DELETE_RECORD") { |
| 103 | + new_content = new_content + html_content["delete_record"]; |
| 104 | + } |
| 105 | + new_content = new_content.replace(/SOCIAL_ID/g, "<a target=\"_blank\" href=\"https://webfinger.io/github/GITHUB_ID\">https://webfinger.io/github/GITHUB_ID</a>"); |
| 106 | + } |
| 107 | + |
| 108 | + // Reddit processing |
| 109 | + if (processing_results["reddit_id"]){ |
| 110 | + if (processing_results["reddit_id"] == "SUCCESS:LINK_MASTODON_ID") { |
| 111 | + new_content = new_content + html_content["link_mastodon_id_social"]; |
| 112 | + } |
| 113 | + else if (processing_results["reddit_id"] == "SUCCESS:DELETE_RECORD") { |
| 114 | + new_content = new_content + html_content["delete_record"]; |
| 115 | + } |
| 116 | + new_content = new_content.replace(/SOCIAL_ID/g, "<a target=\"_blank\" href=\"https://webfinger.io/u/REDDIT_ID\">https://webfinger.io/u/REDDIT_ID</a>"); |
| 117 | + } |
| 118 | + |
| 119 | + // Add footer |
| 120 | + new_content = new_content + html_content["footer"]; |
| 121 | + |
| 122 | + // replacements of ID's, tokens, etc. |
| 123 | + if (data["mastodon_id"]) { |
| 124 | + new_content = new_content.replace(/MASTODON_ID/g, data["mastodon_id"]); |
| 125 | + } |
| 126 | + if (data["token"]) { |
| 127 | + new_content = new_content.replace(/TOKEN/g, data["token"]); |
| 128 | + } |
| 129 | + if (data["email_address"]) { |
| 130 | + new_content = new_content.replace(/EMAIL_ADDRESS/g, data["email_address"]); |
| 131 | + } |
| 132 | + if (data["twitter_id"]) { |
| 133 | + new_content = new_content.replace(/TWITTER_ID/g, data["twitter_id"]); |
| 134 | + } |
| 135 | + if (data["github_id"]) { |
| 136 | + new_content = new_content.replace(/GITHUB_ID/g, data["github_id"]); |
| 137 | + } |
| 138 | + if (data["reddit_id"]) { |
| 139 | + new_content = new_content.replace(/REDDIT_ID/g, data["reddit_id"]); |
| 140 | + } |
| 141 | + return new_content; |
| 142 | + |
| 143 | +} |
0 commit comments