1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-06-17 07:40:47 +03:00

Better CSS inclusion for registry index pages

This commit is contained in:
Graham Nelson 2022-08-01 21:26:41 +01:00
parent 93a3f58d41
commit c84a407fa1
8 changed files with 444 additions and 4 deletions

View file

@ -1,6 +1,6 @@
# Inform 7
v10.1.0-beta+6V35 'Krypton' (26 July 2022)
v10.1.0-beta+6V36 'Krypton' (1 August 2022)
## About Inform 7

View file

@ -1,3 +1,3 @@
Prerelease: beta
Build Date: 26 July 2022
Build Number: 6V35
Build Date: 1 August 2022
Build Number: 6V36

View file

@ -115,6 +115,8 @@ void Registries::build(inbuild_registry *R) {
@<Construct the list of custom macros for this sort of preprocessing@> =
Preprocessor::new_macro(ML, I"include", I"file: LEAFNAME",
Registries::include_expander, NULL);
Preprocessor::new_macro(ML, I"include-css", I"?platform: PLATFORM",
Registries::css_expander, NULL);
Preprocessor::new_macro(ML, I"process", I"file: LEAFNAME",
Registries::process_expander, NULL);
Preprocessor::do_not_suppress_whitespace(
@ -193,6 +195,24 @@ void Registries::process_expander(preprocessor_macro *mm, preprocessor_state *PP
TRUE, Preprocessor::scan_line, NULL, PPS);
}
@ |{include-css platform:P}| splices in the Inform distribution's standard CSS
files for the named platform. It's an |include|, not a |process|.
=
void Registries::css_expander(preprocessor_macro *mm, preprocessor_state *PPS,
text_stream **parameter_values, preprocessor_loop *loop, text_file_position *tfp) {
text_stream *platform = parameter_values[0];
filename *prototype = InstalledFiles::filename_for_platform(CSS_SET_BY_PLATFORM_IRES, platform);
WRITE_TO(PPS->dest, "<style type=\"text/css\">\n");
WRITE_TO(PPS->dest, "<!--\n");
TextFiles::read(prototype, FALSE, "can't open include file",
TRUE, Registries::scan_line, NULL, PPS);
prototype = InstalledFiles::filename_for_platform(CSS_FOR_STANDARD_PAGES_IRES, platform);
TextFiles::read(prototype, FALSE, "can't open include file",
TRUE, Registries::scan_line, NULL, PPS);
WRITE_TO(PPS->dest, "--></style>\n");
}
@ |{sections}| ... |{end-sections}| is a loop construct, which loops over each
section of the registry's roster file. The loop variable |{SECTIONID}| holds
the ID text for the section; right now, that's just |0|, |1|, |2|, ...

View file

@ -362,3 +362,115 @@ ul.leaders li.leaded span:first-child {
ul.leaders li.leaded span + span {
background: var(--leaders-background-colour);
}
/* On Registry index pages (such as the Public Library), these are used for
download buttons and the like: */
span.registrybuttontext {
font-size: 11px;
border-color: #000000;
}
span.registryminibuttontext {
font-size: 10px;
border-color: #000000;
}
span.registrybuttonuninstalled {
color: #000000;
background: #ffffdd;
}
span.registrybuttoninstalled {
color: #000000;
background: #ffffff;
pointer-events: none;
}
span.registrybuttonbuiltin {
color: #888888;
background: #ffffff;
pointer-events: none;
}
span.registrybuttonupdate {
color: #000000;
background: #aaddff;
}
span.registrybuttonrevert {
color: #000000;
background: #ddaaff;
}
span.registrybuttonrevealer {
color: #ffffff;
background: #444444;
}
/* Registry index section headings: */
span.registrysectionname {
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
-webkit-font-smoothing: antialiased;
font-size: 16px;
line-height: 18px;
}
span.registrysubsectionname {
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
-webkit-font-smoothing: antialiased;
font-size: 14px;
line-height: 16px;
}
/* These are for the "mark" for a section, usually a section-symbol and number */
span.registrysectionmark {
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
-webkit-font-smoothing: antialiased;
font-size: 16px;
line-height: 18px;
color: #666;
}
span.registrysubsectionmark {
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
-webkit-font-smoothing: antialiased;
font-size: 14px;
line-height: 16px;
color: #666;
}
/* Text of an item listed in a registry: */
span.registryitemtext {
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
-webkit-font-smoothing: antialiased;
font-size: 12px;
line-height: 16px;
}
/* And how the links in a registry index page behave: */
a.registrysilentlink {
text-decoration: none;
color: #000;
}
a.registrybuttonlink {
text-decoration: none;
}
a.registrycontentslink:link {
text-decoration: none;
color: #202020;
}
a.registrycontentslink:visited {
text-decoration: none;
color: #202020;
}
a.registrycontentslink:hover {
text-decoration: none;
color: #D00000;
}
a.registrycontentslink:active {
text-decoration: none;
color: #D00000;
}

View file

@ -343,3 +343,44 @@ li.indent9 span:first-child {
li.unleaded:before {
content: "";
}
/* On Registry index pages (such as the Public Library), these are used for
download buttons and the like: */
span.registrybuttons {
height: 20px;
padding: 2px 8px 2px 8px;
margin: 2px;
border:1px solid;
border-radius: 5px;
}
span.registryminibuttons {
height: 14px;
padding: 2px 5px 2px 5px;
margin: 2px;
border:1px solid;
border-radius: 4px;
}
/* Used to hide or display sections in the Registry pages: */
div.registrysectionitemsopen {
display: block;
}
div.registrysectionitemsclosed {
display: none;
}
/* Hanging indentation for Registry item paragraphs: */
p.registryitem {
padding-left: 80px;
text-indent: -40px;
}
p.registryaddition {
padding-left: 40px;
text-indent: -40px;
}

View file

@ -311,3 +311,115 @@ ul.leaders li.leaded span:first-child {
ul.leaders li.leaded span + span {
background: white;
}
/* On Registry index pages (such as the Public Library), these are used for
download buttons and the like: */
span.registrybuttontext {
font-size: 11px;
border-color: #000000;
}
span.registryminibuttontext {
font-size: 10px;
border-color: #000000;
}
span.registrybuttonuninstalled {
color: #000000;
background: #ffffdd;
}
span.registrybuttoninstalled {
color: #000000;
background: #ffffff;
pointer-events: none;
}
span.registrybuttonbuiltin {
color: #888888;
background: #ffffff;
pointer-events: none;
}
span.registrybuttonupdate {
color: #000000;
background: #aaddff;
}
span.registrybuttonrevert {
color: #000000;
background: #ddaaff;
}
span.registrybuttonrevealer {
color: #ffffff;
background: #444444;
}
/* Registry index section headings: */
span.registrysectionname {
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
-webkit-font-smoothing: antialiased;
font-size: 16px;
line-height: 18px;
}
span.registrysubsectionname {
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
-webkit-font-smoothing: antialiased;
font-size: 14px;
line-height: 16px;
}
/* These are for the "mark" for a section, usually a section-symbol and number */
span.registrysectionmark {
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
-webkit-font-smoothing: antialiased;
font-size: 16px;
line-height: 18px;
color: #666;
}
span.registrysubsectionmark {
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
-webkit-font-smoothing: antialiased;
font-size: 14px;
line-height: 16px;
color: #666;
}
/* Text of an item listed in a registry: */
span.registryitemtext {
font-family: "Lucida Grande", "Lucida Sans Unicode", Helvetica, Arial, Verdana, sans-serif;
-webkit-font-smoothing: antialiased;
font-size: 12px;
line-height: 16px;
}
/* And how the links in a registry index page behave: */
a.registrysilentlink {
text-decoration: none;
color: #000;
}
a.registrybuttonlink {
text-decoration: none;
}
a.registrycontentslink:link {
text-decoration: none;
color: #202020;
}
a.registrycontentslink:visited {
text-decoration: none;
color: #202020;
}
a.registrycontentslink:hover {
text-decoration: none;
color: #D00000;
}
a.registrycontentslink:active {
text-decoration: none;
color: #D00000;
}

View file

@ -311,3 +311,110 @@ ul.leaders li.leaded span:first-child {
ul.leaders li.leaded span + span {
background: white;
}
/* On Registry index pages (such as the Public Library), these are used for
download buttons and the like: */
span.registrybuttontext {
font-size: 11px;
border-color: #000000;
}
span.registryminibuttontext {
font-size: 10px;
border-color: #000000;
}
span.registrybuttonuninstalled {
color: #000000;
background: #ffffdd;
}
span.registrybuttoninstalled {
color: #000000;
background: #ffffff;
pointer-events: none;
}
span.registrybuttonbuiltin {
color: #888888;
background: #ffffff;
pointer-events: none;
}
span.registrybuttonupdate {
color: #000000;
background: #aaddff;
}
span.registrybuttonrevert {
color: #000000;
background: #ddaaff;
}
span.registrybuttonrevealer {
color: #ffffff;
background: #444444;
}
/* Registry index section headings: */
span.registrysectionname {
-webkit-font-smoothing: antialiased;
font-size: 16px;
line-height: 18px;
}
span.registrysubsectionname {
-webkit-font-smoothing: antialiased;
font-size: 14px;
line-height: 16px;
}
/* These are for the "mark" for a section, usually a section-symbol and number */
span.registrysectionmark {
-webkit-font-smoothing: antialiased;
font-size: 16px;
line-height: 18px;
color: #666;
}
span.registrysubsectionmark {
-webkit-font-smoothing: antialiased;
font-size: 14px;
line-height: 16px;
color: #666;
}
/* Text of an item listed in a registry: */
span.registryitemtext {
-webkit-font-smoothing: antialiased;
font-size: 12px;
line-height: 16px;
}
/* And how the links in a registry index page behave: */
a.registrysilentlink {
text-decoration: none;
color: #000;
}
a.registrybuttonlink {
text-decoration: none;
}
a.registrycontentslink:link {
text-decoration: none;
color: #202020;
}
a.registrycontentslink:visited {
text-decoration: none;
color: #202020;
}
a.registrycontentslink:hover {
text-decoration: none;
color: #D00000;
}
a.registrycontentslink:active {
text-decoration: none;
color: #D00000;
}

View file

@ -61,7 +61,7 @@ filename *InstalledFiles::filename(int ires) {
return InstalledFiles::varied_by_platform(models, I"main.css");
case EXTENSION_DOCUMENTATION_MODEL_IRES:
return InstalledFiles::varied_by_platform(models, I"extensionfile.html");
}
}
internal_error("unknown installation resource file");
return NULL;
}
@ -81,6 +81,54 @@ filename *InstalledFiles::varied_by_platform(pathname *models, text_stream *leaf
return F;
}
@ Or even for a different platform than the one we're running on:
=
filename *InstalledFiles::filename_for_platform(int ires, text_stream *platform) {
if (Str::len(platform) == 0) return InstalledFiles::filename(ires);
pathname *internal = INSTALLED_FILES_HTML_CALLBACK();
pathname *models = Pathnames::down(internal, I"HTML");
switch (ires) {
case CBLORB_REPORT_MODEL_IRES:
return InstalledFiles::varied_by_named_platform(models,
I"CblorbModel.html", platform);
case DOCUMENTATION_XREFS_IRES:
return InstalledFiles::varied_by_named_platform(models,
I"xrefs.txt", platform);
case JAVASCRIPT_FOR_STANDARD_PAGES_IRES:
return InstalledFiles::varied_by_named_platform(models,
I"main.js", platform);
case JAVASCRIPT_FOR_EXTENSIONS_IRES:
return InstalledFiles::varied_by_named_platform(models,
I"extensions.js", platform);
case JAVASCRIPT_FOR_ONE_EXTENSION_IRES:
return InstalledFiles::varied_by_named_platform(models,
I"extensionfile.js", platform);
case CSS_SET_BY_PLATFORM_IRES:
return InstalledFiles::varied_by_named_platform(models,
I"platform.css", platform);
case CSS_FOR_STANDARD_PAGES_IRES:
return InstalledFiles::varied_by_named_platform(models,
I"main.css", platform);
case EXTENSION_DOCUMENTATION_MODEL_IRES:
return InstalledFiles::varied_by_named_platform(models,
I"extensionfile.html", platform);
}
return InstalledFiles::filename(ires);
}
filename *InstalledFiles::varied_by_named_platform(pathname *models, text_stream *leafname,
text_stream *platform) {
filename *F = NULL;
TEMPORARY_TEXT(variation)
WRITE_TO(variation, "%S-%S", platform, leafname);
/* NB: PLATFORM_STRING is a C string, so that %s is correct */
F = Filenames::in(models, variation);
if (TextFiles::exists(F) == FALSE) F = Filenames::in(models, leafname);
DISCARD_TEXT(variation)
return F;
}
@ This directory also holds the |Basic.indext| and |Standard.indext| index
structure files, but in principle we allow a wider range of these to exist, so: