Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/palette.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 2023-10-18 - HTML 트리 μ ‘κ·Όμ„± κ°œμ„ 
**Learning:** 접근성을 μœ„ν•΄ `aria-label`이 ν¬ν•¨λœ `<nav>`와 `<main>` 같은 μ‹œλ§¨ν‹± νƒœκ·Έλ₯Ό 디렉토리 νŠΈλ¦¬μ— μΆ”κ°€ν•˜λŠ” 것은 슀크린 리더 ν™˜κ²½μ„ κ°œμ„ ν•  수 μžˆμŠ΅λ‹ˆλ‹€. λ˜ν•œ, ν¬μ»€μŠ€μ™€ ν˜Έλ²„(hover/focus) μ‹œκ° νš¨κ³ΌλŠ” ν‚€λ³΄λ“œ μ‚¬μš©μžμ˜ 탐색을 λ•λŠ” μœ μš©ν•œ 마이크둜 UXμž…λ‹ˆλ‹€.
**Action:** ν–₯ν›„ HTML ν…œν”Œλ¦Ώ 생성 μ½”λ“œλ₯Ό μˆ˜μ •ν•  λ•Œ μ‹œλ§¨ν‹± μ›Ήκ³Ό ARIA 속성, λͺ…ν™•ν•œ ν‚€λ³΄λ“œ 포컀슀 μŠ€νƒ€μΌμ„ 기본으둜 μΆ”κ°€ν•©λ‹ˆλ‹€.
13 changes: 11 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ buildscript {

apply plugin: 'kotlin'
apply plugin: 'application'
apply plugin: 'jacoco'

mainClassName = 'html4tree.MainKt'

Expand All @@ -22,7 +23,7 @@ repositories {

dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testCompile 'junit:junit:4.11'
testCompile 'junit:junit:4.12'
testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
compile "com.github.ajalt:clikt:2.7.1"
}
Expand All @@ -33,4 +34,12 @@ jar {
}

from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
}
}

jacocoTestReport {
reports {
xml.enabled = false
csv.enabled = true
html.enabled = true
}
}
31 changes: 26 additions & 5 deletions src/main/kotlin/html4tree/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ fun go(topDir: String, maxLevel: Int) {

var lle: LinkedListEntry? = ll.pull()

while(lle != null && lle.file.isDirectory()){
while(lle != null){
if (lle.file.isDirectory()) {
val currentLevel: Int = lle.level
if(maxLevel == -1 || currentLevel <= maxLevel)
process_dir(lle.file)
Expand All @@ -38,6 +39,7 @@ fun go(topDir: String, maxLevel: Int) {
ll.push( LinkedListEntry(it, currentLevel+1))
}
}
}
lle = ll.pull()
}
}
Expand Down Expand Up @@ -94,20 +96,37 @@ fun process_dir(curr_dir: File){
<style>
ul {
list-style-type: none;
padding-left: 0;
}
a {
display: block;
width: 100%;
padding: 4px;
text-decoration: none;
color: #000;
}
a:hover, a:focus {
background-color: #f0f0f0;
outline: 2px solid #005fcc;
border-radius: 4px;
}
</style>
"""

val index_top = """<!doctype html>
<html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>${curr_dir.getName().escapeHtml()}</title>
${css}
</head>
<body>
<main>
<h1>${curr_dir.getName().escapeHtml()}</h1>
<nav aria-label="Directory structure">
<ul>
<li><a style="display:block; width:100%" href="./..">&#x21B0; ..</a></li>
<li><a href="./..">&#x21B0; ..</a></li>
"""

val index_middle = fun():String{
Expand All @@ -116,8 +135,8 @@ fun process_dir(curr_dir: File){
val dir_files: MutableList<File> = curr_dir.listFiles().toMutableList()
dir_files.sortWith(compareBy ({it.name}) )
dir_files.forEach {
if((it.getName() !in exclude) && (it != curr_dir)) {
l += """ <li><a style="display:block; width:100%" href="${if (it.isDirectory()) { "./${it.getName().urlEncodePath()}/" } else { "./${it.getName().urlEncodePath()}" }}">${if (it.isDirectory()) { "&#128193;" } else { "&rtrif;" }} ${it.getName().escapeHtml()}</a></li>"""+"\n"
if((it.getName() !in exclude)) {
l += """ <li><a href="${if (it.isDirectory()) { "./${it.getName().urlEncodePath()}/" } else { "./${it.getName().urlEncodePath()}" }}">${if (it.isDirectory()) { "&#128193;" } else { "&rtrif;" }} ${it.getName().escapeHtml()}</a></li>"""+"\n"
}
}

Expand All @@ -126,6 +145,8 @@ fun process_dir(curr_dir: File){

val index_bottom="""
</ul>
</nav>
</main>
</body>
</html>
"""
Expand Down
Loading