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