Commit graph

4656 commits

Author SHA1 Message Date
Damien Elmes
ed5103141a remove update-alternatives references
6b3d5998cc (commitcomment-40547278)
2020-07-13 13:55:18 +10:00
Damien Elmes
a7c3705d8c ensure sys crates work on older Macs 2020-07-13 13:35:09 +10:00
Damien Elmes
22a87a4f3b vendor coarsetime so we can get the use after free fix 2020-07-13 13:34:37 +10:00
Damien Elmes
c9807581f6 Merge pull request #685 from kelciour/synclog-last-line-scroll
Scroll media sync log to the last line
2020-07-13 13:01:48 +10:00
kelciour
6ca239a247 Scroll media sync log to the last line 2020-07-13 03:06:44 +03:00
Damien Elmes
9a509f5e42 roll back pyo3 for now
0.9 will spit out BorrowMut errors when two concurrent backend
commands are received with allow_threads. The collection mutex protects
most methods, but other attributes like the abort handle are not
protected, so this code may need to be reworked in the future. We
could wrap the entire backend in a mutex, but that means the
long-running syncing code will need to be changed to run in the
background instead.
2020-07-12 20:06:04 +10:00
Damien Elmes
bbc75cdf5d update rslib/rspy deps 2020-07-12 11:38:25 +10:00
Damien Elmes
4e1bc76596 mediasrv symlink fix
https://forums.ankiweb.net/t/anki-2-1-28-beta/629/39
2020-07-11 10:53:41 +10:00
Damien Elmes
dd2960c3e7 Merge pull request #682 from glutanimate/add-top-toolbar-did-redraw-hook
Add top_toolbar_did_redraw hook
2020-07-11 10:20:41 +10:00
Damien Elmes
bcc14bc18e one more attempt at fixing the problem by busting the cache 2020-07-11 09:09:49 +10:00
Glutanimate
ee8696cbf3 Add top_toolbar_did_redraw hook
Notifies add-ons of the top toolbar being redrawn
2020-07-10 17:38:40 +02:00
Damien Elmes
d35bc85ead is:review should include relearning cards
https://forums.ankiweb.net/t/anki-2-1-28-beta/629/36

This issue appears to have existed since the V2 scheduler was
introduced - the old Python search code was ignoring Relearn as well.
2020-07-09 11:07:50 +10:00
Damien Elmes
7302f0655c invalidate cache
in the hopes of fixing
https://github.com/ankitects/anki/runs/848327907
2020-07-08 14:34:23 +10:00
Damien Elmes
367a2d17ba show daily total as well in reviews graph 2020-07-08 14:07:10 +10:00
Damien Elmes
3d8babef39 fix overlapping ranges in histograms
It's bin.x0 <= x < bin.x1
2020-07-08 14:01:09 +10:00
Damien Elmes
1092b4388d another attempt at fixing review graph
This should correctly show today count in the 1 month/3 month graphs.
1+ year will have a very tiny bar, but the today count is not so
important at that range. I experimented with shifting the numbers
by one at the gathering stage (so -1 = today) - that makes today fit
in the previous bin, but means the bars no longer match the ticks.
2020-07-08 13:31:09 +10:00
Damien Elmes
6e07ab64af formatting 2020-07-07 13:28:30 +10:00
Damien Elmes
7113e855ef make tooltip bg stand out slightly 2020-07-07 12:11:51 +10:00
Damien Elmes
ab3fbb3667 de-emphasise axis line, but don't hide completely 2020-07-07 12:06:27 +10:00
Damien Elmes
da4facd680 fix card count graph
https://forums.ankiweb.net/t/anki-2-1-28-beta/629/24
2020-07-07 11:39:58 +10:00
Damien Elmes
a2b4160d60 tidy up logging 2020-07-07 10:50:12 +10:00
Damien Elmes
c5f36ccf08 if webexports does not match, return 403 2020-07-07 10:50:03 +10:00
Damien Elmes
c5fdcf1d4f Merge pull request #679 from evandroforks/fix_mediasrv_addon_paths
Fix _addons/ URL prefix not being removed on Windows systems
2020-07-07 10:09:04 +10:00
evandrocoan
901fb08584 Attempt to fix Python interpreter
Fix _addons/ URL prefix not being removed on Windows systems
https://github.com/ankitects/anki/pull 679
2020-07-06 20:05:31 -03:00
evandrocoan
af731fa739 Fix _addons/ URL prefix not being removed on Windows systems
Anki 2.1.28 Beta
https://forums.ankiweb.net/t/anki-2-1-28-beta/629/26

