incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1553094 [5/5] - in /sling/trunk/samples/mail-archive: ./ docs/ server/ server/src/ server/src/main/ server/src/main/java/ server/src/main/java/org/ server/src/main/java/org/apache/ server/src/main/java/org/apache/sling/ server/src/main/jav...
Date Mon, 23 Dec 2013 11:11:17 GMT
Added: sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/navbar.html.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/navbar.html.esp?rev=1553094&view=auto
==============================================================================
--- sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/navbar.html.esp
(added)
+++ sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/navbar.html.esp
Mon Dec 23 11:11:15 2013
@@ -0,0 +1,68 @@
+<div class="navbar">
+	<% load("head.esp"); %>
+
+<!-- NAVIGATION BAR -->
+
+	<a href=<%= homePage %>>home</a> > 
+<%
+	if (currentNode.getName() == "search") {
+%>
+		<a href="/mailarchiveserver/search.html">search</a>
+<%
+	} else {
+%>
+		<a href="/mailarchiveserver/archive.html">archive</a>
+<%		
+		var name = [];
+		var href = [];
+		var node = currentNode;
+		var folding = false;
+		var fname = "";
+		var fhref = "";
+		while (node.getName() != "archive") {
+			var rt = node["sling:resourceType"];
+			if (rt == "mailarchiveserver/list") 
+				folding = true;
+			
+			if (rt != undefined) {
+				if (!folding) {
+					name.push(node["jcr:text"]);
+					href.push(node.getPath()+".html");
+				} else {
+					fname += node["jcr:text"]+".";
+					if (fhref == "")
+						fhref = node.getPath()+".html";
+				}
+			}
+			node = node.getParent();
+		}
+		if (folding) {
+			name.push(fname.substring(0, fname.length-1));
+			href.push(fhref);
+		}
+
+		while (name.length > 0) {
+			out.print(" > <a href="+href.pop()+">"+name.pop()+"</a>");
+		}
+	}
+%>
+</div>
+
+<!-- SAERCH BAR -->
+
+<form method="GET" action="/mailarchiveserver/search.html" style="width: 40%; margin:
1em auto;">
+    <input type="text" name="q" style="width: 70%;" value='<%= request.getParameter('q')
? request.getParameter('q') : '' %>' /> 
+    <input type="submit" value="Search" style="width: 23%;" /> <span 
+title='You can search in the following ways
+(similar to Markmail)
+General terms:	server
+Or phrases: 	"latest news"
+Sender field:	from:"Roy Fielding", from:adobe.com
+Subject field:	subject:"how to"
+List field:		list:sling
+
+Search is NOT case sensitive, i.e. searching for list:oak and LIST:OAK will produce same
results.
+
+Constraints are ANDed together except in the case of multiple fielded constraints of the
same type which will be ORed together.
+'>(?)</span> <br> 
+</form>

Added: sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/root/html.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/root/html.esp?rev=1553094&view=auto
==============================================================================
--- sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/root/html.esp
(added)
+++ sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/root/html.esp
Mon Dec 23 11:11:15 2013
@@ -0,0 +1,26 @@
+<html>
+
+<head>
+<%
+	load("../head.esp"); 
+	if (! request.getRequestParameter("noredirect") ) {
+		response.sendRedirect(startPage)
+	}
+%>
+	<title>Mail Archive Server</title>
+</head>
+
+<body>
+	<div class="content">
+		<h1>Welcome to the Mail Archive Server!</h1> <br>
+
+		<dl>
+		  <dt>Choose what you want to do:</dt> <br>
+		  <dd><a href="<%= currentNode.getPath() %>/import.mbox.html">Import
mbox file to the archive</a></dd> <br>
+		  <dd><a href="<%= currentNode.getPath() %>/archive.html">Browse archive</a></dd>
<br>
+		  <dd><a href="<%= currentNode.getPath() %>/search.html">Search archive</a></dd>
<br>
+		</dl>
+	</div>
+</body>
+
+</html>

