Skip to content

Commit

Permalink
set up cleaner urls
Browse files Browse the repository at this point in the history
maybe add shorter url paths somehow
  • Loading branch information
404salad committed Sep 19, 2024
1 parent 9db19d3 commit 42199ec
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 19 deletions.
2 changes: 1 addition & 1 deletion dist/articles/Cronjobs.html → dist/articles/Cronjobs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<title>Cronjobs</title>
</head>
<body class="container">
<a href='../index.html'>home</a>
<a href='../home'>home</a>
<h1> Cronjobs </h1>
<hr>
<blockquote>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<title>Debugging C++ Programs with GDB</title>
</head>
<body class="container">
<a href='../index.html'>home</a>
<a href='../home'>home</a>
<h1> Debugging C++ Programs with GDB </h1>
<hr>
<p>If you don’t use GDB but program in C/C++, you are missing out on a powerful debugging tool. Here’s a quick 5-minute tutorial to get you started.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<title>Every Programmer Should Watch Conference Talks on YouTube</title>
</head>
<body class="container">
<a href='../index.html'>home</a>
<a href='../home'>home</a>
<h1> Every Programmer Should Watch Conference Talks on YouTube </h1>
<hr>
<p>I was going to write a longer article to convince everyone to watch the conferences but Its much better to give a summary of my favorite talks and hopefully that will be persuasive enough~</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<title>Makefiles:)</title>
</head>
<body class="container">
<a href='../index.html'>home</a>
<a href='../home'>home</a>
<h1> Makefiles:) </h1>
<hr>
<h2>Quick and Easy Makefile Guide</h2>
Expand Down
2 changes: 1 addition & 1 deletion dist/articles/On Logging.html → dist/articles/On Logging
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<title>On Logging</title>
</head>
<body class="container">
<a href='../index.html'>home</a>
<a href='../home'>home</a>
<h1> On Logging </h1>
<hr>
<blockquote>
Expand Down
2 changes: 1 addition & 1 deletion dist/articles/image.html → dist/articles/image

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions dist/home
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>404salad
</title>
<link rel="stylesheet" href="style.css">
<script>
function filterArticles() {
var input, filter, articleList, articles, article, title, i, titleText;
input = document.getElementById('search');
filter = input.value.toUpperCase();
articleList = document.getElementById('articleList');
articles = articleList.getElementsByTagName('article');

// Loop through all articles, and hide those whose titles don't match the search query
for (i = 0; i < articles.length; i++) {
article = articles[i];
title = article.getElementsByTagName('a')[0];
titleText = title.textContent || title.innerText;
if (titleText.toUpperCase().indexOf(filter) > -1) {
article.style.display = '';
} else {
article.style.display = 'none';
}
}
}
</script>
</head>
<body class="container">
<br>
<h1>404salad
</h1>
<h6>sahil
</h6>
<input type="search" id="search" name="search" placeholder="Type to search..." onkeyup="filterArticles()">
<br>
<br>
<section id="articleList"><article>
<a href="articles/image"> image </a>
</article><article>
<a href="articles/Cronjobs"> Cronjobs </a>
</article><article>
<a href="articles/Makefiles:)"> Makefiles:) </a>
</article><article>
<a href="articles/Every Programmer Should Watch Conference Talks on YouTube"> Every Programmer Should Watch Conference Talks on YouTube </a>
</article><article>
<a href="articles/On Logging"> On Logging </a>
</article><article>
<a href="articles/Debugging C++ Programs with GDB"> Debugging C++ Programs with GDB </a>
</article>
</section>
</body>
</html>
12 changes: 6 additions & 6 deletions dist/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@ <h6>sahil
<br>
<br>
<section id="articleList"><article>
<a href="articles/image.html"> image </a>
<a href="articles/image"> image </a>
</article><article>
<a href="articles/Cronjobs.html"> Cronjobs </a>
<a href="articles/Cronjobs"> Cronjobs </a>
</article><article>
<a href="articles/Makefiles:).html"> Makefiles:) </a>
<a href="articles/Makefiles:)"> Makefiles:) </a>
</article><article>
<a href="articles/Every Programmer Should Watch Conference Talks on YouTube.html"> Every Programmer Should Watch Conference Talks on YouTube </a>
<a href="articles/Every Programmer Should Watch Conference Talks on YouTube"> Every Programmer Should Watch Conference Talks on YouTube </a>
</article><article>
<a href="articles/On Logging.html"> On Logging </a>
<a href="articles/On Logging"> On Logging </a>
</article><article>
<a href="articles/Debugging C++ Programs with GDB.html"> Debugging C++ Programs with GDB </a>
<a href="articles/Debugging C++ Programs with GDB"> Debugging C++ Programs with GDB </a>
</article>
</section>
</body>
Expand Down
4 changes: 2 additions & 2 deletions src/consolidate_into_homepage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub fn read_directory_content() -> Vec<String> {

pub fn create_homepage(user_config: &config::UserConfig) -> std::io::Result<()> {
let article_names = read_directory_content();
let output_path = String::from("dist/index.html");
let output_path = String::from("dist/home");

let mut document = String::new();
document.push_str(&format!(
Expand Down Expand Up @@ -85,7 +85,7 @@ pub fn create_homepage(user_config: &config::UserConfig) -> std::io::Result<()>
for article_name in article_names {
document.push_str(&format!(
"<article>
<a href=\"articles/{article_name}.html\"> {article_name} </a>
<a href=\"articles/{article_name}\"> {article_name} </a>
</article>",
article_name = article_name
));
Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn main() {

match consolidate_into_homepage::create_homepage(&user_config) {
Ok(_) => {
println!("added all blogs to homepage, view in dist/index.html")
println!("added all blogs to homepage, view in dist/home")
}
Err(e) => {
eprintln!("unsuccesful in creating homepage {}", e)
Expand Down
8 changes: 4 additions & 4 deletions src/parse_one_article.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn wrap_html(markdown_output: &str, article: &str, _user_config: &config::UserCo
<title>{article}</title>
</head>
<body class=\"container\">
<a href='../index.html'>home</a>
<a href='../home'>home</a>
<h1> {article} </h1>
<hr>
"
Expand All @@ -48,16 +48,16 @@ fn wrap_html(markdown_output: &str, article: &str, _user_config: &config::UserCo
wrapped_html
}

/// convert a single .md file to html
// convert a single .md file to html
pub fn markdown_to_styled_html(
article: &str,
user_config: &config::UserConfig,
) -> std::io::Result<()> {
println!("parsing - {article}");
let mut input_path = String::from("content/") + &article.to_owned();
let mut output_path = String::from("dist/articles/") + &article.to_owned();
let output_path = String::from("dist/articles/") + &article.to_owned();
input_path.push_str(".md");
output_path.push_str(".html");
//output_path.push_str(".html");
let html_from_md = parse_markdown(&read_markdown(input_path)?);
let mut file = File::create(output_path)?;
let wrapped_html = wrap_html(&html_from_md, article, user_config);
Expand Down

0 comments on commit 42199ec

Please sign in to comment.