On 11/03/2009 01:34 PM, anamarias (SVN) wrote:
> Author: anamarias
> Date: 2009-11-03 13:34:40 +0100 (Tue, 03 Nov 2009)
> New Revision: 24799
>
> Log:
> advanced q&a app
>
> Added: sandbox/applications/xwiki-application-qa/pom.xml
> ===================================================================
> --- sandbox/applications/xwiki-application-qa/pom.xml                         
> (rev 0)
> +++ sandbox/applications/xwiki-application-qa/pom.xml 2009-11-03 12:34:40 UTC 
> (rev 24799)
> @@ -0,0 +1,14 @@
> +<project xmlns="http://maven.apache.org/POM/4.0.0"; 
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
> http://maven.apache.org/maven-v4_0_0.xsd";>
> +<parent>
> +<artifactId>xwiki-applications</artifactId>
> +<groupId>com.xpn.xwiki.platform.applications</groupId>
> +<version>15</version>
> +</parent>
> +<modelVersion>4.0.0</modelVersion>
> +<groupId>com.xpn.xwiki.platform.applications</groupId>
> +<artifactId>xwiki-application-qa</artifactId>
> +<packaging>xar</packaging>
> +<name>XWiki Platform - Applications - Question&Answers</name>
> +<version>1.0-SNAPSHOT</version>
> +<description>Q&A Application</description>

Q&A is not valid XML. The XML parser used by Maven complains about it 
and fails to build.

> +</project>
>
> Added: 
> sandbox/applications/xwiki-application-qa/src/main/resources/QA/QASearch.xml
> ===================================================================
> --- 
> sandbox/applications/xwiki-application-qa/src/main/resources/QA/QASearch.xml  
>                             (rev 0)
> +++ 
> sandbox/applications/xwiki-application-qa/src/main/resources/QA/QASearch.xml  
>     2009-11-03 12:34:40 UTC (rev 24799)
> @@ -0,0 +1,88 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +
> +<xwikidoc>
> +<web>QA</web>
> +<name>QASearch</name>
 > [snip]
> +{{html clean="false" wiki="true"}}
> += $msg.get('qa.search.title') =
> +
> +&lt;form action=""&gt;

Please don't use a table here. Tables are supposed to be used only for 
data that semantically belongs in a table.

> +&lt;table&gt;
> +&lt;tr&gt;
> +&lt;td&gt;
> +&lt;input type="text" name="text" value="$!request.text" size="40"/&gt;

Use $xwiki.getXMLEncoded($!{requesttext}) to prevent cross-site 
scripting and broken layout if the user enters some quotes.

> +&lt;/td&gt;
> +&lt;td&gt;
> +&lt;input type="submit" 
> value="$msg.get('qa.search.submit.button.value')"/&gt;

In general we wrapp all buttons with <span class="buttonwrapper">

> +&lt;/td&gt;
> +&lt;/tr&gt;
> +&lt;/table&gt;
> +&lt;/form&gt;
> +&lt;p/&gt;
> +#if($request.getParameter("text"))
> +  #set($text = $request.getParameter("text"))
> +#else
> +  #set($text = "")
> +#end

Shorter variant:
#set($text = "$!{request.getParameter('text')")

> +

This is strange, why are you doing it like this?

> +#set($space = "$doc.space")
> +{{include document="${space}Code.WebSearchCode"/}}
> +{{include document="XWiki.Results"/}}

> +{{/html}}
> +{{/velocity}}
> +</content></xwikidoc>
> \ No newline at end of file
>
>
> Added: 
> sandbox/applications/xwiki-application-qa/src/main/resources/QA/WebHome.xml
> ===================================================================
> --- 
> sandbox/applications/xwiki-application-qa/src/main/resources/QA/WebHome.xml   
>                             (rev 0)
> +++ 
> sandbox/applications/xwiki-application-qa/src/main/resources/QA/WebHome.xml   
>     2009-11-03 12:34:40 UTC (rev 24799)
> @@ -0,0 +1,252 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +
> +<xwikidoc>
> +<web>QA</web>
> +<name>WebHome</name>
> [snip]

