You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Footer with quickstart links and GitHub source links
607
609
- Responsive design with Tailwind CSS
@@ -616,6 +618,118 @@ The interactive features are implemented in JavaScript (location varies by theme
616
618
617
619
> **Note**: JavaScript implementation details are theme-specific and not covered in this specification.
618
620
621
+
#### BinderHub Integration ("Run in Browser" Link)
622
+
623
+
**Purpose**: Provide interactive Jupyter notebook environment for running examples
624
+
625
+
**Feature Description**:
626
+
627
+
The code example boxes can display a "Run this example in the browser" link that launches the example in a BinderHub-powered Jupyter notebook environment. This link appears in the top bar of the example box, next to the three-dot menu icon.
628
+
629
+
**Conditional Display**:
630
+
- Only shown if the example has a `binderId` value in its metadata
631
+
- If no `binderId` exists, the link is not rendered (no placeholder, no broken link)
632
+
- The `binderId` is language-specific, so different languages in the same example set may have different BinderHub links
633
+
- BinderHub uses Jupyter notebooks which can run code in multiple languages (Python, Node.js, Java, etc.)
The link should be placed in the top bar of the example box, alongside the existing menu icon. The exact HTML structure depends on the theme, but conceptually:
681
+
682
+
```html
683
+
<divclass="example-top-bar">
684
+
<!-- Language selector -->
685
+
<select>...</select>
686
+
687
+
<!-- BinderHub link (conditional) -->
688
+
{{ if $binderId }}
689
+
<ahref="{{ $binderUrl }}"
690
+
target="_blank"
691
+
rel="noopener noreferrer"
692
+
class="binder-link"
693
+
title="Run this example in an interactive Jupyter notebook">
694
+
Run this example in the browser
695
+
</a>
696
+
{{ end }}
697
+
698
+
<!-- Menu icon -->
699
+
<buttonclass="menu-icon">...</button>
700
+
</div>
701
+
```
702
+
703
+
**4. Styling considerations**:
704
+
705
+
- Link should be visually distinct but not overwhelming
706
+
- Should work on mobile devices (may need to be icon-only on small screens)
707
+
- Should indicate it opens in a new tab/window
708
+
- Consider adding a BinderHub icon for visual recognition
709
+
710
+
**Data Flow**:
711
+
712
+
1.**Build time**: Python scripts extract `BINDER_ID` from source files → store in `data/examples.json`
713
+
2.**Hugo build**: Template reads `binderId` from `$.Site.Data.examples[exampleSet][language].binderId`
714
+
3.**Template logic**: If `binderId` exists, construct URL and render link
715
+
4.**Runtime**: User clicks link → opens BinderHub in new tab
716
+
717
+
**Important Notes**:
718
+
719
+
-**Language-specific**: Each language in an example set can have its own `binderId`
720
+
-**Multi-language support**: BinderHub uses Jupyter notebooks which can execute code in multiple languages (Python, Node.js, Java, etc.) through language kernels
721
+
-**Notebook filename is constant**: Always use `demo.ipynb` - the BinderHub launcher repository handles routing to the correct example
722
+
-**URL encoding**: The `?urlpath=%2Fdoc%2Ftree%2Fdemo.ipynb` part is URL-encoded (`%2F` = `/`)
723
+
-**External dependency**: Requires the `redis/binder-launchers` repository to be properly configured with the commit referenced by `binderId`
724
+
725
+
**Relationship to Manual Links**:
726
+
727
+
Some documentation pages may have manual BinderHub links in the markdown content (e.g., "You can try this code out in a Jupyter notebook on Binder"). The automated link in the example box serves the same purpose but is:
728
+
- Automatically generated from metadata
729
+
- Consistently placed across all examples
730
+
- Easier to maintain (no manual URL construction in markdown)
If you want to enable the "Run in browser" link for an example:
1052
+
1053
+
**Step 1: Create or update the BinderHub launcher**:
1054
+
1055
+
The `redis/binder-launchers` repository contains Jupyter notebooks for each example. Jupyter notebooks can run code in multiple languages (Python, Node.js, Java, etc.) through language kernels. You need to:
1056
+
1. Create a notebook file (e.g., `demo.ipynb`) that runs your example in the appropriate language
1057
+
2. Ensure the necessary language kernel is configured in the BinderHub environment
1058
+
3. Commit and push to the `redis/binder-launchers` repository
1059
+
4. Note the commit SHA (40-character hexadecimal hash)
1060
+
1061
+
**Step 2: Add BINDER_ID to your example**:
1062
+
1063
+
Add the `BINDER_ID` marker as the second line of your example file (after `EXAMPLE:`):
0 commit comments