new article script
This commit is contained in:
parent
6766fb1fd7
commit
8de8e57e06
@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# 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
|
||||
from datetime import datetime
|
||||
|
||||
@ -14,12 +16,22 @@ args = parser.parse_args()
|
||||
# Génération du nom de fichier org avec la date et le slug
|
||||
now = datetime.now()
|
||||
date_string = now.strftime("%Y-%m-%d")
|
||||
date_string_full = now.strftime("%Y-%m-%d %H:%M:%S")
|
||||
slug = args.title.lower().replace(" ", "-")
|
||||
filename = f"sources/{args.blog_dir}/lang_{args.lang}/{date_string}-{slug}.org"
|
||||
|
||||
import uuid
|
||||
|
||||
def create_uuid_property():
|
||||
uuid_value = uuid.uuid4()
|
||||
return f":PROPERTIES:\n:ID: {uuid_value}\n:END:\n"
|
||||
|
||||
# Écriture du fichier org
|
||||
with open(filename, "w") as f:
|
||||
f.write(f"{create_uuid_property()}")
|
||||
f.write(f"#+TITLE: {args.title}\n")
|
||||
f.write(f"#+CREATED: {date_string_full}\n")
|
||||
f.write(f"#+SLUG: {slug}\n")
|
||||
f.write(f"#+BLOG: {args.blog_dir}\n\n")
|
||||
f.write(f"* {args.title}\n\n")
|
||||
f.write(f"[{date_string}]\n\n")
|
||||
|
@ -0,0 +1,12 @@
|
||||
:PROPERTIES:
|
||||
:ID: 8e220f62-f0fc-4394-8bdf-f9b3db30711e
|
||||
:END:
|
||||
#+TITLE: Création d'un blog gemini
|
||||
#+CREATED: 2024-11-03 12:41:56
|
||||
#+SLUG: création-d'un-blog-gemini
|
||||
#+BLOG: cipherbliss_blog
|
||||
|
||||
* Création d'un blog gemini
|
||||
|
||||
[2024-11-03]
|
||||
|
Loading…
Reference in New Issue
Block a user