Skip to content
Open
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
4 changes: 4 additions & 0 deletions .jules/palette.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@
## 2024-08-01 - ๋„ค์ดํ‹ฐ๋ธŒ ๋ธŒ๋ผ์šฐ์ € UI์˜ ๋‹คํฌ ๋ชจ๋“œ ์ง€์› ๊ฐ•์ œ
**ํ•™์Šต:** CSS ๋ฏธ๋””์–ด ์ฟผ๋ฆฌ(`@media (prefers-color-scheme: dark)`)๋ฅผ ํ†ตํ•ด ๋‹คํฌ ๋ชจ๋“œ๋ฅผ ์ง€์›ํ•˜๋”๋ผ๋„, ๋ธŒ๋ผ์šฐ์ €์˜ ๋„ค์ดํ‹ฐ๋ธŒ UI ์š”์†Œ(์Šคํฌ๋กค๋ฐ”, ๊ธฐ๋ณธ ํผ ์ปจํŠธ๋กค, ๊ธฐ๋ณธ ๋ฐฑ๊ทธ๋ผ์šด๋“œ ๋“ฑ)๋Š” ํ…Œ๋งˆ ๋ณ€๊ฒฝ์„ ์ธ์‹ํ•˜์ง€ ๋ชปํ•ด ์–ด๋‘์šด ํ…Œ๋งˆ ํ™˜๊ฒฝ์—์„œ ๋ฐ์€ ์Šคํฌ๋กค๋ฐ”๊ฐ€ ํ‘œ์‹œ๋˜๋Š” ๋“ฑ ์‹œ๊ฐ์  ๋ถˆ์ผ์น˜๋ฅผ ์ดˆ๋ž˜ํ•ฉ๋‹ˆ๋‹ค.
**์กฐ์น˜:** ํ•ญ์ƒ HTML ๋ฌธ์„œ์˜ `<head>` ์˜์—ญ์— `<meta name="color-scheme" content="light dark">` ๋ฉ”ํƒ€ ํƒœ๊ทธ๋ฅผ ๋ช…์‹œ์ ์œผ๋กœ ์ถ”๊ฐ€ํ•˜์—ฌ ๋ธŒ๋ผ์šฐ์ € ์ˆ˜์ค€์—์„œ ์‚ฌ์šฉ์ž์˜ ์‹œ์Šคํ…œ ํ…Œ๋งˆ(๋‹คํฌ ๋ชจ๋“œ ๋“ฑ)๋ฅผ ์™„์ „ํžˆ ์ƒ์†๋ฐ›์•„ ์ผ๊ด€์„ฑ ์žˆ๋Š” ๋„ค์ดํ‹ฐ๋ธŒ UI๋ฅผ ๋ Œ๋”๋งํ•˜๋„๋ก ๋ณด์žฅํ•˜์‹ญ์‹œ์˜ค.

## 2024-08-05 - ๋นˆ ๋””๋ ‰ํ† ๋ฆฌ์™€ ๋‚ด์šฉ์ด ์žˆ๋Š” ๋””๋ ‰ํ† ๋ฆฌ ์‹œ๊ฐ์ /์‹œ๋งจํ‹ฑ ๊ตฌ๋ถ„
**ํ•™์Šต:** ๋””๋ ‰ํ† ๋ฆฌ ๋ชฉ๋ก์—์„œ ๋น„์–ด์žˆ๋Š” ๋””๋ ‰ํ† ๋ฆฌ์™€ ๊ทธ๋ ‡์ง€ ์•Š์€ ๋””๋ ‰ํ† ๋ฆฌ๊ฐ€ ์‹œ๊ฐ์ ์œผ๋กœ๋‚˜ ์‹œ๋งจํ‹ฑํ•˜๊ฒŒ ๋™์ผํ•˜๊ฒŒ ํ‘œ์‹œ๋˜๋ฉด, ์‚ฌ์šฉ์ž๋Š” ๋นˆ ๋””๋ ‰ํ† ๋ฆฌ ๋‚ด๋ถ€๋ฅผ ๋ถˆํ•„์š”ํ•˜๊ฒŒ ํƒ์ƒ‰ํ•˜๊ฒŒ ๋˜์–ด ๋ถˆํŽธํ•จ์„ ๋А๋‚๋‹ˆ๋‹ค.
**์กฐ์น˜:** ๋””๋ ‰ํ† ๋ฆฌ ํƒ์ƒ‰ ์‹œ ํ•ด๋‹น ๋””๋ ‰ํ† ๋ฆฌ๊ฐ€ ๋น„์–ด์žˆ๋Š”์ง€ ๋ฏธ๋ฆฌ ํ™•์ธํ•˜์—ฌ, ๋น„์–ด์žˆ์„ ๊ฒฝ์šฐ ๋‹ซํžŒ ํด๋” ์•„์ด์ฝ˜ ๋Œ€์‹  ์—ด๋ฆฐ ํด๋” ์•„์ด์ฝ˜(&#128194;)์„ ์‚ฌ์šฉํ•˜๊ณ  `aria-label`๊ณผ `title` ์†์„ฑ์— '๋นˆ ๋””๋ ‰ํ† ๋ฆฌ'๋ผ๊ณ  ๋ช…์‹œํ•จ์œผ๋กœ์จ ๋ถˆํ•„์š”ํ•œ ๋‚ด๋น„๊ฒŒ์ด์…˜์„ ๋ฐฉ์ง€ํ•˜๊ณ  ์ ‘๊ทผ์„ฑ์„ ๊ฐœ์„ ํ•˜์‹ญ์‹œ์˜ค.
18 changes: 15 additions & 3 deletions src/main/kotlin/html4tree/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ fun write_index_file(curr_dir: File, content: String) {
}
}

