mirror of
https://github.com/ganelson/inform.git
synced 2024-05-08 20:18:36 +03:00
Use per-platform CSS when generating RTP and failure HTML pages
This commit is contained in:
parent
6c41938b26
commit
8e0069eb71
|
@ -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.
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
Loading…
Reference in a new issue