Skip to content

Commit db11c4c

Browse files
committed
Initial Commit v1.0.0
0 parents  commit db11c4c

File tree

9 files changed

+276
-0
lines changed

9 files changed

+276
-0
lines changed

.gitignore

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,155 @@
1+
### Python template
2+
# Byte-compiled / optimized / DLL files
3+
__pycache__/
4+
*.py[cod]
5+
*$py.class
6+
7+
# C extensions
8+
*.so
9+
10+
# Distribution / packaging
11+
.Python
12+
env/
13+
build/
14+
develop-eggs/
15+
dist/
16+
downloads/
17+
eggs/
18+
.eggs/
19+
lib/
20+
lib64/
21+
parts/
22+
sdist/
23+
var/
24+
*.egg-info/
25+
.installed.cfg
26+
*.egg
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*,cover
47+
.hypothesis/
48+
49+
# Translations
50+
*.mo
51+
*.pot
52+
53+
# Django stuff:
54+
*.log
55+
local_settings.py
56+
57+
# Flask stuff:
58+
instance/
59+
.webassets-cache
60+
61+
# Scrapy stuff:
62+
.scrapy
63+
64+
# Sphinx documentation
65+
docs/_build/
66+
67+
# PyBuilder
68+
target/
69+
70+
# IPython Notebook
71+
.ipynb_checkpoints
72+
73+
# pyenv
74+
.python-version
75+
76+
# celery beat schedule file
77+
celerybeat-schedule
78+
79+
# dotenv
80+
.env
81+
82+
# virtualenv
83+
venv/
84+
ENV/
85+
86+
# Spyder project settings
87+
.spyderproject
88+
89+
# Rope project settings
90+
.ropeproject
91+
### VirtualEnv template
92+
# Virtualenv
93+
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/
94+
.Python
95+
[Bb]in
96+
[Ii]nclude
97+
[Ll]ib
98+
[Ll]ib64
99+
[Ll]ocal
100+
[Ss]cripts
101+
pyvenv.cfg
102+
.venv
103+
pip-selfcheck.json
104+
105+
### JetBrains template
106+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
107+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
108+
109+
# User-specific stuff:
110+
.idea/workspace.xml
111+
.idea/tasks.xml
112+
.idea/dictionaries
113+
.idea/vcs.xml
114+
.idea/jsLibraryMappings.xml
115+
116+
# Sensitive or high-churn files:
117+
.idea/dataSources.ids
118+
.idea/dataSources.xml
119+
.idea/dataSources.local.xml
120+
.idea/sqlDataSources.xml
121+
.idea/dynamic.xml
122+
.idea/uiDesigner.xml
123+
124+
# Gradle:
125+
.idea/gradle.xml
126+
.idea/libraries
127+
128+
# Mongo Explorer plugin:
129+
.idea/mongoSettings.xml
130+
131+
.idea/
132+
133+
## File-based project format:
134+
*.iws
135+
136+
## Plugin-specific files:
137+
138+
# IntelliJ
139+
/out/
140+
141+
# mpeltonen/sbt-idea plugin
142+
.idea_modules/
143+
144+
# JIRA plugin
145+
atlassian-ide-plugin.xml
146+
147+
# Crashlytics plugin (for Android Studio and IntelliJ)
148+
com_crashlytics_export_strings.xml
149+
crashlytics.properties
150+
crashlytics-build.properties
151+
fabric.properties
152+
153+
### Anki
154+
src/*/meta.json
155+
src/*/manifest.json

LICENCE.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2021, Simon Kelly
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy
4+
of this software and associated documentation files (the "Software"), to deal
5+
in the Software without restriction, including without limitation the rights
6+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
copies of the Software, and to permit persons to whom the Software is
8+
furnished to do so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### Deck Browser CSS
2+
<a title="Release" href="https://github.com/simonkellly/deckbrowser-css/releases"><img src ="https://img.shields.io/github/release-pre/simonkellly/deckbrowser-css.svg?colorB=brightgreen"></a>
3+
4+
Addon to allow injecting additional css into the deck browser, or replace the original without modifying anki's files

addon.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"display_name": "Deck Browser CSS",
3+
"module_name": "deckbrowser_css",
4+
"repo_name": "deckbrowser-css",
5+
"ankiweb_id": "153779542",
6+
"author": "Simon Kelly",
7+
"contact": "https://github.com/simonkellly",
8+
"homepage": "https://github.com/simonkellly/deckbrowser-css",
9+
"copyright_start": 2021,
10+
"tags": "deck browser theme customization",
11+
"conflicts": [],
12+
"targets": [
13+
"anki21"
14+
],
15+
"min_anki_version": "2.1.22",
16+
"tested_anki_version": "2.1.49"
17+
}

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
aab

src/deckbrowser_css/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from . import themer

src/deckbrowser_css/config.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"cssPath": "/user_files/deckbrowser_injected.css",
3+
"overrideOriginal": false
4+
}

src/deckbrowser_css/themer.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import os
2+
3+
from aqt.webview import AnkiWebView
4+
from aqt import gui_hooks, mw
5+
from typing import Callable
6+
7+
originalSetHtml: Callable = AnkiWebView.setHtml
8+
config = mw.addonManager.getConfig(__name__)
9+
10+
11+
def enable_deckbrowser_css(*argv):
12+
AnkiWebView.setHtml = setHtml
13+
14+
15+
def setHtml(self: AnkiWebView, html: str) -> None:
16+
global originalSetHtml
17+
if config["overrideOriginal"]:
18+
html.replace(self.bundledCSS("css/deckbrowser.css"), "")
19+
20+
addon_dir = os.path.dirname(os.path.abspath(__file__))
21+
22+
with open(addon_dir + config["cssPath"]) as f:
23+
lines = "<style>\n" + f.read() + "\n</style>\n"
24+
idx = html.index("</head>")
25+
html = html[:idx] + lines + html[idx:]
26+
27+
originalSetHtml(self, html)
28+
AnkiWebView.setHtml = originalSetHtml
29+
30+
31+
gui_hooks.deck_browser_will_render_content.append(enable_deckbrowser_css)
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
tr {
2+
border-color: #00000000;
3+
border-spacing: 0;
4+
}
5+
6+
tr.deck td {
7+
border-bottom-color: #29292B;
8+
border-bottom: 0;
9+
}
10+
11+
tr.drag-hover td {
12+
border-bottom-color: #777;
13+
}
14+
15+
.current {
16+
background-color: #29292B00;
17+
}
18+
19+
center {
20+
padding-top: 15px;
21+
padding-bottom: 15px;
22+
}
23+
24+
table {
25+
padding: 25px;
26+
background: #68729455;
27+
border-radius: 20px;
28+
overflow: hidden;
29+
}
30+
31+
.night-mode .zero-count {
32+
color: #737070
33+
}
34+
35+
.heatmap {
36+
padding: 15px;
37+
background: #68729455;
38+
border-radius: 20px;
39+
overflow: hidden;
40+
}
41+
42+
.rh-container {
43+
padding: 15px;
44+
}

0 commit comments

Comments
 (0)