diff --git a/app.py b/app.py index ed8d3a2..4b5b387 100644 --- a/app.py +++ b/app.py @@ -100,9 +100,9 @@ env.filters["prettydate"] = prettydate # translate a single file into HTML def render_single_file(page, path, dist, name = False): + name = Path(path).stem template = env.select_template([f"{name}.jinja", "post.jinja"]) html = template.render(documents=documents, page=page, name=name) - name = Path(path).stem if not os.path.exists(dist): os.makedirs(dist) @@ -160,7 +160,7 @@ def get_page_data(path, isPreload=False): page["has_passed"] = datetime.fromtimestamp(page["start_datetime"]) < now - if ".include" in page.content: + if "`include" in page.content: latex = pypandoc.convert_text( page.content, to='md', @@ -225,6 +225,8 @@ def render_posts(path, output_path=OUTPUT_D): render_posts(file_path, f"{output_path}/{name}") elif filename.endswith(".svg"): save_circuit_svg(file_path, f"{output_path}/{name}", filename) + elif Path(filename).suffix in [".jpeg", ".mp3", ".jpg"]: + shutil.copyfile(file_path, f"{output_path}/{name}/{filename}") else: print("doing nothing with", filename) @@ -235,15 +237,17 @@ def preload_documents(): for subdir in os.listdir(CONTENT_D): path = os.path.join(CONTENT_D, subdir) - print(path) if os.path.isdir(path): name = Path(path).stem documents.setdefault(name, []) for filename in sorted(os.listdir(path)): + cpath = os.path.join(path, filename) if filename.endswith(".md"): - documents[name].append(get_page_data(os.path.join(path, filename), isPreload=True)) + documents[name].append(get_page_data(cpath, isPreload=True)) + elif os.path.isdir(cpath): + documents[name].append(get_page_data(os.path.join(cpath, "index.md"), isPreload=True)) elif Path(path).suffix == '.md': documents[Path(path).stem] = get_page_data(path, isPreload=True) @@ -290,5 +294,4 @@ def main(): copy_assets() - main() diff --git a/src/assets/app.js b/src/assets/app.js index 1b83e4d..d351f8a 100644 --- a/src/assets/app.js +++ b/src/assets/app.js @@ -28,4 +28,5 @@ const showLightbox = (e) => { document.querySelectorAll("article img").forEach((img) => { console.log(img); img.addEventListener("click", showLightbox); -}) \ No newline at end of file +}) + diff --git a/src/assets/styles/layout.css b/src/assets/styles/layout.css index 2426981..d161b59 100644 --- a/src/assets/styles/layout.css +++ b/src/assets/styles/layout.css @@ -18,7 +18,7 @@ article:not(article article) { article header { padding-right: 0; - margin-right: calc(var(--footnote-w)*-1); + margin-right: calc(var(--footnote-w) * -1); } article header { @@ -26,6 +26,13 @@ article header { } +aside + section p:first-child{ + margin-top: 0; +} + +.media--pcb { + width: 70mm; +} dialog { max-width: var(--main-w); height: 100%; @@ -46,13 +53,13 @@ dialog img { } dialog::backdrop { - background-color: transparent; - transition: .2s linear; + background-color: transparent; + transition: 0.2s linear; } dialog[open]::backdrop { - background-color: black; - opacity: .5; + background-color: black; + opacity: 0.5; } sup li:before, @@ -67,20 +74,22 @@ li[count]:before { color: var(--accent); } -li[count] { +li[count], aside:not(.footnotes) { float: right; clear: right; width: var(--footnote-w); margin-right: calc((var(--footnote-w) * -1)); - padding-left: 1rem; - margin-top: -1em; + padding-left: var(--gap); margin-bottom: 1em; } -article:not(article article) { -/* padding-right: var(--footnote-w);;*/ +li[count] { + margin-top: -1em; } +article:not(article article) { + /* padding-right: var(--footnote-w);;*/ +} .list--frontpage { display: grid; @@ -88,4 +97,4 @@ article:not(article article) { grid-gap: 1rem; list-style-type: none; padding: 0 0; -} \ No newline at end of file +} diff --git a/src/assets/styles/paged.css b/src/assets/styles/paged.css index 9e20a08..8c4e595 100644 --- a/src/assets/styles/paged.css +++ b/src/assets/styles/paged.css @@ -102,7 +102,7 @@ body { display: none; } .meta:has([data-chapter-title]) { - break-before: page; +/* break-before: page;*/ } .page--cover { page: cover; @@ -113,6 +113,11 @@ body { counter-reset: page; } +[template-type="circuit"] { + page: circuit; +/* break-before: page;*/ +} + .header-section-number { display: none; diff --git a/src/assets/styles/print.css b/src/assets/styles/print.css deleted file mode 100644 index 492e6c3..0000000 --- a/src/assets/styles/print.css +++ /dev/null @@ -1,66 +0,0 @@ -/*:root { - font-size: 16px; - --background: transparent; -} - -@page { - size: A5; - margin: 1cm; - font-family: sans-serif; -} - -section.level1 { - page: default; - break-before: page; - padding-right: calc(var(--footnote-w) + 16px); -} - -section.level1:has([data-template-type="chapter"]) { - page: chapter; -} - -section.level1:has([data-template-type="bib"]) { - page: bib; -} - -@page chapter { - size: A5; - margin: 1cm; - font-family: sans-serif; - margin-top: 20mm; - margin-bottom: 20mm; - bleed: 60mm; - - @top-center { - content: "This is a chapter"; - } -} - - - -@page bib { - size: A5; - margin: 1cm; - font-family: sans-serif; - margin-top: 20mm; - margin-bottom: 20mm; - bleed: 6mm; - - text-align: right; - @top-center { - content: "This is the bibliography"; - } -} - -.no-print { - display: none; -} - -p { - break-inside: avoid; -} - -article h1 { - margin-top: 0; -} -*/ \ No newline at end of file diff --git a/src/assets/styles/style.css b/src/assets/styles/style.css index 8cabb30..fb01d61 100644 --- a/src/assets/styles/style.css +++ b/src/assets/styles/style.css @@ -3,10 +3,10 @@ --article-w: 800px; --main-w: calc(1200px - 2rem); --img-offset: -5ch; - --accent: red; --background: floralwhite; --text: black; --accent: orange; + --gap: 2rem; font-size: 11px; } @@ -44,3 +44,36 @@ body { display: inline-block; } } + +.sample { + border-radius: 20px; + display: inline-flex; + gap: .25rem; + padding: 4px; + background-color: lightgrey; + transition: .2s linera; + cursor: pointer; + align-items: center; +} + +.sample .icon { + display: inline-block; + width: 12px; + height: 12px; +} + +.sample:not([active]) .pause { + display: none; +} +.sample[active] .play { + display: none; +} +.sample label { + line-height: 100%; +} + + + +.sample[active], .sample:hover { + background-color: var(--accent); +} diff --git a/src/assets/styles/typography.css b/src/assets/styles/typography.css index a3e8558..10b98ff 100644 --- a/src/assets/styles/typography.css +++ b/src/assets/styles/typography.css @@ -27,6 +27,15 @@ h2, h3 { line-height: 125%; } + +header.sm h2 { + font-weight: normal; +} + +article header h2 { + font-weight:normal; +} + h3 { } article { @@ -53,9 +62,7 @@ figure { margin: 2rem 0; } article img { - border: 1px solid red; max-width: 100%; - } ins { font-family: monospace; @@ -83,6 +90,7 @@ ins::before { } sup:has(li), article li:has(.footnote-back), +aside, figcaption, .footnote { font-family: monospace; font-size: 80%; @@ -96,6 +104,8 @@ sup li p, article li:has(.footnote-back) p { margin-top: 0; } + + p { break-inside: avoid; } \ No newline at end of file diff --git a/src/content/chapters/3-recipes.md b/src/content/chapters/3-recipes.md index 2a78ab0..e5f147c 100644 --- a/src/content/chapters/3-recipes.md +++ b/src/content/chapters/3-recipes.md @@ -16,3 +16,10 @@ Rule #17: If it sounds good and doesn’t smoke, don’t worry if you don’t un {{ show grid recipes}} + +How to Build a Paper Circuit PCB + +Paper circuits use thick paper or cardboard as a base instead of traditional fiberglass PCBs. The conductive traces are made with copper tape, aluminum foil, or conductive ink. Inspired by Ciat-Lonbarde’s designs, this method allows for flexible, handmade circuits that are easy to modify and repair. + +To make a paper PCB, start with a sturdy sheet of cardstock. Print or draw the circuit layout onto the surface. Lay down copper tape along the traced paths, ensuring clean connections at intersections. If using aluminum foil, glue it down with conductive adhesive or attach components with eyelets. Soldering directly onto paper is possible but requires low heat and quick contact to avoid burning. For durability, add a layer of clear tape over the traces to prevent oxidation. Finally, secure components with tape or conductive paint, creating a rugged yet flexible circuit ready for experimentation. + diff --git a/src/content/recipes/SingleTransistorOsc/BOM.csv b/src/content/recipes/SingleTransistorOsc/BOM.csv new file mode 100644 index 0000000..697dce8 --- /dev/null +++ b/src/content/recipes/SingleTransistorOsc/BOM.csv @@ -0,0 +1,7 @@ +"Reference","Value","Datasheet","Footprint","Qty","DNP" +"BT1,BT2,BT3","Battery","~","TerminalBlock:TerminalBlock_bornier-2_P5.08mm","3","" +"C1,C2","10uF","","Capacitor_SMD:CP_Elec_4x5.3","2","" +"J1","+V","~","MountingHole:MountingHole_2.2mm_M2_DIN965_Pad","1","" +"J2","GND","~","MountingHole:MountingHole_2.2mm_M2_DIN965_Pad","1","" +"J3","-V","~","MountingHole:MountingHole_2.2mm_M2_DIN965_Pad","1","" +"R1,R2","10","","PCM_4ms_Resistor:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_Horizontal","2","" diff --git a/src/content/recipes/SingleTransistorOsc/PaperCircuit.svg b/src/content/recipes/SingleTransistorOsc/PaperCircuit.svg new file mode 100644 index 0000000..bb59979 --- /dev/null +++ b/src/content/recipes/SingleTransistorOsc/PaperCircuit.svg @@ -0,0 +1,413 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/content/recipes/SingleTransistorOsc/index.md b/src/content/recipes/SingleTransistorOsc/index.md new file mode 100644 index 0000000..4eee704 --- /dev/null +++ b/src/content/recipes/SingleTransistorOsc/index.md @@ -0,0 +1,32 @@ +--- +title: Single Transistor Oscillator +BOM: + - "2x 10uF Capacitor" + - "x 10Ohm Resistor" + - "2x 9V Battery & Clips" +pcb: "/recipes/SingleTransistorOsc/PaperCircuit.svg" +--- + +This circuit converts a 9V power source into a stable 5V output, suitable for powering low-voltage circuits like microcontrollers, sensors, and small audio devices. It ensures a clean, regulated voltage with minimal noise, preventing fluctuations that could interfere with sound circuits. + +Instructions: + +Prepare Components: Gather all components and ensure they match the schematic. + +Place the 7805 Regulator: Position the 7805 with its flat side facing you. The left pin is input (9V), the middle pin is ground, and the right pin is output (5V). + +Add Capacitors: Connect a 10µF capacitor between the input pin and ground, and another between the output pin and ground. These smooth out voltage fluctuations. + +Install the Diode: Place the 1N4007 in series with the power input to prevent accidental reverse polarity damage. + +Connect Power: Attach a 9V battery clip or a DC jack to the input. + +Test Output: Use a multimeter to verify that the output is a stable 5V. + +Mount on PCB or Paper Circuit: If using a PCB, solder components as per the schematic. If using a paper circuit, glue aluminum or copper tape for traces and attach components using conductive paint or wire bridges. + +Final Check: Before connecting sensitive circuits, double-check polarity and voltage output to avoid damage. + +```{.include +BOM.csv +``` \ No newline at end of file diff --git a/src/content/recipes/power-supply.md b/src/content/recipes/power-supply.md deleted file mode 100644 index 7d7f06c..0000000 --- a/src/content/recipes/power-supply.md +++ /dev/null @@ -1,4 +0,0 @@ ---- -title: Power Supply ---- - diff --git a/src/content/recipes/power-supply/BOM.csv b/src/content/recipes/power-supply/BOM.csv new file mode 100644 index 0000000..697dce8 --- /dev/null +++ b/src/content/recipes/power-supply/BOM.csv @@ -0,0 +1,7 @@ +"Reference","Value","Datasheet","Footprint","Qty","DNP" +"BT1,BT2,BT3","Battery","~","TerminalBlock:TerminalBlock_bornier-2_P5.08mm","3","" +"C1,C2","10uF","","Capacitor_SMD:CP_Elec_4x5.3","2","" +"J1","+V","~","MountingHole:MountingHole_2.2mm_M2_DIN965_Pad","1","" +"J2","GND","~","MountingHole:MountingHole_2.2mm_M2_DIN965_Pad","1","" +"J3","-V","~","MountingHole:MountingHole_2.2mm_M2_DIN965_Pad","1","" +"R1,R2","10","","PCM_4ms_Resistor:R_Axial_DIN0207_L6.3mm_D2.5mm_P7.62mm_Horizontal","2","" diff --git a/src/content/recipes/power-supply/PaperCircuit.png b/src/content/recipes/power-supply/PaperCircuit.png new file mode 100644 index 0000000..bbe80d0 Binary files /dev/null and b/src/content/recipes/power-supply/PaperCircuit.png differ diff --git a/src/content/recipes/power-supply/PaperCircuit.svg b/src/content/recipes/power-supply/PaperCircuit.svg new file mode 100644 index 0000000..93801de --- /dev/null +++ b/src/content/recipes/power-supply/PaperCircuit.svg @@ -0,0 +1,824 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/content/recipes/power-supply/index.md b/src/content/recipes/power-supply/index.md new file mode 100644 index 0000000..cde0c72 --- /dev/null +++ b/src/content/recipes/power-supply/index.md @@ -0,0 +1,29 @@ +--- +title: Power Supply +BOMTable: true +shortDescription: + "This circuit converts a 9V power source " +BOM: + - type: Capacitor + count: 2 + value: "10uF" + - type: Resistor + count: 2 + value: "10Ω" + - type: Misc + label: "2x 9V battery clips" +pcb: "/recipes/power-supply/PaperCircuit.svg" +sample: "/recipes/power-supply/sample.mp3" +--- + +This circuit converts a 9V power source into a stable 5V output, suitable for powering low-voltage circuits like microcontrollers, sensors, and small audio devices. It ensures a clean, regulated voltage with minimal noise, preventing fluctuations that could interfere with sound circuits. + +![drawing](/recipes/power-supply/photo.jpeg) + +Instructions: + +Prepare Components[^what-is]: Gather all components and ensure they match the schematic. + +[^what-is]: what really is a component anyways./ + +Place the 7805 Regulator: Position the 7805 with its flat side facing you. The left pin is input (9V), the middle pin is ground, and the right pin is output (5V). \ No newline at end of file diff --git a/src/content/recipes/power-supply/photo.jpeg b/src/content/recipes/power-supply/photo.jpeg new file mode 100644 index 0000000..e352c75 Binary files /dev/null and b/src/content/recipes/power-supply/photo.jpeg differ diff --git a/src/content/recipes/power-supply/sample.WAV b/src/content/recipes/power-supply/sample.WAV new file mode 100755 index 0000000..9c78a6a Binary files /dev/null and b/src/content/recipes/power-supply/sample.WAV differ diff --git a/src/content/recipes/power-supply/sample.mp3 b/src/content/recipes/power-supply/sample.mp3 new file mode 100644 index 0000000..eff8778 Binary files /dev/null and b/src/content/recipes/power-supply/sample.mp3 differ diff --git a/src/content/recipes/single-transistor-oscillator-prev.md b/src/content/recipes/single-transistor-oscillator-prev.md new file mode 100644 index 0000000..3be4c66 --- /dev/null +++ b/src/content/recipes/single-transistor-oscillator-prev.md @@ -0,0 +1,47 @@ +--- + +title: A single transistor Oscillator +description: This is the description +--- + +Transistors are used often used when making sound circuits. The oscillators I am aware of usually combine transistor with some sort of a chip, to create a fast frequency. This specific oscillator however, only uses one transistor. + +_I could talk about the history of electronic music and transistors here, but at the moment I do not think this should happen_ + +Since this schematic uses only a couple of components, I think this recipe could actually be combined with the rc-filter recipe. + +## Schematic + +![Schematic of the Single Transistor Oscillator](http://www.seekic.com/uploadfile/ic-circuit/s201357212933141.jpg) + +## Components + +- 1 Transistor _I need to figure out if transistors are interchangable_ +- 1 Resistor +- A speaker +- A battery +- A Capacitor + +The size of the capacitor and the resistor decide upon the frequency of the pitch. + +## Notes while making the circuit + +- First time i've tried building this circuit, it did not work. Since, I've found a book[^transistor-book] that might be of use when I would like to do more with transistors. + +I suspect that salvaging IC's will be slightly more difficult, which is why i've been focussing on transistors, but ye, if i cant get the simplest circuit to work, maybe I should step a way from the suspisions and see what i'll find. + +[^transistor-book]: Turner, R. P. (1957). Transistor circuits. GERNSBACK LIBRARY INC. https://tubes.mit.edu/6S917/_static/2024/resources/turner_transistor_circuits.pdf + +Additionally, i've learned from Ash that crystals and transistors could be used to make radios! + +Turns out, this circuit above is actually called the "Relaxation oscillator". The wikipedia description is actually pretty visual: "It consists of an energy-storing element (a capacitor or, more rarely, an inductor) and a nonlinear switching device (a latch, Schmitt trigger, or negative resistance element) connected in a feedback loop.[22][23] " + +There are various relaxation circuits: + +- Using the 555 timer IC +- Using an op-amp! https://upload.wikimedia.org/wikipedia/commons/thumb/1/15/OpAmpHystereticOscillator.svg/440px-OpAmpHystereticOscillator.svg.png + +Then there are also "RC Oscillators" https://en.wikipedia.org/wiki/RC_oscillator + +AGain no luck with this schematic.... +I'll try my luck with a 555 timer circuit now. diff --git a/src/templates/base.jinja b/src/templates/base.jinja index 19526a3..34211b2 100644 --- a/src/templates/base.jinja +++ b/src/templates/base.jinja @@ -37,7 +37,29 @@ constructor(chunker, polisher, caller) { super(chunker, polisher, caller); } + afterRendered(pages) { + console.log(pages) + pages.forEach((p) => { + p.element.querySelectorAll(".sample").forEach((el) => { + el.addEventListener("click", function (e) { + const audioEl = e.currentTarget.querySelector("audio"); + if(audioEl.paused) { + document.querySelectorAll(".sample").forEach((s) => { + s.removeAttribute("active"); + s.querySelector("audio").pause(); + }) + e.currentTarget.setAttribute("active", true) + audioEl.play(); + } else { + audioEl.pause(); + e.currentTarget.removeAttribute("active") + } + }) +}) + }) + + } beforeParsed(content) { let count = 0; diff --git a/src/templates/index.jinja b/src/templates/index.jinja index 1277d5f..117956f 100644 --- a/src/templates/index.jinja +++ b/src/templates/index.jinja @@ -1,11 +1,10 @@ {% extends "base.jinja" %} +{% from 'snippets/page-detail.jinja' import showDetail with context %} +{% from 'snippets/page-circuit.jinja' import showCircuit with context %} {% block content %} - -
- {{ page['body'] | shortcode }} -
- + {{ showDetail(page) }} + {{ showCircuit(page) }} {% endblock %} {% block aside %} {% endblock %} \ No newline at end of file diff --git a/src/templates/pages:front.jinja b/src/templates/pages:front.jinja new file mode 100644 index 0000000..5c9227a --- /dev/null +++ b/src/templates/pages:front.jinja @@ -0,0 +1 @@ +pages \ No newline at end of file diff --git a/src/templates/post.jinja b/src/templates/post.jinja index 38c139b..a75a34c 100644 --- a/src/templates/post.jinja +++ b/src/templates/post.jinja @@ -1,10 +1,25 @@ {% extends "base.jinja" %} {% from 'snippets/inventory.jinja' import inventory with context %} - +{% from 'snippets/page-detail.jinja' import showDetail with context %} +{% from 'snippets/page-circuit.jinja' import showCircuit with context %} +{% from 'snippets/pages-nest.jinja' import showNestedPages with context %} +{% from 'snippets/page-cover.jinja' import showCoverPage with context %} {% block content %} +{% if page['front'] and page['nested'] %} + {{ showCoverPage(page, documents, "X") }} +{% endif %} + +{{ showDetail(page, false) }} +{{ showCircuit(page) }} + + +{{ showNestedPages(page, documents) }} + +{% if false %}
+

