| | @@ -83,10 +83,15 @@ |
| 83 | 83 | /* |
| 84 | 84 | ** Ad-unit styles. |
| 85 | 85 | */ |
| 86 | 86 | static unsigned adUnitFlags = 0; |
| 87 | 87 | |
| 88 | +/* |
| 89 | +** Page data JSON |
| 90 | +*/ |
| 91 | +static Blob pageDataJson = BLOB_INITIALIZER; |
| 92 | + |
| 88 | 93 | |
| 89 | 94 | /* |
| 90 | 95 | ** List of hyperlinks and forms that need to be resolved by javascript in |
| 91 | 96 | ** the footer. |
| 92 | 97 | */ |
| | @@ -192,10 +197,23 @@ |
| 192 | 197 | aFormAction[nFormAction++] = zLink; |
| 193 | 198 | n = nFormAction; |
| 194 | 199 | @ <form id="form%d(n)" method="POST" action='%R/login' %s(zOtherArgs)> |
| 195 | 200 | } |
| 196 | 201 | } |
| 202 | + |
| 203 | +/* |
| 204 | +** Append page-data JSON |
| 205 | +*/ |
| 206 | +void style_pagedata_appendf(const char *zFormat, ...){ |
| 207 | + va_list ap; |
| 208 | + if( blob_size(&pageDataJson)==0 ){ |
| 209 | + blob_append(&pageDataJson, "[", 1); |
| 210 | + } |
| 211 | + va_start(ap, zFormat); |
| 212 | + blob_vappendf(&pageDataJson, zFormat, ap); |
| 213 | + va_end(ap); |
| 214 | +} |
| 197 | 215 | |
| 198 | 216 | /* |
| 199 | 217 | ** Generate javascript that will set the href= attribute on all anchors. |
| 200 | 218 | */ |
| 201 | 219 | void style_resolve_href(void){ |
| | @@ -423,15 +441,17 @@ |
| 423 | 441 | */ |
| 424 | 442 | static char zDfltHeader[] = |
| 425 | 443 | @ <html> |
| 426 | 444 | @ <head> |
| 427 | 445 | @ <base href="$baseurl/$current_page" /> |
| 446 | +@ <meta http-equiv="Content-Security-Policy-xxx" \ |
| 447 | +@ content="default-src 'self' 'unsafe-inline'" /> |
| 428 | 448 | @ <title>$<project_name>: $<title></title> |
| 429 | | -@ <link rel="alternate" type="application/rss+xml" title="RSS Feed" |
| 430 | | -@ href="$home/timeline.rss" /> |
| 431 | | -@ <link rel="stylesheet" href="$stylesheet_url" type="text/css" |
| 432 | | -@ media="screen" /> |
| 449 | +@ <link rel="alternate" type="application/rss+xml" title="RSS Feed" \ |
| 450 | +@ href="$home/timeline.rss" /> |
| 451 | +@ <link rel="stylesheet" href="$stylesheet_url" type="text/css" \ |
| 452 | +@ media="screen" /> |
| 433 | 453 | @ </head> |
| 434 | 454 | @ <body> |
| 435 | 455 | ; |
| 436 | 456 | |
| 437 | 457 | /* |
| | @@ -724,11 +744,18 @@ |
| 724 | 744 | cgi_append_content("</span>\n", -1); |
| 725 | 745 | } |
| 726 | 746 | |
| 727 | 747 | /* Add document end mark if it was not in the footer */ |
| 728 | 748 | if( sqlite3_strlike("%</body>%", zFooter, 0)!=0 ){ |
| 729 | | - @ </body></html> |
| 749 | + style_pagedata_appendf("{'op':'no-op'}]"); |
| 750 | + @ <script type='application/json' id='page-data'> |
| 751 | + @ %s(blob_str(&pageDataJson)) |
| 752 | + @ </script> |
| 753 | + @ <script src='%s(g.zBaseURL)/main.js' type='application/javascript'>\ |
| 754 | + @ <script> |
| 755 | + @ </body> |
| 756 | + @ </html> |
| 730 | 757 | } |
| 731 | 758 | } |
| 732 | 759 | |
| 733 | 760 | /* |
| 734 | 761 | ** Begin a side-box on the right-hand side of a page. The title and |
| | @@ -858,10 +885,23 @@ |
| 858 | 885 | Th_Render(blob_str(&css)); |
| 859 | 886 | |
| 860 | 887 | /* Tell CGI that the content returned by this page is considered cacheable */ |
| 861 | 888 | g.isConst = 1; |
| 862 | 889 | } |
| 890 | + |
| 891 | +/* |
| 892 | +** WEBPAGE: main.js |
| 893 | +** |
| 894 | +** Return the javascript |
| 895 | +*/ |
| 896 | +void page_main_js(void){ |
| 897 | + Blob mainjs; |
| 898 | + cgi_set_content_type("application/javascript"); |
| 899 | + blob_init(&mainjs, builtin_text("main.js"), -1); |
| 900 | + cgi_set_content(&mainjs); |
| 901 | +} |
| 902 | + |
| 863 | 903 | |
| 864 | 904 | /* |
| 865 | 905 | ** WEBPAGE: test_env |
| 866 | 906 | ** |
| 867 | 907 | ** Display CGI-variables and other aspects of the run-time |
| 868 | 908 | |