Commit cc099aa8 authored by Matthieu Boileau's avatar Matthieu Boileau

Fixing missing colon after day directive

Strangly, it doesn't trigger an error but instead put the block inside
an html comment
parent a8fbc3f4
......@@ -164,7 +164,7 @@ ANF "Python avancé en calcul scientifique"
Cython est un langage hybride entre le Python et le C fait spécifiquement pour le développement de modules d'extension Python. Cython permet d'optimiser du code Python ligne par ligne en remplaçant des variables Python non-typées par des variables C typées. Cython peut également être utilisé pour l'interfaçage avec des routines en C où Fortran. Nous proposons une initiation à son usage dans le cadre de l'optimisation.
.. day: 04-12-2013
.. day:: 04-12-2013
.. event:: Notions de performances et profiling
:begin: 13:30
......
......@@ -154,7 +154,7 @@
Les technologies évoluent à grande vitesse afin d’atteindre les cibles d’efficacité, de performance et de densité que nos grands défis scientifiques et techniques appellent. Cette présentation vise premièrement à évaluer combien les nouvelles technologies peuvent répondre à nos attentes. Dans un second temps, l’enjeu d’une adaptation continue de nos applications et de nos architectures est établi afin de bénéficier des dernières spécifications et de voir converger les résultats obtenus avec les attentes. La conclusion pose quelques directions pour des collaborations étroites avec Dell Technologies.
.. event:: Cheminement vers l'IPGP.
:support: [Comment s'y rendre](http://calcul.math.cnrs.fr/IMG/png/ihp-ipgp.png)
:support: [Comment s'y rendre](attachments/spip/IMG/png/ihp-ipgp.png)
:begin: 17:30
:end: 18:00
......
......@@ -51,8 +51,10 @@ DIRECT_TEMPLATES = ['index', 'categories', 'archives', 'tags', 'search']
MARKUP = ('md', 'ipynb')
PLUGIN_PATHS = ['./plugins']
PLUGINS = ['ipynb.markup', 'pelican_dynamic', 'rst_directives', 'extract_toc', 'calcul_reader', 'calcul_filters',
'rst_include', 'sitemap', 'tipue_search', 'check_deadlinks']
PLUGINS = ['ipynb.markup', 'pelican_dynamic', 'rst_directives', 'extract_toc',
'calcul_reader', 'calcul_filters', 'rst_include', 'sitemap',
'tipue_search', 'check_deadlinks', 'orphean_attachments']
# Useful for 'rst_include' plugin (elative to content directory)
RST_GLOBAL_INCLUDES = ['../plugins/rst_include/include.rst']
......@@ -63,6 +65,13 @@ DEADLINK_OPTS = {
'request_verify': True
}
# For orphean_attachments plugin
ORPHEAN_VALIDATION = True
ORPHEAN_OPTS = {
'prefix': 'attachments',
'action': 'list'
}
MENUITEMS = [('Le groupe', '/pages/presentation_groupe.html'),
('Paysage du calcul', '/pages/paysage_du_calcul.html'),
('Nos journées', '/category/journee.html'),
......
# -*- coding: utf8 -*-
from .orphean_attachments import *
# -*- coding: utf8 -*-
"""List and remove attachment files that are not referenced by any html link"""
from logging import info, debug, warning
from bs4 import BeautifulSoup
from pelican import signals
from pathlib import Path
import requests
import os
import urllib3
from urllib.parse import unquote
DEFAULT_OPTS = {
'prefix': 'attachments',
'action': 'list' # 'list' or 'remove'
}
# Global variable to store link paths
LINKS = set()
def user_enabled(inst, opt):
"""
Check whether the option is enabled.
:param inst: instance from content object init
:param opt: Option to be checked
:return: True if enabled, False if disabled or non present
"""
return opt in inst.settings and inst.settings[opt]
def content_object_init(instance):
"""
Pelican callback
"""
if instance._content is None:
return
if not user_enabled(instance, 'ORPHEAN_VALIDATION'):
debug("Configured not to validate attachments")
return
opts = instance.settings.get('ORPHEAN_OPTS', DEFAULT_OPTS)
soup_doc = BeautifulSoup(instance._content, 'html.parser')
for anchor in soup_doc(['a', 'object', 'img']):
if 'href' in anchor.attrs:
url = anchor['href']
elif 'src' in anchor.attrs:
url = anchor['src']
else:
continue
# Decoding escaped characters (like `%20` from spaces)
url = unquote(url)
if opts['prefix'] in url.split('/'):
debug("Adding url to attachments links: {}".format(url))
if url.startswith('../'):
# article is from pages/ directory so its path has to be
# resolved
parent_path = Path(instance.save_as).parent
resolved_path = (Path('content') / parent_path /
Path(url)).resolve()
debug("resolved_path: {}".format(resolved_path))
relative_path = resolved_path.relative_to(os.getcwd())
else:
# article is from an article so the file path starts
# from content/
relative_path = (Path('content') / Path(url))
debug("Corresponding file: {}".format(relative_path))
LINKS.add(relative_path)
def finalized(pelican):
opts = pelican.settings.get('ORPHEAN_OPTS', DEFAULT_OPTS)
# List all files in content/attachments/ directory
files = {path for path in (Path('content') /
Path(opts['prefix'])).glob('**/*')
if path.is_file()}
# List all links that have no files
all_path = files | LINKS
dead_links = all_path - files
if dead_links:
warning("{} links have no target:".format(len(dead_links)))
for path in dead_links:
warning(" {}".format(str(path)))
# List files that are not targeted by an html link
files_to_remove = files - LINKS
debug("{} attachments files".format(len(files)))
debug("{} attachments links".format(len(LINKS)))
if files_to_remove:
warning("{} attachments have no link:".format(len(files_to_remove)))
if opts['action'] == 'list':
if len(files_to_remove) > 20:
# Output is too long => store in file
logfilename = "{}.log".format(__name__.split('.')[-1])
with open(logfilename, 'w') as f:
for path in files_to_remove:
f.write("{}\n".format(str(path)))
warning("orphean files are listed in {}".format(logfilename))
else:
for path in files_to_remove:
warning(" {}".format(str(path)))
elif opts['action'] == 'remove':
warning("Removing {} orphean files".format(len(files_to_remove)))
for path in files_to_remove:
warning("Removing {}".format(str(path)))
os.remove(path)
def register():
"""
Part of Pelican API
"""
signals.content_object_init.connect(content_object_init)
signals.finalized.connect(finalized)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment