Browse Source

Merge branch 'upgrade-npm-dependencies' into 'develop-1.101'

Draft: Upgrade Node and NPM dependencies

See merge request tildes/tildes!173
merge-requests/173/merge
talklittle 4 weeks ago
parent
commit
b04c269f0c
  1. 2
      ansible/playbook.yml
  2. 3
      ansible/roles/nginx_site_config/templates/tildes.conf.jinja2
  3. 4
      ansible/roles/nodejs/tasks/main.yml
  4. 6
      ansible/roles/swagger_ui/files/index.html
  5. 3
      ansible/roles/swagger_ui/meta/main.yml
  6. 20
      ansible/roles/swagger_ui/tasks/main.yml
  7. 1
      tildes/.prettierignore
  8. 22
      tildes/eslint.config.js
  9. 7876
      tildes/package-lock.json
  10. 187
      tildes/package.json
  11. 1
      tildes/prospector.yaml
  12. 6
      tildes/scss/_base.scss
  13. 8
      tildes/scss/_layout.scss
  14. 3
      tildes/scss/_mixins.scss
  15. 1
      tildes/scss/_placeholders.scss
  16. 13
      tildes/scss/modules/_btn.scss
  17. 2
      tildes/scss/modules/_chip.scss
  18. 10
      tildes/scss/modules/_comment.scss
  19. 2
      tildes/scss/modules/_donation.scss
  20. 9
      tildes/scss/modules/_form.scss
  21. 2
      tildes/scss/modules/_label.scss
  22. 1
      tildes/scss/modules/_logged-in-user.scss
  23. 1
      tildes/scss/modules/_menu.scss
  24. 1
      tildes/scss/modules/_message.scss
  25. 5
      tildes/scss/modules/_sidebar.scss
  26. 1
      tildes/scss/modules/_site-footer.scss
  27. 2
      tildes/scss/modules/_site-header.scss
  28. 1
      tildes/scss/modules/_tab.scss
  29. 4
      tildes/scss/modules/_theme-preview.scss
  30. 1
      tildes/scss/modules/_toast.scss
  31. 11
      tildes/scss/modules/_topic.scss
  32. 3
      tildes/scss/styles.scss
  33. 18
      tildes/scss/themes/_atom_one_dark.scss
  34. 2
      tildes/scss/themes/_dracula.scss
  35. 18
      tildes/scss/themes/_theme_mixins.scss
  36. 7
      tildes/static/js/behaviors/auto-focus.js
  37. 10
      tildes/static/js/behaviors/autocomplete-chip-clear.js
  38. 33
      tildes/static/js/behaviors/autocomplete-input.js
  39. 20
      tildes/static/js/behaviors/autocomplete-menu-item.js
  40. 4
      tildes/static/js/behaviors/autocomplete-menu.js
  41. 4
      tildes/static/js/behaviors/autoselect-input.js
  42. 8
      tildes/static/js/behaviors/autosubmit-on-change.js
  43. 16
      tildes/static/js/behaviors/cancel-button.js
  44. 25
      tildes/static/js/behaviors/comment-collapse-all-button.js
  45. 4
      tildes/static/js/behaviors/comment-collapse-button.js
  46. 20
      tildes/static/js/behaviors/comment-collapse-read-button.js
  47. 19
      tildes/static/js/behaviors/comment-expand-all-button.js
  48. 27
      tildes/static/js/behaviors/comment-label-button.js
  49. 10
      tildes/static/js/behaviors/comment-parent-button.js
  50. 4
      tildes/static/js/behaviors/comment-reply-form.js
  51. 4
      tildes/static/js/behaviors/confirm-leave-page-unsaved.js
  52. 8
      tildes/static/js/behaviors/copy-button.js
  53. 8
      tildes/static/js/behaviors/ctrl-enter-submit-form.js
  54. 10
      tildes/static/js/behaviors/dropdown-toggle.js
  55. 4
      tildes/static/js/behaviors/external-links-new-tabs.js
  56. 8
      tildes/static/js/behaviors/fadeout-parent-on-success.js
  57. 4
      tildes/static/js/behaviors/group-links-new-tabs.js
  58. 4
      tildes/static/js/behaviors/hide-sidebar-if-open.js
  59. 4
      tildes/static/js/behaviors/hide-sidebar-no-preventdefault.js
  60. 12
      tildes/static/js/behaviors/markdown-edit-tab.js
  61. 14
      tildes/static/js/behaviors/markdown-preview-tab.js
  62. 6
      tildes/static/js/behaviors/prevent-double-submit.js
  63. 4
      tildes/static/js/behaviors/remove-on-click.js
  64. 4
      tildes/static/js/behaviors/remove-on-success.js
  65. 4
      tildes/static/js/behaviors/sidebar-toggle.js
  66. 4
      tildes/static/js/behaviors/stripe-checkout.js
  67. 4
      tildes/static/js/behaviors/stripe-donate-form.js
  68. 8
      tildes/static/js/behaviors/tab.js
  69. 4
      tildes/static/js/behaviors/theme-preview.js
  70. 15
      tildes/static/js/behaviors/theme-selector.js
  71. 6
      tildes/static/js/behaviors/time-period-select.js
  72. 4
      tildes/static/js/behaviors/user-links-new-tabs.js
  73. 10
      tildes/static/js/scripts.js
  74. 5
      tildes/tildes/routes.py

2
ansible/playbook.yml

@ -38,7 +38,6 @@
- redis_module_cell
- postgresql_redis_bridge
- boussole
- nodejs
- swagger_ui
- webassets
- scripts
@ -56,6 +55,7 @@
roles:
- prometheus
- java
- nodejs
- development
- hosts: prod

3
ansible/roles/nginx_site_config/templates/tildes.conf.jinja2