> Did the requirements on how to expose resources on the internal server change? Because scripts, css files and the like, registered with setWebExports, do not work anymore with beta2.
> A look at the console shows the following for all resources:
> Failed to load resource: the server responded with a status of 500 (INTERNAL SERVER ERROR)

**\Anki2\addons21\someaddon\__init__.py**
```py
from aqt import mw
import aqt

# assuming add-on folder is named "test"
# and assuming a 'test.js' is in the same folder
addon_id = "someaddon"
port = mw.mediaServer.getPort()
mw.addonManager.setWebExports(addon_id, ".*\\.js$")

print("Hello")

aqt.editor._html += f"""
<script>
    var script = document.createElement('script');
    script.type = 'text/javascript';
    script.src = 'http://127.0.0.1:{port}/_addons/{addon_id}/test.js';
    document.body.appendChild(script);
</script>"""
```
2020-07-06 13:51:37 -03:00
Damien Elmes
3aafa384fc fix bar of wrong size 2020-07-06 19:16:03 +10:00
Damien Elmes
63abfa7473 cards->reviews; total->running total 2020-07-06 19:16:03 +10:00
Damien Elmes
c22040f33d drop 1 month period 2020-07-06 19:16:03 +10:00
Damien Elmes
214ba8ead9 update title 2020-07-06 19:16:03 +10:00
Damien Elmes
bc8d60171e show total correct in answer buttons graph 2020-07-06 19:16:03 +10:00
Damien Elmes
097d91d143 add 'no data' overlay when graph empty 2020-07-06 19:16:03 +10:00
Damien Elmes
3a75161778 fix deck tree with a day delta, and support arbitrary timestamps 2020-07-06 19:16:03 +10:00
Damien Elmes
54d2f6bfad Merge pull request #678 from rathsky/colordialog-linux
Always use standard QT color dialog on Linux
2020-07-06 19:15:42 +10:00
Andreas Reis
94ace1c0a7 Add myself to CONTRIBUTORS 2020-07-05 13:21:42 +02:00
Andreas Reis
3628011599 Always use standard QT color dialog on Linux
On Linux only Gnome uses its own color dialog, and it's inferior to QT's own: See the same issue @ https://github.com/OpenShot/openshot-qt/pull/2425

