diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a95e1f1..79d9859 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -45,7 +45,8 @@ repos: rev: "v3.4.2" hooks: - id: prettier - exclude_types: [html, css, javascript, json, scss] + exclude_types: [html, css, json, scss] + exclude: '(^trac-env\/htdocs\/js\/lib\/.*$)' - repo: https://github.com/tox-dev/pyproject-fmt rev: "v2.5.0" diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..6962fc7 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,11 @@ +{ + "overrides": [ + { + "files": "*.js", + "options": { + "tabWidth": 2, + "singleQuote": true + } + } + ] +} diff --git a/trac-env/htdocs/js/main.js b/trac-env/htdocs/js/main.js index a4290d0..961ecfd 100644 --- a/trac-env/htdocs/js/main.js +++ b/trac-env/htdocs/js/main.js @@ -1,63 +1,70 @@ // Require.js Module Loader - http://requirejs.org requirejs.config({ - paths: { - "jquery": "//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min", - // "jquery": "lib/jquery", -- local version of jquery if desired. - "jquery.inview": "lib/jquery.inview" - } + paths: { + jquery: '//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min', + // "jquery": "lib/jquery", -- local version of jquery if desired. + 'jquery.inview': 'lib/jquery.inview', + }, }); -define(function(){ - - var mods = []; - - //detect Class function - function hasClass( className ) { - if (!document.getElementsByClassName) { //class name function in old IE - document.getElementsByClassName = function(search) { - var d = document, elements, pattern, i, results = []; - if (d.querySelectorAll) { // IE8 - return d.querySelectorAll("." + search); - } - if (d.evaluate) { // IE6, IE7 - pattern = ".//*[contains(concat(' ', @class, ' '), ' " + search + " ')]"; - elements = d.evaluate(pattern, d, null, 0, null); - while ((i = elements.iterateNext())) { - results.push(i); - } - } else { - elements = d.getElementsByTagName("*"); - pattern = new RegExp("(^|\\s)" + search + "(\\s|$)"); - for (i = 0; i < elements.length; i++) { - if ( pattern.test(elements[i].className) ) { - results.push(elements[i]); - } - } - } - return results; - }; - } - return !!document.getElementsByClassName( className ).length; //return a boolean - } - - //feature list - if (hasClass('list-features')) { - mods.push('mod/list-feature'); - } - - //collapsing list - if (hasClass('list-collapsing')) { - mods.push('mod/list-collapsing'); - } - - if (hasClass('version-switcher')) { - mods.push('mod/version-switcher'); - } - - if (hasClass('doc-floating-warning')) { - mods.push('mod/floating-warning'); - } - - require(mods); +define(function () { + var mods = []; + + //detect Class function + function hasClass(className) { + if (!document.getElementsByClassName) { + //class name function in old IE + document.getElementsByClassName = function (search) { + var d = document, + elements, + pattern, + i, + results = []; + if (d.querySelectorAll) { + // IE8 + return d.querySelectorAll('.' + search); + } + if (d.evaluate) { + // IE6, IE7 + pattern = + ".//*[contains(concat(' ', @class, ' '), ' " + search + " ')]"; + elements = d.evaluate(pattern, d, null, 0, null); + while ((i = elements.iterateNext())) { + results.push(i); + } + } else { + elements = d.getElementsByTagName('*'); + pattern = new RegExp('(^|\\s)' + search + '(\\s|$)'); + for (i = 0; i < elements.length; i++) { + if (pattern.test(elements[i].className)) { + results.push(elements[i]); + } + } + } + return results; + }; + } + return !!document.getElementsByClassName(className).length; //return a boolean + } + + //feature list + if (hasClass('list-features')) { + mods.push('mod/list-feature'); + } + + //collapsing list + if (hasClass('list-collapsing')) { + mods.push('mod/list-collapsing'); + } + + if (hasClass('version-switcher')) { + mods.push('mod/version-switcher'); + } + + if (hasClass('doc-floating-warning')) { + mods.push('mod/floating-warning'); + } + + require(mods); }); diff --git a/trac-env/htdocs/js/mobile-menu.js b/trac-env/htdocs/js/mobile-menu.js index 435779e..10d6f88 100644 --- a/trac-env/htdocs/js/mobile-menu.js +++ b/trac-env/htdocs/js/mobile-menu.js @@ -1,11 +1,13 @@ -jQuery(document).ready(function($) { - var menu = $('[role="banner"] [role="navigation"]'); - var button = $('
'); +jQuery(document).ready(function ($) { + var menu = $('[role="banner"] [role="navigation"]'); + var button = $( + ' ', + ); - menu.addClass('nav-menu-on'); - button.insertBefore(menu); - button.on('click', function(){ - menu.toggleClass('active'); - button.toggleClass('active') - }); -}) + menu.addClass('nav-menu-on'); + button.insertBefore(menu); + button.on('click', function () { + menu.toggleClass('active'); + button.toggleClass('active'); + }); +}); diff --git a/trac-env/htdocs/tickethacks.js b/trac-env/htdocs/tickethacks.js index 1fbcbef..bc30d1d 100644 --- a/trac-env/htdocs/tickethacks.js +++ b/trac-env/htdocs/tickethacks.js @@ -2,251 +2,291 @@ // Hacks for the ticket page. // -$(function() { - // Don't collapse ticket properties. - $("#modify").parent().removeClass('collapsed'); +$(function () { + // Don't collapse ticket properties. + $('#modify').parent().removeClass('collapsed'); - // - // Link field names to the corresponding sections in the Triaging doc. - // + // + // Link field names to the corresponding sections in the Triaging doc. + // - var linkMap = { - "h_stage": "triage-stages", - "h_ui_ux": "ui-ux", - "h_version": "version", - "h_component": "component", - "h_severity": "severity", - "h_needs_docs": "needs-documentation", - "h_needs_better_patch": "patch-needs-improvement", - "h_cc": "cc", - "h_has_patch": "has-patch", - "h_easy": "easy-pickings", - "h_keywords": "keywords", - "h_needs_tests": "needs-tests" + var linkMap = { + h_stage: 'triage-stages', + h_ui_ux: 'ui-ux', + h_version: 'version', + h_component: 'component', + h_severity: 'severity', + h_needs_docs: 'needs-documentation', + h_needs_better_patch: 'patch-needs-improvement', + h_cc: 'cc', + h_has_patch: 'has-patch', + h_easy: 'easy-pickings', + h_keywords: 'keywords', + h_needs_tests: 'needs-tests', + }; + + $('table.properties th').each(function () { + var $this = $(this); + var anchor = linkMap[$this.attr('id')]; + if (anchor) { + $this.wrapInner(function () { + return ( + "" + ); + }); } + }); - $("table.properties th").each(function(){ - var $this = $(this); - var anchor = linkMap[$this.attr("id")]; - if (anchor) { - $this.wrapInner(function(){ - return ""; - }); + // Show Pull Requests from Github with titles matching any of the following + // patterns: "#[https://github.com/django/django/pull/#### PR]
."
+ var link =
+ 'How to create a pull request';
+ if (links.length > 0) {
+ link = links.join(', ');
+ }
+ $('table.properties').append(
+ '[https://github.com/django/django/pull/#### PR]
.';
+ if (ticket_status == 'closed') {
+ // TODO (e.g. reopening a wontfix or needsinfo, or what to do in the
+ // case of a regression caused by the ticket
+ } else if (stage == 'Unreviewed') {
+ next_steps.push(
+ "For bugs: reproduce the bug. If it's a regression, " +
+ "" +
+ 'bisect to find the commit where the behavior changed.',
+ );
+ next_steps.push(
+ 'For new features or cleanups: give a second opinion of the proposal.',
);
- if (ticket_status == 'closed') {
- // TODO (e.g. reopening a wontfix or needsinfo, or what to do in the
- // case of a regression caused by the ticket
- } else if (stage == 'Unreviewed') {
+ next_steps.push(
+ 'In either case, mark the Triage Stage as "Accepted" if the issue seems valid, ' +
+ 'ask for additional clarification from the reporter, or close the ticket.',
+ );
+ } else if (stage == 'Accepted') {
+ if (!has_patch) {
+ next_steps.push(
+ "" +
+ 'To provide a patch by sending a pull request. ' +
+ "" +
+ "Claim the ticket when you start working so that someone else doesn't duplicate effort. " +
+ "Before sending a pull request, review your work against the " +
+ 'patch review checklist. ' +
+ 'Check the "Has patch" flag on the ticket after sending a pull request and ' +
+ include_link_to_pr_msg,
+ );
+ } else {
+ if (needs_tests) {
next_steps.push(
- "For bugs: reproduce the bug. If it's a regression, " +
- "" +
- "bisect to find the commit where the behavior changed."
+ 'To add tests to the patch, then uncheck the "Needs tests" flag on the ticket.',
);
+ }
+ if (needs_docs) {
next_steps.push(
- "For new features or cleanups: give a second opinion of the proposal."
+ 'To write documentation for the patch, then uncheck "Needs documentation" on the ticket.',
);
+ }
+ if (patch_needs_improvement) {
next_steps.push(
- "In either case, mark the Triage Stage as \"Accepted\" if the issue seems valid, " +
- "ask for additional clarification from the reporter, or close the ticket."
+ 'To improve the patch as described in the pull request review ' +
+ 'comments or on this ticket, then uncheck "Patch needs improvement".',
);
- } else if (stage == 'Accepted') {
- if (!has_patch) {
- next_steps.push(
- "" +
- "To provide a patch by sending a pull request. " +
- "" +
- "Claim the ticket when you start working so that someone else doesn't duplicate effort. " +
- "Before sending a pull request, review your work against the " +
- "patch review checklist. " +
- "Check the \"Has patch\" flag on the ticket after sending a pull request and " +
- include_link_to_pr_msg
- );
- } else {
- if (needs_tests) {
- next_steps.push('To add tests to the patch, then uncheck the "Needs tests" flag on the ticket.');
- }
- if (needs_docs) {
- next_steps.push('To write documentation for the patch, then uncheck "Needs documentation" on the ticket.');
- }
- if (patch_needs_improvement) {
- next_steps.push(
- "To improve the patch as described in the pull request review " +
- "comments or on this ticket, then uncheck \"Patch needs improvement\"."
- );
- }
- if (!needs_tests && !needs_docs && !patch_needs_improvement) {
- next_steps.push(
- 'For anyone except the patch author to review the patch using the ' +
- '' +
- 'patch review checklist and either ' +
- 'mark the ticket as "Ready for checkin" if everything looks good, ' +
- 'or leave comments for improvement and mark the ticket as ' +
- '"Patch needs improvement".'
- );
- } else {
- next_steps.push("If creating a new pull request, " + include_link_to_pr_msg); - } - } - } else if (stage == 'Ready for checkin') { + } + if (!needs_tests && !needs_docs && !patch_needs_improvement) { next_steps.push( - 'For a Django committer to do a final review of the patch and merge ' + - 'it if all looks good.' + 'For anyone except the patch author to review the patch using the ' + + '' + + 'patch review checklist and either ' + + 'mark the ticket as "Ready for checkin" if everything looks good, ' + + 'or leave comments for improvement and mark the ticket as ' + + '"Patch needs improvement".', ); - } else if (stage == 'Someday/Maybe') { + } else { next_steps.push( - '
Unknown. The Someday/Maybe triage stage is used ' + - 'to keep track of high-level ideas or long term feature requests.
' + - 'It could be an issue that\'s blocked until a future version of Django ' + - '(if so, Keywords will contain that version number). It could also ' + - 'be an enhancement request that we might consider adding someday to the framework ' + - 'if an excellent patch is submitted.
' + - 'If you\'re interested in contributing to the issue, ' + - 'raising your ideas on the django-developers ' + - 'mailing list certainly wouldn\'t hurt.
' - ); - } - if (next_steps.length) { - $("#ticket").after( - "
According to the " + - "" + - "ticket's flags, the next step(s) to move this issue forward are:
" + - "If creating a new pull request, ' + include_link_to_pr_msg, ); + } } + } else if (stage == 'Ready for checkin') { + next_steps.push( + 'For a Django committer to do a final review of the patch and merge ' + + 'it if all looks good.', + ); + } else if (stage == 'Someday/Maybe') { + next_steps.push( + '
Unknown. The Someday/Maybe triage stage is used ' + + 'to keep track of high-level ideas or long term feature requests.
' + + "It could be an issue that's blocked until a future version of Django " + + '(if so, Keywords will contain that version number). It could also ' + + 'be an enhancement request that we might consider adding someday to the framework ' + + 'if an excellent patch is submitted.
' + + "If you're interested in contributing to the issue, " + + 'raising your ideas on the django-developers ' + + "mailing list certainly wouldn't hurt.
", + ); + } + if (next_steps.length) { + $('#ticket').after( + "
According to the " + + "" + + "ticket's flags, the next step(s) to move this issue forward are:
" + + '