@ -18,6 +18,9 @@ map $request_uri $csp_header {
# The CSP for the Stripe donation page:
# - "https://js.stripe.com" in script-src and frame-src is needed for Stripe
"~^/donate_stripe$" "default-src 'none'; script-src 'self' https://js.stripe.com; style-src 'self'; img-src 'self' data:; connect-src 'self'; manifest-src 'self'; frame-src 'self' https://js.stripe.com; form-action 'self'; frame-ancestors 'none'; base-uri 'none'";
# The CSP for the OpenAPI (Swagger) UI page:
# - "https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/" in script-src and style-src is needed for Swagger UI
"~^/api/beta/ui$" "default-src 'none'; script-src 'self' https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/; style-src 'self' https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/; img-src 'self' data:; connect-src 'self'; manifest-src 'self'; form-action 'self'; frame-ancestors 'none'; base-uri 'none'";
}
server {

4
ansible/roles/nodejs/tasks/main.yml

@ -5,11 +5,11 @@
- name: Add NodeSource Node.js APT repository
apt_repository:
repo: deb https://deb.nodesource.com/node_20.x nodistro main
repo: deb https://deb.nodesource.com/node_22.x nodistro main
- name: Install Node.js
apt:
name: nodejs
name: nodejs>=22
- name: Install npm packages defined in package.json
become_user: "{{ app_username }}"

6
ansible/roles/swagger_ui/files/index.html

@ -3,14 +3,14 @@
<head>
<meta charset="UTF-8">
<title>Swagger UI</title>
<link rel="stylesheet" type="text/css" href="/swagger-ui/swagger-ui.css" />
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/${ui_version}/swagger-ui.css" />
<link rel="stylesheet" type="text/css" href="/swagger-ui/index.css" />
</head>
<body>
<div id="swagger-ui"></div>
<script src="/swagger-ui/swagger-ui-bundle.js" charset="UTF-8"> </script>
<script src="/swagger-ui/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/${ui_version}/swagger-ui-bundle.js" charset="UTF-8"> </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/${ui_version}/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>
<script src="/swagger-ui/index.js" charset="UTF-8"> </script>
</body>
</html>

3
ansible/roles/swagger_ui/meta/main.yml

@ -1,3 +0,0 @@
---
dependencies:
- role: nodejs

20
ansible/roles/swagger_ui/tasks/main.yml

@ -1,28 +1,30 @@
---
- name: Copy swagger-ui web assets from node package
copy:
src: "{{ app_dir }}/node_modules/swagger-ui/dist/"
dest: "{{ app_dir }}/static/swagger-ui/"
- name: Create directory for swagger-ui web assets
file:
path: "{{ app_dir }}/static/swagger-ui"
state: directory
owner: "{{ app_username }}"
group: "{{ app_username }}"
mode: 0755
remote_src: true
- name: Copy our own custom swagger-ui web assets
- name: Copy our custom swagger-ui web assets
block:
- copy:
- name: Copy our custom swagger-ui index.html
copy:
src: "index.html"
dest: "{{ app_dir }}/static/swagger-ui/index.html"
owner: "{{ app_username }}"
group: "{{ app_username }}"
mode: 0644
- copy:
- name: Copy our custom swagger-ui index.css
copy:
src: "index.css"
dest: "{{ app_dir }}/static/swagger-ui/index.css"
owner: "{{ app_username }}"
group: "{{ app_username }}"
mode: 0644
- copy:
- name: Copy our custom swagger-ui index.js
copy:
src: "index.js"
dest: "{{ app_dir }}/static/swagger-ui/index.js"
owner: "{{ app_username }}"

1
tildes/.prettierignore

@ -0,0 +1 @@
static/js/third_party/

22
tildes/eslint.config.js

@ -0,0 +1,22 @@
import js from "@eslint/js";
import globals from "globals";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
export default [
js.configs.recommended,
eslintPluginPrettierRecommended,
{
languageOptions: {
globals: {
...globals.browser,
$: "readonly",
Intercooler: "readonly",
Promise: "readonly",
Tildes: "readonly",
},
},
},
{
ignores: ["static/js/third_party*", "static/js/tildes.js"],
},
];

7876
tildes/package-lock.json
File diff suppressed because it is too large
View File

187
tildes/package.json

@ -6,41 +6,19 @@
"scripts": {
"lint": "npm run lint:js ; npm run lint:scss",
"lint:js": "node node_modules/eslint/bin/eslint.js static/js/",
"lint:scss": "node node_modules/stylelint/bin/stylelint.js scss/"
},
"dependencies": {
"swagger-ui": "^5.27.1"
"lint:scss": "node node_modules/stylelint/bin/stylelint.mjs scss/"
},
"dependencies": {},
"devDependencies": {
"eslint": "^5.16.0",
"eslint-config-prettier": "^4.3.0",
"eslint-plugin-prettier": "^3.1.0",
"prettier": "^1.17.1",
"stylelint": "^10.0.1",
"stylelint-scss": "^3.6.0"
},
"scarfSettings": {
"enabled": false
},
"eslintConfig": {
"env": {
"browser": true
},
"extends": [
"eslint:recommended",
"plugin:prettier/recommended"
],
"globals": {
"$": "readonly",
"Intercooler": "readonly",
"Promise": "readonly",
"Tildes": "readonly"
}
"eslint": "^9.35.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.4",
"prettier": "^3.6.2",
"stylelint": "^16.24.0",
"stylelint-config-standard-scss": "^16.0.0",
"@stylistic/stylelint-plugin": "^4.0.0"
},
"eslintIgnore": [
"static/js/third_party*",
"static/js/tildes.js"
],
"type": "module",
"prettier": {
"bracketSpacing": false,
"printWidth": 88,
@ -52,8 +30,9 @@
"scss/spectre*/**"
],
"plugins": [
"stylelint-scss"
"@stylistic/stylelint-plugin"
],
"extends": "stylelint-config-standard-scss",
"rules": {
"at-rule-empty-line-before": [
"always",
@ -70,77 +49,31 @@
]
}
],
"at-rule-name-case": "lower",
"at-rule-name-space-after": "always",
"at-rule-semicolon-newline-after": "always",
"at-rule-semicolon-space-before": "never",
"block-closing-brace-empty-line-before": "never",
"block-closing-brace-newline-after": [
"always",
{
"ignoreAtRules": [
"else",
"if"
]
}
],
"block-closing-brace-newline-before": "always",
"block-no-empty": true,
"block-opening-brace-newline-after": "always",
"block-opening-brace-space-before": "always",
"color-hex-case": "lower",
"color-function-notation": "legacy",
"color-named": "never",
"color-no-invalid-hex": true,
"comment-empty-line-before": "always",
"comment-no-empty": true,
"comment-whitespace-inside": "always",
"declaration-bang-space-after": "never",
"declaration-bang-space-before": "always",
"declaration-block-no-duplicate-properties": true,
"declaration-block-no-redundant-longhand-properties": null,
"declaration-block-no-shorthand-property-overrides": true,
"declaration-block-semicolon-newline-after": "always",
"declaration-block-semicolon-newline-before": "never-multi-line",
"declaration-block-semicolon-space-before": "never",
"declaration-block-trailing-semicolon": "always",
"declaration-colon-newline-after": "always-multi-line",
"declaration-colon-space-before": "never",
"font-family-no-duplicate-names": true,
"font-family-no-missing-generic-family-keyword": true,
"font-weight-notation": "named-where-possible",
"function-calc-no-unspaced-operator": true,
"function-comma-newline-after": "always-multi-line",
"function-comma-space-after": "always-single-line",
"function-comma-space-before": "never",
"function-max-empty-lines": 0,
"function-name-case": "lower",
"function-parentheses-newline-inside": "always-multi-line",
"function-parentheses-space-inside": "never-single-line",
"function-url-quotes": "always",
"function-url-scheme-whitelist": "https",
"function-whitespace-after": "always",
"indentation": 2,
"function-url-scheme-allowed-list": "https",
"length-zero-no-unit": true,
"max-empty-lines": 1,
"max-line-length": 88,
"media-feature-colon-space-after": "always",
"media-feature-colon-space-before": "never",
"media-feature-name-case": "lower",
"media-feature-name-no-unknown": true,
"media-feature-parentheses-space-inside": "never",
"media-feature-range-operator-space-after": "always",
"media-feature-range-operator-space-before": "always",
"no-descending-specificity": null,
"no-duplicate-at-import-rules": true,
"no-duplicate-selectors": true,
"no-empty-first-line": true,
"no-empty-source": true,
"no-eol-whitespace": true,
"no-extra-semicolons": true,
"no-invalid-double-slash-comments": true,
"no-missing-end-of-source-newline": true,
"number-leading-zero": "always",
"number-no-trailing-zeros": true,
"number-max-precision": 1,
"property-case": "lower",
"property-no-unknown": true,
"rule-empty-line-before": [
"always",
@ -153,31 +86,18 @@
]
}
],
"selector-attribute-brackets-space-inside": "never",
"selector-attribute-operator-space-after": "never",
"selector-attribute-operator-space-before": "never",
"selector-attribute-quotes": "always",
"selector-combinator-space-after": "always",
"selector-combinator-space-before": "always",
"selector-descendant-combinator-no-non-space": true,
"selector-list-comma-newline-after": "always",
"selector-list-comma-newline-before": "never-multi-line",
"selector-max-empty-lines": 0,
"selector-pseudo-class-case": "lower",
"selector-pseudo-class-no-unknown": true,
"selector-pseudo-class-parentheses-space-inside": "never",
"selector-pseudo-element-case": "lower",
"selector-pseudo-element-colon-notation": "double",
"selector-pseudo-element-no-unknown": true,
"selector-type-case": "lower",
"selector-type-no-unknown": true,
"shorthand-property-no-redundant-values": true,
"string-no-newline": true,
"string-quotes": "double",
"unit-case": "lower",
"unit-no-unknown": true,
"unit-whitelist": [
"unit-allowed-list": [
"%",
"deg",
"fr",
"px",
"rem",
@ -185,7 +105,6 @@
"vw"
],
"value-keyword-case": "lower",
"value-list-max-empty-lines": 0,
"value-no-vendor-prefix": true,
"scss/at-else-closing-brace-newline-after": "always-last-in-chain",
"scss/at-else-closing-brace-space-after": "always-intermediate",
@ -196,10 +115,10 @@
"scss/at-function-pattern": "^[a-z-]+$",
"scss/at-if-closing-brace-newline-after": "always-last-in-chain",
"scss/at-if-closing-brace-space-after": "always-intermediate",
"scss/at-import-no-partial-leading-underscore": true,
"scss/at-mixin-argumentless-call-parentheses": "never",
"scss/at-mixin-parentheses-space-before": "never",
"scss/at-mixin-pattern": "^[a-z-]+$",
"scss/at-rule-conditional-no-parentheses": null,
"scss/at-rule-no-unknown": true,
"scss/declaration-nested-properties": "never",
"scss/dollar-variable-colon-newline-after": "always-multi-line",
@ -230,11 +149,77 @@
}
],
"scss/double-slash-comment-whitespace-inside": "always",
"scss/load-no-partial-leading-underscore": true,
"scss/no-global-function-names": null,
"scss/operator-no-newline-after": true,
"scss/operator-no-newline-before": true,
"scss/operator-no-unspaced": true,
"scss/percent-placeholder-pattern": "^[a-z-]+$",
"scss/selector-no-redundant-nesting-selector": true
"scss/selector-no-redundant-nesting-selector": true,
"@stylistic/at-rule-name-case": "lower",
"@stylistic/at-rule-name-space-after": "always",
"@stylistic/at-rule-semicolon-newline-after": "always",
"@stylistic/at-rule-semicolon-space-before": "never",
"@stylistic/block-closing-brace-empty-line-before": "never",
"@stylistic/block-closing-brace-newline-after": [
"always",
{
"ignoreAtRules": [
"else",
"if"
]
}
],
"@stylistic/block-closing-brace-newline-before": "always",
"@stylistic/block-opening-brace-newline-after": "always",
"@stylistic/block-opening-brace-space-before": "always",
"@stylistic/color-hex-case": "lower",
"@stylistic/declaration-bang-space-after": "never",
"@stylistic/declaration-bang-space-before": "always",
"@stylistic/declaration-block-semicolon-newline-after": "always",
"@stylistic/declaration-block-semicolon-newline-before": "never-multi-line",
"@stylistic/declaration-block-semicolon-space-before": "never",
"@stylistic/declaration-block-trailing-semicolon": "always",
"@stylistic/declaration-colon-newline-after": "always-multi-line",
"@stylistic/declaration-colon-space-before": "never",
"@stylistic/function-comma-newline-after": "always-multi-line",
"@stylistic/function-comma-space-after": "always-single-line",
"@stylistic/function-comma-space-before": "never",
"@stylistic/function-max-empty-lines": 0,
"@stylistic/function-parentheses-newline-inside": "always-multi-line",
"@stylistic/function-parentheses-space-inside": "never-single-line",
"@stylistic/function-whitespace-after": "always",
"@stylistic/indentation": 2,
"@stylistic/max-empty-lines": 1,
"@stylistic/max-line-length": 88,
"@stylistic/media-feature-colon-space-after": "always",
"@stylistic/media-feature-colon-space-before": "never",
"@stylistic/media-feature-name-case": "lower",
"@stylistic/media-feature-parentheses-space-inside": "never",
"@stylistic/media-feature-range-operator-space-after": "always",
"@stylistic/media-feature-range-operator-space-before": "always",
"@stylistic/no-empty-first-line": true,
"@stylistic/no-eol-whitespace": true,
"@stylistic/no-extra-semicolons": true,
"@stylistic/no-missing-end-of-source-newline": true,
"@stylistic/number-leading-zero": "always",
"@stylistic/number-no-trailing-zeros": true,
"@stylistic/property-case": "lower",
"@stylistic/selector-attribute-brackets-space-inside": "never",
"@stylistic/selector-attribute-operator-space-after": "never",
"@stylistic/selector-attribute-operator-space-before": "never",
"@stylistic/selector-combinator-space-after": "always",
"@stylistic/selector-combinator-space-before": "always",
"@stylistic/selector-descendant-combinator-no-non-space": true,
"@stylistic/selector-list-comma-newline-after": "always",
"@stylistic/selector-list-comma-newline-before": "never-multi-line",
"@stylistic/selector-max-empty-lines": 0,
"@stylistic/selector-pseudo-class-case": "lower",
"@stylistic/selector-pseudo-class-parentheses-space-inside": "never",
"@stylistic/selector-pseudo-element-case": "lower",
"@stylistic/string-quotes": "double",
"@stylistic/unit-case": "lower",
"@stylistic/value-list-max-empty-lines": 0
}
}
}

