Skip to content

Commit

Permalink
move to more centralized faq
Browse files Browse the repository at this point in the history
  • Loading branch information
Colack authored and Colack committed Jan 6, 2025
1 parent 68c2929 commit 0e112e1
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 120 deletions.
2 changes: 1 addition & 1 deletion Assets/scripts/footer.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ footer.innerHTML = `
<div class="footer-info">
<p>Email: <a href="mailto:[email protected]">[email protected]</a></p>
<p>&copy; 2024 - 2025 WatermelonKatana. All rights reserved.</p>
<p>Stay updated with our <a href="/news">latest news</a>!</p>
<p>Stay updated with our <a href="/faq">FAQ</a>!</p>
</div>
`;
footer.onclick = function() {
Expand Down
89 changes: 89 additions & 0 deletions Pages/faq/faq.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<!-- This is basically a mirror of updates.html, but with better logic -->

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>FAQ | WatermelonKatana</title>
<link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png">
<link rel="manifest" href="/site.webmanifest">
<meta property="og:title" content="FAQ | WatermelonKatana"/>
<meta property="og:type" content="profile"/>
<meta property="og:description" content="The WatermelonKatana FAQ"/>
<link rel="stylesheet" type="text/css" href="/styles/style.css">
<script src="/scripts/script.js"></script>
</head>
<body>
<script src="/scripts/navbar.js"></script>

<div id="content" style="width: 90%">Loading...</div>

<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="/scripts/md-render.js"></script>
<script>
// Define update page mappings
const updatePages = {
"watermelonkatana_overview": "WatermelonKatana/refs/heads/main/README.md",
"website_announcements": "discussions/refs/heads/main/announcements/current_announcement.md",
"terms_of_service": "WatermelonKatana/refs/heads/main/Assets/md/tos.md",
"posting_guidelines": "WatermelonKatana/refs/heads/main/Assets/md/posting_guidelines.md",
"turbowarp_guide": "TurboWarp/refs/heads/main/README.md"
};

/**
* Fetch and render Markdown content
* @param {string} url - URL of the Markdown file
*/
function fetchMarkdown(url) {
fetch(url)
.then(response => {
if (!response.ok) {
throw new Error(`Failed to fetch content from ${url}`);
}
return response.text();
})
.then(markdown => {
document.querySelector("#content").innerHTML = marked.parse(markdown);
})
.catch(error => {
document.querySelector("#content").innerHTML = `<p style="color:red;">Error loading content: ${error.message}</p>`;
});
}

/**
* Load bookmarks list
*/
function loadBookmarks() {
const bookmarks = `
<div id="bookmarks" style="text-align: center">
<h1>FAQ</h1>
<br>
${Object.keys(updatePages)
.map(page =>
`<h2><a href="/faq?page=${page}">${page.replace(/_/g, " ").replace(/\b\w/g, e => e.toUpperCase())}</a></h2>`
)
.join("")}
</div>`;
document.querySelector("#content").innerHTML = bookmarks;
}

// Main logic for page loading
window.onload = function() {
const page = new URLSearchParams(location.search).get("page") || "";
const fileUrl = updatePages[page];

if (fileUrl) {
// Fetch the Markdown content if the page exists in updatePages
const fullUrl = `https://raw.githubusercontent.com/WatermelonKatanaDevs/${fileUrl}`;
fetchMarkdown(fullUrl);
} else {
// Load the bookmarks list if no valid page is specified
loadBookmarks();
}
};
</script>
</body>
</html>
30 changes: 0 additions & 30 deletions Pages/faq/posting_guidelines.html

This file was deleted.

30 changes: 0 additions & 30 deletions Pages/faq/tos.html

This file was deleted.

2 changes: 1 addition & 1 deletion Pages/forum/publish.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<h1>Post Discussion</h1>
<span style="text-align: center"> Please make sure your post follows our
<a href="/updates?page=posting_guidelines"> guidelines </a>
<a href="/faq?page=posting_guidelines"> guidelines </a>
</span>

<form>
Expand Down
4 changes: 2 additions & 2 deletions Pages/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <h2 id="username" style="color: #777777"></h2>
<a href="/chat">Chat</a>
<a href="/search">Project Gallery</a>
<a href="/forum">Forum</a>
<a href="/updates?page=website_announcements">Announcements</a>
<a href="/faq">FAQ</a>
<a href="https://www.patreon.com/watermelonkatana"> Donate </a>
</nav>
</header>
Expand Down Expand Up @@ -103,7 +103,7 @@ <h2>Hot Forum Topics</h2>
<a href="/chat">Chat</a>
<a href="/search">Project Gallery</a>
<a href="/forum">Forum</a>
<a href="/updates?page=website_announcements">Announcements</a>
<a href="/faq">FAQ</a>
<a href="/userlist">User List</a>
${(data.user.role === "Admin" ? `<a href="/admin">Admin List</a>`: "")}
<a href="https://www.patreon.com/watermelonkatana"> Donate </a>
Expand Down
4 changes: 2 additions & 2 deletions Pages/projects/publish.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@

<h1>Publish Project</h1>
<span style="text-align: center"> Please make sure your project follows our
<a href="/updates?page=posting_guidelines"> guidelines </a>
<a href="/faq?page=posting_guidelines"> guidelines </a>
<br>
Publishing a code.org project? Feel free to read this
<a href="/updates?page=turbowarp_guide"> guide </a>
<a href="/faq?page=turbowarp_guide"> guide </a>
if unsure where to start.
</span>

Expand Down
2 changes: 1 addition & 1 deletion Pages/sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<priority>0.2</priority>
</url>
<url>
<loc>https://watermelonkatana.com/updates/</loc>
<loc>https://watermelonkatana.com/faq/</loc>
<changefreq>weekly</changefreq>
<priority>0.2</priority>
</url>
Expand Down
48 changes: 0 additions & 48 deletions Pages/updates.html

This file was deleted.

6 changes: 1 addition & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ app.get("/lib/meloncanvas.js", (req, res) => res.sendFile(__dirname + "/lib/melo
/**
* WatermelonKatana FAQ pages
*/
app.get("/tos", (req, res) => res.sendFile(cldir + "/faq/tos.html")); // Terms of Service
app.get("/posting_guidelines", (req, res) => res.sendFile(cldir + "/faq/posting_guidelines.html")); // Posting Guidelines
app.get("/faq", (req, res) => res.sendFile(cldir + "/faq/faq.html")); // Faq

// Logout route: clear the JWT cookie and redirect to home
app.get("/logout", (req, res) => {
Expand Down Expand Up @@ -140,9 +139,6 @@ app.get("/project/:id/delete", userAuth, (req, res) => res.redirect("/api/projec
// Authors
app.get("/authors", (req, res) => { res.sendFile(cldir + "/authors.html") });

// Updates
app.get("/updates", (req, res) => res.sendFile(cldir + "/updates.html"));

// Posts
app.get("/forum", (req, res) => res.sendFile(cldir + "/forum/home.html")); // Forum Home/Search
app.get("/forum/post", userAuth, (req, res) => res.sendFile(cldir + "/forum/publish.html")); // Publish page, users only
Expand Down

0 comments on commit 0e112e1

Please sign in to comment.