tempalte: post

{{page['title']}}

@@ -40,4 +55,5 @@ {{inventory("type", (page.type.capitalize() | slugify)) }} {% endif %} +{% endif %} {% endblock %} {% block aside %} {% endblock %} diff --git a/src/templates/snippets/page-circuit.jinja b/src/templates/snippets/page-circuit.jinja new file mode 100644 index 0000000..66afa27 --- /dev/null +++ b/src/templates/snippets/page-circuit.jinja @@ -0,0 +1,13 @@ +{%- macro showCircuit(content) -%} + {% if content['pcb'] %} +
+
+

Paper circuit: {{content['title']}}

+
+ +
+ +
+
+{% endif %} +{%- endmacro -%} diff --git a/src/templates/snippets/page-cover.jinja b/src/templates/snippets/page-cover.jinja new file mode 100644 index 0000000..399bddd --- /dev/null +++ b/src/templates/snippets/page-cover.jinja @@ -0,0 +1,24 @@ +{% from 'snippets/page-detail.jinja' import showDetail with context %} +{% from 'snippets/page-front.jinja' import pageFront with context %} +{% from 'snippets/page-circuit.jinja' import showCircuit with context %} + + +{%- macro showCoverPage(chapter, documents, index) -%} +
+ {{chapter['title']}} +
+
+ +

