mirror of
https://github.com/ganelson/inform.git
synced 2024-05-04 01:59:41 +03:00
Merge pull request #87 from DavidKinder/master
Change inblorb and inrtps to generate HTML using per-platform CSS, for dark mode compatibility
This commit is contained in:
commit
b8f9931b58
|
@ -227,6 +227,11 @@ void Main::print_report(void) {
|
|||
if (status_template) Websites::web_copy(status_template, status_file);
|
||||
}
|
||||
|
||||
void Main::read_css_line(text_stream *line, text_file_position *tfp, void *X) {
|
||||
text_stream *str = (text_stream *) X;
|
||||
WRITE_TO(str, "%S\n", line);
|
||||
}
|
||||
|
||||
@ If it isn't apparent what these placeholders do, take a look at
|
||||
the template file called |CblorbModel.html| in the Inform application --
|
||||
that's where they're used.
|
||||
|
@ -234,6 +239,7 @@ that's where they're used.
|
|||
@<Set a whole pile of placeholders which will be needed to generate the status page@> =
|
||||
if (error_count > 0) {
|
||||
Placeholders::set_to(I"CBLORBSTATUS", I"Failed", 0);
|
||||
Placeholders::set_to(I"CBLORBSTATUSLOW", I"failed", 0);
|
||||
Placeholders::set_to(I"CBLORBSTATUSIMAGE", I"inform:/outcome_images/cblorb_failed.png", 0);
|
||||
Placeholders::set_to(I"CBLORBSTATUSTEXT",
|
||||
Str::literal(L"Inform translated your source text as usual, to manufacture a 'story "
|
||||
|
@ -243,6 +249,7 @@ that's where they're used.
|
|||
} else {
|
||||
Placeholders::set_to(I"CBLORBERRORS", I"No problems occurred", 0);
|
||||
Placeholders::set_to(I"CBLORBSTATUS", I"Succeeded", 0);
|
||||
Placeholders::set_to(I"CBLORBSTATUSLOW", I"succeeded", 0);
|
||||
Placeholders::set_to(I"CBLORBSTATUSIMAGE", I"file://[SMALLCOVER]", 0);
|
||||
Placeholders::set_to(I"CBLORBSTATUSTEXT",
|
||||
Str::literal(L"All went well. I've put the released material into the 'Release' subfolder "
|
||||
|
@ -269,3 +276,19 @@ that's where they're used.
|
|||
Placeholders::set_to_number(I"BLORBFILEDATAFILES", 0);
|
||||
PRINT("! Completed: no blorb output requested\n");
|
||||
}
|
||||
if (status_template) {
|
||||
filename *css_filename = NULL;
|
||||
pathname *css_path = Filenames::up(status_template);
|
||||
TEMPORARY_TEXT(platform_variation)
|
||||
WRITE_TO(platform_variation, "%s-platform.css", PLATFORM_STRING);
|
||||
css_filename = Filenames::in(css_path, platform_variation);
|
||||
if (TextFiles::exists(css_filename) == FALSE) {
|
||||
css_filename = Filenames::in(css_path, I"platform.css");
|
||||
}
|
||||
if (TextFiles::exists(css_filename)) {
|
||||
TEMPORARY_TEXT(css)
|
||||
TextFiles::read(css_filename, FALSE, "can't open css file",
|
||||
TRUE, Main::read_css_line, NULL, css);
|
||||
Placeholders::set_to(I"PLATFORMCSS", css, 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
[PLATFORMCSS]
|
||||
-->
|
||||
</style>
|
||||
<style type="text/css">
|
||||
<!--
|
||||
*, *:before, *:after {
|
||||
|
@ -7,42 +12,24 @@
|
|||
-webkit-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.headingboxFailed {
|
||||
.headingpanellayout {
|
||||
position: relative;
|
||||
height: 56px;
|
||||
padding: 0px;
|
||||
white-space:nowrap;
|
||||
background: #f69Ca6; /* red */
|
||||
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
.headingboxSucceeded {
|
||||
position: relative;
|
||||
height: 56px;
|
||||
padding: 0px;
|
||||
white-space:nowrap;
|
||||
background: #E6FFE6; /* green */
|
||||
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
.headingtext {
|
||||
position: absolute;
|
||||
top: -4px;
|
||||
left: -1px;
|
||||
width: 100%;
|
||||
color: #000000;
|
||||
padding: 14px 10px 0px 10px;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.headingrubric {
|
||||
position: absolute;
|
||||
top: 36px;
|
||||
width: 100%;
|
||||
color: #000000;
|
||||
padding: 0px 10px 0px 10px;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
|
@ -50,9 +37,9 @@
|
|||
<body><font [FONTTAG]>
|
||||
<table cellspacing="3" border="0" width="100%">
|
||||
<tr id="surround0"><td style="width:100%">
|
||||
<div class="headingbox[CBLORBSTATUS]">
|
||||
<div class="headingtext">Report on Release: [CBLORBSTATUS]</div>
|
||||
<div class="headingrubric">Produced by [GENERATOR] at [TIMESTAMP] on [DATESTAMP]</div>
|
||||
<div class="headingpanellayout headingpanel[CBLORBSTATUSLOW]">
|
||||
<div class="headingtext"><span class="headingpaneltext">Report on Release: [CBLORBSTATUS]</span></div>
|
||||
<div class="headingrubric"><span class="headingpanelrubric">Produced by [GENERATOR] at [TIMESTAMP] on [DATESTAMP]</span></div>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
<p>
|
||||
|
|
|
@ -106,14 +106,14 @@ span.headingpaneltext {
|
|||
color: var(--heading-panel-text-colour);
|
||||
font-family: sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
font-size: 1.333rem; /* 20/12 * 100/125 */
|
||||
font-size: 1.2rem; /* 18/12 * 100/125 */
|
||||
font-weight: bold;
|
||||
}
|
||||
span.headingpaneltextalt {
|
||||
color: #ffffff;
|
||||
font-family: sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
font-size: 1.333rem; /* 20/12 * 100/125 */
|
||||
font-size: 1.2rem; /* 18/12 * 100/125 */
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,9 @@ int main(int argc, char **argv) {
|
|||
text_stream *f = NULL;
|
||||
if (font_setting)
|
||||
f = I"face='lucida grande,geneva,arial,tahoma,verdana,helvetica,helv'";
|
||||
Translator::go(from_folder, to_folder, f);
|
||||
TEMPORARY_TEXT(css)
|
||||
@<Read the platform CSS file@>;
|
||||
Translator::go(from_folder, to_folder, f, css);
|
||||
}
|
||||
Foundation::end();
|
||||
return 0;
|
||||
|
@ -54,3 +56,25 @@ void Main::bareword(int id, text_stream *arg, void *state) {
|
|||
else if (to_folder == NULL) to_folder = Pathnames::from_text(arg);
|
||||
else Errors::fatal("too many arguments given at command line");
|
||||
}
|
||||
|
||||
@ We also read the per-platform CSS file, if present:
|
||||
|
||||
@<Read the platform CSS file@> =
|
||||
filename *css_filename = NULL;
|
||||
pathname *css_path = Pathnames::from_text(I"inform7/Internal/HTML");
|
||||
TEMPORARY_TEXT(platform_variation)
|
||||
WRITE_TO(platform_variation, "%s-platform.css", PLATFORM_STRING);
|
||||
css_filename = Filenames::in(css_path, platform_variation);
|
||||
if (TextFiles::exists(css_filename) == FALSE) {
|
||||
css_filename = Filenames::in(css_path, I"platform.css");
|
||||
}
|
||||
if (TextFiles::exists(css_filename)) {
|
||||
TextFiles::read(css_filename, FALSE, "can't open css file",
|
||||
TRUE, Main::read_css_line, NULL, css);
|
||||
}
|
||||
|
||||
@ =
|
||||
void Main::read_css_line(text_stream *line, text_file_position *tfp, void *X) {
|
||||
text_stream *str = (text_stream *) X;
|
||||
WRITE_TO(str, "%S\n", line);
|
||||
}
|
||||
|
|
|
@ -11,13 +11,14 @@ typedef struct translator_state {
|
|||
struct text_stream *current_title;
|
||||
struct text_stream *current_pcode;
|
||||
struct text_stream *font;
|
||||
struct text_stream *css;
|
||||
struct filename *model_to_follow;
|
||||
struct pathname *destination_folder;
|
||||
struct text_stream *write_to;
|
||||
int counter;
|
||||
} translator_state;
|
||||
|
||||
void Translator::go(pathname *from_folder, pathname *to_folder, text_stream *font_setting) {
|
||||
void Translator::go(pathname *from_folder, pathname *to_folder, text_stream *font_setting, text_stream *css) {
|
||||
filename *texts = Filenames::in(from_folder, I"texts.txt");
|
||||
translator_state ts;
|
||||
ts.current_text = Str::new();
|
||||
|
@ -27,6 +28,7 @@ void Translator::go(pathname *from_folder, pathname *to_folder, text_stream *fon
|
|||
ts.destination_folder = to_folder;
|
||||
ts.model_to_follow = NULL;
|
||||
ts.font = font_setting;
|
||||
ts.css = css;
|
||||
ts.counter = 0;
|
||||
TextFiles::read(texts, FALSE, "unable to read file of source text", TRUE,
|
||||
&Translator::go_helper, NULL, &ts);
|
||||
|
@ -85,7 +87,7 @@ void Translator::flush(translator_state *ts) {
|
|||
match_results mr = Regexp::create_mr();
|
||||
while (Regexp::match(&mr, ts->current_text, L"(%c*?)\"(%c*?)\"(%c*)")) {
|
||||
Str::clear(ts->current_text);
|
||||
WRITE_TO(ts->current_text, "%S<font color=_QUOTE_#000080_QUOTE_><b>%S</b></font>%S",
|
||||
WRITE_TO(ts->current_text, "%S<span class=_QUOTE_indexdullblue_QUOTE_><b>%S</b></span>%S",
|
||||
mr.exp[0], mr.exp[1], mr.exp[2]);
|
||||
}
|
||||
while (Regexp::match(&mr, ts->current_text, L"(%c*?)_QUOTE_(%c*)")) {
|
||||
|
@ -129,4 +131,8 @@ void Translator::flush_helper(text_stream *text, text_file_position *tfp, void *
|
|||
Str::clear(text);
|
||||
WRITE_TO(text, "%S%S%S", mr.exp[0], ts->font, mr.exp[1]);
|
||||
}
|
||||
while (Regexp::match(&mr, text, L"(%c*?)%*5(%c*)")) {
|
||||
Str::clear(text);
|
||||
WRITE_TO(text, "%S%S%S", mr.exp[0], ts->css, mr.exp[1]);
|
||||
}
|
||||
Regexp::dispose_of(&mr);
|
||||
|
|
|
@ -53,7 +53,7 @@ from the next. For instance:
|
|||
A number cannot be divided by 0: similarly, we cannot take the remainder
|
||||
after dividing something by 0.
|
||||
=
|
||||
The model file is a standard HTML file, except that it can contain four
|
||||
The model file is a standard HTML file, except that it can contain five
|
||||
escape codes, which Inrtps expands. Thus:
|
||||
|
||||
(a) |*1| expands to the code number of the message.
|
||||
|
@ -61,3 +61,5 @@ escape codes, which Inrtps expands. Thus:
|
|||
(c) |*3| expands to a short title for the message.
|
||||
(d) |*4| expands to font settings inside a |<font ...>| tag. (This will be
|
||||
blank if |nofont| is set, or will choose a Helvetica-like font if |font| is set.)
|
||||
(e) |*5| expands to the contents of the appropriate per-platform CSS file, which
|
||||
is read from the Internal/HTML/ directory of the Inform installation.
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 3.4 KiB After Width: | Height: | Size: 3.7 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.6 KiB After Width: | Height: | Size: 3.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 331 B After Width: | Height: | Size: 658 B |
|
@ -1,5 +1,12 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"></head>
|
||||
<html><head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
*5
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body><font *4 size=2><b>Translating the Source - *3</b>
|
||||
<p>
|
||||
*2
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"></head>
|
||||
<html><head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||||
<style type="text/css">
|
||||
<!--
|
||||
*5
|
||||
-->
|
||||
</style>
|
||||
</head>
|
||||
<body><font *4 size=2><b>Packaging up for Release - *3</b>
|
||||
<p>
|
||||
*2
|
||||
|
|
|
@ -2,33 +2,29 @@
|
|||
<html><head>
|
||||
<style type="text/css">
|
||||
<!--
|
||||
.headingbox {
|
||||
*5
|
||||
-->
|
||||
</style>
|
||||
<style type="text/css">
|
||||
<!--
|
||||
.headingpanellayout {
|
||||
position: relative;
|
||||
height: 56px;
|
||||
padding: 0px;
|
||||
white-space:nowrap;
|
||||
background: #f69Ca6; /* red */
|
||||
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
.headingtext {
|
||||
position: absolute;
|
||||
top: -4px;
|
||||
left: -1px;
|
||||
width: 100%;
|
||||
color: #000000;
|
||||
padding: 14px 10px 0px 10px;
|
||||
font-size: 20px;
|
||||
font-weight: bold;
|
||||
}
|
||||
.headingrubric {
|
||||
position: absolute;
|
||||
top: 36px;
|
||||
width: 100%;
|
||||
color: #000000;
|
||||
padding: 0px 10px 0px 10px;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
}
|
||||
-->
|
||||
</style>
|
||||
|
@ -36,9 +32,9 @@
|
|||
<body><font *4 size=2>
|
||||
<table cellspacing="3" border="0" width="100%">
|
||||
<tr id="surround0"><td style="width:100%">
|
||||
<div class="headingbox">
|
||||
<div class="headingtext">Run-Time Problem</div>
|
||||
<div class="headingrubric">*3 (*1)</div>
|
||||
<div class="headingpanellayout headingpanelfailed">
|
||||
<div class="headingtext"><span class="headingpaneltext">Run-Time Problem</span></div>
|
||||
<div class="headingrubric"><span class="headingpanelrubric">*3 (*1)</span></div>
|
||||
</div></td>
|
||||
</tr></table>
|
||||
|
||||
|
|
|
@ -328,22 +328,13 @@ The application ran your source text through the Inform 7 compiler, as usual, an
|
|||
<p>
|
||||
Inform can produce story files for several different virtual computers, and the one used by the current project can be selected using the Settings panel. If you are currently using the "Z-machine" format, try switching the project to "Glulx" format (you can make this change at the Settings panel), and limits like this will probably not bother you again. Although Z-machine story files used to be much more widely playable than Glulx ones, these days Glulx interpreters are widely available, so it's probably not worth making big sacrifices to stay within the Z-machine memory size.
|
||||
|
||||
# And finally the pages showing the result of cblorb, on a Release run.
|
||||
# And finally the pages showing the result of inblorb, on a Release run.
|
||||
|
||||
model = released.html
|
||||
|
||||
--> ErrorCblorb - Failed
|
||||
The application ran your source text through the Inform 7 compiler, as usual, and then manufactured the final story file using Inform 6: all of this worked fine. However, the "cblorb" packaging tool then failed to make the actual release of the data out of your project. Its errors are written out on the Console tab.
|
||||
The application ran your source text through the Inform 7 compiler, as usual, and then manufactured the final story file using Inform 6: all of this worked fine. However, the "inblorb" packaging tool then failed to make the actual release of the data out of your project. Its errors are written out on the Console tab.
|
||||
<p>
|
||||
<center><img src='inform:/cblorb_failed.png' border=0></center>
|
||||
<p>
|
||||
This almost never happens in normal usage, and is almost certainly the result of a "Release along with..." sentence in the source having asked to do something impossible. For instance, an attempt to release along with cover art will fail if there's no cover art provided, or it has the wrong filename or is in the wrong place. So the best thing to do is probably to look carefully at any Release instructions in the source, and check them against the documentation.
|
||||
|
||||
--> GoodCblorb - Succeeded
|
||||
The source text was successfully translated to produce the story file, and the "cblorb" packaging tool was then used to wrap it up into a Blorb archive, the standard run-time format produced by Inform.
|
||||
<p>
|
||||
<center><img src='inform:/cblorb_succeeded.png' border=0></center>
|
||||
<p>
|
||||
In the same way that books in many different languages nevertheless have the same kind of binding, the Blorb wrapper can contain story files of several different story file formats (for instance, versions of Glulx or the Z-machine): see Chapter 2 of the Inform documentation.
|
||||
<p>
|
||||
Many modern interpreters can play Blorbed story files, but a few older ones cannot; besides, you might need a raw story file for use on a small portable device with very little memory. If you do need to avoid Blorbing, go to the Settings panel for the project and untick the "Create a Blorb archive for release" box, then release again. The result will be just a bare story file, and none of the advanced release options (solutions, website, cover art, etc.) will be possible. The bibliographic data will also be lost.
|
||||
|
|
Loading…
Reference in a new issue