├── .gitattributes ├── .github ├── ISSUE_TEMPLATE.md └── workflows │ └── gitlab.yml ├── .gitignore ├── .nuget ├── NuGet.Config ├── NuGet.exe └── NuGet.targets ├── LICENSE ├── Libs ├── Microsoft.Extensions.DependencyInjection.Abstractions.dll ├── Microsoft.Extensions.DependencyInjection.dll ├── SC82 │ ├── Microsoft.Extensions.DependencyInjection.Abstractions.dll │ └── Microsoft.Extensions.DependencyInjection.dll └── SC90 │ ├── Microsoft.Extensions.DependencyInjection.Abstractions.dll │ └── Microsoft.Extensions.DependencyInjection.dll ├── NitroNet.Sitecore.CastleWindsorModules ├── NitroNet.Sitecore.CastleWindsorModules.csproj ├── NitroNet.Sitecore.CastleWindsorModules.nuspec ├── Properties │ └── AssemblyInfo.cs ├── SitecoreCastleWindsorModule.cs └── app.config ├── NitroNet.Sitecore.Microsoft.DependencyInjection ├── App_Config │ └── Include │ │ └── NitroNet │ │ └── DependencyInjection.config ├── NitroNet.Sitecore.Microsoft.DependencyInjection.csproj ├── NitroNet.Sitecore.Microsoft.DependencyInjection.nuspec ├── NitroNetServicesConfigurator.cs ├── Properties │ └── AssemblyInfo.cs └── app.config ├── NitroNet.Sitecore.UnityModules ├── NitroNet.Sitecore.UnityModules.csproj ├── NitroNet.Sitecore.UnityModules.nuspec ├── Properties │ └── AssemblyInfo.cs ├── SitecoreUnityModule.cs └── app.config ├── NitroNet.Sitecore.sln ├── NitroNet.Sitecore ├── App_Config │ └── Include │ │ └── NitroNet │ │ ├── DynamicPlaceholder.config │ │ ├── EventHandlingInitializer.config │ │ ├── MvcRenderingPipeline.config │ │ └── RegisterViewEngine.config ├── Caching │ ├── ISitecoreCache.cs │ ├── ISitecoreCacheManager.cs │ ├── SitecoreCache.cs │ ├── SitecoreCacheManager.cs │ └── SitecoreCacheValue.cs ├── DynamicPlaceholder │ ├── DynamicPlaceholderExtension.cs │ ├── DynamicPlaceholderKeyProvider.cs │ ├── Helpers │ │ └── SitecoreHelperExtension.cs │ └── Pipelines │ │ ├── GetDynamicPlaceholderChromeData.cs │ │ ├── GetDynamicPlaceholderInitialKey │ │ └── RemovePlaceholderUniqueKeySuffixWithCountOrId.cs │ │ ├── GetDynamicPlaceholderKeys │ │ └── GetUniqueIdKeyWithinRendering.cs │ │ └── GetDynamicPlaceholderRenderings.cs ├── Events │ └── EventHandlingInitializer.cs ├── NitroNet.Sitecore.csproj ├── NitroNet.Sitecore.nuspec ├── Pipelines │ ├── Initialize │ │ └── RegisterNitroNetViewEngine.cs │ └── MvcRenderRendering │ │ ├── GenerateCacheKey.cs │ │ └── SetCacheability.cs ├── Properties │ └── AssemblyInfo.cs ├── Rendering │ ├── ISitecoreRenderingRepository.cs │ └── SitecoreRenderingRepository.cs ├── SitecoreMvcNitroTemplateHandler.cs ├── SitecoreMvcNitroTemplateHandlerFactory.cs ├── SitecoreNitroNetViewEngine.cs ├── Skin │ ├── ISkinDefinition.cs │ ├── ISkinRepository.cs │ ├── ITemplateInfo.cs │ ├── NitroNetSkinDefinition.cs │ ├── NitroNetSkinRepository.cs │ └── NitroNetTemplateInfo.cs └── app.config ├── NuGet.Config ├── README.md ├── docs ├── configuration.md ├── getting-started.md ├── imgs │ ├── layout_path.PNG │ └── logo.png ├── installation.md ├── known-issues.md ├── releases │ ├── 1.1.1.md │ ├── 1.1.2.md │ ├── 2.0.0.md │ └── utils │ │ └── MigrateDynamicPlaceholders.aspx └── samples.md ├── packaging.targets └── versioning.targets /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **Do you want to request a *feature* or report a *bug*?** 2 | 3 | **What is the current behavior?** 4 | 5 | **If the current behavior is a bug, please provide the steps to reproduce.** 6 | 7 | **What is the expected behavior?** 8 | 9 | **Please mention your NitroNet.Sitecore version, your .NET Runtime, your Sitecore version and the type of frontend you are using** -------------------------------------------------------------------------------- /.github/workflows/gitlab.yml: -------------------------------------------------------------------------------- 1 | name: trigger gitlab job 2 | on: 3 | push: 4 | branches: 5 | - master 6 | jobs: 7 | build: 8 | name: Build 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: trigger Job 12 | uses: appleboy/gitlab-ci-action@master 13 | with: 14 | host: ${{ secrets.GIT_LAB_HOST }} 15 | token: ${{ secrets.GIT_LAB_TOKEN }} 16 | project_id: 4757 17 | ref: "main" 18 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | 4 | # User-specific files 5 | *.suo 6 | *.user 7 | *.sln.docstates 8 | 9 | .idea/ 10 | 11 | # Build results 12 | 13 | [Dd]ebug/ 14 | [Rr]elease/ 15 | x64/ 16 | build/ 17 | [Bb]in/ 18 | [Oo]bj/ 19 | 20 | # Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets 21 | !packages/*/build/ 22 | 23 | # MSTest test Results 24 | [Tt]est[Rr]esult*/ 25 | [Bb]uild[Ll]og.* 26 | 27 | *_i.c 28 | *_p.c 29 | *.ilk 30 | *.meta 31 | *.obj 32 | *.pch 33 | *.pdb 34 | *.pgc 35 | *.pgd 36 | *.rsp 37 | *.sbr 38 | *.tlb 39 | *.tli 40 | *.tlh 41 | *.tmp 42 | *.tmp_proj 43 | *.log 44 | *.vspscc 45 | *.vssscc 46 | .builds 47 | *.pidb 48 | *.log 49 | *.scc 50 | 51 | # Visual C++ cache files 52 | ipch/ 53 | *.aps 54 | *.ncb 55 | *.opensdf 56 | *.sdf 57 | *.cachefile 58 | 59 | # Visual Studio profiler 60 | *.psess 61 | *.vsp 62 | *.vspx 63 | 64 | # Guidance Automation Toolkit 65 | *.gpState 66 | 67 | # ReSharper is a .NET coding add-in 68 | _ReSharper*/ 69 | *.[Rr]e[Ss]harper 70 | 71 | # TeamCity is a build add-in 72 | _TeamCity* 73 | 74 | # DotCover is a Code Coverage Tool 75 | *.dotCover 76 | 77 | # NCrunch 78 | *.ncrunch* 79 | .*crunch*.local.xml 80 | 81 | # Installshield output folder 82 | [Ee]xpress/ 83 | 84 | # DocProject is a documentation generator add-in 85 | DocProject/buildhelp/ 86 | DocProject/Help/*.HxT 87 | DocProject/Help/*.HxC 88 | DocProject/Help/*.hhc 89 | DocProject/Help/*.hhk 90 | DocProject/Help/*.hhp 91 | DocProject/Help/Html2 92 | DocProject/Help/html 93 | 94 | # Click-Once directory 95 | publish/ 96 | 97 | # Publish Web Output 98 | *.Publish.xml 99 | 100 | # NuGet Packages Directory 101 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line 102 | #packages/ 103 | 104 | # Windows Azure Build Output 105 | csx 106 | *.build.csdef 107 | 108 | # Windows Store app package directory 109 | AppPackages/ 110 | 111 | # Others 112 | sql/ 113 | *.Cache 114 | ClientBin/ 115 | [Ss]tyle[Cc]op.* 116 | ~$* 117 | *~ 118 | *.dbmdl 119 | *.[Pp]ublish.xml 120 | *.pfx 121 | *.publishsettings 122 | 123 | # RIA/Silverlight projects 124 | Generated_Code/ 125 | 126 | # Backup & report files from converting an old project file to a newer 127 | # Visual Studio version. Backup files are not needed, because we have git ;-) 128 | _UpgradeReport_Files/ 129 | Backup*/ 130 | UpgradeLog*.XML 131 | UpgradeLog*.htm 132 | 133 | # SQL Server files 134 | App_Data/*.mdf 135 | App_Data/*.ldf 136 | 137 | 138 | #LightSwitch generated files 139 | GeneratedArtifacts/ 140 | _Pvt_Extensions/ 141 | ModelManifest.xml 142 | 143 | # ========================= 144 | # Windows detritus 145 | # ========================= 146 | 147 | # Windows image file caches 148 | Thumbs.db 149 | ehthumbs.db 150 | 151 | # Folder config file 152 | Desktop.ini 153 | 154 | # Recycle Bin used on file shares 155 | $RECYCLE.BIN/ 156 | 157 | # Mac desktop service store files 158 | .DS_Store 159 | 160 | #NuGet 161 | packages 162 | !packages/repositories.config 163 | 164 | .vs/ 165 | 166 | #SC Assemblies 167 | Libs/Sitecore* -------------------------------------------------------------------------------- /.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/merkle-open/NitroNetSitecore/609c2e9e8c323bf099ef031322c092fc1e513ee6/.nuget/NuGet.exe -------------------------------------------------------------------------------- /.nuget/NuGet.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildProjectDirectory)\..\ 5 | 6 | 7 | false 8 | 9 | 10 | false 11 | 12 | 13 | true 14 | 15 | 16 | false 17 | 18 | 19 | 20 | 21 | 22 | 26 | 27 | 28 | 29 | 30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) 31 | 32 | 33 | 34 | 35 | $(SolutionDir).nuget 36 | 37 | 38 | 39 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName.Replace(' ', '_')).config 40 | $(MSBuildProjectDirectory)\packages.$(MSBuildProjectName).config 41 | 42 | 43 | 44 | $(MSBuildProjectDirectory)\packages.config 45 | $(PackagesProjectConfig) 46 | 47 | 48 | 49 | 50 | $(NuGetToolsPath)\NuGet.exe 51 | @(PackageSource) 52 | 53 | "$(NuGetExePath)" 54 | mono --runtime=v4.0.30319 "$(NuGetExePath)" 55 | 56 | $(TargetDir.Trim('\\')) 57 | 58 | -RequireConsent 59 | -NonInteractive 60 | 61 | "$(SolutionDir) " 62 | "$(SolutionDir)" 63 | 64 | 65 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir $(PaddedSolutionDir) 66 | $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -Symbols -SymbolPackageFormat snupkg 67 | 68 | 69 | 70 | RestorePackages; 71 | $(BuildDependsOn); 72 | 73 | 74 | 75 | 76 | $(BuildDependsOn); 77 | BuildPackage; 78 | 79 | 80 | 81 | 82 | 83 | 84 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 99 | 100 | 103 | 104 | 105 | 106 | 108 | 109 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2018 Namics AG 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Libs/Microsoft.Extensions.DependencyInjection.Abstractions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/merkle-open/NitroNetSitecore/609c2e9e8c323bf099ef031322c092fc1e513ee6/Libs/Microsoft.Extensions.DependencyInjection.Abstractions.dll -------------------------------------------------------------------------------- /Libs/Microsoft.Extensions.DependencyInjection.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/merkle-open/NitroNetSitecore/609c2e9e8c323bf099ef031322c092fc1e513ee6/Libs/Microsoft.Extensions.DependencyInjection.dll -------------------------------------------------------------------------------- /Libs/SC82/Microsoft.Extensions.DependencyInjection.Abstractions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/merkle-open/NitroNetSitecore/609c2e9e8c323bf099ef031322c092fc1e513ee6/Libs/SC82/Microsoft.Extensions.DependencyInjection.Abstractions.dll -------------------------------------------------------------------------------- /Libs/SC82/Microsoft.Extensions.DependencyInjection.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/merkle-open/NitroNetSitecore/609c2e9e8c323bf099ef031322c092fc1e513ee6/Libs/SC82/Microsoft.Extensions.DependencyInjection.dll -------------------------------------------------------------------------------- /Libs/SC90/Microsoft.Extensions.DependencyInjection.Abstractions.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/merkle-open/NitroNetSitecore/609c2e9e8c323bf099ef031322c092fc1e513ee6/Libs/SC90/Microsoft.Extensions.DependencyInjection.Abstractions.dll -------------------------------------------------------------------------------- /Libs/SC90/Microsoft.Extensions.DependencyInjection.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/merkle-open/NitroNetSitecore/609c2e9e8c323bf099ef031322c092fc1e513ee6/Libs/SC90/Microsoft.Extensions.DependencyInjection.dll -------------------------------------------------------------------------------- /NitroNet.Sitecore.CastleWindsorModules/NitroNet.Sitecore.CastleWindsorModules.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {7AB3D8F6-200A-4C56-8310-4FCBF862815B} 8 | Library 9 | Properties 10 | NitroNet.Sitecore.CastleWindsorModules 11 | NitroNet.Sitecore.CastleWindsorModules 12 | v4.6.2 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | bin\Debug-SC90\ 35 | TRACE 36 | false 37 | full 38 | AnyCPU 39 | prompt 40 | MinimumRecommendedRules.ruleset 41 | 42 | 43 | bin\Release-SC90\ 44 | TRACE 45 | true 46 | pdbonly 47 | AnyCPU 48 | prompt 49 | MinimumRecommendedRules.ruleset 50 | 51 | 52 | v4.5.2 53 | true 54 | bin\Debug-SC82\ 55 | DEBUG;TRACE 56 | full 57 | AnyCPU 58 | prompt 59 | MinimumRecommendedRules.ruleset 60 | 61 | 62 | v4.5.2 63 | bin\Release-SC82\ 64 | TRACE 65 | true 66 | pdbonly 67 | AnyCPU 68 | prompt 69 | MinimumRecommendedRules.ruleset 70 | 71 | 72 | v4.5.2 73 | true 74 | bin\Debug-SC81\ 75 | DEBUG;TRACE 76 | full 77 | AnyCPU 78 | prompt 79 | MinimumRecommendedRules.ruleset 80 | 81 | 82 | v4.5.2 83 | bin\Release-SC81\ 84 | TRACE 85 | true 86 | pdbonly 87 | AnyCPU 88 | prompt 89 | MinimumRecommendedRules.ruleset 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | all 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | ..\..\NitroNet\NitroNet.Common\bin\release\NitroNet.Common.dll 135 | 136 | 137 | ..\..\NitroNet\NitroNet.Mvc\bin\release\NitroNet.Mvc.dll 138 | 139 | 140 | ..\..\NitroNet\NitroNet.CastleWindsorModules\bin\release\NitroNet.CastleWindsorModules.dll 141 | 142 | 143 | ..\..\NitroNet\NitroNet.ViewEngine\bin\release\NitroNet.ViewEngine.dll 144 | 145 | 146 | ..\..\NitroNet\NitroNet.ViewEngine.TemplateHandler\bin\release\NitroNet.ViewEngine.TemplateHandler.dll 147 | 148 | 149 | ..\..\NitroNet\Veil\Src\Veil\bin\release\Veil.dll 150 | 151 | 152 | 153 | 154 | 155 | 156 | ..\..\NitroNet\NitroNet.Common\bin\debug\NitroNet.Common.dll 157 | 158 | 159 | ..\..\NitroNet\NitroNet.Mvc\bin\debug\NitroNet.Mvc.dll 160 | 161 | 162 | ..\..\NitroNet\NitroNet.CastleWindsorModules\bin\debug\NitroNet.CastleWindsorModules.dll 163 | 164 | 165 | ..\..\NitroNet\NitroNet.ViewEngine\bin\debug\NitroNet.ViewEngine.dll 166 | 167 | 168 | ..\..\NitroNet\NitroNet.ViewEngine.TemplateHandler\bin\debug\NitroNet.ViewEngine.TemplateHandler.dll 169 | 170 | 171 | ..\..\NitroNet\Veil\Src\Veil\bin\debug\Veil.dll 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | {d5228116-9ebd-4055-b50b-33a2f28b2a6e} 187 | NitroNet.Sitecore 188 | 189 | 190 | 191 | 192 | 193 | 200 | -------------------------------------------------------------------------------- /NitroNet.Sitecore.CastleWindsorModules/NitroNet.Sitecore.CastleWindsorModules.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $id$.$productVersion$ 5 | $version$ 6 | Namics AG 7 | Namics AG 8 | http://www.microsoft.com/en-us/openness/licenses.aspx 9 | https://github.com/merkle-open/NitroNetSitecore 10 | https://raw.githubusercontent.com/namics/NitroNet/master/nuget_icon.png 11 | false 12 | NitroNet Castle Windsor package for Sitecore 13 | Copyright 2017 14 | nitro sitecore castle windsor handlebars viewengine 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /NitroNet.Sitecore.CastleWindsorModules/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("NitroNet.Sitecore.CastleWindsorModules")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NitroNet.Sitecore.CastleWindsorModules")] 13 | [assembly: AssemblyCopyright("Copyright © Namics AG 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("7ab3d8f6-200a-4c56-8310-4fcbf862815b")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.1.0.0")] 36 | [assembly: AssemblyFileVersion("1.1.0.0")] 37 | -------------------------------------------------------------------------------- /NitroNet.Sitecore.CastleWindsorModules/SitecoreCastleWindsorModule.cs: -------------------------------------------------------------------------------- 1 | using Castle.MicroKernel.Registration; 2 | using Castle.Windsor; 3 | using NitroNet.CastleWindsorModules; 4 | using NitroNet.Sitecore.Caching; 5 | using NitroNet.Sitecore.Rendering; 6 | using NitroNet.ViewEngine.TemplateHandler; 7 | using NitroNet.ViewEngine.TemplateHandler.Grid; 8 | using Sitecore; 9 | using Sitecore.Data; 10 | using Sitecore.Mvc.Common; 11 | using Veil; 12 | 13 | namespace NitroNet.Sitecore.CastleWindsorModules 14 | { 15 | public class SitecoreCastleWindsorModule : ICastleWindsorModule 16 | { 17 | public void Configure(IWindsorContainer container) 18 | { 19 | container.Register(Component.For().UsingFactoryMethod(() => GridContext.GetFromRenderingContext(ContextService.Get().GetCurrent())).LifestyleTransient()); 20 | container.Register(Component.For().ImplementedBy()); 21 | container.Register(Component.For().ImplementedBy()); 22 | container.Register(Component.For().ImplementedBy()); 23 | container.Register(Component.For().UsingFactoryMethod(() => Context.Database)); 24 | } 25 | } 26 | } -------------------------------------------------------------------------------- /NitroNet.Sitecore.CastleWindsorModules/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /NitroNet.Sitecore.Microsoft.DependencyInjection/App_Config/Include/NitroNet/DependencyInjection.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /NitroNet.Sitecore.Microsoft.DependencyInjection/NitroNet.Sitecore.Microsoft.DependencyInjection.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {4252660C-89CA-43A2-9CBF-8FB66F710A42} 8 | Library 9 | Properties 10 | NitroNet.Sitecore.Microsoft.DependencyInjection 11 | NitroNet.Sitecore.Microsoft.DependencyInjection 12 | 512 13 | v4.6.2 14 | 15 | 16 | 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | true 37 | full 38 | false 39 | bin\Debug-SC90\ 40 | DEBUG;TRACE 41 | prompt 42 | 4 43 | 44 | 45 | pdbonly 46 | true 47 | bin\Release-SC90\ 48 | TRACE 49 | prompt 50 | 4 51 | 52 | 53 | v4.5.2 54 | true 55 | bin\Debug-SC82\ 56 | DEBUG;TRACE 57 | full 58 | AnyCPU 59 | prompt 60 | MinimumRecommendedRules.ruleset 61 | 62 | 63 | v4.5.2 64 | bin\Release-SC82\ 65 | TRACE 66 | true 67 | pdbonly 68 | AnyCPU 69 | prompt 70 | MinimumRecommendedRules.ruleset 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | all 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | False 111 | ..\Libs\SC90\Microsoft.Extensions.DependencyInjection.dll 112 | 113 | 114 | False 115 | ..\Libs\SC90\Microsoft.Extensions.DependencyInjection.Abstractions.dll 116 | 117 | 118 | 119 | 120 | 121 | 122 | False 123 | ..\Libs\SC82\Microsoft.Extensions.DependencyInjection.dll 124 | 125 | 126 | False 127 | ..\Libs\SC82\Microsoft.Extensions.DependencyInjection.Abstractions.dll 128 | 129 | 130 | 131 | 132 | 133 | 134 | False 135 | ..\Libs\Microsoft.Extensions.DependencyInjection.dll 136 | 137 | 138 | False 139 | ..\Libs\Microsoft.Extensions.DependencyInjection.Abstractions.dll 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | ..\..\NitroNet\NitroNet.Common\bin\release\NitroNet.Common.dll 149 | 150 | 151 | ..\..\NitroNet\NitroNet.Mvc\bin\release\NitroNet.Mvc.dll 152 | 153 | 154 | ..\..\NitroNet\NitroNet.ViewEngine\bin\release\NitroNet.ViewEngine.dll 155 | 156 | 157 | ..\..\NitroNet\NitroNet.ViewEngine.TemplateHandler\bin\release\NitroNet.ViewEngine.TemplateHandler.dll 158 | 159 | 160 | ..\..\NitroNet\Veil\Src\Veil\bin\release\Veil.dll 161 | 162 | 163 | 164 | 165 | 166 | 167 | ..\..\NitroNet\NitroNet.Common\bin\debug\NitroNet.Common.dll 168 | 169 | 170 | ..\..\NitroNet\NitroNet.Mvc\bin\debug\NitroNet.Mvc.dll 171 | 172 | 173 | ..\..\NitroNet\NitroNet.ViewEngine\bin\debug\NitroNet.ViewEngine.dll 174 | 175 | 176 | ..\..\NitroNet\NitroNet.ViewEngine.TemplateHandler\bin\debug\NitroNet.ViewEngine.TemplateHandler.dll 177 | 178 | 179 | ..\..\NitroNet\Veil\Src\Veil\bin\debug\Veil.dll 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E} 196 | NitroNet.Sitecore 197 | 198 | 199 | 200 | 201 | 202 | 209 | -------------------------------------------------------------------------------- /NitroNet.Sitecore.Microsoft.DependencyInjection/NitroNet.Sitecore.Microsoft.DependencyInjection.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $id$.$productVersion$ 5 | $version$ 6 | Namics AG 7 | Namics AG 8 | http://www.microsoft.com/en-us/openness/licenses.aspx 9 | https://github.com/merkle-open/NitroNetSitecore 10 | https://raw.githubusercontent.com/namics/NitroNet/master/nuget_icon.png 11 | false 12 | NitroNet MS.DependencyInjection package for Sitecore 13 | Copyright 2017 14 | nitro sitecore microsoft extensions handlebars viewengine 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /NitroNet.Sitecore.Microsoft.DependencyInjection/NitroNetServicesConfigurator.cs: -------------------------------------------------------------------------------- 1 | using System.Configuration; 2 | using System.Web.Hosting; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using NitroNet.Mvc; 5 | using NitroNet.Sitecore.Caching; 6 | using NitroNet.Sitecore.Rendering; 7 | using NitroNet.ViewEngine; 8 | using NitroNet.ViewEngine.Cache; 9 | using NitroNet.ViewEngine.Config; 10 | using NitroNet.ViewEngine.IO; 11 | using NitroNet.ViewEngine.TemplateHandler; 12 | using NitroNet.ViewEngine.TemplateHandler.Grid; 13 | using NitroNet.ViewEngine.ViewEngines; 14 | using Sitecore.DependencyInjection; 15 | using Sitecore.Mvc.Common; 16 | using Veil; 17 | using Veil.Compiler; 18 | using Veil.Helper; 19 | 20 | namespace NitroNet.Sitecore.Microsoft.DependencyInjection 21 | { 22 | public class NitroNetServicesConfigurator : IServicesConfigurator 23 | { 24 | public void Configure(IServiceCollection serviceCollection) 25 | { 26 | RegisterNitroNet(serviceCollection); 27 | RegisterNitroNetSitecore(serviceCollection); 28 | } 29 | 30 | protected virtual void RegisterNitroNetSitecore(IServiceCollection serviceCollection) 31 | { 32 | serviceCollection.AddTransient(); 33 | serviceCollection.AddTransient(); 34 | serviceCollection.AddTransient(x => GridContext.GetFromRenderingContext(ContextService.Get().GetCurrent())); 35 | serviceCollection.AddSingleton(); 36 | serviceCollection.AddSingleton(); 37 | } 38 | 39 | protected virtual void RegisterNitroNet(IServiceCollection serviceCollection) 40 | { 41 | var basePath = GetNitroNetBasePath(); 42 | 43 | var config = ConfigurationLoader.LoadNitroConfiguration(basePath); 44 | serviceCollection.AddSingleton(config); 45 | serviceCollection.AddSingleton(new FileSystem(basePath, config)); 46 | 47 | serviceCollection.AddSingleton(); 48 | serviceCollection.AddTransient(); 49 | serviceCollection.AddTransient(); 50 | serviceCollection.AddTransient(); 51 | serviceCollection.AddTransient(); 52 | serviceCollection.AddTransient(); 53 | serviceCollection.AddSingleton(); 54 | serviceCollection.AddSingleton(); 55 | serviceCollection.AddSingleton(); 56 | } 57 | 58 | protected virtual string GetNitroNetBasePath() 59 | { 60 | var rootPath = HostingEnvironment.MapPath("~/"); 61 | var basePath = PathInfo.Combine(PathInfo.Create(rootPath), PathInfo.Create(ConfigurationManager.AppSettings["NitroNet.BasePath"])); 62 | 63 | return basePath.ToString(); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /NitroNet.Sitecore.Microsoft.DependencyInjection/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("NitroNet.Sitecore.Microsoft.DependencyInjection")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NitroNet.Sitecore.Microsoft.DependencyInjection")] 13 | [assembly: AssemblyCopyright("Copyright © Namics AG 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("4252660c-89ca-43a2-9cbf-8fb66f710a42")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.1.0.0")] 36 | [assembly: AssemblyFileVersion("1.1.0.0")] 37 | -------------------------------------------------------------------------------- /NitroNet.Sitecore.Microsoft.DependencyInjection/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /NitroNet.Sitecore.UnityModules/NitroNet.Sitecore.UnityModules.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {F836AB0E-1182-4D45-836F-0066DEDE0D68} 8 | Library 9 | Properties 10 | NitroNet.Sitecore.UnityModules 11 | NitroNet.Sitecore.UnityModules 12 | v4.6.2 13 | 512 14 | 15 | 16 | 17 | 18 | 19 | true 20 | full 21 | false 22 | bin\Debug\ 23 | DEBUG;TRACE 24 | prompt 25 | 4 26 | 27 | 28 | pdbonly 29 | true 30 | bin\Release\ 31 | TRACE 32 | prompt 33 | 4 34 | 35 | 36 | bin\Debug-SC90\ 37 | TRACE 38 | false 39 | full 40 | AnyCPU 41 | prompt 42 | MinimumRecommendedRules.ruleset 43 | 44 | 45 | bin\Release-SC90\ 46 | TRACE 47 | true 48 | pdbonly 49 | AnyCPU 50 | prompt 51 | MinimumRecommendedRules.ruleset 52 | 53 | 54 | v4.5.2 55 | true 56 | bin\Debug-SC82\ 57 | DEBUG;TRACE 58 | full 59 | AnyCPU 60 | prompt 61 | MinimumRecommendedRules.ruleset 62 | 63 | 64 | v4.5.2 65 | bin\Release-SC82\ 66 | TRACE 67 | true 68 | pdbonly 69 | AnyCPU 70 | prompt 71 | MinimumRecommendedRules.ruleset 72 | 73 | 74 | v4.5.2 75 | true 76 | bin\Debug-SC81\ 77 | DEBUG;TRACE 78 | full 79 | AnyCPU 80 | prompt 81 | MinimumRecommendedRules.ruleset 82 | 83 | 84 | v4.5.2 85 | bin\Release-SC81\ 86 | TRACE 87 | true 88 | pdbonly 89 | AnyCPU 90 | prompt 91 | MinimumRecommendedRules.ruleset 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | all 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | ..\..\NitroNet\NitroNet.Common\bin\release\NitroNet.Common.dll 137 | 138 | 139 | ..\..\NitroNet\NitroNet.Mvc\bin\release\NitroNet.Mvc.dll 140 | 141 | 142 | ..\..\NitroNet\NitroNet.UnityModules\bin\release\NitroNet.UnityModules.dll 143 | 144 | 145 | ..\..\NitroNet\NitroNet.ViewEngine\bin\release\NitroNet.ViewEngine.dll 146 | 147 | 148 | ..\..\NitroNet\NitroNet.ViewEngine.TemplateHandler\bin\release\NitroNet.ViewEngine.TemplateHandler.dll 149 | 150 | 151 | ..\..\NitroNet\Veil\Src\Veil\bin\release\Veil.dll 152 | 153 | 154 | 155 | 156 | 157 | 158 | ..\..\NitroNet\NitroNet.Common\bin\debug\NitroNet.Common.dll 159 | 160 | 161 | ..\..\NitroNet\NitroNet.Mvc\bin\debug\NitroNet.Mvc.dll 162 | 163 | 164 | ..\..\NitroNet\NitroNet.UnityModules\bin\debug\NitroNet.UnityModules.dll 165 | 166 | 167 | ..\..\NitroNet\NitroNet.ViewEngine\bin\debug\NitroNet.ViewEngine.dll 168 | 169 | 170 | ..\..\NitroNet\NitroNet.ViewEngine.TemplateHandler\bin\debug\NitroNet.ViewEngine.TemplateHandler.dll 171 | 172 | 173 | ..\..\NitroNet\Veil\Src\Veil\bin\debug\Veil.dll 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | {d5228116-9ebd-4055-b50b-33a2f28b2a6e} 189 | NitroNet.Sitecore 190 | 191 | 192 | 193 | 194 | 195 | 202 | -------------------------------------------------------------------------------- /NitroNet.Sitecore.UnityModules/NitroNet.Sitecore.UnityModules.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $id$.$productVersion$ 5 | $version$ 6 | Namics AG 7 | Namics AG 8 | http://www.microsoft.com/en-us/openness/licenses.aspx 9 | https://github.com/merkle-open/NitroNetSitecore 10 | https://raw.githubusercontent.com/namics/NitroNet/master/nuget_icon.png 11 | false 12 | NitroNet Unity package for Sitecore 13 | Copyright 2017 14 | nitro sitecore unity handlebars viewengine 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /NitroNet.Sitecore.UnityModules/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("NitroNet.Sitecore.UnityModules")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("Namics AG")] 12 | [assembly: AssemblyProduct("NitroNet.Sitecore.UnityModules")] 13 | [assembly: AssemblyCopyright("Copyright © Namics AG 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("f836ab0e-1182-4d45-836f-0066dede0d68")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.1.0.0")] 36 | [assembly: AssemblyFileVersion("1.1.0.0")] 37 | -------------------------------------------------------------------------------- /NitroNet.Sitecore.UnityModules/SitecoreUnityModule.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Practices.Unity; 2 | using NitroNet.Sitecore.Caching; 3 | using NitroNet.Sitecore.Rendering; 4 | using NitroNet.UnityModules; 5 | using NitroNet.ViewEngine.TemplateHandler; 6 | using NitroNet.ViewEngine.TemplateHandler.Grid; 7 | using Sitecore; 8 | using Sitecore.Data; 9 | using Sitecore.Mvc.Common; 10 | using Veil; 11 | 12 | namespace NitroNet.Sitecore.UnityModules 13 | { 14 | public class SitecoreUnityModule : IUnityModule 15 | { 16 | public void Configure(IUnityContainer container) 17 | { 18 | container.RegisterType( 19 | new InjectionFactory(u => GridContext.GetFromRenderingContext(ContextService.Get().GetCurrent()))); 20 | container.RegisterType(); 21 | container.RegisterType(new ContainerControlledLifetimeManager()); 22 | container.RegisterType( 23 | new ContainerControlledLifetimeManager()); 24 | container.RegisterType(new InjectionFactory(u => Context.Database)); 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /NitroNet.Sitecore.UnityModules/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /NitroNet.Sitecore.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.4.33103.184 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NitroNet.Sitecore", "NitroNet.Sitecore\NitroNet.Sitecore.csproj", "{D5228116-9EBD-4055-B50B-33A2F28B2A6E}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NitroNet.Sitecore.UnityModules", "NitroNet.Sitecore.UnityModules\NitroNet.Sitecore.UnityModules.csproj", "{F836AB0E-1182-4D45-836F-0066DEDE0D68}" 9 | EndProject 10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NitroNet.Sitecore.CastleWindsorModules", "NitroNet.Sitecore.CastleWindsorModules\NitroNet.Sitecore.CastleWindsorModules.csproj", "{7AB3D8F6-200A-4C56-8310-4FCBF862815B}" 11 | EndProject 12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NitroNet.Sitecore.Microsoft.DependencyInjection", "NitroNet.Sitecore.Microsoft.DependencyInjection\NitroNet.Sitecore.Microsoft.DependencyInjection.csproj", "{4252660C-89CA-43A2-9CBF-8FB66F710A42}" 13 | EndProject 14 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{0B61BA54-29AD-469C-9F41-170C9879E6C6}" 15 | ProjectSection(SolutionItems) = preProject 16 | .nuget\NuGet.Config = .nuget\NuGet.Config 17 | .nuget\NuGet.targets = .nuget\NuGet.targets 18 | EndProjectSection 19 | EndProject 20 | Global 21 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 22 | Debug|Any CPU = Debug|Any CPU 23 | Debug-SC81|Any CPU = Debug-SC81|Any CPU 24 | Debug-SC82|Any CPU = Debug-SC82|Any CPU 25 | Debug-SC90|Any CPU = Debug-SC90|Any CPU 26 | Release|Any CPU = Release|Any CPU 27 | Release-SC81|Any CPU = Release-SC81|Any CPU 28 | Release-SC82|Any CPU = Release-SC82|Any CPU 29 | Release-SC90|Any CPU = Release-SC90|Any CPU 30 | EndGlobalSection 31 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 32 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E}.Debug-SC81|Any CPU.ActiveCfg = Debug-SC81|Any CPU 35 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E}.Debug-SC81|Any CPU.Build.0 = Debug-SC81|Any CPU 36 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E}.Debug-SC82|Any CPU.ActiveCfg = Debug-SC82|Any CPU 37 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E}.Debug-SC82|Any CPU.Build.0 = Debug-SC82|Any CPU 38 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E}.Debug-SC90|Any CPU.ActiveCfg = Debug-SC90|Any CPU 39 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E}.Debug-SC90|Any CPU.Build.0 = Debug-SC90|Any CPU 40 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E}.Release|Any CPU.ActiveCfg = Release|Any CPU 41 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E}.Release|Any CPU.Build.0 = Release|Any CPU 42 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E}.Release-SC81|Any CPU.ActiveCfg = Release-SC81|Any CPU 43 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E}.Release-SC81|Any CPU.Build.0 = Release-SC81|Any CPU 44 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E}.Release-SC82|Any CPU.ActiveCfg = Release-SC82|Any CPU 45 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E}.Release-SC82|Any CPU.Build.0 = Release-SC82|Any CPU 46 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E}.Release-SC90|Any CPU.ActiveCfg = Release-SC90|Any CPU 47 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E}.Release-SC90|Any CPU.Build.0 = Release-SC90|Any CPU 48 | {F836AB0E-1182-4D45-836F-0066DEDE0D68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 49 | {F836AB0E-1182-4D45-836F-0066DEDE0D68}.Debug-SC81|Any CPU.ActiveCfg = Debug-SC81|Any CPU 50 | {F836AB0E-1182-4D45-836F-0066DEDE0D68}.Debug-SC81|Any CPU.Build.0 = Debug-SC81|Any CPU 51 | {F836AB0E-1182-4D45-836F-0066DEDE0D68}.Debug-SC82|Any CPU.ActiveCfg = Debug-SC82|Any CPU 52 | {F836AB0E-1182-4D45-836F-0066DEDE0D68}.Debug-SC82|Any CPU.Build.0 = Debug-SC82|Any CPU 53 | {F836AB0E-1182-4D45-836F-0066DEDE0D68}.Debug-SC90|Any CPU.ActiveCfg = Debug-SC90|Any CPU 54 | {F836AB0E-1182-4D45-836F-0066DEDE0D68}.Release|Any CPU.ActiveCfg = Release|Any CPU 55 | {F836AB0E-1182-4D45-836F-0066DEDE0D68}.Release-SC81|Any CPU.ActiveCfg = Release-SC81|Any CPU 56 | {F836AB0E-1182-4D45-836F-0066DEDE0D68}.Release-SC81|Any CPU.Build.0 = Release-SC81|Any CPU 57 | {F836AB0E-1182-4D45-836F-0066DEDE0D68}.Release-SC82|Any CPU.ActiveCfg = Release-SC82|Any CPU 58 | {F836AB0E-1182-4D45-836F-0066DEDE0D68}.Release-SC82|Any CPU.Build.0 = Release-SC82|Any CPU 59 | {F836AB0E-1182-4D45-836F-0066DEDE0D68}.Release-SC90|Any CPU.ActiveCfg = Release-SC90|Any CPU 60 | {7AB3D8F6-200A-4C56-8310-4FCBF862815B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 61 | {7AB3D8F6-200A-4C56-8310-4FCBF862815B}.Debug-SC81|Any CPU.ActiveCfg = Debug-SC81|Any CPU 62 | {7AB3D8F6-200A-4C56-8310-4FCBF862815B}.Debug-SC81|Any CPU.Build.0 = Debug-SC81|Any CPU 63 | {7AB3D8F6-200A-4C56-8310-4FCBF862815B}.Debug-SC82|Any CPU.ActiveCfg = Debug-SC82|Any CPU 64 | {7AB3D8F6-200A-4C56-8310-4FCBF862815B}.Debug-SC82|Any CPU.Build.0 = Debug-SC82|Any CPU 65 | {7AB3D8F6-200A-4C56-8310-4FCBF862815B}.Debug-SC90|Any CPU.ActiveCfg = Debug-SC90|Any CPU 66 | {7AB3D8F6-200A-4C56-8310-4FCBF862815B}.Release|Any CPU.ActiveCfg = Release|Any CPU 67 | {7AB3D8F6-200A-4C56-8310-4FCBF862815B}.Release-SC81|Any CPU.ActiveCfg = Release-SC81|Any CPU 68 | {7AB3D8F6-200A-4C56-8310-4FCBF862815B}.Release-SC81|Any CPU.Build.0 = Release-SC81|Any CPU 69 | {7AB3D8F6-200A-4C56-8310-4FCBF862815B}.Release-SC82|Any CPU.ActiveCfg = Release-SC82|Any CPU 70 | {7AB3D8F6-200A-4C56-8310-4FCBF862815B}.Release-SC82|Any CPU.Build.0 = Release-SC82|Any CPU 71 | {7AB3D8F6-200A-4C56-8310-4FCBF862815B}.Release-SC90|Any CPU.ActiveCfg = Release-SC90|Any CPU 72 | {4252660C-89CA-43A2-9CBF-8FB66F710A42}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 73 | {4252660C-89CA-43A2-9CBF-8FB66F710A42}.Debug|Any CPU.Build.0 = Debug|Any CPU 74 | {4252660C-89CA-43A2-9CBF-8FB66F710A42}.Debug-SC81|Any CPU.ActiveCfg = Debug-SC82|Any CPU 75 | {4252660C-89CA-43A2-9CBF-8FB66F710A42}.Debug-SC82|Any CPU.ActiveCfg = Debug-SC82|Any CPU 76 | {4252660C-89CA-43A2-9CBF-8FB66F710A42}.Debug-SC82|Any CPU.Build.0 = Debug-SC82|Any CPU 77 | {4252660C-89CA-43A2-9CBF-8FB66F710A42}.Debug-SC90|Any CPU.ActiveCfg = Debug-SC90|Any CPU 78 | {4252660C-89CA-43A2-9CBF-8FB66F710A42}.Debug-SC90|Any CPU.Build.0 = Debug-SC90|Any CPU 79 | {4252660C-89CA-43A2-9CBF-8FB66F710A42}.Release|Any CPU.ActiveCfg = Release|Any CPU 80 | {4252660C-89CA-43A2-9CBF-8FB66F710A42}.Release|Any CPU.Build.0 = Release|Any CPU 81 | {4252660C-89CA-43A2-9CBF-8FB66F710A42}.Release-SC81|Any CPU.ActiveCfg = Release-SC82|Any CPU 82 | {4252660C-89CA-43A2-9CBF-8FB66F710A42}.Release-SC82|Any CPU.ActiveCfg = Release-SC82|Any CPU 83 | {4252660C-89CA-43A2-9CBF-8FB66F710A42}.Release-SC82|Any CPU.Build.0 = Release-SC82|Any CPU 84 | {4252660C-89CA-43A2-9CBF-8FB66F710A42}.Release-SC90|Any CPU.ActiveCfg = Release-SC90|Any CPU 85 | {4252660C-89CA-43A2-9CBF-8FB66F710A42}.Release-SC90|Any CPU.Build.0 = Release-SC90|Any CPU 86 | EndGlobalSection 87 | GlobalSection(SolutionProperties) = preSolution 88 | HideSolutionNode = FALSE 89 | EndGlobalSection 90 | GlobalSection(ExtensibilityGlobals) = postSolution 91 | SolutionGuid = {88A5E74C-DE1E-4CCE-A85F-67FDD2D2D1DB} 92 | EndGlobalSection 93 | EndGlobal 94 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/App_Config/Include/NitroNet/DynamicPlaceholder.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/App_Config/Include/NitroNet/EventHandlingInitializer.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/App_Config/Include/NitroNet/MvcRenderingPipeline.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/App_Config/Include/NitroNet/RegisterViewEngine.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/Caching/ISitecoreCache.cs: -------------------------------------------------------------------------------- 1 | namespace NitroNet.Sitecore.Caching 2 | { 3 | public interface ISitecoreCache 4 | { 5 | T GetAs(string key) where T : class; 6 | 7 | void Set(string key, T value) where T : class; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/Caching/ISitecoreCacheManager.cs: -------------------------------------------------------------------------------- 1 | namespace NitroNet.Sitecore.Caching 2 | { 3 | public interface ISitecoreCacheManager 4 | { 5 | ISitecoreCache Get(string name); 6 | 7 | void Clear(string name); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/Caching/SitecoreCache.cs: -------------------------------------------------------------------------------- 1 | using Sitecore.Caching; 2 | 3 | namespace NitroNet.Sitecore.Caching 4 | { 5 | public class SitecoreCache : CustomCache, ISitecoreCache 6 | { 7 | public SitecoreCache(string name, long maxSize) : base(name, maxSize) 8 | { 9 | } 10 | 11 | public T GetAs(string key) where T : class 12 | { 13 | var cacheValue = GetObject(key) as SitecoreCacheValue; 14 | if (cacheValue == null || cacheValue.Value == null) 15 | { 16 | return null; 17 | } 18 | 19 | return cacheValue.Value as T; 20 | } 21 | 22 | public void Set(string key, T value) where T : class 23 | { 24 | SetObject(key, new SitecoreCacheValue(value)); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/Caching/SitecoreCacheManager.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Concurrent; 2 | using Sitecore; 3 | 4 | namespace NitroNet.Sitecore.Caching 5 | { 6 | public class SitecoreCacheManager : ISitecoreCacheManager 7 | { 8 | private readonly ConcurrentDictionary _caches; 9 | 10 | public SitecoreCacheManager() 11 | { 12 | _caches = new ConcurrentDictionary(); 13 | } 14 | 15 | public ISitecoreCache Get(string name) 16 | { 17 | if (_caches.ContainsKey(name)) 18 | { 19 | return _caches[name]; 20 | } 21 | 22 | var cache = new SitecoreCache(name, StringUtil.ParseSizeString("10MB")); 23 | _caches[name] = cache; 24 | 25 | return cache; 26 | } 27 | 28 | public void Clear(string name) 29 | { 30 | if (_caches.ContainsKey(name)) 31 | { 32 | _caches[name].Clear(); 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/Caching/SitecoreCacheValue.cs: -------------------------------------------------------------------------------- 1 | using Sitecore.Caching; 2 | using SC = Sitecore; 3 | 4 | namespace NitroNet.Sitecore.Caching 5 | { 6 | public class SitecoreCacheValue : ICacheable 7 | { 8 | public SitecoreCacheValue(object value) 9 | { 10 | Value = value; 11 | Cacheable = true; 12 | } 13 | 14 | public object Value { get; set; } 15 | 16 | public long GetDataLength() 17 | { 18 | return SC.Reflection.TypeUtil.SizeOfObject(); 19 | } 20 | 21 | public bool Cacheable { get; set; } 22 | 23 | public bool Immutable 24 | { 25 | get { return true; } 26 | } 27 | 28 | public event DataLengthChangedDelegate DataLengthChanged; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/DynamicPlaceholder/DynamicPlaceholderExtension.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using Sitecore.Mvc.Helpers; 3 | 4 | namespace NitroNet.Sitecore.DynamicPlaceholder 5 | { 6 | /// 7 | /// Dynamic Placeholders for Sitecore 8.x 8 | /// 9 | public static class DynamicPlaceholderExtension 10 | { 11 | public static HtmlString DynamicPlaceholder(this SitecoreHelper helper, string key) 12 | { 13 | var id = helper.CurrentRendering.UniqueId; 14 | return helper.Placeholder(DynamicPlaceholderKeyProvider.GetKey(key, id)); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /NitroNet.Sitecore/DynamicPlaceholder/DynamicPlaceholderKeyProvider.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Text.RegularExpressions; 3 | 4 | namespace NitroNet.Sitecore.DynamicPlaceholder 5 | { 6 | /// 7 | /// Dynamic Placeholders for Sitecore 8.x 8 | /// 9 | static internal class DynamicPlaceholderKeyProvider 10 | { 11 | //text that ends in a GUID 12 | private const string DynamicKeyRegex = @"^(.+?)(?:_([^_]*))?_[\d\w]{8}\-([\d\w]{4}\-){3}[\d\w]{12}$"; 13 | 14 | public static bool TryGetValue(string placeholderKey, out string resultPlaceholderKey, out string resultPlaceholderIndex) 15 | { 16 | resultPlaceholderKey = null; 17 | resultPlaceholderIndex = null; 18 | 19 | var regex = new Regex(DynamicKeyRegex); 20 | var match = regex.Match(placeholderKey); 21 | if (match.Success && match.Groups.Count > 0) 22 | { 23 | resultPlaceholderKey = match.Groups[1].Value; 24 | resultPlaceholderIndex = match.Groups[2].Value; 25 | return true; 26 | } 27 | 28 | return false; 29 | } 30 | 31 | public static string GetKey(string key, Guid currentRenderingId) 32 | { 33 | if (currentRenderingId == Guid.Empty) 34 | return key; 35 | 36 | return string.Format("{0}_{1}", key, currentRenderingId); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /NitroNet.Sitecore/DynamicPlaceholder/Helpers/SitecoreHelperExtension.cs: -------------------------------------------------------------------------------- 1 | using System.Web; 2 | using NitroNet.Sitecore.DynamicPlaceholder.Pipelines.GetDynamicPlaceholderKeys; 3 | using Sitecore.Data; 4 | using Sitecore.Diagnostics; 5 | using Sitecore.Mvc.Helpers; 6 | using Sitecore.Mvc.Presentation; 7 | 8 | namespace NitroNet.Sitecore.DynamicPlaceholder.Helpers 9 | { 10 | /// 11 | /// Dynamic Placeholders extension for Sitecore 9.x 12 | /// 13 | public static class SitecoreHelperExtension 14 | { 15 | public static HtmlString DynamicPlaceholder(this SitecoreHelper helper, string placeholderName, ID placeholderSuffix) 16 | { 17 | Assert.ArgumentNotNull(placeholderName, nameof(placeholderName)); 18 | 19 | helper.CurrentRendering.Parameters[GetUniqueIdKeyWithinRendering.RenderingParameterKey] = placeholderSuffix.ToString(); 20 | 21 | return helper.DynamicPlaceholder(new DynamicPlaceholderDefinition(placeholderName)); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/DynamicPlaceholder/Pipelines/GetDynamicPlaceholderChromeData.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Sitecore; 3 | using Sitecore.Diagnostics; 4 | using Sitecore.Pipelines.GetChromeData; 5 | using Sitecore.Web.UI.PageModes; 6 | 7 | namespace NitroNet.Sitecore.DynamicPlaceholder.Pipelines 8 | { 9 | /// 10 | /// Dynamic Placeholders for Sitecore 8.x 11 | /// 12 | public class GetDynamicPlaceholderChromeData : GetChromeDataProcessor 13 | { 14 | public override void Process(GetChromeDataArgs args) 15 | { 16 | Assert.ArgumentNotNull(args, "args"); 17 | Assert.IsNotNull(args.ChromeData, "Chrome Data"); 18 | 19 | if (!"placeholder".Equals(args.ChromeType, StringComparison.OrdinalIgnoreCase)) 20 | return; 21 | 22 | var argument = args.CustomData["placeHolderKey"] as string; 23 | 24 | string placeholderKey; 25 | string placeholderIndex; 26 | if (!DynamicPlaceholderKeyProvider.TryGetValue(argument, out placeholderKey, out placeholderIndex)) 27 | return; 28 | 29 | if (args.Item == null) 30 | return; 31 | 32 | var layout = ChromeContext.GetLayout(args.Item); 33 | var item = Client.Page.GetPlaceholderItem(placeholderKey, args.Item.Database, layout); 34 | if (item == null) 35 | return; 36 | 37 | args.ChromeData.DisplayName = item.DisplayName; 38 | 39 | if (!string.IsNullOrEmpty(item.Appearance.ShortDescription)) 40 | args.ChromeData.ExpandedDisplayName = item.Appearance.ShortDescription; 41 | } 42 | } 43 | } -------------------------------------------------------------------------------- /NitroNet.Sitecore/DynamicPlaceholder/Pipelines/GetDynamicPlaceholderInitialKey/RemovePlaceholderUniqueKeySuffixWithCountOrId.cs: -------------------------------------------------------------------------------- 1 | using System.Text.RegularExpressions; 2 | using Sitecore.Mvc.Pipelines.Response.GetDynamicPlaceholderInitialKey; 3 | 4 | namespace NitroNet.Sitecore.DynamicPlaceholder.Pipelines.GetDynamicPlaceholderInitialKey 5 | { 6 | /// 7 | /// Dynamic Placeholders extension for Sitecore 9.x 8 | /// 9 | public class RemovePlaceholderUniqueKeySuffixWithCountOrId : RemovePlaceholderUniqueKeySuffix 10 | { 11 | private static readonly Regex DynamicPartMatcherWithId = 12 | new Regex("-{[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}}-([0-9]+|{[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}})$", RegexOptions.Compiled); 13 | 14 | public RemovePlaceholderUniqueKeySuffixWithCountOrId() 15 | { 16 | DynamicPartMatcher = DynamicPartMatcherWithId; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/DynamicPlaceholder/Pipelines/GetDynamicPlaceholderKeys/GetUniqueIdKeyWithinRendering.cs: -------------------------------------------------------------------------------- 1 | using Sitecore.Mvc.Pipelines.Response.GetDynamicPlaceholderKeys; 2 | 3 | namespace NitroNet.Sitecore.DynamicPlaceholder.Pipelines.GetDynamicPlaceholderKeys 4 | { 5 | /// 6 | /// Dynamic Placeholders extension for Sitecore 9.x 7 | /// 8 | public class GetUniqueIdKeyWithinRendering : GetDynamicPlaceholderKeysProcessor 9 | { 10 | public static readonly string RenderingParameterKey = "GetUniqueIdKeyWithinRendering"; 11 | 12 | public override void Process(GetDynamicPlaceholderKeysArgs args) 13 | { 14 | var rendering = args.Rendering; 15 | 16 | var uniqueKeysWithinRendering = rendering.Parameters[RenderingParameterKey]; 17 | 18 | if (!string.IsNullOrEmpty(uniqueKeysWithinRendering)) 19 | { 20 | args.UniqueSuffixesWithinRendering[0] = uniqueKeysWithinRendering; 21 | 22 | rendering.Parameters[RenderingParameterKey] = string.Empty; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/DynamicPlaceholder/Pipelines/GetDynamicPlaceholderRenderings.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Sitecore; 3 | using Sitecore.Data; 4 | using Sitecore.Data.Items; 5 | using Sitecore.Diagnostics; 6 | using Sitecore.Pipelines.GetPlaceholderRenderings; 7 | 8 | namespace NitroNet.Sitecore.DynamicPlaceholder.Pipelines 9 | { 10 | /// 11 | /// Dynamic Placeholders for Sitecore 8.x 12 | /// 13 | public class GetDynamicPlaceholderRenderings : GetAllowedRenderings 14 | { 15 | private readonly GetAllowedRenderings _innerAllowedRenderings; 16 | 17 | public GetDynamicPlaceholderRenderings() 18 | { 19 | _innerAllowedRenderings = new GetAllowedRenderings(); 20 | } 21 | 22 | public void Process(GetPlaceholderRenderingsArgs args) 23 | { 24 | Assert.IsNotNull(args, "args"); 25 | 26 | string placeholderKey; 27 | string placeholderIndex; 28 | if (!DynamicPlaceholderKeyProvider.TryGetValue(args.PlaceholderKey, out placeholderKey, out placeholderIndex)) 29 | return; 30 | 31 | Item placeholderItem = null; 32 | if (ID.IsNullOrEmpty(args.DeviceId)) 33 | { 34 | placeholderItem = Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase, 35 | args.LayoutDefinition); 36 | } 37 | else 38 | { 39 | using (new DeviceSwitcher(args.DeviceId, args.ContentDatabase)) 40 | { 41 | placeholderItem = Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase, 42 | args.LayoutDefinition); 43 | } 44 | } 45 | 46 | List collection = null; 47 | if (placeholderItem != null) 48 | { 49 | bool flag; 50 | args.HasPlaceholderSettings = true; 51 | collection = GetRenderings(placeholderItem, out flag); 52 | if (flag) 53 | { 54 | args.Options.ShowTree = false; 55 | } 56 | } 57 | if (collection != null) 58 | { 59 | if (args.PlaceholderRenderings == null) 60 | { 61 | args.PlaceholderRenderings = new List(); 62 | } 63 | args.PlaceholderRenderings.AddRange(collection); 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/Events/EventHandlingInitializer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Web.Mvc; 5 | using NitroNet.Sitecore.Caching; 6 | using NitroNet.Sitecore.Rendering; 7 | using Sitecore.Data.Events; 8 | using Sitecore.Data.Items; 9 | using Sitecore.Diagnostics; 10 | using Sitecore.Events; 11 | using Sitecore.Pipelines; 12 | 13 | namespace NitroNet.Sitecore.Events 14 | { 15 | public class EventHandlingInitializer 16 | { 17 | public void Process(PipelineArgs args) 18 | { 19 | Event.Subscribe("item:saved", OnSavedRaised); 20 | Event.Subscribe("item:saved:remote", OnSavedRaised); 21 | 22 | Event.Subscribe("publish:end", OnPublishRaised); 23 | Event.Subscribe("publish:end:remote", OnPublishRaised); 24 | } 25 | 26 | private static void OnPublishRaised(object sender, EventArgs e) 27 | { 28 | ExecutePublishEvents(); 29 | } 30 | 31 | private static void OnSavedRaised(object sender, EventArgs e) 32 | { 33 | var eventArgs = e as SitecoreEventArgs; 34 | var remoteEventArgs = e as ItemSavedRemoteEventArgs; 35 | 36 | Item item = null; 37 | if (eventArgs != null) 38 | { 39 | item = eventArgs.Parameters[0] as Item; 40 | } 41 | if (remoteEventArgs != null) 42 | { 43 | item = remoteEventArgs.Item; 44 | } 45 | 46 | if (item == null || item.Database.Name.Equals("web", StringComparison.OrdinalIgnoreCase)) 47 | { 48 | // Do not trigger save events for the web db 49 | return; 50 | } 51 | 52 | ExecuteSaveEvents(new[] { item }); 53 | } 54 | 55 | private static void ExecuteSaveEvents(IEnumerable items) 56 | { 57 | ClearSitecoreRenderingCache(items); 58 | } 59 | 60 | private static void ExecutePublishEvents() 61 | { 62 | ClearSitecoreRenderingCache(null); 63 | } 64 | 65 | private static void ClearSitecoreRenderingCache(IEnumerable items) 66 | { 67 | var cacheManager = DependencyResolver.Current.GetService(); 68 | 69 | if (items == null || 70 | items.Any(i => i.TemplateID.ToString().Equals(SitecoreRenderingRepository.ControllerRenderingId, StringComparison.InvariantCultureIgnoreCase))) 71 | { 72 | ClearSitecoreRenderingCacheInternal(cacheManager); 73 | } 74 | } 75 | 76 | private static void ClearSitecoreRenderingCacheInternal(ISitecoreCacheManager cacheManager) 77 | { 78 | cacheManager.Clear(SitecoreRenderingRepository.SitecoreRenderingCache); 79 | Log.Info(string.Format("{0} Cache has been cleared.", SitecoreRenderingRepository.SitecoreRenderingCache), typeof(EventHandlingInitializer)); 80 | } 81 | } 82 | } -------------------------------------------------------------------------------- /NitroNet.Sitecore/NitroNet.Sitecore.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {D5228116-9EBD-4055-B50B-33A2F28B2A6E} 8 | Library 9 | Properties 10 | NitroNet.Sitecore 11 | NitroNet.Sitecore 12 | 512 13 | v4.6.2 14 | ..\ 15 | true 16 | 17 | 18 | 19 | 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | pdbonly 30 | true 31 | bin\Release\ 32 | TRACE 33 | prompt 34 | 4 35 | 36 | 37 | true 38 | full 39 | false 40 | bin\Debug-SC90\ 41 | DEBUG;TRACE 42 | prompt 43 | 4 44 | 45 | 46 | pdbonly 47 | true 48 | bin\Release-SC90\ 49 | TRACE 50 | prompt 51 | 4 52 | 53 | 54 | v4.5.2 55 | true 56 | bin\Debug-SC82\ 57 | DEBUG;TRACE;SC8 58 | full 59 | AnyCPU 60 | prompt 61 | MinimumRecommendedRules.ruleset 62 | 63 | 64 | v4.5.2 65 | bin\Release-SC82\ 66 | TRACE;SC8 67 | true 68 | pdbonly 69 | AnyCPU 70 | prompt 71 | MinimumRecommendedRules.ruleset 72 | 73 | 74 | v4.5.2 75 | true 76 | bin\Debug-SC81\ 77 | DEBUG;TRACE;SC8 78 | full 79 | AnyCPU 80 | prompt 81 | MinimumRecommendedRules.ruleset 82 | 83 | 84 | v4.5.2 85 | bin\Release-SC81\ 86 | TRACE;SC8 87 | true 88 | pdbonly 89 | AnyCPU 90 | prompt 91 | MinimumRecommendedRules.ruleset 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | all 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | ..\..\NitroNet\NitroNet.Common\bin\release\NitroNet.Common.dll 177 | 178 | 179 | ..\..\NitroNet\NitroNet.Mvc\bin\release\NitroNet.Mvc.dll 180 | 181 | 182 | ..\..\NitroNet\NitroNet.ViewEngine\bin\release\NitroNet.ViewEngine.dll 183 | 184 | 185 | ..\..\NitroNet\NitroNet.ViewEngine.TemplateHandler\bin\release\NitroNet.ViewEngine.TemplateHandler.dll 186 | 187 | 188 | ..\..\NitroNet\Veil\Src\Veil\bin\release\Veil.dll 189 | 190 | 191 | 192 | 193 | 194 | 195 | ..\..\NitroNet\NitroNet.Common\bin\debug\NitroNet.Common.dll 196 | 197 | 198 | ..\..\NitroNet\NitroNet.Mvc\bin\debug\NitroNet.Mvc.dll 199 | 200 | 201 | ..\..\NitroNet\NitroNet.ViewEngine\bin\debug\NitroNet.ViewEngine.dll 202 | 203 | 204 | ..\..\NitroNet\NitroNet.ViewEngine.TemplateHandler\bin\debug\NitroNet.ViewEngine.TemplateHandler.dll 205 | 206 | 207 | ..\..\NitroNet\Veil\Src\Veil\bin\debug\Veil.dll 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | Designer 219 | 220 | 221 | 222 | 223 | 224 | 225 | 232 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/NitroNet.Sitecore.nuspec: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $id$.$productVersion$ 5 | $version$ 6 | Namics AG 7 | Namics AG 8 | http://www.microsoft.com/en-us/openness/licenses.aspx 9 | https://github.com/merkle-open/NitroNetSitecore 10 | https://raw.githubusercontent.com/namics/NitroNet/master/nuget_icon.png 11 | false 12 | NitroNet package for Sitecore 13 | Copyright 2018 14 | nitro sitecore handlebars viewengine 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/Pipelines/Initialize/RegisterNitroNetViewEngine.cs: -------------------------------------------------------------------------------- 1 | using System.Web.Mvc; 2 | using Sitecore.Pipelines; 3 | 4 | namespace NitroNet.Sitecore.Pipelines.Initialize 5 | { 6 | public class RegisterNitroNetViewEngine 7 | { 8 | public virtual void Process(PipelineArgs args) 9 | { 10 | ViewEngines.Engines.Add(DependencyResolver.Current.GetService()); 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/Pipelines/MvcRenderRendering/GenerateCacheKey.cs: -------------------------------------------------------------------------------- 1 | using Sitecore.Globalization; 2 | using Sitecore.Mvc.Extensions; 3 | using Sitecore.Mvc.Pipelines.Response.RenderRendering; 4 | using Sitecore.Mvc.Presentation; 5 | using System; 6 | 7 | namespace NitroNet.Sitecore.Pipelines.MvcRenderRendering 8 | { 9 | public class GenerateCacheKey : global::Sitecore.Mvc.Pipelines.Response.RenderRendering.GenerateCacheKey 10 | { 11 | protected override string GetDataPart(global::Sitecore.Mvc.Presentation.Rendering rendering) 12 | { 13 | var baseResult = base.GetDataPart(rendering) ?? string.Empty; 14 | 15 | var variation = rendering["data"]; 16 | if (variation == null) 17 | { 18 | return baseResult; 19 | } 20 | 21 | return baseResult + "_#data:" + variation; 22 | } 23 | protected override string GenerateKey(global::Sitecore.Mvc.Presentation.Rendering rendering, RenderRenderingArgs args) 24 | { 25 | string text = rendering.Caching.CacheKey.OrIfEmpty(args.Rendering.Renderer.ValueOrDefault((Renderer renderer) => renderer.CacheKey)); 26 | string result; 27 | if (StringExtensions.IsEmptyOrNull(text)) 28 | { 29 | result = null; 30 | } 31 | else 32 | { 33 | string text2 = text + "_#lang:" + Language.Current.Name.ToUpper(); 34 | RenderingCachingDefinition caching = rendering.Caching; 35 | if (rendering["ClearOnIndexUpdate"] == "1") 36 | { 37 | text2 += "_#index"; 38 | } 39 | if (caching.VaryByData) 40 | { 41 | text2 += this.GetDataPart(rendering); 42 | } 43 | if (caching.VaryByDevice) 44 | { 45 | text2 += this.GetDevicePart(rendering); 46 | } 47 | if (caching.VaryByLogin) 48 | { 49 | text2 += this.GetLoginPart(rendering); 50 | } 51 | if (caching.VaryByUser) 52 | { 53 | text2 += this.GetUserPart(rendering); 54 | } 55 | if (caching.VaryByParameters) 56 | { 57 | text2 += this.GetParametersPart(rendering); 58 | } 59 | if (caching.VaryByQueryString) 60 | { 61 | text2 += this.GetQueryStringPart(rendering); 62 | } 63 | result = text2; 64 | } 65 | return result; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/Pipelines/MvcRenderRendering/SetCacheability.cs: -------------------------------------------------------------------------------- 1 | using Sitecore.Mvc.Pipelines.Response.RenderRendering; 2 | 3 | namespace NitroNet.Sitecore.Pipelines.MvcRenderRendering 4 | { 5 | public class SetCacheability : global::Sitecore.Mvc.Pipelines.Response.RenderRendering.SetCacheability 6 | { 7 | protected virtual string ClearOnIndexUpdateCacheKey 8 | { 9 | get { return "ClearOnIndexUpdate"; } 10 | } 11 | 12 | protected override bool IsCacheable(global::Sitecore.Mvc.Presentation.Rendering rendering, 13 | RenderRenderingArgs args) 14 | { 15 | if (rendering.RenderingItem != null && rendering.RenderingItem.Caching != null) 16 | { 17 | rendering.Caching.Cacheable = rendering.RenderingItem.Caching.Cacheable; 18 | } 19 | bool flag = rendering.Caching.Cacheable && this.DoesContextAllowCaching(args); 20 | if (flag) 21 | { 22 | this.AddCachingSettings(rendering); 23 | } 24 | return flag; 25 | } 26 | 27 | protected virtual void AddCachingSettings(global::Sitecore.Mvc.Presentation.Rendering rendering) 28 | { 29 | rendering.Caching.VaryByData = rendering.RenderingItem.Caching.VaryByData; 30 | rendering.Caching.VaryByDevice = rendering.RenderingItem.Caching.VaryByDevice; 31 | rendering.Caching.VaryByLogin = rendering.RenderingItem.Caching.VaryByLogin; 32 | rendering.Caching.VaryByParameters = rendering.RenderingItem.Caching.VaryByParm; 33 | rendering.Caching.VaryByQueryString = rendering.RenderingItem.Caching.VaryByQueryString; 34 | rendering.Caching.VaryByUser = rendering.RenderingItem.Caching.VaryByUser; 35 | rendering[this.ClearOnIndexUpdateCacheKey] = 36 | (rendering.RenderingItem.Caching.ClearOnIndexUpdate ? "1" : string.Empty); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /NitroNet.Sitecore/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("NitroNet.Sitecore")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("NitroNet.Sitecore")] 13 | [assembly: AssemblyCopyright("Copyright © Namics AG 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("d5228116-9ebd-4055-b50b-33a2f28b2a6e")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.1.0.0")] 36 | [assembly: AssemblyFileVersion("1.1.0.0")] 37 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/Rendering/ISitecoreRenderingRepository.cs: -------------------------------------------------------------------------------- 1 | namespace NitroNet.Sitecore.Rendering 2 | { 3 | public interface ISitecoreRenderingRepository 4 | { 5 | string GetRenderingId(string id); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/Rendering/SitecoreRenderingRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using NitroNet.Sitecore.Caching; 5 | using SC = Sitecore; 6 | 7 | namespace NitroNet.Sitecore.Rendering 8 | { 9 | public class SitecoreRenderingRepository : ISitecoreRenderingRepository 10 | { 11 | public const string ControllerRenderingId = "{2A3E91A0-7987-44B5-AB34-35C2D9DE83B9}"; 12 | public const string SitecoreRenderingCache = "NitroNet.SitecoreRenderings"; 13 | private readonly ISitecoreCache _cache; 14 | 15 | public SitecoreRenderingRepository(ISitecoreCacheManager cacheManager) 16 | { 17 | _cache = cacheManager.Get(SitecoreRenderingCache); 18 | } 19 | 20 | private static string GetCacheKey() 21 | { 22 | return "allRenderings"; 23 | } 24 | 25 | private IDictionary GetAllRenderings() 26 | { 27 | var allRenderings = new Dictionary(); 28 | var layoutItem = SC.Context.Database.GetItem(SC.ItemIDs.LayoutRoot); 29 | 30 | if (layoutItem != null) 31 | { 32 | var renderings = layoutItem.Axes.GetDescendants(); 33 | foreach (var rendering in renderings) 34 | { 35 | if (rendering.TemplateID.ToString().Equals(ControllerRenderingId, StringComparison.InvariantCultureIgnoreCase)) 36 | { 37 | allRenderings.Add(CleanName(rendering.Name), rendering.ID.Guid.ToString()); 38 | } 39 | } 40 | } 41 | 42 | return allRenderings; 43 | } 44 | 45 | public string GetRenderingId(string renderingName) 46 | { 47 | var cleanRenderingName = CleanName(renderingName); 48 | var renderings = _cache.GetAs>(GetCacheKey()); 49 | 50 | if (renderings == null) 51 | { 52 | renderings = GetAllRenderings(); 53 | _cache.Set(GetCacheKey(), renderings); 54 | } 55 | 56 | return !renderings.ContainsKey(cleanRenderingName) ? null : renderings[cleanRenderingName]; 57 | } 58 | 59 | private static string CleanName(string text) 60 | { 61 | return string.IsNullOrEmpty(text) ? string.Empty : text.Replace(" ", string.Empty).Replace("-", string.Empty).ToLower(CultureInfo.InvariantCulture); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/SitecoreMvcNitroTemplateHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Globalization; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Web.Mvc; 7 | using System.Web.Mvc.Html; 8 | using NitroNet.Mvc; 9 | using NitroNet.Sitecore.Rendering; 10 | using NitroNet.ViewEngine; 11 | using NitroNet.ViewEngine.TemplateHandler; 12 | using Sitecore.Diagnostics; 13 | using Sitecore.Mvc; 14 | using Sitecore.Mvc.Presentation; 15 | using RenderingContext = Veil.RenderingContext; 16 | using SC = Sitecore; 17 | 18 | #if SC8 19 | using NitroNet.Sitecore.DynamicPlaceholder; 20 | #else 21 | using Sitecore.Data; 22 | using NitroNet.Sitecore.DynamicPlaceholder.Helpers; 23 | #endif 24 | 25 | namespace NitroNet.Sitecore 26 | { 27 | public class SitecoreMvcNitroTemplateHandler : INitroTemplateHandler 28 | { 29 | private const string ThisIdentifier = "this"; 30 | private const string SkinParameter = "template"; 31 | private const string DataParameter = "data"; 32 | private const string ModelParameter = "model"; 33 | 34 | private readonly IComponentRepository _componentRepository; 35 | private readonly ISitecoreRenderingRepository _renderingRepository; 36 | 37 | public SitecoreMvcNitroTemplateHandler(IComponentRepository componentRepository, ISitecoreRenderingRepository renderingRepository) 38 | { 39 | _componentRepository = componentRepository; 40 | _renderingRepository = renderingRepository; 41 | } 42 | 43 | private static HtmlHelper CreateHtmlHelper(RenderingContext context) 44 | { 45 | return CreateHtmlHelper(GetMvcContext(context)); 46 | } 47 | 48 | private static MvcRenderingContext GetMvcContext(RenderingContext context) 49 | { 50 | var mvcContext = context as MvcRenderingContext; 51 | if (mvcContext == null) 52 | throw new InvalidOperationException("SitecoreMvcNitroTemplateHandler can only be used inside a Mvc application."); 53 | return mvcContext; 54 | } 55 | 56 | private static HtmlHelper CreateHtmlHelper(MvcRenderingContext mvcContext) 57 | { 58 | return new HtmlHelper(mvcContext.ViewContext, mvcContext.ViewDataContainer); 59 | } 60 | 61 | public Task RenderPlaceholderAsync(object model, string key, string index, RenderingContext context) 62 | { 63 | throw new NotImplementedException(); 64 | } 65 | 66 | public void RenderPlaceholder(object model, string key, string index, RenderingContext context) 67 | { 68 | var htmlHelper = CreateHtmlHelper(context); 69 | #if SC8 70 | var dynamicKey = key; 71 | if (!string.IsNullOrEmpty(index)) 72 | { 73 | dynamicKey = key + "_" + index; 74 | } 75 | 76 | context.Writer.Write(htmlHelper.Sitecore().DynamicPlaceholder(dynamicKey)); 77 | #else 78 | if (string.IsNullOrEmpty(index)) 79 | { 80 | context.Writer.Write(htmlHelper.Sitecore().Placeholder(key)); 81 | return; 82 | } 83 | 84 | if (int.TryParse(index, out var parsedIntIndex)) 85 | { 86 | context.Writer.Write(htmlHelper.Sitecore().DynamicPlaceholder(key, 1, 0, parsedIntIndex)); 87 | return; 88 | } 89 | 90 | if (ID.TryParse(index, out var parsedIdIndex)) 91 | { 92 | context.Writer.Write(htmlHelper.Sitecore().DynamicPlaceholder(key, parsedIdIndex)); 93 | return; 94 | } 95 | 96 | throw new ArgumentException($"'Index' attribute of {{placeholder}} helper needs to be an integer or Sitecore.Data.ID string. The chosen index is '{index}'"); 97 | #endif 98 | } 99 | 100 | public void RenderComponent(RenderingParameter component, RenderingParameter skin, RenderingParameter dataVariation, 101 | object model, RenderingContext context) 102 | { 103 | var requestContext = PageContext.Current.RequestContext; 104 | var savedSkin = requestContext.RouteData.Values[SkinParameter]; 105 | var savedModel = requestContext.RouteData.Values[ModelParameter]; 106 | var savedDataVariation = requestContext.RouteData.Values[DataParameter]; 107 | try 108 | { 109 | // Try to get values from model 110 | AggregateRenderingParameter(component, model); 111 | AggregateRenderingParameter(skin, model); 112 | 113 | if (string.IsNullOrEmpty(dataVariation.Value)) 114 | { 115 | dataVariation.Value = component.Value; 116 | } 117 | 118 | var propertyName = CleanName(dataVariation.Value); 119 | 120 | object subModel = null; 121 | 122 | if (dataVariation.Value.Equals(ThisIdentifier)) 123 | { 124 | subModel = model; 125 | } 126 | 127 | var modelFound = false; 128 | 129 | if (subModel == null) 130 | { 131 | modelFound = GetValueFromObjectHierarchically(model, propertyName, out subModel); 132 | } 133 | 134 | if (subModel != null && !(subModel is string)) 135 | { 136 | var componentIdBySkin = GetComponentId(component.Value, skin.Value); 137 | RenderPartial(componentIdBySkin, subModel, context); 138 | return; 139 | } 140 | 141 | if (modelFound && subModel == null) 142 | { 143 | Log.Error( 144 | string.Format("Property {0} of model {1} is null.", propertyName, model.GetType()), this); 145 | return; 146 | } 147 | 148 | var htmlHelper = CreateHtmlHelper(context); 149 | var parts = component.Value.Split('/'); 150 | var componentName = parts[parts.Length - 1]; 151 | var cleanComponentName = CleanName(componentName); 152 | var renderingId = _renderingRepository.GetRenderingId(cleanComponentName); 153 | requestContext.RouteData.Values[SkinParameter] = skin.Value ?? string.Empty; 154 | requestContext.RouteData.Values[DataParameter] = dataVariation.Value ?? string.Empty; 155 | 156 | if (renderingId != null) 157 | { 158 | // TODO: Cache! 159 | context.Writer.Write(htmlHelper.Sitecore() 160 | .Rendering(renderingId, new { data = dataVariation.Value ?? string.Empty})); 161 | } 162 | else 163 | { 164 | var controller = CleanControllerName(componentName); 165 | 166 | context.Writer.Write(htmlHelper.Sitecore().Controller(controller)); 167 | 168 | Log.Warn( 169 | string.Format( 170 | "Controller {0} gets directly called by NitroNet. " + 171 | "Consider to create a rendering with name \"{1}\" in order to let the controller be called by the Sitecore rendering pipeline. " + 172 | "Component: {2}, Template: {3}, Data: {4}", 173 | controller, cleanComponentName, component.Value, skin.Value, dataVariation.Value), this); 174 | } 175 | } 176 | finally 177 | { 178 | requestContext.RouteData.Values[SkinParameter] = savedSkin; 179 | requestContext.RouteData.Values[DataParameter] = savedDataVariation; 180 | requestContext.RouteData.Values[ModelParameter] = savedModel; 181 | } 182 | } 183 | 184 | public Task RenderLabelAsync(string key, RenderingContext context) 185 | { 186 | var label = SC.Globalization.Translate.Text(key); 187 | 188 | context.Writer.Write(label); 189 | 190 | return Task.FromResult(true); 191 | } 192 | 193 | public void RenderLabel(string key, RenderingContext context) 194 | { 195 | var label = SC.Globalization.Translate.Text(key); 196 | 197 | context.Writer.Write(label); 198 | } 199 | 200 | public Task RenderPartialAsync(string template, object model, RenderingContext context) 201 | { 202 | throw new NotImplementedException(); 203 | } 204 | 205 | public void RenderPartial(string template, object model, RenderingContext context) 206 | { 207 | CreateHtmlHelper(context).RenderPartial(template, model); 208 | } 209 | 210 | private string GetComponentId(string componentId, string skin) 211 | { 212 | var componentDefinition = _componentRepository.GetComponentDefinitionByIdAsync(componentId).Result; 213 | if (componentDefinition != null) 214 | { 215 | FileTemplateInfo templateInfo; 216 | if (string.IsNullOrEmpty(skin) || componentDefinition.Skins == null || 217 | !componentDefinition.Skins.TryGetValue(skin, out templateInfo)) 218 | templateInfo = componentDefinition.DefaultTemplate; 219 | 220 | return templateInfo.Id; 221 | } 222 | 223 | return null; 224 | } 225 | 226 | private static string CleanControllerName(string text) 227 | { 228 | if (string.IsNullOrEmpty(text)) 229 | { 230 | return string.Empty; 231 | } 232 | 233 | var words = text.Split(' ', '-'); 234 | var sb = new StringBuilder(); 235 | 236 | foreach (var s in words) 237 | { 238 | var firstLetter = s.Substring(0, 1); 239 | var rest = s.Substring(1, s.Length - 1); 240 | sb.Append(firstLetter.ToUpper(CultureInfo.InvariantCulture) + rest); 241 | } 242 | 243 | return sb.ToString(); 244 | } 245 | 246 | private string CleanName(string text) 247 | { 248 | if (string.IsNullOrEmpty(text)) 249 | { 250 | return string.Empty; 251 | } 252 | 253 | return text.Replace(" ", string.Empty).Replace("-", string.Empty).ToLower(CultureInfo.InvariantCulture); 254 | } 255 | 256 | private bool GetValueFromObjectHierarchically(object model, string propertyName, out object modelValue) 257 | { 258 | modelValue = null; 259 | if (propertyName.IndexOf(".", StringComparison.Ordinal) <= 0) 260 | { 261 | return GetValueFromObject(model, propertyName, out modelValue); 262 | } 263 | 264 | var subModel = model; 265 | foreach (var s in propertyName.Split('.')) 266 | { 267 | var modelFound = GetValueFromObject(subModel, s, out subModel); 268 | if (!modelFound) 269 | { 270 | return false; 271 | } 272 | 273 | if (subModel == null) 274 | { 275 | break; 276 | } 277 | } 278 | 279 | modelValue = subModel; 280 | return true; 281 | } 282 | 283 | private bool GetValueFromObject(object model, string propertyName, out object modelValue) 284 | { 285 | modelValue = null; 286 | var dataProperty = 287 | model.GetType().GetProperties().FirstOrDefault(prop => prop.Name.ToLower().Equals(propertyName)); 288 | if (dataProperty == null) 289 | { 290 | return false; 291 | } 292 | 293 | modelValue = dataProperty.GetValue(model); 294 | return true; 295 | } 296 | 297 | private bool AggregateRenderingParameter(RenderingParameter renderingParameter, object model) 298 | { 299 | if (renderingParameter == null) 300 | { 301 | return false; 302 | } 303 | 304 | if (!renderingParameter.IsDynamic) 305 | { 306 | return false; 307 | } 308 | 309 | var propertyName = CleanName(renderingParameter.Value); 310 | object dynamicName; 311 | if (GetValueFromObjectHierarchically(model, propertyName, out dynamicName) && dynamicName is string) 312 | { 313 | renderingParameter.Value = dynamicName.ToString(); 314 | return true; 315 | } 316 | 317 | return false; 318 | } 319 | } 320 | } 321 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/SitecoreMvcNitroTemplateHandlerFactory.cs: -------------------------------------------------------------------------------- 1 | using NitroNet.Sitecore.Rendering; 2 | using NitroNet.ViewEngine; 3 | using NitroNet.ViewEngine.TemplateHandler; 4 | 5 | namespace NitroNet.Sitecore 6 | { 7 | public class SitecoreMvcNitroTemplateHandlerFactory : INitroTemplateHandlerFactory 8 | { 9 | private readonly IComponentRepository _componentRepository; 10 | private readonly ISitecoreRenderingRepository _sitecoreRenderingRepository; 11 | 12 | public SitecoreMvcNitroTemplateHandlerFactory(IComponentRepository componentRepository, 13 | ISitecoreRenderingRepository sitecoreRenderingRepository) 14 | { 15 | _componentRepository = componentRepository; 16 | _sitecoreRenderingRepository = sitecoreRenderingRepository; 17 | } 18 | 19 | public INitroTemplateHandler Create() 20 | { 21 | return new SitecoreMvcNitroTemplateHandler(_componentRepository, _sitecoreRenderingRepository); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /NitroNet.Sitecore/SitecoreNitroNetViewEngine.cs: -------------------------------------------------------------------------------- 1 | using System.IO; 2 | using System.Linq; 3 | using System.Threading.Tasks; 4 | using System.Web.Mvc; 5 | using Newtonsoft.Json.Linq; 6 | using NitroNet.Mvc; 7 | using NitroNet.ViewEngine; 8 | using Sitecore.Mvc.Common; 9 | using Sitecore.Mvc.Presentation; 10 | using IView = NitroNet.ViewEngine.IView; 11 | using IViewEngine = System.Web.Mvc.IViewEngine; 12 | using RenderingContext = Veil.RenderingContext; 13 | 14 | namespace NitroNet.Sitecore 15 | { 16 | public class SitecoreNitroNetViewEngine : NitroNetViewEngine, IViewEngine 17 | { 18 | public SitecoreNitroNetViewEngine(ViewEngine.IViewEngine viewEngine, ITemplateRepository templateRepository, IModelTypeProvider modelTypeProvider, IComponentRepository componentRepository) 19 | : base(viewEngine, templateRepository, modelTypeProvider, componentRepository) 20 | { 21 | } 22 | 23 | ViewEngineResult IViewEngine.FindView(ControllerContext controllerContext, string viewName, string masterName, bool useCache) 24 | { 25 | string templateId; 26 | if (TryGetView(viewName, out templateId)) 27 | return FindView(controllerContext, templateId, masterName, useCache); 28 | 29 | return FindView(controllerContext, viewName, masterName, useCache); 30 | } 31 | 32 | ViewEngineResult IViewEngine.FindPartialView(ControllerContext controllerContext, string partialViewName, bool useCache) 33 | { 34 | string templateId; 35 | if (TryGetView(partialViewName, out templateId)) 36 | return FindPartialView(controllerContext, templateId, useCache); 37 | 38 | return FindPartialView(controllerContext, partialViewName, useCache); 39 | } 40 | 41 | protected override IView CreateAdapter(IView view) 42 | { 43 | return new SitecoreViewAdapter(view); 44 | } 45 | 46 | protected override MvcRenderingContext ResolveContext(ViewContext viewContext, IViewDataContainer viewDataContainer, TextWriter writer) 47 | { 48 | var context = ContextService.Get().GetCurrentOrDefault(); 49 | return new MvcRenderingContext(viewContext, viewDataContainer, writer, context); 50 | } 51 | 52 | private static bool TryGetView(string viewName, out string templateId) 53 | { 54 | templateId = null; 55 | if (Path.GetExtension(viewName) == ".cshtml") 56 | { 57 | templateId = GetTemplateId(viewName); 58 | return true; 59 | } 60 | return false; 61 | } 62 | 63 | private static string GetTemplateId(string viewName) 64 | { 65 | var path = Path.Combine(Path.GetDirectoryName(viewName), Path.GetFileNameWithoutExtension(viewName)); 66 | 67 | path = path.Replace("\\", "/"); 68 | path = path.TrimStart('/'); 69 | 70 | return path; 71 | } 72 | 73 | private class SitecoreViewAdapter : ViewEngine.IView 74 | { 75 | private readonly IView _adaptee; 76 | 77 | public SitecoreViewAdapter(IView adaptee) 78 | { 79 | _adaptee = adaptee; 80 | } 81 | 82 | public Task RenderAsync(object model, RenderingContext context) 83 | { 84 | Render(model, context); 85 | return Task.FromResult(true); 86 | } 87 | 88 | public void Render(object model, RenderingContext context) 89 | { 90 | using (ContextService.Get().Push(context)) 91 | { 92 | var renderingModel = model as RenderingModel; 93 | if (renderingModel != null) 94 | { 95 | var renderingParameters = renderingModel.Rendering.Parameters.ToDictionary(k => k.Key, k => k.Value); 96 | _adaptee.Render(JObject.FromObject(renderingParameters), context); 97 | } 98 | else 99 | _adaptee.Render(model, context); 100 | } 101 | } 102 | } 103 | } 104 | } -------------------------------------------------------------------------------- /NitroNet.Sitecore/Skin/ISkinDefinition.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace NitroNet.Sitecore.Skin 4 | { 5 | public interface ISkinDefinition 6 | { 7 | ITemplateInfo DefaultTemplate { get; } 8 | IDictionary Skins { get; } 9 | } 10 | } -------------------------------------------------------------------------------- /NitroNet.Sitecore/Skin/ISkinRepository.cs: -------------------------------------------------------------------------------- 1 | namespace NitroNet.Sitecore.Skin 2 | { 3 | public interface ISkinRepository 4 | { 5 | bool TryGetSkinDefinition(string id, out ISkinDefinition skinDefinition); 6 | 7 | bool TryGetSkinTemplateInfo(string id, string skin, out ITemplateInfo templateInfo); 8 | } 9 | } -------------------------------------------------------------------------------- /NitroNet.Sitecore/Skin/ITemplateInfo.cs: -------------------------------------------------------------------------------- 1 | namespace NitroNet.Sitecore.Skin 2 | { 3 | public interface ITemplateInfo 4 | { 5 | string Id { get; } 6 | } 7 | } -------------------------------------------------------------------------------- /NitroNet.Sitecore/Skin/NitroNetSkinDefinition.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using NitroNet.ViewEngine; 3 | 4 | namespace NitroNet.Sitecore.Skin 5 | { 6 | public class NitroNetSkinDefinition : ISkinDefinition 7 | { 8 | private readonly ITemplateInfo _defaultTemplate; 9 | private readonly IDictionary _skins; 10 | 11 | public NitroNetSkinDefinition(ComponentDefinition componentDefinition) 12 | { 13 | _defaultTemplate = new NitroNetTemplateInfo(componentDefinition.DefaultTemplate); 14 | _skins = new Dictionary(); 15 | foreach (var skin in componentDefinition.Skins) 16 | { 17 | if (!_skins.ContainsKey(skin.Key)) 18 | _skins.Add(skin.Key, new NitroNetTemplateInfo(skin.Value)); 19 | } 20 | } 21 | 22 | public ITemplateInfo DefaultTemplate 23 | { 24 | get { return _defaultTemplate; } 25 | } 26 | 27 | public IDictionary Skins 28 | { 29 | get { return _skins; } 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /NitroNet.Sitecore/Skin/NitroNetSkinRepository.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using NitroNet.ViewEngine; 3 | 4 | namespace NitroNet.Sitecore.Skin 5 | { 6 | public class NitroNetSkinRepository : ISkinRepository 7 | { 8 | private readonly IComponentRepository _componentRepository; 9 | 10 | public NitroNetSkinRepository(IComponentRepository componentRepository) 11 | { 12 | _componentRepository = componentRepository; 13 | } 14 | 15 | public bool TryGetSkinDefinition(string id, out ISkinDefinition skinDefinition) 16 | { 17 | skinDefinition = null; 18 | var componentDefinitionTask = _componentRepository.GetComponentDefinitionByIdAsync(id); 19 | try 20 | { 21 | var componentDefinition = componentDefinitionTask.Result; 22 | if (componentDefinition != null) 23 | { 24 | skinDefinition = new NitroNetSkinDefinition(componentDefinition); 25 | return true; 26 | } 27 | } 28 | catch (AggregateException) 29 | { 30 | } 31 | return false; 32 | } 33 | 34 | public bool TryGetSkinTemplateInfo(string id, string skin, out ITemplateInfo templateInfo) 35 | { 36 | templateInfo = null; 37 | var componentDefinitionTask = _componentRepository.GetComponentDefinitionByIdAsync(id); 38 | try 39 | { 40 | var componentDefinition = componentDefinitionTask.Result; 41 | if (componentDefinition != null) 42 | { 43 | FileTemplateInfo fileTemplateInfo; 44 | if (componentDefinition.Skins.TryGetValue(skin, out fileTemplateInfo)) 45 | { 46 | templateInfo = new NitroNetTemplateInfo(fileTemplateInfo); 47 | return true; 48 | } 49 | } 50 | } 51 | catch (AggregateException) 52 | { 53 | } 54 | return false; 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /NitroNet.Sitecore/Skin/NitroNetTemplateInfo.cs: -------------------------------------------------------------------------------- 1 | using NitroNet.ViewEngine; 2 | 3 | namespace NitroNet.Sitecore.Skin 4 | { 5 | public class NitroNetTemplateInfo : ITemplateInfo 6 | { 7 | private readonly TemplateInfo _templateInfo; 8 | 9 | public NitroNetTemplateInfo(TemplateInfo templateInfo) 10 | { 11 | _templateInfo = templateInfo; 12 | } 13 | 14 | public string Id 15 | { 16 | get { return _templateInfo.Id; } 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /NitroNet.Sitecore/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![NitroNet Logo](docs/imgs/logo.png) 2 | 3 | NitroNet for Sitecore extends [NitroNet](https://github.com/merkle-open/NitroNet) with the support for the WCMS [Sitecore](http://www.sitecore.net). 4 | It handles all possible presentation scenarios to integrate a [handlebars](http://handlebarsjs.com) frontend into Sitecore without functional loss. In addition it's possible to get a hybrid integration with handlebars frontends (based on simple and logic-less view pages) and own Razor views (*.cshtml). 5 | 6 | ### NitroNet for Sitecore features 7 | There are [many features which come with NitroNet](https://github.com/merkle-open/NitroNet#nitronet-features) alone. On top of that NitroNet for Sitecore offers the following things: 8 | - Support for the following Sitecore characteristics: 9 | - MVC based renderings (e.g. Controller Rendering) 10 | - Placeholders 11 | - Full support for the Experience Editor 12 | - Personalization 13 | - etc... 14 | - Caching which fully integrates into the Sitecore caching mechanisms 15 | - Out of the box integration as view engine 16 | - Different NuGets for supported Sitecore versions and your preferred IoC framework 17 | 18 | ### What's NitroNet? 19 | [NitroNet](https://github.com/merkle-open/NitroNet) is a handlebars view engine with an intelligent built-in file system and the possibility to add custom helpers. Because of these two features NitroNet differs from other existing handlebars view engines. 20 | 21 | ### ... and whats Nitro? 22 | [Nitro](https://github.com/merkle-open/generator-nitro/) is a Node.js application for simple and complex frontend development with a tiny footprint. It provides a proven but flexible structure to develop your frontend code, even in a large team. 23 | 24 | ## How to get started 25 | For a particularly smooth start with NitroNet for Sitecore we advise you to just to through the chapters **Installation**, **Configuration** and **Getting started**. 26 | 27 | If you need some code samples you can have a look a chapter **Samples** and if you having some problems or are interested how NitroNet for Sitecore is integrated or can be used, just have a look at our **Demo Integration** based on the Sitecore Habitat solution. 28 | 29 | You can find all links below under [Table of contents](https://github.com/merkle-open/NitroNetSitecore#table-of-contents). 30 | 31 | It's also not a bad idea to have a look at NitroNet itself: https://github.com/merkle-open/NitroNet 32 | 33 | ## Future roadmap 34 | [Please look at the milestones regarding the features and time frames of future releases.](https://github.com/merkle-open/NitroNetSitecore/milestones) 35 | 36 | ## Contact / Contributing 37 | If you want to submit a bug or request a feature please feel free to open an issue. 38 | 39 | If you want to get in contact with us, just write an email to [Manuel Fischer](https://github.com/hombreDelPez) or [Fabian Geiger](https://github.com/naibafch). 40 | 41 | Pull requests are welcome! 42 | 43 | ## Credits and special thanks 44 | Thanks to all the people who made and released these awesome resources for free! 45 | 46 | Special thanks to [Marco Schälle](https://github.com/marcoschaelle) and [Stefan Schälle](https://github.com/schaelle) who fight for a smart way to integrate Frontends into ASP.NET and created the predecessor [TerrificNet](https://github.com/merkle-open/TerrificNet) of NitroNet itself. Marco and Stefan were our opinion leaders of this product. 47 | 48 | Also special thanks to [Mark Cassidy](https://github.com/cassidydotdk) for all product commits and propagation of our idea to the whole world. 49 | 50 | ## Table of contents 51 | - [Installation](docs/installation.md) 52 | - [Configuration](docs/configuration.md) 53 | - [Getting started](docs/getting-started.md) 54 | - [Samples](docs/samples.md) 55 | - [Demo Integration (Habitat)](https://github.com/hombreDelPez/Habitat/tree/feature/nitronet-sitecore-demo) 56 | - [Release Notes](https://github.com/merkle-open/NitroNetSitecore/releases) 57 | - [Known Issues](docs/known-issues.md) 58 | -------------------------------------------------------------------------------- /docs/configuration.md: -------------------------------------------------------------------------------- 1 | ## Table of contents 2 | - [Installation](installation.md) 3 | - [Configuration](configuration.md) 4 | - [Getting started](getting-started.md) 5 | - [Samples](samples.md) 6 | - [Release Notes](https://github.com/merkle-open/NitroNetSitecore/releases) 7 | - [Known Issues](known-issues.md) 8 | 9 | ## Configuration 10 | 11 | Please see the [configuration guide of NitroNet](https://github.com/merkle-open/NitroNet/blob/master/docs/configuration.md) to configure your NitroNet for Sitecore installation. -------------------------------------------------------------------------------- /docs/getting-started.md: -------------------------------------------------------------------------------- 1 | ## Table of contents 2 | - [Installation](installation.md) 3 | - [Configuration](configuration.md) 4 | - [Getting started](getting-started.md) 5 | - [Samples](samples.md) 6 | - [Release Notes](https://github.com/merkle-open/NitroNetSitecore/releases) 7 | - [Known Issues](known-issues.md) 8 | 9 | ## Getting started with NitroNet for Sitecore 10 | 11 | Please see the [getting started guide of NitroNet](https://github.com/merkle-open/NitroNet/blob/master/docs/getting-started.md) to learn about the basic MVC features of NitroNet. 12 | 13 | ### Create a Layout in Sitecore 14 | 15 | Create a layout item below `/sitecore/layout/Layouts` and set the `Path` field relative to the path you configured in the setting `NitroNet.BasePath`. Please make sure that you set the file name without the file extension. 16 | 17 | :exclamation: **Important:** The path must not have a leading slash: 18 | ![Layout path](imgs/layout_path.PNG) 19 | 20 | #### Example 21 | Assumption: 22 | - The layout file path is `/Nitro/Sample/frontend/views/layout.html` 23 | - `NitroNet.BasePath` setting is `Nitro/Sample` 24 | 25 | Conclusion: The resulting `Path` field value of the layout item is `frontend/views/layout` 26 | 27 | ### Create a Controller rendering in Sitecore 28 | 29 | You only need to create Controller renderings for static components or renderings you want to place on a placeholder. But when creating a Sitecore Controller rendering for a Nitro component you also have the big advantage that you can configure the Sitecore caching for this component. 30 | For more information on this matter please follow the [Samples](samples.md) page. 31 | 32 | Create a Controller rendering item below `/sitecore/layout/Renderings` and set the item name accoording to the components directory name (hyphens and case sensitivity can be ignored). Also set the `Controller` field to the controller you have created as shown in the example above. -------------------------------------------------------------------------------- /docs/imgs/layout_path.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/merkle-open/NitroNetSitecore/609c2e9e8c323bf099ef031322c092fc1e513ee6/docs/imgs/layout_path.PNG -------------------------------------------------------------------------------- /docs/imgs/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/merkle-open/NitroNetSitecore/609c2e9e8c323bf099ef031322c092fc1e513ee6/docs/imgs/logo.png -------------------------------------------------------------------------------- /docs/installation.md: -------------------------------------------------------------------------------- 1 | ## Table of contents 2 | - [Installation](installation.md) 3 | - [Configuration](configuration.md) 4 | - [Getting started](getting-started.md) 5 | - [Samples](samples.md) 6 | - [Release Notes](https://github.com/merkle-open/NitroNetSitecore/releases) 7 | - [Known Issues](known-issues.md) 8 | 9 | ## Installation 10 | 11 | ### Preconditions 12 | You need a handlebars frontend with a specific file structure (learn more about that here) or a [Nitro](https://github.com/merkle-open/generator-nitro/) project as a precondition of this installation manual. 13 | 14 | ### Step 1 - Install Sitecore 15 | Please install Sitecore on your local machine and create a Visual Studio project (a clean ASP.Net MVC solution) around of this. As a Sitecore developer you will know what to do ;-) . 16 | 17 | ### Step 2 - Install NitroNet for Sitecore 18 | There are several ways to install NitroNet for Sitecore. The easiest way is to use it together with Microsoft.DependencyInjection, Unity or CastleWindsor. 19 | 20 | Please choose between variant 21 | * **A** with Microsoft.DependencyInjection, Unity or CastleWindsor 22 | * **B** with another IoC Framework. 23 | 24 | **Important information**: Because there can be vital changes between different Sitecore versions, we have to make sure that a specific NitroNet.Sitecore Nuget works with a specific Sitecore version. Therefore we created the NuGets with a Sitecore suffix. So you can be sure that they are working with the declared Sitecore version. 25 | So for each supported Sitecore version you will find the corresponding NuGets. (e.g. all NuGets with Sitecore 8.2 compatibility end with the suffix `.Sitecore82`) 26 | 27 | #### (A) With Microsoft.DependencyInjection, Unity or CastleWindsor 28 | 29 | ##### NuGet Package Installation 30 | 31 | Execute following the line in your NuGet Package Manager to install NitroNet for Sitecore with your preferred IoC framework: 32 | 33 | ###### Microsoft.DependencyInjection 34 | 35 | Starting with Sitecore 8.2, this IoC container is supported out of the box. 36 | 37 | `PM >` `Install-Package NitroNet.Sitecore.Microsoft.DependencyInjection.Sitecore82` 38 | 39 | ###### Unity 40 | 41 | `PM >` `Install-Package NitroNet.Sitecore.UnityModules.Sitecore82` 42 | 43 | Optionally, we recommend to install the [Unity.Mvc](https://www.nuget.org/packages/Unity.Mvc/) which is a lightweight Unity bootstrapper for MVC applications: 44 | 45 | `PM >` `Install-Package Unity.Mvc` 46 | 47 | ###### CastleWindsor 48 | 49 | `PM >` `Install-Package NitroNet.Sitecore.CastleWindsorModules.Sitecore82` 50 | 51 | ##### Register the IoC containers 52 | 53 | ###### Microsoft.DependencyInjection 54 | When you are using NitroNet for Sitecore with Microsoft.DependencyInjection then there is nothing to do to active the IoC framework. 55 | The */App_Config/Include/NitroNet/DependencyInjection.config* is automatically installed with this NuGet and sets up the activation. 56 | 57 | ###### Unity 58 | To activate NitroNet for Sitecore with Unity, please add these lines to */App_Start/UnityConfig.cs* in your application ([Gist](https://gist.github.com/hombreDelPez/a268d69a0b03d5e117d0707f0b3132d9)): 59 | 60 | ```csharp 61 | public static void RegisterTypes(IUnityContainer container) 62 | { 63 | var rootPath = HostingEnvironment.MapPath("~/"); 64 | var basePath = PathInfo.Combine(PathInfo.Create(rootPath), PathInfo.Create(ConfigurationManager.AppSettings["NitroNet.BasePath"])).ToString(); 65 | 66 | new DefaultUnityModule(basePath).Configure(container); 67 | new SitecoreUnityModule().Configure(container); 68 | } 69 | ``` 70 | 71 | ###### CastleWindsor 72 | To activate NitroNet for Sitecore with CastleWindsor, please add these lines to your application: 73 | 74 | ```csharp 75 | public static void RegisterTypes(IWindsorContainer container) 76 | { 77 | var rootPath = HostingEnvironment.MapPath("~/"); 78 | var basePath = PathInfo.Combine(PathInfo.Create(rootPath), PathInfo.Create(ConfigurationManager.AppSettings["NitroNet.BasePath"])).ToString(); 79 | 80 | new DefaultCastleWindsorModule(basePath).Configure(container); 81 | new SitecoreCastleWindsorModule().Configure(container); 82 | } 83 | ``` 84 | 85 | 86 | #### (B) With another IoC Framework 87 | You don't like Unity and you design your application with an other IoC framework? No Problem. 88 | 89 | In this case, you can install NitroNet only with our base package: 90 | 91 | `PM >` `Install-Package NitroNet.Sitecore.Sitecore82 ` 92 | 93 | ##### Extend your Global.asax 94 | *Please extend your Global.asax(.cs) in the same way as in scenario A* 95 | 96 | ##### Register NitroNet for Sitecore with your own IoC Framework 97 | Actually, we only made a Microsoft.DependencyInjection, Unity or CastleWindsor integration with NitroNet for Sitecore. But it's easy to use another IoC Framework. 98 | Please follow our Unity sample as a template for you ([Gist](https://gist.github.com/daniiiol/036be44e535768fac2df5eec0aff9180)): 99 | 100 | ###### DefaultUnityModule.cs 101 | 102 | ```csharp 103 | using Microsoft.Practices.Unity; 104 | using NitroNet.Mvc; 105 | using NitroNet.ViewEngine; 106 | using NitroNet.ViewEngine.Cache; 107 | using NitroNet.ViewEngine.Config; 108 | using NitroNet.ViewEngine.IO; 109 | using NitroNet.ViewEngine.TemplateHandler; 110 | using NitroNet.ViewEngine.ViewEngines; 111 | using Veil.Compiler; 112 | using Veil.Helper; 113 | 114 | namespace NitroNet.UnityModules 115 | { 116 | public class DefaultUnityModule : IUnityModule 117 | { 118 | private readonly string _basePath; 119 | 120 | public DefaultUnityModule(string basePath) 121 | { 122 | _basePath = basePath; 123 | } 124 | 125 | public void Configure(IUnityContainer container) 126 | { 127 | RegisterConfiguration(container); 128 | RegisterApplication(container); 129 | } 130 | 131 | protected virtual void RegisterConfiguration(IUnityContainer container) 132 | { 133 | var config = ConfigurationLoader.LoadNitroConfiguration(_basePath); 134 | container.RegisterInstance(config); 135 | 136 | container.RegisterInstance(new FileSystem(_basePath, config)); 137 | } 138 | 139 | protected virtual void RegisterApplication(IUnityContainer container) 140 | { 141 | container.RegisterType( 142 | new ContainerControlledLifetimeManager()); 143 | container.RegisterType(); 144 | container.RegisterType(); 145 | container.RegisterType(); 146 | container.RegisterType(); 147 | container.RegisterType(); 148 | container.RegisterType(new ContainerControlledLifetimeManager()); 149 | container.RegisterType(new ContainerControlledLifetimeManager()); 150 | container.RegisterType( 151 | new ContainerControlledLifetimeManager()); 152 | } 153 | } 154 | } 155 | ``` 156 | 157 | ###### SitecoreUnityModule.cs 158 | 159 | ```csharp 160 | using Microsoft.Practices.Unity; 161 | using NitroNet.Sitecore.Caching; 162 | using NitroNet.Sitecore.Rendering; 163 | using NitroNet.UnityModules; 164 | using NitroNet.ViewEngine.TemplateHandler; 165 | using NitroNet.ViewEngine.TemplateHandler.Grid; 166 | using Sitecore; 167 | using Sitecore.Data; 168 | using Sitecore.Mvc.Common; 169 | using Veil; 170 | 171 | namespace NitroNet.Sitecore.UnityModules 172 | { 173 | public class SitecoreUnityModule : IUnityModule 174 | { 175 | public void Configure(IUnityContainer container) 176 | { 177 | container.RegisterType( 178 | new InjectionFactory(u => GridContext.GetFromRenderingContext(ContextService.Get().GetCurrent()))); 179 | container.RegisterType(); 180 | container.RegisterType(new ContainerControlledLifetimeManager()); 181 | container.RegisterType( 182 | new ContainerControlledLifetimeManager()); 183 | container.RegisterType(new InjectionFactory(u => Context.Database)); 184 | } 185 | } 186 | } 187 | ``` -------------------------------------------------------------------------------- /docs/known-issues.md: -------------------------------------------------------------------------------- 1 | ## Table of contents 2 | - [Installation](installation.md) 3 | - [Configuration](configuration.md) 4 | - [Getting started](getting-started.md) 5 | - [Samples](samples.md) 6 | - [Release Notes](https://github.com/merkle-open/NitroNetSitecore/releases) 7 | - [Known Issues](known-issues.md) 8 | 9 | ## Limitations 10 | 11 | ### Caching of components called by `Html.Sitecore().Rendering(pathOrId)` 12 | Sitecore 8.2 (and 8.1) has a bug that the method mentioned above doesn't read the cache settings correctly. As NitroNet for Sitecore uses this internally to render components where a Sitecore controller rendering exists for, those components won't be cached correctly. 13 | 14 | Therefore we added the pipeline processor `NitroNet.Sitecore.Pipelines.MvcRenderRendering` which replaces the default one from Sitecore. 15 | 16 | In addition, as explained in the [samples](samples.md), there is the possibility to statically add subcomponents to another component and those subcomponents are rendered via the Sitecore rendering pipeline. NitroNet for Sitecore needs to add this data parameter to the cache key in order for the components to be cached correctly. Therefore we made some further adjustments to the `GenerateCacheKey` processor of the MVC rendering pipeline. 17 | 18 | These two pipeline processors get activated with the shipped `MvcRenderingPipeline.config`. 19 | 20 | **Important:** Please pay attention if you have already included the official Sitecore fixes (*Sitecore.Support.387950* and *Sitecore.Support.414987*) or customized the `SetCacheability` or the `GenerateCacheKey` processor in your solution! 21 | 22 | ## Currently not implemented 23 | Please consult the [known issues documentation of NitroNet](https://github.com/merkle-open/NitroNet/blob/master/docs/known-issues.md) to see which features are currently not supported. -------------------------------------------------------------------------------- /docs/releases/1.1.1.md: -------------------------------------------------------------------------------- 1 | ### New Features / Enhancements 2 | - NitroNet updated to version **1.1.1** 3 | - You can find the release notes [here](https://github.com/merkle-open/NitroNet/releases/tag/1.1.1) 4 | - Greatly improved documentation: 5 | - Updated, corrected and extended 6 | - Better syntax highligthing of code examples 7 | - Prereleases are now supported by the build routine and delivered via nuget.org if necessary 8 | - There will be Sitecore specific NuGets. Currently there are Sitecore 8.1 and 8.2 NuGets. 9 | - A new NuGet `NitroNet.Sitecore.Microsoft.DependencyInjection.Sitecore82` is available now (only for Sitecore 8.2). It automatically registers all the NitroNet-types to the container. 10 | 11 | ### Fixed Issues 12 | - `NitroNet.UnityModules` and `NitroNet.CastleWindsorModules` now reference the correct `NitroNet.Sitecore` dependency 13 | - The Caching of components has been fixed and works now correct in Sitecore. Find more information in the *Known Issues* section. 14 | - NitroNet.Sitecore.dll was not installed properly. This has been fixed. 15 | - It is now possible to have several files in a component folder which contain hyphens in the file name. Before, it was only possible to have one file with hyphens. 16 | 17 | ### Removed Features / Breaking Changes 18 | - The controller parameters `skin` and `dataVariation` have been renamed to `template` and `data` to meet the naming convention of *Nitro* 19 | - AsyncLocal has been removed. It was legacy code from the previous project and is no longer needed. 20 | 21 | ### Update/Installation Instructions 22 | 23 | #### NitroNet upgrade instructions 24 | Please consult the [release notes of NitroNet 1.1.1](https://github.com/merkle-open/NitroNet/releases/tag/1.1.1.0). 25 | 26 | #### Upgrading the NitroNet.Sitecore NuGet 27 | It is not possible to just update the NitroNet.Sitecore NuGet in Visual Studio. You have to uninstall it and then install the new Sitecore specific NuGet of NitroNet.Sitecore. This is because we change the names of the NuGets to have specific Sitecore version compatibility. 28 | 29 | #### Guide to renaming the controller parameters 30 | You have to do a Find/Replace operation in your solution in your controller classes. 31 | Then you need to replace `skin` with `template` and `dataVariation` with `data`. 32 | 33 | Example: 34 | 35 | ```csharp 36 | //Before 37 | public ActionResult Index(string skin, string dataVariation) 38 | { 39 | //Your code 40 | } 41 | ``` 42 | 43 | ```csharp 44 | //After 45 | public ActionResult Index(string template, string data) 46 | { 47 | //Your code 48 | } 49 | ``` -------------------------------------------------------------------------------- /docs/releases/1.1.2.md: -------------------------------------------------------------------------------- 1 | ### New Features / Enhancements 2 | - NitroNet updated to version **1.1.2** 3 | - You can find the release notes [here](https://github.com/merkle-open/NitroNet/releases/tag/1.1.2) 4 | - The methods of the NitroNetServicesConfigurator class can now be overwritten. 5 | 6 | ### Fixed Issues 7 | - The *appSetting* `NitroNet.BasePath` now is respected when using the NitroNet.Sitecore with Microsoft.DependencyInjection. Before it didn't have an impact. -------------------------------------------------------------------------------- /docs/releases/2.0.0.md: -------------------------------------------------------------------------------- 1 | ### New Features / Enhancements 2 | - NitroNet updated to version **1.1.3** 3 | - You can find the release notes [here](https://github.com/merkle-open/NitroNet/releases/tag/1.1.3) 4 | - Updated documentation 5 | - Various fixes and enhancements 6 | - Updated roadmap 7 | - Support for Sitecore 9 was added - Issue [23](https://github.com/merkle-open/NitroNetSitecore/issues/23) 8 | - A new NuGet package was added for Sitecore 9: `NitroNet.Sitecore.Sitecore90` 9 | - *Sitecore.Configuration.Settings.GetAppSetting* caused a lock during dependency registration in Sitecore 9. It was replaced with *System.Configuration.ConfigurationManager.AppSettings* 10 | - The new dynamic placeholder of Sitecore 9 are being used (see breaking changes) 11 | - The Sitecore libraries (DLLs) were removed from the repository and the Sitecore PackageReference approach was implemented 12 | - Sitecore Support fixes relevant for Sitecore 8.1/8.2 were directly integrated into the code 13 | - The view engine now automatically gets registered with a config file. This saves an additional step in the installation process. - Issue [20](https://github.com/merkle-open/NitroNetSitecore/issues/20) 14 | 15 | ### Fixed Issues 16 | - Rendering cache isn't properly updated on CD servers after publishing 17 | 18 | ### Removed Features / Breaking Changes 19 | - Dynamic Placeholder extension for Sitecore 9: Additionally allows Sitecore.Data.ID besides integer - Issue [18](https://github.com/merkle-open/NitroNetSitecore/issues/18) 20 | - Further down are instructions for how to migrate existing content. 21 | 22 | ### Update/Installation Instructions 23 | 24 | #### Migrate from a Sitecore 8.1 or 8.2 NuGet 25 | 26 | 1) If you are using a Sitecore 9 NitroNet.Sitecore NuGet then there is nothing to do for you. But if you are currently using a Sitecore 8.1 or 8.2 NitroNet.Sitecore NuGet you first have to become aware of all Visual Studio projects on which the NitroNet.Sitecore NuGet has been installed and write this information down. 27 | 28 | - When using Microsoft DI, Unity or CastleWindsor you have to look for the following packages: 29 | - NitroNet.Sitecore.Microsoft.DependencyInjection.Sitecore82 30 | - NitroNet.Sitecore.UnityModules.Sitecore8x 31 | - NitroNet.Sitecore.CastleWindsorModules.Sitecore8x 32 | - When using another IoC framework you have to look for the following package: 33 | - NitroNet.Sitecore.Sitecore8x 34 | 35 | 2) Uninstall these packages in all Visual Studio projects 36 | 37 | 3) Install the following new NuGet package in your selected Visual Studio projects: 38 | 39 | - When using MS DI: 40 | - `PM >` `Install-Package NitroNet.Sitecore.Microsoft.DependencyInjection.Sitecore90` 41 | - When using another IoC framework: 42 | - `PM >` `Install-Package NitroNet.Sitecore.Sitecore90` 43 | 44 | #### Remove manual Registration of NitroNet View Engine 45 | Before this release it was necessary to register the NitroNet View Engine manually with a Sitecore pipeline processor and a Sitecore config file/entry. This is now done automatically. 46 | 47 | So remove your own Sitecore pipeline processor and its corresponding config file/entry after updating the NuGets. 48 | 49 | #### Migrate Dynamic Placeholders 50 | 51 | Sitecore 9 introduced the dynamic placeholder feature. Please follow the [official documentation](https://doc.sitecore.net/sitecore_experience_platform/developing/developing_with_sitecore/dynamic_placeholders) for more information about when and how to use it. NitroNet for Sitecore uses the new native dynamic placeholders starting with version 2.0. This means if you used NitroNet for Sitecore 1.x in combination with Sitecore 8.x and are upgrading to Sitecore 9 then you need to migrate all existing placeholder keys to the new format. 52 | 53 | ##### Migration of NitroNet 1.x placeholders 54 | 55 | NitroNet for Sitecore 1.x offers dynamic placeholders out of the box. 56 | The pattern of those keys looks the following: *mykey_1_88498ee8-6dae-470e-bbec-bf158eb4a6e5* 57 | This pattern needs to be migrated to the new format: *mykey-{88498EE8-6DAE-470E-BBEC-BF158EB4A6E5}-1* 58 | 59 | Instructions: 60 | 61 | - Add admin page [MigrateDynamicPlaceholders.aspx](https://github.com/merkle-open/NitroNetSitecore/tree/master/docs/releases/utils/MigrateDynamicPlaceholders.aspx) to your solution in folder /sitecore/admin 62 | - Change the setting *Query.MaxItems* to a high value which should be higher than the amount of page items you need to migrate (e.g. 10000) 63 | - Run /sitecore/admin/MigrateDynamicPlaceholders.aspx in your browser. You should first run this script on a single test page and check if the migration works as intended. There are the following GET parameters you can use to migrate the right content. 64 | - database: Sitecore database. Default value: master 65 | - itemId: The dynamic placeholder migration is only processed on this start item. Example: {456B38B8-1C42-48AF-858E-FC58A2FC1491} 66 | - enableRecursion: This option enables recursion for the start item. Example: true 67 | 68 | For example the following request migrates all renderings on the page item with ID {456B38B8-1C42-48AF-858E-FC58A2FC1491} and all its descendent page items in the master database to the new format: /sitecore/admin/MigrateDynamicPlaceholders.aspx?database=master&itemId={456B38B8-1C42-48AF-858E-FC58A2FC1491}&enableRecursion=true 69 | 70 | ##### Migration of DynamicPlaceholders.Mvc NuGet package 71 | 72 | [DynamicPlaceholders.Mvc](http://fortis.ws/fortis-collection/dynamic-placeholders/) NuGet package is probably the most used library for enabling dynamic placeholders prior to Sitecore 9. If you are using this library instead of the NitroNet placeholders then you have to use another approach to migrate the placeholder keys when upgrading to Sitecore 9. Thankfully, Richard Seal covers this in his [blogpost about upgrading to Dynamic Placeholders in Sitecore 9](https://www.sitecorenutsbolts.net/2017/10/17/Sitecore-9-Upgrading-to-Dynamic-Placeholders/). -------------------------------------------------------------------------------- /docs/releases/utils/MigrateDynamicPlaceholders.aspx: -------------------------------------------------------------------------------- 1 | <%@ Page Language="C#" AutoEventWireup="true" Debug="true" %> 2 | <%@ Import Namespace="System.Linq" %> 3 | <%@ Import Namespace="Sitecore" %> 4 | <%@ Import Namespace="Sitecore.Configuration" %> 5 | <%@ Import Namespace="Sitecore.Data" %> 6 | <%@ Import Namespace="Sitecore.Data.Fields" %> 7 | <%@ Import Namespace="Sitecore.Data.Items" %> 8 | <%@ Import Namespace="Sitecore.Layouts" %> 9 | 10 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 |
282 |
283 |
284 |
285 | 286 | -------------------------------------------------------------------------------- /docs/samples.md: -------------------------------------------------------------------------------- 1 | ## Table of contents 2 | - [Installation](installation.md) 3 | - [Configuration](configuration.md) 4 | - [Getting started](getting-started.md) 5 | - [Samples](samples.md) 6 | - [Release Notes](https://github.com/merkle-open/NitroNetSitecore/releases) 7 | - [Known Issues](known-issues.md) 8 | 9 | 10 | Please see the [samples of NitroNet](https://github.com/merkle-open/NitroNet/blob/master/docs/getting-started.md) to see some code samples for the basic MVC features of NitroNet and informations and samples for working with plain handlebars and/or Nitro. 11 | 12 | Some helpers mentioned below are custom handlebars helpers from Nitro such as the component or the placeholder helper. 13 | 14 | ## Layout view 15 | 16 | ### An easy example 17 | When working with Sitecore you can add only partials, placeholders or static components (which have no Sitecore datasource) to a layout file: 18 | 19 | ```html 20 | 21 | 22 | 23 | {{partial name="head"}} 24 | 25 | 26 |
27 | {{placeholder name="HeaderArea"}} 28 |
29 |
30 | {{component name="Breadcrumb"}} 31 | {{placeholder name="ContentArea"}} 32 |
33 |
34 | {{placeholder name="FooterArea"}} 35 |
36 | {{partial name="foot"}} 37 | 38 | 39 | ``` 40 | 41 | In order to get this layout view to work you need to create the following things: 42 | - A Sitecore placeholder item for each placeholder (3x in this example) 43 | - A Sitecore layout item 44 | - A Sitecore controller rendering called `Breadcrumb` 45 | - A C# controller `BreadcrumbController`. 46 | 47 | Please follow the [Getting started](getting-started.md) page for this simple case. 48 | 49 | ### Model on layout level 50 | 51 | In the above example you can only see partials, placeholders and components in the markup without data properties. But what if you need to add direct values to the first level of your handlebars hierarchy, e.g. a simple string indicating the language? 52 | 53 | You can make use of the out of the box functionality of Sitecore where you can define a model on your layout. First change your layout to this: 54 | 55 | ```html 56 | 57 | 58 | ... 59 | 60 | ``` 61 | 62 | Create a model inheriting from the Sitecore.Mvc.Presentation.IRenderingModel and implement the `Initialize()` method where you set your properties: 63 | 64 | ```csharp 65 | public class DefaultRenderingModel : IRenderingModel 66 | { 67 | public string HtmlLanguage { get; set; } 68 | 69 | public void Initialize(Rendering rendering) 70 | { 71 | HtmlLanguage = Sitecore.Context.Language.Name; 72 | } 73 | } 74 | ``` 75 | 76 | In the Sitecore backend create a new model item under `/sitecore/layout/Models`. On the newly created item in the field `Model Type` enter the fully qualified name of the DefaultRenderingModel you've created above (e.g. `MyProject.Internet.Model.DefaultRenderingModel, MyProject.Internet.Model`). 77 | 78 | Finally you need to link your layout to the model item. Do this in the `Model` field of the layout item. Reload your page and voila, the value is there. 79 | 80 | ### Controller invocation with template and data attribute 81 | 82 | With NitroNet for Sitecore it is possible to determine with which template and data attribute a Controller was called. 83 | All you have to do is to add the two parameters `string template` `string data` to the `Index()` method of the Controller. 84 | 85 | Let's look at the following example: 86 | 87 | View snippet: 88 | 89 | ```html 90 |
91 | {{title}} 92 |
93 | {{component name="footer-link-list" template="templateB"}} 94 |
95 |
96 | {{component name="footer-link-list" data="social"}} 97 |
98 |
99 | ``` 100 | 101 | `Index()` method: 102 | 103 | ```csharp 104 | public ActionResult Index(string data, string template) 105 | { 106 | FooterLinkListViewModel model; 107 | if (data.Equals("social", StringComparison.InvariantCultureIgnoreCase)) 108 | { 109 | model = _service.CreateSocialLinks() 110 | } 111 | else if (template.Equals("templateB", StringComparison.InvariantCultureIgnoreCase)) 112 | { 113 | model = _service.CreateBLinks() 114 | } 115 | else 116 | { 117 | model = _service.CreateFooterLinks(); 118 | } 119 | 120 | return View("[path to your component folder]/footer-link-list", model); 121 | } 122 | ``` 123 | 124 | For direct values like `title` there needs to be a property, for the `footer-link-list` component not. 125 | 126 | ### Use of Sitecore edit frames 127 | 128 | An important feature when developing with Sitecore is the use of edit frames for the Experience Editor. 129 | The following example shows you how you can achieve this when using *handlebars* and *NitroNet.Sitecore*. 130 | 131 | #### 1.) Create a view model 132 | In the first step you have to create C# view model for your edit frame: 133 | 134 | ```csharp 135 | public class EditFrame 136 | { 137 | public string EditFrameStart { get; set; } 138 | public string EditFrameStop { get; set; } 139 | } 140 | ``` 141 | 142 | #### 2.) Write a method to populate the view model 143 | In the second step you have to write a method for populating the edit frame view model. You can copy the following method or use it as a basis for your own implementation: 144 | 145 | ```csharp 146 | public EditFrame GetEditFrame(string path, string buttons, string title, string tooltip, string css, object parameters) 147 | { 148 | var result = new EditFrame(); 149 | if (!Sitecore.Context.PageMode.IsExperienceEditorEditing) 150 | return result; 151 | 152 | var output = new StringWriter(); 153 | var writer = new HtmlTextWriter(output); 154 | var editFrame = new Sitecore.Mvc.Common.EditFrame(path,buttons, title, tooltip, css, parameters); 155 | editFrame.RenderFirstPart(writer); 156 | result.EditFrameStart = output.ToString(); 157 | 158 | output = new StringWriter(); 159 | writer = new HtmlTextWriter(output); 160 | editFrame.RenderLastPart(writer); 161 | result.EditFrameStop = output.ToString(); 162 | 163 | return result; 164 | } 165 | ``` 166 | 167 | #### 3.) Use the edit frame in your views 168 | And last but not least you need this handlebars markup to activate the edit frame. 169 | 170 | ```html 171 | {{{editframe.editframeStart}}} 172 | 175 | {{{editframe.editframeStop}}} 176 | ``` 177 | 178 | Please keep in mind that the context object needs to have a property with the following type and name: 179 | 180 | ```csharp 181 | public EditFrame EditFrame { get; set; } 182 | ``` 183 | 184 | ## Nitro helpers for Sitecore 185 | 186 | ### Placeholders 187 | 188 | Placeholders don't need a special interaction in user code. In Sitecore you need to create a placeholder setting item with the same key value as the `name` attribute of the placeholder. The `template` parameter is completely ignored by NitroNet. 189 | 190 | ```html 191 |
192 | {{placeholder name="AccordionArea" template="accordion-area"}} 193 |
194 | ``` 195 | 196 | #### Identical placeholders on the same level 197 | 198 | You might run into situations where you want to have multiple placeholders with the same key on the same hierarchical level. Therefore you need to use the `index` or `indexprop` attribute. NitroNet uses Dynamic Placeholders by default. 199 | 200 | ##### index attribute 201 | 202 | ```html 203 |
204 | {{placeholder name="AccordionArea" index="1"}} 205 | {{placeholder name="AccordionArea" index="2"}} 206 |
207 | ``` 208 | 209 | ##### indexprop attribute 210 | 211 | View snippet: 212 | 213 | ```html 214 |
215 | {{#each items}} 216 | {{placeholder name="AccordionArea" indexprop="Id"}} 217 | {{/each}} 218 |
219 | ``` 220 | 221 | Model snippet: 222 | 223 | ```csharp 224 | public class AccordionModel 225 | { 226 | public IEnumerable Items { get; set; } 227 | } 228 | 229 | public class AccordionItemModel 230 | { 231 | public string Id { get; set; } 232 | } 233 | ``` 234 | 235 | 236 | ### A component with subcomponents 237 | There are two ways to deal with a component who contains subcomponents (e.g. a molecule that consists of one or more atoms): 238 | 239 | #### 1) Create a Controller for each or selected subcomponents 240 | Sometimes it is necessary to controll the caching of the individual subcomponents (e.g. header component) and therefore necessary to create Sitecore controller renderings and C# Controllers for these subcomponents. If you do not provide a model of the subcomponent, NitroNet tries to invoke a Controller for this subcomponent. You can also create a Sitecore controller rendering for it if you need to set special caching settings for this component because it is run through the rendering pipeline. NitroNet for Sitecore internally invokes the controller respectively the rendering pipeline. 241 | 242 | In the following example we will look more detailed into that: 243 | 244 | View snippet: 245 | 246 | ```html 247 |
248 | {{title}} 249 |
250 | {{component name="footer-link-list"}} 251 |
252 |
253 | {{component name="footer-link-list" data="social"}} 254 |
255 |
256 | ``` 257 | 258 | C# Model: 259 | 260 | ```csharp 261 | public class FooterContainerModel 262 | { 263 | public string Title { get; set; } 264 | } 265 | ``` 266 | 267 | C# Controller for the `footer-link-list`: 268 | 269 | ```csharp 270 | public class FooterLinkListController : Controller 271 | { 272 | private readonly IFooterLinkService _service; 273 | 274 | public FooterLinkListController(IFooterLinkService service) 275 | { 276 | _service = service; 277 | } 278 | 279 | public ActionResult Index(string data) 280 | { 281 | FooterLinkListViewModel model; 282 | if (data.Equals("social", StringComparison.InvariantCultureIgnoreCase)) 283 | { 284 | model = _service.CreateSocialLinks() 285 | } 286 | else 287 | { 288 | model = _service.CreateFooterLinks(); 289 | } 290 | 291 | return View("path/to/your/template/footer-link-list", model); 292 | } 293 | } 294 | ``` 295 | 296 | For direct values like `title` there needs to be property, for the `footer-link-list` component not. At this point the controller gets invoked directly. 297 | 298 | If you want to cache the `footer-link-list` component specifically you need to create a Controller Rendering called *FooterLinkList* (hyphens and case sensitivity can be ignored) in Sitecore. Now, the rendering pipeline gets invoked and you can set all the caching configurations for the component. Note that the `data` attribute is considered if you choose *Vary By Data*. 299 | 300 | #### 2) Create only one Controller for the parent component 301 | You can find the code example and explanations for this case [here](https://github.com/merkle-open/NitroNet/blob/master/docs/samples.md#a-component-with-subcomponents). 302 | -------------------------------------------------------------------------------- /packaging.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) 5 | 6 | 7 | 8 | $(SolutionDir).nuget 9 | 10 | 14 | 15 | 16 | true 17 | 18 | true 19 | 20 | C:\nuget_local 21 | 22 | 23 | Sitecore82 24 | true 25 | snupkg 26 | 27 | 28 | 29 | 30 | 31 | $(PackageVersion)-$(PrereleaseVersion)$([System.String]::Format('{0:000}', $([MSBuild]::Add($(BuildNumber), 0)))) 32 | 33 | 34 | 35 | 36 | $(PackageVersion) 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | $(NugetPackageVersion) 45 | 46 | 47 | 48 | 49 | $(NitroNetCoreMajorVersion).$(NitroNetCoreMinorVersion).$(NitroNetCorePatchVersion)-$(NitroNetCorePrereleaseVersion)$([System.String]::Format('{0:000}', $([MSBuild]::Add($(NitroNetCoreBuildnumber), 0)))) 50 | 51 | 52 | 53 | 54 | $(NitroNetCoreMajorVersion).$(NitroNetCoreMinorVersion).$(NitroNetCorePatchVersion) 55 | 56 | 57 | 58 | 59 | 60 | $(BuildDependsOn); 61 | BuildPackageCustom; 62 | PublishPackage; 63 | 64 | $(NuGetToolsPath)\NuGet.exe 65 | "$(NuGetExePath)" 66 | mono --runtime=v4.0.30319 $(NuGetExePath) 67 | <_NugetApiKey Condition="'$(NugetApiKey)' != ''"> -ApiKey "$(NugetApiKey)" 68 | $([System.IO.Path]::GetDirectoryName('$(ProjectDir)$(IntermediateOutputPath)')) 69 | $(ProjectPath.Replace('.csproj', '.nuspec')) 70 | $(ProjectName.Replace('.csproj', '')).*$(NugetPackageVersion).nupkg 71 | $(NuGetCommand) pack "$(ProjectPath)" -Properties "Configuration=$(Configuration);Platform=$(Platform)" $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" $(IncludeReferencedProjects) -Properties "ProductVersion=$(ProductVersion);DependentVersion=$(NugetPackageVersion);DependentNitroNetVersion=$(DependentNitroNetVersion)" -Version "$(NugetPackageVersion)" 72 | $(NuGetCommand) push "$(PackageOutputDir)\$(PackageOutput)" $(_NugetApiKey) -source "$(NugetRepository)" 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /versioning.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 1 8 | 1 9 | 0 10 | 0 11 | $(MajorVersion).$(MinorVersion).$(PatchVersion) 12 | $(MajorVersion).$(MinorVersion).0.0 13 | $(PackageVersion).$(BuildNumber) 14 | 15 | 16 | 17 | 18 | --------------------------------------------------------------------------------