hgiesel / closet

The Web Framework for Flashcards
https://closetengine.com
GNU General Public License v3.0
65 stars 6 forks source link

Update not Loading Closet js #33

Closed TowelSniffer closed 3 years ago

TowelSniffer commented 4 years ago

after the latest update, only the closet setup script seems to be loaded by asset manager, not the closet script itself.

hgiesel commented 4 years ago

This is the intended behavior. The user script now loads the closet script asynchronously, which you can see here:

https://github.com/hgiesel/closet/blob/8e231ea73e27b2a626f89c0d5bdea7ed1db05cd6/anki/web/user.js#L9)

Concerning the script in Asset Manager: If you open it, you should see, that it says "loose". You can safely delete it, as it is no longer necessary.

Additionally, the Anki Persistence is no longer a requirement for Closet to work, as I incorporated the logic into the Closet main code.

This increases performance a lot, where as before basically it continuously waited 100ms to check whether the closet script loaded.

TowelSniffer commented 4 years ago

Hi, where i'm getting confused is I'm getting this error which I can see using AnkiWebView Inspector.

image

hgiesel commented 4 years ago

Hm, weird. Can you try typing import('./__closet.js') or import('/__closet.js') into the inspector. Also, what platform are you on?

At this point, I'm thinking of rolling back the update...

TowelSniffer commented 4 years ago

The error occurs on windows, and my cards don't work on android either.

image

hgiesel commented 4 years ago

I just uploaded a new version, could you try updating it?

And in case it still does not work, could you look into the media folder of your Anki collection (called collection.media), and check for the file __closet.js?

TowelSniffer commented 4 years ago

I tried and I still seem to get the same error, and the file is in my media folder.

hgiesel commented 4 years ago

Okay, I don't really know how to go from here. Next week I'll have a Windows computer to make Windows-specific debugging. In the mean time, I can offer you to keep using the old version. Download this zip, rename the file from .zip to .ankiaddon (GitHub doesn't allow uploading files with file endings it doesn't know), and install it.

You can safely uninstall Closet For Anki and install this version instead, without loosing data.

TowelSniffer commented 4 years ago

Hey man thank you for this. I feel like I'm overlooking something if you can't replicate this because issue as it happens on all my devices including ankidroid.

hgiesel commented 4 years ago

Maybe a last thing you could try (in case you haven't changed back yet) is to execute:

fetch('./__closet.js').then(response => response.blob()).then(console.log)

What I get as a result is Blob {size: 93267, type: "application/javascript"}.

TowelSniffer commented 4 years ago

yeah so I'm getting Blob {size: 93267, type: "text/plain"} for that

hgiesel commented 4 years ago

Ok, so this solves this mystery: for some reason the webview in Anki on Windows doesn't recognize the file ending in .js as a javascript file, but rather as "plain text" file.

There's nothing you can do here, but also nothing that I can do. This is actually a bug in Anki.... I'll have to send a PR to Anki itself to fix it. However if it doesn't work on AnkiDroid either, they'd also have to fix it.

lonelyspirit commented 4 years ago

Hi, it seems like I have this same issue. Is there any workaround for now? Thank you.

TowelSniffer commented 4 years ago

Okay, I don't really know how to go from here. Next week I'll have a Windows computer to make Windows-specific debugging. In the mean time, I can offer you to keep using the old version. Download this zip, rename the file from .zip to .ankiaddon (GitHub doesn't allow uploading files with file endings it doesn't know), and install it.

You can safely uninstall Closet For Anki and install this version instead, without loosing data.

The workaround is downloading the old version in that link

lonelyspirit commented 4 years ago

Thank you. after installing, I do run into a problem when try to "Write to template" in Asset manager. Is there any step I need to do? Following is the debug info.

Debug info: Anki 2.1.35 (84dcaa86) Python 3.8.0 Qt 5.14.2 PyQt 5.14.2 Platform: Windows 10 Flags: frz=True ao=True sv=2 Add-ons, last update check: 2020-11-10 22:04:25

Caught exception: Traceback (most recent call last): File "C:\Users\david\AppData\Roaming\Anki2\addons21\656021484\gui_config\config.py", line 56, in writeBackCurrentSetting write_media(self.modelId, script_data) File "C:\Users\david\AppData\Roaming\Anki2\addons21\656021484\src\media_writer.py", line 25, in write_media mw.col.media.write_data(script[0], script[1].encode()) File "anki\media.py", line 108, in write_data File "anki\rsbackend_gen.py", line 197, in add_media_file File "anki\rsbackend.py", line 267, in _run_command anki.rsbackend.IOError: IOError { info: "Os { code: 3, kind: NotFound, message: \"The system cannot find the path specified.\" }" }

TowelSniffer commented 4 years ago

I'm not the addon author so i'm not sure with bug fixing but that link works for me, Have you deleted the other closet version so that you dont have two installed?

lonelyspirit commented 4 years ago

yes I deleted the web-installed one and then install from this link and I get this error.

hgiesel commented 4 years ago

Hey @lonelyspirit , it seems at some point I was unsubscribed from this thread, which is why I didn't get a notification!

Go into the Asset Manager menu, and make sure, that all of the list items have "Into Template" as their Insertion Position. This should fix it.

lonelyspirit commented 4 years ago

Thank you @hgiesel , the error disappeared. However, it still cant get closet to work. Not sure how to troubleshoot this. If it is too much of work, maybe I just have to wait and see if the original problem with the .js file is fix. Thank you.

hgiesel commented 4 years ago

Sure. This problem should already be fixable in the next Anki version, which is already in its second beta. Then we can try again.

hgiesel commented 3 years ago

This is kind of work-around should be no longer necessary since Anki 2.1.36