Skip to content

Commit de99034

Browse files
Add 404.html
1 parent b83f98c commit de99034

File tree

4 files changed

+30
-32
lines changed

4 files changed

+30
-32
lines changed

web/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44

55
The source code in this directory [(/web)](/web) is licensed under the GPLv3 license. See the [LICENSE](./LICENSE) file for more details.
66

7+
## Deployment
8+
9+
This static site is served with CloudFlare pages (this is not managed on this repository).
10+
11+
CloudFlare Pages handles custom error pages. For example, it serves `404.html`, when a page is not found.
12+
713
## Development
814

915
### Prerequisites

web/resources/404.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<h1>Page not found</h1>
2+
3+
<p>Error 404: The page you are looking for does not exist.</p>

web/resources/layout.html

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -96,37 +96,5 @@
9696
<p><i class="fab fa-github"></i> <a href="https://github.com/multitheftauto/mtasa-wiki" rel="noopener" target="_blank">Wiki on GitHub</a></p>
9797
</div>
9898
</footer>
99-
100-
<script>
101-
function dropdownFunc(btn) {
102-
var dropdown = btn.nextElementSibling;
103-
// Close other dropdowns
104-
var dropdowns = document.getElementsByClassName("dropdown-content");
105-
for (var d = 0; d < dropdowns.length; d++) {
106-
var openDropdown = dropdowns[d];
107-
if (openDropdown !== dropdown && openDropdown.classList.contains('show')) {
108-
openDropdown.classList.remove('show');
109-
}
110-
}
111-
// Toggle current dropdown
112-
if (dropdown.classList.contains('show')) {
113-
dropdown.classList.remove('show');
114-
} else {
115-
dropdown.classList.add('show');
116-
}
117-
}
118-
119-
window.onclick = function(e) {
120-
if (!e.target.matches('.dropbtn')) {
121-
var dropdowns = document.getElementsByClassName("dropdown-content");
122-
for (var d = 0; d < dropdowns.length; d++) {
123-
var openDropdown = dropdowns[d];
124-
if (openDropdown.classList.contains('show')) {
125-
openDropdown.classList.remove('show');
126-
}
127-
}
128-
}
129-
}
130-
</script>
13199
</body>
132100
</html>

web/scripts/builder.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,25 @@ def create_category(self, web_path, category_data):
316316
html_file.write(html_content)
317317

318318
self.logger.info(f"Generated {output_path} for category {category_name}")
319+
320+
def create_misc_pages(self):
321+
322+
other_pages = [
323+
{
324+
'path_html': '404.html',
325+
'template': '404.html',
326+
},
327+
]
328+
329+
for page in other_pages:
330+
template = self.input_env.get_template(page['template'])
331+
html_content = self.render_page(page['path_html'], template.render())
332+
333+
output_path = os.path.join(OUTPUT_HTML_PATH, page['path_html'])
334+
with open(output_path, 'w') as html_file:
335+
html_file.write(html_content)
336+
337+
self.logger.info(f"Generated {output_path} for {page['path_html']}")
319338

320339
def create_pages(self):
321340
self.navigation = [
@@ -422,6 +441,8 @@ def create_item(item):
422441
create_item(subitem)
423442
else:
424443
create_item(item)
444+
445+
self.create_misc_pages()
425446

426447

427448
def copy_assets(self):

0 commit comments

Comments
 (0)