Chapter {{index}}

+

{{chapter['title']}}

+ + {% if chapter['nested'] %} + + + {% endif %} +
+{%- endmacro -%} \ No newline at end of file diff --git a/src/templates/snippets/page-detail.jinja b/src/templates/snippets/page-detail.jinja new file mode 100644 index 0000000..a638b41 --- /dev/null +++ b/src/templates/snippets/page-detail.jinja @@ -0,0 +1,84 @@ +{%- macro showDetail(content, parentChapter) -%} +
+
+ {{content['title']}} +
+ +
+ +

[[chapter title]]

+ +

{{content['title']}}

+ + {% if content['alsoKnownAs'] %} +
Also known as {{content['alsoKnownAs']}}
+ {% endif %} + + {% if content['shortDescription'] %} +

{{content['shortDescription'] }}

+ {% endif %} + + {% if content['sample'] %} +
+ + + + + + + + + + + +
+ + + {% endif %} +
+{% if content['BOM'] %} + +{% endif %} +
+ {{content['body']}} +
+ + {% if content['image'] %}{% endif %} {% if content['material'] %} + +
+
Material
+
{{content['material']}}
+
Usage
+
{{content['usage']}}
+
Typically found in
+
{{content['whereToFind']}}
+ {% if content['schematicSymbol'] %} +
Schematic symbol
+
+ {% endif %} +
+ {% endif %} +
+{%- endmacro -%} diff --git a/src/templates/snippets/page-front.jinja b/src/templates/snippets/page-front.jinja new file mode 100644 index 0000000..a7f81ba --- /dev/null +++ b/src/templates/snippets/page-front.jinja @@ -0,0 +1,30 @@ +{%- macro showFront(content) -%} +
+
+ {{detail['title']}} +
+
+

