This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
informatique:web:pelican [2024/11/17 20:24] – [Script PowerShell] yahiko | informatique:web:pelican [2024/12/18 22:39] (current) – removed yahiko | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Pelican ====== | ||
- | <WRAP center round important 60%> | ||
- | Notes personnelles, | ||
- | </ | ||
- | |||
- | Notes d' | ||
- | |||
- | Notes suite à une installation pour test sur un conteneur Debian 12 sous Proxmox. | ||
- | |||
- | ===== Installation ===== | ||
- | On installe pip, Python3 était déjà installé sur mon conteneur Debian : | ||
- | <code bash> | ||
- | apt install python3-pip -y | ||
- | </ | ||
- | |||
- | ==== Définir une environnement virtuel Python ==== | ||
- | |||
- | === Sous Linux === | ||
- | <code bash> | ||
- | mkdir undossier | ||
- | python3 -m venv ~/undossier | ||
- | source undossier/ | ||
- | </ | ||
- | |||
- | === Sous Windows === | ||
- | <code powershell> | ||
- | python -m venv undossier | ||
- | .\undossier\Scripts\activate | ||
- | </ | ||
- | |||
- | Comme je suis une feignasse, j'ai fait un script PowerShell pour ne pas me faire chier sous Windows : | ||
- | |||
- | <file powershell venv.ps1> | ||
- | $path_global = " | ||
- | $path_venv = " | ||
- | $py_activate = " | ||
- | Set-Location -Path $path_global | ||
- | powershell -noexit " | ||
- | </ | ||
- | |||
- | Et je le lance avec un batch (oui) en utilisant Windows Terminal : | ||
- | <file batch start.bat> | ||
- | @ECHO OFF | ||
- | SET folder=" | ||
- | wt PowerShell -c %folder%\venv.ps1 | ||
- | </ | ||
- | |||
- | ==== Installer Pelican ==== | ||
- | |||
- | On installe Pelican : | ||
- | <code bash> | ||
- | pip install " | ||
- | </ | ||
- | |||
- | ===== Créer un premier site ===== | ||
- | On créé un dossier et on lance l' | ||
- | <code bash> | ||
- | mkdir monsupersite | ||
- | cd monsupersite | ||
- | pelican-quickstart | ||
- | </ | ||
- | |||
- | On répond aux questions de l' | ||
- | < | ||
- | pelican-quickstart | ||
- | Welcome to pelican-quickstart v4.10.1. | ||
- | |||
- | This script will help you create a new Pelican-based website. | ||
- | |||
- | Please answer the following questions so this script can generate the files | ||
- | needed by Pelican. | ||
- | |||
- | | ||
- | > Where do you want to create your new web site? [.] | ||
- | > What will be the title of this web site? Erreur503 | ||
- | > Who will be the author of this web site? Yahiko | ||
- | > What will be the default language of this web site? [en] fr | ||
- | > Do you want to specify a URL prefix? e.g., https:// | ||
- | > What is your URL prefix? (see above example; no trailing slash) https:// | ||
- | > Do you want to enable article pagination? (Y/n) Y | ||
- | > How many articles per page do you want? [10] 5 | ||
- | > What is your time zone? [Europe/ | ||
- | > Do you want to generate a tasks.py/ | ||
- | > Do you want to upload your website using FTP? (y/N) N | ||
- | > Do you want to upload your website using SSH? (y/N) y | ||
- | > What is the hostname of your SSH server? [localhost] | ||
- | > What is the port of your SSH server? [22] | ||
- | > What is your username on that server? [root] | ||
- | > Where do you want to put your web site on that server? [/ | ||
- | > Do you want to upload your website using Dropbox? (y/N) | ||
- | > Do you want to upload your website using S3? (y/N) | ||
- | > Do you want to upload your website using Rackspace Cloud Files? (y/N) | ||
- | > Do you want to upload your website using GitHub Pages? (y/N) | ||
- | Done. Your new project is available at / | ||
- | </ | ||
- | |||
- | ===== Créer une page ===== | ||
- | Dans '' | ||
- | |||
- | <file md article.md> | ||
- | Title: Mon super article | ||
- | Date: 2024/11/13 21:43 | ||
- | Category: 3615 Ma vie | ||
- | Tags: pelican, ma vie, test, osef | ||
- | Slug: mon-super-article | ||
- | Authors: Lapinours | ||
- | |||
- | # Titre 1 | ||
- | ## Titre 2 | ||
- | Wow, un **super** article sur `Pelican`. | ||
- | |||
- | Tellement _beau_ et **_frais_**. | ||
- | </ | ||
- | |||
- | ==== Script Python ==== | ||
- | Pour générer un peu plus rapidement les articles lors de mes tests, j'ai fait rapidement ce script Python (à la base il était en PowerShell mais je me suis réveillé) : | ||
- | |||
- | <file python article.py> | ||
- | import datetime | ||
- | import os | ||
- | |||
- | # Variables | ||
- | file_ext = " | ||
- | file_name = input(" | ||
- | date = datetime.datetime.now() | ||
- | article_title = input(" | ||
- | article_date = str(date.strftime(" | ||
- | article_category = input(" | ||
- | article_tags = input(" | ||
- | article_slug = str(file_name) | ||
- | article_authors = " | ||
- | |||
- | # Lignes pour le template | ||
- | lines = [ | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ' | ||
- | ] | ||
- | |||
- | # On écrit dans le fichier | ||
- | f = open(file_name + " | ||
- | for line in lines: | ||
- | f.write(line) | ||
- | f.write(' | ||
- | f.close | ||
- | |||
- | # On lance l' | ||
- | os.startfile(file_name + " | ||
- | |||
- | ===== Publier ===== | ||
- | <code bash> | ||
- | pelican / | ||
- | </ | ||
- | |||
- | Pour mon environnement de test j'ai installé Apache comme un sagouin. J'ai copié le contenu du dossier '' | ||
- | <code bash> | ||
- | cp -r / | ||
- | </ | ||
- | |||
- | La commande '' | ||
- | |||
- | '' | ||
- | |||
- | ===== Installer un thème ===== | ||
- | |||
- | <WRAP center round alert 60%> | ||
- | Pas terminé, je suis propablement teubé, ou j'ai encore lu la doc trop en diagonale. | ||
- | </ | ||
- | |||
- | De base Pelican produit des pages HTML très simples. C'est bien mais ce n'est pas très très pratique. On va installer les thèmes depuis le [[https:// | ||
- | |||
- | On va suivre bêtement la doc et cloner le repo git des thèmes Pelican : | ||
- | <code bash> | ||
- | git clone --recursive https:// | ||
- | </ | ||
- | |||
- | On va éditer le fichier de conf du site : | ||
- | <file python pelicanconf.py> | ||
- | THEME = "/ | ||
- | </ | ||
- | |||
- | |||
- | |||