mirror of
https://github.com/ae-utbm/sith.git
synced 2026-09-04 19:44:34 +00:00
Compare commits
16
Commits
pedagogy
...
timetable-og
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
338ca6cd25 | ||
|
|
d2c259c4f9 | ||
|
|
f57fe290d6 | ||
|
|
e7b5330f4f | ||
|
|
3cdbb9605c | ||
|
|
c17f2feefc | ||
|
|
22ecd01898 | ||
|
|
1fa4ccd710 | ||
|
|
2a71708ccd | ||
|
|
549d8c67e7 | ||
|
|
ff69741c82 | ||
|
|
b5b837498f | ||
|
|
8ef3054888 | ||
|
|
362f1a6a62 | ||
|
|
b6347829c6 | ||
|
|
2099e1bd36 |
-11
@@ -3,7 +3,6 @@ from typing import Annotated, Literal
|
||||
from annotated_types import Ge, Le, MinLen
|
||||
from django.conf import settings
|
||||
from django.db.models import F
|
||||
from django.http import HttpResponse
|
||||
from ninja import File, Query
|
||||
from ninja.security import SessionAuth
|
||||
from ninja_extra import ControllerBase, api_controller, paginate, route
|
||||
@@ -18,7 +17,6 @@ from core.models import Group, QuickUploadImage, SithFile, User
|
||||
from core.schemas import (
|
||||
FamilyGodfatherSchema,
|
||||
GroupSchema,
|
||||
MarkdownSchema,
|
||||
SithFileSchema,
|
||||
UploadedFileSchema,
|
||||
UploadedImage,
|
||||
@@ -28,18 +26,9 @@ from core.schemas import (
|
||||
UserSchema,
|
||||
ValidationErrorSchema,
|
||||
)
|
||||
from core.templatetags.renderer import markdown
|
||||
from counter.utils import is_logged_in_counter
|
||||
|
||||
|
||||
@api_controller("/markdown")
|
||||
class MarkdownController(ControllerBase):
|
||||
@route.post("", url_name="markdown")
|
||||
def render_markdown(self, body: MarkdownSchema):
|
||||
"""Convert the markdown text into html."""
|
||||
return HttpResponse(markdown(body.text), content_type="text/html")
|
||||
|
||||
|
||||
@api_controller("/upload")
|
||||
class UploadController(ControllerBase):
|
||||
@route.post(
|
||||
|
||||
@@ -161,10 +161,6 @@ class UserFilterSchema(FilterSchema):
|
||||
return value
|
||||
|
||||
|
||||
class MarkdownSchema(Schema):
|
||||
text: str
|
||||
|
||||
|
||||
class FamilyGodfatherSchema(Schema):
|
||||
godfather: int
|
||||
godchild: int
|
||||
|
||||
@@ -3,16 +3,12 @@
|
||||
import "codemirror/lib/codemirror.css";
|
||||
// @ts-expect-error 2307
|
||||
import "easymde/src/css/easymde.css";
|
||||
import { markdown } from "@ae_utbm/aemark";
|
||||
// biome-ignore lint/correctness/noUndeclaredDependencies: Imported by EasyMDE
|
||||
import type CodeMirror from "codemirror";
|
||||
// biome-ignore lint/style/useNamingConvention: This is how they called their namespace
|
||||
import type CodeMirror from "codemirror"; // biome-ignore lint/style/useNamingConvention: This is how they called their namespace
|
||||
import EasyMDE from "easymde";
|
||||
import { inheritHtmlElement, registerComponent } from "#core:utils/web-components";
|
||||
import {
|
||||
markdownRenderMarkdown,
|
||||
type UploadUploadImageErrors,
|
||||
uploadUploadImage,
|
||||
} from "#openapi";
|
||||
import { type UploadUploadImageErrors, uploadUploadImage } from "#openapi";
|
||||
|
||||
const loadEasyMde = (textarea: HTMLTextAreaElement) => {
|
||||
const easymde = new EasyMDE({
|
||||
@@ -64,19 +60,7 @@ const loadEasyMde = (textarea: HTMLTextAreaElement) => {
|
||||
});
|
||||
easymde.codemirror.replaceSelection("\n");
|
||||
},
|
||||
previewRender: (plainText, preview) => {
|
||||
/* This is wrapped this way to allow time for Alpine to be loaded on the page */
|
||||
return Alpine.debounce(() => {
|
||||
const func = async () => {
|
||||
preview.innerHTML = (
|
||||
await markdownRenderMarkdown({ body: { text: plainText } })
|
||||
).data as string;
|
||||
return null;
|
||||
};
|
||||
func().then();
|
||||
return null;
|
||||
}, 300)();
|
||||
},
|
||||
previewRender: (plainText) => markdown(plainText),
|
||||
forceSync: true, // Avoid validation error on generic create view
|
||||
imageTexts: {
|
||||
sbInit: gettext("Attach files by drag and dropping or pasting from clipboard."),
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
|
||||
<div id="page">
|
||||
<h3>{% trans %}404, Not Found{% endtrans %}</h3>
|
||||
|
||||
<blockquote>
|
||||
{% trans %}Impossible, perhaps the archives are incomplete{% endtrans %}
|
||||
</blockquote>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
{%- endblock %}"
|
||||
>
|
||||
<meta property="og:site_name" content="Association des Étudiants de l'UTBM" />
|
||||
<meta property="og:locale" content="fr_FR" />
|
||||
<meta property="og:locale:alternate" content="en_GB" />
|
||||
{% block metatags %}
|
||||
<meta property="og:url" content="{{ request.build_absolute_uri() }}" />
|
||||
<meta property="og:type" content="website" />
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
## syntaxe aemark
|
||||
|
||||
Le site AE utilise markdown pour le rendu de la plupart
|
||||
des textes saisis par les utilisateurs.
|
||||
Cependant, la syntaxe utilisée n'est pas celle officielle
|
||||
telle que définie par John Gruber,
|
||||
mais est basée sur [CommonMark](https://commonmark.org/),
|
||||
avec quelques variations pour les usages particuliers du site AE.
|
||||
|
||||
Les deux principaux ajouts sont :
|
||||
|
||||
- Les urls commençant par `page://` sont modifiées pour commencer par `/page/`
|
||||
- Des modificateurs de taille peuvent être indiqués directement dans la source
|
||||
d'une image
|
||||
|
||||
Les variations d'aemark sont documentées sur
|
||||
[le site AE](https://ae.utbm.fr/page/Aide_sur_la_syntaxe/).
|
||||
|
||||
Le code est hébergé sur le dépôt Git [aemark](https://github.com/ae-utbm/ae-markdown).
|
||||
|
||||
## Utiliser aemark
|
||||
|
||||
Le code du parser aemark est écrit en Rust dans une librairie
|
||||
indépendante, avec des bindings vers différents langages.
|
||||
Les librairies mises à disposition exposent une seule fonction,
|
||||
qui prend simplement du markdown en entrée et renvoie l'HTML correspondant.
|
||||
|
||||
Les librairies pour les différents langages sont toutes
|
||||
basées sur le même code Rust.
|
||||
La seule différence entre chacune tient uniquement dans la manière
|
||||
d'intégrer ce code dans les bindings.
|
||||
De cette manière, le comportement est assuré d'être le même
|
||||
sur toutes les plateformes disponibles, avec en prime des performances
|
||||
respectables.
|
||||
|
||||
|
||||
=== ":simple-python: Python"
|
||||
|
||||
```python
|
||||
from aemark import markdown
|
||||
|
||||
result = markdown("this is some *markdown text* with __formatting__")
|
||||
```
|
||||
|
||||
=== ":simple-javascript: Javascript"
|
||||
|
||||
```typescript
|
||||
import { markdown } from "@ae_utbm/aemark"
|
||||
|
||||
const result = markdown("this is some *markdown text* with __formatting__");
|
||||
```
|
||||
@@ -6,7 +6,7 @@
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-08-21 14:10+0200\n"
|
||||
"POT-Creation-Date: 2026-09-04 19:39+0200\n"
|
||||
"PO-Revision-Date: 2016-07-18\n"
|
||||
"Last-Translator: Maréchal <thomas.girod@utbm.fr\n"
|
||||
"Language-Team: AE info <ae.info@utbm.fr>\n"
|
||||
@@ -2049,6 +2049,10 @@ msgstr "403, Non autorisé"
|
||||
msgid "404, Not Found"
|
||||
msgstr "404. Non trouvé"
|
||||
|
||||
#: core/templates/core/404.jinja
|
||||
msgid "Impossible, perhaps the archives are incomplete"
|
||||
msgstr "Impossible, les archives sont peut-être incomplètes"
|
||||
|
||||
#: core/templates/core/500.jinja
|
||||
msgid "500, Server Error"
|
||||
msgstr "500, Erreur Serveur"
|
||||
@@ -5089,6 +5093,10 @@ msgstr "signalant"
|
||||
msgid "A guide of courses available at UTBM."
|
||||
msgstr "Un guide de tous les cours disponibles à l'UTBM."
|
||||
|
||||
#: pedagogy/templates/pedagogy/guide.jinja
|
||||
msgid "Search UE"
|
||||
msgstr "Recherche d'UE"
|
||||
|
||||
#: pedagogy/templates/pedagogy/guide.jinja
|
||||
#, python-format
|
||||
msgid "%(display_name)s"
|
||||
@@ -5758,6 +5766,18 @@ msgstr "fin de la cotisation"
|
||||
msgid "location"
|
||||
msgstr "lieu"
|
||||
|
||||
#: subscription/models.py
|
||||
msgid "created_at"
|
||||
msgstr "créé le"
|
||||
|
||||
#: subscription/models.py
|
||||
msgid ""
|
||||
"When this subscription was created. This date may differ from the start of "
|
||||
"the subscription."
|
||||
msgstr ""
|
||||
"Quand la cotisation a été créée. Cette date peut différer du début effectif "
|
||||
"de la cotisation."
|
||||
|
||||
#: subscription/models.py
|
||||
msgid "You can not subscribe many time for the same period"
|
||||
msgstr "Vous ne pouvez pas cotiser plusieurs fois pour la même période"
|
||||
@@ -5812,6 +5832,14 @@ msgstr "les groupes pouvant créer des cotisations"
|
||||
msgid "Timetable generator"
|
||||
msgstr "Générateur d'emploi du temps"
|
||||
|
||||
#: timetable/templates/timetable/generator.jinja
|
||||
msgid "Get a nice schedule from the raw text in your student file"
|
||||
msgstr "Générez un joli emploi du temps à partir du texte brut de votre dossier étudiant"
|
||||
|
||||
#: timetable/templates/timetable/generator.jinja
|
||||
msgid "Paste your schedule (without the header)"
|
||||
msgstr "Colle ton emploi du temps (sans l'entête)"
|
||||
|
||||
#: timetable/templates/timetable/generator.jinja
|
||||
msgid "Generate"
|
||||
msgstr "Générer"
|
||||
|
||||
@@ -71,6 +71,7 @@ nav:
|
||||
- API:
|
||||
- Développement: tutorial/api/dev.md
|
||||
- Connexion à l'API: tutorial/api/connect.md
|
||||
- Markdown AE: tutorial/markdown.md
|
||||
- Etransactions: tutorial/etransaction.md
|
||||
- How-to:
|
||||
- L'ORM de Django: howto/querysets.md
|
||||
|
||||
Generated
+6
@@ -9,6 +9,7 @@
|
||||
"version": "3",
|
||||
"license": "GPL-3.0-only",
|
||||
"dependencies": {
|
||||
"@ae_utbm/aemark": "^0.1.3",
|
||||
"@alpinejs/sort": "^3.16.2",
|
||||
"@arendjr/text-clipper": "npm:@jsr/arendjr__text-clipper@^3.0.0",
|
||||
"@floating-ui/dom": "^1.8.0",
|
||||
@@ -56,6 +57,11 @@
|
||||
"vite": "^8.2.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@ae_utbm/aemark": {
|
||||
"version": "0.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@ae_utbm/aemark/-/aemark-0.1.3.tgz",
|
||||
"integrity": "sha512-JHb9XDgYxy9J0f7bUWtS7eVptKbeB/4+VQoHO3g1ASwNHZpIpW+RRdJPXA+oi2/RDrdPbEtCMkkVROc+8ifFYQ=="
|
||||
},
|
||||
"node_modules/@alpinejs/sort": {
|
||||
"version": "3.16.2",
|
||||
"resolved": "https://registry.npmjs.org/@alpinejs/sort/-/sort-3.16.2.tgz",
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
"vite": "^8.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ae_utbm/aemark": "^0.1.3",
|
||||
"@alpinejs/sort": "^3.16.2",
|
||||
"@arendjr/text-clipper": "npm:@jsr/arendjr__text-clipper@^3.0.0",
|
||||
"@floating-ui/dom": "^1.8.0",
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
# Generated by Django 5.2.17 on 2026-09-01 08:44
|
||||
|
||||
import django.utils.timezone
|
||||
from django.db import migrations, models
|
||||
from django.db.migrations.state import StateApps
|
||||
from django.db.models import F, Value
|
||||
from django.db.models.functions import Least
|
||||
from django.utils.timezone import now
|
||||
|
||||
|
||||
def make_default_creation_date(apps: StateApps, schema_editor):
|
||||
Subscription = apps.get_model("subscription", "Subscription")
|
||||
Subscription.objects.update(
|
||||
created_at=Least(
|
||||
F("subscription_start"), Value(now()), output_field=models.DateTimeField()
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [("subscription", "0016_alter_subscription_subscription_type")]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="subscription",
|
||||
name="created_at",
|
||||
field=models.DateTimeField(
|
||||
auto_now_add=True,
|
||||
default=django.utils.timezone.now,
|
||||
help_text=(
|
||||
"When this subscription was created. "
|
||||
"This date may differ from the start of the subscription."
|
||||
),
|
||||
verbose_name="created_at",
|
||||
),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.RunPython(
|
||||
make_default_creation_date,
|
||||
reverse_code=migrations.RunPython.noop,
|
||||
elidable=True,
|
||||
),
|
||||
]
|
||||
@@ -64,6 +64,14 @@ class Subscription(models.Model):
|
||||
max_length=20,
|
||||
verbose_name=_("location"),
|
||||
)
|
||||
created_at = models.DateTimeField(
|
||||
_("created_at"),
|
||||
help_text=_(
|
||||
"When this subscription was created. "
|
||||
"This date may differ from the start of the subscription."
|
||||
),
|
||||
auto_now_add=True,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
ordering = ["subscription_start"]
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import html2canvas from "html2canvas";
|
||||
|
||||
// see https://regex101.com/r/QHSaPM/2
|
||||
// see https://regex101.com/r/QHSaPM/3
|
||||
const TIMETABLE_ROW_RE: RegExp =
|
||||
/^(?<ueCode>\w.+\w)\s+(?<courseType>[A-Z]{2}\d)\s+((?<weekGroup>[AB])\s+)?(?<weekday>(lundi)|(mardi)|(mercredi)|(jeudi)|(vendredi)|(samedi)|(dimanche))\s+(?<startHour>\d{2}:\d{2})\s+(?<endHour>\d{2}:\d{2})\s+[\dA-B]\s+((?<attendance>[\wé]*)\s+)?(?<room>\w+(?:, \w+)?)$/;
|
||||
/^(?<ueCode>\w.+\w)\s+(?<courseType>[A-Z]{2}\d)\s+((?<weekGroup>[AB])\s+)?(?<weekday>(lundi)|(mardi)|(mercredi)|(jeudi)|(vendredi)|(samedi)|(dimanche))\s+(?<startHour>\d{2}:\d{2})\s+(?<endHour>\d{2}:\d{2})\s+[\dA-B]\s+((?<attendance>[\wé]*)\s+)?(?<room>\w+(?:, \w+)*)$/;
|
||||
|
||||
const DEFAULT_TIMETABLE: string = `DS52\t\tCM1\t\tlundi\t08:00\t10:00\t1\tPrésentiel\tA113
|
||||
DS53\t\tCM1\t\tlundi\t10:15\t12:15\t1\tPrésentiel\tA101
|
||||
|
||||
@@ -12,15 +12,36 @@
|
||||
{% trans %}Timetable generator{% endtrans %}
|
||||
{% endblock %}
|
||||
|
||||
{% block description -%}
|
||||
{% trans trimmed %}
|
||||
Get a nice schedule from the raw text in your student file
|
||||
{% endtrans %}
|
||||
{%- endblock %}
|
||||
|
||||
{% block metatags %}
|
||||
<meta property="og:url" content="{{ request.build_absolute_uri() }}" />
|
||||
<meta property="og:type" content="website" />
|
||||
<meta property="og:title" content="Générateur d'emploi du temps" />
|
||||
<meta property="og:image" content="{{ request.build_absolute_uri(static("core/img/logo_no_text.png")) }}" />
|
||||
<meta
|
||||
property="og:description"
|
||||
content="Générateur d'emploi du temps de l'UTBM.
|
||||
Copiez le texte de l'emploi du temps de votre dossier étudiant
|
||||
et récupérez une image plus jolie."
|
||||
/>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div x-data="timetableGenerator">
|
||||
<form @submit.prevent="generate()">
|
||||
<h1>Générateur d'emploi du temps</h1>
|
||||
<h1>{% trans %}Timetable generator{% endtrans %}</h1>
|
||||
<div class="alert alert-red" x-show="!!error" x-cloak>
|
||||
<span class="alert-main" x-text="error"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="timetable-input">Colle ton emploi du temps (sans l'entête)</label>
|
||||
<label for="timetable-input">
|
||||
{% trans %}Paste your schedule (without the header){% endtrans %}
|
||||
</label>
|
||||
<textarea id="timetable-input" cols="30" rows="15" x-model="content"></textarea>
|
||||
</div>
|
||||
<input type="submit" class="btn btn-blue" value="{% trans %}Generate{% endtrans %}">
|
||||
|
||||
+1
-3
@@ -1,8 +1,6 @@
|
||||
# Create your views here.
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from core.auth.mixins import FormerSubscriberMixin
|
||||
|
||||
|
||||
class GeneratorView(FormerSubscriberMixin, TemplateView):
|
||||
class GeneratorView(TemplateView):
|
||||
template_name = "timetable/generator.jinja"
|
||||
|
||||
Reference in New Issue
Block a user