Mercurial Hosting > luan
changeset 219:f9e3e64132e1
improve rev 217, allow "java:" paths to include sample files to check in jars
git-svn-id: https://luan-java.googlecode.com/svn/trunk@220 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Wed, 16 Jul 2014 04:53:01 +0000 |
parents | 92f5d74697f8 |
children | 61afe2a1ce96 |
files | core/src/luan/modules/Utils.java dist/luan-core-trunk.jar dist/luan-logging-trunk.jar dist/luan-web-trunk.jar web/src/luan/modules/web/Web_server.luan |
diffstat | 5 files changed, 22 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
diff -r 92f5d74697f8 -r f9e3e64132e1 core/src/luan/modules/Utils.java --- a/core/src/luan/modules/Utils.java Tue Jul 15 20:19:36 2014 +0000 +++ b/core/src/luan/modules/Utils.java Wed Jul 16 04:53:01 2014 +0000 @@ -74,16 +74,23 @@ path = path.substring(5); if( path.contains("//") ) return null; - URL url = ClassLoader.getSystemResource(path); - if( url==null && path.endsWith("/") ) { - url = ClassLoader.getSystemResource(path+"index.html"); - if( url==null ) - url = ClassLoader.getSystemResource(path+"index.html.luan"); - if( url != null ) { - try { - url = new URL(url,"."); - } catch(MalformedURLException e) { - throw new RuntimeException(e); + URL url; + if( !path.contains("#") ) { + url = ClassLoader.getSystemResource(path); + } else { + String[] a = path.split("#"); + url = ClassLoader.getSystemResource(a[0]); + if( url==null ) { + for( int i=1; i<a.length; i++ ) { + url = ClassLoader.getSystemResource(a[0]+"/"+a[i]); + if( url != null ) { + try { + url = new URL(url,"."); + } catch(MalformedURLException e) { + throw new RuntimeException(e); + } + break; + } } } }
diff -r 92f5d74697f8 -r f9e3e64132e1 dist/luan-core-trunk.jar Binary file dist/luan-core-trunk.jar has changed
diff -r 92f5d74697f8 -r f9e3e64132e1 dist/luan-logging-trunk.jar Binary file dist/luan-logging-trunk.jar has changed
diff -r 92f5d74697f8 -r f9e3e64132e1 dist/luan-web-trunk.jar Binary file dist/luan-web-trunk.jar has changed
diff -r 92f5d74697f8 -r f9e3e64132e1 web/src/luan/modules/web/Web_server.luan --- a/web/src/luan/modules/web/Web_server.luan Tue Jul 15 20:19:36 2014 +0000 +++ b/web/src/luan/modules/web/Web_server.luan Wed Jul 16 04:53:01 2014 +0000 @@ -72,7 +72,11 @@ Http.dir = dir Package.path = dir.."?.luan;java:luan/modules/?.luan" authentication_handler.setPassword(private_password) - resource_handler.setResourceBase(Io.File(dir.."/").to_string()) + local base = dir + if base.match("^java:") ~= nil then + base = dir.."#"..welcome_file.."#"..welcome_file..".luan" + end + resource_handler.setResourceBase(Io.File(base).to_string()) resource_handler.setWelcomeFiles {welcome_file} luan_handler.setWelcomeFile(welcome_file) local server = Server.new(port)