Skip to content

Commit 00c33b4

Browse files
committed
sitewide test
1 parent eaf846b commit 00c33b4

File tree

6 files changed

+158
-98
lines changed

6 files changed

+158
-98
lines changed

404.html

Lines changed: 3 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
---
22
layout: base
3-
permalink: /404.html
43
title: Page Not Found - GitHubTree
54
description: The page you were looking for couldn't be found. It might have been removed, renamed, or didn't exist in the first place.
5+
show_search: false
6+
permalink: /404
67
---
78

89
<div class="error-container">
@@ -23,79 +24,4 @@ <h3>Popular repositories to explore:</h3>
2324
{% endfor %}
2425
</ul>
2526
</div>
26-
</div>
27-
28-
<style>
29-
.error-container {
30-
text-align: center;
31-
padding: 40px 20px;
32-
max-width: 800px;
33-
margin: 0 auto;
34-
}
35-
36-
.error-container h2 {
37-
font-size: 32px;
38-
color: #e74c3c;
39-
margin-bottom: 20px;
40-
}
41-
42-
.error-actions {
43-
margin: 30px 0;
44-
}
45-
46-
.home-link {
47-
display: inline-block;
48-
padding: 10px 20px;
49-
background-color: #024ea2;
50-
color: white;
51-
text-decoration: none;
52-
border-radius: 4px;
53-
transition: background-color 0.3s;
54-
}
55-
56-
.home-link:hover {
57-
background-color: #023e82;
58-
}
59-
60-
.error-suggestions {
61-
margin-top: 40px;
62-
padding: 20px;
63-
background-color: #f5f5f5;
64-
border-radius: 8px;
65-
}
66-
67-
.error-suggestions h3 {
68-
margin-bottom: 15px;
69-
}
70-
71-
.suggestions-list {
72-
list-style: none;
73-
padding: 0;
74-
display: flex;
75-
flex-wrap: wrap;
76-
justify-content: center;
77-
}
78-
79-
.suggestions-list li {
80-
margin: 8px 12px;
81-
}
82-
83-
.suggestions-list a {
84-
color: #024ea2;
85-
text-decoration: none;
86-
}
87-
88-
.suggestions-list a:hover {
89-
text-decoration: underline;
90-
}
91-
92-
@media (max-width: 768px) {
93-
.error-container h2 {
94-
font-size: 24px;
95-
}
96-
97-
.suggestions-list {
98-
flex-direction: column;
99-
}
100-
}
101-
</style>
27+
</div>

_layouts/base.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
---
22
layout: minimal
3-
show_support: true
4-
show_search: true
5-
show_share_overlay: true
63
---
74
<div class="tree-container" id="tree-container" style="display: none;">
85
<div class="tree-header">

_layouts/minimal.html

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,15 +93,15 @@
9393
<div class="container">
9494
{% include header.html %}
9595

96-
{% if layout.show_support != false %}
96+
{% if page.show_support != false %}
9797
<div class="support-block">
9898
<a href="https://github.com/sponsors/mgks" class="support-button">
9999
<span class="fas fa-heart"></span> Support the Project
100100
</a>
101101
</div>
102102
{% endif %}
103103

104-
{% if layout.show_search != false %}
104+
{% if page.show_search != false %}
105105
<div class="search-area">
106106
<div class="input-area">
107107
<input type="text" id="repoInput" placeholder="username/repo" value="{% if page.repo_name %}{{ page.repo_name }}{% else %}mgks/GitHubTree{% endif %}">
@@ -121,7 +121,7 @@
121121
{% include footer.html %}
122122
</div>
123123

