mirror of
https://github.com/openmlsys/openmlsys-zh.git
synced 2026-04-01 18:01:13 +08:00
fix: correct english homepage frontpage
Add an English-specific frontpage template so the default homepage no longer falls back to the Chinese frontpage, and clear homepage image backgrounds in the frontpage wrapper CSS.
This commit is contained in:
479
en_chapters/frontpage.html
Normal file
479
en_chapters/frontpage.html
Normal file
@@ -0,0 +1,479 @@
|
||||
<head>
|
||||
<style>
|
||||
h1, .side-doc-outline {
|
||||
display: none;
|
||||
}
|
||||
.document .page-content {
|
||||
width: 100%;
|
||||
}
|
||||
h2, h3, h4 {
|
||||
letter-spacing: 2px;
|
||||
}
|
||||
.mdl-grid {
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
text-align: center;
|
||||
padding: 150px 0 0 0;
|
||||
}
|
||||
h2.toc {
|
||||
padding: 150px 0 0 0;
|
||||
}
|
||||
|
||||
.header h2 {
|
||||
font-size: 2rem;
|
||||
padding-bottom: 35px;
|
||||
}
|
||||
|
||||
.header p {
|
||||
font-size: 1.25rem;
|
||||
letter-spacing: 0px;
|
||||
line-height: 1.5rempx;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.header .mdl-button {
|
||||
margin: 0px 10px;
|
||||
letter-spacing: 2px;
|
||||
font-size: 16px;
|
||||
margin: 1rem 1.5rem;
|
||||
height: 40px;
|
||||
width: 120px;
|
||||
}
|
||||
.author-item {
|
||||
max-width: 300px;
|
||||
}
|
||||
.author-item h3 {
|
||||
padding-top: 25px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
.author-item img {
|
||||
border-radius: 50%;
|
||||
width: 120px;
|
||||
}
|
||||
.authors h4 {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.authors h2 {
|
||||
padding-bottom: 18px;
|
||||
}
|
||||
|
||||
.running-item {
|
||||
max-width: 300px;
|
||||
}
|
||||
|
||||
.running-item img {
|
||||
height: 40px;
|
||||
}
|
||||
|
||||
.running-item p {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.running.mdl-grid {
|
||||
padding: 20px 0 0 0;
|
||||
}
|
||||
|
||||
.logos img {
|
||||
display: inline;
|
||||
max-height: 70px;
|
||||
max-width: 100px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
.logos {
|
||||
padding-top: 1em;
|
||||
padding-bottom: 2em;
|
||||
}
|
||||
|
||||
.logos .mdl-grid {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.features .logos .mdl-cell {
|
||||
padding: 10px 0;
|
||||
}
|
||||
|
||||
|
||||
.features .mdl-cell {
|
||||
padding: 0 36px;
|
||||
}
|
||||
.features h2, .features-2 h2 {
|
||||
padding-bottom: 24px;
|
||||
}
|
||||
.features-2 p {
|
||||
padding: 0 200px;
|
||||
}
|
||||
.institute.mdl-grid {
|
||||
padding: 24px;
|
||||
}
|
||||
.institute .mdl-cell {
|
||||
text-align: left;
|
||||
padding: 0;
|
||||
}
|
||||
#logoimg {
|
||||
padding-top: 0em;
|
||||
padding-bottom: 2em;
|
||||
width: 100%;
|
||||
}
|
||||
#map {
|
||||
height: 400px;
|
||||
width: 100%;
|
||||
}
|
||||
#mapimg {
|
||||
width: 100%;
|
||||
}
|
||||
a {
|
||||
font-size: normal;
|
||||
}
|
||||
|
||||
@media (max-width: 1000px) {
|
||||
.mdl-grid, h2.toc {
|
||||
padding: 50px 0 0 0;
|
||||
}
|
||||
.header img, .features-2 img {
|
||||
max-width: 300px;
|
||||
}
|
||||
.header .mdl-cell--1-col {
|
||||
display: none;
|
||||
}
|
||||
.features img {
|
||||
max-width: 350px;
|
||||
}
|
||||
.features-2 p {
|
||||
padding: 0 24px;
|
||||
}
|
||||
.features .mdl-cell {
|
||||
padding: 0 8px;
|
||||
}
|
||||
}
|
||||
|
||||
.collapsible {
|
||||
background-color: #EEE;
|
||||
color: black;
|
||||
cursor: pointer;
|
||||
padding: 6px;
|
||||
width: 100%;
|
||||
border: none;
|
||||
text-align: left;
|
||||
outline: none;
|
||||
font-size: 16px;
|
||||
}
|
||||
.collapsible-active, .collapsible:hover {
|
||||
background-color: #DDD;
|
||||
}
|
||||
.expansion {
|
||||
padding: 3px 6px;
|
||||
max-height: 0;
|
||||
overflow: hidden;
|
||||
transition: max-height 0.2s ease-out;
|
||||
}
|
||||
|
||||
.cover h2 {
|
||||
font-size: 34px;
|
||||
margin-bottom: 0px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
|
||||
.cover p.version {
|
||||
font-size: 18px;
|
||||
padding: 0 0 9px 0;
|
||||
|
||||
}
|
||||
|
||||
.cover p {
|
||||
margin: 0;
|
||||
padding: 20px 0 0px 0;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<div class="mdl-grid header">
|
||||
<div class="mdl-cell mdl-cell--3-col">
|
||||
<img src="_images/logo.png" class="img-fluid" alt="">
|
||||
</div>
|
||||
<div class="mdl-cell mdl-cell--1-col">
|
||||
</div>
|
||||
<div class="mdl-cell mdl-cell--5-col mdl-cell--middle cover">
|
||||
<h2 class="mdl-color-text--primary">Machine Learning Systems: Design and Implementation</h2>
|
||||
<p>The first open-source book to comprehensively cover machine learning systems</p>
|
||||
<p><a class="github-button" href="https://github.com/openmlsys/openmlsys-zh" data-icon="octicon-star" data-size="large" data-show-count="true" aria-label="Star openmlsys/openmlsys-zh on GitHub">Star</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class = "authors mdl-grid" id = "author" >
|
||||
<div class = "author-group-title mdl-cell mdl-cell--12-col mdl-cell--top">
|
||||
<h2>Core Authors</h2>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/1136455?v=4"/>
|
||||
<h3><a href="https://github.com/luomai">Mai Luo</a></h3>
|
||||
<p>University of Edinburgh</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/10713581?v=4"/>
|
||||
<h3><a href="https://github.com/zsdonghao">Hao Dong</a></h3>
|
||||
<p>Peking University, Peng Cheng Laboratory</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="./_images/jinxuefeng.png"/>
|
||||
<h3>Xuefeng Jin</h3>
|
||||
<p>MindSpore Architect</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/90942796?v=4"/>
|
||||
<h3><a href="https://github.com/ganzhiliang">Zhiliang Gan</a></h3>
|
||||
<p>MindSpore Architect</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class = "author-group-title mdl-cell mdl-cell--12-col mdl-cell--top">
|
||||
<h2>Chapter Authors</h2>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/21324004?v=4"/>
|
||||
<h3><a href="https://github.com/Laicheng0830">Cheng Lai</a></h3>
|
||||
<p>Peng Cheng Laboratory</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/73918561?v=4"/>
|
||||
<h3><a href="https://github.com/hanjr92">Jiarong Han</a></h3>
|
||||
<p>Peng Cheng Laboratory</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/31511840?v=4"/>
|
||||
<h3><a href="https://github.com/future-xy">Yao Fu</a></h3>
|
||||
<p>University of Edinburgh</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/39682259?v=4"/>
|
||||
<h3><a href="https://github.com/eedalong">Xiulong Yuan</a></h3>
|
||||
<p>Tsinghua University</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/22659010?v=4"/>
|
||||
<h3><a href="https://github.com/quantumiracle">Zihan Ding</a></h3>
|
||||
<p>Princeton University</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/25477396?v=4"/>
|
||||
<h3><a href="https://github.com/Jiankai-Sun">Jiankai Sun</a></h3>
|
||||
<p>Stanford University</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/34192321?v=4"/>
|
||||
<h3><a href="https://liaopeiyuan.com/">Peiyuan Liao</a></h3>
|
||||
<p>Carnegie Mellon University</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/91313652?v=4"/>
|
||||
<h3><a href="https://github.com/Went-Liang">Wenteng Liang</a></h3>
|
||||
<p>Beijing University of Posts and Telecommunications</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/49299030?v=4"/>
|
||||
<h3><a href="https://github.com/JieRen98">Jie Ren</a></h3>
|
||||
<p>University of Edinburgh</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="./_images/wanghanchen.png"/>
|
||||
<h3><a href="https://github.com/hansen7">Hanchen Wang</a></h3>
|
||||
<p>University of Cambridge</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/10811136?v=4"/>
|
||||
<h3><a href="https://github.com/ds1231h">Pei Mu</a></h3>
|
||||
<p>University of Edinburgh</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="./_images/zhangqinghua.png"/>
|
||||
<h3>Qinghua Zhang</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/18185293?v=4"/>
|
||||
<h3>Zhibo Liang</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/20573763?v=4"/>
|
||||
<h3>Jianfeng Yu</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/5563661?v=4"/>
|
||||
<h3>Jinjin Chu</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/68210792?v=4"/>
|
||||
<h3>Fubi Cai</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="./_images/zhangrenwei.png"/>
|
||||
<h3>Renwei Zhang</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/2681256?v=4"/>
|
||||
<h3>Chao Liu</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/5202350?v=4"/>
|
||||
<h3>Gang Chen</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/61316635?v=4"/>
|
||||
<h3>Mingqi Li</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/36526001?v=4"/>
|
||||
<h3>Gangqiang Han</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/55628940?v=4"/>
|
||||
<h3>Yehui Tang</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="./_images/zhaizhiqiang.png"/>
|
||||
<h3>Zhiqiang Zhai</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="./_images/wutiancheng.png"/>
|
||||
<h3>Tiancheng Wu</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/59854698?v=4"/>
|
||||
<h3>Xiaohui Li</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/20376974?v=4"/>
|
||||
<h3>Haoyang Li</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/17228522?v=4"/>
|
||||
<h3>Zhipeng Tan</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="https://avatars.githubusercontent.com/u/105415060?v=4"/>
|
||||
<h3>Shanni Li</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "mdl-cell mdl-cell--3-col mdl-cell--top">
|
||||
<div class="author-item">
|
||||
<img src="./_images/guozhijian.png"/>
|
||||
<h3>Zhijian Guo</h3>
|
||||
<p>Huawei Engineer</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class = "author-group-title mdl-cell mdl-cell--12-col mdl-cell--top">
|
||||
<h3> Thanks to our <a href="https://github.com/openmlsys/openmlsys-zh/graphs/contributors">contributors</a></h3>
|
||||
<h3> and everyone who reported valuable <a href="https://github.com/openmlsys/openmlsys-zh/issues">errata and suggestions</a></h3>
|
||||
<h4><a href="https://github.com/openmlsys/openmlsys-zh">Contribute to this Book</a></h4>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<h2 class="toc">Table of Contents</h2>
|
||||
|
||||
<script>
|
||||
var coll = document.getElementsByClassName("collapsible");
|
||||
var i;
|
||||
for (i = 0; i < coll.length; i++) {
|
||||
coll[i].addEventListener("click", function() {
|
||||
this.classList.toggle("collapsible-active");
|
||||
var content = this.nextElementSibling;
|
||||
if (content.style.maxHeight){
|
||||
content.style.maxHeight = null;
|
||||
} else {
|
||||
content.style.maxHeight = content.scrollHeight + "px";
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<script async defer src="https://buttons.github.io/buttons.js"></script>
|
||||
@@ -144,6 +144,45 @@ Reference :cite:`smith2024`.
|
||||
self.assertIn('href="cn/"', rewritten)
|
||||
self.assertIn(">中文</a>", rewritten)
|
||||
|
||||
def test_rewrite_markdown_prefers_book_local_frontpage_file(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
root = Path(tmpdir)
|
||||
source = root / "en_chapters"
|
||||
static_dir = source / "static"
|
||||
source.mkdir()
|
||||
static_dir.mkdir()
|
||||
|
||||
index = source / "index.md"
|
||||
index.write_text(
|
||||
"""# Home
|
||||
|
||||
```eval_rst
|
||||
.. raw:: html
|
||||
:file: frontpage.html
|
||||
```
|
||||
""",
|
||||
encoding="utf-8",
|
||||
)
|
||||
(source / "frontpage.html").write_text(
|
||||
"<div class=\"hero\">English frontpage</div>\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
(static_dir / "frontpage.html").write_text(
|
||||
"<div class=\"hero\">Chinese fallback</div>\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
|
||||
rewritten = rewrite_markdown(
|
||||
index.read_text(encoding="utf-8"),
|
||||
index.resolve(),
|
||||
{index.resolve(): "Home"},
|
||||
)
|
||||
|
||||
self.assertIn("English frontpage", rewritten)
|
||||
self.assertNotIn("Chinese fallback", rewritten)
|
||||
self.assertIn("background: transparent !important;", rewritten)
|
||||
self.assertIn("padding: 0 !important;", rewritten)
|
||||
|
||||
def test_regular_page_does_not_render_frontpage_switch(self) -> None:
|
||||
with tempfile.TemporaryDirectory() as tmpdir:
|
||||
root = Path(tmpdir)
|
||||
|
||||
@@ -91,6 +91,8 @@ FRONTPAGE_LAYOUT_CSS = """
|
||||
.openmlsys-frontpage img {
|
||||
max-width: 100%;
|
||||
height: auto;
|
||||
background: transparent !important;
|
||||
padding: 0 !important;
|
||||
}
|
||||
#content,
|
||||
.content {
|
||||
|
||||
Reference in New Issue
Block a user