From: <de...@de...> - 2017-07-05 08:00:15
|
Author: HideyoImazu Date: 2017-07-05 07:42:42 +0000 (Wed, 05 Jul 2017) New Revision: 30353 Trac url: http://develop.twiki.org/trac/changeset/30353 Modified: twiki/trunk/core/data/TWiki/ManagingWebs.txt twiki/trunk/core/data/TWiki/TWikiPreferences.txt twiki/trunk/core/lib/TWiki/Store.pm Log: Item7816: Excluding specified topics when creating a new web Modified: twiki/trunk/core/data/TWiki/ManagingWebs.txt =================================================================== --- twiki/trunk/core/data/TWiki/ManagingWebs.txt 2017-06-29 10:02:26 UTC (rev 30352) +++ twiki/trunk/core/data/TWiki/ManagingWebs.txt 2017-07-05 07:42:42 UTC (rev 30353) @@ -34,6 +34,9 @@ __%X% Note:__ *Keep the number of webs to a minimum!* Don't create a new web for each little project. Cross-linking topics is easier, and searches are faster, if there are only a few larger webs. You can organize content within a web using categories, TWikiForms and FormattedSearch. | *Name of new web:* | <input name="newweb" class="twikiInputField" type="text" value="%URLPARAM{"newweb" encode="entity"}%" size="16" /> | The name must start with an upper case letter, followed by upper or lower case letters or numbers. Specify a short name to avoid long URLs. | | *Based on web:* | <select name="baseweb" class="twikiSelect"> %WEBLIST{ "<option $marker>$name</option>" webs="webtemplate%IF{"{NoInAllPublicWebs}" else=",public"}%" selection="_default" separator=" "}% </select> | Select a TemplateWeb. | +| *Exclude Topic:* | <input type="text" class="twikiInputField" name="excludetopic" value="" size="60" /><br /> Enter comma separated list of topics to exclude from the template web. For example, =Data*= excludes all topics whose name starts with Data.%BR%<noautolink>%TWISTY{mode="div" + showlink="Specify exception (you don't need to change most of the time) %ICONURL{toggleopen}%" + hidelink="Hide exception %ICONURL{toggleclose}%"}%<input name="excludeexception" class="twikiInputField" size="60" value="%VAR{CREATE_WEB_EXCLUDE_EXCEPTION}%"/>%BR%e.g. if =*Form= is specified as exception, =DataForm= is copied even if =Data*= is specified to be excluded. %ENDTWISTY%</noautolink>|| | *Web color:* | %COLORPICKER{ name="WEBBGCOLOR" size="16" value="#d0d0d0" class="twikiInputField" }% | Select color for the new web, shown in the list of webs.<br /><br /> __Note:__ Use a light color within the top 1/4th area of the center square depicting the saturation/luminance gradients. | | *Site Map:* | <input type="radio" name="SITEMAPLIST" value="on" checked="checked" /> Yes <input type="radio" name="SITEMAPLIST" value="" /> No | Include this web in the site map | | *Description:<br /> <br /> * | <input type="text" class="twikiInputField" name="SITEMAPWHAT" value="" size="60" /><br /> Enter a short description of the web. Write =[<nop>[Web.TopicName][title]]= instead of just =TopicName= if you include links. This description will be used in the %SYSTEMWEB%.SiteMap. || Modified: twiki/trunk/core/data/TWiki/TWikiPreferences.txt =================================================================== --- twiki/trunk/core/data/TWiki/TWikiPreferences.txt 2017-06-29 10:02:26 UTC (rev 30352) +++ twiki/trunk/core/data/TWiki/TWikiPreferences.txt 2017-07-05 07:42:42 UTC (rev 30353) @@ -84,6 +84,10 @@ * If not set: included TOC is shown * Possible values: =on= or nothing +#ExcludeException + * When you create a new web with ManagingWebs, topics are copied from the template web, which can be any web. In doing so, you can specify topics to exclude. And you can specify topics not to exclude. The following defines the default value of the exclude exception. + * Set CREATE_WEB_EXCLUDE_EXCEPTION = *Template, *Form, WebPreferences + #DefaultUserSettings ---++ Default User Settings Modified: twiki/trunk/core/lib/TWiki/Store.pm =================================================================== --- twiki/trunk/core/lib/TWiki/Store.pm 2017-06-29 10:02:26 UTC (rev 30352) +++ twiki/trunk/core/lib/TWiki/Store.pm 2017-07-05 07:42:42 UTC (rev 30353) @@ -1840,6 +1840,23 @@ # copy topics from base web my @topicList = $this->getTopicNames( $baseWeb ); + require TWiki::Search; + my $excludeTopic = + TWiki::Search::_makeTopicPattern($opts->{EXCLUDETOPIC}); + my $excludeException = + TWiki::Search::_makeTopicPattern($opts->{EXCLUDEEXCEPTION}); + delete $opts->{EXCLUDETOPIC}; + delete $opts->{EXCLUDEEXCEPTION}; + if ( $excludeTopic ) { + if ( $excludeException ) { + @topicList = grep { /$excludeException/ || !/$excludeTopic/ } + @topicList; + } + else { + @topicList = grep { !/$excludeTopic/ } @topicList; + } + } + foreach my $topic ( @topicList ) { $this->copyTopic( $user, $baseWeb, $topic, $newWeb, $topic ); } |