Skip to content

Commit

Permalink
Implement dark mode for projects
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Apr 3, 2024
1 parent 3d04532 commit 9631e39
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions jaraco/site/projects.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
import textwrap

import cherrypy
from jaraco.develop import git, filters


style = textwrap.dedent("""
@media (prefers-color-scheme: dark) {
body {
background-color: #444;
color: white;
}
}
""")


class Projects:
@cherrypy.expose
def index(self):
projects = filter(filters.Tag('not fork'), git.projects())
doc = '<br>\n'.join(map(self.make_badge, projects))
return f'<html><body>\n{doc}\n</body></html>'
return f'<html><head><style>{style}</style></head><body>\n{doc}\n</body></html>'

def make_badge(self, project):
url = git.resolve(project + '/')
badge = url.join('actions/workflows/main.yml/badge.svg').resolved
workflow = url.join('actions?query=workflow%3A%22tests%22').resolved
return f'<div><a href="{workflow}"><img src="{badge}"> {project}</a></div>'
return f'<div><a href="{workflow}"><img src="{badge}"></a> {project}</div>'
1 change: 1 addition & 0 deletions newsfragments/+e667826e.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Implement dark mode for projects.

0 comments on commit 9631e39

Please sign in to comment.