-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'github_pages_from_main'
- Loading branch information
Showing
7 changed files
with
553 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
name: Update GitHub Pages | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
jobs: | ||
update-content: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Configure Git user | ||
run: | | ||
git config --global user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --global user.name "github-actions[bot]" | ||
# Step 1: Checkout the 'github_pages_from_main' branch | ||
- name: Checkout github_pages_from_main branch | ||
uses: actions/checkout@v4 | ||
with: | ||
ref: github_pages_from_main | ||
|
||
- name: Configure Git Pull Strategy | ||
run: git config pull.rebase false # Use 'true' for rebase or 'ff only' for fast-forward only | ||
|
||
# Step 2: Merge changes from 'main' into 'github_pages_from_main' | ||
- name: Merge main into github_pages_from_main | ||
run: | | ||
git remote set-url origin https://x-access-token:${{ secrets.TOKEN }}@github.com/${{ github.repository }}.git | ||
git checkout github_pages_from_main | ||
git pull origin main --allow-unrelated-histories -X theirs | ||
# Step 3: Ensure files.json exists | ||
- name: Create files.json if it does not exist | ||
run: | | ||
if [ ! -f files.json ]; then | ||
echo "[]" > files.json | ||
fi | ||
# Step 4: Run the JavaScript script to update the files.json | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20' | ||
|
||
- name: Install dependencies | ||
run: npm install node-fetch | ||
|
||
- name: Run update script | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.TOKEN }} | ||
run: node updateContentGitHubActionsGitHubPages.mjs | ||
|
||
# Step 5: Commit and push changes to github_pages_from_main | ||
- name: Commit and push changes to github_pages_from_main | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.TOKEN }} | ||
run: | | ||
git config --global user.name 'github-actions[bot]' | ||
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | ||
git add files.json | ||
git commit -m 'Update files.json with latest Kotlin files' || echo "No changes to commit" | ||
git push https://x-access-token:${{ secrets.TOKEN }}@github.com/${{ github.repository }}.git HEAD:github_pages_from_main | ||
deploy: | ||
needs: update-content | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Step 6: Deploy the content to GitHub Pages | ||
- name: Checkout github_pages_from_main branch | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: github_pages_from_main | ||
|
||
- name: Deploy to GitHub Pages | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.TOKEN }} | ||
publish_dir: ./kotlinDSAWithIntellijIdea | ||
destination_branch: gh-pages # Specify the branch to deploy to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
[ | ||
{ | ||
"name": "array.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level02DataTypes/array.kt" | ||
}, | ||
{ | ||
"name": "scanner.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level06/scanner.kt" | ||
}, | ||
{ | ||
"name": "maxPairProduct.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level10/maxPairProduct.kt" | ||
}, | ||
{ | ||
"name": "010nthFibonacci.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level20Week2AlgorithmicWarmUp/010nthFibonacci.kt" | ||
}, | ||
{ | ||
"name": "012nthFibonacciModulo.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level20Week2AlgorithmicWarmUp/012nthFibonacciModulo.kt" | ||
}, | ||
{ | ||
"name": "013nthFibonacciModuloArithmetically.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level20Week2AlgorithmicWarmUp/013nthFibonacciModuloArithmetically.kt" | ||
}, | ||
{ | ||
"name": "015lastDigitOfNthFibonacci.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level20Week2AlgorithmicWarmUp/015lastDigitOfNthFibonacci.kt" | ||
}, | ||
{ | ||
"name": "020hugeNthFibonacciModuloDynamic.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level20Week2AlgorithmicWarmUp/020hugeNthFibonacciModuloDynamic.kt" | ||
}, | ||
{ | ||
"name": "028naiveLastDigit4SumOfNthFibonacci.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level20Week2AlgorithmicWarmUp/028naiveLastDigit4SumOfNthFibonacci.kt" | ||
}, | ||
{ | ||
"name": "030lastDigit4sumOfNthFibonacci.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level20Week2AlgorithmicWarmUp/030lastDigit4sumOfNthFibonacci.kt" | ||
}, | ||
{ | ||
"name": "035lastDigitOfPartialSumOfNthFibonacci.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level20Week2AlgorithmicWarmUp/035lastDigitOfPartialSumOfNthFibonacci.kt" | ||
}, | ||
{ | ||
"name": "036lastDigitOfPartialSumOfNthFibonacci.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level20Week2AlgorithmicWarmUp/036lastDigitOfPartialSumOfNthFibonacci.kt" | ||
}, | ||
{ | ||
"name": "040lastDigitOfSumOfSquareOfNthFibonacci.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level20Week2AlgorithmicWarmUp/040lastDigitOfSumOfSquareOfNthFibonacci.kt" | ||
}, | ||
{ | ||
"name": "05naivePrintFibonacciUpTo.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level20Week2AlgorithmicWarmUp/05naivePrintFibonacciUpTo.kt" | ||
}, | ||
{ | ||
"name": "070gcdOrHcfUsingEuclid.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level20Week2AlgorithmicWarmUp/070gcdOrHcfUsingEuclid.kt" | ||
}, | ||
{ | ||
"name": "071gcdOrHcfUsingEuclid.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level20Week2AlgorithmicWarmUp/071gcdOrHcfUsingEuclid.kt" | ||
}, | ||
{ | ||
"name": "080lcmUsingEuclideanTheory.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level20Week2AlgorithmicWarmUp/080lcmUsingEuclideanTheory.kt" | ||
}, | ||
{ | ||
"name": "090Josephus.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level20Week2AlgorithmicWarmUp/090Josephus.kt" | ||
}, | ||
{ | ||
"name": "091josephusProblem.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level20Week2AlgorithmicWarmUp/091josephusProblem.kt" | ||
}, | ||
{ | ||
"name": "100RangeSumQueryImmutable.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level20Week2AlgorithmicWarmUp/100RangeSumQueryImmutable.kt" | ||
}, | ||
{ | ||
"name": "010MoneyChangeDenomination.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level30Module3AlgorithmExercise/010MoneyChangeDenomination.kt" | ||
}, | ||
{ | ||
"name": "020maximumLoot.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level30Module3AlgorithmExercise/020maximumLoot.kt" | ||
}, | ||
{ | ||
"name": "030carFueling.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level30Module3AlgorithmExercise/030carFueling.kt" | ||
}, | ||
{ | ||
"name": "032carFueling2ndWay.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level30Module3AlgorithmExercise/032carFueling2ndWay.kt" | ||
}, | ||
{ | ||
"name": "040maximumDotProductOf2Sequences.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level30Module3AlgorithmExercise/040maximumDotProductOf2Sequences.kt" | ||
}, | ||
{ | ||
"name": "050minimumPointsToCoverUnionSegments.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level30Module3AlgorithmExercise/050minimumPointsToCoverUnionSegments.kt" | ||
}, | ||
{ | ||
"name": "060distinctSummandsProblem.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level30Module3AlgorithmExercise/060distinctSummandsProblem.kt" | ||
}, | ||
{ | ||
"name": "070largestConcatenatedNumber.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level30Module3AlgorithmExercise/070largestConcatenatedNumber.kt" | ||
}, | ||
{ | ||
"name": "010selectionSortExample.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level40Module4AlgorithmExercise/010selectionSortExample.kt" | ||
}, | ||
{ | ||
"name": "020mergeSortExample.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level40Module4AlgorithmExercise/020mergeSortExample.kt" | ||
}, | ||
{ | ||
"name": "030mergeSortClean.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level40Module4AlgorithmExercise/030mergeSortClean.kt" | ||
}, | ||
{ | ||
"name": "040countSortExample.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level40Module4AlgorithmExercise/040countSortExample.kt" | ||
}, | ||
{ | ||
"name": "050countSortClean.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level40Module4AlgorithmExercise/050countSortClean.kt" | ||
}, | ||
{ | ||
"name": "060quickSort1.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level40Module4AlgorithmExercise/060quickSort1.kt" | ||
}, | ||
{ | ||
"name": "070quickSort1Clean.kt", | ||
"url": "https://github.com/sagarpatel288/kotlinDSAWithIntellijIdea/blob/main/src/level40Module4AlgorithmExercise/070quickSort1Clean.kt" | ||
} | ||
] |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Kotlin DSA Practice Files</title> | ||
<link rel="stylesheet" href="styles.css"> | ||
<script defer src="updateContentBrowserScript.js"></script> | ||
<!--<script> | ||
<!–Client-Side JavaScript:–> | ||
<!–This script runs in the browser to load and display files.json.–> | ||
<!–It handles sorting and UI interactions.–> | ||
<!–Environment Separation:–> | ||
<!–Ensure server-side code runs in GitHub Actions and client-side code runs in the browser.–> | ||
<!–Sorting and UI: Handle sorting and UI interactions in the browser.–> | ||
<!–Loading and Messages: Use the browser script to manage loading states and display messages.–> | ||
<!–This separation ensures that each part of your application runs in the correct environment without errors.–> | ||
document.addEventListener('DOMContentLoaded', async () => { | ||
const fileList = document.getElementById('file-list'); | ||
const sortOptions = document.getElementById('sort-options'); | ||
const loader = document.getElementById('loader'); | ||
const messageBox = document.getElementById('message-box'); | ||
const messageText = document.getElementById('message-text'); | ||
const closeMessageButton = document.getElementById('close-message'); | ||
let kotlinFiles = []; | ||
loader.style.display = 'block'; | ||
closeMessageButton.addEventListener('click', () => { | ||
messageBox.style.display = 'none'; | ||
}); | ||
async function loadFiles() { | ||
try { | ||
const timestamp = new Date().getTime(); | ||
const response = await fetch(`files.json?t=${timestamp}`); | ||
if (!response.ok) throw new Error('Failed to fetch files'); | ||
kotlinFiles = await response.json(); | ||
renderFileList(kotlinFiles); | ||
} catch (error) { | ||
console.error('Error loading files:', error); | ||
showMessage('Error loading files. Please try again later.', 'error'); | ||
} finally { | ||
loader.style.display = 'none'; | ||
} | ||
} | ||
function renderFileList(files) { | ||
fileList.innerHTML = ''; | ||
files.forEach(file => { | ||
const link = document.createElement('a'); | ||
link.href = file.url; | ||
link.textContent = file.name; | ||
link.className = 'file-link'; | ||
fileList.appendChild(link); | ||
}); | ||
} | ||
function showMessage(message, type) { | ||
messageText.textContent = message; | ||
messageBox.className = `message-box ${type}`; | ||
messageBox.style.display = 'block'; | ||
} | ||
sortOptions.addEventListener('change', () => { | ||
const option = sortOptions.value; | ||
let sortedFiles = [...kotlinFiles]; | ||
switch (option) { | ||
case 'ascending': | ||
sortedFiles.sort((a, b) => a.name.localeCompare(b.name)); | ||
break; | ||
case 'descending': | ||
sortedFiles.sort((a, b) => b.name.localeCompare(a.name)); | ||
break; | ||
case 'latest': | ||
sortedFiles.sort((a, b) => new Date(b.date) - new Date(a.date)); | ||
break; | ||
case 'oldest': | ||
sortedFiles.sort((a, b) => new Date(a.date) - new Date(b.date)); | ||
break; | ||
default: | ||
break; | ||
} | ||
renderFileList(sortedFiles); | ||
}); | ||
await loadFiles(); | ||
}); | ||
</script>--> | ||
<style> | ||
body { | ||
font-family: 'Roboto', Arial, sans-serif; | ||
background-color: #1e1e1e; | ||
color: #c9d1d9; | ||
text-align: center; | ||
padding: 20px; | ||
} | ||
.file-link { | ||
display: block; | ||
color: #58a6ff; | ||
text-decoration: none; | ||
margin: 5px 0; | ||
} | ||
.file-link:hover { | ||
text-decoration: underline; | ||
} | ||
#sort-options { | ||
margin-bottom: 20px; | ||
padding: 10px; | ||
font-size: 16px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h1>Kotlin DSA Practice Files</h1> | ||
<div id="loader" class="loader">Loading...</div> | ||
|
||
<div id="message-box" class="message-box" style="display: none;"> | ||
<span id="message-text"></span> | ||
<button id="close-message">Close</button> | ||
</div> | ||
|
||
<!-- Sorting Options --> | ||
<label for="sort-options"></label><select id="sort-options"> | ||
<option value="default">Default</option> | ||
<option value="ascending">Ascending</option> | ||
<option value="descending">Descending</option> | ||
<option value="latest">Latest to Old</option> | ||
<option value="oldest">Old to Latest</option> | ||
</select> | ||
|
||
<!-- File List --> | ||
<div id="file-list"> | ||
<!-- The file list will be populated here dynamically --> | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.