examples: first shot at description text at top of page. Not working yet.

This commit is contained in:
Ryan C. Gordon 2024-07-30 13:18:37 -04:00
parent b881e19896
commit 69a2d7960c
No known key found for this signature in database
GPG key ID: FA148B892AB48044
2 changed files with 13 additions and 5 deletions

View file

@ -103,16 +103,15 @@ sub handle_example_dir {
my $jsdst = "$dst/$jsfname"; my $jsdst = "$dst/$jsfname";
my $wasmdst = "$dst/$wasmfname"; my $wasmdst = "$dst/$wasmfname";
my $print_description = ''; my $description = '';
if (open(my $readmetxth, '<', "$examples_dir/$category/$example/README.txt")) { if (open(my $readmetxth, '<', "$examples_dir/$category/$example/README.txt")) {
my $spc = ''; my $spc = '';
while (<$readmetxth>) { while (<$readmetxth>) {
chomp; chomp;
s/\"/\\"/g; s/\"/\\"/g;
$print_description .= "${spc}Module.print(\"$_\");"; $description .= "$spc$_";
$spc = ' '; $spc = ' ';
} }
$print_description .= "${spc}Module.print(\"\");";
close($readmetxth); close($readmetxth);
} }
@ -155,7 +154,7 @@ sub handle_example_dir {
s/\@example_name\@/$example/g; s/\@example_name\@/$example/g;
s/\@javascript_file\@/$jsfname/g; s/\@javascript_file\@/$jsfname/g;
s/\@htmlified_source_code\@/$htmlified_source_code/g; s/\@htmlified_source_code\@/$htmlified_source_code/g;
s/\@print_description\@/$print_description/g; s/\@description\@/$description/g;
$html .= $_; $html .= $_;
} }
close($htmltemplate); close($htmltemplate);

View file

@ -133,10 +133,20 @@
height: 100%; height: 100%;
overflow: scroll; overflow: scroll;
} }
#example-description {
background: black;
color: white;
height: 100%;
align-items: center;
}
</style> </style>
<link rel="stylesheet" type="text/css" href="highlight.css"> <link rel="stylesheet" type="text/css" href="highlight.css">
</head> </head>
<body> <body>
<div id="example-description">
@description@
</div>
<div class="canvas-container"> <div class="canvas-container">
<canvas id="canvas" oncontextmenu="event.preventDefault()" tabindex="-1"></canvas> <canvas id="canvas" oncontextmenu="event.preventDefault()" tabindex="-1"></canvas>
</div> </div>
@ -201,7 +211,6 @@
if (text) console.error('[post-exception status] ' + text); if (text) console.error('[post-exception status] ' + text);
}; };
}; };
@print_description@
</script> </script>
<script async type="text/javascript" src="@javascript_file@"></script> <script async type="text/javascript" src="@javascript_file@"></script>
</body> </body>