diff --git a/.basedpyright/baseline.json b/.basedpyright/baseline.json index ac53915..a9f1789 100644 --- a/.basedpyright/baseline.json +++ b/.basedpyright/baseline.json @@ -193,54 +193,6 @@ "lineCount": 1 } }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 12, - "endColumn": 32, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 35, - "endColumn": 52, - "lineCount": 1 - } - }, - { - "code": "reportAttributeAccessIssue", - "range": { - "startColumn": 45, - "endColumn": 52, - "lineCount": 1 - } - }, - { - "code": "reportUnknownVariableType", - "range": { - "startColumn": 12, - "endColumn": 33, - "lineCount": 1 - } - }, - { - "code": "reportUnknownMemberType", - "range": { - "startColumn": 36, - "endColumn": 53, - "lineCount": 1 - } - }, - { - "code": "reportAttributeAccessIssue", - "range": { - "startColumn": 46, - "endColumn": 53, - "lineCount": 1 - } - }, { "code": "reportAttributeAccessIssue", "range": { diff --git a/.gitignore b/.gitignore index 9806e6e..512a4c1 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ docs/_build/ node_modules/ frontend/dist/* +frontend/src/js/* !frontend/dist/.keep frontend/webpack/stats.json backend/forum/settings_override.py diff --git a/backend/forum/account/forms.py b/backend/forum/account/forms.py index bbe275e..954037b 100644 --- a/backend/forum/account/forms.py +++ b/backend/forum/account/forms.py @@ -4,7 +4,7 @@ from django.contrib.auth.forms import AuthenticationForm from django.core.exceptions import ValidationError from django.db.models.query import QuerySet from django.forms import ModelForm -from django.http.request import HttpRequest +from django.http.request import HttpRequest, QueryDict from django.utils.functional import cached_property from ktools.django.utils.translation import gettext_safelazy as _ @@ -89,6 +89,9 @@ class SettingsForm(ModelForm[User]): the introductions, because thosa are handled by the `IntroductionModificationForm`. """ + + data: QueryDict # pyright: ignore[reportIncompatibleVariableOverride] + @final class Meta: model = User diff --git a/backend/forum/account/jinja/account/settings.html b/backend/forum/account/jinja/account/settings.html index 8867103..6d855dc 100644 --- a/backend/forum/account/jinja/account/settings.html +++ b/backend/forum/account/jinja/account/settings.html @@ -1,4 +1,4 @@ -{% extends 'base.html' %} +{% extends 'base.html.jinja' %} {% from 'ktools/macros/render-form-simple.html' import render_form_simple with context %} {% block extra_scripts_head %} diff --git a/backend/forum/base/jinja/base.html b/backend/forum/base/jinja/base.html.jinja similarity index 93% rename from backend/forum/base/jinja/base.html rename to backend/forum/base/jinja/base.html.jinja index 80d81d6..28ca222 100644 --- a/backend/forum/base/jinja/base.html +++ b/backend/forum/base/jinja/base.html.jinja @@ -1,6 +1,6 @@ {% get_my_language_info as current_language %} - +
{{ render_bundle(bundle_name='onDomReady') }} {{ render_bundle(bundle_name='common', skip_common_chunks=True, attrs='defer') }} @@ -8,8 +8,8 @@ + + var _paq = window._paq = window._paq || []; + _paq.push(['trackPageView']); + _paq.push(['enableLinkTracking']); + _paq.push(['setTrackerUrl', '/mtmo/']); + _paq.push(['setSiteId', '7']); {% endjsmin %} + + {{ render_bundle(bundle_name='mtmo', skip_common_chunks=True, attrs='defer') }} {% block extra_scripts_head %}{% endblock extra_scripts_head %} diff --git a/backend/forum/base/jinja/base/comments-expansion.html b/backend/forum/base/jinja/base/comments-expansion.html index 3bc060c..fc88ace 100644 --- a/backend/forum/base/jinja/base/comments-expansion.html +++ b/backend/forum/base/jinja/base/comments-expansion.html @@ -1,4 +1,4 @@ -{% extends 'base.html' %} +{% extends 'base.html.jinja' %} {% from 'base/macros/topic-comment-template.html' import topic_comment_template with context %} {% from 'base/macros/topic-comment-action-template.html' import topic_comment_action_template with context %} {% from 'base/macros/js-config-topic-comment.html' import js_config_topic_comment with context %} diff --git a/backend/forum/base/jinja/base/topic-comment-listing.html b/backend/forum/base/jinja/base/topic-comment-listing.html index 4417ddf..d3cd6d3 100644 --- a/backend/forum/base/jinja/base/topic-comment-listing.html +++ b/backend/forum/base/jinja/base/topic-comment-listing.html @@ -1,4 +1,4 @@ -{% extends 'base.html' %} +{% extends 'base.html.jinja' %} {% from 'base/macros/topic-comment-template.html' import topic_comment_template with context %} {% from 'base/macros/topic-comment-action-template.html' import topic_comment_action_template with context %} {% from 'base/macros/js-config-topic-comment.html' import js_config_topic_comment with context %} diff --git a/backend/forum/base/jinja/base/topic-listing.html b/backend/forum/base/jinja/base/topic-listing.html index 5fd8ed8..47ab867 100644 --- a/backend/forum/base/jinja/base/topic-listing.html +++ b/backend/forum/base/jinja/base/topic-listing.html @@ -1,4 +1,4 @@ -{% extends 'base.html' %} +{% extends 'base.html.jinja' %} {% from 'base/macros/topic-group.html' import topic_group with context %} {% block extra_scripts_head %} diff --git a/backend/forum/base/models/user.py b/backend/forum/base/models/user.py index d48cc7f..9c6c001 100644 --- a/backend/forum/base/models/user.py +++ b/backend/forum/base/models/user.py @@ -198,10 +198,10 @@ class User(AbstractUser): @cached_property def is_admin(self) -> bool: 'Return `True` if the `User` is an administrator.' - self.introductionmodification return self.is_staff or self.is_superuser +@final @dataclass class FriendsGraph(object): # Whom did I mark as friend? diff --git a/backend/forum/base/utils/cache.py b/backend/forum/base/utils/cache.py index 4067ecb..51efe5e 100644 --- a/backend/forum/base/utils/cache.py +++ b/backend/forum/base/utils/cache.py @@ -4,7 +4,7 @@ from django.conf import settings from django.core.cache import cache from redis.exceptions import ConnectionError as RedisConnectionerror -_OBJ_TIMEOUT: int = settings.CACHE_DEFAULT_TIMEOUT +_OBJ_TIMEOUT: int = getattr(settings, 'CACHE_DEFAULT_TIMEOUT') _T = TypeVar(name='_T') @@ -22,7 +22,7 @@ def get_or_set( try: obj: _T = cache.get(key=key, default=_NOT_FOUND, version=version) if obj != _NOT_FOUND: - cache.touch(key=key, timeout=_OBJ_TIMEOUT, version=version) + _ = cache.touch(key=key, timeout=_OBJ_TIMEOUT, version=version) return obj except RedisConnectionerror: pass @@ -55,7 +55,7 @@ def get_or_set_many( if not missing_items: return result try: - cache.set_many(data=missing_items, timeout=_OBJ_TIMEOUT) + _ = cache.set_many(data=missing_items, timeout=_OBJ_TIMEOUT) except RedisConnectionerror: pass result.update({ diff --git a/frontend/webpack/config.base.js b/frontend/webpack/config.base.js index b3ac9cb..3827346 100644 --- a/frontend/webpack/config.base.js +++ b/frontend/webpack/config.base.js @@ -52,6 +52,9 @@ const defaultConfig = { export: 'default' } }, + mtmo: [ + '../src/js/matomo', + ], common: [ // Put the JS entries always at the end, otherwise libraryTarget // variable exporting will not work! diff --git a/gulpfile.js b/gulpfile.js index fc6095b..dc3df81 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -8,8 +8,13 @@ import Server from 'webpack-dev-server' // import path from 'path' import gulpEslint from 'gulp-eslint-new' // import { fileURLToPath } from 'url' +import download from 'gulp-download-stream' -const sourceGlob = ['frontend/src/ts/**/*.js'] +const sourceGlob = [ + 'frontend/src/ts/**/*.js', + 'frontend/src/**/*.ts', + '!frontend/src/js/matomo.js' +] // const _myFileName = fileURLToPath(import.meta.url) // const _myDirName = path.dirname(_myFileName) @@ -26,6 +31,13 @@ const sourceGlob = ['frontend/src/ts/**/*.js'] // Cleanup task GulpClient.task('clean', () => deleteAsync(['./frontend/dist/**/*'])) +// download-matomo-js task +GulpClient.task('download-matomo-js', () => download( + 'https://owa.ksol.io/matomo.js' +) + .pipe(GulpClient.dest('frontend/src/js/')) +) + // Lint Task if (process.argv.length < 4) { GulpClient.task('lint', () => GulpClient.src(sourceGlob) @@ -52,7 +64,9 @@ if (process.argv.length < 4) { .pipe(gulpEslint.failAfterError())) } -GulpClient.task('clean-lint', GulpClient.parallel(['clean', 'lint'])) +GulpClient.task( + 'clean-lint', + GulpClient.parallel(['clean', 'lint', 'download-matomo-js'])) GulpClient.task('webpack-prod', GulpClient.series('clean-lint', async (done) => { const prodConfig = (await import('./frontend/webpack/config.prod.js')).default @@ -75,21 +89,23 @@ GulpClient.task('webpack-dev', GulpClient.series(['clean-lint'], async (done) => GulpClient.task('build', GulpClient.series(['webpack-prod'])) GulpClient.task('build-dev', GulpClient.series(['clean', 'webpack-dev'])) -GulpClient.task('webpack-dev-server', GulpClient.series(['clean'], async (done) => { - const config = ( - await import('./frontend/webpack/config.dev-server.js')).default +GulpClient.task( + 'webpack-dev-server', + GulpClient.series(['clean', 'download-matomo-js'], async (done) => { + const config = ( + await import('./frontend/webpack/config.dev-server.js')).default - const compiler = webpack(config, () => {}) - const devServerOptions = config.devServer + const compiler = webpack(config, () => {}) + const devServerOptions = config.devServer - const server = new Server(devServerOptions, compiler) - // @See https://webpack.js.org/configuration/dev-server/#usage-via-api - server.startCallback((err) => { - if (err) throw new PluginError('webpack-dev-server', err) - // Server listening - logger('[webpack-dev-server]', `http://${devServerOptions.host}:3000/`) - }) - done() -})) + const server = new Server(devServerOptions, compiler) + // @See https://webpack.js.org/configuration/dev-server/#usage-via-api + server.startCallback((err) => { + if (err) throw new PluginError('webpack-dev-server', err) + // Server listening + logger('[webpack-dev-server]', `http://${devServerOptions.host}:3000/`) + }) + done() + })) GulpClient.task('default', GulpClient.series('clean-lint')) diff --git a/package.json b/package.json index 2ee739c..40623ac 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "font-awesome": "^4.7.0", "gulp": "^5.0.0", "gulp-cli": "^3.0.0", + "gulp-download-stream": "^0.0.20", "gulp-eslint-new": "^2.4.0", "html-loader": "^5.1.0", "imports-loader": "^5.0.0", diff --git a/tools/reload-dump.sh b/tools/devdump-reload.sh similarity index 100% rename from tools/reload-dump.sh rename to tools/devdump-reload.sh