Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add metadata & PDF download link #86

Merged
merged 3 commits into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ jobs:
- name: linkcheck
# https://jupyterbook.org/en/stable/reference/cli.html
run: jupyter-book build --builder linkcheck --warningiserror --nitpick --keep-going .
env: {PYTHONPATH: .}
build:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -74,7 +73,6 @@ jobs:
book.tex
# insert PDF cover
curl -fsSLO https://static.premai.io/book/cover.pdf
env: {PYTHONPATH: .}
- uses: xu-cheng/latex-action@v3
with:
working_directory: _build/latex
Expand Down
10 changes: 6 additions & 4 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,13 @@ sphinx:
extra_extensions:
- sphinx_last_updated_by_git
- sphinx_subfigure
# custom (local *.py files)
- badges
- committers
- bibliography
local_extensions:
badges: .
committers: .
bibliography: .
prem_theme: .
config:
html_theme: prem_theme
myst_heading_anchors: 4
html_js_files:
- [https://analytics.prem.ninja/js/script.js, {defer: defer, data-domain: book.premai.io}]
Expand Down
6 changes: 6 additions & 0 deletions _static/download_pdf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
document.addEventListener('DOMContentLoaded', function(){
/// download whole book PDF
document.querySelectorAll('.btn-download-pdf-button').forEach(a => {
a.onclick = () => window.open("/state-of-open-source-ai.pdf");
});
});
6 changes: 3 additions & 3 deletions index.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ Spot something outdated or missing? Want to start a discussion? We welcome any o
- Or instead, manually set up your own Python environment:

```sh
pip install -r requirements.txt # setup
PYTHONPATH=. jupyter-book build --builder dirhtml --all . # build
python -m http.server -d _build/dirhtml # serve
pip install -r requirements.txt # setup
jupyter-book build --builder dirhtml --all . # build
python -m http.server -d _build/dirhtml # serve
```

````{admonition} alternative: live rebuilding & serving (experimental)
Expand Down
4 changes: 4 additions & 0 deletions prem_theme/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from os import path

def setup(app):
app.add_html_theme('prem_theme', path.abspath(path.dirname(__file__)))
21 changes: 21 additions & 0 deletions prem_theme/layout.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% extends "sphinx_book_theme/layout.html" %}
{% block extrahead %}
<meta property="og:site_name" content="The State of Open Source AI" />
<meta property="og:title" content="{{ title }}" />
<meta property="og:type" content="book" />
<meta property="og:image" content="https://static.premai.io/book/book-cover.jpg" />
<meta property="og:url" content="https://book.premai.io/state-of-open-source-ai/{{ '' if pagename == 'index' else pagename }}" />
<meta property="og:description" content="Clarity in the current fast-paced mess of Open Source innovation" />
<meta property="og:locale" content="en_GB" />
<meta property="og:book:author" content="Prem" />
{%- if last_updated %}
<meta property="og:book:release_date" content="{{ last_updated }}" />
{%- endif %}
<meta property="og:book:tag" content="open-source" />
<meta property="og:book:tag" content="AI" />
<meta property="og:book:tag" content="book" />
<meta property="og:book:tag" content="ML" />
<meta property="og:book:tag" content="MLOps" />
<meta property="og:book:tag" content="Jupyter-Book" />
{{ super() }}
{% endblock extrahead %}
2 changes: 2 additions & 0 deletions prem_theme/theme.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[theme]
inherit = sphinx_book_theme