Skip to content

Commit c38fb4f

Browse files
committed
sitewide update
1 parent a438d97 commit c38fb4f

File tree

6 files changed

+91
-53
lines changed

6 files changed

+91
-53
lines changed

404.html

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,24 +76,8 @@
7676
}
7777
</style>
7878
<script>
79-
// First check if this is a repository path
80-
function isRepoPath() {
81-
return window.location.pathname.match(/^\/repo\/.+/);
82-
}
83-
84-
// If this is a repository path, check format and handle accordingly
85-
if (isRepoPath()) {
86-
const path = window.location.pathname;
87-
const pathMatch = path.match(/\/repo\/([^\/]+)\/([^\/]+)\/([^\/]+)\/?$/);
88-
89-
if (pathMatch) {
90-
// Valid repository path format - direct navigate to maintain clean URL
91-
window.location.href = path;
92-
} else {
93-
// Invalid repository path format - redirect to home page
94-
window.location.replace('/');
95-
}
96-
}
79+
// We no longer need special handling for repository paths
80+
// The Jekyll plugin handles all /repo/* paths directly
9781
</script>
9882
</head>
9983
<body>

_config.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,6 @@ defaults:
3434
path: ""
3535
values:
3636
image: /assets/images/preview.png
37-
- scope:
38-
path: "/repo/*"
39-
values:
40-
sitemap: true
41-
layout: repository
42-
- scope:
43-
path: "/repo/**/*"
44-
values:
45-
sitemap: true
46-
layout: repository
4737
- scope:
4838
path: "assets/css"
4939
values:

_layouts/minimal.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,16 @@
8888
});
8989
}
9090
</script>
91+
92+
<script>
93+
// Handle repository path parameter from 404 redirects
94+
document.addEventListener('DOMContentLoaded', function() {
95+
// Code for repository path parameter
96+
});
97+
</script>
9198
</head>
9299
<body>
93-
<div class="container">
100+
<div class="wrapper">
94101
{% include header.html %}
95102

96103
{% if page.show_support != false %}

_layouts/repository.html

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,35 @@
11
---
22
layout: base
3-
---
3+
---
4+
<script>
5+
document.addEventListener('DOMContentLoaded', function() {
6+
// Extract repository information from URL path
7+
const path = window.location.pathname;
8+
const pathMatch = path.match(/\/repo\/([^\/]+)\/([^\/]+)\/([^\/]+)\/?$/);
9+
10+
if (pathMatch) {
11+
const [, user, repo, branch] = pathMatch;
12+
const fullRepo = `${user}/${repo}`;
13+
14+
// Set input values
15+
const repoInput = document.getElementById('repoInput');
16+
const branchInput = document.getElementById('branchInput');
17+
18+
if (repoInput && branchInput) {
19+
repoInput.value = fullRepo;
20+
branchInput.value = branch;
21+
22+
// Trigger fetch automatically
23+
setTimeout(function() {
24+
const fetchButton = document.getElementById('fetchButton');
25+
if (fetchButton) {
26+
fetchButton.click();
27+
}
28+
}, 100);
29+
}
30+
}
31+
// If URL doesn't match the exact pattern, we don't try to process it
32+
// This could be a partial path like /repo/user/ which we just show as is
33+
});
34+
</script>
35+
{{ content }}

_plugins/repo_path_handler.rb

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
module Jekyll
2+
class RepoPathHandler < Jekyll::Generator
3+
safe true
4+
priority :high
5+
6+
def generate(site)
7+
# Create a catch-all page for repository paths
8+
repo_index = RepoPathPage.new(site, site.source, '', 'repo/index.html')
9+
site.pages << repo_index
10+
11+
# Create a catch-all page for each level of repository paths
12+
# This handles /repo/:user/
13+
user_index = RepoPathPage.new(site, site.source, 'repo', ':user/index.html')
14+
site.pages << user_index
15+
16+
# This handles /repo/:user/:repo/
17+
repo_name_index = RepoPathPage.new(site, site.source, 'repo/:user', ':repo/index.html')
18+
site.pages << repo_name_index
19+
20+
# This handles /repo/:user/:repo/:branch/
21+
branch_index = RepoPathPage.new(site, site.source, 'repo/:user/:repo', ':branch/index.html')
22+
site.pages << branch_index
23+
24+
# Log info about the plugin
25+
Jekyll.logger.info "RepoPathHandler:", "Created dynamic handlers for /repo/* paths"
26+
end
27+
end
28+
29+
# Custom page class that will capture all repository paths
30+
class RepoPathPage < Jekyll::Page
31+
def initialize(site, base, dir, name)
32+
@site = site
33+
@base = base
34+
@dir = dir
35+
@name = name
36+
37+
self.process(name)
38+
# Use the repository layout which is the same as index.html
39+
self.data = {
40+
'layout' => 'repository',
41+
'title' => 'GitHub repo explorer: visualize and navigate github project structures',
42+
'description' => 'Effortlessly explore and visualize the file structure of any public GitHub repository online. Navigate project folders, view directory trees, and copy paths without cloning.',
43+
'is_repo_path' => true,
44+
'permalink' => File.join('/', dir, name.sub('index.html', ''))
45+
}
46+
end
47+
end
48+
end

assets/js/script.js

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

183183
function parseURL() {
184-
// Check for repo_path query parameter (from 404.html redirect)
185184
const urlParams = new URLSearchParams(window.location.search);
186-
const repoPathParam = urlParams.get('repo_path');
187185

188-
if (repoPathParam) {
189-
// We have a repository path from 404.html redirect
190-
const pathMatch = repoPathParam.match(/\/repo\/([^\/]+)\/([^\/]+)\/([^\/]+)\/?$/);
191-
192-
if (pathMatch) {
193-
const [, user, repo, branch] = pathMatch;
194-
const fullRepo = `${user}/${repo}`;
195-
196-
// Update the URL to the canonical form without query parameters
197-
history.replaceState(null, null, repoPathParam);
198-
199-
// Set input values and fetch the repository
200-
if (repoInput && branchInput) {
201-
repoInput.value = fullRepo;
202-
branchInput.value = branch;
203-
setTimeout(() => fetchRepoTree(), 100); // Small delay to ensure UI is ready
204-
}
205-
return; // Skip the rest of parseURL
206-
}
207-
}
208-
209186
// Skip URL parsing for specific pages we want to preserve
210187
const specialPages = ['/featured-repos', '/featured-repos.html'];
211188
if (specialPages.includes(window.location.pathname)) {

0 commit comments

Comments
 (0)