Skip to content

Commit

Permalink
Merge pull request #1 from husni-zuhdi/finalize-blog-format
Browse files Browse the repository at this point in the history
Finalize blog format
  • Loading branch information
husni-zuhdi authored Jul 6, 2024
2 parents 321cc53 + d4adcc9 commit fe0dcd7
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 60 deletions.
15 changes: 10 additions & 5 deletions internal/src/model/data.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::utils::md_to_html;
use crate::utils::{capitalize, md_to_html};
use log::{debug, info};
use serde::Deserialize;
use std::fs;
Expand Down Expand Up @@ -55,9 +55,14 @@ impl BlogsData {
let blogs: Vec<BlogData> = blogs_paths
.iter()
.map(|blog_path| {
let (id, name) = blog_path
let (id, name_init) = blog_path
.split_once("-")
.expect("Failed to split filename into id and name");
let name_formated = name_init.replace("_", " ");
let (name_lower, _) = name_formated
.split_once(".")
.expect("Failed to remove file extension");
let name = capitalize(name_lower);
let fullpath = format!("{}{}", directory, blog_path);

info!("markdown loaded: {}", fullpath);
Expand Down Expand Up @@ -89,11 +94,11 @@ mod test {
fn test_blogs_data_from_dir() {
// Preparation
let test_id = "999";
let test_name = "test-blog.md";
let test_name = "Test blog";
let test_body = "# Testing Blog for Unit Test";
let test_body_html = "<h1>Testing Blog for Unit Test</h1>";
let test_filename = "999-test-blog.md";
let test_path = "../statics/blogs/999-test-blog.md";
let test_filename = "999-test_blog.md";
let test_path = "../statics/blogs/999-test_blog.md";

// Get current directory
debug!(
Expand Down
3 changes: 2 additions & 1 deletion internal/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use askama::Template;
use log::info;

pub async fn styles() -> Result<NamedFile> {
Ok(NamedFile::open("./statics/styles.css")?)
let styles = NamedFile::open("./statics/styles.css").expect("Failed to render styles.css");
Ok(styles)
}

pub async fn profile() -> Result<impl Responder> {
Expand Down
9 changes: 9 additions & 0 deletions internal/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,12 @@ pub fn read_version_manifest() -> Result<VersionData, String> {
let json: VersionData = serde_json::from_reader(reader).expect("Failed to parse version.json");
Ok(json)
}

/// Capitalizes the first character in s.
pub fn capitalize(s: &str) -> String {
let mut c = s.chars();
match c.next() {
None => String::new(),
Some(f) => f.to_uppercase().collect::<String>() + c.as_str(),
}
}
2 changes: 1 addition & 1 deletion internal/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
LinkedIn
</a>

<a href="https://github.com/Hazunanafaru" target="_blank">
<a href="https://github.com/husni-zuhdi" target="_blank">
GitHub
</a>
<br>
Expand Down
4 changes: 2 additions & 2 deletions internal/templates/blog.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
{% block description %}"Blog {{id}} - {{name}}"{% endblock %}

{% block content %}
<h1>{{id}} - {{name}}</h1>
<h2>{{filename}}</h2>
<h1>{{id}} | {{name}}</h1>
<!-- <h2>{{filename}}</h2> -->
<hr>
<div>
{{body|safe}}
Expand Down
7 changes: 4 additions & 3 deletions internal/templates/blogs.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@

{% block content %}
<h1>Blogs</h1>

<hr>
{% for blog in blogs %}
<h2><a href="/blogs/{{blog.id}}">Blog {{blog.id}}</a></h2>
<p>{{blog.name}}</p>
<h2>
{{blog.id}} | <a href="/blogs/{{blog.id}}">{{blog.name}}</a>
</h2>
{% endfor %}

{% endblock content %}
48 changes: 27 additions & 21 deletions internal/templates/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ <h1>Husni Naufal Zuhdi - Site Reliability Engineer</h1>

<h2>Overview</h2>
<p>Hi! I'm a Site Reliability Engineer by job and Software Engineer by passion. I'm comfortable writing code with python, golang, and rust.</p>
<p>I love exploring several topics such as Cloud Computing, DevOps, Platform Engineering, Nuclear Science, and Physics Computation.</p>

<h2>Work Experiences</h2>
<hr>
Expand Down Expand Up @@ -59,7 +60,10 @@ <h3>Cloud Computing</h3>
<div>
<h3>Kubernetes</h3>
<p class=paragraph>
Manage hundreds of Kubernetes clusters.
Manage hundreds of Kubernetes clusters and create my own cluster.
<ul>
<li><a href="https://www.credly.com/badges/a7ef8fab-b735-4c73-9fe2-39e14e2a458d/public_url" target="_blank">K8S Certified Kubernetes Administrator</a></li>
</ul>
</p>
</div>
<div>
Expand All @@ -76,30 +80,32 @@ <h3>Linux</h3>
</div>
</div>

<h2>Projects</h2>
<hr>
<div class="flex-container">
<div>
<h3>Sapa.AI</h3>
<ul>
<li>Design microservice architecture to serve simple CURD API and inference ML API</li>
<li>Develop CRUD and ML APIs with flask and tensorflow frameworks</li>
<li>Lead team of 6 people to deliver a violence reporting android app</li>
</ul>
</div>
<div>
<h3>Bachelor Thesis</h3>
<ul>
<li>Design a neutronic fusion reactor simulation with Paramak and OpenMC library</li>
<li>Optimize simulation workflow to run in Cloud-Native environment</li>
<li>Enable multi-cloud environments with GCP and AWS cloud providers to increase simulation efficiency</li>
</ul>
</div>
</div>
<!-- <h2>Projects</h2> -->
<!-- <hr> -->
<!---->
<!-- <div class="flex-container"> -->
<!-- <div> -->
<!-- <h3>Sapa.AI</h3> -->
<!-- <ul> -->
<!-- <li>Design microservice architecture to serve simple CURD API and inference ML API</li> -->
<!-- <li>Develop CRUD and ML APIs with flask and tensorflow frameworks</li> -->
<!-- <li>Lead team of 6 people to deliver a violence reporting android app</li> -->
<!-- </ul> -->
<!-- </div> -->
<!-- <div> -->
<!-- <h3>Bachelor Thesis</h3> -->
<!-- <ul> -->
<!-- <li>Design a neutronic fusion reactor simulation with Paramak and OpenMC library</li> -->
<!-- <li>Optimize simulation workflow to run in Cloud-Native environment</li> -->
<!-- <li>Enable multi-cloud environments with GCP and AWS cloud providers to increase simulation efficiency</li> -->
<!-- </ul> -->
<!-- </div> -->
<!-- </div> -->


<h2>Personal Interests</h2>
<hr>

<p class="paragraph">
<i>Running, Hard Sci-fi and Fantasy, Books, Climbing, Staring</i>
</p>
Expand Down
10 changes: 4 additions & 6 deletions internal/templates/version.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
<h1></h1>
{% extends "base.html" %}

{% block title %}Husni Blog v{{version}}{% endblock %}
{% block description %}"Husni Blog v{{version}}"{% endblock %}

{% block content %}
<h1>Husni Blog v{{version}}</h1>
<hr>
<h2>Environment: {{environment}}</h2>
<h2>Githash: {{build_hash}}</h2>
<h2>Build Date: {{build_date}}</h2>
<p>Husni Blog v{{version}}</p>
<p>Environment: {{environment}}</p>
<p>Githash: {{build_hash}}</p>
<p>Build Date: {{build_date}}</p>
{% endblock content %}
19 changes: 0 additions & 19 deletions statics/blogs/my_favourite_books.md

This file was deleted.

4 changes: 2 additions & 2 deletions statics/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
}

.paragraph {
padding-left: 5px;
padding-right: 5px;
padding-left: 0px;
padding-right: 0px;
}

.btn {
Expand Down

0 comments on commit fe0dcd7

Please sign in to comment.