Documentation

This is a tool to add a topic based application, or part of it to another web. This is done by creating a TopicStub that points back to the implementation. For example, to add a new TopicType to web, you create a TopicStub that points back to the implementation of that TopicType.

The function will display a small input form to specify the web where the TopicStub is to be created.

Parameters
  • TEXT: headline for the install form, defaults to "Install BASETOPIC"
  • NAME: name of the topic to be created, defaults to BASETOPIC
  • SOURCE: used to specify the TopicStub's target to be created, defaults to BASEWEB.BASETOPIC
  • PARENT: topicparent of the new topic, defaults to HOMETOPIC
  • TEMPLATE: TopicTemplate used to create this topic, defaults to TopicStubTemplate
  • FORM: DataForm used for this topic, defaults to TopicStub
  • TYPE: type of the new topic, defaults to TopicStub
  • WIKIAPP: the name of the WikiApllication? this topic belongs to, defaults to BASEWEB
  • EXTRA: extra stuff to be send during save

Implementation

%STARTINCLUDE%<!-- rendertopic installer --><noautolink>
%TWISTY{
  mode="div"
  link="%BUTTON{"%MAKETEXT{"Install"}%" icon="application_add"}%%CLEAR%"
}%

<form id="topicinstaller" action="%SCRIPTURLPATH{"save"}%/" method="post">
<div class="foswikiFormSteps">
<h2 >%IF{"defined TEXT" then="$percntTEXT$percnt" else="%MAKETEXT{"Install %BASETOPIC%"}%"}%</h2>
<input type="hidden" name="onlynewtopic" value="on" />
<input type="hidden" name="TopicTitle" value="" />
<input type="hidden" name="Summary" value="%FORMFIELD{"Summary" topic="%IF{"defined SOURCE" then="%SOURCE%" else="%BASETOPIC%"}%"}%" />
<input type="hidden" name="topicparent" value="%IF{
  "defined PARENT"
  then="%PARENT%"
  else="%HOMETOPIC%"}%" />
<input type="hidden" name="templatetopic" value="%IF{
  "defined TEMPLATE"
   then="%TEMPLATE%"
   else="Applications.TopicStubTemplate"}%" />
<input type="hidden" name="formtemplate" value="%IF{
  "defined FORM" 
  then="%FORM%" 
  else="Applications.TopicStub"}%" />
<input type="hidden" name="TopicType" value="%IF{
  "defined TYPE"
  then="TopicStub, %TYPE%"
  else="TopicStub"}%" />
<input type="hidden" name="Target" value="%IF{
  "defined SOURCE" 
  then="%SOURCE%" 
  else="%BASEWEB%.%BASETOPIC%"}%" />
<input type="hidden" name="WikiApplication" value="%IF{
  "defined WIKIAPP"
  then="%WIKIAPP%"
  else="%FLEXWEBLIST{include="%BASEWEB%" format="$name"}%"}%" />
%IF{"defined EXTRA" then="$percntEXTRA$percnt"}%
<input type="hidden" name="topic" id="topic" value="%IF{"defined NAME" then="%NAME%" else="%BASETOPIC%"}%" />
<div class="foswikiFormStep">
  <h3>Target web:</h3>
  <select id="newweb" name="web" class="foswikiSelect"> 
    <option>Select ... </option>
    %FLEXWEBLIST{
      format="<option value='$web'>$web</option>"
      webs="public,webtemplate" 
      separator=" " 
      exclude="Trash"
    }%
  </select>
  <div class="foswikiFormDescription">
    %MAKETEXT{"Select a web where to deploy this component."}%
  </div>
</div>
<div class="foswikiFormStep">
%BUTTON{"%MAKETEXT{"Submit"}%" icon="tick" type="save"}%
%CLEAR%
</div>
</div>
</form> 
%ENDTWISTY%
%ADDTOZONE{"script" topic="%WEB%.%TOPIC%" section="init" requires="JQUERYPLUGIN"}%
</noautolink><!-- //render topic installer -->%STOPINCLUDE%

JavaScript initialisation

%STARTSECTION{"init"}%<literal>
<script type='text/javascript'>
jQuery(function($) {
  $('#topicinstaller').bind('submit', function() {
    var $form = $("#topicinstaller");
    var $topic = $form.find('[name=topic]');
    var $web = $form.find('[name=web]');
    $topic.val($web.val()+'.'+$topic.val());
  });
});
</script>
</literal>%ENDSECTION{"init"}%

Test

Install RenderTopicInstaller

Target web:

Select a web where to deploy this component.

Calls to 'RenderTopicInstaller'

Copyright

© 2006-2013 Michael Daum http://michaeldaumconsulting.com

This file is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. For more details read the LICENSE.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY, to the extent permitted by law; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

ApplicationTopic edit

TopicType DocuTopic, TopicFunction
TopicTitle
Summary Render a simple factory to deploy a topic in another web
WikiApplication WikiWorkbench
Topic revision: r1 - 23 Dec 2012, ProjectContributor
 

Das Urheberrecht © liegt bei den mitwirkenden Autoren. Alle Inhalte dieser Kollaborations-Plattform sind Eigentum der Autoren.