up doc, add tags to autodetect
This commit is contained in:
parent
63d51307d5
commit
530b8b7553
12
README.md
12
README.md
@ -13,7 +13,19 @@ Pour un article en langue En (english), sur le blog cipherbliss_blog, donner le
|
||||
python3 new_article.py cipherbliss_blog en "Creation of a gemini blog"
|
||||
```
|
||||
On peut se faire un alias de commande en bash pour n'avoir à remplir que le titre pour un blog donné.
|
||||
### Inclure des images
|
||||
Dans un article on souhaite avoir des thumbnails liées à leur version plus grande et hébergées sur notre site.
|
||||
Placez vos images et autres documents de votre article dans le dossier, puis lancez la commande de conversion et déplacement de vos fichiers.
|
||||
|
||||
```commandline
|
||||
python3 pictures_resize.py
|
||||
```
|
||||
|
||||
Vos miniatures sont crées, et les images originales sont déplacées dans un dossier output/pictures/{année_courante}.
|
||||
|
||||
Un texte orgmode sera mis à disposition dans output/images_{année_courante].org pour les intégrer dans votre ou vos articles Org. Un préfixe de chemin relatif de ces images est configuré dans `website_config.py`
|
||||
|
||||
Il vous faudra placer les images sur votre serveur.
|
||||
|
||||
## prérequis pour installation
|
||||
|
||||
|
@ -3,7 +3,15 @@ import re
|
||||
from datetime import datetime
|
||||
|
||||
# Chemin du dossier source
|
||||
source_dir = "source"
|
||||
import argparse
|
||||
|
||||
# Configuration des arguments de la ligne de commande
|
||||
parser = argparse.ArgumentParser(description="Générer un nouvel article en mode orgmode.")
|
||||
parser.add_argument("blog_dir", help="Le nom du dossier de blog.")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
blog_dir = args.blog_dir
|
||||
|
||||
# Expression régulière pour extraire la date du contenu de l'article
|
||||
date_regex = re.compile(r"\b(\d{14})\b")
|
||||
@ -12,7 +20,7 @@ date_regex = re.compile(r"\b(\d{14})\b")
|
||||
org_files = []
|
||||
|
||||
# Parcourt le dossier source à la recherche de fichiers org-mode
|
||||
for root, dirs, files in os.walk(source_dir):
|
||||
for root, dirs, files in os.walk(blog_dir):
|
||||
for file in files:
|
||||
if file.endswith(".org"):
|
||||
# Ouvre le fichier et recherche la première date dans le contenu de l'article
|
||||
|
@ -56,7 +56,7 @@ def enrich_one_file(html_content: str, partials: dict = {"header_page": "", "foo
|
||||
css_content = f.read()
|
||||
css_content = "<style type='text/css'>{css_content}</style>"
|
||||
template_content["CSS_INLINE_CONTENT"] = css_content
|
||||
template_content["PAGE_SLUG"] = "la_page"
|
||||
template_content["PAGE_SLUG"] = detect_slug_in_file_basename(file)
|
||||
# remplir le template
|
||||
html_content = f"""
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
from collections import defaultdict
|
||||
|
||||
from utils import *
|
||||
@ -18,8 +17,9 @@ directory_fr = f'{directory_base}/lang_fr' # Remplacez par le chemin de votre d
|
||||
output_file = f'sources/{blog_folder}/converted/tags.json' # Fichier de sortie
|
||||
html_output_folder = f'html-websites/{blog_folder}/tags' # Dossier de sortie pour les fichiers HTML
|
||||
excluded_tags = {'PROPERTIES', 'CREATED', 'ID', 'END'}
|
||||
automatic_tagging_enabled=True
|
||||
automatic_tagging_enabled = True
|
||||
|
||||
count_not_tagged_files = 0
|
||||
count_orgfiles = 0
|
||||
|
||||
|
||||
@ -90,14 +90,13 @@ def extract_tags_from_file(file_path, excluded_tags, count_not_tagged_files=0):
|
||||
tags.add(tag)
|
||||
tag_found = True
|
||||
|
||||
|
||||
if not tag_found:
|
||||
count_not_tagged_files = count_not_tagged_files + 1
|
||||
count_not_tagged_files += 1
|
||||
print('no tag in the article', file_path)
|
||||
return tags
|
||||
|
||||
|
||||
def group_files_by_tags(org_files, excluded_tags, count_not_tagged_files):
|
||||
def group_files_by_tags(org_files, excluded_tags):
|
||||
tag_to_files = defaultdict(set)
|
||||
for file_path in org_files:
|
||||
tags = extract_tags_from_file(file_path, excluded_tags, count_not_tagged_files)
|
||||
@ -129,17 +128,17 @@ def generate_html_pages_for_all_tags(tag_to_files, html_output_folder):
|
||||
<ul>
|
||||
"""
|
||||
for file_path_org in files:
|
||||
basename_file= os.path.basename(file_path_org)
|
||||
slug=detect_slug_in_file_basename(basename_file)
|
||||
basename_file = os.path.basename(file_path_org)
|
||||
slug = detect_slug_in_file_basename(basename_file)
|
||||
if not slug:
|
||||
slug = trouver_slug_in_article(file_path_org)
|
||||
|
||||
nom_article = trouver_nom_article( file_path_org, blog_folder, 'org')
|
||||
nom_article = trouver_nom_article(file_path_org, blog_folder, 'org')
|
||||
|
||||
print('slug',slug)
|
||||
print('slug', slug)
|
||||
print('basename_file', basename_file, nom_article)
|
||||
|
||||
html_content += f" <li><a href='{slug}'>{nom_article}</a></li>\n"
|
||||
html_content += f" <li><a href='/{slug}'>{nom_article}</a></li>\n"
|
||||
|
||||
html_content += """
|
||||
</ul>
|
||||
@ -155,7 +154,6 @@ def generate_html_pages_for_all_tags(tag_to_files, html_output_folder):
|
||||
print(f"Pages HTML générées dans {html_output_folder}")
|
||||
|
||||
|
||||
|
||||
def trouver_slug_in_article(file_path_org):
|
||||
"""
|
||||
Trouve le contenu de la variable #+slug: dans un fichier Org.
|
||||
@ -180,15 +178,10 @@ def trouver_slug_in_article(file_path_org):
|
||||
|
||||
def generate_index_page(tag_to_files, html_output_folder):
|
||||
index_content = f"""
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Index des tags</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="tags_page">
|
||||
<h1>Index des tags</h1>
|
||||
|
||||
<ul>
|
||||
"""
|
||||
sorted_tags = sorted(tag_to_files.items())
|
||||
@ -200,8 +193,8 @@ def generate_index_page(tag_to_files, html_output_folder):
|
||||
|
||||
index_content += """
|
||||
</ul>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
index_file_path = os.path.join(html_output_folder, "index.html")
|
||||
@ -213,9 +206,8 @@ def generate_index_page(tag_to_files, html_output_folder):
|
||||
|
||||
if __name__ == "__main__":
|
||||
org_files = find_org_files(directory_fr)
|
||||
count_not_tagged_files = 0
|
||||
|
||||
tag_to_files = group_files_by_tags(org_files, excluded_tags, count_not_tagged_files)
|
||||
tag_to_files = group_files_by_tags(org_files, excluded_tags)
|
||||
|
||||
save_to_json(tag_to_files, output_file)
|
||||
generate_html_pages_for_all_tags(tag_to_files, html_output_folder)
|
||||
@ -223,3 +215,4 @@ if __name__ == "__main__":
|
||||
|
||||
print(f"Tags et fichiers associés ont été enregistrés dans {output_file}")
|
||||
print(f"Pages HTML générées dans {html_output_folder}")
|
||||
print(f"Pages non tagguées: {count_not_tagged_files}")
|
||||
|
@ -48,7 +48,7 @@ Rédaction, conversion, completion des nouveaux articles, régénération des in
|
||||
|
||||
# Sources d'inspiration:
|
||||
|
||||
Offpunk LazyBlog Dotclear, Wordpress, Hugo, Pélican Pandoc, PandocGmi
|
||||
Offpunk, LazyBlog, Dotclear, Wordpress, Hugo, Pélican, Pandoc, PandocGmi
|
||||
=> https://github.com/njamescouk/pandocGmi/tree/master https://github.com/njamescouk/pandocGmi/tree/master
|
||||
|
||||
# Roadmap
|
||||
@ -63,7 +63,5 @@ Offpunk LazyBlog Dotclear, Wordpress, Hugo, Pélican Pandoc, PandocGmi
|
||||
# Fait
|
||||
|
||||
* navigation sur les pages d'article
|
||||
|
||||
- gestion des langues dans la source et la destination
|
||||
|
||||
* gestion des langues dans la source et la destination
|
||||
* gestion multi site et multi langue
|
@ -27,7 +27,7 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="page" class="page__la_page">
|
||||
<div id="page" class="page__None">
|
||||
<header id="masthead" class="site-header">
|
||||
<div class="header-image" style="background: url(https://www.cipherbliss.com/wp-content/uploads/2016/11/bg.jpg)">
|
||||
<a href="/">
|
||||
|
@ -27,7 +27,7 @@
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="page" class="page__la_page">
|
||||
<div id="page" class="page__None">
|
||||
<header id="masthead" class="site-header">
|
||||
<div class="header-image" style="background: url(https://www.cipherbliss.com/wp-content/uploads/2016/11/bg.jpg)">
|
||||
<a href="/">
|
||||
@ -79,7 +79,7 @@
|
||||
<main class="body-wrap boxed-container">
|
||||
<article class="content">
|
||||
|
||||
<div id="page" class="page__la_page">
|
||||
<div id="page" class="page__None">
|
||||
<header id="masthead" class="site-header">
|
||||
<div class="header-image" style="background: url(https://www.cipherbliss.com/wp-content/uploads/2016/11/bg.jpg)">
|
||||
<a href="/">
|
||||
|
@ -2,9 +2,9 @@
|
||||
# création de nouvel article de blog
|
||||
# exemple de commande
|
||||
# python new_article.py cipherbliss_blog fr "Création d'un blog gemini"
|
||||
import argparse
|
||||
import os
|
||||
from datetime import datetime
|
||||
import argparse
|
||||
|
||||
# Configuration des arguments de la ligne de commande
|
||||
parser = argparse.ArgumentParser(description="Générer un nouvel article en mode orgmode.")
|
||||
|
@ -7,7 +7,12 @@ global_config = {
|
||||
"rebuild_files_filter": 2024,
|
||||
"source_files_extension": "org",
|
||||
# controlled vocabulary to find tags automatically
|
||||
"auto_tag_terms": ["illustration", "tuto", "nsfw", "bd", "récit", "science"]
|
||||
"auto_tag_terms": ["illustration", "tuto", "nsfw", "bd", "récit", "science",
|
||||
"wtf","yaoi","yuri","sondage","entreprise","ai","photos",
|
||||
"cosplay","festival","fanzine","manif","logiciel","inktober",
|
||||
"kotlife","féminisme","fantasme","art","sociologie","couple","masturbation",
|
||||
"boobs","sortirDesFossiles","électrique","maison","GTD","chat","PIM",
|
||||
"openstreetmap","sauvegarde","mastodon","voyages","bouffe"]
|
||||
}
|
||||
configs_sites = {
|
||||
"cipherbliss_blog": {
|
||||
|
Loading…
Reference in New Issue
Block a user