(This is/was visible only on some distributions' packaged versions of Anki, not via ./run.)

isLin check since QT on Windows already uses the default, whereas Mac's own picker seems superior (from what I can judge by screenshots).
2020-07-05 13:21:38 +02:00
Damien Elmes
e635e001e3 css->scss in makefile deps 2020-07-04 13:49:50 +10:00
Damien Elmes
e46a89ddbe limit max width of graphs
https://forums.ankiweb.net/t/anki-2-1-28-beta/629/19
2020-07-04 13:49:42 +10:00
Damien Elmes
a5e823f3ec use graph for card counts 2020-07-04 13:38:46 +10:00
Damien Elmes
71dbbd9fa8 set schema on collection creation 2020-07-03 11:55:27 +10:00
Damien Elmes
85dd611b72 don't stuff mw into function objects
Using the global is preferable to fighting against mypy to insert mw
into a function object.
2020-07-03 10:55:29 +10:00
Damien Elmes
17f80e4a7a port previous css workaround to flask 2020-07-03 10:40:23 +10:00
Damien Elmes
d1253bbfa0 Merge pull request #554 from evandroforks/fix_html5_media_support
Fixed HTML5 media tags
2020-07-03 10:25:43 +10:00
evandrocoan
f96e090b72 Replaced flask.Response by flask.make_response to simplify the
implementation and because make_response is preferred over Response
as it respects the server defined Response type.
2020-07-02 20:39:03 -03:00
evandrocoan
6c5311417f Removed duplicated mediasrv.py security check and fixed invalid
command/path error message.
2020-07-02 20:39:03 -03:00
evandrocoan
2de914267b Fix jest unit tests after merge
# Conflicts:
#	qt/aqt/mediasrv.py
#	qt/ts/src/ankimedia.ts
#	qt/ts/src/reviewer-exceptions.test.ts
#	qt/ts/src/reviewer.test.ts
#	ts/package.json
2020-07-02 14:30:43 -03:00
evandrocoan
3ae83a0ec3 Replaced send_from_directory by send_file to simplify the code 2020-07-02 13:52:07 -03:00
evandrocoan
9bd8e494b3 Ensure protection against directory transversal
https://security.openstack.org/guidelines/dg_using-file-paths.html
2020-07-02 13:52:03 -03:00
evandrocoan
11183ac1f3 Fixed aqt/mediasrv.py:14: error: unused 'type: ignore' comment
from waitress.server import create_server  # type: ignore
https://github.com/evandroforks/anki/runs/743801391#step:25:1129
2020-07-02 13:51:59 -03:00
evandrocoan
7033329012 Replaced the mediasrv.py SimpleHttp server by flask and waitress,
fixing HTML5 media support.
https://stackoverflow.com/questions/37044064/html-audio-cant-set-currenttime
https://stackoverflow.com/questions/21956683/enable-access-control-on-simple-http-server
https://stackoverflow.com/questions/5052635/what-is-relation-between-content-length-and-byte-ranges-in-http-1-1
https://stackoverflow.com/questions/16725907/google-app-engine-serving-mp3-for-audio-element-needs-content-range-header

I was trying to use HTML5 audio tag to display audios like:
```html
<audio id="elem_audio" src="myfile.mp3" controls></audio>
```
![image](https://user-images.githubusercontent.com/5332158/79063321-565b5500-7c77-11ea-9f8d-6e1df6f07892.png)

But the progress bar seek was not working. After researching, I found the problem was the HTML server not properly responding to the HTML5 header requests. The HTML server should respond to quite complicated things as 206 partial, properly handle keep-alive, provide media ranges and other HTTP headers: https://stackoverflow.com/questions/37044064/html-audio-cant-set-currenttime

To implement all these on the Simple HTTP server would be quite complicated. Then, instead, I imported the `flask` web server, which is quite simple and straight forward to use. Now, the back-end is using a secure complaint HTTP back-end:
1. https://palletsprojects.com/p/flask/
    > Flask is a lightweight WSGI web application framework. It is designed to make getting started quick and easy, with the ability to scale up to complex applications. It began as a simple wrapper around Werkzeug and Jinja and has become one of the most popular Python web application frameworks.
    >
    > Flask offers suggestions, but doesn't enforce any dependencies or project layout. It is up to the developer to choose the tools and libraries they want to use. There are many extensions provided by the community that make adding new functionality easy.

1. https://docs.pylonsproject.org/projects/waitress/en/latest/
    > Waitress is meant to be a production-quality pure-Python WSGI server with very acceptable performance. It has no dependencies except ones which live in the Python standard library. It runs on CPython on Unix and Windows under Python 2.7+ and Python 3.5+. It is also known to run on PyPy 1.6.0 on UNIX. It supports HTTP/1.0 and HTTP/1.1.

Right now, anki does not support fields passing file names directly to HTML audio tags, but this can be easily done with (https://github.com/ankitects/anki/pull 540 - Added arguments to the sound tag) plus the commit 826a97df61, the HTML5 audio tag can be used like this:
```html
// Audio = [sound:myfile.mp3|onlyfilename]
<audio id="elem_audio" src="{{Audio}}" controls controlsList="nodownload"></audio>
```
![image](https://user-images.githubusercontent.com/5332158/79063736-c539ad80-7c79-11ea-8420-40b72185f4e7.png)

# Conflicts:
#	qt/aqt/mediasrv.py
2020-07-02 13:51:49 -03:00
Damien Elmes
f093acc0e8 dump error on profile load fail
may help diagnose
https://forums.ankiweb.net/t/i-couldnt-open-anki-resetting-corrupt-global/190
2020-07-02 10:35:01 +10:00