[# tag: ewok sites administration page #] [! do { use File::Path qw(mkpath); use Ewok::Util qw(loadSiteMap saveSiteMap); use Ewok::Config qw($EWOK_HOME) } !][- do { Execute({ inputfile => 'util.epl', import => 1 }); $req = shift; $site = lc($fdat{site}); $step = lc($fdat{step}); $op = lc($fdat{op}); $op =~ s/ .*//; @errors = (); } -]
[# New #] [$ if ($op eq 'new') $] [$ if ($step eq 'create') $] [- do { $label = lc($fdat{label}); $alias = $fdat{alias}; $path = $fdat{path}; $smap = loadSiteMap(); push @errors, "Invalid label '$label'" if $label !~ m/^\w+$/; push @errors, "Site '$label' already exists" if exists $smap->{$label}; push @errors, 'Invalid stage type' if $fdat{stage} != 0 && $fdat{stage} != 1; push @errors, "Invalid alias '$alias'" if $alias && $alias !~ m!^/\w+$!; push @errors, "Invalid path '$path'" if $path !~ m!^/!; } -] [$ if (! @errors) $] [# Create or confirm $path creation if not exists #] [$ if (! -d $path) $] [$ if (! exists $fdat{mkpath}) $]

The '[+ $path +]' directory does not exist - create it?   Yes    No 

[# #]

[$ hidden $]
[$ elsif ($fdat{mkpath}) $] [- do { push @errors, "Creating path '$path' failed: $!" unless mkpath("$path/templates") } -] [$ endif $][# mkpath testing #] [$ endif $][# ! -d $path #] [# Add entry to site map #] [$ if (-d $path || exists $fdat{mkpath}) $] [- do { $smap->{$label} = { alias => $alias, path => $path, stage => $fdat{stage} }; $saved = saveSiteMap($smap); errors "Save of site map failed!" unless $saved; } -] [$ if ($saved) $] [- errors \@errors, { h1 => '' } -]

New ewok site '[+ $label +]' created. You will need to restart Apache for it to pick up the new site.

ewok Administration

[$ endif $][# $saved #] [$ endif $][# -d $path #] [$ endif $][# ! @errors #] [$ endif $][# $step eq 'create' #] [$ if ($step eq 'next' || ($step eq 'create' && @errors)) $] [- do { $label = lc($fdat{label}); $smap = loadSiteMap(); push @errors, "Invalid label '$label'" if $label !~ m/^\w+$/; push @errors, "Site '$label' already exists" if exists $smap->{$label}; push @errors, 'Invalid stage type' if $fdat{stage} != 0 && $fdat{stage} != 1; } -] [$ if ($step eq 'create' || ($step eq 'next' && !@errors)) $]

New site: [+ $label +]

[- errors \@errors, { h1 => '' } -]
Alias
Path
[$ hidden $]
[$ endif $] [$ endif $] [$ if (! $step || ($step eq 'next' && @errors)) $]

New ewok site

[- errors \@errors, { h1 => '' } -]
Label
TypeStage   Publish 
[$ endif $] [# Delete #] [$ elsif ($op eq 'delete') $] [- do { $smap = loadSiteMap(); push @errors, "Invalid site '$site'" unless $smap->{$site}; push @errors, "Invalid site '$site'" if $site eq 'ewok'; } -] [$ if (@errors) $] [- errors \@errors, -] [$ elsif ($step eq 'confirm') $] [- do { delete $smap->{$site}; $saved = saveSiteMap($smap); errors "Save of site map failed!" unless $saved; } -] [$ if ($saved) $] [- errors \@errors, { h1 => '' } -]

ewok site '[+ $site +]' deleted. You will need to restart Apache to have it pick up your changes.

ewok Administration

[$ endif $][# $saved #] [$ elsif ($step eq 'cancel') $] [- $http_headers_out{Location} = 'index.html' -] [$ else $]

Delete '[+ $site +]' site

Are you sure you want to delete the '[+ $site +]' site?  

[$ hidden $]
[$ endif $][# @errors/$confirm #] [$ endif $][# $op new/delete #]