You should use the current color theme for styling.

> +<code>.qaSearchContainer, .qaAddContainer {
> +  background-color:#EFF6D7;
> +  padding:10px;
> +  margin-bottom:10px;
> +}
> +
> +.qaAddContainer {
> +  background-color:#FFFACD;
> +}
> +
> +.qaSearch, .qaAdd {
> +  font-size:1.5em;
> +  font-weight:bold;
> +  line-height:2.5em; 
> +}
> +
> +.qaSearchName, .qaAddName {
> +  display: inline;
> +  color:#B5C742;
> +}
> +
> +.qaAddName {
> +  color:#E78013;
> +}
> +
> +.qaSearchValue, .qaAddValue {
> +  display: inline;
> +  margin: 0;
> +}
> +
> +.qaSearchValue form, .qaAddValue form {
> +  display: inline;
> +}
> +
> +.qaSearchValue form input[type="text"], .qaAddValue form input[type="text"] {
> +  font-size:0.9em;

px heights are not good. They don't scale well if the user increases the 
font size, or if his OS in general uses a different DPI.

> +  height:20px;
> +}
> +
> +.qaSearchValue form input[type="submit"], .qaAddValue form 
> input[type="submit"] {
> +  color:#4D4D4D;
> +  font-size:0.6em;
> +  height:26px;
> +}
> +</code></property><property><name></name></property><property><parse>0</parse>
> +</property>
> +<property>
 > [snip]
> +<content>{{include document="QACode.Macros" /}}
> +{{velocity filter="none"}}
> +## QA variables
> +#set($qaSpace = "$doc.space")
> +#set($qaWebHome = "${qaSpace}.WebHome")
> +#set($qaClassName = "${qaSpace}Code.${qaSpace}Class")
> +#set($qaSheet = "${qaSpace}Code.${qaSpace}Sheet")
> +#set($qaTemplate = "${qaSpace}Code.${qaSpace}Template")
> +#set($qaSearch = "${qaSpace}.${qaSpace}Search")
> +##
> +$xwiki.ssx.use("$qaWebHome")
> +##
> +{{html clean="false" wiki="true"}}
> += $msg.get('qa.webhome.title') =
> +## ---------------------------------------------------
> +## Let the user search for QAs
> +## ---------------------------------------------------
> +&lt;div class='qaSearchContainer'&gt;
> +&lt;div class='qaSearch'&gt;
> +&lt;div class='qaSearchName'&gt;Search:&lt;/div&gt;
> +&lt;div class='qaSearchValue'&gt;
> +&lt;form action="$xwiki.getURL("${qaSearch}")"&gt;

Not valid XHTML, since a form can contain only block level elements. You 
must wrap the input elements in a <div> or <fieldset>.

> +&lt;input type="text" name="text" value="$!request.text" size="40"/&gt;

Again, use a buttonwrapper.

> +&lt;input type="submit" 
> value="$msg.get('qa.webhome.search.submit.button.value')"/&gt;
> +&lt;/form&gt;
> +&lt;/div&gt;
> +&lt;/div&gt;
> +&lt;/div&gt;
> +## ---------------------------------------------------
> +## Let the user add QAs
> +## ---------------------------------------------------
> +&lt;div class='qaAddContainer'&gt;
> +&lt;div class='qaAdd'&gt;
> +&lt;div class='qaAddName'&gt;Submit:&lt;/div&gt;
> +&lt;div class='qaAddValue'&gt;
> +&lt;form action="" id="newqa"&gt;

Use a block wrapper for validity.

> +&lt;input type="hidden" name="parent" value="${qaWebHome}" /&gt;
> +&lt;input type="hidden" name="template" value="${qaTemplate}" /&gt;
> +&lt;input type="hidden" name="sheet" value="1" /&gt;
> +&lt;input type="hidden" name="webname" value="${qaSpace}"/&gt;
> +&lt;input type="hidden" name="name" value=""/&gt;
> +&lt;input type="text" name="qa" value="" size="40"/&gt;

