Skip to content

Commit 8d8c41f

Browse files
authored
fix: unlock share box from uBlock origins (#347)
1 parent a787de9 commit 8d8c41f

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

lms/lmsweb/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ def share():
377377
solution_id = int(request.json.get('solutionId', 0))
378378

379379
try:
380-
shared_solution = share_link.get(solution_id)
380+
shared_solution = share_link.get_or_create(solution_id)
381381
except LmsError as e:
382382
error_message, status_code = e.args
383383
return fail(status_code, error_message)
@@ -666,7 +666,7 @@ def shared_solution(shared_url: str, file_id: Optional[int] = None):
666666
if shared_solution is None:
667667
return fail(404, 'The solution does not exist.')
668668

669-
share_link.new(shared_solution)
669+
share_link.new_visit(shared_solution)
670670
solution_id = shared_solution.solution.id
671671
return view(
672672
solution_id=solution_id, file_id=file_id, shared_url=shared_url,

lms/models/share_link.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from lms.models.errors import ForbiddenPermission, ResourceNotFound
77

88

9-
def get(solution_id: int) -> SharedSolution:
9+
def get_or_create(solution_id: int) -> SharedSolution:
1010
if not webapp.config.get('SHAREABLE_SOLUTIONS', False):
1111
raise ForbiddenPermission('Shareable solutions are not allowed.', 403)
1212

@@ -30,7 +30,7 @@ def get(solution_id: int) -> SharedSolution:
3030
return shared_solution
3131

3232

33-
def new(shared_solution: SharedSolution) -> None:
33+
def new_visit(shared_solution: SharedSolution) -> None:
3434
SharedSolutionEntry.create(
3535
referrer=request.referrer,
3636
user=current_user.id,

lms/static/my.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -503,14 +503,14 @@ button#share-action:hover {
503503
}
504504

505505
.code-toolbar-button,
506-
#share-text {
506+
#shared-text {
507507
padding: 0.4rem;
508508
margin: 0 0.2rem;
509509
border-radius: 0;
510510
outline: none;
511511
}
512512

513-
#share-box > button {
513+
#shared-box > button {
514514
padding: 0 0.7rem;
515515
}
516516

@@ -537,7 +537,7 @@ button#share-action:hover {
537537
align-items: center;
538538
}
539539

540-
#share-box {
540+
#shared-box {
541541
display: flex;
542542
position: absolute;
543543
direction: rtl;
@@ -551,7 +551,7 @@ button#share-action:hover {
551551
padding: 0.4rem;
552552
}
553553

554-
#share-box * {
554+
#shared-box * {
555555
position: relative;
556556
display: flex;
557557
line-height: unset;

lms/static/my.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ function sendShareRequest(act, solutionId, callback) {
2323
xhr.setRequestHeader('Content-Type', 'application/json');
2424
xhr.responseType = 'json';
2525

26-
xhr.onreadystatechange = () => { callback(xhr); };
26+
xhr.onreadystatechange = () => {callback(xhr);};
2727

2828
xhr.send(
29-
JSON.stringify({ act, solutionId }),
29+
JSON.stringify({act, solutionId}),
3030
);
3131
return xhr;
3232
}
@@ -38,7 +38,7 @@ function trackCopyButton(button, context) {
3838
}
3939

4040
function hideShareLink(xhr) {
41-
const shareBox = document.getElementById('share-box');
41+
const shareBox = document.getElementById('shared-box');
4242
if (xhr.readyState === 4) {
4343
if (xhr.status === 200) {
4444
shareBox.classList.add('d-none');
@@ -49,8 +49,8 @@ function hideShareLink(xhr) {
4949
}
5050

5151
function updateShareLink(xhr) {
52-
const shareBox = document.getElementById('share-box');
53-
const shareText = document.getElementById('share-text');
52+
const shareBox = document.getElementById('shared-box');
53+
const shareText = document.getElementById('shared-text');
5454
if (xhr.readyState === 4) {
5555
if (xhr.status === 200) {
5656
if (shareBox.classList.contains('d-none')) {

lms/templates/view.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ <h1>{{ _('Exercise view') }} {{ solution['exercise']['number'] }}: {{ solution['
5656
<div id="code-toolbar-buttons">
5757
{% if config.SHAREABLE_SOLUTIONS and not shared_url %}
5858
<div id="share-solution" class="code-toolbar-button glowing">
59-
<div id="share-text">
59+
<div id="shared-text">
6060
<button id="share-action" title="Share solution"><i class="fa fa-share-alt"></i></button>
6161
</div>
62-
<div id="share-box" class="glowing d-none">
62+
<div id="shared-box" class="glowing d-none">
6363
<button id="cancel-share" class="share-button" title="Disable share solution"><i class="fa fa-trash"></i></button>
6464
<button id="copy-link" class="share-button" title="Copy shared link"><i class="fa fa-copy"></i></button>
6565
<input id="shareable-link" class="form-control" type="text" readonly>

0 commit comments

Comments
 (0)