Skip to content

Commit

Permalink
Item11571: split out "create new topic" form elements to a "component…
Browse files Browse the repository at this point in the history
…s" topic and reuse it on Sandbox.WebHome

git-svn-id: http://svn.foswiki.org/trunk@15012 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
ArthurClemens authored and ArthurClemens committed Jun 16, 2012
1 parent 4e5ea13 commit ec7bbce
Show file tree
Hide file tree
Showing 4 changed files with 239 additions and 45 deletions.
60 changes: 42 additions & 18 deletions core/data/Sandbox/WebHome.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,51 @@
---+!! %MAKETEXT{"Welcome to the [_1] web" args="<nop>%WEB%"}%
%MAKETEXT{"The [_1] web is the sandbox you can use for testing. Everybody is welcome to add or delete some stuff. It is recommended to walk through the [_2] to get a jumpstart on the [_3] tool. A good rule of thumb is to add at the end of the page and sign and date it with your [_4]." args="<b><nop>%WEB%</b>,%SYSTEMWEB%.TwentyMinuteTutorial,<nop>%WIKITOOLNAME%,%SYSTEMWEB%.WikiName"}%

<!--
To include a custom "create new topic" form on a page, see System.WebCreateNewTopicComponents
-->
%TWISTY{
link="%BUTTON{"Create a new topic" icon="add"}%%CLEAR%"
link="%BUTTON{"%MAKETEXT{"Create New Topic"}%" icon="add"}%%CLEAR%"
mode="div"
}%

<form action='%SCRIPTURLPATH{"edit"}%/%WEB%/'>
<input type="hidden" name="onlywikiname" value="on" />
<input type="hidden" name="t" value="%GMTIME{"$epoch"}%" />
<div class="foswikiFormSteps">
<div class="foswikiFormStep">
<h3 >%MAKETEXT{"Topic name"}% </h3>
<table cellpadding="0" cellspacing="0"><tr><td>
<input class="foswikiInputField" type="text" name="topic" id="topic" size="32" value="TestTopicAUTOINC0" />&nbsp;
</td><td>
%BUTTON{"%MAKETEXT{"Create topic"}%" type="submit"}%
%CLEAR%
</td></tr></table>
<div class="foswikiFormDescription">%MAKETEXT{"Use a topic name in %SYSTEMWEB%.WikiNotation"}% </div>
</div>
</div>
</form>
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="js"
}%
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="formstart"
}%
<div class="foswikiFormSteps">
<div class="foswikiFormStep">
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="topicname"
newtopic=""
placeholder="%MAKETEXT{"Topic name"}%"
}%
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="topicnamefeedback"
}%
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="wikiword"
}%
<div>%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="errorfeedback"
}%</div>
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="submit"
}%
</div>
</div>
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="formend"
}%
%ENDTWISTY%

---++ %MAKETEXT{"Recently changed topics"}%
Expand Down
157 changes: 157 additions & 0 deletions core/data/System/WebCreateNewTopicComponents.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
%META:TOPICINFO{author="ProjectContributor" date="1252413407" format="1.1" version="1"}%
%META:TOPICPARENT{name="WebHome"}%
---+!! <nop>%TOPIC%
This topic is meant for developers. It contains =INCLUDE= sections to build a "create new topic" form.

%TOC%

---++ Usage
---+++ Including the form (simple)
Create a form with an empty name field:
<verbatim>
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="newtopic"
newtopic=""
}%
</verbatim>

Create a form with an "auto increment" name:
<verbatim>
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="newtopic"
newtopic="TestTopicAUTOINC0"
}%
</verbatim>

---+++ Customizing the order and layout
See the component table below what parts you can use to construct a form.

This is the code used in the [[Sandbox.WebHome]] form:
<verbatim>
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="js"
}%
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="formstart"
}%
<div class="foswikiFormSteps">
<div class="foswikiFormStep">
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="topicname"
newtopic=""
}%
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="topicnamefeedback"
}%
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="wikiword"
}%
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="errorfeedback"
}%
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="submit"
}%
</div>
</div>
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="formend"
}%
</verbatim>