I know that the following code is copied from another XWiki document, 
but it is not OK to use onclick.

> +&lt;input type="submit" 
> value="$msg.get('qa.webhome.add.submit.button.value')" onclick='if 
> (updateName(this.form.qa,this.form.name)) { action="../../inline/" + 
> this.form.webname.value + "/" + this.form.name.value; this.form.submit(); }' 
> /&gt;
> +&lt;/form&gt;
> +&lt;/div&gt;
> +&lt;/div&gt;
> +&lt;/div&gt;
> +
> +## Display Question Class admin button only for users with admin rights on 
> the current space
> +#if($xwiki.hasAdminRights())
> +Questions Class:&lt;a href='${xwiki.getURL("$qaClassName", 'edit', 
> 'editor=class')}'&gt;Edit Question Class Properties (Metadata)&lt;/a&gt;
> +#end
> +##
> +## ---------------------------------------------------
> +## Livetable for QA entries that have answers
> +## ---------------------------------------------------
> +== $msg.get('qa.answered.title') ==
> +#qaLiveGrid("ansqadiv" "$doc.space" true)
> +##
> +## ----------------------------------------------------
> +## Livetable for QA entries that have no answers yet
> +## ----------------------------------------------------
> +== $msg.get('qa.notanswered.title') ==
> +#qaLiveGrid("notansqadiv" "$doc.space" false)
> +
> +{{/html}}
> +{{/velocity}}</content>
> +</xwikidoc>
>
>
> Property changes on: 
> sandbox/applications/xwiki-application-qa/src/main/resources/QA/WebHome.xml
> ___________________________________________________________________
> Name: svn:executable
>     + *

Why executable?

> Name: svn:keywords
>     + Author Id Revision HeadURL
> Name: svn:eol-style
>     + native
>
> Added: 
> sandbox/applications/xwiki-application-qa/src/main/resources/QACode/Install.xml
> ===================================================================
> --- 
> sandbox/applications/xwiki-application-qa/src/main/resources/QACode/Install.xml
>                            (rev 0)
> +++ 
> sandbox/applications/xwiki-application-qa/src/main/resources/QACode/Install.xml
>    2009-11-03 12:34:40 UTC (rev 24799)
> @@ -0,0 +1,80 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +
> +<xwikidoc>
> +<web>QACode</web>
> +<name>Install</name>
>  [snip]
> +<content>{{velocity}}
> +#if(!$xwiki.hasAdminRights())
> +You are running this script as a non admin. It will have no effect. Login as 
> admin.
> +#end
> +
> +#set($transdoc = $xwiki.getDocument("XWiki.XWikiPreferences"))
> +#set($ok = $transdoc.use("XWiki.XWikiPreferences"))
> +#set($transprefs = $transdoc.getValue("documentBundles"))

RecruitmentCode.Translations?

> +#if($transprefs.indexOf("RecruitmentCode.Translations")==-1)
> +#if($request.confirm=="1")
> +#set($transprefs = "${transprefs},QACode.Translations")
> +#set($ok = $transdoc.set("documentBundles", $transprefs))
> +#set($ok = $transdoc.save())
> +#end

This message should be before the #end above.

> +* Added translation bundle to XWiki Preferences

Add an "everything OK" like message to let the user know that no work 
needs to be done.

> +#end
> +

Put this on an #else branch with a link back with a confirm=1 query 
paraeter (if the current user has admin rights).

> +1.1 Additional Install steps
> +The page "QACode.Translations" also needs to be added to the translations 
> bundles in the XWiki Preferences / Programming section.
> +{{/velocity}}</content>
> +</xwikidoc>
>
>
> Added: 
> sandbox/applications/xwiki-application-qa/src/main/resources/QACode/QAClass.xml
> ===================================================================
> --- 
> sandbox/applications/xwiki-application-qa/src/main/resources/QACode/QAClass.xml
>                            (rev 0)
> +++ 
> sandbox/applications/xwiki-application-qa/src/main/resources/QACode/QAClass.xml
>    2009-11-03 12:34:40 UTC (rev 24799)
> @@ -0,0 +1,139 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +
> +<xwikidoc>
> +<web>QACode</web>
> +<name>QAClass</name>
 > [snip]
