1use atomic_lti::dynamic_registration::platform_configuration::PlatformConfiguration;
2
3pub fn build_html(head: &str, body: &str) -> String {
4 format!(
5 r#"
6 <!DOCTYPE html>
7 <html lang="en">
8 <head>
9 <style>
10 .hidden {{ display: none !important; }}
11 </style>
12 <link href="https://fonts.googleapis.com/icon?family=Material+Icons+Outlined" rel="stylesheet">
13 <link rel="stylesheet" type="text/css" href="/assets/styles.css" />
14 {head}
15 </head>
16 <body>
17 <noscript>
18 <div class="u-flex">
19 <i class="material-icons-outlined aj-icon" aria-hidden="true">warning</i>
20 <p class="aj-text">
21 You must have javascript enabled to use this application.
22 </p>
23 </div>
24 </noscript>
25 {body}
26 </body>
27 </html>
28 "#,
29 )
30}
31
32pub fn dynamic_registration_init_html(
33 platform_config: &PlatformConfiguration,
34 registration_finish_path: &str,
35 registration_token: &str,
36) -> String {
37 let head = "";
38 let body = format!(
39 r#"
40 <h1>Register</h1>
41 <form action="{registration_finish_path}" method="post">
42 <input type="hidden" name="registration_endpoint" value="{registration_endpoint}" />
43 <input type="hidden" name="registration_token" value="{registration_token}" />
44 <input type="hidden" name="product_family_code" value="{product_family_code}" />
45 <input type="submit" value="Finish Registration" />
46 </form>
47 "#,
48 registration_finish_path = registration_finish_path,
49 registration_endpoint = platform_config.registration_endpoint,
50 registration_token = registration_token,
51 product_family_code = platform_config
52 .lti_platform_configuration
53 .product_family_code,
54 );
55 build_html(head, &body)
56}
57
58pub fn dynamic_registration_complete_html() -> String {
59 let head = "";
60 let body = r#"
61 <h1>Registration complete</h1>
62 <script type="text/javascript">
63 (window.opener || window.parent).postMessage({subject:"org.imsglobal.lti.close"}, "*");
64 </script>
65 "#
66 .to_string();
67 build_html(head, &body)
68}