Skip to content

Commit

Permalink
Commandlets code structure cleanup.
Browse files Browse the repository at this point in the history
Fizes to Zen Garden tenant creation
Issues #136, #135,
Improvements for Issue #7
  • Loading branch information
AdamNaj committed Dec 16, 2013
1 parent 54e5a46 commit 2b10159
Show file tree
Hide file tree
Showing 42 changed files with 689 additions and 125 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -217,5 +217,4 @@ pip-log.txt
/Database/
/Data/*/
!/Data/packages/
!/Data/serialization/
Data/serialization/master/sitecore/system/Tasks/Schedules/Test-PowerShell.item
!/Data/serialization/
41 changes: 22 additions & 19 deletions Cognifide.PowerShell.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,11 @@
<DependentUpon>RemoteScriptCall.ashx</DependentUpon>
</Compile>
<Compile Include="PowerShellIntegrations\Commandlets\Data\ExpandTokensCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\ExecuteScriptCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\GetSessionCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\ImportFunctionCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Presentation\GetLayoutCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Presentation\GetRenderingCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Session\ExecuteScriptCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Session\GetSessionCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Session\ImportFunctionCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Interactive\CloseWindowCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Interactive\Messages\IMessageWithResult.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Interactive\Messages\ShowApplicationMessage.cs" />
Expand Down Expand Up @@ -178,16 +180,16 @@
<Compile Include="PowerShellIntegrations\Commandlets\Analytics\GetAnalyticsVisitsCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Analytics\SetAnalyticsProfileCardCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\BaseCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\DatabaseContextBaseCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\GetArchiveCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\GetCacheCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\GetDatabaseCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\GetIndexCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\GetItemByUriCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\GetItemTemplateCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\GetSearchIndexCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\GetUserAgent.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\GetUserCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Data\DatabaseContextBaseCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Data\GetArchiveCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Session\GetCacheCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Data\GetDatabaseCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Data\GetIndexCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Data\GetItemByUriCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Data\GetItemTemplateCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Data\GetSearchIndexCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Session\GetUserAgent.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Session\GetUserCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Interactive\BaseFormCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Interactive\BaseShellCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Interactive\DownloadFileCommand.cs" />
Expand All @@ -199,8 +201,8 @@
<Compile Include="PowerShellIntegrations\Commandlets\Interactive\ShowInputCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Interactive\ShowModalDialogCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Interactive\ShowYesNoCancelCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\LoginUserCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\LogoutUserCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Session\LoginUserCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Session\LogoutUserCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Packages\BasePackageCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Packages\ExportPackageCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Packages\GetPackageCommand.cs" />
Expand All @@ -210,15 +212,15 @@
<Compile Include="PowerShellIntegrations\Commandlets\Packages\NewFileSourceCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Packages\NewItemSourceCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Packages\NewPackageCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\PublishItemCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\RestartApplicationCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Data\PublishItemCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Session\RestartApplicationCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Serialization\DeserializeItemCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Serialization\SerializeItemCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\SetHostPropertyCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Session\SetHostPropertyCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Workflows\ExecuteWorkflowCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Workflows\GetItemWorkflowEventCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Workflows\NewItemWorkflowEventCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\WrapItemCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\Data\WrapItemCommand.cs" />
<Compile Include="PowerShellIntegrations\Commandlets\WriteLogCommand.cs" />
<Compile Include="PowerShellIntegrations\Host\BufferSplitterCollection.cs" />
<Compile Include="PowerShellIntegrations\Host\CommandCompletion.cs" />
Expand Down Expand Up @@ -447,6 +449,7 @@
<Content Include="Console\Services\RemoteScriptCall.ashx" />
<None Include="sitecore\shell\Themes\Standard\PowerShell.zip" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Target Name="AfterBuild">
<CallTarget Targets="DeployToWeb" Condition="$(SitecorePath) != ''" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ content-length: 0
----version----
language: en
version: 1
revision: 7921d1c2-6ae1-4069-a436-fcf565fb5c5e
revision: f86b06d0-3d3b-4b80-aa49-2eb9c0bfce4b

----field----
field: {67B6378B-C9F1-47C7-9CAC-BFA79B0727D9}
Expand Down Expand Up @@ -163,14 +163,14 @@ name: __Revision
key: __revision
content-length: 36

7921d1c2-6ae1-4069-a436-fcf565fb5c5e
f86b06d0-3d3b-4b80-aa49-2eb9c0bfce4b
----field----
field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
name: __Updated
key: __updated
content-length: 34

20120907T141138:634826238980104512
20131120T180535:635205675352567657
----field----
field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
name: __Updated by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ content-length: 0
----version----
language: en
version: 1
revision: 736e9c0f-98e0-4c46-8eaa-21769b48ca1a
revision: e71a1bbd-4e9a-4db7-91d0-bf10877bebb6

----field----
field: {67B6378B-C9F1-47C7-9CAC-BFA79B0727D9}
Expand Down Expand Up @@ -146,14 +146,14 @@ name: __Revision
key: __revision
content-length: 36

736e9c0f-98e0-4c46-8eaa-21769b48ca1a
e71a1bbd-4e9a-4db7-91d0-bf10877bebb6
----field----
field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
name: __Updated
key: __updated
content-length: 34

20121129T232108:634898280681354844
20131120T180920:635205677608534454
----field----
field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
name: __Updated by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ content-length: 145
----version----
language: en
version: 1
revision: 5e95dfb0-b391-419c-973c-87604397ee01
revision: 511beb76-aa4d-4479-940b-5a27a2b9d9cd

----field----
field: {67B6378B-C9F1-47C7-9CAC-BFA79B0727D9}
Expand Down Expand Up @@ -139,14 +139,14 @@ name: __Revision
key: __revision
content-length: 36

5e95dfb0-b391-419c-973c-87604397ee01
511beb76-aa4d-4479-940b-5a27a2b9d9cd
----field----
field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
name: __Updated
key: __updated
content-length: 34

20130907T203825:635141831057658516
20131120T180440:635205674801093047
----field----
field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
name: __Updated by
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,20 @@ templatekey: PowerShell Script
field: {B1A94FF0-6897-47C0-9C51-AA6ACB80B1F0}
name: Script
key: script
content-length: 4376
content-length: 5059

Write-Progress -Activity "Asking for parameters"
$validThemes = get-item "master:/media library/themes/Balsamiq v2"
$result = Read-Variable -Parameters `
@{ Name = "tenantName"; Value="New tenant"; Title="Tenant Name"}, `
@{ Name = "marketName"; Value="int"; Title="Market Name"}, `
@{ Name = "removeExistingTenant"; Value=$false; Title="Remove current tenant/market & theme if exists"}, `
@{ Name = "hostName"; Value="newtenant"; Title="Host name"}, `
@{ Name = "createNewTheme"; Value=$true; Title="Create new theme"} `
@{ Name = "tenantName"; Value="New tenant"; Title="Tenant Name"; Tab="General"}, `
@{ Name = "marketName"; Value="int"; Title="Market Name"; Tab="General"}, `
@{ Name = "removeExistingTenant"; Value=$false; Title="Remove current tenant/market & theme if exists"; Tab="General"}, `
@{ Name = "hostName"; Value="newtenant"; Title="Host name"; Tab="General"}, `
@{ Name = "createNewTheme"; Value=$true; Title="Create new theme"; Tab="Theme"}, `
@{ Name = "validThemes"; Source="DataSource=/sitecore/media library/themes&DatabaseName=master&IncludeTemplatesForDisplay=ThemeTemplate&IncludeTemplatesForSelection=ThemeTemplate&ExcludeItemsForDisplay=/sitecore/media library/themes";
editor="treelist"; Title="themes usable by this market"; Tab="Theme" } `
-Description "This script will create a new fully functional tenant within your Zen Garden enabled Sitecore instance." `
-Title "Create a new Zen Garden tenant" -Width 500 -Height 420 `
-Title "Create a new Zen Garden tenant" -Width 500 -Height 480 `
-OkButtonName "Proceed" -CancelButtonName "Abort"

if($result -ne "ok")
Expand Down Expand Up @@ -110,19 +113,27 @@ if($createNewTheme)
$theme = Get-Item "master:\media library\themes\$seoTenantName"
$theme."__Display name" = $tenantName
$designs.ZenGardenTheme = "{FE5D7FDF-89C0-4D99-9AA3-B5FBD009C9F3}=$($theme.ID)"
$validThemes = $validThemes + $theme
} else {
# Set default theme to Balsamiq
$designs.ZenGardenTheme = "{FE5D7FDF-89C0-4D99-9AA3-B5FBD009C9F3}=%7b5BC33F0E-A0F8-434E-9808-E32C6BABF76E%7d"
}

# Assign valid themes to the tenant
$themeIds = ""
foreach($validTheme in $validThemes){
$themeIds = $themeIds + "|" + $validTheme.ID
}
$settings.Themes = $themeIds.Trim('|');

$mediaPath = New-Item -Path 'master:\media library' -Name $tenantName -ItemType "System/Media/Media folder"

Write-Host "Done! Don't forget to publish the templates, theme and the tenant!"

----version----
language: en
version: 1
revision: 28f50109-afe5-4f29-9960-e011536cb8c4
revision: fd60dba0-8a1e-458f-9420-6b1551a9d9bb

----field----
field: {25BED78C-4957-4165-998A-CA1B52F67497}
Expand All @@ -137,14 +148,14 @@ name: __Revision
key: __revision
content-length: 36

28f50109-afe5-4f29-9960-e011536cb8c4
fd60dba0-8a1e-458f-9420-6b1551a9d9bb
----field----
field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
name: __Updated
key: __updated
content-length: 34

20130928T025621:635159337814584609
20131119T133209:635204647296093125
----field----
field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
name: __Updated by
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
----item----
version: 1
id: {E206F3BE-F252-490F-9A3C-531CD5D43C3E}
database: master
path: /sitecore/system/Modules/PowerShell/Script Library/Content Editor/Context Menu/Create New Tenant
parent: {47BA2B5B-36CB-4061-9DC0-BEE85700780E}
name: Create New Tenant
master: {00000000-0000-0000-0000-000000000000}
template: {DD22F1B3-BD87-4DB2-9E7D-F7A496888D43}
templatekey: PowerShell Script

----field----
field: {1C76313E-3C8C-4807-A826-135D10C39299}
name: ShowRule
key: showrule
content-length: 549

<ruleset>
<rule uid="{43538564-0CB2-4A07-AF9D-F920F49B92D1}">
<conditions>
<and uid="B5087284C5AA413FB94EB3FCC5B168CA">
<condition id="{4F5389E9-79B7-4FE1-A43A-EEA4ECD19C94}" uid="B4B58EF1AC0244848CF9EF84D335DA39" operatorid="{10537C58-1684-4CAB-B4C0-40C10907CE31}" value="{0DE95AE4-41AB-4D01-9EB0-67441B7C2450}" />
<condition id="{5CD2292C-32AC-4976-AA4F-A741555D22F8}" uid="FA3A75AF19CB4B0D85549D5BF6784B28" query="/sitecore/templates/Cognifide/ZenGarden" />
</and>
</conditions>
</rule>
</ruleset>
----field----
field: {B1A94FF0-6897-47C0-9C51-AA6ACB80B1F0}
name: Script
key: script
content-length: 64

Execute-Script 'Cognifide Internal\Create new Zen Garden Tenant'
----field----
field: {06D5295C-ED2F-4A54-9BF2-26228D113318}
name: __Icon
key: __icon
content-length: 36

BusinessV2/32x32/office_building.png
----field----
field: {BA3F86A2-4A1C-4D78-B63D-91C2779C1B5E}
name: __Sortorder
key: __sortorder
content-length: 3

100
----version----
language: en
version: 1
revision: 71da9e58-3697-4cc5-a92d-6a672b9c1ec1

----field----
field: {25BED78C-4957-4165-998A-CA1B52F67497}
name: __Created
key: __created
content-length: 15

20131119T123832
----field----
field: {8CDC337E-A112-42FB-BBB4-4143751E123F}
name: __Revision
key: __revision
content-length: 36

71da9e58-3697-4cc5-a92d-6a672b9c1ec1
----field----
field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522}
name: __Updated
key: __updated
content-length: 34

20131119T160629:635204739897831406
----field----
field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A}
name: __Updated by
key: __updated by
content-length: 14

sitecore\admin
Loading

0 comments on commit 2b10159

Please sign in to comment.