> +<class>
> +<answer>
> +</answer>
> +<country>

Why does a QA application need a country?

> +</country>
> +<fabrication>

Strange word in this context...

> +</fabrication>
> +<pays>

Who's paying?

> +</pays>
> +<question>

A problem with the StringClass is that it can only hold 255 characters. 
Do you think it's enough?

> +<classType>com.xpn.xwiki.objects.classes.StringClass</classType>
> +</question>
> +</class>
>
> Added: 
> sandbox/applications/xwiki-application-qa/src/main/resources/QACode/QASheet.xml
> ===================================================================
> --- 
> sandbox/applications/xwiki-application-qa/src/main/resources/QACode/QASheet.xml
>                            (rev 0)
> +++ 
> sandbox/applications/xwiki-application-qa/src/main/resources/QACode/QASheet.xml
>    2009-11-03 12:34:40 UTC (rev 24799)
> @@ -0,0 +1,261 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +
> +<xwikidoc>
> +<web>QACode</web>
> +<name>QASheet</name>
 > [snip]
> +<property>
> +<cache></cache>
> +</property>
> +<property>

Again, use the color theme.

> +<code>.qaContainer {
> +  background-color:#EFF6D7;
> +  padding:10px;
> +}
> +
> +.qaQuestionContainer {
> +  font-size:1.5em;
> +  font-weight:bold;
> +  line-height:2.5em; 
> +}
> +
> +.qaQuestionName {
> +  color:#B5C742;
> +}
> +
> +.qaQuestionValue { }
> +
> +.qaMetadataContainer {
> +  margin-left:40px;
> +}
> +
> +.qaAnswerContainer {
> +  border: 1px solid #D7D7D7;
> +  padding:10px;
> +  margin-top:10px;
> +}
> +
> +.qaAnswerName {
> +  color:#003399;
> +  font-size:1.5em;
> +  font-weight:bold;
> +}
> +
> +.qaAnswerValue { }
> +
> +.qaUnansweredContainer {
> +  padding: 20px 40px;
> +}
> +
> +.floatRight {
> +  float: right;
> +}
> +
> +.qaQuestionValue pre {
> +  display: inline
> +}
> +</code></property><property><name></name></property><property><parse>0</parse>
> +</property>
> +<property>
> +<use>onDemand</use>
> +</property>
> +</object>
> +<content>{{velocity filter="none"}}
> +#set($qaSpace = "$doc.space")
> +#set($qaClassName = "${qaSpace}Code.${qaSpace}Class")
> +#set($qaSheet = "${qaSpace}Code.${qaSpace}Sheet")
> +## CSS Stylesheet
> +$xwiki.ssx.use("$qaSheet")
> +##
> +{{html clean="false" wiki="true"}}
> +##
> +#set($qaObject = $doc.getObject("$qaClassName"))
> +#set($qaClass = $qaObject.xWikiClass)
> +##
> +## QA properties