{{detail['title']}}

+
Also known as {{detail['alsoKnownAs']}}
+
+ + {% if detail['image'] %}{% endif %} + +
+
Material
+
{{detail['material']}}
+
Usage
+
{{detail['usage']}}
+
Typically found in
+
{{detail['whereToFind']}}
+ {% if detail['schematicSymbol'] %} +
Schematic symbol
+
+ {% endif %} +
+ + + {{detail['body']}} + +
+ {%- endmacro -%} diff --git a/src/templates/snippets/pages-nest.jinja b/src/templates/snippets/pages-nest.jinja new file mode 100644 index 0000000..b417f87 --- /dev/null +++ b/src/templates/snippets/pages-nest.jinja @@ -0,0 +1,14 @@ +{% from 'snippets/page-detail.jinja' import showDetail with context %} +{% from 'snippets/page-front.jinja' import pageFront with context %} +{% from 'snippets/page-circuit.jinja' import showCircuit with context %} + + +{%- macro showNestedPages(chapter, documents) -%} + {% if chapter['nested']%} +
{{ documents[chapter['nested']]|length }} 
+ {% for nest in documents[chapter['nested']] %} + {{ showDetail(nest, chapter) }} + {{ showCircuit(nest) }} + {% endfor %} + {% endif %} +{%- endmacro -%} \ No newline at end of file diff --git a/src/templates/thesis.jinja b/src/templates/thesis.jinja index c3fb3bc..dbd74e0 100644 --- a/src/templates/thesis.jinja +++ b/src/templates/thesis.jinja @@ -1,7 +1,15 @@ +{% from 'snippets/page-detail.jinja' import showDetail with context %} +{% from 'snippets/page-front.jinja' import pageFront with context %} +{% from 'snippets/page-circuit.jinja' import showCircuit with context %} +{% from 'snippets/pages-nest.jinja' import showNestedPages with context %} + +%} +{% from 'snippets/page-cover.jinja' import showCoverPage with context %} + {% extends "base.jinja" %} {% block content %} -
+
{{documents["meta"]["now"]}} {{page['title']}} @@ -21,74 +29,27 @@
-{% for result in documents['chapters'] %} -
+ {% for chapter in documents['chapters'] %} +
- {% if result['front'] %} -
- {{result['title']}} -
-
- -

Chapter {{loop.index0}}

-

{{result['title']}}

- - {% if result['nested'] %} - -
    - {% for nest in documents[result['nested']] %} -
  • {{nest['title']}} + (pagenr/link)

  • - {% endfor %} -
+ {% if chapter['front'] %} + {{ showCoverPage(chapter, documents, loop.inex0) }} {% endif %} -
- {% endif %} -
- {% if not result['front'] %} -
- {{result['title']}} -
- {% endif %} -
-

{{result['title']}}

-
- {{result['body'] | shortcode}} -
-
- -{% if result['nested']%} - {% for nest in documents[result['nested']] %} - -
-
- {{nest['title']}} +
+ {% if not chapter['front'] %} +
+ {{chapter['title']}}
+ {% endif %}
-

{{nest['title']}}

-
Also known as {{nest['alsoKnownAs']}}
+

{{chapter['title']}}

+ {{chapter['body'] | shortcode}} +
+
- {% if nest['image'] %}{% endif %} + {{ showNestedPages(chapter, documents) }} -
-
Material
-
{{nest['material']}}
-
Usage
-
{{nest['usage']}}
-
Typically found in
-
{{nest['whereToFind']}}
- {% if nest['schematicSymbol'] %} -
Schematic symbol
-
- {% endif %} -
- - - {{nest['body']}} - -
- {% endfor %} - {% endif %} {% endfor %}