Skip to content

add path mapping for file items#353

Open
Madhvik007 wants to merge 1 commit intodiwas7777:mainfrom
Madhvik007:add-clickable-file-items-github-links
Open

add path mapping for file items#353
Madhvik007 wants to merge 1 commit intodiwas7777:mainfrom
Madhvik007:add-clickable-file-items-github-links

Conversation

@Madhvik007
Copy link

@Madhvik007 Madhvik007 commented Oct 6, 2025

Fixes #352

Now users can click on any file item and be taken directly to the correct GitHub file in the new page

@diwas7777 diwas7777 requested a review from Copilot October 10, 2025 17:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds path mapping functionality to enable direct navigation from file items to their corresponding GitHub locations. Users can now click on any file item in the modal to open the file in a new tab on GitHub.

Key changes:

  • Added comprehensive path mapping configuration for nested files across multiple languages
  • Transformed file items from static divs to clickable anchor elements with GitHub URLs
  • Enhanced styling with hover effects and cursor pointer for better UX

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

'typescript': 'TS'
};
// File path mapping for nested files
const filePathMapping = {
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This large hardcoded mapping object (lines 897-951) makes the code difficult to maintain. Consider extracting this configuration to a separate JSON file or implementing a more dynamic approach to discover file paths.

Copilot uses AI. Check for mistakes.
'style.css': 'fun project/style.css'
},
'Java': {
'Fruites.java': 'arrayList/Fruites.java',
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'Fruites' to 'Fruits'.

Suggested change
'Fruites.java': 'arrayList/Fruites.java',
'Fruits.java': 'arrayList/Fruits.java',

Copilot uses AI. Check for mistakes.
fileGrid.innerHTML = '';

const folders = language.items ? language.items.filter(item =>
!item.includes('.') && !['full pyramid', 'inverted full pyramid', 'inverted half pyramid', 'pascals triangle', 'traingle'].includes(item)
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'traingle' to 'triangle'.

Suggested change
!item.includes('.') && !['full pyramid', 'inverted full pyramid', 'inverted half pyramid', 'pascals triangle', 'traingle'].includes(item)
!item.includes('.') && !['full pyramid', 'inverted full pyramid', 'inverted half pyramid', 'pascals triangle', 'triangle'].includes(item)

Copilot uses AI. Check for mistakes.
Comment on lines +966 to +973
async function checkFileExists(url) {
try {
const response = await fetch(url, { method: 'HEAD' });
return response.ok;
} catch {
return false;
}
}
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The checkFileExists function is defined but never used in the provided code. If it's intended for future use, consider adding a TODO comment explaining its purpose.

Copilot uses AI. Check for mistakes.
Comment on lines +1078 to +1085
for (const folder of folders) {
if (file.name.toLowerCase().includes('tree') && folder.toLowerCase().includes('tree')) {
filePath = `${folder}/${file.name}`;
break;
} else if (file.name.toLowerCase().includes('os') && folder.toLowerCase().includes('os')) {
filePath = `${folder}/${file.name}`;
break;
}
Copy link

Copilot AI Oct 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hardcoded string matching logic for 'tree' and 'os' files should be extracted to a configuration object for better maintainability and extensibility.

Suggested change
for (const folder of folders) {
if (file.name.toLowerCase().includes('tree') && folder.toLowerCase().includes('tree')) {
filePath = `${folder}/${file.name}`;
break;
} else if (file.name.toLowerCase().includes('os') && folder.toLowerCase().includes('os')) {
filePath = `${folder}/${file.name}`;
break;
}
// Configuration object for keyword-folder matching
const keywordFolderMapping = {
'tree': 'tree',
'os': 'os'
// Add more keywords as needed
};
for (const [keyword, folderKeyword] of Object.entries(keywordFolderMapping)) {
for (const folder of folders) {
if (file.name.toLowerCase().includes(keyword) && folder.toLowerCase().includes(folderKeyword)) {
filePath = `${folder}/${file.name}`;
break;
}
}
if (filePath !== file.name) break; // If filePath was updated, exit outer loop

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: Make the code name clickable to view the code in github

2 participants