.Value looks strange to me (C#). It's either .value or .getValue().

> +#set($qaQuestion = $qaObject.getProperty('question').Value)
> +#set($qaAnswer = $qaObject.getProperty('answer').Value)
> += $qaQuestion =
> +&lt;div class='qaContainer'&gt;
> +&lt;div class='qaQuestionContainer'&gt;
> +&lt;span class='qaQuestionName'&gt;Q:&lt;/span&gt;
> +&lt;span class='qaQuestionValue'&gt;$doc.display('question')&lt;/span&gt;
> +&lt;/div&gt;
> +&lt;div class='qaMetadataContainer'&gt;
> +    #foreach($prop in $qaClass.properties)
> +      #set($propName = $prop.Name)
> +      #if($propName != 'question'&amp;&amp; $propName != 'answer')
> +        ; $prop.prettyName
> +        : $doc.display($prop.getName())
> +      #end
> +    #end
> +&lt;/div&gt;
> +&lt;/div&gt;
> +#if($qaAnswer!='' || $context.action=='inline' )
> +&lt;div class='qaAnswerContainer'&gt;
> +  #if($context.action=='view')
> +&lt;div class='floatRight'&gt;&lt;a 
> href="$doc.getURL('inline')"&gt;[Improve]&lt;/a&gt;&lt;/div&gt;
> +  #end

Too much HTML.

> +&lt;div class='qaAnswerName'&gt;A:&lt;/div&gt;
> +&lt;div class='qaAnswerValue'&gt;$doc.display('answer')&lt;/div&gt;
> +&lt;/div&gt;
> +#else
> +&lt;div class='qaUnansweredContainer'&gt;
> +&lt;b&gt;This question has not been answered yet.&lt;/b&gt;&lt;br /&gt;

And what am I supposed to do with this button if I don't have JavaScript 
enabled? What's wrong with a plain link?

> +&lt;input type="button" value="A: Answer Question" 
> onclick="window.location.href='$doc.getURL('inline')'" /&gt;
> +&lt;/div&gt;
> +#end
> +{{/html}}
> +{{/velocity}}</content>
> +</xwikidoc>
>
>
> Added: 
> sandbox/applications/xwiki-application-qa/src/main/resources/QACode/Translations.xml
> ===================================================================
> --- 
> sandbox/applications/xwiki-application-qa/src/main/resources/QACode/Translations.xml
>                               (rev 0)
> +++ 
> sandbox/applications/xwiki-application-qa/src/main/resources/QACode/Translations.xml
>       2009-11-03 12:34:40 UTC (rev 24799)
> @@ -0,0 +1,82 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +
> +<xwikidoc>
> +<web>QACode</web>
> +<name>Translations</name>
> [snip]
> +<content>qa.webhome.title=Questions&amp; Answers
> +qa.webhome.search.title=In order to find the information you're looking for, 
> you can use the search feature of your browser to search for QA entries 
> displayed on this page or use the search box below.
> +qa.webhome.search.submit.button.value=Go!
> +qa.webhome.add.title=If you don't find the QA you're looking for, create a 
> new QA using the following form and fill the answer once you've found it!
> +qa.webhome.add.submit.button.value=Add this QA
> +qa.webhome.table.answered.title={0} Answered QAs (latest first)
> +qa.webhome.table.notanswered.title={0} Unanswered QAs (latest first)
> +
> +qa.search.title=QA Search
> +qa.search.submit.button.value=Search QAs
> +

Where are these used?

> +qa.class.property.qa.question=Question
> +qa.class.property.qa.answer=Answer
> +qa.class.property.qa.country=Country
> +qa.class.property.qa.doc.date=Last Edited
> +qa.class.property.qa.doc.author=Last Author
> +qa.class.property.qa.doc.name=Questions
> +qa.class.property.qa.emptyvalue=-
> +qa.class.property.qa._actions=Actions
> +
> +qa.answered.title=Answered QAs
> +qa.notanswered.title=Unanswered QAs</content>
> +</xwikidoc>
>
>
> Added: 
> sandbox/applications/xwiki-application-qa/src/main/resources/QACode/WebHome.xml
> ===================================================================
> --- 
> sandbox/applications/xwiki-application-qa/src/main/resources/QACode/WebHome.xml
>                            (rev 0)
> +++ 
> sandbox/applications/xwiki-application-qa/src/main/resources/QACode/WebHome.xml
>    2009-11-03 12:34:40 UTC (rev 24799)
> @@ -0,0 +1,61 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +
> +<xwikidoc>
> +<web>QACode</web>
> +<name>WebHome</name>
 > [snip]
> +<content></content>

A document with no content at all is not nice. At least put a short 
message explaining what the space is for.

> +</xwikidoc>

-- 
Sergiu Dumitriu
http://purl.org/net/sergiu/
_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to