Author: shane.bryzak(a)jboss.com
Date: 2010-06-15 20:24:00 -0400 (Tue, 15 Jun 2010)
New Revision: 6435
Modified:
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/CodeEntity.java
examples/trunk/jsf/pastecode/src/main/webapp/rightMenuDefault.xhtml
examples/trunk/jsf/pastecode/src/main/webapp/style/style.css
Log:
started on style changes
Modified:
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/CodeEntity.java
===================================================================
---
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/CodeEntity.java 2010-06-15
07:22:26 UTC (rev 6434)
+++
examples/trunk/jsf/pastecode/src/main/java/org/jboss/weld/examples/pastecode/model/CodeEntity.java 2010-06-16
00:24:00 UTC (rev 6435)
@@ -31,6 +31,9 @@
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Lob;
+import javax.persistence.Transient;
+
+import java.text.SimpleDateFormat;
import java.util.Date;
/**
@@ -41,6 +44,13 @@
@Table(name = "code")
public class CodeEntity implements Serializable, Cloneable
{
+ private static final long MS_PER_SECOND = 1000;
+ private static final long MS_PER_MINUTE = 60 * MS_PER_SECOND;
+ private static final long MS_PER_HOUR = 60 * MS_PER_MINUTE;
+ private static final long MS_PER_DAY = 24 * MS_PER_HOUR;
+
+ private static final SimpleDateFormat df = new SimpleDateFormat("d MMM");
+
private static final long serialVersionUID = 1L;
private int id;
private Date datetime;
@@ -95,6 +105,60 @@
{
this.datetime = datetime;
}
+
+ @Transient
+ public String getFriendlyDate()
+ {
+ if (getDatetime() == null) return "unknown";
+
+ Date now = new Date();
+
+ long age = now.getTime() - getDatetime().getTime();
+
+ long days = (long) Math.floor(age / MS_PER_DAY);
+ age -= (days * MS_PER_DAY);
+ long hours = (long) Math.floor(age / MS_PER_HOUR);
+ age -= (hours * MS_PER_HOUR);
+ long minutes = (long) Math.floor(age / MS_PER_MINUTE);
+
+ if (days < 7)
+ {
+ StringBuilder sb = new StringBuilder();
+
+ if (days > 0)
+ {
+ sb.append(days);
+ sb.append(days > 1 ? " days " : " day ");
+ }
+
+ if (hours > 0)
+ {
+ sb.append(hours);
+ sb.append(hours > 1 ? " hrs " : " hr ");
+ }
+
+ if (minutes > 0)
+ {
+ sb.append(minutes);
+ sb.append(minutes > 1 ? " minutes " : " minute ");
+ }
+
+ if (hours == 0 && minutes == 0)
+ {
+ sb.append("just now");
+ }
+ else
+ {
+ sb.append("ago");
+ }
+
+ return sb.toString();
+ }
+ else
+ {
+ return df.format(getDatetime());
+ }
+ }
@Column(name = "language")
public String getLanguage()
Modified: examples/trunk/jsf/pastecode/src/main/webapp/rightMenuDefault.xhtml
===================================================================
--- examples/trunk/jsf/pastecode/src/main/webapp/rightMenuDefault.xhtml 2010-06-15
07:22:26 UTC (rev 6434)
+++ examples/trunk/jsf/pastecode/src/main/webapp/rightMenuDefault.xhtml 2010-06-16
00:24:00 UTC (rev 6435)
@@ -5,38 +5,19 @@
xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition>
-
- <div id="rightmenuhead" style="width:230px;">
- <strong>Last Pastes:</strong>
- </div>
- <div id="rightmenubody" style="width:230px;">
- <h:dataTable value="#{paster.codes}" var="varcode">
- <h:column>
- <h:panelGroup>
- <h:outputLabel for="user" value="User: "/>
- <h:outputLink id="user" value="#{
varcode.id}"> <!-- display.jsf?id= -->
- <h:outputText
value="#{varcode.user}"></h:outputText>
- </h:outputLink>
- </h:panelGroup>
- <br/>
- <h:panelGroup>
- <h:outputLabel for="datetime" value="Date:
"/>
- <h:outputText id="datetime" value="#{
varcode.datetime}">
- <f:convertDateTime type="both"
pattern="yyyy-MM-dd HH:mm:ss"/>
- </h:outputText>
- </h:panelGroup>
- <br/>
- <h:panelGroup>
- <h:outputLabel for="language" value="Language:
"/>
- <h:outputText id="language" value="#{
varcode.language}"></h:outputText>
- </h:panelGroup>
- <br/>
- <br/>
- </h:column>
- </h:dataTable>
+ <div class="recentPastes">
+ <div class="recentPastesHeader">Recent pastes</div>
+
+ <ui:repeat value="#{paster.codes}" var="varcode">
+ <div class="recentPaste">
+ <h:outputLink id="user"
value="#{varcode.id}">#{varcode.user}</h:outputLink>
+ <span
class="recentPasteLang">#{varcode.language}</span><span> |
</span>#{varcode.friendlyDate}
+ </div>
+ </ui:repeat>
+
</div>
</ui:composition>
-</html>
\ No newline at end of file
+</html>
Modified: examples/trunk/jsf/pastecode/src/main/webapp/style/style.css
===================================================================
--- examples/trunk/jsf/pastecode/src/main/webapp/style/style.css 2010-06-15 07:22:26 UTC
(rev 6434)
+++ examples/trunk/jsf/pastecode/src/main/webapp/style/style.css 2010-06-16 00:24:00 UTC
(rev 6435)
@@ -2,7 +2,8 @@
margin: 0px;
padding: 0px;
border-width: 0px;
- background-color: #FFFFFF;
+ background-color: #cccccc;
+ font-family:trebuchet MS, Lucida Sans Unicode, Lucida Sans, Sans-Serif;
}
table {
@@ -52,17 +53,6 @@
text-align: center;
}
-div#rightmenuhead {
- background-color:#C1C1E8;
- border-color:#8784C6;
- border-width:1px;
- padding:2px;
-}
-
-div#rightmenubody {
- padding:2px;
-}
-
span#menuitem {
margin: 2px;
padding-left: 7px;
@@ -100,6 +90,46 @@
}
+/** Recent pastes styles */
+div.recentPastes {
+ width: 230px;
+ background-color: #ffffff;
+ padding: 0px;
+ border: 0px;
+}
+div.recentPastesHeader {
+ background-color: #bbbbbb;
+ color: #000000;
+ font-weight: bold;
+ padding: 4px;
+ border: 0px;
+}
+div.recentPaste {
+ border-bottom: 1px dotted #aaaaaa;
+ border-left: 0px;
+ border-right: 0px;
+ color: #aaaaaa;
+ padding: 2px;
+}
+
+div.recentPaste a, div.recentPaste a:visited {
+ color: #ff0000;
+ text-decoration: none;
+ display: block;
+}
+
+div.recentPaste a:hover {
+ color: #aaaaaa;
+ text-decoration: none;
+ display: block;
+}
+
+span.recentPasteLang {
+ color: #000000;
+}
+
+
+