Skip to content

Commit

Permalink
Additional fixes and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wilwade committed Nov 20, 2024
1 parent dbceead commit bf5385e
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 176 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ Documentation is written in [CommonMark Markdown](https://rust-lang.github.io/md
#### Local Development

- Serve the HTML locally and watch for changes: `mdbook serve` or `mdbook serve -p <port, default 3000>`
- For style edits see: [`docs/css/extended.css`](./docs/css/extended.css)
- For changes to the custom preprocessor see: [`docs/preprocessor.mjs`](./docs/preprocessor.mjs)
- For style edits see: [`docs/css/overrides.css`](./docs/css/overrides.css)
- For changes to the custom preprocessor see: [`docs/preprocessors/README.md`](./docs/preprocessors/README.md)

#### Deployment

Expand Down
4 changes: 4 additions & 0 deletions docs/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ command = "node preprocessors/button-links.mjs"
[preprocessor.svg-embed]
command = "node preprocessors/svg-embed.mjs"

[preprocessor.generator]
command = "node preprocessors/generator.mjs"


[output.html]
no-section-label = true
Expand All @@ -22,6 +25,7 @@ additional-css = [
"css/highlight-dark.css",
"css/tailwind-short.css",
"css/button-links.css",
"css/generator.css",
"css/overrides.css",
]

Expand Down
99 changes: 99 additions & 0 deletions docs/css/generator.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#generator {
label {
font-size: 24px;
font-weight: 400;
margin-bottom: 0.5em;
display: block;
}

fieldset label {
font-size: 20px;
}

fieldset {
border: none;
padding: 0;
}

legend {
font-size: 24px;
font-weight: 400;
}

.checkboxes {
margin-top: 8px;
padding-left: 24px;
label {
cursor: pointer;
}
> div {
margin-top: 2rem;
margin-bottom: 1rem;
}
}

.mb-4 {
margin-bottom: 24px;
}

.my-2 {
margin-top: 1rem;
margin-bottom: 1rem;
}

.text-sm {
font-size: 80%;
}

.text-red {
color: #eb5757;
}

button {
text-transform: none;
-webkit-appearance: button;
font-family: inherit;
font-size: 24px;
line-height: 1.15;
margin: 0 0 3rem 0;
border-radius: 1em;
border: none;
background-color: #4ba0a5;
padding: 1em 24px;
color: white;
cursor: pointer;
&:hover {
background-color: #00b6af;
}
}

input[type="text"],
input[type="url"],
input[type="email"],
select,
textarea {
font-size: 1.8rem;
width: 100%;
border-radius: 10px;
padding: 1rem 24px;
border: 2px solid #c8cdd0;
&:focus {
border-color: #00b6af;
outline: none;
}
&:read-only {
&:focus {
border-color: #c8cdd0;
}
font-size: 1.2rem;
padding: 1rem 1rem;
}
}

dt {
font-weight: 600;
}
dd {
margin-bottom: 3rem;
}
}
159 changes: 0 additions & 159 deletions docs/preprocessor.mjs

This file was deleted.

65 changes: 65 additions & 0 deletions docs/preprocessors/generator.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// Debugging Help
// Use console.error, not console.log
//
// Replaces {{#GENERATOR}} with the ./src/Generator/index.html data

import { readFileSync } from "node:fs";

function generatorEmbed(chapter) {
const regex = /{{#GENERATOR}}/g;
const matches = [...chapter.content.matchAll(regex)];
matches.forEach((match) => {
try {
const output = readFileSync("./src/Generator/index.html", "utf8");

const replaceWith = output
.split("\n")
.map((line) => line.trim().replace("./_app/", "./Generator/_app/"))
.join("\n");
chapter.content = chapter.content.replace(match[0], replaceWith);
} catch (e) {
console.error(
"Unable to read the generated Generator script. Looks like you need to follow the instructions in tools/signed-request-generator/README.md",
);
throw e;
}
});
if (chapter.sub_items) {
chapter.sub_items.forEach((section) => {
section.Chapter && generatorEmbed(section.Chapter);
});
}
}

// Function to perform the preprocessing
function preprocessMdBook([_context, book]) {
// Generator Embed
book.sections.forEach((section) => {
section.Chapter && generatorEmbed(section.Chapter);
});

// Output the processed content in mdbook preprocessor format
process.stdout.write(JSON.stringify(book));
}

if (process.argv < 3) {
throw new Error("Something strange is happening");
}

if (process.argv[2] === "supports") {
process.exit(0);
}

process.stdin.setEncoding("utf-8");
process.stdout.setEncoding("utf-8");

// Read data from stdin
let inputData = "";

process.stdin.on("data", (chunk) => {
inputData += chunk;
});

process.stdin.on("end", () => {
preprocessMdBook(JSON.parse(inputData));
});
6 changes: 3 additions & 3 deletions docs/src/Actions/Response.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ SIWF services do not manage user sessions.

## New Frequency User Response

{{#markdown-embed src/DataStructures/Response-NewUser.md 0}}
{{#include ../DataStructures/Response-NewUser.md 0}}

## New Application/Delegation Response

{{#markdown-embed src/DataStructures/Response-NewProvider.md 0}}
{{#include ../DataStructures/Response-NewProvider.md 0}}

## Login Only Response

{{#markdown-embed src/DataStructures/Response-LoginOnly.md 0}}
{{#include ../DataStructures/Response-LoginOnly.md 0}}
4 changes: 2 additions & 2 deletions docs/src/Actions/Start.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ For example, if you wish to correlate the original unauthorized session with the

Parameters

{{#markdown-embed src/DataStructures/Request.md 0}}
{{#include ../DataStructures/Request.md 0}}

Testnet Authentication URL

{{#markdown-embed src/DataStructures/RequestUrl.md 0}}
{{#include ../DataStructures/RequestUrl.md 0}}

## Step 3: Redirect the User

Expand Down
Loading

0 comments on commit bf5385e

Please sign in to comment.