changeset 273:073044e3ac03

fix mmake.sh and multipart mail git-svn-id: https://luan-java.googlecode.com/svn/trunk@274 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Fri, 31 Oct 2014 18:44:11 +0000
parents eb27e765affb
children 8afe9f2fdfec
files core/src/luan/modules/Time.luan dist/jars/luan-core-trunk.jar dist/jars/luan-logging-trunk.jar dist/jars/luan-lucene-trunk.jar dist/jars/luan-mail-trunk.jar dist/jars/luan-web-trunk.jar dist/scripts/mmake.luan mail/src/luan/modules/mail/SmtpCon.java
diffstat 8 files changed, 22 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/core/src/luan/modules/Time.luan	Fri Oct 31 04:50:24 2014 +0000
+++ b/core/src/luan/modules/Time.luan	Fri Oct 31 18:44:11 2014 +0000
@@ -37,6 +37,7 @@
 end
 
 function format(time,pattern)
+	pattern = pattern or "yyyy-MM-dd HH:m:ss"
 	return SimpleDateFormat.new(pattern).format(Date.new(time))
 end
 
Binary file dist/jars/luan-core-trunk.jar has changed
Binary file dist/jars/luan-logging-trunk.jar has changed
Binary file dist/jars/luan-lucene-trunk.jar has changed
Binary file dist/jars/luan-mail-trunk.jar has changed
Binary file dist/jars/luan-web-trunk.jar has changed
--- a/dist/scripts/mmake.luan	Fri Oct 31 04:50:24 2014 +0000
+++ b/dist/scripts/mmake.luan	Fri Oct 31 18:44:11 2014 +0000
@@ -1,8 +1,7 @@
-import "Table"
-import "Io"
-import "String"
-import "Java"
-import "java.util.Date"
+import "luan:Table"
+import "luan:Io"
+import "luan:String"
+import "luan:Time"
 
 compiler = Table.concat( { "javac -g -encoding UTF8", ... }, " " )
 
@@ -41,14 +40,14 @@
 
 function header()
 	return 	%>
-# Makefile created on <%=Date.new()%> by Mmake
+# Makefile created on <%=Time.format(Time.now())%> by Mmake
 
 .SUFFIXES: .java .class
 
 .java.class:
-	javac -g -encoding UTF8 $<
+	<%=compiler%> $<
 
 all: <%
 end
 
-mmake(Io.File ".")
+mmake(Io.schemes.file ".")
--- a/mail/src/luan/modules/mail/SmtpCon.java	Fri Oct 31 04:50:24 2014 +0000
+++ b/mail/src/luan/modules/mail/SmtpCon.java	Fri Oct 31 18:44:11 2014 +0000
@@ -1,6 +1,7 @@
 package luan.modules.mail;
 
 import java.util.Map;
+import java.util.HashMap;
 import java.util.Properties;
 import javax.mail.Authenticator;
 import javax.mail.PasswordAuthentication;
@@ -105,19 +106,23 @@
 				if( body instanceof String ) {
 					msg.setText((String)body);
 				} else if( body instanceof LuanTable ) {
+					LuanTable bodyTbl = (LuanTable)body;
+					Map<Object,Object> map = new HashMap<Object,Object>(bodyTbl.asMap());
 					MimeMultipart mp = new MimeMultipart("alternative");
-					for( Map.Entry<Object,Object> entry : (LuanTable)body ) {
-						String key = (String)entry.getKey();
-						String val = (String)entry.getValue();
+					String text = (String)map.remove("text");
+					if( text != null ) {
 						MimeBodyPart part = new MimeBodyPart();
-						if( key.equals("text") ) {
-							part.setText(val);
-						} else if( key.equals("html") ) {
-							part.setContent(val,"text/html");
-						} else
-							throw luan.exception( "invalid body type: " + key );
+						part.setText(text);
 						mp.addBodyPart(part);
 					}
+					String html = (String)map.remove("html");
+					if( html != null ) {
+						MimeBodyPart part = new MimeBodyPart();
+						part.setContent(html,"text/html");
+						mp.addBodyPart(part);
+					}
+					if( !map.isEmpty() )
+						throw luan.exception( "invalid body types: " + map );
 					msg.setContent(mp);
 				} else
 					throw luan.exception( "parameter 'body' is must be a string or table" );