r7253 - in dumbhippo/trunk: openfire/src/plugins/hippo/src/java/com/dumbhippo/jive server/src/com/dumbhippo/server/blocks server/src/com/dumbhippo/server/dm server/src/com/dumbhippo/server/impl server/web/tags/3
- From: commits mugshot org
- To: online-desktop-list gnome org
- Subject: r7253 - in dumbhippo/trunk: openfire/src/plugins/hippo/src/java/com/dumbhippo/jive server/src/com/dumbhippo/server/blocks server/src/com/dumbhippo/server/dm server/src/com/dumbhippo/server/impl server/web/tags/3
- Date: Wed, 23 Jan 2008 18:37:57 -0600 (CST)
Author: marinaz
Date: 2008-01-23 18:37:56 -0600 (Wed, 23 Jan 2008)
New Revision: 7253
Added:
dumbhippo/trunk/server/web/tags/3/accountQuestionBlock.tag
Modified:
dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/AccountQuestionIQHandler.java
dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/BlocksIQHandler.java
dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestion.java
dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockHandlerBean.java
dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockView.java
dumbhippo/trunk/server/src/com/dumbhippo/server/dm/AccountQuestionBlockDMO.java
dumbhippo/trunk/server/src/com/dumbhippo/server/impl/StackerBean.java
dumbhippo/trunk/server/web/tags/3/block.tag
Log:
Include account questions in the user's stacker on the web.
Append unanswered account questions to the front of the stacker.
Still need to make sure that unanswered account questions do not appear
in their regular position in the stacker, tweak how they look, and test
processing a response to them.
Modified: dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/AccountQuestionIQHandler.java
===================================================================
--- dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/AccountQuestionIQHandler.java 2008-01-23 20:05:31 UTC (rev 7252)
+++ dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/AccountQuestionIQHandler.java 2008-01-24 00:37:56 UTC (rev 7253)
@@ -49,7 +49,7 @@
} catch (NotFoundException e) {
throw IQException.createBadRequest("blockId attribute doesn't point to a question for this user");
} catch (BadResponseCodeException e) {
- throw IQException.createBadRequest("response attribute had an expected value");
+ throw IQException.createBadRequest("response attribute had an unexpected value");
}
}
}
Modified: dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/BlocksIQHandler.java
===================================================================
--- dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/BlocksIQHandler.java 2008-01-23 20:05:31 UTC (rev 7252)
+++ dumbhippo/trunk/openfire/src/plugins/hippo/src/java/com/dumbhippo/jive/BlocksIQHandler.java 2008-01-24 00:37:56 UTC (rev 7253)
@@ -85,7 +85,7 @@
} catch (NotFoundException e) {
throw IQException.createBadRequest("blockId attribute doesn't point to a question for this user");
} catch (BadResponseCodeException e) {
- throw IQException.createBadRequest("response attribute had an expected value");
+ throw IQException.createBadRequest("response attribute had an unexpected value");
}
}
}
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestion.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestion.java 2008-01-23 20:05:31 UTC (rev 7252)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestion.java 2008-01-24 00:37:56 UTC (rev 7253)
@@ -35,7 +35,12 @@
}
@Override
- public String getMoreLink(String moreParam) {
+ public String getTitleLink(String linkParam) {
+ return null;
+ }
+
+ @Override
+ public String getMoreLink(String linkParam) {
return "/applications";
}
},
@@ -68,13 +73,19 @@
}
@Override
- public String getMoreLink(String moreParam) {
- return "http://www.facebook.com/add.php?api_key=" + moreParam;
+ public String getTitleLink(String linkParam) {
+ return "http://www.facebook.com/add.php?api_key=" + linkParam;
}
+
+ @Override
+ public String getMoreLink(String linkParam) {
+ return null;
+ }
};
abstract public String getTitle();
abstract public String getDescription(String answer);
abstract public AccountQuestionButton[] getButtons();
- abstract public String getMoreLink(String moreParam);
+ abstract public String getTitleLink(String linkParam);
+ abstract public String getMoreLink(String linkParam);
}
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockHandlerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockHandlerBean.java 2008-01-23 20:05:31 UTC (rev 7252)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockHandlerBean.java 2008-01-24 00:37:56 UTC (rev 7253)
@@ -92,7 +92,7 @@
protected void populateBlockViewImpl(AccountQuestionBlockView blockView) throws BlockNotVisibleException {
Viewpoint viewpoint = blockView.getViewpoint();
String answer = null;
- String moreParam = null;
+ String linkParam = null;
if (!(viewpoint instanceof SystemViewpoint || viewpoint.isOfUser(getData1User(blockView.getBlock()))))
throw new BlockNotVisibleException("AccountQuestion block only visible to the user it was sent to");
@@ -100,15 +100,15 @@
switch (blockView.getQuestion()) {
case APPLICATION_USAGE:
answer = getApplicationUsageAnswer(blockView);
- moreParam = "";
+ linkParam = "";
break;
case FACEBOOK_APPLICATION:
answer = getFacebookApplicationAnswer(blockView);
- moreParam = facebookSystem.getApiKey();
+ linkParam = facebookSystem.getApiKey();
break;
}
- blockView.populate(answer, moreParam);
+ blockView.populate(answer, linkParam);
}
public Set<Group> getInterestedGroups(Block block) {
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockView.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockView.java 2008-01-23 20:05:31 UTC (rev 7252)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/blocks/AccountQuestionBlockView.java 2008-01-24 00:37:56 UTC (rev 7253)
@@ -5,10 +5,10 @@
import com.dumbhippo.persistence.UserBlockData;
import com.dumbhippo.server.views.Viewpoint;
-public class AccountQuestionBlockView extends BlockView {
+public class AccountQuestionBlockView extends BlockView implements TitleBlockView {
private AccountQuestion question;
String answer;
- String moreParam;
+ String linkParam;
public AccountQuestionBlockView(Viewpoint viewpoint, Block block, UserBlockData ubd, boolean participated) {
super(viewpoint, block, ubd, participated);
@@ -25,9 +25,9 @@
}
}
- public void populate(String answer, String moreParam) {
+ public void populate(String answer, String linkParam) {
this.answer = answer;
- this.moreParam = moreParam;
+ this.linkParam = linkParam;
setPopulated(true);
}
@@ -41,6 +41,36 @@
return "/images3/star.png";
}
+ public String getTitleForHome() {
+ return getTitle();
+ }
+ public String getTitle() {
+ return getQuestion().getTitle();
+ }
+
+ public String getLink() {
+ return getQuestion().getTitleLink(linkParam);
+ }
+
+ public String getMoreLink() {
+ return getQuestion().getMoreLink(linkParam);
+ }
+
+ public String getDescription() {
+ return getQuestion().getDescription(answer);
+ }
+
+ public String getDescriptionAsHtml() {
+ String description = getDescription();
+ if (description.trim().length() > 0) {
+ XmlBuilder xml = new XmlBuilder();
+ xml.appendTextAsHtml(description, null);
+ return xml.toString();
+ } else {
+ return "";
+ }
+ }
+
@Override
public String getBlockSummaryHeading() {
return "New feature";
@@ -48,7 +78,10 @@
@Override
public String getBlockSummaryLink() {
- return getQuestion().getMoreLink(moreParam);
+ if (getLink() != null)
+ return getLink();
+
+ return getQuestion().getMoreLink(linkParam);
}
@Override
@@ -65,7 +98,7 @@
protected void writeDetailsToXmlBuilder(XmlBuilder builder) {
builder.openElement("accountQuestion",
"answer", answer,
- "moreLink", question.getMoreLink(moreParam));
+ "moreLink", question.getMoreLink(linkParam));
builder.appendTextNode("title", question.getTitle());
builder.appendTextNode("description", question.getDescription(answer));
@@ -91,8 +124,8 @@
return answer;
}
- public String getMoreParam() {
- return moreParam;
+ public String getLinkParam() {
+ return linkParam;
}
@Override
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/dm/AccountQuestionBlockDMO.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/dm/AccountQuestionBlockDMO.java 2008-01-23 20:05:31 UTC (rev 7252)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/dm/AccountQuestionBlockDMO.java 2008-01-24 00:37:56 UTC (rev 7253)
@@ -29,7 +29,7 @@
@DMProperty(defaultInclude=true, type=PropertyType.URL)
public String getMoreLink() {
- return ((AccountQuestionBlockView)blockView).getQuestion().getMoreLink(((AccountQuestionBlockView)blockView).getMoreParam());
+ return ((AccountQuestionBlockView)blockView).getQuestion().getMoreLink(((AccountQuestionBlockView)blockView).getLinkParam());
}
@DMProperty(defaultInclude=true)
Modified: dumbhippo/trunk/server/src/com/dumbhippo/server/impl/StackerBean.java
===================================================================
--- dumbhippo/trunk/server/src/com/dumbhippo/server/impl/StackerBean.java 2008-01-23 20:05:31 UTC (rev 7252)
+++ dumbhippo/trunk/server/src/com/dumbhippo/server/impl/StackerBean.java 2008-01-24 00:37:56 UTC (rev 7253)
@@ -1148,7 +1148,7 @@
expectedHitFactor = blocks.size() / resultItemCount + 1;
}
- List<BlockView> blockViewsToReturn;
+ List<BlockView> blockViewsToReturn;
if (stack.size() < targetedNumberOfItems) {
// this will readjust the position, so pageable.getStart() will be readjusted too
pageable.setTotalCount(stack.size());
@@ -1165,7 +1165,7 @@
for (BlockView blockView : blockViewsToReturn) {
populateBlockView(blockView);
}
-
+
pageable.setResults(blockViewsToReturn);
}
@@ -1189,7 +1189,7 @@
pageStack(viewpoint, new BlockSource<UserBlockData>() {
public List<Pair<Block, UserBlockData>> get(int start, int count) {
List<Pair<Block, UserBlockData>> results = new ArrayList<Pair<Block, UserBlockData>>();
- for (UserBlockData ubd : getBlocks(viewpoint, user, lastTimestamp, -1, start, count, filter, participantOnly)) {
+ for (UserBlockData ubd : getBlocks(viewpoint, user, lastTimestamp, -1, start, count, filter, participantOnly)) {
results.add(new Pair<Block, UserBlockData>(ubd.getBlock(), ubd));
}
return results;
@@ -1198,6 +1198,9 @@
return prepareBlockView(viewpoint, block, ubd, participantOnly);
}
}, pageable, expectedHitFactor);
+
+ if (pageable.getPosition() == 0 && !participantOnly && viewpoint.isOfUser(user))
+ pageable.getResults().addAll(0, getUnansweredQuestions((UserViewpoint)viewpoint, System.currentTimeMillis()));
}
private static abstract class ItemSource<T> {
Added: dumbhippo/trunk/server/web/tags/3/accountQuestionBlock.tag
===================================================================
--- dumbhippo/trunk/server/web/tags/3/accountQuestionBlock.tag 2008-01-23 20:05:31 UTC (rev 7252)
+++ dumbhippo/trunk/server/web/tags/3/accountQuestionBlock.tag 2008-01-24 00:37:56 UTC (rev 7253)
@@ -0,0 +1,53 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="/jsp/dumbhippo.tld" prefix="dh" %>
+<%@ taglib tagdir="/WEB-INF/tags/2" prefix="dht" %>
+<%@ taglib tagdir="/WEB-INF/tags/3" prefix="dht3" %>
+
+<dh:script modules="dh.util,dh.server"/>
+<script type="text/javascript">
+ function dhAnswerAccountQuestion(blockId, response) {
+ dh.server.doPOST("answeraccountquestion",
+ { "blockId" : blockId,
+ "response" : response },
+ function(type, data, http) {
+ dh.util.refresh();
+ },
+ function(type, error, http) {
+ alert("Couldn't update your response.");
+ });
+ }
+</script>
+
+<%@ attribute name="block" required="true" type="com.dumbhippo.server.blocks.AccountQuestionBlockView" %>
+<%@ attribute name="offset" required="true" type="java.lang.Boolean" %>
+<%@ attribute name="blockId" required="true" type="java.lang.String" %>
+<%@ attribute name="showFrom" required="false" type="java.lang.Boolean" %>
+
+<c:set var="hasDescription" value="${dh:myInstanceOf(block, 'com.dumbhippo.server.blocks.TitleDescriptionBlockView') && block.description != ''}"/>
+
+<dht3:blockContainer cssClass="${offset ? 'dh-box-grey2' : 'dh-box-grey1'}" blockId="${blockId}" title="${block.title}" expandable="false">
+ <dht3:blockLeft block="${block}">
+ <dht3:simpleBlockTitle block="${block}" oneLine="${oneLine}" homeStack="false" spanClass="dh-stacker-block-title-generic"/>
+ <dht3:blockDescription blockId="${blockId}">${block.descriptionAsHtml}</dht3:blockDescription>
+ <c:if test="${block.moreLink != null}">
+ <div class="dh-thumbnail-block-more">
+ <jsp:element name="a">
+ <jsp:attribute name="href"><c:out value="${block.moreLink}"/></jsp:attribute>
+ <jsp:body>Read More</jsp:body>
+ </jsp:element>
+ </div>
+ </c:if>
+ <c:if test="${!oneLine && !chatHeader}">
+ <dht3:stackReason block="${block}" blockId="${blockId}"/>
+ <dht3:blockContent blockId="${blockId}">
+ <dht3:quipper block="${block}" blockId="${blockId}"/>
+ <dht3:chatPreview block="${block}" blockId="${blockId}"/>
+ </dht3:blockContent>
+ </c:if>
+ <form>
+ <c:forEach items="${block.question.buttons}" var="button">
+ <input type="button" value="${button.text}" onclick="dhAnswerAccountQuestion(${blockId},${button.response})"></input>
+ </c:forEach>
+ </form>
+ </dht3:blockLeft>
+</dht3:blockContainer>
\ No newline at end of file
Modified: dumbhippo/trunk/server/web/tags/3/block.tag
===================================================================
--- dumbhippo/trunk/server/web/tags/3/block.tag 2008-01-23 20:05:31 UTC (rev 7252)
+++ dumbhippo/trunk/server/web/tags/3/block.tag 2008-01-24 00:37:56 UTC (rev 7253)
@@ -48,7 +48,9 @@
<c:when test="${(dh:enumIs(block.blockType, 'AMAZON_REVIEW') || dh:enumIs(block.blockType, 'AMAZON_WISH_LIST_ITEM')) && !oneLine}">
<dht3:amazonBlock block="${block}" blockId="${blockId}" offset="${offset}" showFrom="${showFrom}" chatHeader="${chatHeader}"/>
</c:when>
-
+ <c:when test="${dh:enumIs(block.blockType, 'ACCOUNT_QUESTION')}">
+ <dht3:accountQuestionBlock block="${block}" blockId="${blockId}" offset="${offset}" showFrom="${showFrom}"/>
+ </c:when>
<%-- These next instanceof tests have to be in order of most to least specific, so we use the most elaborate display engine
we know how to use for a block --%>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]