ShoroukAziz / Beautify-Anki

An Anki addon that attempts to give Anki's deck browser and deck overview pages a material design look.

Home Page:http://beautify-anki.shorouk.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The top bar where browse, stats, etc; are supposed to be only shows %s.

PedroCI opened this issue · comments

Before posting, please verify that you've done the following

  • read the "before you install instructions" and disabled all the known conflicted add-ons.
  • You've looked through previous issues to see if someone else had the same problem.

Describe the bug
The top bar where browse, stats, etc; are supposed to be only shows %s.

Screenshots
image

Contex (please complete the following information):

  • OS: Windows
  • Anki Version 2.1.57
  • screen Resolution 1366 x 768

Additional context
In your Anki
go to help > About > Copy Debug Log and paste it between the following backticks

    
    Anki 2.1.57 (6b7d372c) Python 3.9.15 Qt 6.4.2 PyQt 6.4.0
    Platform: Windows-10-10.0.22621
    Flags: frz=True ao=True sv=2
    Add-ons, last update check: 2023-02-21 21:04:07
    
    
    ===Add-ons (active)===
    (add-on provided name [Add-on folder, installed at, version, is config changed])
    '' ['Beautify Anki', 0, 'None', '']
    AnkiConnect ['2055492159', 2022-09-18T21:11, 'None', '']
    Kanji Grid ['909972618', 2019-01-09T19:40, 'None', '']
    Migaku Kanji GOD ['Migaku Kanji GOD', 0, 'None', mod]
    Review Heatmap ['1771074083', 2022-06-29T22:43, 'None', '']
    True Retention ['613684242', 2017-11-19T17:43, 'None', '']
    
    ===IDs of active AnkiWeb add-ons===
    1771074083 2055492159 613684242 909972618
    
    ===Add-ons (inactive)===
    (add-on provided name [Add-on folder, installed at, version, is config changed])
    

commented

I would like to know that too

It appears Anki 2.1.57 implemented new code for the Top toolbar. I installed 2.1.56 and got the toolbar back. Unfortunately it isn't a pretty toolbar, but I have addons that break further back I go.

I'm not super savvy with Python, but I do know deck_browser.py has a <nav> tag with the %s in question. If we could extract {toolbar_content} into it I think it might work?
I should note that toolbar_content is def in Anki's toolbar.py in the draw function
Commit dif between 2.1.57 and 2.1.56
firefox_2023-04-08_18-12-07
line 344 -> beautify-anki/deck_browser.py
image

I can confirm that the toolbar is missing on my version of Anki as well

has anyone tried it with the new version of anki?

hey, I updated to Anki version 2.1.63 Qt6 and ran into this issue as well. starting based on @Barthol-io's findings, I think I managed to fix it, albeit in a spaghetti code style, since my experience with Python is almost non-existent.

Toolbar._body = """
<div style="font-size: 12px; text-align: {THEME[topbar-position]}; background-color: {THEME[topbar-color]}" width="100%">
""".format(THEME=THEME)

toolbar_content = "<div>{toolbar_content}</div>"
end_div = "</div>"

Toolbar._body = Toolbar._body + toolbar_content + end_div

in my extension files, this was on line 340 from beautify-anki/deck_browser.py.

so if anyone wants to try it out, just replace the 2nd snippet from Barthol with the stuff above.

for context, I ended up splitting the div because if I tried to apply the .format() to everything, including the {toolbar_content}, it would throw some error about the toolbar not being loaded yet, and I don't know what sort of callback/conditional would be needed to only run this code after the toolbar_content was actually available. tried to mess a bit with the __init__.py file as well, but that didn't go anywhere, so I figure this fix will have to suffice for now.

lastly, seeing how this repo has stopped being updated, did anyone else make a different one that's maintained so we could make a PR?

hey, I updated to Anki version 2.1.63 Qt6 and ran into this issue as well. starting based on @Barthol-io's findings, I think I managed to fix it, albeit in a spaghetti code style, since my experience with Python is almost non-existent.

Toolbar._body = """
<div style="font-size: 12px; text-align: {THEME[topbar-position]}; background-color: {THEME[topbar-color]}" width="100%">
""".format(THEME=THEME)

toolbar_content = "<div>{toolbar_content}</div>"
end_div = "</div>"

Toolbar._body = Toolbar._body + toolbar_content + end_div

in my extension files, this was on line 340 from beautify-anki/deck_browser.py.

so if anyone wants to try it out, just replace the 2nd snippet from Barthol with the stuff above.

for context, I ended up splitting the div because if I tried to apply the .format() to everything, including the {toolbar_content}, it would throw some error about the toolbar not being loaded yet, and I don't know what sort of callback/conditional would be needed to only run this code after the toolbar_content was actually available. tried to mess a bit with the __init__.py file as well, but that didn't go anywhere, so I figure this fix will have to suffice for now.

lastly, seeing how this repo has stopped being updated, did anyone else make a different one that's maintained so we could make a PR?

Screenshot (50)
Thank you, it worked! Is there a way to get rid of that white line?

glad to hear that!

I have the white line too, it was reported in issue #66 and it was supposed to be fixed in PR #69, but since the project is not being updated, the PR was closed.

I tried to copy the changed file from that PR (user_files/assets/css/bootstrap.min.css), and it did fix the white line, but it also changed some other things regarding the formatting, which I didn't like, so I didn't keep the changes. if you wanna try it out, I'd recommend keeping a backup of your current file.

Someone else took care of this addon and it solved all the above problems.
https://ankiweb.net/shared/info/1116770498
Is it related to this?
#69

oh right, I saw the new addon at some point, but I didn't test it out yet.

and yeah, the white line issue is related to #69.

@ROOMBON thanks bro for the information