• Do not register here on develop.twiki.org, login with your twiki.org account.
• Use View topic Item7848 for generic doc work for TWiki-6.1.1. Use View topic Item7851 for doc work on extensions that are not part of a release. More... Close
• Anything you create or change in standard webs (Main, TWiki, Sandbox etc) will be automatically reverted on every SVN update.
Does this site look broken?. Use the LitterTray web for test cases.

Item6856: Publish multiple webs feature, useful for virtual host publishing

Item Form Data

AppliesTo: Component: Priority: CurrentState: WaitingFor: TargetRelease ReleasedIn
Extension PublishWebPlugin Enhancement Closed   n/a  

Edit Form Data

Summary:
Reported By:
Codebase:
Applies To:
Component:
Priority:
Current State:
Waiting For:
Target Release:
Released In:
 

Detail

JohnVestrum wrote in TWiki:Plugins.PublishWebPluginDev:

So back in 2006 Peter asked if anyone needed support for publishing multiple webs. Well, I do, so I wrote a patch to that end. It creates a new boolean config variable, AppendWebnameToPath (defaults to off), which if set appends the web name to the publishdir and attachdir. Like always, you still need manually create those dirs and chown them to the webserver user.

--- lib/TWiki/Plugins/PublishWebPlugin/Config.spec.dist   2012-03-02 10:48:12.103829568 -0600
+++ lib/TWiki/Plugins/PublishWebPlugin/Config.spec        2012-03-01 16:52:26.683852378 -0600
@@ -30,4 +30,7 @@
 # URL path that corresponds to <code>{PublishPath}</code> directory. Leave
 # empty if it is the HTML document root.
 $TWiki::cfg{Plugins}{PublishWebPlugin}{PublishUrlPath} = '';
+# **BOOLEAN**
+# Append the webname to PublishPath and AttachPath
+$TWiki::cfg{Plugins}{PublishWebPlugin}{AppendWebnameToPath} = 0;
 1;

--- lib/TWiki/Plugins/PublishWebPlugin.pm.dist    2012-03-01 16:27:14.575903461 -0600
+++ lib/TWiki/Plugins/PublishWebPlugin.pm 2012-03-01 16:49:09.551896845 -0600
@@ -44,6 +44,7 @@
 my $publishDir;
 my $attachDir;
 my $publishUrlPath;
+my $appendWebnameToPath = 0;

 # template path for skin file; empty for twiki/templates; must be absolute path if specified
 $templatePath = $TWiki::cfg{Plugins}{PublishWebPlugin}{TemplatePath} || "";
@@ -57,6 +58,9 @@
 # URL path corresponding to $publishPath
 $publishUrlPath = $TWiki::cfg{Plugins}{PublishWebPlugin}{PublishUrlPath} || "";
 
+# if set to true, append the web name to publishPath and attachPath
+$appendWebnameToPath = $TWiki::cfg{Plugins}{PublishWebPlugin}{AppendWebnameToPath} || 0;
+
 # =========================
 sub initPlugin
 {
@@ -73,6 +77,12 @@
     # Get plugin debug flag
     $debug = TWiki::Func::getPluginPreferencesFlag( "DEBUG" );
     
+    # append web name to path?
+    if( $appendWebnameToPath == 1 ) {
+        $publishPath = $publishPath . '/' . $web;
+        $attachPath = $attachPath . '/' . $web;
+    }
+
     writeDebug( "initPlugin( $web.$topic ) is OK" );
     $initialized = 0;
     $error = "";

I'd love to see this pulled back into the main plugin, if there is anything I can do to improve the odds of that let me know. Thanks.

-- TWiki:Main/JohnVestrum - 2012-03-02

Good idea. What a coincidence. I also have a need now for multi-web publishing. I take this into the next release with some modifications:

  • use lower case web name for publishPath instead of Upper-lowercase web name (to keep all URL path lower case as it currently is)
  • no change to attachPath because I think it is better remain relative to the publishPath. I have an actual use case with Apache virtual hosts, where each publish web's published content is for a virtual host. Example:
    • Web WebsiteOne:
      • publish path: /var/www/vhosts/websiteone/
      • attach path: /var/www/vhosts/websiteone/_publish/
    • Web WebsiteTwo:
      • publish path: /var/www/vhosts/websitetwo/
      • attach path: /var/www/vhosts/websitetwo/_publish/

-- TWiki:Main/PeterThoeny - 2012-03-05

Thinking this over, it would be more natural to have this structure for virtual hosts:

  • Web WebsiteOne:
    • publish path: /var/www/vhosts/websiteone/html/
    • attach path: /var/www/vhosts/websiteone/html/_publish/
  • Web WebsiteTwo:
    • publish path: /var/www/vhosts/websitetwo/html/
    • attach path: /var/www/vhosts/websitetwo/html/_publish/

What about defining a variable in {PublishPath} and {PublishUrlPath}, such as:

$TWiki::cfg{Plugins}{PublishWebPlugin}{PublishPath} = '/var/www/vhosts/%LCWEB%/html';

Where %WEB% resolves to the name of the publish web, and %LCWEB% resolves to the lower case name thereof.

That way there is no need for a {AppendWebnameToPath} setting.

I think this is a flexible solution that should fit John's needs as well.

-- TWiki:Main/PeterThoeny - 2012-03-05

OK, I implemented as I proposed. Credit for enhancement is with TWiki:Main/JohnVestrum because you supplied the initial code.

-- TWiki:Main/PeterThoeny - 2012-03-05

I also added a %SKIN%, which resolves to the name of the publish skin; handled in all path settings.

-- TWiki:Main/PeterThoeny - 2012-03-05

ItemTemplate
Summary Publish multiple webs feature, useful for virtual host publishing
ReportedBy TWiki:Main.PeterThoeny
Codebase ~twiki4, 5.1.1
SVN Range TWiki-5.1.1-trunk, Sun, 26 Feb 2012, build 22642
AppliesTo Extension
Component PublishWebPlugin
Priority Enhancement
CurrentState Closed
WaitingFor

Checkins TWikirev:22665 TWikirev:22666 TWikirev:22667 TWikirev:22668 TWikirev:22669 TWikirev:22670 TWikirev:22671 TWikirev:22672 TWikirev:22673 TWikirev:22674 TWikirev:22675 TWikirev:22676
TargetRelease n/a
ReleasedIn

Edit | Attach | Watch | Print version | History: r16 < r15 < r14 < r13 < r12 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r16 - 2012-03-05 - PeterThoeny
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback