|
1 | | -"""Attach temporary assembly-video players to the matching tutorial pages.""" |
| 1 | +"""Attach assembly videos and reference galleries to module tutorial pages.""" |
2 | 2 |
|
3 | 3 | from __future__ import annotations |
4 | 4 |
|
|
42 | 42 | } |
43 | 43 |
|
44 | 44 |
|
| 45 | +GALLERIES = { |
| 46 | + "build/assembly-tutorials/modules/mod-frm-assembly": [ |
| 47 | + ("/images/BB_V3_Material.jpg", "BEATBox V3 parts prepared for assembly", "V3 parts and materials"), |
| 48 | + ("/images/real-build-setup.jpg", "BEATBox enclosure during assembly", "Enclosure assembly"), |
| 49 | + ("/images/BB_Full-1.jpg", "Completed BEATBox viewed from the front", "Completed enclosure — front"), |
| 50 | + ("/images/BB_Full-2.jpg", "Completed BEATBox viewed from the side", "Completed enclosure — side"), |
| 51 | + ], |
| 52 | + "build/assembly-tutorials/modules/mod-bmt-assembly": [ |
| 53 | + ("/images/BB-TIPS_Using-forceps-to-help-inserts.jpg", "Using forceps to position a threaded insert", "Positioning threaded inserts"), |
| 54 | + ("/images/BB_water-holder.jpg", "Completed BEATBox water bottle holder", "Completed water bottle mount"), |
| 55 | + ], |
| 56 | + "build/assembly-tutorials/modules/mod-fdr-aseembly": [ |
| 57 | + ("/videos/buidling_gifs/BB_Feeder_material.tiny.gif", "Feeder parts laid out before assembly", "Prepare the feeder parts"), |
| 58 | + ("/images/Feeder/BB_Feeder-1.jpg", "First stage of the feeder housing assembly", "Prepare the housing — 1"), |
| 59 | + ("/images/Feeder/BB_Feeder-2.jpg", "Second stage of the feeder housing assembly", "Prepare the housing — 2"), |
| 60 | + ("/images/Feeder/BB_Feeder_IR-1.jpg", "First stage of feeder IR board installation", "Install the IR board — 1"), |
| 61 | + ("/images/Feeder/BB_Feeder_IR-2.jpg", "Second stage of feeder IR board installation", "Install the IR board — 2"), |
| 62 | + ("/images/Feeder/BB_Feeder_IR-3.jpg", "Third stage of feeder IR board installation", "Install the IR board — 3"), |
| 63 | + ("/images/Feeder/BB_Feeder_IR-4.jpg", "Fourth stage of feeder IR board installation", "Install the IR board — 4"), |
| 64 | + ("/images/Feeder/BB_Feeder_IR-5.jpg", "Fifth stage of feeder IR board installation", "Install the IR board — 5"), |
| 65 | + ("/images/Feeder/BB_Feeder_cable.jpg", "Feeder cable routed through the housing", "Route the IR cable"), |
| 66 | + ("/videos/buidling_gifs/BB_Feeder-motor.tiny.gif", "Feeder stepper motor installation", "Install the stepper motor"), |
| 67 | + ("/images/Feeder/BB_Feeder_PCB_color-code.jpg", "Feeder PCB terminal wire color reference", "Connect the motor wires"), |
| 68 | + ("/videos/buidling_gifs/BB_Feeder-Assembly-motor-cables-to-PCB.tiny.gif", "Connecting the feeder motor cables to the PCB", "Wire the motor to the PCB"), |
| 69 | + ("/images/Feeder.jpg", "Completed BEATBox feeder viewed from the front", "Completed feeder — front"), |
| 70 | + ("/images/Feeder_side.jpg", "Completed BEATBox feeder viewed from the side", "Completed feeder — side"), |
| 71 | + ], |
| 72 | + "build/assembly-tutorials/modules/mod-lgt": [ |
| 73 | + ("/images/Light_bottom.jpg", "Bottom face of the assembled BEATBox light ring", "PCB, housing, and connector"), |
| 74 | + ("/images/Light_top.jpg", "Top face of the assembled BEATBox light ring", "Completed light ring and diffuser"), |
| 75 | + ], |
| 76 | + "build/assembly-tutorials/modules/mod-pbg-assembly": [ |
| 77 | + ("/images/Tunnel-Passage-Corridor/BB_Tunnel_PCB.jpg", "Photobeam gate controller and IR circuit boards", "Prepare the electronics"), |
| 78 | + ("/images/Tunnel-Passage-Corridor/BB_Tunnel_IR-PCG-with-cables.jpg", "Photobeam gate IR boards connected with cables", "Connect the IR boards"), |
| 79 | + ("/images/Tunnel-Passage-Corridor/BB_Tunnel_PCG-assembly.jpg", "Circuit boards being installed in the photobeam passage", "Install and route the electronics"), |
| 80 | + ("/images/Tunnel-Passage-Corridor/BB_Tunnel_PCG-assembled.jpg", "Assembled photobeam gate electronics", "Check the assembled electronics"), |
| 81 | + ("/images/Tunnel.jpg", "Completed BEATBox photobeam gate", "Completed photobeam gate"), |
| 82 | + ], |
| 83 | + "build/assembly-tutorials/modules/mod-scr-assembly": [ |
| 84 | + ("/images/Screens/BB_Screen-1.jpg", "First stage of BEATBox screen module assembly", "Screen assembly — 1"), |
| 85 | + ("/images/Screens/BB_Screen-2.jpg", "Second stage of BEATBox screen module assembly", "Screen assembly — 2"), |
| 86 | + ("/images/Screens/BB_Screen-3.jpg", "Third stage of BEATBox screen module assembly", "Screen assembly — 3"), |
| 87 | + ("/images/Screens/BB_Screen-4.jpg", "Fourth stage of BEATBox screen module assembly", "Screen assembly — 4"), |
| 88 | + ("/images/Screens/BB_Screen-5.jpg", "Fifth stage of BEATBox screen module assembly", "Screen assembly — 5"), |
| 89 | + ("/images/Screens/BB_Screen-6.jpg", "Sixth stage of BEATBox screen module assembly", "Screen assembly — 6"), |
| 90 | + ("/images/Screens/BB_Screen_inside.jpg", "Interior of the BEATBox screen module", "Interior layout"), |
| 91 | + ("/images/Screens/BB_Screen_long-cables.jpg", "Long cables routed inside the BEATBox screen module", "Cable routing"), |
| 92 | + ("/images/Screens/BB_Screens-inside-view.jpg", "First inside view of the assembled screen module", "Inside view — 1"), |
| 93 | + ("/images/Screens/BB_Screens_Inside-view-2.jpg", "Second inside view of the assembled screen module", "Inside view — 2"), |
| 94 | + ("/images/electronics/photo-circuit-ecrans1.jpg", "First screen electronics connection reference", "Screen electronics — 1"), |
| 95 | + ("/images/electronics/photo-circuit-ecrans2.jpg", "Second screen electronics connection reference", "Screen electronics — 2"), |
| 96 | + ], |
| 97 | +} |
| 98 | + |
| 99 | + |
45 | 100 | def _append_video(app: Sphinx, doctree: nodes.document, docname: str) -> None: |
46 | 101 | video = VIDEOS.get(docname) |
47 | 102 | if video is None or app.builder.format != "html": |
@@ -95,8 +150,44 @@ def _append_video(app: Sphinx, doctree: nodes.document, docname: str) -> None: |
95 | 150 | doctree += section |
96 | 151 |
|
97 | 152 |
|
| 153 | +def _append_gallery(app: Sphinx, doctree: nodes.document, docname: str) -> None: |
| 154 | + gallery = GALLERIES.get(docname) |
| 155 | + if gallery is None or app.builder.format != "html": |
| 156 | + return |
| 157 | + |
| 158 | + section = nodes.section(ids=["assembly-gallery"]) |
| 159 | + section += nodes.title(text="Assembly gallery") |
| 160 | + section += nodes.paragraph( |
| 161 | + text=( |
| 162 | + "Use these reference images alongside the numbered instructions above. " |
| 163 | + "They are ordered to follow the main stages of the assembly. Select an " |
| 164 | + "image to open the full-size version." |
| 165 | + ) |
| 166 | + ) |
| 167 | + |
| 168 | + figures = [] |
| 169 | + for image_url, alt_text, caption in gallery: |
| 170 | + escaped_url = escape(image_url, quote=True) |
| 171 | + figures.append( |
| 172 | + '<figure class="assembly-gallery-item">' |
| 173 | + f'<a href="{escaped_url}" target="_blank" rel="noopener noreferrer">' |
| 174 | + f'<img src="{escaped_url}" alt="{escape(alt_text, quote=True)}" loading="lazy">' |
| 175 | + "</a>" |
| 176 | + f"<figcaption>{escape(caption)}</figcaption>" |
| 177 | + "</figure>" |
| 178 | + ) |
| 179 | + |
| 180 | + section += nodes.raw( |
| 181 | + "", |
| 182 | + '<div class="assembly-gallery">' + "".join(figures) + "</div>", |
| 183 | + format="html", |
| 184 | + ) |
| 185 | + doctree += section |
| 186 | + |
| 187 | + |
98 | 188 | def setup(app: Sphinx) -> dict[str, object]: |
99 | 189 | app.connect("doctree-resolved", _append_video) |
| 190 | + app.connect("doctree-resolved", _append_gallery) |
100 | 191 | return { |
101 | 192 | "version": "1.0", |
102 | 193 | "parallel_read_safe": True, |
|
0 commit comments