1
tildes/prospector.yaml

@ -5,7 +5,6 @@ max-line-length: 88
ignore-paths:
- alembic
- static/swagger-ui
pep8:
disable:

6
tildes/scss/_base.scss

@ -14,7 +14,6 @@ html {
a {
text-decoration: none;
color: var(--link-color);
&:hover {
@ -42,9 +41,7 @@ blockquote {
margin-left: 1rem;
max-width: $paragraph-max-width - 1rem; // subtract the left margin
margin-right: 0;
border-left: 1px dotted;
border-color: var(--foreground-highlight-color);
background-color: var(--background-secondary-color);
@ -79,9 +76,7 @@ button {
code {
display: inline-block;
font-size: inherit;
-moz-tab-size: 4;
tab-size: 4;
color: var(--foreground-highlight-color);
background-color: var(--background-secondary-color);
}
@ -178,7 +173,6 @@ main {
padding: 0.2rem;
overflow: hidden;
max-width: 100vw;
background-color: var(--background-primary-color);
@media (min-width: $size-md) {

8
tildes/scss/_layout.scss

@ -5,13 +5,12 @@ body {
@supports (display: grid) {
display: grid;
grid-template-rows: auto 1fr auto;
grid-template-columns: 1fr minmax(auto, $main-max-width) 1fr;
grid-template-areas:
". header ."
". main ."
". footer .";
grid-row-gap: 0.2rem;
row-gap: 0.2rem;
@media (min-width: $show-sidebar-width) {
grid-template-columns: 1fr minmax(auto, $main-max-width) $sidebar-width 1fr;
@ -19,7 +18,7 @@ body {
". header header ."
". main sidebar ."
". footer footer .";
grid-gap: 0.4rem;
gap: 0.4rem;
}
}
}
@ -56,9 +55,7 @@ body {
#site-header {
grid-area: header;
max-width: 100vw;
padding: 0.2rem;
padding-bottom: 0;
@ -83,7 +80,6 @@ body {
width: $sidebar-width;
min-width: $sidebar-width;
padding: 0.4rem;
}

3
tildes/scss/_mixins.scss

@ -1,6 +1,8 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
// stylelint-disable no-invalid-position-declaration
// shrinks a font size by 0.1rem on mobile screen sizes
@mixin font-shrink-on-mobile($base-size) {
font-size: $base-size - 0.1rem;
@ -30,6 +32,7 @@
// Only Firefox supports overflow-wrap: anywhere so far, these two rules should be
// fairly similar for other browsers
overflow-wrap: break-word;
// stylelint-disable-next-line declaration-property-value-keyword-no-deprecated
word-break: break-word;
}
}

1
tildes/scss/_placeholders.scss

@ -30,6 +30,7 @@
ol,
ul {
$list-left-margin: 2rem;
margin: 0 0 0.4rem $list-left-margin;
li {

13
tildes/scss/modules/_btn.scss

@ -7,10 +7,8 @@
display: inline-flex;
align-items: center;
justify-content: center;
font-size: 0.6rem;
font-weight: bold;
color: var(--button-color);
background-color: transparent;
border-color: var(--button-color);
@ -79,14 +77,11 @@
align-items: center;
margin: 0 0.4rem;
padding: 0.2rem;
background: none;
border: 0;
font-size: 0.6rem;
font-weight: bold;
text-transform: capitalize;
cursor: pointer;
&.btn-used {
@ -131,7 +126,6 @@
.btn-light {
font-weight: normal;
color: var(--foreground-secondary-color);
border-color: var(--border-color);
@ -173,19 +167,14 @@
display: flex;
padding: 0.4rem;
background: none;
border: 0;
justify-content: center;
align-items: center;
font-weight: bold;
font-size: 0.6rem;
line-height: 0.6rem;
cursor: pointer;
color: var(--foreground-secondary-color);
&:hover {
@ -200,7 +189,6 @@
.btn.btn-primary {
color: var(--button-by-brightness-color);
background-color: var(--button-color);
border-color: var(--button-color);
@ -208,7 +196,6 @@
color: var(--button-by-brightness-color);
background-color: var(--button-color);
border-color: var(--button-color);
filter: brightness(90%);
}

2
tildes/scss/modules/_chip.scss

@ -3,7 +3,6 @@
.chip {
border-radius: 0;
background-color: var(--background-secondary-color);
color: var(--foreground-highlight-color);
@ -18,7 +17,6 @@
&.error {
background-color: var(--error-color);
color: var(--error-by-brightness-color);
.btn {

10
tildes/scss/modules/_comment.scss

@ -55,7 +55,6 @@
.comment-excerpt {
display: none;
margin-left: 0.4rem;
white-space: nowrap;
overflow: hidden;
@ -64,9 +63,7 @@
.comment-branch-counter {
display: none;
margin-right: 0.4rem;
color: var(--foreground-secondary-color);
}
@ -91,9 +88,7 @@
display: flex;
align-items: center;
font-size: 0.6rem;
margin-left: 0.4rem;
@media (min-width: $size-md) {
@ -142,7 +137,6 @@
.comment-label-buttons {
display: flex;
flex-wrap: wrap;
margin: 0;
padding: 0 1rem;
justify-content: space-between;
@ -292,8 +286,8 @@
// Makes it so that comments of the specified depth or greater will not indent
// their replies when they only have one reply *and* they're also the only reply to
// their parent (this avoids confusion between subtrees and siblings).
// When indenting is avoided, it adds text at the top of the next comment (the single
// reply) indicating that it's a direct reply to the above comment.
// When indenting is avoided, it adds text at the top of the next comment (the
// single reply) indicating that it's a direct reply to the above comment.
// We actually need the selector to check 2 levels up from the specified starting
// depth because of how we're utilizing nesting.

2
tildes/scss/modules/_donation.scss

@ -6,12 +6,10 @@
flex-direction: column;
align-items: center;
max-width: $paragraph-max-width;
padding: 0.4rem;
margin: 1rem 0;
border: 1px solid;
border-color: inherit;
font-size: 0.6rem;
line-height: 1.3;
text-align: center;

9
tildes/scss/modules/_form.scss

@ -25,11 +25,8 @@
}
}
select.form-select:not([multiple]):not([size]) {
// would be better to implement autoprefixer to do this
-moz-appearance: none;
-webkit-appearance: none;
select.form-select:not([multiple], [size]) {
appearance: none;
border-color: var(--border-color);
background-color: var(--background-input-color);
}
@ -72,7 +69,6 @@ select.form-select:not([multiple]):not([size]) {
padding: 0.4rem;
border: 1px dashed;
overflow: auto;
border-color: var(--border-color);
}
@ -81,7 +77,6 @@ select.form-select:not([multiple]):not([size]) {
flex-direction: row-reverse;
justify-content: flex-start;
align-items: center;
margin: 0.2rem 0;
max-width: 40rem;

2
tildes/scss/modules/_label.scss

@ -70,7 +70,7 @@
background-color: transparent;
margin: 0 0.4rem 0 0;
padding: 0;
word-wrap: break-word;
overflow-wrap: break-word;
max-width: 100%;
& + & {

1
tildes/scss/modules/_logged-in-user.scss

@ -4,7 +4,6 @@
.logged-in-user-info {
flex-direction: row-reverse;
align-items: center;
font-size: 0.8rem;
a {

1
tildes/scss/modules/_menu.scss

@ -4,7 +4,6 @@
.menu {
box-shadow: none;
border: 1px outset var(--border-color);
background-color: var(--background-primary-color);
.menu-item {

1
tildes/scss/modules/_message.scss

@ -12,7 +12,6 @@
padding: 0.2rem;
font-size: 0.7rem;
line-height: 0.9rem;
color: var(--foreground-highlight-color);
background-color: var(--background-secondary-color);

5
tildes/scss/modules/_sidebar.scss

@ -4,11 +4,11 @@
#sidebar {
// Prevents the sidebar background from being transparent on extremely old browsers
// that don't support *either* custom properties or the @supports test for them
// stylelint-disable-next-line declaration-block-no-duplicate-properties
background-color: $body-bg;
// stylelint-disable-next-line declaration-block-no-duplicate-properties
background-color: var(--background-primary-color);
border-left-color: var(--border-color);
.btn {
@ -52,7 +52,6 @@
padding: 0.2rem 0.4rem;
align-items: center;
justify-content: space-between;
background-color: var(--background-secondary-color);
}
@ -62,13 +61,11 @@
position: absolute;
right: 0;
top: 0;
min-width: 0 !important;
max-width: 90vw;
z-index: 1000;
min-height: 100vh;
height: 100%;
border-left: 3px double;
}
}

1
tildes/scss/modules/_site-footer.scss

@ -20,7 +20,6 @@
display: flex;
flex-wrap: wrap;
justify-content: space-around;
list-style-type: none;
margin: 0 auto;
max-width: 50rem;

2
tildes/scss/modules/_site-header.scss

@ -66,10 +66,8 @@
padding-left: 40px;
padding-right: 8px;
line-height: 32px;
font-size: 1.2rem;
font-weight: bold;
color: var(--foreground-highlight-color);
&:visited {

1
tildes/scss/modules/_tab.scss

@ -32,7 +32,6 @@
flex-wrap: nowrap;
padding-left: 0;
margin-top: 0;
justify-content: space-around;
// have the tabs span the full width at small sizes

4
tildes/scss/modules/_theme-preview.scss

@ -11,14 +11,14 @@
min-width: 6rem;
margin: 0.4rem;
padding: 1rem;
text-align: center;
font-weight: bold;
white-space: nowrap;
}
.theme-preview-fake-posts {
// Disables all click events (and hover) on the fake posts so links/buttons don't work
// Disables all click events (and hover) on the fake posts
// so links/buttons don't work
pointer-events: none;
// Set a max width on the fake topics so the vote button isn't way off to the right

1
tildes/scss/modules/_toast.scss

@ -6,7 +6,6 @@
margin: 1rem 0;
font-weight: bold;
color: var(--foreground-highlight-color);
background-color: var(--background-secondary-color);
border-color: var(--border-color);

11
tildes/scss/modules/_topic.scss

@ -23,10 +23,11 @@
"info actions"
"action-settings action-settings";
grid-template-columns: 1fr auto;
grid-gap: 0.2rem;
gap: 0.2rem;
// set some minimum row heights on mobile to space them out a bit
$row-height: $min-touch-size - 4px; // subtract grid-gap
grid-template-rows: repeat(3, minmax($row-height, auto));
// on larger screens, rows can size automatically
@ -35,7 +36,6 @@
}
align-items: center;
position: relative;
// smaller bottom padding to account for the empty .post-action-settings div
@ -251,7 +251,6 @@
margin: 0;
overflow: hidden;
font-style: italic;
color: var(--foreground-secondary-color);
h1 {
@ -291,9 +290,7 @@
.topic-info {
display: grid;
grid-template-columns: 1fr 1.5fr 0.7fr;
grid-column-gap: 0.4rem;
column-gap: 0.4rem;
align-items: end;
max-width: 32rem;
white-space: nowrap;
@ -350,7 +347,6 @@
display: grid;
grid-template-columns: max-content minmax(auto, $paragraph-max-width);
align-items: baseline;
margin: 0;
}
@ -407,7 +403,6 @@
display: flex;
flex-wrap: wrap;
align-items: center;
margin-bottom: 0.4rem;
h2 {

3
tildes/scss/styles.scss

@ -2,13 +2,10 @@
@import "functions";
@import "variables";
@import "spectre-0.5.1/variables";
@import "mixins";
@import "placeholders";
@import "base";
@import "layout";
@import "modules/breadcrumbs";
@import "modules/btn";
@import "modules/chip";

18
tildes/scss/themes/_atom_one_dark.scss

@ -2,18 +2,18 @@
// https://github.com/atom/atom/blob/master/packages/one-dark-syntax/styles/colors.less
// Base colors
$background: hsl(220, 13%, 18%);
$background: hsl(220deg, 13%, 18%);
$background-alt: #21242b;
$foreground: hsl(220, 14%, 71%);
$foreground-alt: hsl(220, 9%, 55%);
$foreground: hsl(220deg, 14%, 71%);
$foreground-alt: hsl(220deg, 9%, 55%);
// Accent colors
$cyan: hsl(187, 47%, 55%);
$blue: hsl(207, 82%, 66%);
$purple: hsl(286, 60%, 67%);
$green: hsl(95, 38%, 62%);
$red: hsl(355, 65%, 65%);
$orange: hsl(29, 54%, 61%);
$cyan: hsl(187deg, 47%, 55%);
$blue: hsl(207deg, 82%, 66%);
$purple: hsl(286deg, 60%, 67%);
$green: hsl(95deg, 38%, 62%);
$red: hsl(355deg, 65%, 65%);
$orange: hsl(29deg, 54%, 61%);
// Actual theme definition
$theme-atom-one-dark: (

2
tildes/scss/themes/_dracula.scss

@ -12,7 +12,7 @@ $green: #50fa7b;
$orange: #ffb86c;
$pink: #ff79c6;
$purple: #bd93f9;
$red: #ff5555;
$red: #f55;
$yellow: #f1fa8c;
// Actual theme definition

18
tildes/scss/themes/_theme_mixins.scss

@ -144,7 +144,7 @@
input[readonly],
textarea,
textarea[readonly],
.form-select:not([multiple]):not([size]) {
.form-select:not([multiple], [size]) {
background-color: map-get($theme, "background-input");
}
@ -172,7 +172,6 @@
// When creating CSS custom properties and using any of Sass' capabilities
// you'll have to interpolate it with the Sass syntax `#{...}` as seen below.
--alert-color: #{map-get($theme, "alert")};
--background-input-color: #{map-get($theme, "background-input")};
--background-mixed-color:
#{mix(
@ -181,9 +180,7 @@
)};
--background-primary-color: #{map-get($theme, "background-primary")};
--background-secondary-color: #{map-get($theme, "background-secondary")};
--border-color: #{map-get($theme, "border")};
--button-color: #{map-get($theme, "button")};
--button-by-brightness-color:
#{choose-by-brightness(
@ -192,9 +189,7 @@
#fff
)};
--button-transparent-color: #{rgba(map-get($theme, "button"), 0.2)};
--button-used-color: #{map-get($theme, "button-used")};
--error-color: #{map-get($theme, "error")};
--error-by-brightness-color:
#{choose-by-brightness(
@ -202,7 +197,6 @@
#000,
#fff
)};
--foreground-extreme-color:
#{choose-by-brightness(
map-get($theme, "background-primary"),
@ -217,16 +211,12 @@
)};
--foreground-primary-color: #{map-get($theme, "foreground-primary")};
--foreground-secondary-color: #{map-get($theme, "foreground-secondary")};
--link-color: #{map-get($theme, "link")};
--link-hover-color: #{map-get($theme, "link-hover")};
--link-visited-color: #{map-get($theme, "link-visited")};
--stripe-mine-color: #{map-get($theme, "stripe-mine")};
--stripe-target-color: #{map-get($theme, "stripe-target")};
--success-color: #{map-get($theme, "success")};
--syntax-builtin-color: #{map-get($theme, "syntax-builtin")};
--syntax-comment-color: #{map-get($theme, "syntax-comment")};
--syntax-constant-color: #{map-get($theme, "syntax-constant")};
@ -239,7 +229,6 @@
--topic-tag-nsfw-color: #{map-get($theme, "topic-tag-nsfw")};
--topic-tag-nsfw-foreground-color: #fff;
--topic-tag-nsfw-border-color: transparent;
--topic-tag-spoiler-color: #{map-get($theme, "topic-tag-spoiler")};
--topic-tag-spoiler-foreground-color: #fff;
--topic-tag-spoiler-border-color: transparent;
@ -247,7 +236,6 @@
--topic-tag-nsfw-color: transparent;
--topic-tag-nsfw-foreground-color: #{map-get($theme, "topic-tag-nsfw")};
--topic-tag-nsfw-border-color: #{map-get($theme, "topic-tag-nsfw")};
--topic-tag-spoiler-color: transparent;
--topic-tag-spoiler-foreground-color: #{map-get($theme, "topic-tag-spoiler")};
--topic-tag-spoiler-border-color: #{map-get($theme, "topic-tag-spoiler")};
@ -271,13 +259,11 @@
--background-label-noise-color: #{map-get($theme, "comment-label-noise")};
--background-label-offtopic-color: #{map-get($theme, "comment-label-offtopic")};
--background-label-malice-color: #{map-get($theme, "comment-label-malice")};
--comment-label-exemplary-color: #{map-get($theme, "comment-label-exemplary")};
--comment-label-joke-color: #{map-get($theme, "comment-label-joke")};
--comment-label-noise-color: #{map-get($theme, "comment-label-noise")};
--comment-label-offtopic-color: #{map-get($theme, "comment-label-offtopic")};
--comment-label-malice-color: #{map-get($theme, "comment-label-malice")};
--foreground-label-exemplary-color: #fff;
--foreground-label-joke-color: #fff;
--foreground-label-noise-color: #fff;
@ -289,13 +275,11 @@
--background-label-noise-color: transparent;
--background-label-offtopic-color: transparent;
--background-label-malice-color: transparent;
--comment-label-exemplary-color: #{map-get($theme, "comment-label-exemplary")};
--comment-label-joke-color: #{map-get($theme, "comment-label-joke")};
--comment-label-noise-color: #{map-get($theme, "comment-label-noise")};
--comment-label-offtopic-color: #{map-get($theme, "comment-label-offtopic")};
--comment-label-malice-color: #{map-get($theme, "comment-label-malice")};
--foreground-label-exemplary-color: #{map-get($theme, "comment-label-exemplary")};
--foreground-label-joke-color: #{map-get($theme, "comment-label-joke")};
--foreground-label-noise-color: #{map-get($theme, "comment-label-noise")};

7
tildes/static/js/behaviors/auto-focus.js

@ -1,14 +1,11 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-auto-focus]", function() {
$.onmount("[data-js-auto-focus]", function () {
var $input = $(this);
// just calling .focus() will place the cursor at the start of the field,
// so un-setting and re-setting the value moves the cursor to the end
var original_val = $input.val();
$input
.focus()
.val("")
.val(original_val);
$input.focus().val("").val(original_val);
});

10
tildes/static/js/behaviors/autocomplete-chip-clear.js

@ -1,7 +1,7 @@
// Copyright (c) 2019 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-autocomplete-chip-clear]", function() {
$.onmount("[data-js-autocomplete-chip-clear]", function () {
function clearChip($chip) {
var $tagsHiddenInput = $("[data-js-autocomplete-hidden-input]");
var $autocompleteInput = $("[data-js-autocomplete-input]");
@ -11,22 +11,22 @@ $.onmount("[data-js-autocomplete-chip-clear]", function() {
$tagsHiddenInput.val(
tags
.filter(function(tag) {
.filter(function (tag) {
return tag !== tagToRemove;
})
.join(",")
.join(","),
);
$chip.remove();
$autocompleteInput.focus();
}
$(this).click(function(event) {
$(this).click(function (event) {
event.preventDefault();
clearChip($(this).parent());
});
$(this).keydown(function(event) {
$(this).keydown(function (event) {
switch (event.key) {
case "Backspace":
event.preventDefault();

33
tildes/static/js/behaviors/autocomplete-input.js

@ -1,7 +1,7 @@
// Copyright (c) 2019 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-autocomplete-input]", function() {
$.onmount("[data-js-autocomplete-input]", function () {
function addChip($input, userTypedComma) {
var $autocompleteContainer = $input
.parents("[data-js-autocomplete-container]")
@ -15,10 +15,10 @@ $.onmount("[data-js-autocomplete-input]", function() {
var inputTags = $input
.val()
.split(",")
.map(function(tag) {
.map(function (tag) {
return tag.trim();
})
.filter(function(tag) {
.filter(function (tag) {
return tag !== "";
});
@ -28,7 +28,7 @@ $.onmount("[data-js-autocomplete-input]", function() {
inputTags = inputTags.slice(0, 1);
}
inputTags.forEach(function(tag) {
inputTags.forEach(function (tag) {
if (!$tagsHiddenInput.val().match(new RegExp("(^|,)" + tag + ","))) {
var clearIcon = document.createElement("a");
clearIcon.classList.add("btn");
@ -47,7 +47,7 @@ $.onmount("[data-js-autocomplete-input]", function() {
$chip.addClass("error");
$chip.attr(
"title",
"Tags may only contain letters, numbers, and spaces."
"Tags may only contain letters, numbers, and spaces.",
);
}
@ -74,7 +74,7 @@ $.onmount("[data-js-autocomplete-input]", function() {
$(this)
.closest("form")
/* eslint-disable-next-line no-unused-vars */
.on("beforeSend.ic", function(evt, elt, data, settings, xhr, requestId) {
.on("beforeSend.ic", function (evt, elt, data, settings, xhr, requestId) {
var $autocompleteInput = $(elt)
.find("[data-js-autocomplete-input]")
.first();
@ -98,7 +98,7 @@ $.onmount("[data-js-autocomplete-input]", function() {
addChip($(this));
}
$(this).focus(function() {
$(this).focus(function () {
var $autocompleteContainer = $(this)
.parents("[data-js-autocomplete-container]")
.first();
@ -109,7 +109,7 @@ $.onmount("[data-js-autocomplete-input]", function() {
$chips.children().removeClass("active");
});
$(this).keydown(function(event) {
$(this).keydown(function (event) {
var $this = $(this);
var $autocompleteMenu = $("[data-js-autocomplete-menu]").first();
var $nextActiveItem = null;
@ -121,7 +121,7 @@ $.onmount("[data-js-autocomplete-input]", function() {
break;
case ",":
// wait for comma to be added to text so addChip() sees it
setTimeout(function() {
setTimeout(function () {
addChip($this, true);
}, 100);
break;
@ -171,7 +171,7 @@ $.onmount("[data-js-autocomplete-input]", function() {
}
});
$(this).keyup(function() {
$(this).keyup(function () {
var $this = $(this);
var $autocompleteMenu = $("[data-js-autocomplete-menu]");
if ($autocompleteMenu) {
@ -183,14 +183,9 @@ $.onmount("[data-js-autocomplete-input]", function() {
var $tagsHiddenInput = $("[data-js-autocomplete-hidden-input]");
var suggestions = $this
.data("js-autocomplete-input")
.filter(function(suggestion) {
.filter(function (suggestion) {
return (
suggestion.startsWith(
$this
.val()
.toLowerCase()
.trim()
) &&
suggestion.startsWith($this.val().toLowerCase().trim()) &&
!$tagsHiddenInput
.val()
.match(new RegExp("(^|,)" + suggestion + ","))
@ -202,7 +197,7 @@ $.onmount("[data-js-autocomplete-input]", function() {
var $autocompleteSuggestions = $("[data-js-autocomplete-suggestions]");
$autocompleteMenu = $('<ol class="menu" data-js-autocomplete-menu>');
suggestions.forEach(function(suggestion) {
suggestions.forEach(function (suggestion) {
$autocompleteMenu.append(
'<li class="menu-item">' +
'<a href="#" data-js-autocomplete-menu-item>' +
@ -212,7 +207,7 @@ $.onmount("[data-js-autocomplete-input]", function() {
"</div>" +
"</div>" +
"</a>" +
"</li>"
"</li>",
);
});
$autocompleteSuggestions.append($autocompleteMenu);

20
tildes/static/js/behaviors/autocomplete-menu-item.js

@ -1,7 +1,7 @@
// Copyright (c) 2019 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-autocomplete-menu-item]", function() {
$.onmount("[data-js-autocomplete-menu-item]", function () {
function addChip($menuItem) {
var $autocompleteContainer = $menuItem
.parents("[data-js-autocomplete-container]")
@ -13,7 +13,7 @@ $.onmount("[data-js-autocomplete-menu-item]", function() {
var existingTags = $tagsHiddenInput.val().split(",");
if (
existingTags.every(function(val) {
existingTags.every(function (val) {
return val !== clickedSuggestionText;
})
) {
@ -46,18 +46,16 @@ $.onmount("[data-js-autocomplete-menu-item]", function() {
$.onmount();
}
$(this).click(function(event) {
$(this).click(function (event) {
event.preventDefault();
addChip($(this), event);
});
$(this).keydown(function(event) {
$(this).keydown(function (event) {
var $nextActiveItem = null;
switch (event.key) {
case "Escape":
$("[data-js-autocomplete-menu]")
.parent()
.remove();
$("[data-js-autocomplete-menu]").parent().remove();
break;
case "Enter":
event.preventDefault();
@ -65,9 +63,7 @@ $.onmount("[data-js-autocomplete-menu-item]", function() {
break;
case "ArrowDown":
event.preventDefault();
$nextActiveItem = $(this)
.parent()
.next();
$nextActiveItem = $(this).parent().next();
$nextActiveItem
.children("[data-js-autocomplete-menu-item]")
.first()
@ -75,9 +71,7 @@ $.onmount("[data-js-autocomplete-menu-item]", function() {
break;
case "ArrowUp":
event.preventDefault();
$nextActiveItem = $(this)
.parent()
.prev();
$nextActiveItem = $(this).parent().prev();
$nextActiveItem
.children("[data-js-autocomplete-menu-item]")
.first()

4
tildes/static/js/behaviors/autocomplete-menu.js

@ -1,7 +1,7 @@
// Copyright (c) 2019 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-autocomplete-menu]", function() {
$.onmount("[data-js-autocomplete-menu]", function () {
var $autocompleteContainer = $(this)
.parents("[data-js-autocomplete-container]")
.first();
@ -9,7 +9,7 @@ $.onmount("[data-js-autocomplete-menu]", function() {
$(this)
.children("[data-js-autocomplete-menu-item]")
.each(function(index, $menuItem) {
.each(function (index, $menuItem) {
$menuItem.setAttribute("tabindex", $chips.children().length + index);
});
});

4
tildes/static/js/behaviors/autoselect-input.js

@ -1,8 +1,8 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-autoselect-input]", function() {
$(this).click(function() {
$.onmount("[data-js-autoselect-input]", function () {
$(this).click(function () {
$(this).select();
});
});

8
tildes/static/js/behaviors/autosubmit-on-change.js

@ -1,10 +1,8 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-autosubmit-on-change]", function() {
$(this).change(function() {
$(this)
.closest("form")
.submit();
$.onmount("[data-js-autosubmit-on-change]", function () {
$(this).change(function () {
$(this).closest("form").submit();
});
});

16
tildes/static/js/behaviors/cancel-button.js

@ -1,8 +1,8 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-cancel-button]", function() {
$(this).click(function() {
$.onmount("[data-js-cancel-button]", function () {
$(this).click(function () {
var $parentForm = $(this).closest("form");
var shouldRemove = true;
@ -11,9 +11,11 @@ $.onmount("[data-js-cancel-button]", function() {
var confirmPrompt = $parentForm.attr("data-js-confirm-cancel");
if (confirmPrompt) {
// only prompt if any of the inputs aren't empty
var $nonEmptyFields = $parentForm.find("input,textarea").filter(function() {
return $(this).val();
});
var $nonEmptyFields = $parentForm
.find("input,textarea")
.filter(function () {
return $(this).val();
});
if ($nonEmptyFields.length > 0) {
shouldRemove = window.confirm(confirmPrompt);
@ -23,9 +25,7 @@ $.onmount("[data-js-cancel-button]", function() {
}
if (shouldRemove) {
$(this)
.closest("form")
.remove();
$(this).closest("form").remove();
}
});
});

25
tildes/static/js/behaviors/comment-collapse-all-button.js

@ -1,24 +1,21 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-comment-collapse-all-button]", function() {
$(this).click(function() {
$.onmount("[data-js-comment-collapse-all-button]", function () {
$(this).click(function () {
// first uncollapse any individually collapsed comments
$(".is-comment-collapsed-individual").each(function(idx, child) {
$(child)
.find("[data-js-comment-collapse-button]:first")
.trigger("click");
$(".is-comment-collapsed-individual").each(function (idx, child) {
$(child).find("[data-js-comment-collapse-button]:first").trigger("click");
});
// then collapse all first-level replies
$('.comment[data-comment-depth="1"]:not(.is-comment-collapsed)').each(function(
idx,
child
) {
$(child)
.find("[data-js-comment-collapse-button]:first")
.trigger("click");
});
$('.comment[data-comment-depth="1"]:not(.is-comment-collapsed)').each(
function (idx, child) {
$(child)
.find("[data-js-comment-collapse-button]:first")
.trigger("click");
},
);
$(this).blur();
});

4
tildes/static/js/behaviors/comment-collapse-button.js

@ -1,8 +1,8 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-comment-collapse-button]", function() {
$(this).click(function() {
$.onmount("[data-js-comment-collapse-button]", function () {
$(this).click(function () {
var $this = $(this);
var $comment = $this.closest(".comment");

20
tildes/static/js/behaviors/comment-collapse-read-button.js

@ -1,30 +1,30 @@
// Copyright (c) 2019 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-comment-collapse-read-button]", function() {
var commentExpand = function(idx, elem) {
$.onmount("[data-js-comment-collapse-read-button]", function () {
var commentExpand = function (idx, elem) {
$(elem).removeClass("is-comment-collapsed");
$(elem).removeClass("is-comment-collapsed-individual");
};
var commentCollapse = function(idx, elem) {
var commentCollapse = function (idx, elem) {
$(elem).removeClass("is-comment-collapsed-individual");
$(elem).addClass("is-comment-collapsed");
};
var commentCollapseIndividual = function(idx, elem) {
var commentCollapseIndividual = function (idx, elem) {
$(elem).removeClass("is-comment-collapsed");
$(elem).addClass("is-comment-collapsed-individual");
};
$(this).click(function() {
$(this).click(function () {
// expand all comments to start with consistent state
$(".is-comment-collapsed, .is-comment-collapsed-individual").each(
commentExpand
commentExpand,
);
// fully collapse the "shallowest" comment in a branch with no new descendants
$(".comment").each(function(idx, elem) {
$(".comment").each(function (idx, elem) {
if (
$(elem).parents(".is-comment-collapsed").length === 0 &&
$(elem).find(".is-comment-new").length === 0
@ -33,7 +33,7 @@ $.onmount("[data-js-comment-collapse-read-button]", function() {
});
// expand new comments
$(".is-comment-new").each(function(idx, elem) {
$(".is-comment-new").each(function (idx, elem) {
$(elem)
// expand new comments just in case they were collapsed above
.each(commentExpand)
@ -45,10 +45,10 @@ $.onmount("[data-js-comment-collapse-read-button]", function() {
// immediate parent of a new comment (in the case one new comment
// responds to another)
.parents(".comment")
.each(function(idx2, ancestor) {
.each(function (idx2, ancestor) {
if (
$(ancestor).find(
"> .comment-tree > .comment-tree-item > .is-comment-new"
"> .comment-tree > .comment-tree-item > .is-comment-new",
).length === 0
)
commentCollapseIndividual(idx2, ancestor);

19
tildes/static/js/behaviors/comment-expand-all-button.js

@ -1,16 +1,15 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-comment-expand-all-button]", function() {
$(this).click(function() {
$(".is-comment-collapsed, .is-comment-collapsed-individual").each(function(
idx,
child
) {
$(child)
.find("[data-js-comment-collapse-button]:first")
.trigger("click");
});
$.onmount("[data-js-comment-expand-all-button]", function () {
$(this).click(function () {
$(".is-comment-collapsed, .is-comment-collapsed-individual").each(
function (idx, child) {
$(child)
.find("[data-js-comment-collapse-button]:first")
.trigger("click");
},
);
$(this).blur();
});

27
tildes/static/js/behaviors/comment-label-button.js

@ -1,13 +1,11 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-comment-label-button]", function() {
$(this).click(function(event) {
$.onmount("[data-js-comment-label-button]", function () {
$(this).click(function (event) {
event.preventDefault();
var $comment = $(this)
.parents(".comment")
.first();
var $comment = $(this).parents(".comment").first();
var userLabels = $comment.attr("data-comment-user-labels");
// check if the label button div already exists and just remove it if so
@ -46,11 +44,11 @@ $.onmount("[data-js-comment-label-button]", function() {
if (labelPrompt) {
label.setAttribute(
"data-ic-confirm",
"Remove your " + labelName + " label?"
"Remove your " + labelName + " label?",
);
}
$(label).on("after.success.ic", function(evt) {
$(label).on("after.success.ic", function (evt) {
var labelName = evt.target.getAttribute("data-js-label-name");
Tildes.removeUserLabel(commentID, labelName);
});
@ -62,7 +60,7 @@ $.onmount("[data-js-comment-label-button]", function() {
label.setAttribute("data-ic-prompt-name", "reason");
}
$(label).on("after.success.ic", function(evt) {
$(label).on("after.success.ic", function (evt) {
var labelName = evt.target.getAttribute("data-js-label-name");
Tildes.addUserLabel(commentID, labelName);
@ -70,7 +68,7 @@ $.onmount("[data-js-comment-label-button]", function() {
// template since they can't use it again anyway
if (labelName === "exemplary") {
var exemplaryButton = labeltemplate.content.querySelector(
".btn-comment-label-exemplary"
".btn-comment-label-exemplary",
);
if (exemplaryButton) {
exemplaryButton.parentElement.remove();
@ -81,21 +79,18 @@ $.onmount("[data-js-comment-label-button]", function() {
label.setAttribute(
"data-ic-target",
"#comment-" + commentID + " .comment-itself:first"
"#comment-" + commentID + " .comment-itself:first",
);
}
// update Intercooler so it knows about these new elements
Intercooler.processNodes(clone);
$comment
.find(".btn-post")
.first()
.after(clone);
$comment.find(".btn-post").first().after(clone);
});
});
Tildes.removeUserLabel = function(commentID, labelName) {
Tildes.removeUserLabel = function (commentID, labelName) {
var $comment = $("#comment-" + commentID);
var userLabels = $comment.attr("data-comment-user-labels").split(" ");
@ -110,7 +105,7 @@ Tildes.removeUserLabel = function(commentID, labelName) {
$comment.attr("data-comment-user-labels", userLabels.join(" "));
};
Tildes.addUserLabel = function(commentID, labelName) {
Tildes.addUserLabel = function (commentID, labelName) {
var $comment = $("#comment-" + commentID);
var userLabels = $comment.attr("data-comment-user-labels").split(" ");

10
tildes/static/js/behaviors/comment-parent-button.js

@ -1,17 +1,15 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-comment-parent-button]", function() {
$(this).click(function() {
var $comment = $(this)
.parents(".comment")
.first();
$.onmount("[data-js-comment-parent-button]", function () {
$(this).click(function () {
var $comment = $(this).parents(".comment").first();
var $parentComment = $comment.parents(".comment").first();
var backButton = document.createElement("a");
backButton.setAttribute(
"href",
"#comment-" + $comment.attr("data-comment-id36")
"#comment-" + $comment.attr("data-comment-id36"),
);
backButton.setAttribute("class", "comment-nav-link");
backButton.setAttribute("data-js-comment-back-button", "");

4
tildes/static/js/behaviors/comment-reply-form.js

@ -1,7 +1,7 @@
// Copyright (c) 2020 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-comment-reply-form]", function() {
$.onmount("[data-js-comment-reply-form]", function () {
var $this = $(this);
// the parent comment's Reply button (that was clicked to create this form)
@ -14,7 +14,7 @@ $.onmount("[data-js-comment-reply-form]", function() {
$replyButton.css("pointer-events", "none");
// have the Cancel button re-enable click/hover events on the reply button
$this.find("[data-js-cancel-button]").click(function() {
$this.find("[data-js-cancel-button]").click(function () {
$replyButton.css("pointer-events", "auto");
});

4
tildes/static/js/behaviors/confirm-leave-page-unsaved.js

@ -1,14 +1,14 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-confirm-leave-page-unsaved]", function() {
$.onmount("[data-js-confirm-leave-page-unsaved]", function () {
var $form = $(this);
$form.areYouSure();
// Fixes a strange interaction between Intercooler and AreYouSure, where
// submitting a form by using the keyboard to push the submit button would
// trigger a confirmation prompt before leaving the page.
$form.on("success.ic", function() {
$form.on("success.ic", function () {
$form.removeClass("dirty");
});
});

8
tildes/static/js/behaviors/copy-button.js

@ -1,8 +1,8 @@
// Copyright (c) 2020 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-copy-button]", function() {
$(this).click(function(event) {
$.onmount("[data-js-copy-button]", function () {
$(this).click(function (event) {
event.preventDefault();
var textToCopy;
@ -25,10 +25,10 @@ $.onmount("[data-js-copy-button]", function() {
});
});
Tildes.writeToClipboard = function(text) {
Tildes.writeToClipboard = function (text) {
// Minimal polyfill for writing to clipboard, by Lucas Garron
// https://gist.github.com/lgarron/d1dee380f4ed9d825ca7
return new Promise(function(resolve, reject) {
return new Promise(function (resolve, reject) {
var success = false;
function listener(event) {
event.clipboardData.setData("text/plain", text);

8
tildes/static/js/behaviors/ctrl-enter-submit-form.js

@ -1,15 +1,13 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-ctrl-enter-submit-form]", function() {
$(this).keydown(function(event) {
$.onmount("[data-js-ctrl-enter-submit-form]", function () {
$(this).keydown(function (event) {
if (
(event.ctrlKey || event.metaKey) &&
(event.keyCode == 13 || event.keyCode == 10)
) {
$(this)
.closest("form")
.submit();
$(this).closest("form").submit();
}
});
});

10
tildes/static/js/behaviors/dropdown-toggle.js

@ -4,8 +4,8 @@
// Note: unlike almost all other JS behaviors, this one does not attach to elements
// based on the presence of a data-js-* HTML attribute. This attaches to any element
// with the dropdown-toggle class so that this behavior is always applied to dropdowns.
$.onmount(".dropdown-toggle", function() {
$(this).click(function() {
$.onmount(".dropdown-toggle", function () {
$(this).click(function () {
var $this = $(this);
// Spectre.css's dropdown menus use the focus event to display the menu,
@ -32,7 +32,7 @@ $.onmount(".dropdown-toggle", function() {
.parent()
.toggleClass(
"dropdown-right",
$this.offset().left + $this.outerWidth() - $menu.outerWidth() > 0
$this.offset().left + $this.outerWidth() - $menu.outerWidth() > 0,
);
// If the menu extends past the bottom of the viewport, or the site footer
@ -45,11 +45,11 @@ $.onmount(".dropdown-toggle", function() {
.parent()
.toggleClass(
"dropdown-bottom",
menuBottom > viewportHeight + scrollTop || menuBottom > footerTop
menuBottom > viewportHeight + scrollTop || menuBottom > footerTop,
);
});
$(this).blur(function() {
$(this).blur(function () {
$(this).removeClass("active");
});
});

4
tildes/static/js/behaviors/external-links-new-tabs.js

@ -1,11 +1,11 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-external-links-new-tabs]", function() {
$.onmount("[data-js-external-links-new-tabs]", function () {
// Open external links in topic, comment, and message text in new tabs
$(this)
.find("a")
.each(function() {
.each(function () {
if (this.host !== window.location.host) {
$(this).attr("target", "_blank");
$(this).attr("rel", "noopener");

8
tildes/static/js/behaviors/fadeout-parent-on-success.js

@ -1,10 +1,8 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-fadeout-parent-on-success]", function() {
$(this).on("after.success.ic", function() {
$(this)
.parent()
.fadeOut("fast");
$.onmount("[data-js-fadeout-parent-on-success]", function () {
$(this).on("after.success.ic", function () {
$(this).parent().fadeOut("fast");
});
});

4
tildes/static/js/behaviors/group-links-new-tabs.js

@ -1,11 +1,11 @@
// Copyright (c) 2020 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-group-links-new-tabs]", function() {
$.onmount("[data-js-group-links-new-tabs]", function () {
// Open links to groups on Tildes in new tabs
$(this)
.find(".link-group")
.each(function() {
.each(function () {
$(this).attr("target", "_blank");
});
});

4
tildes/static/js/behaviors/hide-sidebar-if-open.js

@ -1,8 +1,8 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-hide-sidebar-if-open]", function() {
$(this).on("click", function(event) {
$.onmount("[data-js-hide-sidebar-if-open]", function () {
$(this).on("click", function (event) {
if ($("#sidebar").hasClass("is-sidebar-displayed")) {
event.preventDefault();
event.stopPropagation();

4
tildes/static/js/behaviors/hide-sidebar-no-preventdefault.js

@ -1,8 +1,8 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-hide-sidebar-no-preventdefault]", function() {
$(this).on("click", function() {
$.onmount("[data-js-hide-sidebar-no-preventdefault]", function () {
$(this).on("click", function () {
$("#sidebar").removeClass("is-sidebar-displayed");
});
});

12
tildes/static/js/behaviors/markdown-edit-tab.js

@ -1,14 +1,10 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-markdown-edit-tab]", function() {
$(this).click(function() {
var $editTextarea = $(this)
.closest("form")
.find('[name="markdown"]');
var $previewDiv = $(this)
.closest("form")
.find(".form-markdown-preview");
$.onmount("[data-js-markdown-edit-tab]", function () {
$(this).click(function () {
var $editTextarea = $(this).closest("form").find('[name="markdown"]');
var $previewDiv = $(this).closest("form").find(".form-markdown-preview");
$editTextarea.removeClass("d-none");
$previewDiv.addClass("d-none");

14
tildes/static/js/behaviors/markdown-preview-tab.js

@ -1,14 +1,10 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-markdown-preview-tab]", function() {
$(this).click(function() {
var $editTextarea = $(this)
.closest("form")
.find('[name="markdown"]');
var $previewDiv = $(this)
.closest("form")
.find(".form-markdown-preview");
$.onmount("[data-js-markdown-preview-tab]", function () {
$(this).click(function () {
var $editTextarea = $(this).closest("form").find('[name="markdown"]');
var $previewDiv = $(this).closest("form").find(".form-markdown-preview");
var $previewErrors = $(this)
.closest("form")
.find(".text-status-message.text-error");
@ -18,7 +14,7 @@ $.onmount("[data-js-markdown-preview-tab]", function() {
$previewErrors.remove();
});
$(this).on("after.success.ic success.ic", function(event) {
$(this).on("after.success.ic success.ic", function (event) {
// Stop intercooler event from bubbling up past this button. This
// prevents behaviors on parent elements from mistaking a successful
// "preview" from a successful "submit".

6
tildes/static/js/behaviors/prevent-double-submit.js

@ -1,9 +1,9 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-prevent-double-submit]", function() {
$.onmount("[data-js-prevent-double-submit]", function () {
/* eslint-disable-next-line no-unused-vars */
$(this).on("beforeSend.ic", function(evt, elt, data, settings, xhr, requestId) {
$(this).on("beforeSend.ic", function (evt, elt, data, settings, xhr, requestId) {
var $form = $(this);
if ($form.attr("data-js-submitting") !== undefined) {
@ -14,7 +14,7 @@ $.onmount("[data-js-prevent-double-submit]", function() {
}
});
$(this).on("complete.ic", function() {
$(this).on("complete.ic", function () {
$(this).removeAttr("data-js-submitting");
});
});

4
tildes/static/js/behaviors/remove-on-click.js

@ -1,8 +1,8 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-remove-on-click]", function() {
$(this).on("click", function() {
$.onmount("[data-js-remove-on-click]", function () {
$(this).on("click", function () {
$(this).remove();
});
});

4
tildes/static/js/behaviors/remove-on-success.js

@ -1,8 +1,8 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-remove-on-success]", function() {
$(this).on("after.success.ic", function() {
$.onmount("[data-js-remove-on-success]", function () {
$(this).on("after.success.ic", function () {
$(this).remove();
});
});

4
tildes/static/js/behaviors/sidebar-toggle.js

@ -1,8 +1,8 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-sidebar-toggle]", function() {
$(this).click(function(event) {
$.onmount("[data-js-sidebar-toggle]", function () {
$(this).click(function (event) {
event.preventDefault();
event.stopPropagation();

4
tildes/static/js/behaviors/stripe-checkout.js

@ -1,10 +1,10 @@
// Copyright (c) 2019 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-stripe-checkout]", function() {
$.onmount("[data-js-stripe-checkout]", function () {
/* eslint-disable-next-line no-undef */
var stripe = Stripe($(this).attr("data-js-stripe-checkout"));
stripe.redirectToCheckout({
sessionId: $(this).attr("data-js-stripe-checkout-session")
sessionId: $(this).attr("data-js-stripe-checkout-session"),
});
});

4
tildes/static/js/behaviors/stripe-donate-form.js

@ -1,8 +1,8 @@
// Copyright (c) 2019 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-stripe-donate-form]", function() {
$(this).on("submit", function(event) {
$.onmount("[data-js-stripe-donate-form]", function () {
$(this).on("submit", function (event) {
var $amountInput = $(this).find("#amount");
var amount = $amountInput.val();

8
tildes/static/js/behaviors/tab.js

@ -1,11 +1,9 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-tab]", function() {
$(this).click(function() {
$(this)
.siblings()
.removeClass("active");
$.onmount("[data-js-tab]", function () {
$(this).click(function () {
$(this).siblings().removeClass("active");
$(this).addClass("active");
});
});

4
tildes/static/js/behaviors/theme-preview.js

@ -1,8 +1,8 @@
// Copyright (c) 2019 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-theme-preview]", function() {
$(this).click(function() {
$.onmount("[data-js-theme-preview]", function () {
$(this).click(function () {
var newTheme = $(this).attr("data-js-theme-preview");
Tildes.changeTheme(newTheme);

15
tildes/static/js/behaviors/theme-selector.js

@ -1,17 +1,14 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-theme-selector]", function() {
$.onmount("[data-js-theme-selector]", function () {
Tildes.toggleSetDefaultThemeButton($(this));
$(this).change(function(event) {
$(this).change(function (event) {
event.preventDefault();
// hide any IC change message
$(this)
.parent()
.find(".text-status-message")
.hide();
$(this).parent().find(".text-status-message").hide();
var new_theme = $(this).val();
@ -28,10 +25,8 @@ $.onmount("[data-js-theme-selector]", function() {
});
});
Tildes.toggleSetDefaultThemeButton = function(element) {
var selected_text = $(element)
.find("option:selected")
.text();
Tildes.toggleSetDefaultThemeButton = function (element) {
var selected_text = $(element).find("option:selected").text();
var $setDefaultButton = $("#button-set-default-theme");
// set visibility of 'Set as account default' button
if (selected_text.indexOf("account default") === -1) {

6
tildes/static/js/behaviors/time-period-select.js

@ -1,8 +1,8 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-time-period-select]", function() {
$(this).change(function() {
$.onmount("[data-js-time-period-select]", function () {
$(this).change(function () {
var periodValue = this.value;
if (periodValue === "other") {
@ -12,7 +12,7 @@ $.onmount("[data-js-time-period-select]", function() {
// prompt for a time period until they enter a valid one
while (!validRegex.test(enteredPeriod)) {
enteredPeriod = prompt(
'Enter a custom time period (number of hours, or add a "d" suffix for days):'
'Enter a custom time period (number of hours, or add a "d" suffix for days):',
);
// exit if they specifically cancelled the prompt

4
tildes/static/js/behaviors/user-links-new-tabs.js

@ -1,11 +1,11 @@
// Copyright (c) 2020 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$.onmount("[data-js-user-links-new-tabs]", function() {
$.onmount("[data-js-user-links-new-tabs]", function () {
// Open links to users on Tildes in new tabs
$(this)
.find(".link-user")
.each(function() {
.each(function () {
$(this).attr("target", "_blank");
});
});

10
tildes/static/js/scripts.js

@ -1,12 +1,12 @@
// Copyright (c) 2018 Tildes contributors <code@tildes.net>
// SPDX-License-Identifier: AGPL-3.0-or-later
$(function() {
$(function () {
$.onmount();
// Add the CSRF token to all Intercooler AJAX requests as a header
/* eslint-disable-next-line no-unused-vars */
$(document).on("beforeAjaxSend.ic", function(event, ajaxSetup, elt) {
$(document).on("beforeAjaxSend.ic", function (event, ajaxSetup, elt) {
var token = $("meta[name='csrftoken']").attr("content");
ajaxSetup.headers["X-CSRF-Token"] = token;
@ -31,14 +31,14 @@ $(function() {
});
// Automatically call onmount whenever Intercooler swaps in new content
Intercooler.ready(function() {
Intercooler.ready(function () {
$.onmount();
});
// Called whenever an Intercooler request completes; used to display an error or
// success message in an appropriate place near supported elements.
/* eslint-disable-next-line no-unused-vars */
$(document).on("complete.ic", function(evt, elt, data, status, xhr, requestId) {
$(document).on("complete.ic", function (evt, elt, data, status, xhr, requestId) {
var $container = null;
// Only display these messages if the triggering element was <form> or <button>
@ -99,7 +99,7 @@ if (!window.Tildes) {
window.Tildes = {};
}
Tildes.changeTheme = function(newThemeName) {
Tildes.changeTheme = function (newThemeName) {
// remove any theme classes currently on the body
var $body = $("body").first();
var bodyClasses = $body[0].className.split(" ");

5
tildes/tildes/routes.py

@ -18,6 +18,7 @@ from tildes.resources.user import user_by_username
OPENAPI_YAML_FILE = "/opt/tildes/openapi_beta.yaml"
SWAGGER_UI_HTML_FILE = "/opt/tildes/static/swagger-ui/index.html"
SWAGGER_UI_VERSION = "5.27.1"
def includeme(config: Configurator) -> None:
@ -136,7 +137,9 @@ def includeme(config: Configurator) -> None:
# We also provide a path for the full spec and the built-in swagger UI explorer
config.pyramid_openapi3_spec(OPENAPI_YAML_FILE, route="/api/beta/openapi.yaml")
config.pyramid_openapi3_add_explorer(
route="/api/beta/ui", template=SWAGGER_UI_HTML_FILE
route="/api/beta/ui",
template=SWAGGER_UI_HTML_FILE,
ui_version=SWAGGER_UI_VERSION,
)
with config.route_prefix_context("/api/beta"):

Loading…
Cancel
Save