From 3ebcd66cd17741ec7dc7793f9f0121e2ee025fdf Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Tue, 24 Nov 2020 12:10:40 +0100 Subject: Fixing templating (without ejs) --- .gitignore | 2 + base.ejs | 20 ------ base.template.html | 19 ++++++ generate | 70 ++++++++++++++------ index.ejs | 30 --------- index.template.html | 26 ++++++++ school.ejs | 93 --------------------------- school.template.html | 93 +++++++++++++++++++++++++++ utils/fractal_tree/index.ejs | 16 ----- utils/fractal_tree/index.template.html | 14 ++++ utils/langton_ant/index.ejs | 4 -- utils/langton_ant/index.template.html | 3 + utils/minesweeper/index.ejs | 31 --------- utils/minesweeper/index.template.html | 29 +++++++++ utils/rot13/index.ejs | 14 ---- utils/rot13/index.template.html | 12 ++++ utils/sierpinski_triangle/index.ejs | 10 --- utils/sierpinski_triangle/index.template.html | 8 +++ 18 files changed, 256 insertions(+), 238 deletions(-) delete mode 100644 base.ejs create mode 100644 base.template.html delete mode 100644 index.ejs create mode 100644 index.template.html delete mode 100644 school.ejs create mode 100644 school.template.html delete mode 100644 utils/fractal_tree/index.ejs create mode 100644 utils/fractal_tree/index.template.html delete mode 100644 utils/langton_ant/index.ejs create mode 100644 utils/langton_ant/index.template.html delete mode 100644 utils/minesweeper/index.ejs create mode 100644 utils/minesweeper/index.template.html delete mode 100644 utils/rot13/index.ejs create mode 100644 utils/rot13/index.template.html delete mode 100644 utils/sierpinski_triangle/index.ejs create mode 100644 utils/sierpinski_triangle/index.template.html diff --git a/.gitignore b/.gitignore index 2e0badf..1c393b0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *.bak node_modules build +*.html +!*.template.html diff --git a/base.ejs b/base.ejs deleted file mode 100644 index 4ddd460..0000000 --- a/base.ejs +++ /dev/null @@ -1,20 +0,0 @@ - - - - cacharle - - - - - - - - - - - -
- <%- include(pageFilename, {}) %> -
- - diff --git a/base.template.html b/base.template.html new file mode 100644 index 0000000..43638bf --- /dev/null +++ b/base.template.html @@ -0,0 +1,19 @@ + + + + cacharle + + + + + + + + + + +
+ +
+ + diff --git a/generate b/generate index 725d38e..d13dac6 100755 --- a/generate +++ b/generate @@ -1,42 +1,72 @@ #!/bin/sh -# Put your posts in a blog_src directory -# Depends on pandoc for markdown to html convertion +base_template () { + body_file=$(mktemp) + cat > "$body_file" + sed '//r '"$body_file" base.template.html +} -blog_dir=blog +base_template_link () { + link_href="$1" + case $link_href in + *.css) + link_rel="stylesheet" + link_type="text/css" + ;; + *.png) + link_rel="icon" + link_type="image/png" + ;; + *) + echo Invalid link file + exit 1 + ;; + esac + sed "//i\ + " +} -[ ! -d "$blog_dir" ] || [ -z "$(ls $blog_dir)" ] && exit 1 -mkdir -p "$blog_dir" +# Setup +blog_path=blog +mkdir -p "$blog_path" +base_template < index.template.html | + base_template_link 'favicon.png' | + base_template_link 'style.css' > index.html +base_template < school.template.html | + base_template_link 'favicon.png' | + base_template_link 'style.css' > school.html -for post_path in "$blog_dir"/*.md +# Generate blog posts +for post_path in "$(find "$blog_path" -name '*.md')" do - post_dst_path=$(echo "$post_path" | sed 's/\.md/.build.html/') + post_dst_path=$(echo "$post_path" | sed 's_.md_.html_') - # Convert markdown post to html - tmp_file=$(mktemp) - pandoc -f markdown -t html < "$post_path" > "$tmp_file" - - ejs base.ejs -i "{\"pageFilename\": \"$post_path\" }" > "$post_dst_path" - - # Put the blog content in a wrapper template - # sed "// r $tmp_file" < blog.template.html > "$post_dst_path" + pandoc -f markdown -t html < "$post_path" | + base_template | + base_template_link '../favicon.png' | + base_template_link '../style.css' > "$post_dst_path" # Add blog artcle link to the index.html title=$(grep '^# .*$' -m 1 "$post_path" | cut -c 2-) [ -z "$title" ] && echo "post $post_path doesn't have a title" && title=$post_path - sed -i'' "// a\ + sed -i "// a\
  • $title
  • " index.html echo "Generated post at $post_dst_path" done +# Generate utilities for util_path in utils/* do title=$(basename "$util_path" | tr '_' ' ') - - ejs base.ejs -i "{\"pageFilename\": \"$post_path\" }" > "$post_dst_path" - - sed -i'' "// a\ + sed '$ a ' < "$util_path/index.template.html" | + base_template | + base_template_link '../../favicon.png' | + base_template_link '../../style.css' | + base_template_link 'style.css' > "$util_path/index.html" + sed -i'' "// a\
  • $title
  • " index.html + + echo "Generated utility at $util_path" done diff --git a/index.ejs b/index.ejs deleted file mode 100644 index a1afa91..0000000 --- a/index.ejs +++ /dev/null @@ -1,30 +0,0 @@ -

    Charles's website

    - -

    About me

    -

    I'm a computer science student currently at s19, a summary of my progress can be found here

    -

    This site is an experiment to host some of the services I use every day like a mail server and a git server and becoming more independant in general.

    -

    Inspired by a serie of videos posted by Luke Smith.

    - -

    Blog articles

    - - -

    Utils

    - - -

    Links

    - - -

    The style sheet used for this site can be found here.

    diff --git a/index.template.html b/index.template.html new file mode 100644 index 0000000..4055ddb --- /dev/null +++ b/index.template.html @@ -0,0 +1,26 @@ +

    Charles's website

    + +

    About me

    +

    I'm a computer science student currently at s19, a summary of my progress can be found here

    +

    This site is an experiment to host some of the services I use every day like a mail server and a git server and becoming more independant in general.

    +

    Inspired by a serie of videos posted by Luke Smith.

    + +

    Blog articles

    + + +

    Utils

    + + +

    Links

    + + +

    The style sheet used for this site can be found here.

    diff --git a/school.ejs b/school.ejs deleted file mode 100644 index ca2375d..0000000 --- a/school.ejs +++ /dev/null @@ -1,93 +0,0 @@ -

    School projects

    - -

    Most of these are in C and respect the coding style of the school called the norm, the guidelines of each project are detailed in the subject.pdf file of each repository.

    - -

    Validated

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    NameDescription
    libftRewrite some of libc's functions, this project will be used and improved throughout the other project since we're - generally not allowed 3rd party functions that aren't syscall
    get_next_lineA function which read's the next line of a file descriptor each time it is called, will later be integrated to the libft
    ft_printfRewrite the printf function
    ft_serverIntroduction to Docker, An nginx server running Wordpress, phpmyamdin with a MySQL database
    cub3dRaycasting with textures and a map generated from a formated file
    libasmIndroduction to x86_64 assembly, rewritting some basic libc function
    minishellMinimalistic shell based on bash
    - -

    Pending

    - - - - - - - - - - - - - - - - - - -
    ft_services
    philosophers
    ft_containers
    computorv1
    computorv2
    push_swap
    fractol
    scop
    42run
    ft_ls
    ft_select
    ft_ping
    piscine_cpp
    ft_ssl
    rubik
    ft_linear_regression
    dslr
    - -

    Test

    -

    I've made tests for some project's

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    TestTested
    ft_printf_testft_printf
    libasm_testlibasm
    minishell_testminishell
    philosophers_testphilosophers
    ft_containers_testft_containers
    ft_ls_testft_ls
    diff --git a/school.template.html b/school.template.html new file mode 100644 index 0000000..ca2375d --- /dev/null +++ b/school.template.html @@ -0,0 +1,93 @@ +

    School projects

    + +

    Most of these are in C and respect the coding style of the school called the norm, the guidelines of each project are detailed in the subject.pdf file of each repository.

    + +

    Validated

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    NameDescription
    libftRewrite some of libc's functions, this project will be used and improved throughout the other project since we're + generally not allowed 3rd party functions that aren't syscall
    get_next_lineA function which read's the next line of a file descriptor each time it is called, will later be integrated to the libft
    ft_printfRewrite the printf function
    ft_serverIntroduction to Docker, An nginx server running Wordpress, phpmyamdin with a MySQL database
    cub3dRaycasting with textures and a map generated from a formated file
    libasmIndroduction to x86_64 assembly, rewritting some basic libc function
    minishellMinimalistic shell based on bash
    + +

    Pending

    + + + + + + + + + + + + + + + + + + +
    ft_services
    philosophers
    ft_containers
    computorv1
    computorv2
    push_swap
    fractol
    scop
    42run
    ft_ls
    ft_select
    ft_ping
    piscine_cpp
    ft_ssl
    rubik
    ft_linear_regression
    dslr
    + +

    Test

    +

    I've made tests for some project's

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    TestTested
    ft_printf_testft_printf
    libasm_testlibasm
    minishell_testminishell
    philosophers_testphilosophers
    ft_containers_testft_containers
    ft_ls_testft_ls
    diff --git a/utils/fractal_tree/index.ejs b/utils/fractal_tree/index.ejs deleted file mode 100644 index 088dd83..0000000 --- a/utils/fractal_tree/index.ejs +++ /dev/null @@ -1,16 +0,0 @@ -

    fractal tree

    - - - -
    -
    - - -
    -
    - - -
    -
    - - diff --git a/utils/fractal_tree/index.template.html b/utils/fractal_tree/index.template.html new file mode 100644 index 0000000..265f772 --- /dev/null +++ b/utils/fractal_tree/index.template.html @@ -0,0 +1,14 @@ +

    fractal tree

    + + + +
    +
    + + +
    +
    + + +
    +
    diff --git a/utils/langton_ant/index.ejs b/utils/langton_ant/index.ejs deleted file mode 100644 index 5930ebe..0000000 --- a/utils/langton_ant/index.ejs +++ /dev/null @@ -1,4 +0,0 @@ -

    langton ant

    -
    - - diff --git a/utils/langton_ant/index.template.html b/utils/langton_ant/index.template.html new file mode 100644 index 0000000..9efb764 --- /dev/null +++ b/utils/langton_ant/index.template.html @@ -0,0 +1,3 @@ +

    langton ant

    +
    + diff --git a/utils/minesweeper/index.ejs b/utils/minesweeper/index.ejs deleted file mode 100644 index fdbb5be..0000000 --- a/utils/minesweeper/index.ejs +++ /dev/null @@ -1,31 +0,0 @@ -

    minesweeper

    - - - -
    - - -
    -
    - - -
    -
    - - -
    -
    - - -
    -
    -
    - -
    - - diff --git a/utils/minesweeper/index.template.html b/utils/minesweeper/index.template.html new file mode 100644 index 0000000..bf1ea4d --- /dev/null +++ b/utils/minesweeper/index.template.html @@ -0,0 +1,29 @@ +

    minesweeper

    + + + +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    + +
    diff --git a/utils/rot13/index.ejs b/utils/rot13/index.ejs deleted file mode 100644 index 27b3a20..0000000 --- a/utils/rot13/index.ejs +++ /dev/null @@ -1,14 +0,0 @@ -

    rot13

    - -

    Implementation of the rot13 encryption

    - -
    Shift size:
    - - -

    Input

    - - -

    Output

    - - - diff --git a/utils/rot13/index.template.html b/utils/rot13/index.template.html new file mode 100644 index 0000000..64fffdf --- /dev/null +++ b/utils/rot13/index.template.html @@ -0,0 +1,12 @@ +

    rot13

    + +

    Implementation of the rot13 encryption

    + +
    Shift size:
    + + +

    Input

    + + +

    Output

    + diff --git a/utils/sierpinski_triangle/index.ejs b/utils/sierpinski_triangle/index.ejs deleted file mode 100644 index c9b0247..0000000 --- a/utils/sierpinski_triangle/index.ejs +++ /dev/null @@ -1,10 +0,0 @@ -

    sierpinski triangle

    - - - -
    - - -
    - - diff --git a/utils/sierpinski_triangle/index.template.html b/utils/sierpinski_triangle/index.template.html new file mode 100644 index 0000000..3bad80c --- /dev/null +++ b/utils/sierpinski_triangle/index.template.html @@ -0,0 +1,8 @@ +

    sierpinski triangle

    + + + +
    + + +
    -- cgit