---++ List of components
| *Component* | *Description* |
| =js= | Includes necessary Javascript files |
| =formstart= | Opens the form |
| =topicname= | Topic name field |
| =topicnamefeedback= | Provides feedback on the automatically constructed topic name |
| =topicparent= | Input field with toggle to select list of topics in the current web to select as topic parent |
| =templatetopic= | Select list of template topics |
| =errorfeedback= | Provides feedback on why the submit button is disabled |
| =submit= | The submit button |
| =formend= | Closes the form |

<verbatim class="foswikiHidden">

%STARTSECTION{"newtopic"}%%INCLUDE{
"%TOPIC%"
section="js"
}%%INCLUDE{
"%TOPIC%"
section="formstart"
}%%INCLUDE{
"%TOPIC%"
section="topicname"
}%%INCLUDE{
"%TOPIC%"
section="submit"
}% %INCLUDE{
"%TOPIC%"
section="topicnamefeedback"
}%%INCLUDE{
"%TOPIC%"
section="errorfeedback"
}%%INCLUDE{
"%TOPIC%"
section="formend"
}%%ENDSECTION{"newtopic"}%


%STARTSECTION{"js"}%%TMPL:P{"JavascriptFiles/foswikiString"}%%TMPL:P{
"LIBJS"
id="JavascriptFiles/foswikiStringUnicodeChars"
requires="JavascriptFiles/foswikiString"
}%%TMPL:P{
"LIBJS"
id="JavascriptFiles/foswikiWebTopicCreator"
requires="JavascriptFiles/foswikiStringUnicodeChars"
}%%ADDTOZONE{"head"
tag="WebCreateNewTopicTemplate:META"
text="<noautolink><meta name='foswiki.webTopicCreator.nameFeedback' content='%MAKETEXT{"Topic will be named: "}%' />
<meta name='foswiki.webTopicCreator.errorFeedbackNoWikiName' content='<p class=\"foswikiGrayText\">%MAKETEXT{"Enter the topic name as WikiWord or check the allow non-Wiki Word box."}%</p>' />"
requires=""
}%%ENDSECTION{"js"}%

%STARTSECTION{"formstart"}%<form name="newtopicform" action="%SCRIPTURLPATH{manage}%/%BASEWEB%/" method="post">
<input type="hidden" name="action" value="create" />
<input type="hidden" name="onlynewtopic" value="on" />%ENDSECTION{"formstart"}%

%STARTSECTION{"topicname"}%<input type="text" class="foswikiInputField" name="topic" size="40" placeholder="%IF{
"defined placeholder"
then="%URLPARAM{"placeholder" default="%placeholder%"}%"
}%" value="%IF{
"defined newtopic"
then="%URLPARAM{"newtopic" default="%newtopic%"}%"
else="%BASETOPIC%"
}%" />%ENDSECTION{"topicname"}%

%STARTSECTION{"wikiword"}%%TMPL:P{"nonwikiword"}%%ENDSECTION{"wikiword"}%

%STARTSECTION{"topicnamefeedback"}%<span class="webTopicCreatorFeedback foswikiGrayText"><!--generated name will be put here--></span>%ENDSECTION{"topicnamefeedback"}%

%STARTSECTION{"topicparent"}%<input type='text' size='40' name='topicparent' class='foswikiInputField' value='%URLPARAM{topicparent}%' />&nbsp;<span class='foswikiUnvisited'><a href='#' class='pickparent'>%MAKETEXT{"Pick from a list"}%</a> <img src='%ICONURLPATH{"processing-bg"}%' alt='' class='foswikiHidden processing' /></span>%ENDSECTION{"topicparent"}%

