This repository has been archived by the owner on Mar 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 33065da
Showing
7 changed files
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Generate documents | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
branches: [ main ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
env: | ||
working-directory: ./generator | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v3 | ||
with: | ||
python-version: "3.10" | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
sudo apt-get -y install wkhtmltopdf | ||
mkdir ./out | ||
working-directory: ${{env.working-directory}} | ||
- name: Generate PDF files. | ||
run: | | ||
python3 generate.py -o ./out -d ../src | ||
working-directory: ${{env.working-directory}} | ||
- name: Upload Artifacts | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: fiches-tutos | ||
path: "./generator/out" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# fiches-tuto | ||
|
||
Markdown sources files for genereation of "fiches tutos" at l'Atelier | ||
|
||
## Contributing | ||
|
||
Everyone can contribute by creating or updating the files according to the reference. | ||
([template.md](src/template.md)) | ||
|
||
Feel free to open issues for suggestions and to facilitate the workflow of remaining work. | ||
|
||
## Locale | ||
|
||
local variations must start with prs_, lyn_, tls_... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Fiche</title> | ||
<link rel="preconnect" href="https://fonts.googleapis.com"> | ||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | ||
<link href="https://fonts.googleapis.com/css2?family=Atkinson+Hyperlegible:wght@400;700&display=swap" | ||
rel="stylesheet"> | ||
<style> | ||
html { | ||
font-family: 'Atkinson Hyperlegible', sans-serif; | ||
} | ||
|
||
html, body { | ||
margin: 0px !important; | ||
padding: 0px !important; | ||
} | ||
|
||
.bar { | ||
width: 100%; | ||
height: 20px; | ||
} | ||
|
||
.blue-bar { | ||
background: #3498db; | ||
} | ||
|
||
.logo { | ||
width: 200px; | ||
margin: 20px; | ||
} | ||
|
||
header { | ||
padding-left: 40px; | ||
padding-right: 40px; | ||
display: flex; | ||
font-weight: 700; | ||
text-transform: uppercase; | ||
} | ||
|
||
header div { | ||
width: 100%; | ||
line-height: 98px; | ||
} | ||
|
||
header h1 { | ||
text-align: center; | ||
} | ||
|
||
article { | ||
margin: 42px 115px 115px; | ||
font-size: 20px !important; | ||
} | ||
|
||
h1:not(header h1), h2, h3, h4, h5, h6 { | ||
margin-bottom: 10px; | ||
margin-top: 20px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
|
||
<div class="bar blue-bar"></div> | ||
|
||
<header> | ||
<img src="https://github.com/Atelier-Epita/fiches-machines/raw/main/generator/static/logo.png" alt="L'Atelier" class="logo"> | ||
<div> | ||
<h1>%title%</h1> | ||
</div> | ||
</header> | ||
|
||
|
||
<article> | ||
%content% | ||
</article> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import argparse | ||
import os | ||
|
||
import frontmatter | ||
import markdown | ||
import pdfkit | ||
|
||
|
||
def process(path: str, output: str): | ||
with open(path) as f: | ||
metadata, content = frontmatter.parse(f.read()) | ||
|
||
content = markdown.markdown(content) | ||
|
||
html = "" | ||
with open("document.html") as document: | ||
html = document.read() | ||
|
||
html = html.replace("%title%", metadata['title']) \ | ||
.replace("%content%", content) | ||
|
||
pdfkit.from_string(html, output, options={ | ||
"margin-top": "0", "margin-bottom": "0", "margin-left": "0", "margin-right": "0", | ||
"dpi": "300"}) | ||
|
||
print(f"Processed {os.path.basename(path)}.") | ||
|
||
|
||
def get_pdf_path(outdir: str, original_file: str): | ||
return outdir.rstrip("/") + "/" + os.path.splitext(os.path.basename(original_file))[0] + ".pdf" | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser(description='Process some integers.') | ||
parser.add_argument('-o', '--outdir', nargs='?', help='Output directory', default="./") | ||
parser.add_argument('-f', '--file', nargs='?', help='File to process') | ||
parser.add_argument('-d', '--dir', nargs='?', help='Directory to process') | ||
|
||
args = parser.parse_args() | ||
|
||
if args.file is None and args.dir is None: | ||
print("At least --file or --dir must be provided.") | ||
exit(1) | ||
elif args.file is not None and args.dir is not None: | ||
print("--file and --dir must not be present at the same time.") | ||
exit(1) | ||
|
||
if args.file is not None: | ||
process(str(args.file), | ||
get_pdf_path(str(args.outdir), str(args.file))) | ||
else: | ||
for file in os.listdir(str(args.dir)): | ||
if os.path.splitext(file)[1] in [".md", ".yaml", ".yml"]: | ||
process(str(args.dir).rstrip("/") + "/" + file, | ||
get_pdf_path(str(args.outdir), str(file))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
python-frontmatter | ||
markdown | ||
pdfkit |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
title: Template | ||
--- | ||
|
||
## Description | ||
<!-- description du tuto, éventuellement un plan --> | ||
|
||
## Requirements | ||
<!-- ce sont on a besoin (soft, hard, etc) pour effectuer le tuto --> | ||
|
||
## Contenu | ||
<!-- le contenu du tuto --> |