Skip to content

Commit

Permalink
Merge branch 'main' into calendar-mobile-styling-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jace committed Apr 27, 2024
2 parents 4a4589c + ca83db1 commit df555ec
Show file tree
Hide file tree
Showing 104 changed files with 1,173 additions and 495 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ repos:
- id: pyupgrade
args: ['--keep-runtime-typing', '--py311-plus']
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.7
rev: v0.4.1
hooks:
- id: ruff
args: ['--fix', '--exit-non-zero-on-fix']
Expand Down Expand Up @@ -102,7 +102,7 @@ repos:
additional_dependencies:
- tomli
- repo: https://github.com/psf/black
rev: 24.4.0
rev: 24.4.1
hooks:
- id: black
- repo: https://github.com/PyCQA/flake8
Expand Down
1 change: 0 additions & 1 deletion funnel/assets/sass/components/_list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
}
}
li:first-child {
margin-left: -8px;
list-style-type: none;
padding: 0 20px 0 0;
}
Expand Down
5 changes: 3 additions & 2 deletions funnel/assets/sass/pages/profile_calendar.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@use 'sass:math';
@import '../base/variable';

.calendar-container {
Expand Down Expand Up @@ -89,7 +90,7 @@ table.proposal-list-table tr {

.fc-widget-header {
float: right;
padding: $mui-grid-padding/2 $mui-grid-padding;
padding: math.div($mui-grid-padding, 2) $mui-grid-padding;
position: relative;
align-items: center;
z-index: 3;
Expand Down Expand Up @@ -167,7 +168,7 @@ table.proposal-list-table tr {
.proposal_venue {
margin: $mui-grid-padding 0 0;
display: flex;
gap: $mui-grid-padding/4;
gap: math.div($mui-grid-padding, 4);
}

.filter-menu {
Expand Down
1 change: 0 additions & 1 deletion funnel/assets/sass/pages/update.scss
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@

.update__heading {
display: flex;
gap: 8px;
.update__heading__unpin {
display: none;
}
Expand Down
6 changes: 2 additions & 4 deletions funnel/cli/__init__.py
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']
13 changes: 13 additions & 0 deletions funnel/cli/lint/__init__.py
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']
106 changes: 106 additions & 0 deletions funnel/cli/lint/jinja.py
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,
)
4 changes: 3 additions & 1 deletion funnel/cli/periodic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
'periodic', help="Periodic tasks from cron (with recommended intervals)"
)

from . import mnrl, notification, stats # noqa: F401
from . import mnrl, notification, stats

app.cli.add_command(periodic)

__all__ = ['periodic', 'mnrl', 'notification', 'stats']
4 changes: 3 additions & 1 deletion funnel/cli/refresh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

refresh = AppGroup('refresh', help="Refresh or purge caches")

from . import markdown # isort:skip # noqa: F401
from . import markdown

app.cli.add_command(refresh)

__all__ = ['refresh', 'markdown']
2 changes: 1 addition & 1 deletion funnel/models/auth_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def host_matches(self, url: str) -> bool:
if netloc:
return netloc in (
urllib.parse.urlsplit(r).netloc
for r in (tuple(self.redirect_uris) + (self.website,))
for r in (tuple(self.redirect_uris) + (str(self.website),))
)
return False

Expand Down
4 changes: 3 additions & 1 deletion funnel/proxies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

from flask import Flask

from .request import request_wants, response_varies
from .request import RequestWants, request_wants, response_varies

__all__ = ['RequestWants', 'request_wants']


def init_app(app: Flask) -> None:
Expand Down
2 changes: 1 addition & 1 deletion funnel/proxies/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

from ..typing import ResponseType, T

__all__ = ['request_wants']
__all__ = ['request_wants', 'RequestWants']


def test_uses(
Expand Down
4 changes: 2 additions & 2 deletions funnel/templates/about.html.jinja2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "layout.html.jinja2" %}
{% block title %}{% trans %}About Hasgeek{% endtrans %}{% endblock title %}
{%- from "macros.html.jinja2" import page_footer %}
{%- from "macros.html.jinja2" import about_page_footer %}

{% block pageheaders %}
<link rel="stylesheet" type="text/css" href="{{ manifest('css/about.css') }}" />
Expand Down Expand Up @@ -47,7 +47,7 @@
{%- endblock contentwrapper %}

{% block basefooter %}
{{ page_footer() }}
{{ about_page_footer('about') }}
{% endblock basefooter %}

{% block footerscripts %}
Expand Down
3 changes: 2 additions & 1 deletion funnel/templates/auth_client_index.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@
</thead>
<tbody class="mui--text-subhead">
{% for auth_client in auth_clients %}
{%- set link = auth_client.url_for() %}
{%- with link = auth_client.url_for() %}
<tr>
<td data-th="#"><a href="{{ link }}" title="{{ auth_client.title }}">{{ loop.index }}</a></td>
<td data-th="Title"><a href="{{ link }}" title="{{ auth_client.title }}">{{ auth_client.title }}</a></td>
<td data-th="Owner"><a href="{{ link }}" title="{{ auth_client.title }}">{{ auth_client.account.pickername }}</a></td>
<td data-th="Website"><a href="{{ link }}" title="{{ auth_client.title }}">{{ auth_client.website }}</a></td>
</tr>
{%- endwith %}
{% else %}
<tr>
<td colspan="4">{% trans %}No applications have been registered{% endtrans %}</td>
Expand Down
4 changes: 2 additions & 2 deletions funnel/templates/contact.html.jinja2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "layout.html.jinja2" %}
{% block title %}{{ page.title }}{% endblock title %}
{%- from "macros.html.jinja2" import page_footer %}
{%- from "macros.html.jinja2" import about_page_footer %}

{% block pageheaders %}
<link rel="stylesheet" type="text/css" href="{{ manifest('css/about.css') }}" />
Expand Down Expand Up @@ -32,7 +32,7 @@
{%- endblock contentwrapper %}

{% block basefooter %}
{{ page_footer() }}
{{ about_page_footer('contact') }}
{% endblock basefooter %}

{% block footerscripts %}
Expand Down
1 change: 0 additions & 1 deletion funnel/templates/index.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
{% endif %}

{{ open_cfp_section(open_cfp_projects) }}
{{ all_projects_section(all_projects) }}
{{ past_projects_section() }}
{% endblock basecontent %}

Expand Down
2 changes: 1 addition & 1 deletion funnel/templates/layout.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@
aria-label="{% trans %}Search this site{% endtrans %}"
placeholder="{% trans %}Search…{% endtrans %}"
class="search-form__field js-search-field"
id="header-search" value="{{ query }}"/>
id="header-search" {% if search_query is defined %}value="{{ search_query }}"{% endif %}/>
{{ faicon(icon='search', baseline=false, css_class="search-form__field__icon") }}
<input type="text" name="type" value="project" hidden />
<button type="submit" class="search-form__submit"></button>
Expand Down
8 changes: 4 additions & 4 deletions funnel/templates/macros.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -211,13 +211,13 @@
</a>
{% endmacro %}

{% macro page_footer() %}
{% macro about_page_footer(page=none) %}
<footer class="sub-navbar-container sub-navbar-container--footer bg-accent">
<nav class="sub-navbar mui-container" id="page-navbar">
<a class="sub-navbar__item mui--text-subhead mui--text-dark {% if path == 'index' %}sub-navbar__item--active{%- endif %}" href="{{ url_for('about') }}">{% trans %}About Hasgeek{% endtrans %}</a>
<a class="sub-navbar__item mui--text-subhead mui--text-dark {% if page == 'about' %}sub-navbar__item--active{%- endif %}" href="{{ url_for('about') }}">{% trans %}About Hasgeek{% endtrans %}</a>
<a class="sub-navbar__item mui--text-subhead mui--text-dark" href="{{ url_for('profile', account='hasgeek') }}">{% trans %}Team &amp; careers{% endtrans %}</a>
<a class="sub-navbar__item mui--text-subhead mui--text-dark {% if path == 'contact' %}sub-navbar__item--active{%- endif %}" href="{{ url_for('contact') }}">{% trans %}Contact{% endtrans %}</a>
<a class="sub-navbar__item mui--text-subhead mui--text-dark {% if path == 'policy' %}sub-navbar__item--active{%- endif %}" href="{{ url_for('policy') }}">{% trans %}Site policies{% endtrans %}</a>
<a class="sub-navbar__item mui--text-subhead mui--text-dark {% if page == 'contact' %}sub-navbar__item--active{%- endif %}" href="{{ url_for('contact') }}">{% trans %}Contact{% endtrans %}</a>
<a class="sub-navbar__item mui--text-subhead mui--text-dark {% if page == 'policy' %}sub-navbar__item--active{%- endif %}" href="{{ url_for('policy') }}">{% trans %}Site policies{% endtrans %}</a>
</nav>
</footer>
{% endmacro %}
Expand Down
4 changes: 2 additions & 2 deletions funnel/templates/policy.html.jinja2
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "layout.html.jinja2" %}
{% block title %}{{ page.title }}{% endblock title %}
{%- from "macros.html.jinja2" import page_footer %}
{%- from "macros.html.jinja2" import about_page_footer %}

{% block top_title %}
<h1 class="mui--text-headline"><strong>{{ self.title() }}</strong></h1>
Expand Down Expand Up @@ -36,7 +36,7 @@
{%- endblock contentwrapper %}

{% block basefooter %}
{{ page_footer() }}
{{ about_page_footer('policy') }}
{% endblock basefooter %}

{% block footerscripts %}
Expand Down
1 change: 0 additions & 1 deletion funnel/templates/profile.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@
{% endif %}

{{ open_cfp_section(open_cfp_projects) }}
{{ all_projects_section(all_projects) }}
{{ past_featured_session_videos(profile) }}

{% if sponsored_projects %}
Expand Down
27 changes: 2 additions & 25 deletions funnel/templates/profile_layout.html.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,13 @@
{% endif %}
<ul class="grid projects" role="list">
{% for project in open_cfp_projects %}
<li class="grid__col-xs-12 grid__col-sm-6 grid__col-md-4 js-cfp-projects {% if loop.index > 4 %}mui--hide{% endif %}"
<li class="grid__col-xs-12 grid__col-sm-6 grid__col-md-4 js-cfp-projects {% if loop.index > 3 %}mui--hide{% endif %}"
role="listitem">
{{ projectcard(project, include_calendar=false, save_form_id_prefix='open_spf_') }}
</li>
{%- endfor -%}
</ul>
{% if open_cfp_projects|length > 4 %}
{% if open_cfp_projects|length > 3 %}
<div class="mui--text-center">
<a href="#" onclick="return false;" data-target="show all cfp projects" class="jquery-show-all text-uppercase" data-projects="js-cfp-projects" data-ga="Show all cfp projects" aria-expanded="true">{% trans %}Show more{% endtrans %}</a>
</div>
Expand All @@ -219,29 +219,6 @@
{% endif %}
{% endmacro %}

{% macro all_projects_section(all_projects, heading=true) %}
{% if all_projects %}
<div class="projects-wrapper">
<div class="mui-container">
{% if heading %}
<div class="grid">
<div class="grid__col-12">
<h2 class="mui--text-headline text-bold project-headline">{% trans %}All projects{% endtrans %}</h2>
</div>
</div>
{% endif %}
<ul class="grid projects" role="list">
{% for project in all_projects %}
<li class="grid__col-12 grid__col-xs-12 grid__col-sm-6 grid__col-lg-4" role="listitem">
{{ projectcard(project, save_form_id_prefix='all_spf_') }}
</li>
{%- endfor -%}
</ul>
</div>
</div>
{% endif %}
{% endmacro %}

{% macro membership_section(membership_project, profile) %}
{% if membership_project %}
<div class="projects-wrapper">
Expand Down
Loading

0 comments on commit df555ec

Please sign in to comment.