diff --git a/en_chapters/frontpage.html b/en_chapters/frontpage.html index 98e4e02..eb357b7 100644 --- a/en_chapters/frontpage.html +++ b/en_chapters/frontpage.html @@ -216,6 +216,7 @@ a {

Machine Learning Systems: Design and Implementation

The first open-source book to comprehensively cover machine learning systems

Star

+ diff --git a/static/frontpage.html b/static/frontpage.html index 2db5ba9..53094ea 100644 --- a/static/frontpage.html +++ b/static/frontpage.html @@ -201,6 +201,7 @@ a {

《机器学习系统:设计和实现》

做世界上第一本全面讲述机器学习系统知识的开源书籍

Star

+ @@ -477,4 +478,3 @@ for (i = 0; i < coll.length; i++) { - diff --git a/tests/test_prepare_mdbook.py b/tests/test_prepare_mdbook.py index cbdadcf..69973df 100644 --- a/tests/test_prepare_mdbook.py +++ b/tests/test_prepare_mdbook.py @@ -131,7 +131,7 @@ Reference :cite:`smith2024`. encoding="utf-8", ) (static_dir / "frontpage.html").write_text( - "
frontpage
\n", + "

STAR

\n\n
frontpage
\n", encoding="utf-8", ) @@ -143,9 +143,14 @@ Reference :cite:`smith2024`. frontpage_switch_href="cn/", ) + self.assertIn('class="openmlsys-frontpage-switch-row"', rewritten) self.assertIn('class="openmlsys-frontpage-switch"', rewritten) self.assertIn('href="cn/"', rewritten) self.assertIn(">中文", rewritten) + self.assertLess( + rewritten.index('class="star-slot"'), + rewritten.index('class="openmlsys-frontpage-switch-row"'), + ) def test_rewrite_markdown_prefers_book_local_frontpage_file(self) -> None: with tempfile.TemporaryDirectory() as tmpdir: @@ -185,6 +190,8 @@ Reference :cite:`smith2024`. self.assertNotIn("Chinese fallback", rewritten) self.assertIn("background: transparent !important;", rewritten) self.assertIn("padding: 0 !important;", rewritten) + self.assertIn("border-radius: 6px;", rewritten) + self.assertIn("background: #f6f8fa;", rewritten) def test_regular_page_does_not_render_frontpage_switch(self) -> None: with tempfile.TemporaryDirectory() as tmpdir: diff --git a/tests/test_prepare_mdbook_zh.py b/tests/test_prepare_mdbook_zh.py index e6a7e4c..bad32d2 100644 --- a/tests/test_prepare_mdbook_zh.py +++ b/tests/test_prepare_mdbook_zh.py @@ -202,6 +202,8 @@ missing .other { color: blue; } +

STAR

+
@@ -221,9 +223,14 @@ missing self.assertIn("static/image/logo.png", rewritten) self.assertIn("static/image/jinxuefeng.png", rewritten) self.assertIn("console.log('frontpage')", rewritten) + self.assertIn('class="openmlsys-frontpage-switch-row"', rewritten) self.assertIn('class="openmlsys-frontpage-switch"', rewritten) self.assertIn('href="../"', rewritten) self.assertIn(">English", rewritten) + self.assertLess( + rewritten.index('class="star-slot"'), + rewritten.index('class="openmlsys-frontpage-switch-row"'), + ) if __name__ == "__main__": diff --git a/tools/prepare_mdbook.py b/tools/prepare_mdbook.py index a90b4a7..894a4c3 100644 --- a/tools/prepare_mdbook.py +++ b/tools/prepare_mdbook.py @@ -21,36 +21,37 @@ TOC_PART_RE = re.compile(r"^#+\s+(.+?)\s*$") HEAD_TAG_RE = re.compile(r"", re.IGNORECASE) STYLE_BLOCK_RE = re.compile(r"", re.IGNORECASE | re.DOTALL) DEFAULT_BIBLIOGRAPHY_TITLE = "References" +FRONTPAGE_SWITCH_PLACEHOLDER = "" FRONTPAGE_LAYOUT_CSS = """