improve formatting script and handle formatting errors

This commit is contained in:
timurgordon
2022-09-09 12:39:28 +03:00
parent 4d7cdb6088
commit a24107cbb8
9 changed files with 85 additions and 30 deletions

View File

@@ -44,6 +44,9 @@ do
sed -i "" "s|private: 1| private: 1\\ sed -i "" "s|private: 1| private: 1\\
socialLinks: {\\ socialLinks: {\\
}|g" "$file" }|g" "$file"
sed -i "" "s|private: 0| private: 0\\
socialLinks: {\\
}|g" "$file"
move_below category: excerpt: $file move_below category: excerpt: $file
move_below memberships: excerpt: $file move_below memberships: excerpt: $file
@@ -65,6 +68,10 @@ do
sed -i "" "s|$WEBSITES|$WEBSITES,|g" "$file" sed -i "" "s|$WEBSITES|$WEBSITES,|g" "$file"
LINKEDIN="$(grep -n 'linkedin:' "$file" | sed -n -e 's/^.*\(\(linkedin:\).*\)/\1/p')" LINKEDIN="$(grep -n 'linkedin:' "$file" | sed -n -e 's/^.*\(\(linkedin:\).*\)/\1/p')"
sed -i "" "s|$LINKEDIN|$LINKEDIN,|g" "$file" sed -i "" "s|$LINKEDIN|$LINKEDIN,|g" "$file"
if exists "github" $file; then
GITHUB="$(grep -n 'github:' "$file" | sed -n -e 's/^.*\(\(github:\).*\)/\1/p')"
sed -i "" "s|$GITHUB|$GITHUB,|g" "$file"
fi
# put id into square brackets for people taxonomy # put id into square brackets for people taxonomy
ID="$(grep -n 'id:' "$file" | sed -n -e 's/^.*\(\(id:\).*\)/\1/p')" ID="$(grep -n 'id:' "$file" | sed -n -e 's/^.*\(\(id:\).*\)/\1/p')"
@@ -82,27 +89,30 @@ do
replace "projects:" "organizations:" $file replace "projects:" "organizations:" $file
replace "image: ./" "imgPath: " $file replace "image: ./" "imgPath: " $file
sed -i "" "s|image:|extra:\\ sed -i "" "s|imgPath:|extra:\\
image:|g" "$file" imgPath:|g" "$file"
sed -i "" "s|id:|taxonomies:\\ sed -i "" "s|id:|taxonomies:\\
people:|g" "$file" people:|g" "$file"
add_tab "memberships:" $file
add_tab "categories:" $file
add_tab "cities:" $file add_tab "cities:" $file
add_tab "countries:" $file add_tab "countries:" $file
add_tab "extra:" $file add_tab "organizations:" $file
add_tab "LinkedIn:" $file
add_tab "LinkedIn:" $file
add_tab "websites:" $file
add_tab "websites:" $file
add_tab "github:" $file
add_tab "github:" $file
#dir_path=${file%/*} dir_path=${file%/*}
#fname=${dir_path##*/} fname=${dir_path##*/}
#mkdir content/people/$fname mkdir content/people/$fname
#mv -s $file content/people/$fname/index.md ln -s ../../../$file content/people/$fname/index.md
ln -s ../../../$dir_path/$fname.jpg content/people/$fname
#ln -s ${file%/*} content/people #ln -s ${file%/*} content/people
mv $file ${file%/*}/index.md
mv ${file%/*} content/people
break
done; done;
echo "Formatting blogs..." echo "Formatting blogs..."
@@ -127,10 +137,15 @@ do
sed -i "" "s|image: ./|extra:\\ sed -i "" "s|image: ./|extra:\\
imgPath: |g" "$file" imgPath: |g" "$file"
mv $file ${file%/*}/index.md add_tab "tags" $file
mv ${file%/*} content/blog add_tab "categories" $file
dir_path=${file%/*}
fname=${dir_path##*/}
mkdir content/blog/$fname
ln -s ../../../$file content/blog/$fname/index.md
ln -s ../../../$dir_path/$fname.jpg content/blog/$fname
break
done; done;
echo "Formatting news..." echo "Formatting news..."
@@ -146,7 +161,7 @@ do
move_below image: category: $file move_below image: category: $file
# Change field names # Change field names
sed -i "" "s|category:|categories:|g" "$file" sed -i "" "s|category:|news-category:|g" "$file"
sed -i "" "s|created:|date:|g" "$file" sed -i "" "s|created:|date:|g" "$file"
sed -i "" "s|excerpt:|description:|g" "$file" sed -i "" "s|excerpt:|description:|g" "$file"
sed -i "" "s| ---|---|g" "$file" sed -i "" "s| ---|---|g" "$file"
@@ -155,10 +170,17 @@ do
sed -i "" "s|image: ./|extra:\\ sed -i "" "s|image: ./|extra:\\
imgPath: |g" "$file" imgPath: |g" "$file"
mv $file ${file%/*}/index.md add_tab "tags" $file
mv ${file%/*} content/newsroom add_tab "news-category" $file
break dir_path=${file%/*}
fname=${dir_path##*/}
mkdir content/newsroom/$fname
ln -s ../../../$file content/newsroom/$fname/index.md
ln -s ../../../$dir_path/$fname.jpg content/newsroom/$fname
done; done;
# mickey malul people taxonomy should be mickey_malul
# kristof's categories are not formatted correctly
# zero people it is the future blog bug

File diff suppressed because one or more lines are too long

View File

@@ -2,9 +2,12 @@
{% block content %} {% block content %}
{% if page.taxonomies.people %} {% if page.taxonomies.people %}
{% set people = get_section(path="people/_index.md") %}
{% if people.pages is containing(page.taxonomies.people[0]) %}
{% set author_path = 'people/' ~ page.taxonomies.people[0] ~ '/index.md' %} {% set author_path = 'people/' ~ page.taxonomies.people[0] ~ '/index.md' %}
{% set author = get_page(path=author_path) %} {% set author = get_page(path=author_path) %}
{% endif %} {% endif %}
{% endif %}
<!-- Default page template for blog posts and basic informative markdown files --> <!-- Default page template for blog posts and basic informative markdown files -->
<main> <main>

View File

@@ -17,6 +17,9 @@ and a side nav for category and featured post navigation
{%- set_global featured = page %} {%- set_global featured = page %}
{% break %} {% break %}
{% endif %} {% endif %}
{% if not featured %}
{%- set_global featured = section.pages[0] %}
{% endif %}
{% endfor %} {% endfor %}
{% include "partials/featuredBlog.html" %} {% include "partials/featuredBlog.html" %}

View File

@@ -17,6 +17,9 @@ and a side nav for category and featured post navigation
{%- set_global featured = page %} {%- set_global featured = page %}
{% break %} {% break %}
{% endif %} {% endif %}
{% if not featured %}
{%- set_global featured = section.pages[0] %}
{% endif %}
{% endfor %} {% endfor %}
{% include "partials/featuredNews.html" %} {% include "partials/featuredNews.html" %}

View File

@@ -1,3 +1,14 @@
<!-- Takes the path of a page and checks if it exists
- if exists sets the page
-->
{% macro get_if_exists(path, type="text") %}
{% set pages_str = people.pages | json_encode() | as_str %}
{% if pages_str is containing(person.name) %}
{% set page = get_page(path=page_path) %}
{% endif %}
{{ page }}
{% endmacro get_if_exists %}
{% macro page_list(type="text") %} {% macro page_list(type="text") %}
<div id="list"></div> <div id="list"></div>
{% if section.extra.group_pages_by %} {% if section.extra.group_pages_by %}

View File

@@ -1,8 +1,12 @@
{% if post.date %} {% if post.date %}
{% if post.taxonomies.people %} {% if post.taxonomies.people %}
{% set people = get_section(path="people/_index.md") %}
{% set pages_str = people.pages | json_encode() | as_str %}
{% if pages_str is containing(post.taxonomies.people[0]) %}
{% set author_path = 'people/' ~ post.taxonomies.people[0] ~ '/index.md' %} {% set author_path = 'people/' ~ post.taxonomies.people[0] ~ '/index.md' %}
{% set author = get_page(path=author_path) %} {% set author = get_page(path=author_path) %}
{% endif %} {% endif %}
{% endif %}
<div class="flex flex-col rounded-lg shadow-lg overflow-hidden"> <div class="flex flex-col rounded-lg shadow-lg overflow-hidden">
<div class="flex-1 border-b"> <div class="flex-1 border-b">

View File

@@ -18,10 +18,14 @@
<div class="mt-12 grid gap-5 max-w-lg mx-auto lg:grid-cols-2 xl:grid-cols-4 lg:max-w-none"> <div class="mt-12 grid gap-5 max-w-lg mx-auto lg:grid-cols-2 xl:grid-cols-4 lg:max-w-none">
{% for person in terms %} {% for person in terms %}
{% set page_path = person.path ~ 'index.md' | replace(from='-', to='_') | trim_start_matches(pat="/") %} {% set page_path = person.path ~ 'index.md' | replace(from='-', to='_') | trim_start_matches(pat="/") %}
{% set people = get_section(path="people/_index.md") %}
{% set pages_str = people.pages | json_encode() | as_str %}
{% if pages_str is containing(person.name) %}
{% set page = get_page(path=page_path) %} {% set page = get_page(path=page_path) %}
{% if page.extra.private >= 0 %} {% if page.extra.private >= 0 %}
{% include "partials/person_card.html" %} {% include "partials/person_card.html" %}
{% endif %} {% endif %}
{% endif %}
{% endfor %} {% endfor %}
</div> </div>
<hr class="mt-6" /> <hr class="mt-6" />

View File

@@ -2,8 +2,12 @@
{% block content %} {% block content %}
{% set page_path = term.path ~ 'index.md' | replace(from='-', to='_') | trim_start_matches(pat="/") %} {% set page_path = term.path ~ 'index.md' | replace(from='-', to='_') | trim_start_matches(pat="/") %}
{% set people = get_section(path="people/_index.md") %}
{% set pages_str = people.pages | json_encode() | as_str %}
{% if pages_str is containing(term.name) %}
{% set page = get_page(path=page_path) %} {% set page = get_page(path=page_path) %}
<div class="container sm:pxi-0 lg:w-5/6 mx-auto min-h-screen overflow-x-hidden pt-24"> <div class="container sm:pxi-0 lg:w-5/6 mx-auto min-h-screen overflow-x-hidden pt-24">
<div class="flex flex-row flex-wrap items-start mx-4 sm:mx-0"> <div class="flex flex-row flex-wrap items-start mx-4 sm:mx-0">
<div class="w-full md:w-1/6 mx-auto sm:mx-0"> <div class="w-full md:w-1/6 mx-auto sm:mx-0">
@@ -47,5 +51,6 @@
<hr/> <hr/>
</div> </div>
</div> </div>
{% endif %}
{% endblock content %} {% endblock content %}