-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into calendar-mobile-styling-fixes
- Loading branch information
Showing
104 changed files
with
1,173 additions
and
495 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,7 +77,6 @@ | |
} | ||
} | ||
li:first-child { | ||
margin-left: -8px; | ||
list-style-type: none; | ||
padding: 0 20px 0 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,7 +38,6 @@ | |
|
||
.update__heading { | ||
display: flex; | ||
gap: 8px; | ||
.update__heading__unpin { | ||
display: none; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
"""Command line interface.""" | ||
|
||
# flake8: noqa | ||
from . import geodata, lint, misc, periodic, refresh | ||
|
||
from __future__ import annotations | ||
|
||
from . import geodata, misc, periodic, refresh | ||
__all__ = ['geodata', 'lint', 'misc', 'periodic', 'refresh'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"""Linter commands.""" | ||
|
||
from flask.cli import AppGroup | ||
|
||
from ... import app | ||
|
||
lint = AppGroup('lint', help="Periodic tasks from cron (with recommended intervals)") | ||
|
||
from . import jinja | ||
|
||
app.cli.add_command(lint) | ||
|
||
__all__ = ['lint', 'jinja'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
"""Jinja template linter.""" | ||
|
||
import sys | ||
from collections import deque | ||
from collections.abc import Sequence | ||
|
||
import click | ||
import jinja2 | ||
from jinja2 import TemplateNotFound, TemplateSyntaxError | ||
from rich.console import Console | ||
|
||
from ... import app | ||
from ...utils import JinjaTemplateBase | ||
from . import lint | ||
|
||
|
||
def all_jinja_template_classes() -> dict[str, type[JinjaTemplateBase]]: | ||
"""Find all JinjaTemplate classes and return as a dict against the template name.""" | ||
classes = deque([JinjaTemplateBase]) | ||
result: dict[str, type[JinjaTemplateBase]] = {} | ||
while True: | ||
try: | ||
cls = classes.popleft() | ||
except IndexError: | ||
break | ||
if hasattr(cls, '_template'): | ||
result[cls._template] = cls # pylint: disable=protected-access | ||
classes.extend(cls.__subclasses__()) | ||
return result | ||
|
||
|
||
@lint.command('jinja') | ||
@click.argument('templates', nargs=-1) | ||
@click.option('-a', '--all', is_flag=True, help="Lint all Jinja templates.") | ||
def lint_jinja_templates( | ||
templates: Sequence[str], | ||
all: bool = False, # noqa: A002 # pylint: disable=redefined-builtin | ||
) -> None: | ||
"""Lint Jinja templates.""" | ||
if all: | ||
templates = list(templates) + app.jinja_env.list_templates() | ||
elif not templates: | ||
click.echo("Specify template names (not paths) or --all") | ||
|
||
template_classes = all_jinja_template_classes() | ||
console = Console(highlight=False) | ||
rprint = console.print | ||
|
||
for template in templates: | ||
has_cls = True | ||
cls = template_classes.get(template) | ||
if cls is None: | ||
has_cls = False | ||
cls = type('_', (JinjaTemplateBase,), {}, template=template) | ||
try: | ||
report = cls.jinja_unresolved_identifiers() | ||
except TemplateNotFound: | ||
rprint(f"[red][bold]{template}[/] not found :cross_mark:") | ||
continue | ||
except TemplateSyntaxError: | ||
rprint(f"[red][bold]{template}[/] syntax error") | ||
console.print_exception( | ||
width=None, | ||
max_frames=1, | ||
word_wrap=True, | ||
suppress=['funnel/cli', 'funnel/utils', jinja2], | ||
) | ||
continue | ||
has_deps = len(report) > 1 | ||
has_undefined = any(report.values()) | ||
if not has_cls: | ||
rprint(f"[bold white]{template}[/]", end='') | ||
else: | ||
rprint( | ||
f"[bold white]{template}[/]" | ||
f" ([link=file://{sys.modules[cls.__module__].__file__}]" | ||
f"{cls.__module__}.[bold]{cls.__qualname__}[/][/])", | ||
end='', | ||
) | ||
if has_undefined: | ||
if has_cls: | ||
rprint(' :cross_mark_button:', end='') | ||
else: | ||
rprint(' :cross_mark:', end='') | ||
else: | ||
rprint(' :white_check_mark:', end='') | ||
if has_deps and has_undefined: | ||
rprint(" [dim]dependencies and undefined names:") | ||
elif has_deps: | ||
rprint(" [dim]dependencies:") | ||
elif has_undefined: | ||
rprint(" [dim]undefined names:") | ||
else: | ||
rprint() | ||
if has_deps or has_undefined: | ||
for dep_template, undefined_names in report.items(): | ||
rprint(f" - {dep_template}", end='') | ||
if undefined_names: | ||
rprint(': ', end='') | ||
rprint( | ||
', '.join( | ||
f'[red]{line}:[bold]{name}[/][/]' | ||
for line, name in sorted(undefined_names) | ||
), | ||
soft_wrap=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.