Skip to content

Commit

Permalink
Merge pull request #92 from premAI-io/badges-doi-cron
Browse files Browse the repository at this point in the history
  • Loading branch information
casperdcl authored Oct 19, 2023
2 parents 882fcd6 + cb327e2 commit bf5cdc5
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 13 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# see https://github.com/actions/starter-workflows/blob/main/pages/jekyll.yml
name: site
on:
push:
workflow_dispatch:
push: {branches: [main], tags-ignore: ['**']}
pull_request:
schedule: [{cron: '0 10 * * 6'}] # M H d m w (Sat 10:00)
permissions:
# allow GITHUB_TOKEN to deploy to GitHub Pages
contents: read
Expand Down
2 changes: 1 addition & 1 deletion CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ authors:
- {given-names: Het, family-names: Trivedi}
- {given-names: Filippo, family-names: Pedrazzini, affiliation: Prem}
- {name: others, website: 'https://github.com/premAI-io/state-of-open-source-ai/graphs/contributors'}
#identifiers: [{type: doi, value: 10.1234/zenodo.TODO}]
identifiers: [{type: doi, value: 10.5281/zenodo.10023181}]
repository-code: https://github.com/premAI-io/state-of-open-source-ai
keywords: [open-source, AI, book, ML, MLOps, Jupyter-Book]
license-url: https://github.com/premAI-io/state-of-open-source-ai/blob/main/LICENCE # CC-BY-4.0 AND Apache-2.0
1 change: 1 addition & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ html:
parse:
myst_substitutions:
baseurl: http://localhost:8000
doi: 10.5281/zenodo.10023181
wip_chapter: |
This chapter is still being written & reviewed. Please do post links & discussion in the {{
'[<i class="fas fa-pencil-alt"></i> comments]({}-comments)'.format(env.docname) }} below, or {{
Expand Down
26 changes: 17 additions & 9 deletions badges.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
MyST usage (HTML only):
```{badges}
```{badges} https://mybook.site https://github.com/org/mybook
:doi: 10.5281.zenodo.12345678
```
"""
from docutils import nodes
Expand All @@ -22,33 +23,40 @@ class badges_node(nodes.General, nodes.Element):

def visit_badges_html(self, node):
self.body.append(
f"""<a href="{node['baseurl']}">
f"""<a href="{node['baseurl']}" target="_blank">
<img alt="site"
src="https://img.shields.io/badge/site-{node['baseurl'].replace('-', '--')}-orange" />
</a>""")
slug = '/'.join(node['repository_url'].split('/')[-2:])
self.body.append(
f"""<a href="{node['repository_url']}/graphs/contributors">
f"""<a href="{node['repository_url']}/graphs/contributors" target="_blank">
<img alt="last updated"
src="https://img.shields.io/github/last-commit/{slug}/main" />
src="https://img.shields.io/github/last-commit/{slug}/main?label=updated" />
</a>""")
self.body.append(
f"""<a href="{node['repository_url']}/pulse">
f"""<a href="{node['repository_url']}/pulse" target="_blank">
<img alt="activity"
src="https://img.shields.io/github/commit-activity/m/{slug}/main" />
src="https://img.shields.io/github/commit-activity/m/{slug}/main?label=commits" />
</a>""")
if node['doi']:
self.body.append(
f"""<a href="https://doi.org/{node['doi']}" target="_blank">
<img alt="doi"
src="https://img.shields.io/badge/doi-{node['doi']}-black" />
</a>""")


class Badges(Directive):
has_content = True
required_arguments = 2
optional_arguments = 0
optional_arguments = 1
final_argument_whitespace = True
option_spec = {'class': directives.class_option, 'name': directives.unchanged}
option_spec = {'doi': directives.unchanged}
_node = None

def run(self):
return [badges_node(baseurl=self.arguments[0], repository_url=self.arguments[1])]
return [badges_node(
baseurl=self.arguments[0], repository_url=self.arguments[1], doi=self.options.get('doi', None))]


def setup(app: Sphinx):
Expand Down
2 changes: 1 addition & 1 deletion index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# State of Open Source AI Book - 2023 Edition

{{ '```{badges} %s %s\n```' % (baseurl, env.config.html_theme_options.repository_url) }}
{{ '```{badges} %s %s\n:doi: %s\n```' % (baseurl, env.config.html_theme_options.repository_url, doi) }}

*Clarity in the current fast-paced mess of Open Source innovation {cite}`prem_stateofosai`*

Expand Down
1 change: 1 addition & 0 deletions references.bib
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ @book{prem_stateofosai
edition={First},
editor={{da Costa-Luis}, Casper},
year=2023,
doi={10.5281/zenodo.10023181},
url={https://book.premai.io/state-of-open-source-ai}
}
@manual{python,
Expand Down

0 comments on commit bf5cdc5

Please sign in to comment.