tags pages
This commit is contained in:
parent
367c7754c6
commit
072eafc751
@ -196,7 +196,6 @@ convert_markdown_to_gmi() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# regrouper les types de fichiers générés
|
# regrouper les types de fichiers générés
|
||||||
|
|
||||||
bash sass_styles.sh
|
bash sass_styles.sh
|
||||||
|
|
||||||
# Boucle à travers la liste des sites Web
|
# Boucle à travers la liste des sites Web
|
||||||
@ -222,7 +221,7 @@ for website_name in "${blogs_folders[@]}"; do
|
|||||||
python3 linking_articles_prev_next.py $website_name
|
python3 linking_articles_prev_next.py $website_name
|
||||||
|
|
||||||
# déplacer les fichiers générés en html dans le dossier statique
|
# déplacer les fichiers générés en html dans le dossier statique
|
||||||
mv sources/$website_name/converted/*.html html-websites/$website_name/
|
# mv sources/$website_name/converted/*.html html-websites/$website_name/
|
||||||
|
|
||||||
# python3 enrich_html.py $website_name --style $style_file
|
# python3 enrich_html.py $website_name --style $style_file
|
||||||
|
|
||||||
|
@ -24,6 +24,12 @@ automatic_tagging_enabled = global_config['automatic_tagging_enabled']
|
|||||||
|
|
||||||
count_not_tagged_files = 0
|
count_not_tagged_files = 0
|
||||||
count_orgfiles = 0
|
count_orgfiles = 0
|
||||||
|
destination_json = f'sources/{args.blog}/build'
|
||||||
|
json_file = destination_json + '/articles_info.json'
|
||||||
|
# Charger les données JSON
|
||||||
|
with open(json_file, 'r', encoding='utf-8') as f:
|
||||||
|
articles_info = json.load(f)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def find_org_files(directory):
|
def find_org_files(directory):
|
||||||
@ -50,8 +56,19 @@ def group_files_by_tags(org_files, excluded_tags):
|
|||||||
tag_to_files = defaultdict(set)
|
tag_to_files = defaultdict(set)
|
||||||
for file_path in org_files:
|
for file_path in org_files:
|
||||||
tags = extract_tags_from_file(file_path, excluded_tags)
|
tags = extract_tags_from_file(file_path, excluded_tags)
|
||||||
|
# ajout de slug avec année pour retrouver dans le fichier d'infos json
|
||||||
|
# slug = find_slug_in_file_basename(file_path)
|
||||||
|
date_str, annee, slug = find_year_and_slug_on_filename(file_path)
|
||||||
|
|
||||||
|
print(file_path)
|
||||||
|
boom = file_path.split('/')
|
||||||
|
dernière_partie = boom[-1]
|
||||||
|
boom = dernière_partie.split('__')
|
||||||
|
slug = boom[0][:4]+'/'+slug
|
||||||
|
|
||||||
|
# print( slug )
|
||||||
for tag in tags:
|
for tag in tags:
|
||||||
tag_to_files[tag].add(file_path)
|
tag_to_files[tag].add(slug)
|
||||||
return tag_to_files
|
return tag_to_files
|
||||||
|
|
||||||
|
|
||||||
@ -64,35 +81,34 @@ def generate_html_pages_for_all_tags(tag_to_files, html_output_folder):
|
|||||||
if not os.path.exists(html_output_folder):
|
if not os.path.exists(html_output_folder):
|
||||||
os.makedirs(html_output_folder)
|
os.makedirs(html_output_folder)
|
||||||
|
|
||||||
|
|
||||||
|
template_content = configs_sites[args.blog]
|
||||||
|
|
||||||
|
# Charger le template Jinja2
|
||||||
|
env = Environment(loader=FileSystemLoader('.'))
|
||||||
|
template = env.get_template('templates/html/tag.html.jinja')
|
||||||
|
sorted_tags = sorted(tag_to_files.items())
|
||||||
|
|
||||||
|
tags_count = {tag: len(files) for tag, files in sorted_tags}
|
||||||
|
|
||||||
|
print(tags_count)
|
||||||
|
|
||||||
for tag, files in tag_to_files.items():
|
for tag, files in tag_to_files.items():
|
||||||
html_content = f"""
|
|
||||||
<!DOCTYPE html>
|
|
||||||
<html lang="fr">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>Articles comportant le tag "{tag}"</title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Articles comportant le tag "{tag}"</h1>
|
|
||||||
<ul>
|
|
||||||
"""
|
|
||||||
for file_path_org in files:
|
|
||||||
basename_file = os.path.basename(file_path_org)
|
|
||||||
date_str, annee, slug = find_year_and_slug_on_filename(basename_file)
|
|
||||||
if not slug:
|
|
||||||
slug = find_slug_in_file_basename(file_path_org)
|
|
||||||
|
|
||||||
nom_article = trouver_nom_article(file_path_org, blog_folder, 'org')
|
|
||||||
|
|
||||||
html_content += f" <li><a href='/{annee}/{slug}'>{annee}, {nom_article}</a></li>\n"
|
# Préparer les données pour le template
|
||||||
|
data = {
|
||||||
|
'title' : 'Articles contenant le tag ',
|
||||||
|
'articles_info': articles_info,
|
||||||
|
'files' : files,
|
||||||
|
'tag' : tag,
|
||||||
|
'template_content' : template_content,
|
||||||
|
'html_output_folder': html_output_folder
|
||||||
|
}
|
||||||
|
|
||||||
|
# Rendre le template avec les données
|
||||||
|
html_content = template.render(data)
|
||||||
|
|
||||||
html_content += """
|
|
||||||
</ul>
|
|
||||||
<p><a href="/tags/">Retour à l'index des tags</a></p>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
"""
|
|
||||||
|
|
||||||
html_file_path = os.path.join(html_output_folder, f"{tag}.html")
|
html_file_path = os.path.join(html_output_folder, f"{tag}.html")
|
||||||
with open(html_file_path, 'w', encoding='utf-8') as html_file:
|
with open(html_file_path, 'w', encoding='utf-8') as html_file:
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<script src="main_script.js"></script>
|
<script src="main_script.js"></script>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>{{template_content['TITLE']}}</title>
|
<title>{{ article.title | safe }} -{{template_content['TITLE']}}</title>
|
||||||
<meta name="author" content="{{template_content['AUTHOR']}}">
|
<meta name="author" content="{{template_content['AUTHOR']}}">
|
||||||
<link rel="alternate" type="application/rss+xml" title="{{template_content['BLOG_TITLE']}} » Flux"
|
<link rel="alternate" type="application/rss+xml" title="{{template_content['BLOG_TITLE']}} » Flux"
|
||||||
href="{{template_content['NDD']}}/feed/">
|
href="{{template_content['NDD']}}/feed/">
|
||||||
@ -35,7 +35,7 @@
|
|||||||
<a href="/">
|
<a href="/">
|
||||||
<img src="{{template_content['SITE_ICON']}}" class="site-icon img">
|
<img src="{{template_content['SITE_ICON']}}" class="site-icon img">
|
||||||
</a>
|
</a>
|
||||||
<h1 class="blog-title">{{ article.title | safe }} - {{template_content['BLOG_TITLE']}}
|
<h1 class="blog-title">{{template_content['BLOG_TITLE']}}
|
||||||
|
|
||||||
</h1>
|
</h1>
|
||||||
<p class="blog-subtitle">{{template_content['BLOG_SUBTITLE']}}</p>
|
<p class="blog-subtitle">{{template_content['BLOG_SUBTITLE']}}</p>
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
<script src="main_script.js"></script>
|
<script src="main_script.js"></script>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>{{template_content['TITLE']}}</title>
|
<title>Index des tags - {{template_content['TITLE']}}</title>
|
||||||
<meta name="author" content="{{template_content['AUTHOR']}}">
|
<meta name="author" content="{{template_content['AUTHOR']}}">
|
||||||
<link rel="alternate" type="application/rss+xml" title="{{template_content['BLOG_TITLE']}} » Flux"
|
<link rel="alternate" type="application/rss+xml" title="{{template_content['BLOG_TITLE']}} » Flux"
|
||||||
href="{{template_content['NDD']}}/feed/">
|
href="{{template_content['NDD']}}/feed/">
|
||||||
@ -35,7 +35,7 @@
|
|||||||
<a href="/">
|
<a href="/">
|
||||||
<img src="{{template_content['SITE_ICON']}}" class="site-icon img">
|
<img src="{{template_content['SITE_ICON']}}" class="site-icon img">
|
||||||
</a>
|
</a>
|
||||||
<h1 class="blog-title">Index des tags - {{template_content['BLOG_TITLE']}}
|
<h1 class="blog-title">{{template_content['BLOG_TITLE']}}
|
||||||
|
|
||||||
</h1>
|
</h1>
|
||||||
<p class="blog-subtitle">{{template_content['BLOG_SUBTITLE']}}</p>
|
<p class="blog-subtitle">{{template_content['BLOG_SUBTITLE']}}</p>
|
||||||
@ -74,11 +74,45 @@
|
|||||||
|
|
||||||
<article class="content">
|
<article class="content">
|
||||||
<h1 class="article-title">
|
<h1 class="article-title">
|
||||||
Tags
|
|
||||||
</h1>
|
|
||||||
<!-- <div class="article-main-content">
|
|
||||||
|
|
||||||
</div> -->
|
{% if title %}
|
||||||
|
{{title}} {{tag}}
|
||||||
|
{% else %}
|
||||||
|
Tags
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
</h1>
|
||||||
|
{% if files %}
|
||||||
|
|
||||||
|
<div class="article-main-content">
|
||||||
|
<ul>
|
||||||
|
|
||||||
|
{% for file in files %}
|
||||||
|
{% if articles_info[file] %}
|
||||||
|
<li>
|
||||||
|
<a href='{{articles_info[file].slug_with_year}}'>
|
||||||
|
<h2>
|
||||||
|
{{articles_info[file].annee}}
|
||||||
|
{{articles_info[file].title}}
|
||||||
|
</h2>
|
||||||
|
</a>
|
||||||
|
<div class="tags">
|
||||||
|
{% for t in articles_info[file].tags %}
|
||||||
|
<a href="/tag/{{t}}">
|
||||||
|
{{t}}
|
||||||
|
</a>
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
{% if tags %}
|
||||||
|
|
||||||
<div class="article-tags">
|
<div class="article-tags">
|
||||||
<ul>
|
<ul>
|
||||||
{% for tag_key, file_count in tags.items() %}
|
{% for tag_key, file_count in tags.items() %}
|
||||||
@ -89,10 +123,12 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<hr />
|
<hr />
|
||||||
|
|
||||||
|
<a href="/tags/">Retour à l'index des tags</a>
|
||||||
<div class="retour-accueil">
|
<div class="retour-accueil">
|
||||||
<a href="/">Retour à l'accueil</a>
|
<a href="/">Retour à l'accueil</a>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user