%STARTSECTION{"templatetopic"}%<select name="templatetopic" class="foswikiSelect">%IF{"'%URLPARAM{"templatetopic"}%'" then='<option selected="selected">%URLPARAM{"templatetopic"}%</option>'}%<option value="">%MAKETEXT{"Default template"}%</option>%SEARCH{"name~'*Template'" scope="topic" topic="*Template" web="%BASEWEB%" excludetopic="*EditTemplate,*WebCreateNewTopicTemplate,*ViewTemplate" type="query" nonoise="on" format="<option value=\"$web.$topic\">$topic</option>"}%</select>%SEARCH{"name~'*Template'" scope="topic" topic="*Template" web="%BASEWEB%" limit="1" excludetopic="WebTopicEditTemplate,*WebCreateNewTopicTemplate,*ViewTemplate" type="query" nonoise="on" format=" <span class='foswikiUnvisited'>%POPUPWINDOW{
url="%SCRIPTURL{view}%/%SYSTEMWEB%/WebTemplateTopics?web=%BASEWEB%;template=viewplain"
template="viewplain"
toolbar="1"
label="%MAKETEXT{"View templates"}%"
}%</span>"}%%JQREQUIRE{"popupwindow"}%%ENDSECTION{"templatetopic"}%

%STARTSECTION{"errorfeedback"}%<div class='webTopicCreatorError'><!--generated name will be put here--></div>%ENDSECTION{"errorfeedback"}%<

%STARTSECTION{"submit"}%<input type="submit" class="foswikiSubmit" value='%MAKETEXT{"Create this topic"}%' />%ENDSECTION{"submit"}%

%STARTSECTION{"formend"}%</form>%ENDSECTION{"formend"}%