Added: sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/search/html.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/search/html.esp?rev=1553094&view=auto
==============================================================================
--- sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/search/html.esp
(added)
+++ sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/search/html.esp
Mon Dec 23 11:11:15 2013
@@ -0,0 +1,31 @@
+<html>
+
+<head>
+<% load("../head.esp"); %>
+<title>Search mail archive</title>
+</head>
+
+<body>
+	<% sling.include(currentNode.getPath(), "forceResourceType=mailarchiveserver,replaceSelectors=navbar");
%>
+
+	<div class="content">
+<%
+	var phrase = request.getParameter("q")
+	if (phrase) {
+		var service = sling.getService(Packages.org.apache.sling.mailarchiveserver.api.SearchService)

+		var resIter = service.find(phrase)
+		var renderer = new OrderedRenderer(dateComparator, "forceResourceType=mailarchiveserver/message,replaceSelectors=preview")
+		while (resIter.hasNext()) {
+			var resource = resIter.next()
+			var node = resource.adaptTo(Packages.javax.jcr.Node)
+			renderer.addMsg(node)
+		}
+		out.print("Found " + renderer.list.length + " messages <br>")
+		renderer.sort()
+		renderer.render()
+	}
+%>
+	</div>
+</body>
+
+</html>

Added: sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/styles.css
URL: http://svn.apache.org/viewvc/sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/styles.css?rev=1553094&view=auto
==============================================================================
--- sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/styles.css
(added)
+++ sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/styles.css
Mon Dec 23 11:11:15 2013
@@ -0,0 +1,49 @@
+/*
+ * Modified version of slingbucks styles:
+ * http://svn.apache.org/repos/asf/sling/trunk/samples/slingbucks/src/main/resources/SLING-CONTENT/apps/slingbucks/common/slingbucks.css
+ */
+
+body {
+  font-family: Georgia, Verdana, Arial, Sans-Serif;
+}
+
+.message {
+  margin-bottom: 1em;
+  border: solid #CCCCCC 1px;
+  padding: 1em;
+}
+
+.header {
+  font-size:120%;
+  margin-bottom: 1em;
+  padding-bottom: 0.5em;
+  border-bottom: solid thin blue;
+  text-align: justify;
+}
+
+.from, .date {
+  font-weight: bold;
+}
+
+.date {
+  float: right;
+}
+
+.content {
+  width:75%;
+  margin:1em auto;
+}
+
+.navbar {
+  margin: 1em;
+}
+
+.nolinkstyle {
+  color: inherit;
+  text-decoration: none;
+}
+
+.bodypreview {
+  margin-top: 1em;
+  font-size:80%;
+}
\ No newline at end of file

Added: sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/thread/html.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/thread/html.esp?rev=1553094&view=auto
==============================================================================
--- sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/thread/html.esp
(added)
+++ sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/thread/html.esp
Mon Dec 23 11:11:15 2013
@@ -0,0 +1,25 @@
+<html>
+	<head>
+	<% load("../head.esp"); %>
+	<title>
+	<%= currentNode["jcr:text"] %>
+	</title>
+	</head>
+
+	<body>
+
+		<% sling.include(currentNode.getPath(), "forceResourceType=mailarchiveserver,replaceSelectors=navbar");
%>
+
+		<h2> <%= currentNode["jcr:text"] %> </h2>
+		
+		<%
+		var messages = currentNode.getChildren()
+		for(i in messages) {
+			var m = messages[i]
+		%>
+		
+		<% sling.include(m.getPath(), "replaceSelectors=preview"); %>
+	
+		<%}%>
+	</body>
+</html>

Added: sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/util.js
URL: http://svn.apache.org/viewvc/sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/util.js?rev=1553094&view=auto
==============================================================================
--- sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/util.js
(added)
+++ sling/trunk/samples/mail-archive/ui/src/main/resources/initial-content/apps/mailarchiveserver/util.js
Mon Dec 23 11:11:15 2013
@@ -0,0 +1,11 @@
+function toHtmlString (str) {
+	var newstr = str.replace(/\ufffd/g, "").replace(/\&/g, "&amp;").replace(/\</g,
"&lt;").replace(/\>/g, "&gt;").replace(/\"/g, "&quot;");
+	return newstr;
+}
+
+// author Rafael
+// taken from http://stackoverflow.com/questions/831030/how-to-get-get-request-parameters-in-javascript
+function getRequestParam (name) {
+   if (name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
+      return decodeURIComponent(name[1]);
+}



Mime
View raw message