From bf0bee402b4852db2f7b79505b9b10b2533acd08 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 20 2019 10:11:31 +0000 Subject: [PATCH 1/5] Move the wait_for_task function down and fix the call to setTimeout Move the function wait_for_task lower down in the file so all the functions about viewing the stats are in one place and the functions about retrieving the data at the bottom. Fix the call to window.setTimeout so it works with the CSP headers Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/static/issues_stats.js b/pagure/static/issues_stats.js index 8b861f1..b8e63b9 100644 --- a/pagure/static/issues_stats.js +++ b/pagure/static/issues_stats.js @@ -57,17 +57,6 @@ function issues_history_stats_plot(url, _b, _s) { }); } -function wait_for_task(url, callback) { - $.get(url) - .done(function(data){ - callback(data); - $("#data_stats_spinner").hide(); - }) - .fail(function(){ - window.setTimeout(wait_for_task(url, callback), 1000); - }); -} - function show_commits_authors(data) { var _b = $("#data_stats"); var html = '

Authors stats

Since ' @@ -157,3 +146,14 @@ function process_async(url, _data, callback) { wait_for_task(data.url, callback); }) } + +function wait_for_task(url, callback) { + $.get(url) + .done(function(data){ + callback(data); + $("#data_stats_spinner").hide(); + }) + .fail(function(){ + window.setTimeout(function() {wait_for_task(url, callback);}, 1000); + }); +} From b5b97e72feced3eb88551efdd8f4d99220e0677f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 20 2019 10:13:01 +0000 Subject: [PATCH 2/5] Fix the id vs class in the repo_stats template The id is either data_stats_spinner or data_stats and hidden is supposed to be a class, not an id. Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/templates/repo_stats.html b/pagure/templates/repo_stats.html index d25fe4e..58aa147 100644 --- a/pagure/templates/repo_stats.html +++ b/pagure/templates/repo_stats.html @@ -28,8 +28,8 @@

- - + +
From e0075514d6db72728d9dfeddd35f78e36d74f104 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 20 2019 10:13:53 +0000 Subject: [PATCH 3/5] Fix typo in the id name: publicnotifications != publicnotificationsb Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/templates/settings.html b/pagure/templates/settings.html index ec954c6..1067f35 100644 --- a/pagure/templates/settings.html +++ b/pagure/templates/settings.html @@ -31,7 +31,7 @@ href="#apikeys-tab" role="tab" aria-controls="apikeys">API Keys Project Options - Public Notifications {% if config.get('ENABLE_USER_MNGT', True) %} From 36de818edb283b7d49ff15603a67c9ce3712018e Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jun 20 2019 13:20:25 +0000 Subject: [PATCH 4/5] Drop all the inline "onclick()" calls These calls do not work with CSP headers Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/templates/_formhelper.html b/pagure/templates/_formhelper.html index f33e3f3..8bdd299 100644 --- a/pagure/templates/_formhelper.html +++ b/pagure/templates/_formhelper.html @@ -130,7 +130,7 @@ }}">commented {% if PRinline %} on line {{ + class="inline_comment_link_btn">{{ comment.line }} of {{ comment.filename }} {% endif %} {{ comment.date_created | humanize}} @@ -176,9 +176,8 @@ {% if id != 0 and g.fas_user and (g.repo_committer or ( comment.parent.status in [True, 'Open'] and g.fas_user.username == comment.user.username)) %} - diff --git a/pagure/templates/add_deploykey.html b/pagure/templates/add_deploykey.html index fa152aa..f69fccb 100644 --- a/pagure/templates/add_deploykey.html +++ b/pagure/templates/add_deploykey.html @@ -29,7 +29,7 @@ {{ render_bootstrap_field(form.pushaccess, field_description="Do you want to give this key push access?") }}

- + {{ form.csrf_token }}

diff --git a/pagure/templates/add_group.html b/pagure/templates/add_group.html index e6376f6..a369583 100644 --- a/pagure/templates/add_group.html +++ b/pagure/templates/add_group.html @@ -24,7 +24,7 @@ {%- endif %}

- + {{ form.csrf_token }}

diff --git a/pagure/templates/add_group_project.html b/pagure/templates/add_group_project.html index f792f05..e69d19e 100644 --- a/pagure/templates/add_group_project.html +++ b/pagure/templates/add_group_project.html @@ -36,7 +36,7 @@

- + {{ form.csrf_token }}

