The repo of example demos that the introweb.tech website pulls from.
Live at https://introweb.tech/examples.
The repo for introweb.tech/examples (same as the examples.introweb.tech site/repo) can be found here.
Upon first glance there are a few different things you’ll notice in this repo:
root-dir-config.json.gitignore, README.md, and continuous-deployment.webp filesWe’ll start with _repo-apis
_repo-apisThis directory is where all of the APIs and build scripts live. The APIs are prefixed with api- while the build scripts are prefixed with build-.
Note: Everything for the Content API is pre-prended with /repos so /:repo/demos becomes https://introweb.tech/repos/examples/demos in practice
| Method | Route | Query Params | Returns | Description | Example |
|---|---|---|---|---|---|
GET |
/:repo |
dir (Optional - the desired subdirectory. Defaults to every subdirectory.) |
Object<Array> | All of the file paths for every file (and a URL to reach the file contents at) in the specified repo. In no particular order. | GET /examples?dir=html |
GET |
/:repo/demos |
dir (Optional - the desired subdirectory. Defaults to every subdirectory.) |
Array<String> | A list of every demo in the specified repo. In no particular order. | GET /examples/demos?=html |
GET |
/:repo/demo-frames |
none | Array<String> | A list of every demo and what frames they use (e.g. markdown, editor, etc). In no particular order. | GET /examples/demo-frames |
GET |
/:repo/file/* |
none | Object | The contents and metadata of the specified file from the specified repo. Must be a relative route to a file (e.g. `form/spa/index.html`) | GET /examples/file/form/ |
GET |
/:repo/contents/* |
none | String | The direct contents (with the MIME type `text/plain`) of the specified file from the specified repo. Must be a relative route to a file (e.g. `form/spa/index.html`) | GET /examples/contents/ |
GET |
/:repo/contents-mime/* |
none | String | The direct contents (with the corresponding MIME type) of the specified file from the specified repo. Must be a relative route to a file (e.g. `form/spa/index.html`) | GET /examples/contents- |
GET |
/:repo/route-configs |
dir (Optional - the desired subdirectory. Defaults to every subdirectory.) |
Object | Reads all of the demo-config.json and dir-config.json files and makes returns them in a structured object in order according to the configs. If dir is specified, just that subdirectory is returned and all of the demos are flattened (proper order is retained). |
GET /examples/route-configs |
GET |
/:repo/demo-files |
none | Object<Object> | Returns an object of every demo containing an array of all of their files. | GET /examples/demo-files |
Note: Everything for the Zip API is pre-prended with /zip so / becomes https://introweb.tech/zip in practice (the trailing slash having been omitted here)
| Method | Route | Query Params | Returns | Description | Example |
|---|---|---|---|---|---|
GET |
/ |
repo & dir (Both required - the desired demo to zip and the repo it's from) |
.zip File | Creates a .zip file of all of the relevant files to the specified demo (ignoring files like quiz.md which aren't meant to be seen raw by users). |
GET https://introweb.tech/zip?repo=examples&dir=http/bundle-size |
Outside of _repo-apis, every other folder in the top level of this repo is a “Main Category Directory”. If you look over at https://introweb.tech/examples, the main categories are the sections that say “Part I - Introduction”, “Part II - HTTP”, etc. Everything is built and generated dynamically from this repo, so if a new folder is added, that /examples page will update in the build process.
root-dir-config.jsonWe’ll talk about dir-config.json files later on, but this root-dir-config.json file is a special file that specifies which order the main category directories should appear in as it defaults to alphabetical.
.gitignore has some basics files and direcotries to ignore to keep this repo cleanREADME.md and continuous-deployment.webp both make up this current README that you are reading right now.Adding a demo in an existing category / subcategory is pretty straightforward. All of the templates for
these files along with the available options for each template will be inside _templates. Follow these
steps:
dir-config.json that should be in the same directory as where you just created the new folder.demo-config.json.learn.md to store it all.quiz.md.resources.md.media where your media will live.
ii. Inside that media folder, create a file named media-config.json.
iii. Specify whether you want to use that media inline in the markdown panel or external in its own media panel
inside the media config.Adding a new category / subcategory is also pretty straightforward. All of the templates for
these files along with the available options for each template will be inside _templates. Follow these steps:
dir-config.json.root-dir-config.json.
The above diagram illustrates the continuous deployment process of this repository. The process starts on your local machine.
git@introweb.tech:/var/repos/bare/examples.gitgit@introweb.tech:/var/repos/bare/examples.introweb.tech.gitpost-receive hook that then pushes those changes to GitHub and triggers the build process after changes are pushed
build-sidebar.js to generate all of the sidebar.html pages/dist folder from the examples.introweb.tech repoexamples.introweb.tech which creates a new /dist folderexamples.introweb.tech DocumentRoot has been set up to live at /var/www/examples.introweb.tech within Apache on the remote server. The actual file at /var/www/examples.introweb.tech is a symbolic link to /var/repos/examples.introweb.tech/dist so creating the new /dist folder automatically deploys the updates live. (This is the dashed green arrow in the diagram)