Skip to content

Commit 8426f4d

Browse files
Copilotmmcky
andcommitted
Fix redirect links in documentation
Co-authored-by: mmcky <8263752+mmcky@users.noreply.github.com>
1 parent 7e8356e commit 8426f4d

File tree

3 files changed

+349
-1
lines changed

3 files changed

+349
-1
lines changed

lectures/_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ sphinx:
3030
html_favicon: _static/lectures-favicon.ico
3131
html_theme: quantecon_book_theme
3232
html_static_path: ['_static']
33+
templates_path: ['_templates']
3334
html_theme_options:
3435
authors:
3536
- name: Thomas J. Sargent

lectures/_templates/layout.html

Lines changed: 347 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,347 @@
1+
{%- extends "quantecon_book_theme/layout.html" %}
2+
3+
{# Override the TOC navigation block to fix the Jupyter Book link #}
4+
{% block content %}
5+
6+
<!-- Override QuantEcon theme colors -->
7+
{%- if not theme_quantecon_project %}
8+
<style>
9+
a {
10+
color: #313131;
11+
}
12+
a:hover {
13+
color: #313131;
14+
}
15+
a:visited {
16+
color: #111111;
17+
}
18+
19+
.main-index {
20+
#qe-page-author-links {
21+
border-bottom: 5px solid #313131;
22+
}
23+
}
24+
25+
.qe-page__header {
26+
border-bottom: 5px solid #313131;
27+
}
28+
29+
.qe-page__footer {
30+
border-top: 5px solid #313131;
31+
}
32+
33+
.toctree-wrapper {
34+
.caption-text {
35+
color: #111111
36+
}
37+
}
38+
</style>
39+
{%- endif %}
40+
41+
<span id="top"></span>
42+
43+
<div class="qe-wrapper">
44+
45+
<div class="qe-main">
46+
47+
<div class="qe-page" id={{pagename}}>
48+
49+
<div class="qe-page__toc">
50+
51+
<div class="inner">
52+
53+
{% set page_toc = generate_toc_html() %}
54+
55+
{%- if page_toc | length >= 1 %}
56+
<div class="qe-page__toc-header">
57+
On this page
58+
</div>
59+
{%- endif %}
60+
61+
62+
<nav id="bd-toc-nav" class="qe-page__toc-nav">
63+
{{ page_toc }}
64+
<p class="logo">
65+
{% if logo_url %}
66+
{% if theme_header_organisation_url %}
67+
<a href={{theme_header_organisation_url}}><img src="{{ pathto(logo_url, 1) }}" class="logo logo-img" alt="logo"></a>
68+
{% if theme_dark_logo %}
69+
<a href={{theme_header_organisation_url}}><img src="{{ pathto('_static/' + theme_dark_logo, 1) }}" class="dark-logo-img" alt="logo"></a>
70+
{% endif %}
71+
{% else %}
72+
<a href="{{ master_url }}"><img src="{{ pathto(logo_url, 1) }}" class="logo" alt="logo"></a>
73+
{% endif %}
74+
{% endif %}
75+
</p>
76+
77+
<p class="powered">Powered by <a href="https://jupyterbook.org/v1/">Jupyter Book</a></p>
78+
79+
</nav>
80+
81+
<div class="qe-page__toc-footer">
82+
{# prev/next buttons #}
83+
{% macro prev_next(prev, next, prev_title='', next_title='') %}
84+
{%- if next %}
85+
<p><a class='right-next' id="next-link" href="{{ next.link|e }}" title="{{ _('next page')}}"><strong>Next topic</strong><br>
86+
{{ next_title or next.title }}</a></p>
87+
{%- endif %}
88+
{%- if prev %}
89+
<p><a class='left-prev' id="prev-link" href="{{ prev.link|e }}" title="{{ _('previous page')}}"><strong>Previous topic</strong><br>
90+
{{ prev_title or prev.title }}</a></p>
91+
{%- endif %}
92+
{% endmacro %}
93+
<p><a href="#top"><strong>Back to top</strong></a></p>
94+
</div>
95+
96+
</div>
97+
98+
</div>
99+
100+
<div class="qe-page__header">
101+
102+
<div class="qe-page__header-copy">
103+
104+
<p class="qe-page__header-heading"><a href="{{ master_url }}">{{ docstitle | e }}</a></p>
105+
106+
<p class="qe-page__header-subheading">{{ pagetitle | e }}</p>
107+
108+
</div>
109+
<!-- length 2, since its a string and empty dict has length 2 - {} -->
110+
{%- if theme_authors | length > 0 %}
111+
<p class="qe-page__header-authors" font-size="{{theme_mainpage_author_fontsize}}">
112+
{% for author in theme_authors %}
113+
{% if loop.last and theme_authors|length >= 2 %}
114+
and <a href="{{ author.url }}" target="_blank"><span>{{ author.name }}</span></a>
115+
{% elif loop.first and theme_authors|length <= 2 %}
116+
<a href="{{ author.url }}" target="_blank"><span>{{ author.name }}</span></a>
117+
{% else %}
118+
<a href="{{ author.url }}" target="_blank"><span>{{ author.name }}</span></a>,
119+
{% endif %}
120+
{% endfor %}
121+
</p>
122+
{%- else %}
123+
<p class="qe-page__header-authors" font-size="{{theme_mainpage_author_fontsize}}">{{ author }}</p>
124+
{%- endif %}
125+
126+
127+
</div> <!-- .page__header -->
128+
129+
130+
131+
{% block docs_main %}
132+
<main class="qe-page__content" role="main">
133+
{% block docs_body %}
134+
<div>
135+
{% block body %} {% endblock %}
136+
</div>
137+
{% endblock %}
138+
</main> <!-- .page__content -->
139+
{% endblock %}
140+
141+
142+
<footer class="qe-page__footer">
143+
144+
<p><a href="https://creativecommons.org/licenses/by-sa/4.0/"><img src="https://licensebuttons.net/l/by-sa/4.0/80x15.png"></a></p>
145+
146+
<p>Creative Commons License &ndash; This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International.</p>
147+
148+
<p>A theme by <a href="https://quantecon.org">QuantEcon</a></p>
149+
150+
</footer> <!-- .page__footer -->
151+
152+
</div> <!-- .page -->
153+
154+
{% block docs_sidebar %}
155+
156+
{% if theme_persistent_sidebar is defined and theme_persistent_sidebar is sameas true %}
157+
<div class="qe-sidebar bd-sidebar inactive persistent" id="site-navigation">
158+
{%- else %}
159+
<div class="qe-sidebar bd-sidebar inactive" id="site-navigation">
160+
{%- endif %}
161+
162+
<div class="qe-sidebar__header">
163+
164+
165+
Contents
166+
167+
</div>
168+
169+
<nav class="qe-sidebar__nav" id="qe-sidebar-nav" aria-label="Main navigation">
170+
{{ sbt_generate_toctree_html(include_item_names=False, with_home_page=theme_home_page_in_toc) }}
171+
</nav>
172+
173+
<div class="qe-sidebar__footer">
174+
175+
</div>
176+
177+
</div> <!-- .sidebar -->
178+
{% endblock %}
179+
</div> <!-- .main -->
180+
181+
<div class="qe-toolbar">
182+
183+
<div class="qe-toolbar__inner">
184+
185+
<ul class="qe-toolbar__main">
186+
<li data-tippy-content="Table of Contents" class="btn__sidebar"><i data-feather="menu"></i></li>
187+
<li data-tippy-content="Home"><a href="{{ master_url }}"><i data-feather="home"></i></a></li>
188+
{%- if theme_quantecon_project %}
189+
<li class="btn__qelogo"><a href="{{theme_header_organisation_url}}" title="{{html_title}}"><span class="show-for-sr">{{ theme_header_organisation}}</span></a></li>
190+
{%- endif %}
191+
</ul>
192+
193+
<ul class="qe-toolbar__links">
194+
<li class="btn__search">
195+
<form action="{{ pathto('search') }}" method="get">
196+
<input type="search" class="form-control" name="q" id="search-input" placeholder="{{ theme_search_bar_text }}" aria-label="{{ theme_search_bar_text }}" autocomplete="off" accesskey="k">
197+
<i data-feather="search" id="search-icon"></i>
198+
</form>
199+
</li>
200+
<li data-tippy-content="Fullscreen" class="btn__fullscreen"><i data-feather="maximize"></i></li>
201+
<li data-tippy-content="Increase font size" class="btn__plus"><i data-feather="plus-circle"></i></li>
202+
<li data-tippy-content="Decrease font size" class="btn__minus"><i data-feather="minus-circle"></i></li>
203+
<li data-tippy-content="Change contrast" class="btn__contrast"><i data-feather="sunset"></i></li>
204+
{%- if notebook_path %}
205+
<li data-tippy-content="Download Notebook"><a href="{{ notebook_path }}" download><i data-feather="download-cloud"></i></a></li>
206+
{%- endif %}
207+
{%- if theme_nb_repository_url %}
208+
<li class="settings-button" id="settingsButton"><div data-tippy-content="Launch Notebook"><i data-feather="play-circle"></i></div></li>
209+
{%- endif %}
210+
{%- if pdf_book_path %}
211+
<li class="download-pdf" id="downloadButton"><i data-feather="file"></i></li>
212+
{%- else %}
213+
<li data-tippy-content="Download PDF" onClick="window.print()"><i data-feather="file"></i></li>
214+
{%- endif %}
215+
<!--
216+
# Enable if looking for link to specific document hosted on GitHub
217+
<li data-tippy-content="View Source"><a target="_blank" href="{{ theme_repository_url }}{{github_sourcefolder}}/{{ sourcename }}" download><i data-feather="github"></i></a></li>
218+
-->
219+
<li data-tippy-content="View Source"><a target="_blank" href="{{ theme_repository_url }}" download><i data-feather="github"></i></a></li>
220+
</ul>
221+
222+
</div>
223+
224+
</div> <!-- .toolbar -->
225+
<div id="downloadPDFModal" style="display: none;">
226+
<ul class="pdf-options" style="display: block;">
227+
<li class="download-pdf-book" onClick="window.print()">
228+
<p>Lecture (PDF)</p>
229+
</li>
230+
<li class="download-pdf-file">
231+
<a href="{{ pdf_book_path }}" download><p>Book (PDF)</p></a>
232+
</li>
233+
</ul>
234+
</div>
235+
<div id="settingsModal" style="display: none;">
236+
<p class="modal-title"> Notebook Launcher </p>
237+
<div class="modal-desc">
238+
<p>
239+
Choose public or private cloud service for "Launch" button.
240+
</p>
241+
</div>
242+
<p class="modal-subtitle">Select a server</p>
243+
<ul class="modal-servers">
244+
<li class="active launcher-public">
245+
<span class="label">Public</span>
246+
<select id="launcher-public-input">
247+
{% for item in launch_buttons%}
248+
<option value="{{item.url}}">{{item.name}}</option>
249+
{% endfor %}
250+
</select>
251+
<i class="fas fa-check-circle"></i>
252+
</li>
253+
<li class="launcher-private">
254+
<span class="label">Private</span>
255+
<input type="text" id="launcher-private-input" data-repourl="{{theme_nb_repository_url}}" data-urlpath="{{jupyterhub_urlpath}}" data-branch={{repo_branch}}>
256+
<i class="fas fa-check-circle"></i>
257+
</li>
258+
</ul>
259+
<p class="launch"><a href="{{default_server}}" id="advancedLaunchButton" target="_blank">Launch Notebook</a></p>
260+
<script>
261+
// QuantEcon Notebook Launcher
262+
const launcherTypeElements = document.querySelectorAll('#settingsModal .modal-servers li');
263+
// Highlight the server type if previous selection exists
264+
if (typeof localStorage.launcherType !== 'undefined') {
265+
for (var i = 0; i < launcherTypeElements.length; i++) {
266+
launcherTypeElements[i].classList.remove('active');
267+
if ( launcherTypeElements[i].classList.contains(localStorage.launcherType) ) {
268+
launcherTypeElements[i].classList.add('active');
269+
}
270+
}
271+
}
272+
// Highlight server type on click and set local storage value
273+
for (var i = 0; i < launcherTypeElements.length; i++) {
274+
launcherTypeElements[i].addEventListener('click', function() {
275+
for (var j = 0; j < launcherTypeElements.length; j++) {
276+
launcherTypeElements[j].classList.remove('active');
277+
}
278+
this.classList.add('active');
279+
if ( this.classList.contains('launcher-private') ) {
280+
localStorage.launcherType = 'launcher-private';
281+
} else if ( this.classList.contains('launcher-public') ) {
282+
localStorage.launcherType = 'launcher-public';
283+
}
284+
setLaunchServer();
285+
})
286+
}
287+
const launcherPublic = document.getElementById('launcher-public-input');
288+
const launcherPrivate = document.getElementById('launcher-private-input');
289+
const pageName = "{{pagename}}";
290+
const repoURL = "{{theme_nb_repository_url}}";
291+
const urlPath = "{{jupyterhub_urlpath}}";
292+
const branch = "{{repo_branch}}"
293+
const launchNotebookLink = document.getElementById('advancedLaunchButton');
294+
295+
// Highlight public server option if previous selection exists
296+
if (typeof localStorage.launcherPublic !== 'undefined') {
297+
launcherPublic.value = localStorage.launcherPublic;
298+
}
299+
// Update local storage upon public server selection
300+
launcherPublic.addEventListener('change', (event) => {
301+
setLaunchServer();
302+
});
303+
// Populate private server input if previous entry exists
304+
if (typeof localStorage.launcherPrivate !== 'undefined') {
305+
launcherPrivate.value = localStorage.launcherPrivate;
306+
}
307+
// Update local storage when a private server is entered
308+
launcherPrivate.addEventListener('input', (event) => {
309+
setLaunchServer();
310+
});
311+
312+
// Function to update the "Launch Notebook" link href
313+
function setLaunchServer() {
314+
launchNotebookLink.removeAttribute("style")
315+
if ( localStorage.launcherType == 'launcher-private' ) {
316+
let repoPrefix = "/user-redirect/git-pull?repo=" + repoURL + "&branch=" + branch + "&urlpath=" + urlPath;
317+
launcherPrivateValue = launcherPrivate.value
318+
if (!launcherPrivateValue) {
319+
launchNotebookLink.removeAttribute("href")
320+
launchNotebookLink.style.background = "grey"
321+
return
322+
}
323+
localStorage.launcherPrivate = launcherPrivateValue;
324+
privateServer = localStorage.launcherPrivate.replace(/\/$/, "")
325+
if (!privateServer.includes("http")) {
326+
privateServer = "http://" + privateServer
327+
}
328+
launchNotebookLinkURL = privateServer + repoPrefix;
329+
} else if ( localStorage.launcherType == 'launcher-public' ) {
330+
launcherPublicValue = launcherPublic.options[launcherPublic.selectedIndex].value;
331+
localStorage.launcherPublic = launcherPublicValue;
332+
launchNotebookLinkURL = localStorage.launcherPublic;
333+
}
334+
if (launchNotebookLinkURL) launchNotebookLink.href = launchNotebookLinkURL;
335+
}
336+
// Check if user has previously selected a server
337+
if ( (typeof localStorage.launcherPrivate !== 'undefined') || (typeof localStorage.launcherPublic !== 'undefined') ) {
338+
setLaunchServer();
339+
}
340+
</script>
341+
342+
</div>
343+
344+
</div> <!-- .wrapper-->
345+
{%- block scripts_end %}
346+
{%- endblock %}
347+
{%- endblock %}

lectures/workspace.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ lectures.
337337

338338
There are two main flavors of Git
339339

340-
1. the plain vanilla [command line Git](https://git-scm.com/downloads) version
340+
1. the plain vanilla [command line Git](https://git-scm.com/downloads/) version
341341
2. the various point-and-click GUI versions
342342
* See, for example, the [GitHub version](https://github.com/apps/desktop) or Git GUI integrated into your IDE.
343343

0 commit comments

Comments
 (0)