forked from viennet/Referentiels
Compare commits
8 Commits
22d262d8e6
...
abec48ce85
Author | SHA1 | Date | |
---|---|---|---|
abec48ce85 | |||
6cb79285b4 | |||
96d516fd13 | |||
555fedef2a | |||
1caf2f0977 | |||
668fdc5900 | |||
04488c3dcc | |||
48ccdf0e1c |
@ -24,6 +24,7 @@
|
||||
<div class="navbar-start">
|
||||
<!-- Liste des catégories -->
|
||||
<a class="navbar-item" href="SAE.html">SAÉ</a>
|
||||
<a class="navbar-item" href="ressources.html">Ressources</a>
|
||||
<a class="navbar-item" href="ressourcesS1.html">Semestre 1</a>
|
||||
<a class="navbar-item" href="ressourcesS2.html">Semestre 2</a>
|
||||
</div>
|
||||
@ -65,7 +66,7 @@
|
||||
// pages web possibles en fonction de ce que entre l'utilisateur
|
||||
// ex: "R101" -> ./HTML/R101.html
|
||||
$("#rechercher").keyup(function(e) {
|
||||
if(e.keyCode == 13) {location.href = $(this).val() + ".html"}
|
||||
if(e.keyCode == 13) {location.href = $(this).val().toUpperCase() + ".html"}
|
||||
});
|
||||
});
|
||||
</script>
|
@ -25,6 +25,8 @@ from ressource import *
|
||||
REPERTOIRE_TEMP = Config.ROOT + "/python/export"
|
||||
REPERTOIRE_RESSOURCES_DEFINITIVES = Config.ROOT + "/yaml/ressources"
|
||||
REPERTOIRE_SAE_DEFINITIVES = Config.ROOT + "/yaml/saes"
|
||||
REPERTOIRE_COMPETENCES_DEFINITIVES = Config.ROOT + "/yaml/competences"
|
||||
REPERTOIRE_ACS = Config.ROOT + "/python/pn"
|
||||
REPERTOIRE_HTML = Config.ROOT + "/html/export"
|
||||
|
||||
# Créer le dossier html/export s'il n'existe pas
|
||||
@ -83,51 +85,56 @@ for fichieryaml in fichiers_exemples:
|
||||
exemples[sem][sae] = []
|
||||
exemples[sem][sae].append(e)
|
||||
|
||||
# Chargement des ACs
|
||||
fichieryaml = REPERTOIRE_ACS +'/acs.yml'
|
||||
acs = ACs(fichieryaml)
|
||||
|
||||
# Chargement des Compétences
|
||||
fichieryaml = REPERTOIRE_COMPETENCES_DEFINITIVES + '/RT123.yml'
|
||||
competences = Competences(fichieryaml)
|
||||
|
||||
#Liste de string pour renommer certaines catégories (les autres qui n'ont pas besoins ont la première lettre en majuscule)
|
||||
rename = {
|
||||
"heures_encadrees": "Heures encadrées",
|
||||
"heures_formation": "Heures formation",
|
||||
"heures_tp": "Heures TP",
|
||||
"tp": "Heures TP",
|
||||
"coeffs": "Coef.",
|
||||
"acs": "ACs",
|
||||
"motscles": "Mots clés",
|
||||
"sae": "SAÉ",
|
||||
"prerequis": "Prérequis",
|
||||
"problematique": "Problématique",
|
||||
"modalite": "Modalité"
|
||||
}
|
||||
|
||||
CHEMIN_TEMPLATE = Config.ROOT + "/html"
|
||||
# Création de l'environnement pour charger les templates
|
||||
env = Environment(trim_blocks=True, lstrip_blocks=True, loader=FileSystemLoader(CHEMIN_TEMPLATE))
|
||||
# Template de chaque pages ressources, saes, exemples
|
||||
# Template de chaque pages ressources, saes, exemples (doit contenir datas,rename,precedent,suivant)
|
||||
template = env.from_string("""
|
||||
{% extends "base.html" %}
|
||||
{% block title %}{{data.code}} - {{data.nom}}{{data.titre}}{% endblock %}
|
||||
{% block content %}
|
||||
<nav class="level is-mobile">
|
||||
<div class="level-left">
|
||||
<div class="level-item">
|
||||
<a class="button is-primary{% if not precedent %} is-static"{% else %} is-outlined" href="{{precedent}}"{% endif %}>
|
||||
<span class="icon is-small">
|
||||
<i class="fas fa-arrow-left"></i>
|
||||
</span>
|
||||
<span>Précédent</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="level-right">
|
||||
<div class="level-item">
|
||||
<a class="button is-primary{% if not suivant %} is-static"{% else %} is-outlined" href="{{suivant}}"{% endif %}>
|
||||
<span>Suivant</span>
|
||||
<span class="icon is-small">
|
||||
<i class="fas fa-arrow-right"></i>
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{% include "navigation.html" %}
|
||||
<table class="table is-bordered is-hoverable is-fullwidth">
|
||||
<tbody>
|
||||
{% for categorie, valeur in data.items() %}
|
||||
<tr>
|
||||
<th>{{categorie.capitalize()}}</th>
|
||||
<th>{% if rename and rename[categorie] %}{{rename[categorie]}}{% else %}{{categorie.capitalize()}}{% endif %}</th>
|
||||
<td>
|
||||
{#- Gestion des tableaux #}
|
||||
{% if categorie == "motscles" or categorie == "sae" or categorie == "ressources" -%}
|
||||
{% if categorie == "motscles" -%}
|
||||
<div class="tags">{% for mot in valeur %}<span class="tag is-info">{{mot}}</span>{% endfor %}</div>
|
||||
{#- Gestion des saes #}
|
||||
{% elif categorie == "sae" or categorie == "ressources" -%}
|
||||
<div class="tags">{% for val in valeur %}<a class="tag is-info" href="{{val.replace("É","E")}}.html">{{val}}</a>{% endfor %}</div>
|
||||
{#- Gestion des ACS #}
|
||||
{% elif categorie == "acs" -%}
|
||||
<div class="tags">{% for rt,acs in valeur.items() %}{% for ac in acs %}<span class="tag is-info">{{ac}}</span>{% endfor %}{% endfor %}</div>
|
||||
<div class="tags">{% for rt,acs in valeur.items() %}{% for ac in acs %}<a class="tag is-info" href="{{ac}}.html">{{ac}}</a>{% endfor %}{% endfor %}</div>
|
||||
{#- Gestion des coeffs #}
|
||||
{% elif categorie == "coeffs" -%}
|
||||
<div class="tags">{% for rt, coeff in valeur.items() %}<span class="tag is-info">{{rt}} : {{coeff}}</span>{% endfor %}</div>
|
||||
<div class="tags">{% for rt, coeff in valeur.items() %}<a class="tag is-info" href="{{rt}}.html">{{rt}} : {{coeff}}</a>{% endfor %}</div>
|
||||
{#- Gestion des exemples #}
|
||||
{% elif categorie == "exemples" -%}
|
||||
{% for exemple in valeur %}<a href="{{exemple.exemple["code"].replace("É","E") + "_exemple" + loop.index|string}}.html">Exemple{{loop.index}}</a>{% if not loop.last %} - {% endif %}{% endfor %}
|
||||
@ -137,39 +144,81 @@ template = env.from_string("""
|
||||
{%- else %}{{valeur}}{% endif %}
|
||||
{#- Gestion des autres catégories #}
|
||||
{% else -%}
|
||||
{{valeur}}
|
||||
<div class="content">{{valeur}}</div>
|
||||
{%- endif -%}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<nav class="level is-mobile">
|
||||
<div class="level-left">
|
||||
<div class="level-item">
|
||||
<a class="button is-primary{% if not precedent %} is-static"{% else %} is-outlined" href="{{precedent}}"{% endif %}>
|
||||
<span class="icon is-small">
|
||||
<i class="fas fa-arrow-left"></i>
|
||||
</span>
|
||||
<span>Précédent</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="level-right">
|
||||
<div class="level-item">
|
||||
<a class="button is-primary{% if not suivant %} is-static"{% else %} is-outlined" href="{{suivant}}"{% endif %}>
|
||||
<span>Suivant</span>
|
||||
<span class="icon is-small">
|
||||
<i class="fas fa-arrow-right"></i>
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
{% include "navigation.html" %}
|
||||
{% endblock %}
|
||||
""")
|
||||
|
||||
# Template de la liste des ressources par semestre
|
||||
# Template de chaque pages de compétences (doit contenir data,rt,precedent,suivant)
|
||||
template_Competence = env.from_string("""
|
||||
{% extends "base.html" %}
|
||||
{% block title %}{{rt}}{% endblock %}
|
||||
{% block content %}
|
||||
{% include "navigation.html" %}
|
||||
<table class="table is-bordered is-hoverable is-fullwidth">
|
||||
<tbody>
|
||||
{% for categorie, valeur in data.items() %}
|
||||
<tr>
|
||||
<th>{{categorie.capitalize()}}</th>
|
||||
<td>
|
||||
{%- if categorie == "composantes" or categorie == "situations" -%}
|
||||
<div class="content">
|
||||
<ul>
|
||||
{% for valeur in valeur %}
|
||||
<li>{{valeur}}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% elif categorie == "niveaux" %}
|
||||
<div class="content">
|
||||
<ul>
|
||||
{% for nom, acs in valeur.items() %}
|
||||
<li>{{nom}}</li>
|
||||
<ul>
|
||||
{% for ac in acs %}
|
||||
{% if ac[:2] == "AC" %}
|
||||
<li><a class="tag is-info" href="{{ac}}.html">{{ac}}</a> - {{acs[ac]}}</li>
|
||||
{% else %}
|
||||
<li>{{ac}}</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% else -%}
|
||||
<div class="content">{{valeur}}</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% include "navigation.html" %}
|
||||
{% endblock %}
|
||||
""")
|
||||
|
||||
# Template de chaque pages de ACs (doit contenir data, precedent, suivant)
|
||||
template_AC = env.from_string("""
|
||||
{% extends "base.html" %}
|
||||
{% block title %}{{data["ac"]}}{% endblock %}
|
||||
{% block content %}
|
||||
{% include "navigation.html" %}
|
||||
<div class="content">
|
||||
<h1>{{data["ac"]}}</h1>
|
||||
<p>{{data["titre"]}}</p>
|
||||
</div>
|
||||
{% include "navigation.html" %}
|
||||
{% endblock %}
|
||||
""")
|
||||
|
||||
# Template de la liste des ressources par semestre (doit contenir data,sem)
|
||||
template_List_Ressource = env.from_string("""
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Liste des Ressources du semestre {{sem}}{% endblock %}
|
||||
@ -184,17 +233,17 @@ template_List_Ressource = env.from_string("""
|
||||
{% endblock %}
|
||||
""")
|
||||
|
||||
# Template de la liste des saes
|
||||
template_List_SAE = env.from_string("""
|
||||
# Template de la liste des saes ou ressources (doit contenir data,titre)
|
||||
template_List = env.from_string("""
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Liste des SAE{% endblock %}
|
||||
{% block title %}Liste des {{title}}{% endblock %}
|
||||
{% block content %}
|
||||
<div class="content">
|
||||
<ul><h1>Liste des SAE</h1>
|
||||
{% for sem, saes in data.items() %}
|
||||
{% for sae in saes %}
|
||||
<li><a href="{{sae.sae["code"].replace("É","E") + ".html"}}">{{sae.sae["code"]}} - {{sae.sae["titre"]}}</a></li>
|
||||
{% endfor %}
|
||||
<ul><h1>Liste des {{title}}</h1>
|
||||
{% for sem, liste in data.items() %}
|
||||
{% for page in liste %}
|
||||
<li><a href="{{page.getInfo()["code"].replace("É","E") + ".html"}}">{{page.getInfo()["code"]}} - {{page.getInfo()["titre"]}}{{page.getInfo()["nom"]}}</a></li>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
@ -220,9 +269,51 @@ def motscles(mc):
|
||||
motscles.append(mot)
|
||||
return motscles
|
||||
|
||||
def formatHTML(string):
|
||||
""" Retourne un string avec les balises <ul> , <li> et <p> correctement placé, code plus compliqué pour ce qu'il fait"""
|
||||
texte = "\n"
|
||||
phrases = list(filter(None,string.split("\n")))
|
||||
i = 0
|
||||
while i < len(phrases):
|
||||
if "* " in phrases[i]: # première balise li détecté
|
||||
texte += "<ul>\n" # \n permet d'améliorer la lisibilité dans les fichiers html
|
||||
while i < len(phrases) and "*" in phrases[i]: # Tant qu'il y a des * on continue de créer des balises
|
||||
texte += " <li>" + phrases[i][2:] + "</li>\n"
|
||||
if i+1 < len(phrases):
|
||||
if phrases[i+1][:3] == " *": # Si il y a une liste dans un li
|
||||
texte += " <ul>\n"
|
||||
while i + 1 < len(phrases) and phrases[i+1][:2] == " ": # Tant qu'on est dans la liste
|
||||
if "*" in phrases[i+1]:
|
||||
texte += " <li>" + phrases[i+1][4:] + "</li>\n"
|
||||
else:
|
||||
texte = texte[:-6]
|
||||
while i + 1 < len(phrases) and phrases[i+1][:2] == " ": # Si il y a des retour chariot
|
||||
texte += phrases[i+1][3:]
|
||||
i += 1
|
||||
i -= 1
|
||||
i += 1
|
||||
texte += " </ul>\n"
|
||||
elif phrases[i+1][:2] == " ": # Retour à la ligne d'un li
|
||||
texte = texte[:-6]
|
||||
while i + 1 < len(phrases) and phrases[i+1][:2] == " ":
|
||||
texte += phrases[i+1][1:]
|
||||
i += 1
|
||||
texte += "</li>\n"
|
||||
i += 1
|
||||
texte += "</ul>\n"
|
||||
i -= 1
|
||||
else:
|
||||
texte += "<p>" + phrases[i] + "</p>\n"
|
||||
i += 1
|
||||
return texte[:-1] # On enlève le dernier \n
|
||||
|
||||
#Créer un fichier contenant la liste des saes
|
||||
data = {"data" : saes} # "data" contient un tableau des saes
|
||||
template_List_SAE.stream(data).dump(REPERTOIRE_HTML + "/SAE.html")
|
||||
datas = {"data" : saes, "title": "SAE"} # "data" contient un tableau des saes
|
||||
template_List.stream(datas).dump(REPERTOIRE_HTML + "/SAE.html")
|
||||
|
||||
#Créer un fichier contenant la liste des ressources
|
||||
datas = {"data" : ressources, "title": "Ressources"}
|
||||
template_List.stream(datas).dump(REPERTOIRE_HTML + "/ressources.html")
|
||||
|
||||
# Création des pages individuelles ressources, saes, exemples
|
||||
for indexSem, sem in enumerate(ressources):
|
||||
@ -230,13 +321,13 @@ for indexSem, sem in enumerate(ressources):
|
||||
data = {}
|
||||
for categorie, valeur in ressource.ressource.items():
|
||||
data[categorie] = valeur
|
||||
# Ajout des espaces en html
|
||||
data["contenu"] = data["contenu"].replace("\n","<br>")
|
||||
data["contexte"] = data["contexte"].replace("\n","<br><br>")
|
||||
# Formatage de string en html
|
||||
data["contenu"] = formatHTML(data["contenu"])
|
||||
data["contexte"] = formatHTML(data["contexte"])
|
||||
# Sépare les motclés pour former des tags
|
||||
data["motscles"] = motscles(data["motscles"])
|
||||
# Ajoute les liens pour les boutons "Suivant" et "Précédent"
|
||||
datas = {"data":data}
|
||||
datas = {"data":data, "rename": rename}
|
||||
if(i > 0): datas["precedent"] = "R" + str(int(ressource.ressource["code"][1:])-1) + ".html"
|
||||
elif(indexSem > 0): datas["precedent"] = "R" + ressources[list(ressources.keys())[indexSem - 1]][-1].ressource["code"][1:] + ".html"
|
||||
if(i < len(ressources[sem]) - 1): datas["suivant"] = "R" + str(int(ressource.ressource["code"][1:])+1) + ".html"
|
||||
@ -255,10 +346,10 @@ for indexSem, sem in enumerate(ressources):
|
||||
# On regarde si des exemples du sae existent, si True, on les ajoute dans "data"
|
||||
if(sae.sae["code"] in exemples[sem]) :
|
||||
data["exemples"] = exemples[sem][sae.sae["code"]]
|
||||
data["description"] = data["description"].replace("\n","<br><br>")
|
||||
data["livrables"] = data["livrables"].replace("\n","<br><br>")
|
||||
data["description"] = formatHTML(data["description"])
|
||||
data["livrables"] = formatHTML(data["livrables"])
|
||||
data["motscles"] = motscles(data["motscles"])
|
||||
datas = {"data":data}
|
||||
datas = {"data":data, "rename": rename}
|
||||
if(i > 0): datas["precedent"] = "SAE" + str(int(sae.sae["code"][3:])-1) + ".html"
|
||||
elif(indexSem > 0): datas["precedent"] = "SAE" + saes[list(saes.keys())[indexSem - 1]][-1].sae["code"][3:] + ".html" # saes[list(saes.keys())[indexSem - 1]][-1].sae["code"][3:] -> "code" du dernier sae du semestre précédent
|
||||
if(i < len(saes[sem]) - 1): datas["suivant"] = "SAE" + str(int(sae.sae["code"][3:])+1) + ".html"
|
||||
@ -271,11 +362,35 @@ for indexSem, sem in enumerate(ressources):
|
||||
data = {}
|
||||
for categorie, valeur in exemple.exemple.items():
|
||||
data[categorie] = valeur
|
||||
if (isinstance(valeur,str)):
|
||||
data[categorie] = data[categorie].replace("\n","<br><br>")
|
||||
datas = {"data":data}
|
||||
data["description"] = formatHTML(data["description"])
|
||||
data["modalite"] = formatHTML(data["modalite"])
|
||||
datas = {"data":data, "rename": rename}
|
||||
if(j > 0): datas["precedent"] = "SAE" + data["code"][-2:] + "_exemple" + str(i-1) + ".html"
|
||||
if(j < len(exemples[sem][sae]) - 1): datas["suivant"] = "SAE" + data["code"][-2:] + "_exemple" + str(i+1) + ".html"
|
||||
template.stream(datas).dump(REPERTOIRE_HTML + "/" + data["code"].replace("É","E") + "_exemple" + str(i) + ".html")
|
||||
i+=1
|
||||
|
||||
# Création des pages individuelles ACs, Compétences
|
||||
for indexRt, rt in enumerate(acs.getInfo()):
|
||||
|
||||
# ACs
|
||||
for i, (ac, desc) in enumerate(acs.getInfo()[rt].items()):
|
||||
data = {}
|
||||
data["ac"] = ac
|
||||
data["titre"] = desc
|
||||
datas = {"data":data}
|
||||
if i > 0: datas["precedent"] = list(acs.getInfo()[rt].keys())[i-1] + ".html"
|
||||
elif indexRt > 0: datas["precedent"] = list(acs.getInfo()["RT" + str(int(rt[-1])-1)].keys())[-1] + ".html"
|
||||
if i < len(acs.getInfo()[rt])-1: datas["suivant"] = list(acs.getInfo()[rt].keys())[i+1] + ".html"
|
||||
elif indexRt < len(acs.getInfo())-1: datas["suivant"] = list(acs.getInfo()["RT" + str(int(rt[-1])+1)].keys())[0] + ".html"
|
||||
template_AC.stream(datas).dump(REPERTOIRE_HTML + "/" + ac + ".html")
|
||||
|
||||
# Compétences
|
||||
data = {}
|
||||
for categorie, valeur in competences.getInfo()[rt].items():
|
||||
data[categorie] = valeur
|
||||
data["description"] = formatHTML(data["description"])
|
||||
datas = {"data": data, "rt": rt}
|
||||
if indexRt > 0: datas["precedent"] = "RT" + str(indexRt) + ".html"
|
||||
if indexRt <= len(competences.getInfo()): datas["suivant"] = "RT" + str(indexRt + 2) + ".html"
|
||||
template_Competence.stream(datas).dump(REPERTOIRE_HTML + "/" + rt + ".html")
|
22
html/navigation.html
Normal file
22
html/navigation.html
Normal file
@ -0,0 +1,22 @@
|
||||
<nav class="level is-mobile">
|
||||
<div class="level-left">
|
||||
<div class="level-item">
|
||||
<a class="button is-primary{% if not precedent %} is-static"{% else %} is-outlined" href="{{precedent}}"{% endif %}>
|
||||
<span class="icon is-small">
|
||||
<i class="fas fa-arrow-left"></i>
|
||||
</span>
|
||||
<span>Précédent</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="level-right">
|
||||
<div class="level-item">
|
||||
<a class="button is-primary{% if not suivant %} is-static"{% else %} is-outlined" href="{{suivant}}"{% endif %}>
|
||||
<span>Suivant</span>
|
||||
<span class="icon is-small">
|
||||
<i class="fas fa-arrow-right"></i>
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
@ -169,6 +169,9 @@ class Ressource:
|
||||
# Insère les abbréviations
|
||||
return chaine
|
||||
|
||||
def getInfo(self):
|
||||
return self.ressource
|
||||
|
||||
|
||||
def contient_abbr(chaine):
|
||||
"""Détecte les abréviations présentes dans la chaine
|
||||
@ -317,6 +320,9 @@ class SAE:
|
||||
chaine = nettoie_latex(chaine)
|
||||
return chaine
|
||||
|
||||
def getInfo(self):
|
||||
return self.sae
|
||||
|
||||
|
||||
class ExempleSAE:
|
||||
"""Modélise un exemple de SAE lorsqu'elle est extraite d'un yaml"""
|
||||
@ -388,6 +394,37 @@ class ExempleSAE:
|
||||
|
||||
return chaine
|
||||
|
||||
class Competences:
|
||||
""" Modélise une liste de compétences lorsqu'elle est extraite d'un dictionnaire """
|
||||
|
||||
__LOGGER = logging.getLogger(__name__)
|
||||
|
||||
def __init__(self, fichieryaml):
|
||||
with open(fichieryaml, "r", encoding="utf8") as fid:
|
||||
yaml = ruamel.yaml.YAML()
|
||||
try:
|
||||
self.competences = yaml.load(fid.read())
|
||||
except:
|
||||
Competences.__LOGGER.warning(f"Pb de chargement de {fichieryaml}")
|
||||
|
||||
def getInfo(self):
|
||||
return self.competences
|
||||
|
||||
class ACs:
|
||||
""" Modélise une liste de acs lorsqu'elle est extraite d'un fichier yaml """
|
||||
|
||||
__LOGGER = logging.getLogger(__name__)
|
||||
|
||||
def __init__(self, fichieryaml):
|
||||
with open(fichieryaml, "r", encoding="utf8") as fid:
|
||||
yaml = ruamel.yaml.YAML(typ="safe")
|
||||
try:
|
||||
self.acs = yaml.load(fid.read())
|
||||
except:
|
||||
ACs.__LOGGER.warning(f"Pb de chargement de {fichieryaml}")
|
||||
|
||||
def getInfo(self):
|
||||
return self.acs
|
||||
|
||||
def md_to_latex(contenu):
|
||||
"""Réalise la conversion markdown to latex avec pypandoc"""
|
||||
|
Loading…
Reference in New Issue
Block a user