diff --git a/pagure/templates/add_token.html b/pagure/templates/add_token.html index fe2e3d1..7ea5bf3 100644 --- a/pagure/templates/add_token.html +++ b/pagure/templates/add_token.html @@ -56,7 +56,7 @@ Cancel {% endif %} - Toggle all + Toggle all {{ form.csrf_token }} @@ -73,6 +73,9 @@ checkboxes[i].checked = !checkboxes[i].checked; } } + document.addEventListener('DOMContentLoaded', function () { + document.querySelector('.toggle_all').addEventListener('click', toggle); + }); {% endmacro %} diff --git a/pagure/templates/add_user.html b/pagure/templates/add_user.html index 7815057..a4bd4e8 100644 --- a/pagure/templates/add_user.html +++ b/pagure/templates/add_user.html @@ -34,7 +34,7 @@

- + {{ form.csrf_token }}

diff --git a/pagure/templates/blame.html b/pagure/templates/blame.html index 8d79965..05be5e4 100644 --- a/pagure/templates/blame.html +++ b/pagure/templates/blame.html @@ -120,8 +120,7 @@ username=username, namespace=repo.namespace, branchname=branchname, filename=filename) }}"> - {{ forkbuttonform.csrf_token }} @@ -199,6 +198,8 @@ function updateHighlight() { return []; } $(document).ready(function () { + $('.fork_project_btn').click($("[name=fork_project]").submit); + var lines = updateHighlight(); if (lines) { var offset = $('[data-line-number=' + lines[0] + ']').offset().top; diff --git a/pagure/templates/comment_update.html b/pagure/templates/comment_update.html index 51c79c7..d293138 100644 --- a/pagure/templates/comment_update.html +++ b/pagure/templates/comment_update.html @@ -31,8 +31,7 @@
- +
diff --git a/pagure/templates/edit_file.html b/pagure/templates/edit_file.html index 2aeb71f..f4e0218 100644 --- a/pagure/templates/edit_file.html +++ b/pagure/templates/edit_file.html @@ -102,7 +102,7 @@
- +
diff --git a/pagure/templates/edit_group.html b/pagure/templates/edit_group.html index f011c69..3db287c 100644 --- a/pagure/templates/edit_group.html +++ b/pagure/templates/edit_group.html @@ -56,8 +56,7 @@ {{ form.csrf_token }} - @@ -98,5 +97,9 @@ $('#user').selectize({ ); } }); + +$('.give_group_btn').click(function() { + return confirm('Are you sure to give {{ group.group_name }}? \nThis is final and cannot be un-done.'); +}) {% endblock %} diff --git a/pagure/templates/edit_tag.html b/pagure/templates/edit_tag.html index 232f38b..72490f4 100644 --- a/pagure/templates/edit_tag.html +++ b/pagure/templates/edit_tag.html @@ -45,8 +45,8 @@ - + diff --git a/pagure/templates/file.html b/pagure/templates/file.html index 8ca23c5..d778c76 100644 --- a/pagure/templates/file.html +++ b/pagure/templates/file.html @@ -127,8 +127,7 @@ username=username, namespace=repo.namespace, branchname=branchname, filename=filename) }}"> - @@ -122,9 +119,7 @@ namespace=repo.namespace, token_id=token.id) }}" method="post" class="icon"> - diff --git a/pagure/templates/user_emails.html b/pagure/templates/user_emails.html index 6989db4..595a84e 100644 --- a/pagure/templates/user_emails.html +++ b/pagure/templates/user_emails.html @@ -16,7 +16,7 @@
{{ render_bootstrap_field(form.email) }} - + {{ form.csrf_token }}
diff --git a/pagure/templates/user_settings.html b/pagure/templates/user_settings.html index 5d80fff..6dda073 100644 --- a/pagure/templates/user_settings.html +++ b/pagure/templates/user_settings.html @@ -13,9 +13,8 @@ action="{{ url_for('ui_ns.remove_user_email') }}"> {{ form.csrf_token }} - @@ -28,9 +27,8 @@ action="{{ url_for('ui_ns.set_default_email') }}" id="default_mail"> {{ form.csrf_token }} - + @@ -42,9 +40,8 @@ action="{{ url_for('ui_ns.reconfirm_email') }}" id="reconfirm_mail"> {{ form.csrf_token }} - @@ -190,10 +187,7 @@
- @@ -232,9 +226,8 @@ action="{{ url_for( 'ui_ns.remove_user_sshkey', keyid=key.id) }}"> - {{ form.csrf_token }} @@ -337,6 +330,22 @@ {{ super() }}