</verbatim>
66 changes: 39 additions & 27 deletions core/data/System/WebCreateNewTopicTemplate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
%{<verbatim class="tml">
===================================================
Create new topic template
This template uses parts from System.WebCreateNewTopicComponents.
===================================================
}%%TMPL:INCLUDE{"view"}%%{
---------------------------------------------------
Expand All @@ -23,19 +24,9 @@
---------------------------------------------------
script:topictemplate
---------------------------------------------------
}%%TMPL:DEF{"script:topictemplate"}%%TMPL:P{"JavascriptFiles/foswikiString"}%%TMPL:P{
"LIBJS"
id="JavascriptFiles/foswikiStringUnicodeChars"
requires="JavascriptFiles/foswikiString"
}%%TMPL:P{
"LIBJS"
id="JavascriptFiles/foswikiWebTopicCreator"
requires="JavascriptFiles/foswikiStringUnicodeChars"
}%%ADDTOZONE{"head"
tag="WebCreateNewTopicTemplate:META"
text="<noautolink><meta name='foswiki.webTopicCreator.nameFeedback' content='%MAKETEXT{"Topic will be named: "}%' />
<meta name='foswiki.webTopicCreator.errorFeedbackNoWikiName' content='%MAKETEXT{"Enter the topic name as WikiWord or check the allow non-Wiki Word box."}%' />"
requires=""
}%%TMPL:DEF{"script:topictemplate"}%%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="js"
}%%TMPL:END%%{
---------------------------------------------------
createform
Expand Down Expand Up @@ -86,34 +77,55 @@
formstart
---------------------------------------------------
}%%TMPL:DEF{"formstart"}%#NewTopic
<form name="newtopicform" action="%SCRIPTURLPATH{manage}%/%BASEWEB%/" method="post">
<input type="hidden" name="action" value="create" />
<input type="hidden" name="onlynewtopic" value="on" />%TMPL:END%%{
%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="formstart"
}%%TMPL:END%%{
---------------------------------------------------
topicname
---------------------------------------------------
}%%TMPL:DEF{"topicname"}%<p><input type="text" class="foswikiInputField" name="topic" size="40" value="%IF{"defined 'newtopic'" then="%URLPARAM{"newtopic"}%" else="$percentIF{$quot $ TOPIC='WebCreateNewTopic'$quot then=$quot$quot else=$quot%TOPIC%$quot}$percent"}%" /> <span class="webTopicCreatorFeedback foswikiGrayText"><!--generated name will be put here--></span></p>%TMPL:END%%{
}%%TMPL:DEF{"topicname"}%<p>%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="topicname"
}% %INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="topicnamefeedback"
}%</p>%TMPL:END%%{
---------------------------------------------------
topicparent
---------------------------------------------------
}%%TMPL:DEF{"topicparent"}%<p><input type='text' size='40' name='topicparent' class='foswikiInputField' value='%URLPARAM{topicparent}%' />&nbsp;<span class='foswikiUnvisited'><a href='#' class='pickparent'>%MAKETEXT{"Pick from a list"}%</a> <img src='%ICONURLPATH{"processing-bg"}%' alt='' class='foswikiHidden processing' /></span></p>%TMPL:END%%{
}%%TMPL:DEF{"topicparent"}%<p>%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="topicname"
}%</p>%TMPL:END%%{
---------------------------------------------------
topictemplate
---------------------------------------------------
}%%TMPL:DEF{"topictemplate"}%<p><select name="templatetopic" class="foswikiSelect">%IF{"'%URLPARAM{"templatetopic"}%'" then='<option selected="selected">%URLPARAM{"templatetopic"}%</option>'}%<option value="">%MAKETEXT{"Default template"}%</option>%SEARCH{"name~'*Template'" scope="topic" topic="*Template" web="%BASEWEB%" excludetopic="*EditTemplate,*WebCreateNewTopicTemplate,*ViewTemplate" type="query" nonoise="on" format="<option value=\"$web.$topic\">$topic</option>"}%</select>%SEARCH{"name~'*Template'" scope="topic" topic="*Template" web="%BASEWEB%" limit="1" excludetopic="WebTopicEditTemplate,*WebCreateNewTopicTemplate,*ViewTemplate" type="query" nonoise="on" format=" <span class='foswikiUnvisited'>%POPUPWINDOW{
url="%SCRIPTURL{view}%/%SYSTEMWEB%/WebTemplateTopics?web=%BASEWEB%;template=viewplain"
template="viewplain"
toolbar="1"
label="%MAKETEXT{"View templates"}%"
}%</span>"}%</p>%JQREQUIRE{"popupwindow"}%%TMPL:END%%{
}%%TMPL:DEF{"topictemplate"}%<p>%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="templatetopic"
}%</p>%TMPL:END%%{
---------------------------------------------------
errorfeedback
---------------------------------------------------
}%%TMPL:DEF{"errorfeedback"}%<p>%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="errorfeedback"
}%</p>%TMPL:END%%{
---------------------------------------------------
submit
---------------------------------------------------
}%%TMPL:DEF{"submit"}%<p class="webTopicCreatorError foswikiGrayText"><!--generated name will be put here--></p>
<p><input type="submit" class="foswikiSubmit" value='%MAKETEXT{"Create this topic"}%' /></p>%TMPL:END%%{
}%%TMPL:DEF{"submit"}%%TMPL:P{"errorfeedback"}%
<p>%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="submit"
}%</p>%TMPL:END%%{
---------------------------------------------------
formend
---------------------------------------------------
}%%TMPL:DEF{"formend"}%</form>%TMPL:END%%{
}%%TMPL:DEF{"formend"}%%INCLUDE{
"%SYSTEMWEB%.WebCreateNewTopicComponents"
section="formend"
}%%TMPL:END%%{
===================================================
</verbatim>}%
1 change: 1 addition & 0 deletions core/lib/Foswiki/Contrib/core/MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ data/System/WebAtomBase.txt 0644
data/System/WebChanges.txt 0644
data/System/WebChangesAlert.txt 0644
data/System/WebCreateNewTopic.txt 0644
data/System/WebCreateNewTopicComponents.txt 0644
data/System/WebCreateNewTopicTemplate.txt 0644
data/System/WebHome.txt 0644
data/System/WebIndex.txt 0644
Expand Down

0 comments on commit ec7bbce

Please sign in to comment.