Skip to content

Commit

Permalink
Minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ezhil56x committed Nov 9, 2023
1 parent ea20060 commit 9ff3b16
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 95 deletions.
138 changes: 46 additions & 92 deletions website/_includes/related-posts.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,98 +10,52 @@
{% assign TAG_SCORE = 1 %}

<!-- Equals to TAG_SCORE / {max_categories_hierarchy} -->
{% assign CATEGORY_SCORE = 0.5 %}

{% assign SEPARATOR = ':' %}

{% assign score_list = '' | split: '' %}
{% assign last_index = site.posts.size | minus: 1 %}

{% for i in (0..last_index) %}
{% assign post = site.posts[i] %}

{% if post.url == page.url %}
{% continue %}
{% endif %}

{% assign score = 0 %}

{% for tag in post.tags %}
{% if page.tags contains tag %}
{% assign score = score | plus: TAG_SCORE %}
{% endif %}
{% endfor %}

{% for category in post.categories %}
{% if page.categories contains category %}
{% assign score = score | plus: CATEGORY_SCORE %}
{% endif %}
{% endfor %}

{% if score > 0 %}
{% capture score_item %}{{ score }}{{ SEPARATOR }}{{ i }}{% endcapture %}
{% assign score_list = score_list | push: score_item %}
{% endif %}
{% endfor %}

{% assign index_list = '' | split: '' %}

{% if score_list.size > 0 %}
{% assign score_list = score_list | sort | reverse %}
{% for entry in score_list limit: TOTAL_SIZE %}
{% assign index = entry | split: SEPARATOR | last %}
{% assign index_list = index_list | push: index %}
{% endfor %}
{% endif %}
{% assign CATEGORY_SCORE = 0.5 %} {% assign SEPARATOR = ':' %} {% assign
score_list = '' | split: '' %} {% assign last_index = site.posts.size | minus: 1
%} {% for i in (0..last_index) %} {% assign post = site.posts[i] %} {% if
post.url == page.url %} {% continue %} {% endif %} {% assign score = 0 %} {% for
tag in post.tags %} {% if page.tags contains tag %} {% assign score = score |
plus: TAG_SCORE %} {% endif %} {% endfor %} {% for category in post.categories
%} {% if page.categories contains category %} {% assign score = score | plus:
CATEGORY_SCORE %} {% endif %} {% endfor %} {% if score > 0 %} {% capture
score_item %}{{ score }}{{ SEPARATOR }}{{ i }}{% endcapture %} {% assign
score_list = score_list | push: score_item %} {% endif %} {% endfor %} {% assign
index_list = '' | split: '' %} {% if score_list.size > 0 %} {% assign score_list
= score_list | sort | reverse %} {% for entry in score_list limit: TOTAL_SIZE %}
{% assign index = entry | split: SEPARATOR | last %} {% assign index_list =
index_list | push: index %} {% endfor %} {% endif %}

<!-- Fill with the other newlest posts -->
{% assign less = TOTAL_SIZE | minus: index_list.size %}

{% if less > 0 %}
{% for i in (0..last_index) %}
{% assign post = site.posts[i] %}
{% if post.url != page.url %}
{% capture cur_index %}{{ i }}{% endcapture %}
{% unless index_list contains cur_index %}
{% assign index_list = index_list | push: cur_index %}
{% assign less = less | minus: 1 %}
{% if less <= 0 %}
{% break %}
{% endif %}
{% endunless %}
{% endif %}
{% endfor %}
{% endif %}

{% if index_list.size > 0 %}
<div id="related-posts" class="mb-2 mb-sm-4">
<h3
class="pt-2 mb-4 ml-1"
data-toc-skip
>
{{ site.data.locales[include.lang].post.relate_posts }}
</h3>
<div class="card-deck mb-4">
{% for entry in index_list %}
{% assign index = entry | plus: 0 %}
{% assign post = site.posts[index] %}
<div class="card">
<a href="{{ post.url | relative_url }}">
<div class="card-body">
{% include datetime.html date=post.date class="small" %}
<h3 class="pt-0 mt-1 mb-3" data-toc-skip>{{ post.title }}</h3>
<div class="text-muted small">
<p>
{% include no-linenos.html content=post.content %}
{{ content | markdownify | strip_html | truncate: 200 | escape }}
</p>
</div>
</div>
</a>
</div>
{% endfor %}
</div>
<!-- .card-deck -->
</div>
<!-- #related-posts -->
{% assign less = TOTAL_SIZE | minus: index_list.size %} {% if less > 0 %} {% for
i in (0..last_index) %} {% assign post = site.posts[i] %} {% if post.url !=
page.url %} {% capture cur_index %}{{ i }}{% endcapture %} {% unless index_list
contains cur_index %} {% assign index_list = index_list | push: cur_index %} {%
assign less = less | minus: 1 %} {% if less <= 0 %} {% break %} {% endif %} {%
endunless %} {% endif %} {% endfor %} {% endif %} {% if index_list.size > 0 %}
<div id="related-posts" class="mb-2 mb-sm-4">
<h3 class="pt-2 mb-4 ml-1" data-toc-skip>
{{ site.data.locales[include.lang].post.relate_posts }}
</h3>
<div class="card-deck mb-4">
{% for entry in index_list %} {% assign index = entry | plus: 0 %} {% assign
post = site.posts[index] %}
<div class="card">
<a href="{{ post.url | relative_url }}">
<div class="card-body">
{% include datetime.html date=post.date class="small" %}
<h3 class="pt-0 mt-1 mb-3" data-toc-skip>{{ post.title }}</h3>
<div class="text-muted small">
<p>
{% include no-linenos.html content=post.content %} {{ content |
markdownify | strip_html | truncate: 200 | escape }}
</p>
</div>
</div>
</a>
</div>
{% endfor %}
</div>
<!-- .card-deck -->
</div>
<!-- #related-posts -->
{% endif %}
4 changes: 2 additions & 2 deletions website/_layouts/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
<div class="row no-gutters">
<div class="col-sm-2 d-flex justify-content-center">
<img
class="card-img ml-3"
class="card-img"
style="object-fit: contain"
src="{% link assets/img/{{post.cover | default: 'cyscom-logo.png'}} %}"
alt="Event Logo"
/>
</div>
<div class="col-sm-9 ml-1">
<div class="col-sm-9">
<div class="card-body">
<h1 class="card-title">{{ post.title }}</h1>

Expand Down
2 changes: 1 addition & 1 deletion website/writeups/Zypher_2023/level-11-zypher-re.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ flag: zyp{S4NI5Y_17T6CT_}

## Challenge

You are given a [ZypherRE.py](writeupfiles/level11/ZypherRE.py) file
You are given a [Zypher_RE.py](writeupfiles/level11/Zypher_RE.py) file

## Solution

Expand Down

0 comments on commit 9ff3b16

Please sign in to comment.