[from now] 2014/09/18 18:33:18

diff --git a/gaiden-core/src/main/groovy/gaiden/Document.groovy b/gaiden-core/src/main/groovy/gaiden/Document.groovy
index 891159b..1b91f01 100644
--- a/gaiden-core/src/main/groovy/gaiden/Document.groovy
+++ b/gaiden-core/src/main/groovy/gaiden/Document.groovy
@@ -40,7 +40,6 @@ class Document {
     }

     Page nextPageOf(Page page) {
-        page.source.path.subpath()
         if (!pageOrder.contains(page) || pageOrder.last() == page) {
             return null
         }
diff --git a/gaiden-core/src/test/groovy/gaiden/BuildCommandSpec.groovy b/gaiden-core/src/test/groovy/gaiden/BuildCommandSpec.groovy
index 023d334..ffdcbc4 100644
--- a/gaiden-core/src/test/groovy/gaiden/BuildCommandSpec.groovy
+++ b/gaiden-core/src/test/groovy/gaiden/BuildCommandSpec.groovy
@@ -18,6 +18,8 @@ package gaiden

 import gaiden.command.BuildCommand

+import java.nio.file.Paths
+
 class BuildCommandSpec extends FunctionalSpec {

     def "build a document"() {
@@ -43,4 +45,20 @@ class BuildCommandSpec extends FunctionalSpec {
         then:
             assertOutputDirectory "src/test/resources/without-pages/build"
     }
+
+    def "xxx"() {
+        given:
+            def b = Paths.get('/aaa/bbb/file.txt')
+            def c = Paths.get('/aaa/ccc/file.txt')
+
+        when:
+            def found = (0..b.nameCount).find {
+                b.getName(it) != c.getName(it)
+            }
+            println found
+            def path = b.subpath(0, found)
+
+        then:
+            path.toString() == '/aaa'
+    }
 }
diff --git a/gaiden-core/src/test/resources/without-pages/3_third.md b/gaiden-core/src/test/resources/without-pages/3_third.md
deleted file mode 100644
index 8d635dc..0000000
--- a/gaiden-core/src/test/resources/without-pages/3_third.md
+++ /dev/null
@@ -1 +0,0 @@
-# Third
diff --git a/gaiden-core/src/test/resources/without-pages/3_third/3_1_child.md b/gaiden-core/src/test/resources/without-pages/3_third/3_1_child.md
new file mode 100644
index 0000000..8d635dc
--- /dev/null
+++ b/gaiden-core/src/test/resources/without-pages/3_third/3_1_child.md
@@ -0,0 +1 @@
+# Third
diff --git a/gaiden-core/src/test/resources/without-pages/4_fourth.md b/gaiden-core/src/test/resources/without-pages/4_fourth.md
new file mode 100644
index 0000000..8d635dc
--- /dev/null
+++ b/gaiden-core/src/test/resources/without-pages/4_fourth.md
@@ -0,0 +1 @@
+# Third
diff --git a/src/main/dist/themes/default/layouts/explorer.html b/src/main/dist/themes/default/layouts/explorer.html
index fddde80..9169c89 100644
--- a/src/main/dist/themes/default/layouts/explorer.html
+++ b/src/main/dist/themes/default/layouts/explorer.html
@@ -1,5 +1,38 @@
 <%
-  document.pages.each { page ->
-    println page.source.pathe
-  }
-%>
\ No newline at end of file
+def current = config.sourceDirectory
+println '<ul>'
+document.pages.each { page ->
+    if (current && java.nio.file.Files.isSameFile(page.source.path.parent, current)) {
+        println "<li>${gaiden.util.PathUitls.removeExtension(page.source.path.fileName)}</li>"
+    } else if (current && current.startsWith(page.source.path.parent)) {
+        def relativePath = current.relativize(page.source.path.parent)
+        relativePath.each { parent ->
+            println "</ul></li>"
+        }
+        println "<li>${gaiden.util.PathUitls.removeExtension(page.source.path.fileName)}</li>"
+    } else if (current && page.source.path.parent.startsWith(current)) {
+        def relativePath = current.relativize(page.source.path.parent)
+        relativePath.each { parent ->
+            println "<li>${parent}<ul>"
+        }
+        println "<li>${gaiden.util.PathUitls.removeExtension(page.source.path.fileName)}</li>"
+    } else {
+        def found = (0..(Math.min(current.nameCount, page.source.path.parent.nameCount))).find {
+            current.getName(it) != page.source.path.parent.getName(it)
+        }
+        (current.nameCount - found).times {
+            println '</ul></li>'
+        }
+        (current.nameCount..page.source.path.parent.nameCount).each { int index ->
+            println "<li>${page.source.path.parent.getName(index)}<ul>"
+        }
+        println "<li>${gaiden.util.PathUitls.removeExtension(page.source.path.fileName)}</li>"
+    }
+    current = page.source.path.parent
+}
+
+(current.nameCount - config.sourceDirectory.nameCount).times {
+    println "</ul></li>"
+}
+println '</ul>'
+%>