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-02 - 빈 디렉토리에 λŒ€ν•œ μ‹œκ°μ  ν”Όλ“œλ°± κ°œμ„ 
**ν•™μŠ΅:** λͺ©λ‘μ— 파일이 μ—†λŠ” 디렉토리에 λ‹«νžŒ 폴더 μ•„μ΄μ½˜(`&#128193;`)을 μ‚¬μš©ν•˜λ©΄ μ‚¬μš©μžκ°€ μ•ˆμ— λ‚΄μš©μ΄ μžˆμ„ 것이라고 μ˜ˆμƒν•˜κ²Œ λ©λ‹ˆλ‹€. μ—΄λ¦° 빈 폴더 μ•„μ΄μ½˜(`&#128194;`)을 μ‚¬μš©ν•˜λ©΄ 디렉토리가 λΉ„μ–΄ μžˆλ‹€λŠ” 것을 μ§κ΄€μ μœΌλ‘œ 전달할 수 μžˆμŠ΅λ‹ˆλ‹€.
**쑰치:** 디렉토리 트리λ₯Ό λ Œλ”λ§ν•  λ•Œ, ν•΄λ‹Ή 디렉토리가 λΉ„μ–΄ μžˆλŠ”μ§€ ν™•μΈν•˜κ³  빈 κ²½μš°μ—λŠ” μ—΄λ¦° 폴더 이λͺ¨μ§€(`&#128194;`)λ₯Ό μ‚¬μš©ν•˜μ—¬ μ‹œκ°μ  ν”Όλ“œλ°±μ„ λͺ…ν™•νžˆ μ œκ³΅ν•˜μ‹­μ‹œμ˜€.
14 changes: 13 additions & 1 deletion src/main/kotlin/html4tree/main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,19 @@ ${cssContent} </style>
if (!isSymbolicLink) {
val encodedHref = if (isLinkedDirectory) { "./${fileName.urlEncodePath()}/" } else { "./${fileName.urlEncodePath()}" }
val ariaLabel = "${fileName} ${if (isLinkedDirectory) { "디렉토리" } else { "파일" }}".escapeHtml()
val icon = if (isLinkedDirectory) { "&#128193;" } else { "&#128196;" }
var isEmptyDir = false
if (isLinkedDirectory) {
try {
val stream = Files.newDirectoryStream(it.toPath())
try {
isEmptyDir = !stream.iterator().hasNext()
} finally {
stream.close()
}
} catch (e: Exception) {
}
}
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
17 changes: 16 additions & 1 deletion src/test/kotlin/html4tree/MainTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class MainTest {
assertTrue(htmlContent.contains("title=\"subdir 디렉토리\""))
assertTrue(htmlContent.contains("file1.txt"))
assertTrue(htmlContent.contains("subdir/"))
assertTrue(htmlContent.contains("&#128193;"))
assertTrue(htmlContent.contains("&#128194;"))
assertFalse(htmlContent.contains("test.ignore"))
assertTrue(htmlContent.contains("Content-Security-Policy"))
val hashMatch = Regex("""style-src '(sha256-[A-Za-z0-9+/=]+)'""").find(htmlContent)?.groupValues?.get(1)
Expand Down Expand Up @@ -414,6 +414,21 @@ class MainTest {
}
}

@Test
fun testProcessDirEmptyDirIcon() {
val emptyDir = File(tempDir, "empty_dir")
emptyDir.mkdir()
val notEmptyDir = File(tempDir, "not_empty_dir")
notEmptyDir.mkdir()
File(notEmptyDir, "file.txt").writeText("hello")

go(tempDir.absolutePath, 0)

val htmlContent = File(tempDir, "index.html").readText()
assertTrue(htmlContent.contains("&#128194;</span> <span>empty_dir</span>"))
assertTrue(htmlContent.contains("&#128193;</span> <span>not_empty_dir</span>"))
}

@Test
fun testGoWithMaxLevel() {
val subdir = File(tempDir, "subdir")
Expand Down
Loading