124-
{% if layout.show_share_overlay != false %}
124+
{% if page.show_share_overlay != false %}
125125
<div id="shareOverlay" class="share-container-overlay">
126126
<div class="share-content-box">
127127
<input type="text" id="shareUrlInput" readonly title="Shareable URL">
@@ -134,11 +134,6 @@
134134
{% if page.repo_name %}
135135
<script>
136136
document.addEventListener('DOMContentLoaded', function() {
137-
// Don't do anything if we're on a 404 page
138-
if (document.querySelector('.error-container')) {
139-
return;
140-
}
141-
142137
// Redirect legacy parameter URLs to clean URLs
143138
const urlParams = new URLSearchParams(window.location.search);
144139
const repoParam = urlParams.get('repo');
@@ -154,7 +149,10 @@
154149
// Trigger fetch automatically for repo pages
155150
// The static-repo.js script will prevent actual fetching for static pages
156151
setTimeout(function() {
157-
document.getElementById('fetchButton').click();
152+
const fetchButton = document.getElementById('fetchButton');
153+
if (fetchButton) {
154+
fetchButton.click();
155+
}
158156
}, 100);
159157
}
160158
});

assets/css/style.css

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,78 @@ a {
450450
#load-more-btn:hover {
451451
background: #024fa2;
452452
}
453+
.error-container {
454+
text-align: center;
455+
padding: 40px 20px;
456+
max-width: 800px;
457+
margin: 0 auto;
458+
}
459+
460+
.error-container h2 {
461+
font-size: 32px;
462+
color: #e74c3c;
463+
margin-bottom: 20px;
464+
}
465+
466+
.error-actions {
467+
margin: 30px 0;
468+
}
469+
470+
.home-link {
471+
display: inline-block;
472+
padding: 10px 20px;
473+
background-color: #024ea2;
474+
color: white;
475+
text-decoration: none;
476+
border-radius: 4px;
477+
transition: background-color 0.3s;
478+
}
479+
480+
.home-link:hover {
481+
background-color: #023e82;
482+
}
483+
484+
.error-suggestions {
485+
margin-top: 40px;
486+
padding: 20px;
487+
background-color: #f5f5f5;
488+
border-radius: 8px;
489+
}
490+
491+
.error-suggestions h3 {
492+
margin-bottom: 15px;
493+
}
494+
495+
.suggestions-list {
496+
list-style: none;
497+
padding: 0;
498+
display: flex;
499+
flex-wrap: wrap;
500+
justify-content: center;
501+
}
502+
503+
.suggestions-list li {
504+
margin: 8px 12px;
505+
}
506+
507+
.suggestions-list a {
508+
color: #024ea2;
509+
text-decoration: none;
510+
}
511+
512+
.suggestions-list a:hover {
513+
text-decoration: underline;
514+
}
515+
516+
@media (max-width: 768px) {
517+
.error-container h2 {
518+
font-size: 24px;
519+
}
520+
521+
.suggestions-list {
522+
flex-direction: column;
523+
}
524+
}
453525
.footer {
454526
text-align: center;
455527
padding: .5em 1em;

assets/js/script.js

Lines changed: 73 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,6 @@ window.addEventListener('popstate', parseURL);
181181
// --- Core Logic ---
182182

183183
function parseURL() {
184-
// Skip URL parsing if we're on the 404 page
185-
if (document.querySelector('.error-container')) {
186-
return;
187-
}
188-
189184
// Skip URL parsing for specific pages we want to preserve
190185
const specialPages = ['/featured-repos', '/featured-repos.html'];
191186
if (specialPages.includes(window.location.pathname)) {
@@ -240,9 +235,19 @@ function parseURL() {
240235
fetchRepoTree(); // This will handle metadata update after fetch
241236
}
242237
}
238+
} else if (window.location.pathname.match(/\/repo\/.*$/)) {
239+
// Handle invalid repo URL format but keep user on the current page
240+
// This is for URLs like /repo/something-invalid/
241+
if (errorContainer) {
242+
showError("Invalid repository URL format. Please use the format: /repo/username/repository/branch/");
243+
// Ensure tree is cleared
244+
clearTree();
245+
// Clear URL but stay on current page
246+
history.replaceState({}, document.title, "/");
247+
}
243248
} else {
244249
// Only reset to homepage if we're actually on the homepage
245-
// This prevents overriding metadata for other pages like /repo-pages/
250+
// This prevents overriding metadata for other pages
246251
if (window.location.pathname === '/' || window.location.pathname === '/index.html') {
247252
updateMetaData(
248253
'GitHub repo explorer: visualize and navigate github project structures', // Default Title
@@ -792,8 +797,68 @@ function showError(message, append = false) {
792797
appendMsg.style.marginTop = '0.5em';
793798
errorContainer.appendChild(appendMsg);
794799
} else {
795-
// Replace existing error content
796-
errorContainer.innerHTML = message; // Use innerHTML to allow basic formatting like <i>
800+
// Replace existing error content with enhanced error display
801+
let errorHTML = `<div class="error-message"><i class="fas fa-exclamation-circle"></i> ${message}</div>`;
802+
803+
// Add suggestions for common repository errors
804+
if (message.includes("not found") || message.includes("404")) {
805+
// Get example repositories from the featured repos if available or use fallbacks
806+
let repoSuggestions = '';
807+
// Try to get first 3 repositories from the featured-repos page if loaded
808+
const repoEntries = document.querySelectorAll('.repo-entry');
809+
if (repoEntries && repoEntries.length > 0) {
810+
const suggestions = [];
811+
for (let i = 0; i < Math.min(repoEntries.length, 3); i++) {
812+
const entry = repoEntries[i];
813+
const repoName = entry.getAttribute('data-repo');
814+
const branch = entry.querySelector('small') ?
815+
entry.querySelector('small').textContent.replace(/[()]/g, '') : 'main';
816+
if (repoName) {
817+
suggestions.push(`<a href="/repo/${repoName}/${branch}/">${repoName}</a>`);
818+
}
819+
if (suggestions.length >= 3) break;
820+
}
821+
repoSuggestions = suggestions.join('');
822+
}
823+
824+
// If no repo entries found, use hardcoded examples
825+
if (!repoSuggestions) {
826+
repoSuggestions = `
827+
<a href="/repo/mgks/GitHubTree/main/">mgks/GitHubTree</a>
828+
<a href="/repo/facebook/react/main/">facebook/react</a>
829+
<a href="/repo/tensorflow/tensorflow/main/">tensorflow/tensorflow</a>
830+
`;
831+
}
832+
833+
errorHTML += `
834+
<div class="error-suggestions">
835+
<h3>Suggestions:</h3>
836+
<ul>
837+
<li>Check that the repository exists and is public</li>
838+
<li>Verify the repository name and username are spelled correctly</li>
839+
<li>Try exploring one of these popular repositories instead:</li>
840+
</ul>
841+
<div class="suggestion-examples">
842+
${repoSuggestions}
843+
</div>
844+
</div>
845+
`;
846+
} else if (message.includes("branch")) {
847+
errorHTML += `
848+
<div class="error-suggestions">
849+
<h3>Suggestions:</h3>
850+
<ul>
851+
<li>Check that the branch exists in the repository</li>
852+
<li>Try using the default branch (usually 'main' or 'master')</li>
853+
<li>Verify the branch name is spelled correctly</li>
854+
</ul>
855+
</div>
856+
`;
857+
} else if (message.includes("rate limit")) {
858+
// Rate limit error suggestions already handled by handleRateLimit function
859+
}
860+
861+
errorContainer.innerHTML = errorHTML; // Use innerHTML to allow basic formatting
797862
}
798863
errorContainer.style.display = 'block';
799864
}

featured-repos.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
---
22
layout: base
3-
show_search: false
43
title: "GitHubTree featured repositories list: visualize and navigate github project structures"
54
description: "Explore the most explored GitHub repositories with GitHubTree. Browse code structures, visualize directories, and navigate GitHub projects without cloning."
65
keywords: "GitHub repositories, popular GitHub projects, code structure explorer, GitHub navigator, trending repositories, open source projects, GitHub directory viewer"
76
canonical_path: "/featured-repos"
7+
show_support: true
8+
show_search: false
9+
show_share_overlay: true
810
sitemap: true
911
last_modified_at: 2023-08-21T12:00:00+00:00
1012
permalink: /featured-repos

0 commit comments

Comments
 (0)