fun process_dir(curr_dir: File, excludeSet: Set<String>? = null, dirFiles: Array<File>? = null){
fun process_dir(curr_dir: File, excludeSet: Set<String>? = null, dirFiles: Array<File>? = null, newDirectoryStream: (java.nio.file.Path) -> java.nio.file.DirectoryStream<java.nio.file.Path> = { Files.newDirectoryStream(it) }){

val exclude: Set<String> = excludeSet ?: process_ignore_file(curr_dir)

Expand Down Expand Up @@ -360,9 +360,21 @@ ${cssContent} </style>
} catch (e: Exception) {
}
if (!isSymbolicLink) {
var isEmptyDir = false
if (isLinkedDirectory) {
try {
val stream = newDirectoryStream(it.toPath())
try {
isEmptyDir = !stream.iterator().hasNext()
} finally {
stream.close()
}
Comment on lines +366 to +371
} catch (e: Exception) {
}
}
val encodedHref = if (isLinkedDirectory) { "./${fileName.urlEncodePath()}/" } else { "./${fileName.urlEncodePath()}" }
val ariaLabel = "${fileName} ${if (isLinkedDirectory) { "๋””๋ ‰ํ† ๋ฆฌ" } else { "ํŒŒ์ผ" }}".escapeHtml()
val icon = if (isLinkedDirectory) { "&#128193;" } else { "&#128196;" }
val ariaLabel = "${fileName} ${if (isLinkedDirectory) { if (isEmptyDir) "๋นˆ ๋””๋ ‰ํ† ๋ฆฌ" else "๋””๋ ‰ํ† ๋ฆฌ" } else { "ํŒŒ์ผ" }}".escapeHtml()
val icon = if (isLinkedDirectory) { if (isEmptyDir) "&#128194;" else "&#128193;" } else { "&#128196;" }
l.append(""" <li><a class="dir-link" href="${encodedHref}" aria-label="${ariaLabel}" title="${ariaLabel}"><span class="icon" aria-hidden="true">${icon}</span> <span>${fileName.escapeHtml()}</span></a></li>""")
l.append('\n')
}
Expand Down
16 changes: 16 additions & 0 deletions src/test/kotlin/html4tree/AttrExceptionTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,20 @@ class AttrExceptionTest {
tempDir.deleteRecursively()
}
}

@Test
fun testExceptionInNewDirectoryStream() {
val tempDir = Files.createTempDirectory("stream_test").toFile()
try {
val subDir = File(tempDir, "subdir")
subDir.mkdir()
process_dir(tempDir, setOf(), arrayOf(subDir)) { _ ->
throw java.io.IOException("Mock exception")
}
val indexHtml = File(tempDir, "index.html")
assertTrue(indexHtml.exists())
} finally {
tempDir.deleteRecursively()
}
}
}
13 changes: 13 additions & 0 deletions src/test/kotlin/html4tree/MainTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ class MainTest {
}
}

@Test
fun testEmptyDirectoryIcon() {
val emptyDir = File(tempDir, "empty_subdir")
emptyDir.mkdir()
go(tempDir.absolutePath, 0)
val indexFile = File(tempDir, "index.html")
val htmlContent = indexFile.readText()
assertTrue(htmlContent.contains("&#128194;"))
assertTrue(htmlContent.contains("aria-label=\"empty_subdir ๋นˆ ๋””๋ ‰ํ† ๋ฆฌ\""))
assertTrue(htmlContent.contains("title=\"empty_subdir ๋นˆ ๋””๋ ‰ํ† ๋ฆฌ\""))
}

@Test
fun testGoEmptyDir() {
go(tempDir.absolutePath, -1)
Expand Down Expand Up @@ -298,6 +310,7 @@ class MainTest {
fun testProcessDir() {
val subdir = File(tempDir, "subdir")
subdir.mkdir()
File(subdir, "some_file.txt").createNewFile()
File(tempDir, "file1.txt").createNewFile()
File(tempDir, "test.ignore").createNewFile()
File(tempDir, ".html4ignore").writeText("*.ignore")
Expand Down
Loading