Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 62f84ae

Browse files
committedDec 21, 2012
Display index for root as well, exclude some files.
1 parent 2a554f3 commit 62f84ae

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed
 

‎src/main/scala/nl/flotsam/monkeyman/FileSystemResourceLoader.scala

+3-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ class FileSystemResourceLoader(baseDir: File)
121121
new OrFileFilter(
122122
List(
123123
new PrefixFileFilter(".#"),
124-
new SuffixFileFilter("~")
124+
new SuffixFileFilter("~"),
125+
new PrefixFileFilter("."),
126+
new RegexFileFilter("^#[^#]*#$")
125127
)
126128
)
127129
), TrueFileFilter.INSTANCE).map(load).toSeq

‎src/main/scala/nl/flotsam/monkeyman/MonkeymanServer.scala

+9-2
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,22 @@ object MonkeymanServer extends MonkeymanTool("monkeyman server") with Logging {
6565
info("Handling {} for {}", exchange.getRequestMethod, path)
6666
if (exchange.getRequestMethod == "GET") {
6767
val lookup = path.substring(1)
68-
// if (path == "/") "index.html"
69-
// else path.substring(1)
7068
config.registry.resourceByPath.get(lookup) match {
69+
case Some(resource) if resource.contentType == "application/directory" =>
70+
config.registry.resourceByPath.get(resource.path + "/index.html") match {
71+
case Some(altResource) =>
72+
info("Sending index.html")
73+
sendResource(altResource, exchange)
74+
case None =>
75+
sendStatus(404, "Not found", exchange)
76+
}
7177
case Some(resource) =>
7278
sendResource(resource, exchange)
7379
case None =>
7480
sendStatus(404, "Not found", exchange)
7581
}
7682
} else {
83+
println(config.registry.allResources.map(_.path).mkString("\n"))
7784
sendStatus(405, "Method not allowed", exchange)
7885
}
7986
}

‎src/main/scala/nl/flotsam/monkeyman/decorator/directory/DirectoryBrowsingDecoration.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class DirectoryBrowsingDecoration(resource: Resource, allResources: () => Seq[Re
3333
override def open = {
3434
val content = (for {
3535
res <- allResources()
36-
if (res.contentType != "application/directory" && FilenameUtils.getPath(res.path) == resource.path + "/")
37-
} yield " * " + FilenameUtils.getName(res.path))
36+
if (res.path != this.path && FilenameUtils.getPathNoEndSeparator(res.path) == resource.path)
37+
} yield " * " + FilenameUtils.getName(res.path) + " (" + res.contentType + ")")
3838
new ByteArrayInputStream(content.mkString("\n").getBytes("UTF-8"))
3939
}
4040

0 commit comments

Comments
 (0)
Please sign in to comment.