diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..fdadad7 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,5 @@ +# Contributing Guidelines + +Contributions to this package are most welcome! + +There is a test site in the solution to make working with this repository easier. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000..0483504 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,52 @@ +name: "Bug report" +description: "File a bug report to help improve this package." +labels: "bug" +body: +- type: markdown + attributes: + value: | + Thanks for taking the time to report this issue as thoroughly as possible. +- type: input + id: "PackageVersion" + attributes: + label: "Which jcdcdev.Umbraco.Core version are you using?" + description: "Leave blank if you're not sure: the latest version will be assumed." + validations: + required: false +- type: input + id: "umbracoVersion" + attributes: + label: "Which Umbraco version are you using? For example: 10.4.0 - don't just write v10" + description: "Use the help icon in the Umbraco backoffice to find the version you're using." + validations: + required: true +- type: textarea + id: "summary" + attributes: + label: "Bug summary" + description: "Write a summary of the bug." + description: "Remember that you can format code and logs nicely with the `<>` button" + placeholder: > + Try to pinpoint it as much as possible. + + Try to state the actual problem, and not just what you think the solution might be. + validations: + required: true +- type: textarea + attributes: + label: "Steps to reproduce" + id: "reproduction" + description: "How can we reproduce the problem on a clean AdminOnlyPackage + Umbraco install?" + placeholder: > + Please include any links, screenshots, stack-traces, etc. + validations: + required: true +- type: textarea + attributes: + label: "Expected result / actual result" + id: "result" + description: "What did you expect that would happen on your Umbraco site and what is the actual result of the above steps?" + placeholder: > + Describe the intended/desired outcome after you did the steps mentioned. + + Describe the behaviour of the bug \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..ec4bb38 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..eb959da --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,22 @@ +name: "Feature request" +description: "Suggest an idea for this package." +labels: "enhancement" +body: +- type: markdown + attributes: + value: | + Thanks for taking the time to suggest this feature request! +- type: textarea + id: "summary" + attributes: + label: "Feature summary" + description: "Write a brief summary of the feature" + validations: + required: true +- type: textarea + id: "details" + attributes: + label: "Additional details" + description: "Provide any additional details or comments about the feature you are suggesting" + validations: + required: false \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..a68b89f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,22 @@ +name: Build Package + +on: + pull_request: + branches: "*" +jobs: + build: + + runs-on: windows-latest + + steps: + + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + + - name: Build project + run: dotnet build src\jcdcdev.Umbraco.Core\jcdcdev.Umbraco.Core.csproj --configuration Release \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9dfc396 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,67 @@ +name: Release Package +run-name: > + push NuGet ${{ github.repository}} #${{ github.run_number }} +on: + pull_request: + branches: + - main + types: [closed] + workflow_dispatch: +jobs: + determine-version: + runs-on: ubuntu-latest + outputs: + semVer: ${{ steps.gitversion.outputs.semVer }} + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Install GitVersion + uses: gittools/actions/gitversion/setup@v0 + with: + versionSpec: '5.x' + - name: Determine Version + id: gitversion # id to later be referenced + uses: gittools/actions/gitversion/execute@v0 + build: + name: push ${{ needs.determine-version.outputs.semVer }} + runs-on: windows-latest + needs: determine-version + env: + SEMVER: ${{ needs.determine-version.outputs.semVer }} + steps: + - name: Checkout repository + uses: actions/checkout@v3 + - name: Setup .NET + uses: actions/setup-dotnet@v2 + with: + dotnet-version: 6.0.x + - name: Build project + run: dotnet build src\jcdcdev.Umbraco.Core\jcdcdev.Umbraco.Core.csproj --configuration Release -p:Version=${{ env.SEMVER }} + + - name: Pack + run: dotnet pack src\jcdcdev.Umbraco.Core\jcdcdev.Umbraco.Core.csproj --configuration Release -p:Version=${{ env.SEMVER }} --no-build --output . + + - name: Push to NuGet + run: dotnet nuget push **\*.nupkg -k ${{secrets.NUGET_API_KEY}} -s https://api.nuget.org/v3/index.json + post-deploy: + runs-on: ubuntu-latest + needs: + - determine-version + - build + env: + SEMVER: ${{ needs.determine-version.outputs.semVer }} + name: post-deploy ${{ needs.determine-version.outputs.semVer }} + permissions: + contents: write + steps: + - uses: actions/checkout@v3 + - name: Tag commit + env: + TAG: ${{ env.SEMVER }} + MESSAGE: "" + run: | + git config user.name "${GITHUB_ACTOR}" + git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" + git tag -a "${TAG}" -m "${MESSAGE}" + git push origin "${TAG}" \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e0545d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,357 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Git +*.orig + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Rider +src/.idea +*.sqlite.db* diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4892155 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2023 James Carter + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/docs/README_nuget.md b/docs/README_nuget.md new file mode 100644 index 0000000..f1fb94f --- /dev/null +++ b/docs/README_nuget.md @@ -0,0 +1,7 @@ +# jcdcdev.Umbraco.Core + +[![Downloads](https://img.shields.io/nuget/dt/jcdcdev.Umbraco.Core?color=cc9900)](https://www.nuget.org/packages/jcdcdev.Umbraco.Core/) +[![NuGet](https://img.shields.io/nuget/vpre/jcdcdev.Umbraco.Core?color=0273B3)](https://www.nuget.org/packages/jcdcdev.Umbraco.Core) +[![GitHub license](https://img.shields.io/github/license/jcdcdev/jcdcdev.Umbraco.Core?color=8AB803)](https://github.com/jcdcdev/jcdcdev.Umbraco.Core/blob/main/LICENSE) + +Core functionality used by my packages and projects \ No newline at end of file diff --git a/src/jcdcdev.Umbraco.Core.TestSite/.gitignore b/src/jcdcdev.Umbraco.Core.TestSite/.gitignore new file mode 100644 index 0000000..0a60fe5 --- /dev/null +++ b/src/jcdcdev.Umbraco.Core.TestSite/.gitignore @@ -0,0 +1,481 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# JetBrains Rider +.idea/ +*.sln.iml + +## +## Visual Studio Code +## +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +## +## Umbraco CMS +## + +# JSON schema file for appsettings.json +appsettings-schema.json + +# Packages created from the backoffice (package.xml/package.zip) +/umbraco/Data/CreatedPackages/ + +# Temp folder containing Examine indexes, NuCache, MediaCache, etc. +/umbraco/Data/TEMP/ + +# SQLite database files - enable if you don't want to commit your test DB to the repo +#/umbraco/Data/*.sqlite.db +#/umbraco/Data/*.sqlite.db-shm +#/umbraco/Data/*.sqlite.db-wal + +# Log files +/umbraco/Logs/ + +# Media files +/wwwroot/media/ + +# Test Site App_Plugins packages folder (exclude here as in jcdcdev.Umbraco.Core project) +/App_Plugins/jcdcdev.Umbraco.Core/ diff --git a/src/jcdcdev.Umbraco.Core.TestSite/Program.cs b/src/jcdcdev.Umbraco.Core.TestSite/Program.cs new file mode 100644 index 0000000..4cb83bd --- /dev/null +++ b/src/jcdcdev.Umbraco.Core.TestSite/Program.cs @@ -0,0 +1,19 @@ +namespace jcdcdev.Umbraco.Core.TestSite +{ + public class Program + { + public static void Main(string[] args) + => CreateHostBuilder(args) + .Build() + .Run(); + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureUmbracoDefaults() + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStaticWebAssets(); + webBuilder.UseStartup(); + }); + } +} diff --git a/src/jcdcdev.Umbraco.Core.TestSite/Properties/launchSettings.json b/src/jcdcdev.Umbraco.Core.TestSite/Properties/launchSettings.json new file mode 100644 index 0000000..cfa1ef6 --- /dev/null +++ b/src/jcdcdev.Umbraco.Core.TestSite/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:59495", + "sslPort": 44315 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Umbraco.Web.UI": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:44315;http://localhost:59495", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/jcdcdev.Umbraco.Core.TestSite/Startup.cs b/src/jcdcdev.Umbraco.Core.TestSite/Startup.cs new file mode 100644 index 0000000..59fa1dc --- /dev/null +++ b/src/jcdcdev.Umbraco.Core.TestSite/Startup.cs @@ -0,0 +1,74 @@ +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Umbraco.Cms.Core.DependencyInjection; +using Umbraco.Extensions; + +namespace jcdcdev.Umbraco.Core.TestSite +{ + public class Startup + { + private readonly IWebHostEnvironment _env; + private readonly IConfiguration _config; + + /// + /// Initializes a new instance of the class. + /// + /// The web hosting environment. + /// The configuration. + /// + /// Only a few services are possible to be injected here https://github.com/dotnet/aspnetcore/issues/9337. + /// + public Startup(IWebHostEnvironment webHostEnvironment, IConfiguration config) + { + _env = webHostEnvironment ?? throw new ArgumentNullException(nameof(webHostEnvironment)); + _config = config ?? throw new ArgumentNullException(nameof(config)); + } + + /// + /// Configures the services. + /// + /// The services. + /// + /// This method gets called by the runtime. Use this method to add services to the container. + /// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940. + /// + public void ConfigureServices(IServiceCollection services) + { + services.AddUmbraco(_env, _config) + .AddBackOffice() + .AddWebsite() + .AddComposers() + .Build(); + } + + /// + /// Configures the application. + /// + /// The application builder. + /// The web hosting environment. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseUmbraco() + .WithMiddleware(u => + { + u.UseBackOffice(); + u.UseWebsite(); + }) + .WithEndpoints(u => + { + u.UseInstallerEndpoints(); + u.UseBackOfficeEndpoints(); + u.UseWebsiteEndpoints(); + }); + } + } +} diff --git a/src/jcdcdev.Umbraco.Core.TestSite/Views/_ViewImports.cshtml b/src/jcdcdev.Umbraco.Core.TestSite/Views/_ViewImports.cshtml new file mode 100644 index 0000000..091f249 --- /dev/null +++ b/src/jcdcdev.Umbraco.Core.TestSite/Views/_ViewImports.cshtml @@ -0,0 +1,9 @@ +@using Umbraco.Extensions +@using jcdcdev.Umbraco.Core.TestSite +@using Umbraco.Cms.Web.Common.PublishedModels +@using Umbraco.Cms.Web.Common.Views +@using Umbraco.Cms.Core.Models.PublishedContent +@using Microsoft.AspNetCore.Html +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, Smidge +@inject Smidge.SmidgeHelper SmidgeHelper diff --git a/src/jcdcdev.Umbraco.Core.TestSite/appsettings.Development.json b/src/jcdcdev.Umbraco.Core.TestSite/appsettings.Development.json new file mode 100644 index 0000000..91cd2da --- /dev/null +++ b/src/jcdcdev.Umbraco.Core.TestSite/appsettings.Development.json @@ -0,0 +1,34 @@ +{ + "$schema": "./appsettings-schema.json", + "Serilog": { + "MinimumLevel": { + "Default": "Information" + }, + "WriteTo": [ + { + "Name": "Async", + "Args": { + "configure": [ + { + "Name": "Console" + } + ] + } + } + ] + }, + "Umbraco": { + "CMS": { + "Content": { + "MacroErrors": "Throw" + }, + "Hosting": { + "Debug": true + }, + "RuntimeMinification": { + "UseInMemoryCache": true, + "CacheBuster": "Timestamp" + } + } + } +} diff --git a/src/jcdcdev.Umbraco.Core.TestSite/appsettings.json b/src/jcdcdev.Umbraco.Core.TestSite/appsettings.json new file mode 100644 index 0000000..156b6d0 --- /dev/null +++ b/src/jcdcdev.Umbraco.Core.TestSite/appsettings.json @@ -0,0 +1,27 @@ +{ + "$schema": "./appsettings-schema.json", + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information", + "System": "Warning" + } + } + }, + "Umbraco": { + "CMS": { + "Global": { + "Id": "12890910-b1c3-4bba-9544-a9beeb851ed0", + "SanitizeTinyMce": true + }, + "Content": { + "AllowEditInvariantFromNonDefault": true, + "ContentVersionCleanupPolicy": { + "EnableCleanup": true + } + } + } + }, +} \ No newline at end of file diff --git a/src/jcdcdev.Umbraco.Core.TestSite/jcdcdev.Umbraco.Core.TestSite.csproj b/src/jcdcdev.Umbraco.Core.TestSite/jcdcdev.Umbraco.Core.TestSite.csproj new file mode 100644 index 0000000..9a5af15 --- /dev/null +++ b/src/jcdcdev.Umbraco.Core.TestSite/jcdcdev.Umbraco.Core.TestSite.csproj @@ -0,0 +1,39 @@ + + + net6.0 + enable + enable + + + + + + + + + + + + + + + true + + + + + false + false + + + + + + + + + appsettings.json + + + + \ No newline at end of file diff --git a/src/jcdcdev.Umbraco.Core.TestSite/wwwroot/favicon.ico b/src/jcdcdev.Umbraco.Core.TestSite/wwwroot/favicon.ico new file mode 100644 index 0000000..c0749dd Binary files /dev/null and b/src/jcdcdev.Umbraco.Core.TestSite/wwwroot/favicon.ico differ diff --git a/src/jcdcdev.Umbraco.Core.sln b/src/jcdcdev.Umbraco.Core.sln new file mode 100644 index 0000000..0b3cda6 --- /dev/null +++ b/src/jcdcdev.Umbraco.Core.sln @@ -0,0 +1,43 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.4.33020.496 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5A6D3C2C-E986-4648-ABD7-ED442746EEBC}" + ProjectSection(SolutionItems) = preProject + ..\LICENSE = ..\LICENSE + ..\.github\README.md = ..\.github\README.md + EndProjectSection +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "jcdcdev.Umbraco.Core", "jcdcdev.Umbraco.Core\jcdcdev.Umbraco.Core.csproj", "{EC825C30-A30B-4ABF-AD64-FCA92C9EA75C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "jcdcdev.Umbraco.Core.TestSite", "jcdcdev.Umbraco.Core.TestSite\jcdcdev.Umbraco.Core.TestSite.csproj", "{989D710F-EC50-4EFF-AE9D-26A68694FDB5}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EC825C30-A30B-4ABF-AD64-FCA92C9EA75C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EC825C30-A30B-4ABF-AD64-FCA92C9EA75C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EC825C30-A30B-4ABF-AD64-FCA92C9EA75C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EC825C30-A30B-4ABF-AD64-FCA92C9EA75C}.Release|Any CPU.Build.0 = Release|Any CPU + {989D710F-EC50-4EFF-AE9D-26A68694FDB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {989D710F-EC50-4EFF-AE9D-26A68694FDB5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {989D710F-EC50-4EFF-AE9D-26A68694FDB5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {989D710F-EC50-4EFF-AE9D-26A68694FDB5}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6F07004F-9903-4AEB-9ED0-BE57A0326D20} + EndGlobalSection +EndGlobal +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Github", "Github", "{5830A86F-99DA-459D-82FD-A24613A9F22F}" + ProjectSection(SolutionItems) = preProject + ..\.github\workflows\release.yml = ..\.github\workflows\release.yml + ..\.github\workflows\build.yml = ..\.github\workflows\build.yml + EndProjectSection +EndProject diff --git a/src/jcdcdev.Umbraco.Core/AccessRule/AccessRuleBuilder.cs b/src/jcdcdev.Umbraco.Core/AccessRule/AccessRuleBuilder.cs new file mode 100644 index 0000000..b5c2a24 --- /dev/null +++ b/src/jcdcdev.Umbraco.Core/AccessRule/AccessRuleBuilder.cs @@ -0,0 +1,39 @@ +using Umbraco.Cms.Core.Dashboards; + +namespace jcdcdev.Umbraco.Core.AccessRule; + +public class AccessRuleBuilder : IAccessRuleBuilder +{ + private readonly global::Umbraco.Cms.Core.Dashboards.AccessRule _rule; + private readonly bool _allow; + + public static IAccessRuleUserGroupBuilder Deny() + { + return new AccessRuleBuilder(false); + } + + public static IAccessRuleBuilder Allow() + { + return new AccessRuleBuilder(); + } + + private AccessRuleBuilder(bool allow = true) + { + _rule = new global::Umbraco.Cms.Core.Dashboards.AccessRule(); + _allow = allow; + } + + public IAccessRule Section(string section) + { + _rule.Type = _allow ? AccessRuleType.GrantBySection : AccessRuleType.Deny; + _rule.Value = section; + return _rule; + } + + public IAccessRule UserGroup(string userGroup) + { + _rule.Type = _allow ? AccessRuleType.Grant : AccessRuleType.Deny; + _rule.Value = userGroup; + return _rule; + } +} diff --git a/src/jcdcdev.Umbraco.Core/AccessRule/IAccessRuleBuilder.cs b/src/jcdcdev.Umbraco.Core/AccessRule/IAccessRuleBuilder.cs new file mode 100644 index 0000000..9400d4d --- /dev/null +++ b/src/jcdcdev.Umbraco.Core/AccessRule/IAccessRuleBuilder.cs @@ -0,0 +1,17 @@ +using Umbraco.Cms.Core.Dashboards; + +namespace jcdcdev.Umbraco.Core.AccessRule; + +public interface IAccessRuleUserGroupBuilder +{ + IAccessRule UserGroup(string userGroup); +} + +public interface IAccessRuleSectionBuilder +{ + IAccessRule Section(string section); +} + +public interface IAccessRuleBuilder : IAccessRuleUserGroupBuilder +{ +} diff --git a/src/jcdcdev.Umbraco.Core/AccessRule/SimpleAccessRule.cs b/src/jcdcdev.Umbraco.Core/AccessRule/SimpleAccessRule.cs new file mode 100644 index 0000000..2b95cfc --- /dev/null +++ b/src/jcdcdev.Umbraco.Core/AccessRule/SimpleAccessRule.cs @@ -0,0 +1,46 @@ +using Umbraco.Cms.Core; +using Umbraco.Cms.Core.Dashboards; + +namespace jcdcdev.Umbraco.Core.AccessRule; + +public static class SimpleAccessRule +{ + public static IAccessRule GrantByUserGroup(string groupAlias) + { + return new global::Umbraco.Cms.Core.Dashboards.AccessRule { Type = AccessRuleType.Grant, Value = groupAlias }; + } + + public static IAccessRule GrantBySection(string section) + { + return new global::Umbraco.Cms.Core.Dashboards.AccessRule { Type = AccessRuleType.GrantBySection, Value = section }; + } + + public static IAccessRuleBuilder Allow() + { + return AccessRuleBuilder.Allow(); + } + + public static IAccessRule DenyUserGroup(string userGroup) + { + return AccessRuleBuilder.Deny().UserGroup(userGroup); + } + + public static IAccessRule AllowEditorGroup => GrantByUserGroup(Constants.Security.EditorGroupAlias); + public static IAccessRule AllowAdminGroup => GrantByUserGroup(Constants.Security.AdminGroupAlias); + public static IAccessRule AllowTranslatorGroup => GrantByUserGroup(Constants.Security.TranslatorGroupAlias); + public static IAccessRule AllowWriterGroup => GrantByUserGroup(Constants.Security.WriterGroupAlias); + + public static IAccessRule AllowContentSection => GrantBySection(Constants.Applications.Content); + public static IAccessRule AllowUsersSection => GrantBySection(Constants.Applications.Users); + public static IAccessRule AllowFormsSection => GrantBySection(Constants.Applications.Forms); + public static IAccessRule AllowMediaSection => GrantBySection(Constants.Applications.Media); + public static IAccessRule AllowMembersSection => GrantBySection(Constants.Applications.Members); + public static IAccessRule AllowPackagesSection => GrantBySection(Constants.Applications.Packages); + public static IAccessRule AllowSettingsSection => GrantBySection(Constants.Applications.Settings); + public static IAccessRule AllowTranslationSection => GrantBySection(Constants.Applications.Translation); + + public static IAccessRule DenyEditorGroup => DenyUserGroup(Constants.Security.EditorGroupAlias); + public static IAccessRule DenyAdminGroup => DenyUserGroup(Constants.Security.AdminGroupAlias); + public static IAccessRule DenyTranslatorGroup => DenyUserGroup(Constants.Security.TranslatorGroupAlias); + public static IAccessRule DenyWriterGroup => DenyUserGroup(Constants.Security.WriterGroupAlias); +} \ No newline at end of file diff --git a/src/jcdcdev.Umbraco.Core/ContentApp/ContentAppBadges.cs b/src/jcdcdev.Umbraco.Core/ContentApp/ContentAppBadges.cs new file mode 100644 index 0000000..9f0cdd6 --- /dev/null +++ b/src/jcdcdev.Umbraco.Core/ContentApp/ContentAppBadges.cs @@ -0,0 +1,23 @@ +using Umbraco.Cms.Core.Models.ContentEditing; + +namespace jcdcdev.Umbraco.Core.ContentApp; + +public static class ContentAppBadges +{ + public static ContentAppBadge Default(int count) + { + return new ContentAppBadge { Count = count, Type = ContentAppBadgeType.Default }; + } + + public static ContentAppBadge Warning(int count) + { + return new ContentAppBadge { Count = count, Type = ContentAppBadgeType.Warning }; + } + + public static ContentAppBadge Alert(int count) + { + return new ContentAppBadge { Count = count, Type = ContentAppBadgeType.Alert }; + } + + public static ContentAppBadge? None => null; +} diff --git a/src/jcdcdev.Umbraco.Core/icon.png b/src/jcdcdev.Umbraco.Core/icon.png new file mode 100644 index 0000000..3773600 Binary files /dev/null and b/src/jcdcdev.Umbraco.Core/icon.png differ diff --git a/src/jcdcdev.Umbraco.Core/jcdcdev.Umbraco.Core.csproj b/src/jcdcdev.Umbraco.Core/jcdcdev.Umbraco.Core.csproj new file mode 100644 index 0000000..42b0e01 --- /dev/null +++ b/src/jcdcdev.Umbraco.Core/jcdcdev.Umbraco.Core.csproj @@ -0,0 +1,40 @@ + + + net6.0 + 10 + true + enable + enable + / + . + jcdcdev.Umbraco.Core + jcdcdev.Umbraco.Core + jcdcdev.Umbraco.Core + Core functionality used by my packages and projects + umbraco + James Carter + $([System.DateTime]::UtcNow.ToString(`yyyy`)) © James Carter + https://github.com/jcdcdev/jcdcdev.Umbraco.Core + https://github.com/jcdcdev/jcdcdev.Umbraco.Core + README_nuget.md + git + MIT + images\icon.png + + + + + + + + + + + + + + True + \ + + +