├── .github ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE │ ├── bug.yml │ ├── config.yml │ └── feature_request.yml ├── README.md └── workflows │ └── release.yml ├── .gitignore ├── LICENSE ├── docs ├── ModifyingDefaultConfiguration.md └── README_nuget.md ├── images ├── 1.png ├── 2.png ├── 3.png ├── 4.png ├── 5.jpg └── logo.png ├── src ├── .editorconfig ├── QuickBlocks.TestSite │ ├── .gitignore │ ├── CleanUp.ps1 │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── QuickBlocks.TestSite.csproj │ ├── Startup.cs │ ├── TextareaDataTypeMapper.cs │ ├── TextareaMapperComposer.cs │ ├── Views │ │ ├── Partials │ │ │ ├── blockgrid │ │ │ │ ├── area.cshtml │ │ │ │ ├── areas.cshtml │ │ │ │ ├── default.cshtml │ │ │ │ └── items.cshtml │ │ │ ├── blocklist │ │ │ │ └── default.cshtml │ │ │ └── grid │ │ │ │ ├── bootstrap3-fluid.cshtml │ │ │ │ ├── bootstrap3.cshtml │ │ │ │ └── editors │ │ │ │ ├── base.cshtml │ │ │ │ ├── embed.cshtml │ │ │ │ ├── macro.cshtml │ │ │ │ ├── media.cshtml │ │ │ │ ├── rte.cshtml │ │ │ │ └── textstring.cshtml │ │ └── _ViewImports.cshtml │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── stylish.html │ └── wwwroot │ │ ├── assets │ │ ├── favicon.ico │ │ └── img │ │ │ ├── bg-callout.jpg │ │ │ ├── bg-masthead.jpg │ │ │ ├── portfolio-1.jpg │ │ │ ├── portfolio-2.jpg │ │ │ ├── portfolio-3.jpg │ │ │ └── portfolio-4.jpg │ │ ├── css │ │ └── styles.css │ │ ├── favicon.ico │ │ ├── js │ │ └── scripts.js │ │ └── stylish.html ├── QuickBlocks.sln └── QuickBlocks │ ├── .editorconfig │ ├── App_Plugins │ └── QuickBlocks │ │ ├── lang │ │ ├── en-US.xml │ │ └── en.xml │ │ ├── package.manifest │ │ ├── quickBlocks.css │ │ ├── quickBlocks.html │ │ └── quickBlocks.js │ ├── Composing │ ├── NotificationHandlersComposer.cs │ └── RegisterServicesComposer.cs │ ├── Controllers │ └── QuickBlocksUmbracoApiController.cs │ ├── DataTypeMappersCollection.cs │ ├── Models │ ├── BlockConfigModel.cs │ ├── BlockItemModel.cs │ ├── BlockListModel.cs │ ├── ContentTypeModel.cs │ ├── DataTypeMappers │ │ └── DataTypeMappers.cs │ ├── FolderStructure.cs │ ├── IDataTypeMapper.cs │ ├── PartialViewModel.cs │ ├── PropertyModel.cs │ ├── QuickBlocksInstruction.cs │ └── RowModel.cs │ ├── NotificationHandlers │ └── ServerVariablesParsingNotificationHandler.cs │ ├── QuickBlocks.csproj │ ├── QuickBlocksComposer.cs │ ├── QuickBlocksDefaultOptions.cs │ ├── QuickBlocksManifestFilter.cs │ ├── Services │ ├── BlockCreationService.cs │ ├── BlockParsingService.cs │ ├── IBlockCreationService.cs │ ├── IBlockParsingService.cs │ └── Resolvers │ │ ├── DataTypeNameResolver.cs │ │ └── IDataTypeNameResolver.cs │ └── buildTransitive │ └── Umbraco.Community.QuickBlocks.targets └── umbraco-marketplace.json /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing Guidelines 2 | 3 | Contributions to this package are most welcome! 4 | 5 | There is a test site in the solution to make working with this repository easier. 6 | 7 | TODO: *instructions on how to log in to test site assuming you have committed a db with some content* -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug.yml: -------------------------------------------------------------------------------- 1 | name: "Bug report" 2 | description: "File a bug report to help improve this package." 3 | labels: "bug" 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Thanks for taking the time to report this issue as thoroughly as possible. 9 | - type: input 10 | id: "PackageVersion" 11 | attributes: 12 | label: "Which QuickBlocks version are you using?" 13 | description: "Leave blank if you're not sure: the latest version will be assumed." 14 | validations: 15 | required: false 16 | - type: input 17 | id: "umbracoVersion" 18 | attributes: 19 | label: "Which Umbraco version are you using? For example: 10.4.0 - don't just write v10" 20 | description: "Use the help icon in the Umbraco backoffice to find the version you're using." 21 | validations: 22 | required: true 23 | - type: textarea 24 | id: "summary" 25 | attributes: 26 | label: "Bug summary" 27 | description: "Write a summary of the bug." 28 | description: "Remember that you can format code and logs nicely with the `<>` button" 29 | placeholder: > 30 | Try to pinpoint it as much as possible. 31 | 32 | Try to state the actual problem, and not just what you think the solution might be. 33 | validations: 34 | required: true 35 | - type: textarea 36 | attributes: 37 | label: "Steps to reproduce" 38 | id: "reproduction" 39 | description: "How can we reproduce the problem on a clean AdminOnlyPackage + Umbraco install?" 40 | placeholder: > 41 | Please include any links, screenshots, stack-traces, etc. 42 | validations: 43 | required: true 44 | - type: textarea 45 | attributes: 46 | label: "Expected result / actual result" 47 | id: "result" 48 | description: "What did you expect that would happen on your Umbraco site and what is the actual result of the above steps?" 49 | placeholder: > 50 | Describe the intended/desired outcome after you did the steps mentioned. 51 | 52 | Describe the behaviour of the bug -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | name: "Feature request" 2 | description: "Suggest an idea for this package." 3 | labels: "enhancement" 4 | body: 5 | - type: markdown 6 | attributes: 7 | value: | 8 | Thanks for taking the time to suggest this feature request! 9 | - type: textarea 10 | id: "summary" 11 | attributes: 12 | label: "Feature summary" 13 | description: "Write a brief summary of the feature" 14 | validations: 15 | required: true 16 | - type: textarea 17 | id: "details" 18 | attributes: 19 | label: "Additional details" 20 | description: "Provide any additional details or comments about the feature you are suggesting" 21 | validations: 22 | required: false -------------------------------------------------------------------------------- /.github/README.md: -------------------------------------------------------------------------------- 1 | # QuickBlocks 2 | 3 | [![Downloads](https://img.shields.io/nuget/dt/Umbraco.Community.QuickBlocks?color=cc9900)](https://www.nuget.org/packages/Umbraco.Community.QuickBlocks/) 4 | [![NuGet](https://img.shields.io/nuget/vpre/Umbraco.Community.QuickBlocks?color=0273B3)](https://www.nuget.org/packages/Umbraco.Community.QuickBlocks) 5 | [![GitHub license](https://img.shields.io/github/license/prjseal/QuickBlocks?color=8AB803)](LICENSE) 6 | 7 | A package for quickly building block list based Umbraco websites all from data attributes in your HTMl 8 | 9 | ***** Please don't judge my code yet. I've not cleaned it up yet ***** 10 | 11 | ## Installation 12 | 13 | At the moment, it is best to use this on a brand new empty umbraco site. 14 | You can create your empty site and install QuickBlocks using these commands. 15 | You should be able to paste it all into the command line. 16 | 17 | ```ps1 18 | # Ensure we have the latest Umbraco templates 19 | dotnet new -i Umbraco.Templates 20 | 21 | # Create solution/project 22 | dotnet new sln --name "MySolution" 23 | dotnet new umbraco --force -n "MyProject" --friendly-name "Administrator" --email "admin@example.com" --password "1234567890" --development-database-type SQLite 24 | dotnet sln add "MyProject" 25 | 26 | #Add QuickBlocks 27 | dotnet add "MyProject" package Umbraco.Community.QuickBlocks --prerelease 28 | 29 | dotnet run --project "MyProject" 30 | #Running 31 | ``` 32 | 33 | Watch this video to see how I use it. 34 | 35 | 36 | QuickBlocks Introduction Video 37 | 38 | 39 | ## Data Attributes 40 | 41 | Here are some examples 42 | 43 | ### Home Page and Block List Property 44 | 45 | ```html 46 |
50 | ... 51 |
52 | ``` 53 | 54 | ### Add a row 55 | 56 | ```html 57 |
58 | ... 59 |
60 | ``` 61 | 62 | ### Add a property to the row 63 | 64 | ```html 65 | My Link 66 | 67 | 68 | 69 |

Hello

70 | 71 |

72 | My content in here 73 |

74 | ``` 75 | 76 | ### Preview View and CSS 77 | 78 | If you are using the package `Umbraco.Community.BlockPreview` you can add this to the block list to set the preview path and css on all blocks. This can be set on an individual row too. 79 | 80 | ```html 81 |
88 | ... 89 |
90 | ``` 91 | 92 | Or if you'd prefer to use your own preview file you can specify it like this 93 | 94 | ```html 95 |
102 | ... 103 |
104 | ``` 105 | 106 | ### Specify a different data type 107 | ```html 108 |

109 | ``` 110 | 111 | ### Use an image as a background image 112 | ```html 113 |
114 | ... 115 |
116 | ``` 117 | 118 | ### Use a Multi URL Picker for repeating links and use the name for the icon 119 | ```html 120 | 127 | 128 | 129 | ``` 130 | 131 | ### Create a list property inside a row 132 | In the sub list items, we don't need to specify the property location, we only do that for row or page properties. 133 | **NOTE:** The data-sub-list-name and the data-prop-type assume the same name with '[BlockList] ' prepended to the data-prop-type or the generation will fail. 134 | 135 | ```html 136 |
137 |

We build awesome products

138 |
This is the paragraph where you can write more details
139 |
143 | 144 |
145 |

1. Design

146 |

blah blah blah

147 | Find more... 148 |
149 |
150 |
151 | ``` 152 | 153 | ### Move some HTML to a partial view 154 | 155 | ```html 156 | 159 | ``` 160 | 161 | ### Extra block list options 162 | 163 | #### Max Width 164 | 165 | ```html 166 | data-list-maxwidth="100%" 167 | ``` 168 | 169 | #### Single block mode 170 | 171 | ```html 172 | data-list-single="true" 173 | ``` 174 | #### Live editing mode 175 | 176 | ```html 177 | data-list-live="true" 178 | ``` 179 | #### Inline Editing 180 | 181 | ```html 182 | data-list-inline="true" 183 | ``` 184 | 185 | #### List Min Items 186 | 187 | ```html 188 | data-list-min="0" 189 | ``` 190 | 191 | #### List Max Items 192 | 193 | ```html 194 | data-list-max="3" 195 | ``` 196 | 197 | ### Extra row options 198 | 199 | #### Block Row Icon 200 | 201 | ```html 202 | data-icon-class="icon-science" 203 | ``` 204 | 205 | #### Block Row Icon Colour 206 | 207 | ```html 208 | data-icon-colour="color-indigo" 209 | ``` 210 | 211 | #### Block Row Label Property 212 | 213 | ```html 214 | data-label-property="title" 215 | ``` 216 | 217 | ## Contributing 218 | 219 | Contributions to this package are most welcome! Please read the [Contributing Guidelines](CONTRIBUTING.md). 220 | 221 | ## Acknowledgments 222 | 223 | Thanks to my employers [ClerksWell](https://www.clerkswell.com) for allowing me some time during my work day to work on this project on top of my own spare time. 224 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | # This is a basic workflow to help you get started with Actions 2 | 3 | name: Release Package 4 | 5 | on: 6 | push: 7 | tags: 8 | - "[0-9]+.[0-9]+.[0-9]+" 9 | 10 | jobs: 11 | build: 12 | 13 | runs-on: windows-latest 14 | 15 | steps: 16 | 17 | - name: Checkout repository 18 | uses: actions/checkout@v3 19 | 20 | - name: Setup .NET 21 | uses: actions/setup-dotnet@v2 22 | with: 23 | dotnet-version: 6.0.x 24 | 25 | - name: Build project 26 | run: dotnet build src\QuickBlocks\QuickBlocks.csproj --configuration Release 27 | 28 | - name: Push to NuGet 29 | run: dotnet nuget push **\*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --source https://api.nuget.org/v3/index.json 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Git 20 | *.orig 21 | 22 | # Build results 23 | [Dd]ebug/ 24 | [Dd]ebugPublic/ 25 | [Rr]elease/ 26 | [Rr]eleases/ 27 | x64/ 28 | x86/ 29 | [Aa][Rr][Mm]/ 30 | [Aa][Rr][Mm]64/ 31 | bld/ 32 | [Bb]in/ 33 | [Oo]bj/ 34 | [Ll]og/ 35 | [Ll]ogs/ 36 | 37 | # Visual Studio 2015/2017 cache/options directory 38 | .vs/ 39 | # Uncomment if you have tasks that create the project's static files in wwwroot 40 | #wwwroot/ 41 | 42 | # Visual Studio 2017 auto generated files 43 | Generated\ Files/ 44 | 45 | # MSTest test Results 46 | [Tt]est[Rr]esult*/ 47 | [Bb]uild[Ll]og.* 48 | 49 | # NUnit 50 | *.VisualState.xml 51 | TestResult.xml 52 | nunit-*.xml 53 | 54 | # Build Results of an ATL Project 55 | [Dd]ebugPS/ 56 | [Rr]eleasePS/ 57 | dlldata.c 58 | 59 | # Benchmark Results 60 | BenchmarkDotNet.Artifacts/ 61 | 62 | # .NET Core 63 | project.lock.json 64 | project.fragment.lock.json 65 | artifacts/ 66 | 67 | # StyleCop 68 | StyleCopReport.xml 69 | 70 | # Files built by Visual Studio 71 | *_i.c 72 | *_p.c 73 | *_h.h 74 | *.ilk 75 | *.meta 76 | *.obj 77 | *.iobj 78 | *.pch 79 | *.pdb 80 | *.ipdb 81 | *.pgc 82 | *.pgd 83 | *.rsp 84 | *.sbr 85 | *.tlb 86 | *.tli 87 | *.tlh 88 | *.tmp 89 | *.tmp_proj 90 | *_wpftmp.csproj 91 | *.log 92 | *.vspscc 93 | *.vssscc 94 | .builds 95 | *.pidb 96 | *.svclog 97 | *.scc 98 | 99 | # Chutzpah Test files 100 | _Chutzpah* 101 | 102 | # Visual C++ cache files 103 | ipch/ 104 | *.aps 105 | *.ncb 106 | *.opendb 107 | *.opensdf 108 | *.sdf 109 | *.cachefile 110 | *.VC.db 111 | *.VC.VC.opendb 112 | 113 | # Visual Studio profiler 114 | *.psess 115 | *.vsp 116 | *.vspx 117 | *.sap 118 | 119 | # Visual Studio Trace Files 120 | *.e2e 121 | 122 | # TFS 2012 Local Workspace 123 | $tf/ 124 | 125 | # Guidance Automation Toolkit 126 | *.gpState 127 | 128 | # ReSharper is a .NET coding add-in 129 | _ReSharper*/ 130 | *.[Rr]e[Ss]harper 131 | *.DotSettings.user 132 | 133 | # TeamCity is a build add-in 134 | _TeamCity* 135 | 136 | # DotCover is a Code Coverage Tool 137 | *.dotCover 138 | 139 | # AxoCover is a Code Coverage Tool 140 | .axoCover/* 141 | !.axoCover/settings.json 142 | 143 | # Visual Studio code coverage results 144 | *.coverage 145 | *.coveragexml 146 | 147 | # NCrunch 148 | _NCrunch_* 149 | .*crunch*.local.xml 150 | nCrunchTemp_* 151 | 152 | # MightyMoose 153 | *.mm.* 154 | AutoTest.Net/ 155 | 156 | # Web workbench (sass) 157 | .sass-cache/ 158 | 159 | # Installshield output folder 160 | [Ee]xpress/ 161 | 162 | # DocProject is a documentation generator add-in 163 | DocProject/buildhelp/ 164 | DocProject/Help/*.HxT 165 | DocProject/Help/*.HxC 166 | DocProject/Help/*.hhc 167 | DocProject/Help/*.hhk 168 | DocProject/Help/*.hhp 169 | DocProject/Help/Html2 170 | DocProject/Help/html 171 | 172 | # Click-Once directory 173 | publish/ 174 | 175 | # Publish Web Output 176 | *.[Pp]ublish.xml 177 | *.azurePubxml 178 | # Note: Comment the next line if you want to checkin your web deploy settings, 179 | # but database connection strings (with potential passwords) will be unencrypted 180 | *.pubxml 181 | *.publishproj 182 | 183 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 184 | # checkin your Azure Web App publish settings, but sensitive information contained 185 | # in these scripts will be unencrypted 186 | PublishScripts/ 187 | 188 | # NuGet Packages 189 | *.nupkg 190 | # NuGet Symbol Packages 191 | *.snupkg 192 | # The packages folder can be ignored because of Package Restore 193 | **/[Pp]ackages/* 194 | # except build/, which is used as an MSBuild target. 195 | !**/[Pp]ackages/build/ 196 | # Uncomment if necessary however generally it will be regenerated when needed 197 | #!**/[Pp]ackages/repositories.config 198 | # NuGet v3's project.json files produces more ignorable files 199 | *.nuget.props 200 | *.nuget.targets 201 | 202 | # Microsoft Azure Build Output 203 | csx/ 204 | *.build.csdef 205 | 206 | # Microsoft Azure Emulator 207 | ecf/ 208 | rcf/ 209 | 210 | # Windows Store app package directories and files 211 | AppPackages/ 212 | BundleArtifacts/ 213 | Package.StoreAssociation.xml 214 | _pkginfo.txt 215 | *.appx 216 | *.appxbundle 217 | *.appxupload 218 | 219 | # Visual Studio cache files 220 | # files ending in .cache can be ignored 221 | *.[Cc]ache 222 | # but keep track of directories ending in .cache 223 | !?*.[Cc]ache/ 224 | 225 | # Others 226 | ClientBin/ 227 | ~$* 228 | *~ 229 | *.dbmdl 230 | *.dbproj.schemaview 231 | *.jfm 232 | *.pfx 233 | *.publishsettings 234 | orleans.codegen.cs 235 | 236 | # Including strong name files can present a security risk 237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 238 | #*.snk 239 | 240 | # Since there are multiple workflows, uncomment next line to ignore bower_components 241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 242 | #bower_components/ 243 | 244 | # RIA/Silverlight projects 245 | Generated_Code/ 246 | 247 | # Backup & report files from converting an old project file 248 | # to a newer Visual Studio version. Backup files are not needed, 249 | # because we have git ;-) 250 | _UpgradeReport_Files/ 251 | Backup*/ 252 | UpgradeLog*.XML 253 | UpgradeLog*.htm 254 | ServiceFabricBackup/ 255 | *.rptproj.bak 256 | 257 | # SQL Server files 258 | *.mdf 259 | *.ldf 260 | *.ndf 261 | 262 | # Business Intelligence projects 263 | *.rdl.data 264 | *.bim.layout 265 | *.bim_*.settings 266 | *.rptproj.rsuser 267 | *- [Bb]ackup.rdl 268 | *- [Bb]ackup ([0-9]).rdl 269 | *- [Bb]ackup ([0-9][0-9]).rdl 270 | 271 | # Microsoft Fakes 272 | FakesAssemblies/ 273 | 274 | # GhostDoc plugin setting file 275 | *.GhostDoc.xml 276 | 277 | # Node.js Tools for Visual Studio 278 | .ntvs_analysis.dat 279 | node_modules/ 280 | 281 | # Visual Studio 6 build log 282 | *.plg 283 | 284 | # Visual Studio 6 workspace options file 285 | *.opt 286 | 287 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 288 | *.vbw 289 | 290 | # Visual Studio LightSwitch build output 291 | **/*.HTMLClient/GeneratedArtifacts 292 | **/*.DesktopClient/GeneratedArtifacts 293 | **/*.DesktopClient/ModelManifest.xml 294 | **/*.Server/GeneratedArtifacts 295 | **/*.Server/ModelManifest.xml 296 | _Pvt_Extensions 297 | 298 | # Paket dependency manager 299 | .paket/paket.exe 300 | paket-files/ 301 | 302 | # FAKE - F# Make 303 | .fake/ 304 | 305 | # CodeRush personal settings 306 | .cr/personal 307 | 308 | # Python Tools for Visual Studio (PTVS) 309 | __pycache__/ 310 | *.pyc 311 | 312 | # Cake - Uncomment if you are using it 313 | # tools/** 314 | # !tools/packages.config 315 | 316 | # Tabs Studio 317 | *.tss 318 | 319 | # Telerik's JustMock configuration file 320 | *.jmconfig 321 | 322 | # BizTalk build output 323 | *.btp.cs 324 | *.btm.cs 325 | *.odx.cs 326 | *.xsd.cs 327 | 328 | # OpenCover UI analysis results 329 | OpenCover/ 330 | 331 | # Azure Stream Analytics local run output 332 | ASALocalRun/ 333 | 334 | # MSBuild Binary and Structured Log 335 | *.binlog 336 | 337 | # NVidia Nsight GPU debugger configuration file 338 | *.nvuser 339 | 340 | # MFractors (Xamarin productivity tool) working folder 341 | .mfractor/ 342 | 343 | # Local History for Visual Studio 344 | .localhistory/ 345 | 346 | # BeatPulse healthcheck temp database 347 | healthchecksdb 348 | 349 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 350 | MigrationBackup/ 351 | 352 | # Ionide (cross platform F# VS Code tools) working folder 353 | .ionide/ 354 | 355 | # Rider 356 | src/.idea 357 | /src/QuickBlocks.TestSite/umbraco/Data 358 | /src/QuickBlocks.TestSite/Views/Partials/blocklist/Components 359 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Paul Seal 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 | -------------------------------------------------------------------------------- /docs/ModifyingDefaultConfiguration.md: -------------------------------------------------------------------------------- 1 | # Modifying the default configuration 2 | 3 | ## Adding DataType mappers 4 | 5 | QuickBlocks includes a [collection](https://docs.umbraco.com/umbraco-cms/implementation/composing#collections) of mappers used to link html element to default Umbraco data types. 6 | 7 | For example, when the parser finds an `h1` element, it creates a property that uses a `textstring` datatype for it. You can modify this behaviour by modifying the mappers collection. 8 | 9 | First we need to create a new mapper. To do so, create a new class that implements `IDataTypeMapper`. 10 | 11 | ```csharp 12 | public class TextareaDataTypeMapper : IDataTypeMapper 13 | { 14 | public IEnumerable HtmlElements => new[] {"h1"} ; 15 | 16 | public string DataTypeName => "textarea"; 17 | } 18 | ``` 19 | 20 | Next, we need to add our mapper to the QuickBlocks collection. Y For this to work you will need to create a [composer](https://docs.umbraco.com/umbraco-cms/implementation/composing). 21 | 22 | Then add the type mapper using the `QuickBlockDataTypeMappers` extension. 23 | 24 | > ℹ️ Note that QuickBlocks come with a `HeadersDataTypeMapper` that maps `h1` to a `textstring` datatype. In order for the new mapper to be able to override the default configuration, we need to append it to the collection after `HeadersDataTypeMapper` using `InsertAfter` 25 | 26 | 27 | ```csharp 28 | 29 | internal class MyDataTypeMappersComposer : IComposer 30 | { 31 | public void Compose(IUmbracoBuilder builder) 32 | { 33 | 34 | builder.QuickBlockDataTypeMappers() 35 | .InsertAfter(); 36 | } 37 | } 38 | 39 | ``` 40 | 41 | ## Changing the default data type mapper 42 | If a mapper is not found for a given html element, QuickBlocks will create a property using a `textstring` data type. 43 | 44 | This datatype can be modify. To do this, you need to go to your `Startup.cs` file and in the `ConfigureServices` method, you can configure the default options. 45 | 46 | ```csharp 47 | services.Configure(cfg => 48 | { 49 | cfg.DefaultDataTypeName = "Textarea"; 50 | }); 51 | ``` 52 | 53 | -------------------------------------------------------------------------------- /docs/README_nuget.md: -------------------------------------------------------------------------------- 1 | # QuickBlocks 2 | 3 | [![Downloads](https://img.shields.io/nuget/dt/Umbraco.Community.QuickBlocks?color=cc9900)](https://www.nuget.org/packages/Umbraco.Community.QuickBlocks/) 4 | [![NuGet](https://img.shields.io/nuget/vpre/Umbraco.Community.QuickBlocks?color=0273B3)](https://www.nuget.org/packages/Umbraco.Community.QuickBlocks) 5 | [![GitHub license](https://img.shields.io/github/license/prjseal/QuickBlocks?color=8AB803)](LICENSE) 6 | 7 | A package for quickly building block list based Umbraco websites all from data attributes in your HTMl 8 | 9 | ## Installation 10 | 11 | At the moment, it is best to use this on a brand new empty umbraco site. 12 | You can create your empty site and install QuickBlocks using these commands. 13 | You should be able to paste it all into the command line. 14 | 15 | ```ps1 16 | # Ensure we have the latest Umbraco templates 17 | dotnet new -i Umbraco.Templates 18 | 19 | # Create solution/project 20 | dotnet new sln --name "MySolution" 21 | dotnet new umbraco --force -n "MyProject" --friendly-name "Administrator" --email "admin@example.com" --password "1234567890" --development-database-type SQLite 22 | dotnet sln add "MyProject" 23 | 24 | #Add QuickBlocks 25 | dotnet add "MyProject" package Umbraco.Community.QuickBlocks --prerelease 26 | 27 | dotnet run --project "MyProject" 28 | #Running 29 | ``` 30 | 31 | ## 32 | 33 | Watch this video to see how I use it. 34 | 35 | 36 | QuickBlocks Introduction Video 37 | 38 | 39 | ## Data Attributes 40 | 41 | Here are some examples 42 | 43 | ### Home Page and Block List Property 44 | 45 | ```html 46 |
50 | ... 51 |
52 | ``` 53 | 54 | ### Add a row 55 | 56 | ```html 57 |
58 | ... 59 |
60 | ``` 61 | 62 | ### Add a property to the row 63 | 64 | ```html 65 | My Link 66 | 67 | 68 | 69 |

Hello

70 | 71 |

72 | My content in here 73 |

74 | ``` 75 | 76 | ### Preview View and CSS 77 | 78 | If you are using the package `Umbraco.Community.BlockPreview` you can add this to the block list to set the preview path and css on all blocks. This can be set on an individual row too. 79 | 80 | ```html 81 |
88 | ... 89 |
90 | ``` 91 | 92 | Or if you'd prefer to use your own preview file you can specify it like this 93 | 94 | ```html 95 |
102 | ... 103 |
104 | ``` 105 | 106 | ### Specify a different data type 107 | ```html 108 |

109 | ``` 110 | 111 | ### Use an image as a background image 112 | ```html 113 |
114 | ... 115 |
116 | ``` 117 | 118 | ### Use a Multi URL Picker for repeating links and use the name for the icon 119 | ```html 120 | 127 | 128 | 129 | ``` 130 | 131 | ### Create a list property inside a row 132 | In the sub list items, we don't need to specify the property location, we only do that for row or page properties. 133 | 134 | ```html 135 |
136 |

We build awesome products

137 |
This is the paragraph where you can write more details
138 |
142 | 143 |
144 |

1. Design

145 |

blah blah blah

146 | Find more... 147 |
148 |
149 |
150 | ``` 151 | 152 | ### Move some HTML to a partial view 153 | 154 | ```html 155 |
156 | ... 157 |
158 | ``` 159 | 160 | ### Extra block list options 161 | 162 | #### Max Width 163 | 164 | ```html 165 | data-list-maxwidth="100%" 166 | ``` 167 | 168 | #### Single block mode 169 | 170 | ```html 171 | data-list-single="true" 172 | ``` 173 | #### Live editing mode 174 | 175 | ```html 176 | data-list-live="true" 177 | ``` 178 | #### Inline Editing 179 | 180 | ```html 181 | data-list-inline="true" 182 | ``` 183 | 184 | #### List Min Items 185 | 186 | ```html 187 | data-list-min="0" 188 | ``` 189 | 190 | #### List Max Items 191 | 192 | ```html 193 | data-list-max="3" 194 | ``` 195 | 196 | ### Extra row options 197 | 198 | #### Block Row Icon 199 | 200 | ```html 201 | data-icon-class="icon-science" 202 | ``` 203 | 204 | #### Block Row Icon Colour 205 | 206 | ```html 207 | data-icon-colour="color-indigo" 208 | ``` 209 | 210 | #### Block Row Label Property 211 | 212 | ```html 213 | data-label-property="title" 214 | ``` 215 | 216 | ## Contributing 217 | 218 | Contributions to this package are most welcome! Please read the [Contributing Guidelines](CONTRIBUTING.md). 219 | 220 | ## Acknowledgments 221 | 222 | Thanks to my employers [ClerksWell](https://www.clerkswell.com) for allowing me some time during my work day to work on this project on top of my own spare time. -------------------------------------------------------------------------------- /images/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prjseal/QuickBlocks/112753bf5d25f9c00ad8660c81bb94c3561268b2/images/1.png -------------------------------------------------------------------------------- /images/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prjseal/QuickBlocks/112753bf5d25f9c00ad8660c81bb94c3561268b2/images/2.png -------------------------------------------------------------------------------- /images/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prjseal/QuickBlocks/112753bf5d25f9c00ad8660c81bb94c3561268b2/images/3.png -------------------------------------------------------------------------------- /images/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prjseal/QuickBlocks/112753bf5d25f9c00ad8660c81bb94c3561268b2/images/4.png -------------------------------------------------------------------------------- /images/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prjseal/QuickBlocks/112753bf5d25f9c00ad8660c81bb94c3561268b2/images/5.jpg -------------------------------------------------------------------------------- /images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prjseal/QuickBlocks/112753bf5d25f9c00ad8660c81bb94c3561268b2/images/logo.png -------------------------------------------------------------------------------- /src/.editorconfig: -------------------------------------------------------------------------------- 1 | # This .editorconfig has been taken from Umbraco CMS, licensed under MIT. 2 | # https://raw.githubusercontent.com/umbraco/Umbraco-CMS/release-10.2.0/.editorconfig 3 | 4 | # Version: 1.6.2 (Using https://semver.org/) 5 | # Updated: 2020-11-02 6 | # See https://github.com/RehanSaeed/EditorConfig/releases for release notes. 7 | # See https://github.com/RehanSaeed/EditorConfig for updates to this file. 8 | # See http://EditorConfig.org for more information about .editorconfig files. 9 | 10 | ########################################## 11 | # Common Settings 12 | ########################################## 13 | 14 | # This file is the top-most EditorConfig file 15 | root = true 16 | 17 | # All Files 18 | [*] 19 | charset = utf-8 20 | indent_style = space 21 | indent_size = 4 22 | insert_final_newline = true 23 | trim_trailing_whitespace = true 24 | 25 | ########################################## 26 | # File Extension Settings 27 | ########################################## 28 | 29 | # Visual Studio Solution Files 30 | [*.sln] 31 | indent_style = tab 32 | 33 | # Visual Studio XML Project Files 34 | [*.{csproj,vbproj,vcxproj.filters,proj,projitems,shproj}] 35 | indent_size = 2 36 | 37 | # XML Configuration Files 38 | [*.{xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct}] 39 | indent_size = 2 40 | 41 | # JSON Files 42 | [*.{json,json5,webmanifest}] 43 | indent_size = 2 44 | 45 | # YAML Files 46 | [*.{yml,yaml}] 47 | indent_size = 2 48 | 49 | # Markdown Files 50 | [*.md] 51 | trim_trailing_whitespace = false 52 | 53 | # Web Files 54 | [*.{htm,html,js,jsm,ts,tsx,css,sass,scss,less,svg,vue}] 55 | indent_size = 2 56 | 57 | # Batch Files 58 | [*.{cmd,bat}] 59 | end_of_line = crlf 60 | 61 | # Bash Files 62 | [*.sh] 63 | end_of_line = lf 64 | 65 | # Makefiles 66 | [Makefile] 67 | indent_style = tab 68 | 69 | 70 | [*.js] 71 | trim_trailing_whitespace = true 72 | 73 | [*.less] 74 | trim_trailing_whitespace = false 75 | 76 | ########################################## 77 | # File Header (Uncomment to support file headers) 78 | # https://docs.microsoft.com/visualstudio/ide/reference/add-file-header 79 | ########################################## 80 | 81 | # [*.{cs,csx,cake,vb,vbx}] 82 | file_header_template = Copyright (c) Umbraco.\nSee LICENSE for more details. 83 | 84 | # SA1636: File header copyright text should match 85 | # Justification: .editorconfig supports file headers. If this is changed to a value other than "none", a stylecop.json file will need to added to the project. 86 | # dotnet_diagnostic.SA1636.severity = none 87 | 88 | ########################################## 89 | # .NET Language Conventions 90 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions 91 | ########################################## 92 | 93 | # .NET Code Style Settings 94 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#net-code-style-settings 95 | [*.{cs,csx,cake,vb,vbx}] 96 | # "this." and "Me." qualifiers 97 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#this-and-me 98 | dotnet_style_qualification_for_field = false:suggestion 99 | dotnet_style_qualification_for_property = false:suggestion 100 | dotnet_style_qualification_for_method = false:suggestion 101 | dotnet_style_qualification_for_event = false:suggestion 102 | # Language keywords instead of framework type names for type references 103 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#language-keywords 104 | dotnet_style_predefined_type_for_locals_parameters_members = true:warning 105 | dotnet_style_predefined_type_for_member_access = true:warning 106 | # Modifier preferences 107 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#normalize-modifiers 108 | dotnet_style_require_accessibility_modifiers = always:warning 109 | csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning 110 | visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:warning 111 | dotnet_style_readonly_field = true:warning 112 | # Parentheses preferences 113 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#parentheses-preferences 114 | dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning 115 | dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning 116 | dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning 117 | dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion 118 | # Expression-level preferences 119 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-level-preferences 120 | dotnet_style_object_initializer = true:warning 121 | dotnet_style_collection_initializer = true:warning 122 | dotnet_style_explicit_tuple_names = true:warning 123 | dotnet_style_prefer_inferred_tuple_names = true:warning 124 | dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning 125 | dotnet_style_prefer_auto_properties = true:warning 126 | dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning 127 | dotnet_style_prefer_conditional_expression_over_assignment = false:suggestion 128 | dotnet_style_prefer_conditional_expression_over_return = false:suggestion 129 | dotnet_style_prefer_compound_assignment = true:warning 130 | # Null-checking preferences 131 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#null-checking-preferences 132 | dotnet_style_coalesce_expression = true:warning 133 | dotnet_style_null_propagation = true:warning 134 | # Parameter preferences 135 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#parameter-preferences 136 | dotnet_code_quality_unused_parameters = all:warning 137 | # More style options (Undocumented) 138 | # https://github.com/MicrosoftDocs/visualstudio-docs/issues/3641 139 | dotnet_style_operator_placement_when_wrapping = end_of_line 140 | # https://github.com/dotnet/roslyn/pull/40070 141 | dotnet_style_prefer_simplified_interpolation = true:warning 142 | 143 | # C# Code Style Settings 144 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#c-code-style-settings 145 | [*.{cs,csx,cake}] 146 | # Implicit and explicit types 147 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#implicit-and-explicit-types 148 | csharp_style_var_for_built_in_types = never 149 | csharp_style_var_when_type_is_apparent = false 150 | csharp_style_var_elsewhere = false 151 | # Expression-bodied members 152 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-bodied-members 153 | csharp_style_expression_bodied_methods = false:suggestion 154 | csharp_style_expression_bodied_constructors = true:suggestion 155 | csharp_style_expression_bodied_operators = true:suggestion 156 | csharp_style_expression_bodied_properties = true:suggestion 157 | csharp_style_expression_bodied_indexers = true:suggestion 158 | csharp_style_expression_bodied_accessors = true:suggestion 159 | csharp_style_expression_bodied_lambdas = true:suggestion 160 | csharp_style_expression_bodied_local_functions = true:suggestion 161 | # Pattern matching 162 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#pattern-matching 163 | csharp_style_pattern_matching_over_is_with_cast_check = true:warning 164 | csharp_style_pattern_matching_over_as_with_null_check = true:warning 165 | # Inlined variable declarations 166 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#inlined-variable-declarations 167 | csharp_style_inlined_variable_declaration = true:warning 168 | # Expression-level preferences 169 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-level-preferences 170 | csharp_prefer_simple_default_expression = true:warning 171 | # "Null" checking preferences 172 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#c-null-checking-preferences 173 | csharp_style_throw_expression = true:warning 174 | csharp_style_conditional_delegate_call = true:warning 175 | # Code block preferences 176 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#code-block-preferences 177 | csharp_prefer_braces = true:warning 178 | # Unused value preferences 179 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#unused-value-preferences 180 | csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion 181 | csharp_style_unused_value_assignment_preference = discard_variable:suggestion 182 | # Index and range preferences 183 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#index-and-range-preferences 184 | csharp_style_prefer_index_operator = true:warning 185 | csharp_style_prefer_range_operator = true:warning 186 | # Miscellaneous preferences 187 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#miscellaneous-preferences 188 | csharp_style_deconstructed_variable_declaration = true:warning 189 | csharp_style_pattern_local_over_anonymous_function = true:warning 190 | csharp_using_directive_placement = outside_namespace:warning 191 | csharp_prefer_static_local_function = true:warning 192 | csharp_prefer_simple_using_statement = true:suggestion 193 | 194 | ########################################## 195 | # .NET Formatting Conventions 196 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-code-style-settings-reference#formatting-conventions 197 | ########################################## 198 | 199 | # Organize usings 200 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#organize-using-directives 201 | dotnet_sort_system_directives_first = true 202 | # Newline options 203 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#new-line-options 204 | csharp_new_line_before_open_brace = all 205 | csharp_new_line_before_else = true 206 | csharp_new_line_before_catch = true 207 | csharp_new_line_before_finally = true 208 | csharp_new_line_before_members_in_object_initializers = true 209 | csharp_new_line_before_members_in_anonymous_types = true 210 | csharp_new_line_between_query_expression_clauses = true 211 | # Indentation options 212 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#indentation-options 213 | csharp_indent_case_contents = true 214 | csharp_indent_switch_labels = true 215 | csharp_indent_labels = no_change 216 | csharp_indent_block_contents = true 217 | csharp_indent_braces = false 218 | csharp_indent_case_contents_when_block = false 219 | # Spacing options 220 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#spacing-options 221 | csharp_space_after_cast = false 222 | csharp_space_after_keywords_in_control_flow_statements = true 223 | csharp_space_between_parentheses = false 224 | csharp_space_before_colon_in_inheritance_clause = true 225 | csharp_space_after_colon_in_inheritance_clause = true 226 | csharp_space_around_binary_operators = before_and_after 227 | csharp_space_between_method_declaration_parameter_list_parentheses = false 228 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false 229 | csharp_space_between_method_declaration_name_and_open_parenthesis = false 230 | csharp_space_between_method_call_parameter_list_parentheses = false 231 | csharp_space_between_method_call_empty_parameter_list_parentheses = false 232 | csharp_space_between_method_call_name_and_opening_parenthesis = false 233 | csharp_space_after_comma = true 234 | csharp_space_before_comma = false 235 | csharp_space_after_dot = false 236 | csharp_space_before_dot = false 237 | csharp_space_after_semicolon_in_for_statement = true 238 | csharp_space_before_semicolon_in_for_statement = false 239 | csharp_space_around_declaration_statements = false 240 | csharp_space_before_open_square_brackets = false 241 | csharp_space_between_empty_square_brackets = false 242 | csharp_space_between_square_brackets = false 243 | # Wrapping options 244 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#wrap-options 245 | csharp_preserve_single_line_statements = false 246 | csharp_preserve_single_line_blocks = true 247 | 248 | ########################################## 249 | # .NET Naming Conventions 250 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-naming-conventions 251 | ########################################## 252 | 253 | [*.{cs,csx,cake,vb,vbx}] 254 | 255 | ########################################## 256 | # Styles 257 | ########################################## 258 | 259 | # camel_case_style - Define the camelCase style 260 | dotnet_naming_style.camel_case_style.capitalization = camel_case 261 | # pascal_case_style - Define the PascalCase style 262 | dotnet_naming_style.pascal_case_style.capitalization = pascal_case 263 | # first_upper_style - The first character must start with an upper-case character 264 | dotnet_naming_style.first_upper_style.capitalization = first_word_upper 265 | # prefix_interface_with_i_style - Interfaces must be PascalCase and the first character of an interface must be an 'I' 266 | dotnet_naming_style.prefix_interface_with_i_style.capitalization = pascal_case 267 | dotnet_naming_style.prefix_interface_with_i_style.required_prefix = I 268 | # prefix_type_parameters_with_t_style - Generic Type Parameters must be PascalCase and the first character must be a 'T' 269 | dotnet_naming_style.prefix_type_parameters_with_t_style.capitalization = pascal_case 270 | dotnet_naming_style.prefix_type_parameters_with_t_style.required_prefix = T 271 | # disallowed_style - Anything that has this style applied is marked as disallowed 272 | dotnet_naming_style.disallowed_style.capitalization = pascal_case 273 | dotnet_naming_style.disallowed_style.required_prefix = ____RULE_VIOLATION____ 274 | dotnet_naming_style.disallowed_style.required_suffix = ____RULE_VIOLATION____ 275 | # internal_error_style - This style should never occur... if it does, it indicates a bug in file or in the parser using the file 276 | dotnet_naming_style.internal_error_style.capitalization = pascal_case 277 | dotnet_naming_style.internal_error_style.required_prefix = ____INTERNAL_ERROR____ 278 | dotnet_naming_style.internal_error_style.required_suffix = ____INTERNAL_ERROR____ 279 | 280 | ########################################## 281 | # .NET Design Guideline Field Naming Rules 282 | # Naming rules for fields follow the .NET Framework design guidelines 283 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/index 284 | ########################################## 285 | 286 | # All public/protected/protected_internal constant fields must be PascalCase 287 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/field 288 | dotnet_naming_symbols.public_protected_constant_fields_group.applicable_accessibilities = public, protected, protected_internal, internal, private 289 | dotnet_naming_symbols.public_protected_constant_fields_group.required_modifiers = const 290 | dotnet_naming_symbols.public_protected_constant_fields_group.applicable_kinds = field 291 | dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.symbols = public_protected_constant_fields_group 292 | dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.style = pascal_case_style 293 | dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.severity = warning 294 | 295 | # All public/protected/protected_internal static readonly fields must be PascalCase 296 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/field 297 | dotnet_naming_symbols.public_protected_static_readonly_fields_group.applicable_accessibilities = public, protected, protected_internal 298 | dotnet_naming_symbols.public_protected_static_readonly_fields_group.required_modifiers = static, readonly 299 | dotnet_naming_symbols.public_protected_static_readonly_fields_group.applicable_kinds = field 300 | dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.symbols = public_protected_static_readonly_fields_group 301 | dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.style = pascal_case_style 302 | dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.severity = warning 303 | 304 | # No other public/protected/protected_internal fields are allowed 305 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/field 306 | dotnet_naming_symbols.other_public_protected_fields_group.applicable_accessibilities = public, protected, protected_internal 307 | dotnet_naming_symbols.other_public_protected_fields_group.applicable_kinds = field 308 | dotnet_naming_rule.other_public_protected_fields_disallowed_rule.symbols = other_public_protected_fields_group 309 | dotnet_naming_rule.other_public_protected_fields_disallowed_rule.style = disallowed_style 310 | dotnet_naming_rule.other_public_protected_fields_disallowed_rule.severity = error 311 | 312 | # This rule should never fire. However, it's included for at least two purposes: 313 | # First, it helps to understand, reason about, and root-case certain types of issues, such as bugs in .editorconfig parsers. 314 | # Second, it helps to raise immediate awareness if a new field type is added (as occurred recently in C#). 315 | dotnet_naming_symbols.sanity_check_uncovered_field_case_group.applicable_accessibilities = * 316 | dotnet_naming_symbols.sanity_check_uncovered_field_case_group.applicable_kinds = field 317 | dotnet_naming_rule.sanity_check_uncovered_field_case_rule.symbols = sanity_check_uncovered_field_case_group 318 | dotnet_naming_rule.sanity_check_uncovered_field_case_rule.style = internal_error_style 319 | dotnet_naming_rule.sanity_check_uncovered_field_case_rule.severity = error 320 | 321 | ########################################## 322 | # Other Naming Rules 323 | ########################################## 324 | 325 | # All of the following must be PascalCase: 326 | # - Namespaces 327 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-namespaces 328 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1300.md 329 | # - Classes and Enumerations 330 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces 331 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1300.md 332 | # - Delegates 333 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces#names-of-common-types 334 | # - Constructors, Properties, Events, Methods 335 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-type-members 336 | dotnet_naming_symbols.element_group.applicable_kinds = namespace, class, enum, struct, delegate, event, method, property 337 | dotnet_naming_rule.element_rule.symbols = element_group 338 | dotnet_naming_rule.element_rule.style = pascal_case_style 339 | dotnet_naming_rule.element_rule.severity = warning 340 | 341 | # Interfaces use PascalCase and are prefixed with uppercase 'I' 342 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces 343 | dotnet_naming_symbols.interface_group.applicable_kinds = interface 344 | dotnet_naming_rule.interface_rule.symbols = interface_group 345 | dotnet_naming_rule.interface_rule.style = prefix_interface_with_i_style 346 | dotnet_naming_rule.interface_rule.severity = warning 347 | 348 | # Generics Type Parameters use PascalCase and are prefixed with uppercase 'T' 349 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces 350 | dotnet_naming_symbols.type_parameter_group.applicable_kinds = type_parameter 351 | dotnet_naming_rule.type_parameter_rule.symbols = type_parameter_group 352 | dotnet_naming_rule.type_parameter_rule.style = prefix_type_parameters_with_t_style 353 | dotnet_naming_rule.type_parameter_rule.severity = warning 354 | 355 | # Function parameters use camelCase 356 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/naming-parameters 357 | dotnet_naming_symbols.parameters_group.applicable_kinds = parameter 358 | dotnet_naming_rule.parameters_rule.symbols = parameters_group 359 | dotnet_naming_rule.parameters_rule.style = camel_case_style 360 | dotnet_naming_rule.parameters_rule.severity = warning 361 | 362 | # Instance fields use camelCase and are prefixed with '_' 363 | dotnet_naming_rule.instance_fields_should_be_camel_case.severity = warning 364 | dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields 365 | dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style 366 | dotnet_naming_symbols.instance_fields.applicable_kinds = field 367 | dotnet_naming_style.instance_field_style.capitalization = camel_case 368 | dotnet_naming_style.instance_field_style.required_prefix = _ 369 | 370 | ########################################## 371 | # License 372 | ########################################## 373 | # The following applies as to the .editorconfig file ONLY, and is 374 | # included below for reference, per the requirements of the license 375 | # corresponding to this .editorconfig file. 376 | # See: https://github.com/RehanSaeed/EditorConfig 377 | # 378 | # MIT License 379 | # 380 | # Copyright (c) 2017-2019 Muhammad Rehan Saeed 381 | # Copyright (c) 2019 Henry Gabryjelski 382 | # 383 | # Permission is hereby granted, free of charge, to any 384 | # person obtaining a copy of this software and associated 385 | # documentation files (the "Software"), to deal in the 386 | # Software without restriction, including without limitation 387 | # the rights to use, copy, modify, merge, publish, distribute, 388 | # sublicense, and/or sell copies of the Software, and to permit 389 | # persons to whom the Software is furnished to do so, subject 390 | # to the following conditions: 391 | # 392 | # The above copyright notice and this permission notice shall be 393 | # included in all copies or substantial portions of the Software. 394 | # 395 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 396 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 397 | # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 398 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 399 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 400 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 401 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 402 | # OTHER DEALINGS IN THE SOFTWARE. 403 | ########################################## 404 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # Tye 66 | .tye/ 67 | 68 | # ASP.NET Scaffolding 69 | ScaffoldingReadMe.txt 70 | 71 | # StyleCop 72 | StyleCopReport.xml 73 | 74 | # Files built by Visual Studio 75 | *_i.c 76 | *_p.c 77 | *_h.h 78 | *.ilk 79 | *.meta 80 | *.obj 81 | *.iobj 82 | *.pch 83 | *.pdb 84 | *.ipdb 85 | *.pgc 86 | *.pgd 87 | *.rsp 88 | *.sbr 89 | *.tlb 90 | *.tli 91 | *.tlh 92 | *.tmp 93 | *.tmp_proj 94 | *_wpftmp.csproj 95 | *.log 96 | *.vspscc 97 | *.vssscc 98 | .builds 99 | *.pidb 100 | *.svclog 101 | *.scc 102 | 103 | # Chutzpah Test files 104 | _Chutzpah* 105 | 106 | # Visual C++ cache files 107 | ipch/ 108 | *.aps 109 | *.ncb 110 | *.opendb 111 | *.opensdf 112 | *.sdf 113 | *.cachefile 114 | *.VC.db 115 | *.VC.VC.opendb 116 | 117 | # Visual Studio profiler 118 | *.psess 119 | *.vsp 120 | *.vspx 121 | *.sap 122 | 123 | # Visual Studio Trace Files 124 | *.e2e 125 | 126 | # TFS 2012 Local Workspace 127 | $tf/ 128 | 129 | # Guidance Automation Toolkit 130 | *.gpState 131 | 132 | # ReSharper is a .NET coding add-in 133 | _ReSharper*/ 134 | *.[Rr]e[Ss]harper 135 | *.DotSettings.user 136 | 137 | # TeamCity is a build add-in 138 | _TeamCity* 139 | 140 | # DotCover is a Code Coverage Tool 141 | *.dotCover 142 | 143 | # AxoCover is a Code Coverage Tool 144 | .axoCover/* 145 | !.axoCover/settings.json 146 | 147 | # Coverlet is a free, cross platform Code Coverage Tool 148 | coverage*.json 149 | coverage*.xml 150 | coverage*.info 151 | 152 | # Visual Studio code coverage results 153 | *.coverage 154 | *.coveragexml 155 | 156 | # NCrunch 157 | _NCrunch_* 158 | .*crunch*.local.xml 159 | nCrunchTemp_* 160 | 161 | # MightyMoose 162 | *.mm.* 163 | AutoTest.Net/ 164 | 165 | # Web workbench (sass) 166 | .sass-cache/ 167 | 168 | # Installshield output folder 169 | [Ee]xpress/ 170 | 171 | # DocProject is a documentation generator add-in 172 | DocProject/buildhelp/ 173 | DocProject/Help/*.HxT 174 | DocProject/Help/*.HxC 175 | DocProject/Help/*.hhc 176 | DocProject/Help/*.hhk 177 | DocProject/Help/*.hhp 178 | DocProject/Help/Html2 179 | DocProject/Help/html 180 | 181 | # Click-Once directory 182 | publish/ 183 | 184 | # Publish Web Output 185 | *.[Pp]ublish.xml 186 | *.azurePubxml 187 | # Note: Comment the next line if you want to checkin your web deploy settings, 188 | # but database connection strings (with potential passwords) will be unencrypted 189 | *.pubxml 190 | *.publishproj 191 | 192 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 193 | # checkin your Azure Web App publish settings, but sensitive information contained 194 | # in these scripts will be unencrypted 195 | PublishScripts/ 196 | 197 | # NuGet Packages 198 | *.nupkg 199 | # NuGet Symbol Packages 200 | *.snupkg 201 | # The packages folder can be ignored because of Package Restore 202 | **/[Pp]ackages/* 203 | # except build/, which is used as an MSBuild target. 204 | !**/[Pp]ackages/build/ 205 | # Uncomment if necessary however generally it will be regenerated when needed 206 | #!**/[Pp]ackages/repositories.config 207 | # NuGet v3's project.json files produces more ignorable files 208 | *.nuget.props 209 | *.nuget.targets 210 | 211 | # Microsoft Azure Build Output 212 | csx/ 213 | *.build.csdef 214 | 215 | # Microsoft Azure Emulator 216 | ecf/ 217 | rcf/ 218 | 219 | # Windows Store app package directories and files 220 | AppPackages/ 221 | BundleArtifacts/ 222 | Package.StoreAssociation.xml 223 | _pkginfo.txt 224 | *.appx 225 | *.appxbundle 226 | *.appxupload 227 | 228 | # Visual Studio cache files 229 | # files ending in .cache can be ignored 230 | *.[Cc]ache 231 | # but keep track of directories ending in .cache 232 | !?*.[Cc]ache/ 233 | 234 | # Others 235 | ClientBin/ 236 | ~$* 237 | *~ 238 | *.dbmdl 239 | *.dbproj.schemaview 240 | *.jfm 241 | *.pfx 242 | *.publishsettings 243 | orleans.codegen.cs 244 | 245 | # Including strong name files can present a security risk 246 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 247 | #*.snk 248 | 249 | # Since there are multiple workflows, uncomment next line to ignore bower_components 250 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 251 | #bower_components/ 252 | 253 | # RIA/Silverlight projects 254 | Generated_Code/ 255 | 256 | # Backup & report files from converting an old project file 257 | # to a newer Visual Studio version. Backup files are not needed, 258 | # because we have git ;-) 259 | _UpgradeReport_Files/ 260 | Backup*/ 261 | UpgradeLog*.XML 262 | UpgradeLog*.htm 263 | ServiceFabricBackup/ 264 | *.rptproj.bak 265 | 266 | # SQL Server files 267 | *.mdf 268 | *.ldf 269 | *.ndf 270 | 271 | # Business Intelligence projects 272 | *.rdl.data 273 | *.bim.layout 274 | *.bim_*.settings 275 | *.rptproj.rsuser 276 | *- [Bb]ackup.rdl 277 | *- [Bb]ackup ([0-9]).rdl 278 | *- [Bb]ackup ([0-9][0-9]).rdl 279 | 280 | # Microsoft Fakes 281 | FakesAssemblies/ 282 | 283 | # GhostDoc plugin setting file 284 | *.GhostDoc.xml 285 | 286 | # Node.js Tools for Visual Studio 287 | .ntvs_analysis.dat 288 | node_modules/ 289 | 290 | # Visual Studio 6 build log 291 | *.plg 292 | 293 | # Visual Studio 6 workspace options file 294 | *.opt 295 | 296 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 297 | *.vbw 298 | 299 | # Visual Studio LightSwitch build output 300 | **/*.HTMLClient/GeneratedArtifacts 301 | **/*.DesktopClient/GeneratedArtifacts 302 | **/*.DesktopClient/ModelManifest.xml 303 | **/*.Server/GeneratedArtifacts 304 | **/*.Server/ModelManifest.xml 305 | _Pvt_Extensions 306 | 307 | # Paket dependency manager 308 | .paket/paket.exe 309 | paket-files/ 310 | 311 | # FAKE - F# Make 312 | .fake/ 313 | 314 | # CodeRush personal settings 315 | .cr/personal 316 | 317 | # Python Tools for Visual Studio (PTVS) 318 | __pycache__/ 319 | *.pyc 320 | 321 | # Cake - Uncomment if you are using it 322 | # tools/** 323 | # !tools/packages.config 324 | 325 | # Tabs Studio 326 | *.tss 327 | 328 | # Telerik's JustMock configuration file 329 | *.jmconfig 330 | 331 | # BizTalk build output 332 | *.btp.cs 333 | *.btm.cs 334 | *.odx.cs 335 | *.xsd.cs 336 | 337 | # OpenCover UI analysis results 338 | OpenCover/ 339 | 340 | # Azure Stream Analytics local run output 341 | ASALocalRun/ 342 | 343 | # MSBuild Binary and Structured Log 344 | *.binlog 345 | 346 | # NVidia Nsight GPU debugger configuration file 347 | *.nvuser 348 | 349 | # MFractors (Xamarin productivity tool) working folder 350 | .mfractor/ 351 | 352 | # Local History for Visual Studio 353 | .localhistory/ 354 | 355 | # BeatPulse healthcheck temp database 356 | healthchecksdb 357 | 358 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 359 | MigrationBackup/ 360 | 361 | # Ionide (cross platform F# VS Code tools) working folder 362 | .ionide/ 363 | 364 | # Fody - auto-generated XML schema 365 | FodyWeavers.xsd 366 | 367 | ## 368 | ## Visual studio for Mac 369 | ## 370 | 371 | 372 | # globs 373 | Makefile.in 374 | *.userprefs 375 | *.usertasks 376 | config.make 377 | config.status 378 | aclocal.m4 379 | install-sh 380 | autom4te.cache/ 381 | *.tar.gz 382 | tarballs/ 383 | test-results/ 384 | 385 | # Mac bundle stuff 386 | *.dmg 387 | *.app 388 | 389 | # content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore 390 | # General 391 | .DS_Store 392 | .AppleDouble 393 | .LSOverride 394 | 395 | # Icon must end with two \r 396 | Icon 397 | 398 | 399 | # Thumbnails 400 | ._* 401 | 402 | # Files that might appear in the root of a volume 403 | .DocumentRevisions-V100 404 | .fseventsd 405 | .Spotlight-V100 406 | .TemporaryItems 407 | .Trashes 408 | .VolumeIcon.icns 409 | .com.apple.timemachine.donotpresent 410 | 411 | # Directories potentially created on remote AFP share 412 | .AppleDB 413 | .AppleDesktop 414 | Network Trash Folder 415 | Temporary Items 416 | .apdisk 417 | 418 | # content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore 419 | # Windows thumbnail cache files 420 | Thumbs.db 421 | ehthumbs.db 422 | ehthumbs_vista.db 423 | 424 | # Dump file 425 | *.stackdump 426 | 427 | # Folder config file 428 | [Dd]esktop.ini 429 | 430 | # Recycle Bin used on file shares 431 | $RECYCLE.BIN/ 432 | 433 | # Windows Installer files 434 | *.cab 435 | *.msi 436 | *.msix 437 | *.msm 438 | *.msp 439 | 440 | # Windows shortcuts 441 | *.lnk 442 | 443 | # JetBrains Rider 444 | .idea/ 445 | *.sln.iml 446 | 447 | ## 448 | ## Visual Studio Code 449 | ## 450 | .vscode/* 451 | !.vscode/settings.json 452 | !.vscode/tasks.json 453 | !.vscode/launch.json 454 | !.vscode/extensions.json 455 | 456 | ## 457 | ## Umbraco CMS 458 | ## 459 | 460 | # JSON schema file for appsettings.json 461 | appsettings-schema.json 462 | 463 | # Packages created from the backoffice (package.xml/package.zip) 464 | /umbraco/Data/CreatedPackages/ 465 | 466 | # Temp folder containing Examine indexes, NuCache, MediaCache, etc. 467 | /umbraco/Data/TEMP/ 468 | 469 | # SQLite database files - enable if you don't want to commit your test DB to the repo 470 | #/umbraco/Data/*.sqlite.db 471 | #/umbraco/Data/*.sqlite.db-shm 472 | #/umbraco/Data/*.sqlite.db-wal 473 | 474 | # Log files 475 | /umbraco/Logs/ 476 | 477 | # Media files 478 | /wwwroot/media/ 479 | 480 | # Test Site App_Plugins packages folder (exclude here as in QuickBlocks project) 481 | /App_Plugins/QuickBlocks/ 482 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/CleanUp.ps1: -------------------------------------------------------------------------------- 1 | $dir = Join-Path (Split-Path -Path $MyInvocation.MyCommand.Path) 'umbraco\Data\' 2 | #Write-Output "Target directory: $dir" 3 | Get-ChildItem -Path $dir -Filter 'Umbraco.sqlite*' | ForEach-Object { 4 | Write-Host "Deleted: $($_.Name)" -ForegroundColor Green 5 | Remove-Item $_.FullName -Force 6 | } 7 | 8 | $dir = Join-Path (Split-Path -Path $MyInvocation.MyCommand.Path) 'Views\Partials\blocklist\Components\' 9 | #Write-Output "Target directory: $dir" 10 | Get-ChildItem -Path $dir -Filter '*.cshtml' | ForEach-Object { 11 | Write-Host "Deleted: $($_.Name)" -ForegroundColor Green 12 | Remove-Item $_.FullName -Force 13 | } 14 | 15 | $dir = Join-Path (Split-Path -Path $MyInvocation.MyCommand.Path) 'Views\' 16 | #Write-Output "Target directory: $dir" 17 | 18 | Get-ChildItem -Path $dir -File -Filter '*' -Depth 0 | Where-Object {$_.Name -ne '_ViewImports.cshtml'} | ForEach-Object { 19 | Write-Host "Deleted: $($_.Name)" -ForegroundColor Green 20 | Remove-Item $_.FullName -Force 21 | } 22 | 23 | $dir = Join-Path (Split-Path -Path $MyInvocation.MyCommand.Path) 'Views\Partials\' 24 | #Write-Output "Target directory: $dir" 25 | 26 | Get-ChildItem -Path $dir -File -Filter '*' -Depth 0 | Where-Object {$_.Name -ne '_ViewImports.cshtml'} | ForEach-Object { 27 | Write-Host "Deleted: $($_.Name)" -ForegroundColor Green 28 | Remove-Item $_.FullName -Force 29 | } -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/Program.cs: -------------------------------------------------------------------------------- 1 | namespace QuickBlocks.TestSite 2 | { 3 | public class Program 4 | { 5 | public static void Main(string[] args) 6 | => CreateHostBuilder(args) 7 | .Build() 8 | .Run(); 9 | 10 | public static IHostBuilder CreateHostBuilder(string[] args) => 11 | Host.CreateDefaultBuilder(args) 12 | .ConfigureUmbracoDefaults() 13 | .ConfigureWebHostDefaults(webBuilder => 14 | { 15 | webBuilder.UseStaticWebAssets(); 16 | webBuilder.UseStartup(); 17 | }); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://json.schemastore.org/launchsettings.json", 3 | "iisSettings": { 4 | "windowsAuthentication": false, 5 | "anonymousAuthentication": true, 6 | "iisExpress": { 7 | "applicationUrl": "http://localhost:62471", 8 | "sslPort": 44397 9 | } 10 | }, 11 | "profiles": { 12 | "IIS Express": { 13 | "commandName": "IISExpress", 14 | "launchBrowser": true, 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | }, 19 | "Umbraco.Web.UI": { 20 | "commandName": "Project", 21 | "dotnetRunMessages": true, 22 | "launchBrowser": true, 23 | "applicationUrl": "https://localhost:44397;http://localhost:62471", 24 | "environmentVariables": { 25 | "ASPNETCORE_ENVIRONMENT": "Development" 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/QuickBlocks.TestSite.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net6.0 4 | enable 5 | enable 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | true 21 | 22 | 23 | 24 | 25 | false 26 | false 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/Startup.cs: -------------------------------------------------------------------------------- 1 | using Umbraco.Community.QuickBlocks; 2 | 3 | namespace QuickBlocks.TestSite 4 | { 5 | public class Startup 6 | { 7 | private readonly IWebHostEnvironment _env; 8 | private readonly IConfiguration _config; 9 | 10 | /// 11 | /// Initializes a new instance of the class. 12 | /// 13 | /// The web hosting environment. 14 | /// The configuration. 15 | /// 16 | /// Only a few services are possible to be injected here https://github.com/dotnet/aspnetcore/issues/9337. 17 | /// 18 | public Startup(IWebHostEnvironment webHostEnvironment, IConfiguration config) 19 | { 20 | _env = webHostEnvironment ?? throw new ArgumentNullException(nameof(webHostEnvironment)); 21 | _config = config ?? throw new ArgumentNullException(nameof(config)); 22 | } 23 | 24 | /// 25 | /// Configures the services. 26 | /// 27 | /// The services. 28 | /// 29 | /// This method gets called by the runtime. Use this method to add services to the container. 30 | /// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940. 31 | /// 32 | public void ConfigureServices(IServiceCollection services) 33 | { 34 | services.AddUmbraco(_env, _config) 35 | .AddBackOffice() 36 | .AddWebsite() 37 | .AddComposers() 38 | .Build(); 39 | 40 | // Example: hot to modify the default data type name 41 | //services.Configure(cfg => 42 | //{ 43 | // cfg.DefaultDataTypeName = "Textarea"; 44 | //}); 45 | } 46 | 47 | /// 48 | /// Configures the application. 49 | /// 50 | /// The application builder. 51 | /// The web hosting environment. 52 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env) 53 | { 54 | if (env.IsDevelopment()) 55 | { 56 | app.UseDeveloperExceptionPage(); 57 | } 58 | 59 | app.UseUmbraco() 60 | .WithMiddleware(u => 61 | { 62 | u.UseBackOffice(); 63 | u.UseWebsite(); 64 | }) 65 | .WithEndpoints(u => 66 | { 67 | u.UseInstallerEndpoints(); 68 | u.UseBackOfficeEndpoints(); 69 | u.UseWebsiteEndpoints(); 70 | }); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/TextareaDataTypeMapper.cs: -------------------------------------------------------------------------------- 1 | using Umbraco.Community.QuickBlocks.Models; 2 | 3 | namespace QuickBlocks.TestSite 4 | { 5 | public class TextareaDataTypeMapper : IDataTypeMapper 6 | { 7 | public IEnumerable HtmlElements => new[] {"h1"} ; 8 | 9 | public string DataTypeName => "textarea"; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/TextareaMapperComposer.cs: -------------------------------------------------------------------------------- 1 | using Umbraco.Cms.Core.Composing; 2 | using Umbraco.Community.QuickBlocks; 3 | 4 | namespace QuickBlocks.TestSite 5 | { 6 | // Use to test the ability to add a new data type mapper to the datatype mappers collection 7 | [ComposeAfter(typeof(QuickBlocksComposer))] 8 | internal class TextAreaMapperComposer : IComposer 9 | { 10 | public void Compose(IUmbracoBuilder builder) 11 | { 12 | // Example: how to add a new data type mapper to the datatype mappers collection 13 | //builder.QuickBlockDataTypeMappers() 14 | // .InsertAfter(); 15 | 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/Views/Partials/blockgrid/area.cshtml: -------------------------------------------------------------------------------- 1 | @using Umbraco.Extensions 2 | @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage 3 | 4 |
9 | @await Html.GetBlockGridItemsHtmlAsync(Model) 10 |
11 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/Views/Partials/blockgrid/areas.cshtml: -------------------------------------------------------------------------------- 1 | @using Umbraco.Extensions 2 | @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage 3 | @{ 4 | if (Model?.Areas.Any() != true) { return; } 5 | } 6 | 7 |
9 | @foreach (var area in Model.Areas) 10 | { 11 | @await Html.GetBlockGridItemAreaHtmlAsync(area) 12 | } 13 |
14 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/Views/Partials/blockgrid/default.cshtml: -------------------------------------------------------------------------------- 1 | @using Umbraco.Extensions 2 | @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage 3 | @{ 4 | if (Model?.Any() != true) { return; } 5 | } 6 | 7 |
10 | @await Html.GetBlockGridItemsHtmlAsync(Model) 11 |
12 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/Views/Partials/blockgrid/items.cshtml: -------------------------------------------------------------------------------- 1 | @using Umbraco.Cms.Core.Models.Blocks 2 | @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage> 3 | @{ 4 | if (Model?.Any() != true) { return; } 5 | } 6 | 7 |
8 | @foreach (var item in Model) 9 | { 10 | 11 |
19 | @{ 20 | var partialViewName = "blockgrid/Components/" + item.Content.ContentType.Alias; 21 | try 22 | { 23 | @await Html.PartialAsync(partialViewName, item) 24 | } 25 | catch (InvalidOperationException) 26 | { 27 |

28 | Could not render component of type: @(item.Content.ContentType.Alias) 29 |
30 | This likely happened because the partial view @partialViewName could not be found. 31 |

32 | } 33 | } 34 |
35 | } 36 |
37 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/Views/Partials/blocklist/default.cshtml: -------------------------------------------------------------------------------- 1 | @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage 2 | @{ 3 | if (Model?.Any() != true) { return; } 4 | } 5 |
6 | @foreach (var block in Model) 7 | { 8 | if (block?.ContentUdi == null) { continue; } 9 | var data = block.Content; 10 | 11 | @await Html.PartialAsync("blocklist/Components/" + data.ContentType.Alias, block) 12 | } 13 |
14 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/Views/Partials/grid/bootstrap3-fluid.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web 2 | @using Microsoft.AspNetCore.Html 3 | @using Newtonsoft.Json.Linq 4 | @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage 5 | 6 | @* 7 | Razor helpers located at the bottom of this file 8 | *@ 9 | 10 | @if (Model is JObject && Model?.sections is not null) 11 | { 12 | var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1; 13 | 14 |
15 | @if (oneColumn) 16 | { 17 | foreach (var section in Model.sections) 18 | { 19 |
20 | @foreach (var row in section.rows) 21 | { 22 | renderRow(row); 23 | } 24 |
25 | } 26 | } 27 | else 28 | { 29 |
30 | @foreach (var sec in Model.sections) 31 | { 32 |
33 |
34 | @foreach (var row in sec.rows) 35 | { 36 | renderRow(row); 37 | } 38 |
39 |
40 | } 41 |
42 | } 43 |
44 | } 45 | 46 | @functions{ 47 | 48 | private async Task renderRow(dynamic row) 49 | { 50 |
51 |
52 | @foreach (var area in row.areas) 53 | { 54 |
55 |
56 | @foreach (var control in area.controls) 57 | { 58 | if (control?.editor?.view != null) 59 | { 60 | @await Html.PartialAsync("grid/editors/base", (object)control) 61 | } 62 | } 63 |
64 |
65 | } 66 |
67 |
68 | } 69 | } 70 | 71 | @functions{ 72 | 73 | public static HtmlString RenderElementAttributes(dynamic contentItem) 74 | { 75 | var attrs = new List(); 76 | JObject cfg = contentItem.config; 77 | 78 | if (cfg != null) 79 | { 80 | foreach (JProperty property in cfg.Properties()) 81 | { 82 | var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString()); 83 | attrs.Add(property.Name + "=\"" + propertyValue + "\""); 84 | } 85 | } 86 | 87 | JObject style = contentItem.styles; 88 | 89 | if (style != null) { 90 | var cssVals = new List(); 91 | foreach (JProperty property in style.Properties()) 92 | { 93 | var propertyValue = property.Value.ToString(); 94 | if (string.IsNullOrWhiteSpace(propertyValue) == false) 95 | { 96 | cssVals.Add(property.Name + ":" + propertyValue + ";"); 97 | } 98 | } 99 | 100 | if (cssVals.Any()) 101 | attrs.Add("style='" + HttpUtility.HtmlAttributeEncode(string.Join(" ", cssVals)) + "'"); 102 | } 103 | 104 | return new HtmlString(string.Join(" ", attrs)); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/Views/Partials/grid/bootstrap3.cshtml: -------------------------------------------------------------------------------- 1 | @using System.Web 2 | @using Microsoft.AspNetCore.Html 3 | @using Newtonsoft.Json.Linq 4 | @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage 5 | 6 | @if (Model is JObject && Model?.sections is not null) 7 | { 8 | var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1; 9 | 10 |
11 | @if (oneColumn) 12 | { 13 | foreach (var section in Model.sections) 14 | { 15 |
16 | @foreach (var row in section.rows) 17 | { 18 | renderRow(row, true); 19 | } 20 |
21 | } 22 | } 23 | else 24 | { 25 |
26 |
27 | @foreach (var sec in Model.sections) 28 | { 29 |
30 |
31 | @foreach (var row in sec.rows) 32 | { 33 | renderRow(row, false); 34 | } 35 |
36 |
37 | } 38 |
39 |
40 | } 41 |
42 | } 43 | 44 | @functions{ 45 | 46 | private async Task renderRow(dynamic row, bool singleColumn) 47 | { 48 |
49 | @if (singleColumn) { 50 | @:
51 | } 52 |
53 | @foreach (var area in row.areas) 54 | { 55 |
56 |
57 | @foreach (var control in area.controls) 58 | { 59 | if (control?.editor?.view != null) 60 | { 61 | @await Html.PartialAsync("grid/editors/base", (object)control) 62 | } 63 | } 64 |
65 |
66 | } 67 |
68 | @if (singleColumn) { 69 | @:
70 | } 71 |
72 | } 73 | 74 | } 75 | 76 | @functions{ 77 | 78 | public static HtmlString RenderElementAttributes(dynamic contentItem) 79 | { 80 | var attrs = new List(); 81 | JObject cfg = contentItem.config; 82 | 83 | if (cfg != null) 84 | { 85 | foreach (JProperty property in cfg.Properties()) 86 | { 87 | var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString()); 88 | attrs.Add(property.Name + "=\"" + propertyValue + "\""); 89 | } 90 | } 91 | 92 | JObject style = contentItem.styles; 93 | 94 | if (style != null) 95 | { 96 | var cssVals = new List(); 97 | foreach (JProperty property in style.Properties()) 98 | { 99 | var propertyValue = property.Value.ToString(); 100 | if (string.IsNullOrWhiteSpace(propertyValue) == false) 101 | { 102 | cssVals.Add(property.Name + ":" + propertyValue + ";"); 103 | } 104 | } 105 | 106 | if (cssVals.Any()) 107 | attrs.Add("style=\"" + HttpUtility.HtmlAttributeEncode(string.Join(" ", cssVals)) + "\""); 108 | } 109 | 110 | return new HtmlString(string.Join(" ", attrs)); 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/Views/Partials/grid/editors/base.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | 3 | @try 4 | { 5 | string editor = EditorView(Model); 6 | @await Html.PartialAsync(editor, Model as object) 7 | } 8 | catch (Exception ex) 9 | { 10 |
@ex.ToString()
11 | } 12 | 13 | @functions{ 14 | 15 | public static string EditorView(dynamic contentItem) 16 | { 17 | string view = contentItem.editor.render != null ? contentItem.editor.render.ToString() : contentItem.editor.view.ToString(); 18 | view = view.Replace(".html", ".cshtml"); 19 | 20 | if (!view.Contains("/")) 21 | { 22 | view = "grid/editors/" + view; 23 | } 24 | 25 | return view; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/Views/Partials/grid/editors/embed.cshtml: -------------------------------------------------------------------------------- 1 | @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage 2 | 3 | @if (Model is not null) 4 | { 5 | string embedValue = Convert.ToString(Model.value); 6 | embedValue = embedValue.DetectIsJson() ? Model.value.preview : Model.value; 7 | 8 |
9 | @Html.Raw(embedValue) 10 |
11 | } 12 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/Views/Partials/grid/editors/macro.cshtml: -------------------------------------------------------------------------------- 1 | @inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage 2 | 3 | @if (Model?.value is not null) 4 | { 5 | string macroAlias = Model.value.macroAlias.ToString(); 6 | var parameters = new Dictionary(); 7 | foreach (var mpd in Model.value.macroParamsDictionary) 8 | { 9 | parameters.Add(mpd.Name, mpd.Value); 10 | } 11 | 12 | 13 | @await Umbraco.RenderMacroAsync(macroAlias, parameters) 14 | 15 | } 16 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/Views/Partials/grid/editors/media.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | @using Umbraco.Cms.Core.Media 3 | @using Umbraco.Cms.Core.PropertyEditors.ValueConverters 4 | @inject IImageUrlGenerator ImageUrlGenerator 5 | 6 | @if (Model?.value is not null) 7 | { 8 | var url = Model.value.image; 9 | 10 | if (Model.editor.config != null && Model.editor.config.size != null) 11 | { 12 | if (Model.value.coordinates != null) 13 | { 14 | url = ImageCropperTemplateCoreExtensions.GetCropUrl( 15 | (string)url, 16 | ImageUrlGenerator, 17 | width: (int)Model.editor.config.size.width, 18 | height: (int)Model.editor.config.size.height, 19 | cropAlias: "default", 20 | cropDataSet: new ImageCropperValue 21 | { 22 | Crops = new[] 23 | { 24 | new ImageCropperValue.ImageCropperCrop 25 | { 26 | Alias = "default", 27 | Coordinates = new ImageCropperValue.ImageCropperCropCoordinates 28 | { 29 | X1 = (decimal)Model.value.coordinates.x1, 30 | Y1 = (decimal)Model.value.coordinates.y1, 31 | X2 = (decimal)Model.value.coordinates.x2, 32 | Y2 = (decimal)Model.value.coordinates.y2 33 | } 34 | } 35 | } 36 | }); 37 | } 38 | else 39 | { 40 | url = ImageCropperTemplateCoreExtensions.GetCropUrl( 41 | (string)url, 42 | ImageUrlGenerator, 43 | width: (int)Model.editor.config.size.width, 44 | height: (int)Model.editor.config.size.height, 45 | cropDataSet: new ImageCropperValue 46 | { 47 | FocalPoint = new ImageCropperValue.ImageCropperFocalPoint 48 | { 49 | Top = Model.value.focalPoint == null ? 0.5m : Model.value.focalPoint.top, 50 | Left = Model.value.focalPoint == null ? 0.5m : Model.value.focalPoint.left 51 | } 52 | }); 53 | } 54 | } 55 | 56 | var altText = Model.value.altText ?? Model.value.caption ?? string.Empty; 57 | 58 | @altText 59 | 60 | if (Model.value.caption != null) 61 | { 62 |

@Model.value.caption

63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/Views/Partials/grid/editors/rte.cshtml: -------------------------------------------------------------------------------- 1 | @using Umbraco.Cms.Core.Templates 2 | @model dynamic 3 | @inject HtmlLocalLinkParser HtmlLocalLinkParser; 4 | @inject HtmlUrlParser HtmlUrlParser; 5 | @inject HtmlImageSourceParser HtmlImageSourceParser; 6 | 7 | @{ 8 | var value = HtmlLocalLinkParser.EnsureInternalLinks(Model?.value.ToString()); 9 | value = HtmlUrlParser.EnsureUrls(value); 10 | value = HtmlImageSourceParser.EnsureImageSources(value); 11 | } 12 | 13 | @Html.Raw(value) 14 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/Views/Partials/grid/editors/textstring.cshtml: -------------------------------------------------------------------------------- 1 | @model dynamic 2 | 3 | @if (Model?.editor.config.markup is not null) 4 | { 5 | string markup = Model.editor.config.markup.ToString(); 6 | markup = markup.Replace("#value#", Html.ReplaceLineBreaks((string)Model.value.ToString()).ToString()); 7 | 8 | if (Model.editor.config.style != null) 9 | { 10 | markup = markup.Replace("#style#", Model.editor.config.style.ToString()); 11 | } 12 | 13 | 14 | @Html.Raw(markup) 15 | 16 | } 17 | else 18 | { 19 | 20 |
@Model?.value
21 |
22 | } 23 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/Views/_ViewImports.cshtml: -------------------------------------------------------------------------------- 1 | @using Umbraco.Extensions 2 | @using QuickBlocks.TestSite 3 | @using Umbraco.Cms.Web.Common.PublishedModels 4 | @using Umbraco.Cms.Web.Common.Views 5 | @using Umbraco.Cms.Core.Models.PublishedContent 6 | @using Microsoft.AspNetCore.Html 7 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 8 | @addTagHelper *, Smidge 9 | @inject Smidge.SmidgeHelper SmidgeHelper 10 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./appsettings-schema.json", 3 | "Serilog": { 4 | "MinimumLevel": { 5 | "Default": "Information" 6 | }, 7 | "WriteTo": [ 8 | { 9 | "Name": "Async", 10 | "Args": { 11 | "configure": [ 12 | { 13 | "Name": "Console" 14 | } 15 | ] 16 | } 17 | } 18 | ] 19 | }, 20 | "ConnectionStrings": { 21 | "umbracoDbDSN": "Data Source=|DataDirectory|/Umbraco.sqlite.db;Cache=Shared;Foreign Keys=True;Pooling=True", 22 | "umbracoDbDSN_ProviderName": "Microsoft.Data.Sqlite" 23 | }, 24 | "Umbraco": { 25 | "CMS": { 26 | "Unattended": { 27 | "InstallUnattended": true, 28 | "UnattendedUserName": "Administrator", 29 | "UnattendedUserEmail": "admin@example.com", 30 | "UnattendedUserPassword": "1234567890" 31 | }, 32 | "Content": { 33 | "MacroErrors": "Throw" 34 | }, 35 | "Hosting": { 36 | "Debug": true 37 | }, 38 | "RuntimeMinification": { 39 | "UseInMemoryCache": true, 40 | "CacheBuster": "Timestamp" 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./appsettings-schema.json", 3 | "Serilog": { 4 | "MinimumLevel": { 5 | "Default": "Information", 6 | "Override": { 7 | "Microsoft": "Warning", 8 | "Microsoft.Hosting.Lifetime": "Information", 9 | "System": "Warning" 10 | } 11 | } 12 | }, 13 | "Umbraco": { 14 | "CMS": { 15 | "Global": { 16 | "Id": "5a24fea3-3170-4cf7-9b92-1ccd4a1e73ab", 17 | "SanitizeTinyMce": true 18 | }, 19 | "Content": { 20 | "AllowEditInvariantFromNonDefault": true, 21 | "ContentVersionCleanupPolicy": { 22 | "EnableCleanup": true 23 | } 24 | } 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/stylish.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Stylish Portfolio - Start Bootstrap Template 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 33 |
34 | 35 |
36 |
37 |

Stylish Portfolio

38 |

A Free Bootstrap Theme by Start Bootstrap

39 | Find Out More 40 |
41 |
42 | 43 |
44 |
45 |
46 |
47 |

Stylish Portfolio is the perfect theme for your next project!

48 |
49 |

50 | This theme features a flexible, UX friendly sidebar menu and stock photos from our friends at 51 | Unsplash 52 | ! 53 |

54 |
55 | What We Offer 56 |
57 |
58 |
59 |
60 | 61 |
62 |
63 |
64 |

Services

65 |

What We Offer

66 |
67 |
68 |
69 | 70 |

[!title!]

71 |

Looks great on any screen size!

72 |
73 |
74 |
75 |
76 | 77 |
78 |
79 |
80 |

81 | Welcome to 82 | your 83 | next website! 84 |

85 |
86 | Download Now! 87 |
88 |
89 | 90 |
91 |
92 |
93 |

Portfolio

94 |

Recent Projects

95 |
96 | 109 |
110 |
111 | 112 |
113 |
114 |

The buttons below are impossible to resist...

115 | Click Me! 116 | Look at Me! 117 |
118 |
119 | 120 |
121 | 122 |
123 | 124 |
125 |
126 | 127 |
128 |
129 |
    130 |
  • 131 | 132 |
  • 133 |
  • 134 | 135 |
  • 136 |
  • 137 | 138 |
  • 139 |
140 |

Copyright © Your Website 2023

141 |
142 |
143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/wwwroot/assets/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prjseal/QuickBlocks/112753bf5d25f9c00ad8660c81bb94c3561268b2/src/QuickBlocks.TestSite/wwwroot/assets/favicon.ico -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/wwwroot/assets/img/bg-callout.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prjseal/QuickBlocks/112753bf5d25f9c00ad8660c81bb94c3561268b2/src/QuickBlocks.TestSite/wwwroot/assets/img/bg-callout.jpg -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/wwwroot/assets/img/bg-masthead.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prjseal/QuickBlocks/112753bf5d25f9c00ad8660c81bb94c3561268b2/src/QuickBlocks.TestSite/wwwroot/assets/img/bg-masthead.jpg -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/wwwroot/assets/img/portfolio-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prjseal/QuickBlocks/112753bf5d25f9c00ad8660c81bb94c3561268b2/src/QuickBlocks.TestSite/wwwroot/assets/img/portfolio-1.jpg -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/wwwroot/assets/img/portfolio-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prjseal/QuickBlocks/112753bf5d25f9c00ad8660c81bb94c3561268b2/src/QuickBlocks.TestSite/wwwroot/assets/img/portfolio-2.jpg -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/wwwroot/assets/img/portfolio-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prjseal/QuickBlocks/112753bf5d25f9c00ad8660c81bb94c3561268b2/src/QuickBlocks.TestSite/wwwroot/assets/img/portfolio-3.jpg -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/wwwroot/assets/img/portfolio-4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prjseal/QuickBlocks/112753bf5d25f9c00ad8660c81bb94c3561268b2/src/QuickBlocks.TestSite/wwwroot/assets/img/portfolio-4.jpg -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/prjseal/QuickBlocks/112753bf5d25f9c00ad8660c81bb94c3561268b2/src/QuickBlocks.TestSite/wwwroot/favicon.ico -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/wwwroot/js/scripts.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Start Bootstrap - Stylish Portfolio v6.0.6 (https://startbootstrap.com/theme/stylish-portfolio) 3 | * Copyright 2013-2023 Start Bootstrap 4 | * Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-stylish-portfolio/blob/master/LICENSE) 5 | */ 6 | window.addEventListener('DOMContentLoaded', event => { 7 | 8 | const sidebarWrapper = document.getElementById('sidebar-wrapper'); 9 | let scrollToTopVisible = false; 10 | // Closes the sidebar menu 11 | const menuToggle = document.body.querySelector('.menu-toggle'); 12 | menuToggle.addEventListener('click', event => { 13 | event.preventDefault(); 14 | sidebarWrapper.classList.toggle('active'); 15 | _toggleMenuIcon(); 16 | menuToggle.classList.toggle('active'); 17 | }) 18 | 19 | // Closes responsive menu when a scroll trigger link is clicked 20 | var scrollTriggerList = [].slice.call(document.querySelectorAll('#sidebar-wrapper .js-scroll-trigger')); 21 | scrollTriggerList.map(scrollTrigger => { 22 | scrollTrigger.addEventListener('click', () => { 23 | sidebarWrapper.classList.remove('active'); 24 | menuToggle.classList.remove('active'); 25 | _toggleMenuIcon(); 26 | }) 27 | }); 28 | 29 | function _toggleMenuIcon() { 30 | const menuToggleBars = document.body.querySelector('.menu-toggle > .fa-bars'); 31 | const menuToggleTimes = document.body.querySelector('.menu-toggle > .fa-xmark'); 32 | if (menuToggleBars) { 33 | menuToggleBars.classList.remove('fa-bars'); 34 | menuToggleBars.classList.add('fa-xmark'); 35 | } 36 | if (menuToggleTimes) { 37 | menuToggleTimes.classList.remove('fa-xmark'); 38 | menuToggleTimes.classList.add('fa-bars'); 39 | } 40 | } 41 | 42 | // Scroll to top button appear 43 | document.addEventListener('scroll', () => { 44 | const scrollToTop = document.body.querySelector('.scroll-to-top'); 45 | if (document.documentElement.scrollTop > 100) { 46 | if (!scrollToTopVisible) { 47 | fadeIn(scrollToTop); 48 | scrollToTopVisible = true; 49 | } 50 | } else { 51 | if (scrollToTopVisible) { 52 | fadeOut(scrollToTop); 53 | scrollToTopVisible = false; 54 | } 55 | } 56 | }) 57 | }) 58 | 59 | function fadeOut(el) { 60 | el.style.opacity = 1; 61 | (function fade() { 62 | if ((el.style.opacity -= .1) < 0) { 63 | el.style.display = "none"; 64 | } else { 65 | requestAnimationFrame(fade); 66 | } 67 | })(); 68 | }; 69 | 70 | function fadeIn(el, display) { 71 | el.style.opacity = 0; 72 | el.style.display = display || "block"; 73 | (function fade() { 74 | var val = parseFloat(el.style.opacity); 75 | if (!((val += .1) > 1)) { 76 | el.style.opacity = val; 77 | requestAnimationFrame(fade); 78 | } 79 | })(); 80 | }; 81 | -------------------------------------------------------------------------------- /src/QuickBlocks.TestSite/wwwroot/stylish.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Stylish Portfolio - Start Bootstrap Template 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 33 | 34 |
35 |
36 |

Stylish Portfolio

37 |

A Free Bootstrap Theme by Start Bootstrap

38 | Find Out More 39 |
40 |
41 | 42 |
43 |
44 |
45 |
46 |

Stylish Portfolio is the perfect theme for your next project!

47 |

48 | This theme features a flexible, UX friendly sidebar menu and stock photos from our friends at 49 | Unsplash 50 | ! 51 |

52 | What We Offer 53 |
54 |
55 |
56 |
57 | 58 |
59 |
60 |
61 |

Services

62 |

What We Offer

63 |
64 |
65 |
66 | 67 |

Responsive

68 |

Looks great on any screen size!

69 |
70 |
71 | 72 |

Redesigned

73 |

Freshly redesigned for Bootstrap 5.

74 |
75 |
76 | 77 |

Favorited

78 |

79 | Millions of users 80 | 81 | Start Bootstrap! 82 |

83 |
84 |
85 | 86 |

Question

87 |

I mustache you a question...

88 |
89 |
90 |
91 |
92 | 93 |
94 |
95 |

96 | Welcome to 97 | your 98 | next website! 99 |

100 | Download Now! 101 |
102 |
103 | 104 |
105 | 157 |
158 | 159 |
160 |
161 |

The buttons below are impossible to resist...

162 | Click Me! 163 | Look at Me! 164 |
165 |
166 | 167 |
168 | 169 |
170 | 171 |
172 | 173 |
174 |
175 |
    176 |
  • 177 | 178 |
  • 179 |
  • 180 | 181 |
  • 182 |
  • 183 | 184 |
  • 185 |
186 |

Copyright © Your Website 2023

187 |
188 |
189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | -------------------------------------------------------------------------------- /src/QuickBlocks.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.4.33020.496 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{3A7588F1-7C30-424A-9148-8C3F13B34846}" 7 | ProjectSection(SolutionItems) = preProject 8 | ..\LICENSE = ..\LICENSE 9 | ..\.github\README.md = ..\.github\README.md 10 | ..\umbraco-marketplace.json = ..\umbraco-marketplace.json 11 | EndProjectSection 12 | EndProject 13 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QuickBlocks", "QuickBlocks\QuickBlocks.csproj", "{F9627056-2B01-4806-B600-CBFE65FD9EA5}" 14 | EndProject 15 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "QuickBlocks.TestSite", "QuickBlocks.TestSite\QuickBlocks.TestSite.csproj", "{8E1D6B4F-3667-47D3-B517-A7EDE3CF066D}" 16 | EndProject 17 | Global 18 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 19 | Debug|Any CPU = Debug|Any CPU 20 | Release|Any CPU = Release|Any CPU 21 | EndGlobalSection 22 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 23 | {F9627056-2B01-4806-B600-CBFE65FD9EA5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 24 | {F9627056-2B01-4806-B600-CBFE65FD9EA5}.Debug|Any CPU.Build.0 = Debug|Any CPU 25 | {F9627056-2B01-4806-B600-CBFE65FD9EA5}.Release|Any CPU.ActiveCfg = Release|Any CPU 26 | {F9627056-2B01-4806-B600-CBFE65FD9EA5}.Release|Any CPU.Build.0 = Release|Any CPU 27 | {8E1D6B4F-3667-47D3-B517-A7EDE3CF066D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 28 | {8E1D6B4F-3667-47D3-B517-A7EDE3CF066D}.Debug|Any CPU.Build.0 = Debug|Any CPU 29 | {8E1D6B4F-3667-47D3-B517-A7EDE3CF066D}.Release|Any CPU.ActiveCfg = Release|Any CPU 30 | {8E1D6B4F-3667-47D3-B517-A7EDE3CF066D}.Release|Any CPU.Build.0 = Release|Any CPU 31 | EndGlobalSection 32 | GlobalSection(SolutionProperties) = preSolution 33 | HideSolutionNode = FALSE 34 | EndGlobalSection 35 | GlobalSection(ExtensibilityGlobals) = postSolution 36 | SolutionGuid = {6F07004F-9903-4AEB-9ED0-BE57A0326D20} 37 | EndGlobalSection 38 | EndGlobal 39 | -------------------------------------------------------------------------------- /src/QuickBlocks/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | # All files 4 | [*] 5 | indent_style = space 6 | 7 | # Xml files 8 | [*.xml] 9 | indent_size = 2 10 | 11 | # C# files 12 | [*.cs] 13 | 14 | #### Core EditorConfig Options #### 15 | 16 | # Indentation and spacing 17 | indent_size = 4 18 | tab_width = 4 19 | 20 | # New line preferences 21 | end_of_line = crlf 22 | insert_final_newline = false 23 | 24 | #### .NET Coding Conventions #### 25 | [*.{cs,vb}] 26 | 27 | # Organize usings 28 | dotnet_separate_import_directive_groups = true 29 | dotnet_sort_system_directives_first = true 30 | file_header_template = unset 31 | 32 | # this. and Me. preferences 33 | dotnet_style_qualification_for_event = false:silent 34 | dotnet_style_qualification_for_field = false:silent 35 | dotnet_style_qualification_for_method = false:silent 36 | dotnet_style_qualification_for_property = false:silent 37 | 38 | # Language keywords vs BCL types preferences 39 | dotnet_style_predefined_type_for_locals_parameters_members = true:silent 40 | dotnet_style_predefined_type_for_member_access = true:silent 41 | 42 | # Parentheses preferences 43 | dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent 44 | dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent 45 | dotnet_style_parentheses_in_other_operators = never_if_unnecessary:silent 46 | dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent 47 | 48 | # Modifier preferences 49 | dotnet_style_require_accessibility_modifiers = for_non_interface_members:silent 50 | 51 | # Expression-level preferences 52 | dotnet_style_coalesce_expression = true:suggestion 53 | dotnet_style_collection_initializer = true:suggestion 54 | dotnet_style_explicit_tuple_names = true:suggestion 55 | dotnet_style_null_propagation = true:suggestion 56 | dotnet_style_object_initializer = true:suggestion 57 | dotnet_style_operator_placement_when_wrapping = beginning_of_line 58 | dotnet_style_prefer_auto_properties = true:suggestion 59 | dotnet_style_prefer_compound_assignment = true:suggestion 60 | dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion 61 | dotnet_style_prefer_conditional_expression_over_return = true:suggestion 62 | dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion 63 | dotnet_style_prefer_inferred_tuple_names = true:suggestion 64 | dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion 65 | dotnet_style_prefer_simplified_boolean_expressions = true:suggestion 66 | dotnet_style_prefer_simplified_interpolation = true:suggestion 67 | 68 | # Field preferences 69 | dotnet_style_readonly_field = true:warning 70 | 71 | # Parameter preferences 72 | dotnet_code_quality_unused_parameters = all:suggestion 73 | 74 | # Suppression preferences 75 | dotnet_remove_unnecessary_suppression_exclusions = none 76 | 77 | #### C# Coding Conventions #### 78 | [*.cs] 79 | 80 | # var preferences 81 | csharp_style_var_elsewhere = false:silent 82 | csharp_style_var_for_built_in_types = false:silent 83 | csharp_style_var_when_type_is_apparent = false:silent 84 | 85 | # Expression-bodied members 86 | csharp_style_expression_bodied_accessors = true:silent 87 | csharp_style_expression_bodied_constructors = false:silent 88 | csharp_style_expression_bodied_indexers = true:silent 89 | csharp_style_expression_bodied_lambdas = true:suggestion 90 | csharp_style_expression_bodied_local_functions = false:silent 91 | csharp_style_expression_bodied_methods = false:silent 92 | csharp_style_expression_bodied_operators = false:silent 93 | csharp_style_expression_bodied_properties = true:silent 94 | 95 | # Pattern matching preferences 96 | csharp_style_pattern_matching_over_as_with_null_check = true:suggestion 97 | csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion 98 | csharp_style_prefer_not_pattern = true:suggestion 99 | csharp_style_prefer_pattern_matching = true:silent 100 | csharp_style_prefer_switch_expression = true:suggestion 101 | 102 | # Null-checking preferences 103 | csharp_style_conditional_delegate_call = true:suggestion 104 | 105 | # Modifier preferences 106 | csharp_prefer_static_local_function = true:warning 107 | csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:silent 108 | 109 | # Code-block preferences 110 | csharp_prefer_braces = true:silent 111 | csharp_prefer_simple_using_statement = true:suggestion 112 | 113 | # Expression-level preferences 114 | csharp_prefer_simple_default_expression = true:suggestion 115 | csharp_style_deconstructed_variable_declaration = true:suggestion 116 | csharp_style_inlined_variable_declaration = true:suggestion 117 | csharp_style_pattern_local_over_anonymous_function = true:suggestion 118 | csharp_style_prefer_index_operator = true:suggestion 119 | csharp_style_prefer_range_operator = true:suggestion 120 | csharp_style_throw_expression = true:suggestion 121 | csharp_style_unused_value_assignment_preference = discard_variable:suggestion 122 | csharp_style_unused_value_expression_statement_preference = discard_variable:silent 123 | 124 | # 'using' directive preferences 125 | csharp_using_directive_placement = outside_namespace:silent 126 | 127 | #### C# Formatting Rules #### 128 | 129 | # New line preferences 130 | csharp_new_line_before_catch = true 131 | csharp_new_line_before_else = true 132 | csharp_new_line_before_finally = true 133 | csharp_new_line_before_members_in_anonymous_types = true 134 | csharp_new_line_before_members_in_object_initializers = true 135 | csharp_new_line_before_open_brace = all 136 | csharp_new_line_between_query_expression_clauses = true 137 | 138 | # Indentation preferences 139 | csharp_indent_block_contents = true 140 | csharp_indent_braces = false 141 | csharp_indent_case_contents = true 142 | csharp_indent_case_contents_when_block = true 143 | csharp_indent_labels = one_less_than_current 144 | csharp_indent_switch_labels = true 145 | 146 | # Space preferences 147 | csharp_space_after_cast = false 148 | csharp_space_after_colon_in_inheritance_clause = true 149 | csharp_space_after_comma = true 150 | csharp_space_after_dot = false 151 | csharp_space_after_keywords_in_control_flow_statements = true 152 | csharp_space_after_semicolon_in_for_statement = true 153 | csharp_space_around_binary_operators = before_and_after 154 | csharp_space_around_declaration_statements = false 155 | csharp_space_before_colon_in_inheritance_clause = true 156 | csharp_space_before_comma = false 157 | csharp_space_before_dot = false 158 | csharp_space_before_open_square_brackets = false 159 | csharp_space_before_semicolon_in_for_statement = false 160 | csharp_space_between_empty_square_brackets = false 161 | csharp_space_between_method_call_empty_parameter_list_parentheses = false 162 | csharp_space_between_method_call_name_and_opening_parenthesis = false 163 | csharp_space_between_method_call_parameter_list_parentheses = false 164 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false 165 | csharp_space_between_method_declaration_name_and_open_parenthesis = false 166 | csharp_space_between_method_declaration_parameter_list_parentheses = false 167 | csharp_space_between_parentheses = false 168 | csharp_space_between_square_brackets = false 169 | 170 | # Wrapping preferences 171 | csharp_preserve_single_line_blocks = true 172 | csharp_preserve_single_line_statements = true 173 | csharp_style_namespace_declarations = file_scoped:silent 174 | csharp_style_prefer_method_group_conversion = true:silent 175 | csharp_style_prefer_top_level_statements = true:silent 176 | 177 | #### Naming styles #### 178 | [*.{cs,vb}] 179 | 180 | # Naming rules 181 | 182 | dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.severity = suggestion 183 | dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.symbols = types_and_namespaces 184 | dotnet_naming_rule.types_and_namespaces_should_be_pascalcase.style = pascalcase 185 | 186 | dotnet_naming_rule.interfaces_should_be_ipascalcase.severity = suggestion 187 | dotnet_naming_rule.interfaces_should_be_ipascalcase.symbols = interfaces 188 | dotnet_naming_rule.interfaces_should_be_ipascalcase.style = ipascalcase 189 | 190 | dotnet_naming_rule.type_parameters_should_be_tpascalcase.severity = suggestion 191 | dotnet_naming_rule.type_parameters_should_be_tpascalcase.symbols = type_parameters 192 | dotnet_naming_rule.type_parameters_should_be_tpascalcase.style = tpascalcase 193 | 194 | dotnet_naming_rule.methods_should_be_pascalcase.severity = suggestion 195 | dotnet_naming_rule.methods_should_be_pascalcase.symbols = methods 196 | dotnet_naming_rule.methods_should_be_pascalcase.style = pascalcase 197 | 198 | dotnet_naming_rule.properties_should_be_pascalcase.severity = suggestion 199 | dotnet_naming_rule.properties_should_be_pascalcase.symbols = properties 200 | dotnet_naming_rule.properties_should_be_pascalcase.style = pascalcase 201 | 202 | dotnet_naming_rule.events_should_be_pascalcase.severity = suggestion 203 | dotnet_naming_rule.events_should_be_pascalcase.symbols = events 204 | dotnet_naming_rule.events_should_be_pascalcase.style = pascalcase 205 | 206 | dotnet_naming_rule.local_variables_should_be_camelcase.severity = suggestion 207 | dotnet_naming_rule.local_variables_should_be_camelcase.symbols = local_variables 208 | dotnet_naming_rule.local_variables_should_be_camelcase.style = camelcase 209 | 210 | dotnet_naming_rule.local_constants_should_be_camelcase.severity = suggestion 211 | dotnet_naming_rule.local_constants_should_be_camelcase.symbols = local_constants 212 | dotnet_naming_rule.local_constants_should_be_camelcase.style = camelcase 213 | 214 | dotnet_naming_rule.parameters_should_be_camelcase.severity = suggestion 215 | dotnet_naming_rule.parameters_should_be_camelcase.symbols = parameters 216 | dotnet_naming_rule.parameters_should_be_camelcase.style = camelcase 217 | 218 | dotnet_naming_rule.public_fields_should_be_pascalcase.severity = suggestion 219 | dotnet_naming_rule.public_fields_should_be_pascalcase.symbols = public_fields 220 | dotnet_naming_rule.public_fields_should_be_pascalcase.style = pascalcase 221 | 222 | dotnet_naming_rule.private_fields_should_be__camelcase.severity = suggestion 223 | dotnet_naming_rule.private_fields_should_be__camelcase.symbols = private_fields 224 | dotnet_naming_rule.private_fields_should_be__camelcase.style = _camelcase 225 | 226 | dotnet_naming_rule.private_static_fields_should_be_s_camelcase.severity = suggestion 227 | dotnet_naming_rule.private_static_fields_should_be_s_camelcase.symbols = private_static_fields 228 | dotnet_naming_rule.private_static_fields_should_be_s_camelcase.style = s_camelcase 229 | 230 | dotnet_naming_rule.public_constant_fields_should_be_pascalcase.severity = suggestion 231 | dotnet_naming_rule.public_constant_fields_should_be_pascalcase.symbols = public_constant_fields 232 | dotnet_naming_rule.public_constant_fields_should_be_pascalcase.style = pascalcase 233 | 234 | dotnet_naming_rule.private_constant_fields_should_be_pascalcase.severity = suggestion 235 | dotnet_naming_rule.private_constant_fields_should_be_pascalcase.symbols = private_constant_fields 236 | dotnet_naming_rule.private_constant_fields_should_be_pascalcase.style = pascalcase 237 | 238 | dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.severity = suggestion 239 | dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.symbols = public_static_readonly_fields 240 | dotnet_naming_rule.public_static_readonly_fields_should_be_pascalcase.style = pascalcase 241 | 242 | dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.severity = suggestion 243 | dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.symbols = private_static_readonly_fields 244 | dotnet_naming_rule.private_static_readonly_fields_should_be_pascalcase.style = pascalcase 245 | 246 | dotnet_naming_rule.enums_should_be_pascalcase.severity = suggestion 247 | dotnet_naming_rule.enums_should_be_pascalcase.symbols = enums 248 | dotnet_naming_rule.enums_should_be_pascalcase.style = pascalcase 249 | 250 | dotnet_naming_rule.local_functions_should_be_pascalcase.severity = suggestion 251 | dotnet_naming_rule.local_functions_should_be_pascalcase.symbols = local_functions 252 | dotnet_naming_rule.local_functions_should_be_pascalcase.style = pascalcase 253 | 254 | dotnet_naming_rule.non_field_members_should_be_pascalcase.severity = suggestion 255 | dotnet_naming_rule.non_field_members_should_be_pascalcase.symbols = non_field_members 256 | dotnet_naming_rule.non_field_members_should_be_pascalcase.style = pascalcase 257 | 258 | # Symbol specifications 259 | 260 | dotnet_naming_symbols.interfaces.applicable_kinds = interface 261 | dotnet_naming_symbols.interfaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected 262 | dotnet_naming_symbols.interfaces.required_modifiers = 263 | 264 | dotnet_naming_symbols.enums.applicable_kinds = enum 265 | dotnet_naming_symbols.enums.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected 266 | dotnet_naming_symbols.enums.required_modifiers = 267 | 268 | dotnet_naming_symbols.events.applicable_kinds = event 269 | dotnet_naming_symbols.events.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected 270 | dotnet_naming_symbols.events.required_modifiers = 271 | 272 | dotnet_naming_symbols.methods.applicable_kinds = method 273 | dotnet_naming_symbols.methods.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected 274 | dotnet_naming_symbols.methods.required_modifiers = 275 | 276 | dotnet_naming_symbols.properties.applicable_kinds = property 277 | dotnet_naming_symbols.properties.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected 278 | dotnet_naming_symbols.properties.required_modifiers = 279 | 280 | dotnet_naming_symbols.public_fields.applicable_kinds = field 281 | dotnet_naming_symbols.public_fields.applicable_accessibilities = public, internal 282 | dotnet_naming_symbols.public_fields.required_modifiers = 283 | 284 | dotnet_naming_symbols.private_fields.applicable_kinds = field 285 | dotnet_naming_symbols.private_fields.applicable_accessibilities = private, protected, protected_internal, private_protected 286 | dotnet_naming_symbols.private_fields.required_modifiers = 287 | 288 | dotnet_naming_symbols.private_static_fields.applicable_kinds = field 289 | dotnet_naming_symbols.private_static_fields.applicable_accessibilities = private, protected, protected_internal, private_protected 290 | dotnet_naming_symbols.private_static_fields.required_modifiers = static 291 | 292 | dotnet_naming_symbols.types_and_namespaces.applicable_kinds = namespace, class, struct, interface, enum 293 | dotnet_naming_symbols.types_and_namespaces.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected 294 | dotnet_naming_symbols.types_and_namespaces.required_modifiers = 295 | 296 | dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method 297 | dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected 298 | dotnet_naming_symbols.non_field_members.required_modifiers = 299 | 300 | dotnet_naming_symbols.type_parameters.applicable_kinds = namespace 301 | dotnet_naming_symbols.type_parameters.applicable_accessibilities = * 302 | dotnet_naming_symbols.type_parameters.required_modifiers = 303 | 304 | dotnet_naming_symbols.private_constant_fields.applicable_kinds = field 305 | dotnet_naming_symbols.private_constant_fields.applicable_accessibilities = private, protected, protected_internal, private_protected 306 | dotnet_naming_symbols.private_constant_fields.required_modifiers = const 307 | 308 | dotnet_naming_symbols.local_variables.applicable_kinds = local 309 | dotnet_naming_symbols.local_variables.applicable_accessibilities = local 310 | dotnet_naming_symbols.local_variables.required_modifiers = 311 | 312 | dotnet_naming_symbols.local_constants.applicable_kinds = local 313 | dotnet_naming_symbols.local_constants.applicable_accessibilities = local 314 | dotnet_naming_symbols.local_constants.required_modifiers = const 315 | 316 | dotnet_naming_symbols.parameters.applicable_kinds = parameter 317 | dotnet_naming_symbols.parameters.applicable_accessibilities = * 318 | dotnet_naming_symbols.parameters.required_modifiers = 319 | 320 | dotnet_naming_symbols.public_constant_fields.applicable_kinds = field 321 | dotnet_naming_symbols.public_constant_fields.applicable_accessibilities = public, internal 322 | dotnet_naming_symbols.public_constant_fields.required_modifiers = const 323 | 324 | dotnet_naming_symbols.public_static_readonly_fields.applicable_kinds = field 325 | dotnet_naming_symbols.public_static_readonly_fields.applicable_accessibilities = public, internal 326 | dotnet_naming_symbols.public_static_readonly_fields.required_modifiers = readonly, static 327 | 328 | dotnet_naming_symbols.private_static_readonly_fields.applicable_kinds = field 329 | dotnet_naming_symbols.private_static_readonly_fields.applicable_accessibilities = private, protected, protected_internal, private_protected 330 | dotnet_naming_symbols.private_static_readonly_fields.required_modifiers = readonly, static 331 | 332 | dotnet_naming_symbols.local_functions.applicable_kinds = local_function 333 | dotnet_naming_symbols.local_functions.applicable_accessibilities = * 334 | dotnet_naming_symbols.local_functions.required_modifiers = 335 | 336 | # Naming styles 337 | 338 | dotnet_naming_style.pascalcase.required_prefix = 339 | dotnet_naming_style.pascalcase.required_suffix = 340 | dotnet_naming_style.pascalcase.word_separator = 341 | dotnet_naming_style.pascalcase.capitalization = pascal_case 342 | 343 | dotnet_naming_style.ipascalcase.required_prefix = I 344 | dotnet_naming_style.ipascalcase.required_suffix = 345 | dotnet_naming_style.ipascalcase.word_separator = 346 | dotnet_naming_style.ipascalcase.capitalization = pascal_case 347 | 348 | dotnet_naming_style.tpascalcase.required_prefix = T 349 | dotnet_naming_style.tpascalcase.required_suffix = 350 | dotnet_naming_style.tpascalcase.word_separator = 351 | dotnet_naming_style.tpascalcase.capitalization = pascal_case 352 | 353 | dotnet_naming_style._camelcase.required_prefix = _ 354 | dotnet_naming_style._camelcase.required_suffix = 355 | dotnet_naming_style._camelcase.word_separator = 356 | dotnet_naming_style._camelcase.capitalization = camel_case 357 | 358 | dotnet_naming_style.camelcase.required_prefix = 359 | dotnet_naming_style.camelcase.required_suffix = 360 | dotnet_naming_style.camelcase.word_separator = 361 | dotnet_naming_style.camelcase.capitalization = camel_case 362 | 363 | dotnet_naming_style.s_camelcase.required_prefix = s_ 364 | dotnet_naming_style.s_camelcase.required_suffix = 365 | dotnet_naming_style.s_camelcase.word_separator = 366 | dotnet_naming_style.s_camelcase.capitalization = camel_case 367 | tab_width = 4 368 | indent_size = 4 369 | end_of_line = crlf 370 | 371 | -------------------------------------------------------------------------------- /src/QuickBlocks/App_Plugins/QuickBlocks/lang/en-US.xml: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Quick Blocks 🧱 5 | 6 | -------------------------------------------------------------------------------- /src/QuickBlocks/App_Plugins/QuickBlocks/lang/en.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/QuickBlocks/App_Plugins/QuickBlocks/package.manifest: -------------------------------------------------------------------------------- 1 | { 2 | "name": "QuickBlocks", 3 | "version": "1.0.0", 4 | "allowPackageTelemetry": true, 5 | "dashboards": [ 6 | { 7 | "alias": "quickBlocks", 8 | "view": "/App_Plugins/QuickBlocks/quickBlocks.html", 9 | "sections": [ "settings" ], 10 | "weight": -10, 11 | "access": [ 12 | { "deny": "translator" }, 13 | { "grant": "admin" } 14 | ] 15 | } 16 | ], 17 | "javascript": [ 18 | "~/App_Plugins/QuickBlocks/quickBlocks.js" 19 | ], 20 | "css": [ 21 | "~/App_Plugins/QuickBlocks/quickBlocks.css" 22 | ] 23 | } -------------------------------------------------------------------------------- /src/QuickBlocks/App_Plugins/QuickBlocks/quickBlocks.css: -------------------------------------------------------------------------------- 1 | div.quick-blocks-dashboard div.ace_editor { 2 | height: 60vh; 3 | } -------------------------------------------------------------------------------- /src/QuickBlocks/App_Plugins/QuickBlocks/quickBlocks.html: -------------------------------------------------------------------------------- 1 | 
2 | 3 | 4 | 5 | 6 | 7 | 9 | 10 | 11 | 14 |
15 |
16 |
17 |
18 | 19 | 20 |
21 |
22 |
{{model.report | json}}
23 |
24 |
25 | 26 |
27 | 28 |
29 | 34 | 35 | 36 | 41 | 42 |
43 |
44 |
45 | 46 |
-------------------------------------------------------------------------------- /src/QuickBlocks/App_Plugins/QuickBlocks/quickBlocks.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | 'use strict'; 3 | 4 | function QuickBlocksController($scope, $http, editorState, navigationService, $location, notificationsService) { 5 | 6 | var vm = this; 7 | var apiUrl; 8 | 9 | vm.submitState = "init"; 10 | vm.reportState = "init"; 11 | vm.changeTab = changeTab; 12 | 13 | vm.tabs = [ 14 | { 15 | "alias": "htmlSnippet", 16 | "label": "HTML Snippet", 17 | "active": true 18 | }, 19 | { 20 | "alias": "fetchUrl", 21 | "label": "Fetch URL" 22 | }, 23 | { 24 | "alias": "report", 25 | "label": "Report" 26 | } 27 | ]; 28 | 29 | function changeTab(selectedTab) { 30 | vm.tabs.forEach(function(tab) { 31 | tab.active = false; 32 | }); 33 | selectedTab.active = true; 34 | }; 35 | 36 | $scope.submit = function () { 37 | vm.submitState ="busy"; 38 | apiUrl = Umbraco.Sys.ServerVariables["QuickBlocks"]["QuickBlocksApi"]; 39 | 40 | $http.post(apiUrl, JSON.stringify({ Url: $scope.model.url, HtmlBody: $scope.model.htmlbody }), 41 | { 42 | headers: { 43 | 'Content-Type': 'application/json' 44 | } 45 | }).then(function (response) { 46 | $scope.model.report = response.data; 47 | console.log(response.data); 48 | if (response.data?.message) { 49 | notificationsService.error('QuickBlocks', response.data.message); 50 | } else { 51 | notificationsService.success('QuickBlocks', 'Your Block List has been created successfully'); 52 | } 53 | 54 | vm.submitState = "success"; 55 | }, function (response) { 56 | console.log('error'); 57 | notificationsService.error('QuickBlocks', 'There was an error when trying to process your request. Check the console for more details.'); 58 | vm.submitState = "error"; 59 | }); 60 | 61 | }; 62 | 63 | $scope.report = function () { 64 | vm.reportState = "busy"; 65 | apiUrl = Umbraco.Sys.ServerVariables["QuickBlocks"]["QuickBlocksApi"]; 66 | 67 | $http.post(apiUrl, JSON.stringify({ Url: $scope.model.url, HtmlBody: $scope.model.htmlbody, ReadOnly: true }), 68 | { 69 | headers: { 70 | 'Content-Type': 'application/json' 71 | } 72 | }).then(function (response) { 73 | $scope.model.report = response.data; 74 | console.log(response.data); 75 | notificationsService.success('QuickBlocks', 'Your report has been created successfully'); 76 | vm.reportState = "success"; 77 | changeTab(vm.tabs[2]); 78 | }, function (reportState) { 79 | console.log('error'); 80 | notificationsService.success('QuickBlocks', 'There was an error when trying to process your request. Check the console for more details.'); 81 | vm.reportState = "error"; 82 | }); 83 | 84 | }; 85 | 86 | function init() { 87 | 88 | apiUrl = Umbraco.Sys.ServerVariables["QuickBlocks"]["QuickBlocksApi"]; 89 | 90 | $scope.model = { 91 | url: '', 92 | htmlbody: '' 93 | }; 94 | 95 | vm.htmlEditorOptions = { 96 | autoFocus: false, 97 | showGutter: true, 98 | useWrapMode: true, 99 | showInvisibles: false, 100 | showIndentGuides: false, 101 | useSoftTabs: true, 102 | showPrintMargin: false, 103 | disableSearch: false, 104 | theme: "chrome", 105 | mode: "javascript", 106 | firstLineNumber: 1, 107 | advanced: { 108 | fontSize: "small", 109 | enableSnippets: false, 110 | enableBasicAutocompletion: false, 111 | enableLiveAutocompletion: false, 112 | minLines: undefined, 113 | maxLines: undefined, 114 | wrap: true 115 | }, 116 | }; 117 | } 118 | 119 | init(); 120 | 121 | } 122 | 123 | angular.module('umbraco').controller('QuickBlocksController', QuickBlocksController); 124 | 125 | })(); -------------------------------------------------------------------------------- /src/QuickBlocks/Composing/NotificationHandlersComposer.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Umbraco.Community.QuickBlocks.NotificationHandlers; 3 | using Umbraco.Community.QuickBlocks.Services; 4 | using Umbraco.Cms.Core.Composing; 5 | using Umbraco.Cms.Core.DependencyInjection; 6 | using Umbraco.Cms.Core.Notifications; 7 | 8 | namespace Umbraco.Community.QuickBlocks.Composing; 9 | public class NotificationHandlersComposer : IComposer 10 | { 11 | public void Compose(IUmbracoBuilder builder) 12 | { 13 | builder 14 | .AddNotificationHandler(); 16 | } 17 | } -------------------------------------------------------------------------------- /src/QuickBlocks/Composing/RegisterServicesComposer.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using Umbraco.Community.QuickBlocks.Services; 3 | using Umbraco.Cms.Core.Composing; 4 | using Umbraco.Cms.Core.DependencyInjection; 5 | using Umbraco.Community.QuickBlocks.Services.Resolvers; 6 | 7 | namespace Umbraco.Community.QuickBlocks.Composing; 8 | 9 | public class RegisterServicesComposer : IComposer 10 | { 11 | public void Compose(IUmbracoBuilder builder) 12 | { 13 | builder.Services.AddTransient(); 14 | builder.Services.AddTransient(); 15 | builder.Services.AddTransient(); 16 | } 17 | } -------------------------------------------------------------------------------- /src/QuickBlocks/Controllers/QuickBlocksUmbracoApiController.cs: -------------------------------------------------------------------------------- 1 | using System.Text; 2 | 3 | using HtmlAgilityPack; 4 | 5 | using Microsoft.AspNetCore.Hosting; 6 | using Microsoft.AspNetCore.Mvc; 7 | using Microsoft.Extensions.Logging; 8 | 9 | using Umbraco.Cms.Core.Services; 10 | using Umbraco.Cms.Core.Strings; 11 | using Umbraco.Cms.Web.BackOffice.Controllers; 12 | using Umbraco.Community.QuickBlocks.Models; 13 | using Umbraco.Community.QuickBlocks.Services; 14 | 15 | namespace Umbraco.Community.QuickBlocks.Controllers; 16 | 17 | public class QuickBlocksApiController : UmbracoAuthorizedApiController 18 | { 19 | private readonly IBlockParsingService _blockParsingService; 20 | private readonly IBlockCreationService _blockCreationService; 21 | private readonly ILogger _logger; 22 | private readonly IFileService _fileService; 23 | private readonly IContentTypeService _contentTypeService; 24 | private readonly IWebHostEnvironment _webHostEnvironment; 25 | private readonly IShortStringHelper _shortStringHelper; 26 | 27 | 28 | public QuickBlocksApiController(IBlockCreationService blockCreationService, 29 | IBlockParsingService blockParsingService, 30 | ILogger logger, 31 | IFileService fileService, 32 | IContentTypeService contentTypeService, 33 | IWebHostEnvironment webHostEnvironment, 34 | IShortStringHelper shortStringHelper) 35 | { 36 | _blockCreationService = blockCreationService; 37 | _blockParsingService = blockParsingService; 38 | _logger = logger; 39 | _fileService = fileService; 40 | _contentTypeService = contentTypeService; 41 | _webHostEnvironment = webHostEnvironment; 42 | _shortStringHelper = shortStringHelper; 43 | } 44 | 45 | //https://localhost:44306/umbraco/backoffice/api/quickblocksapi/build/ 46 | [HttpPost] 47 | public ActionResult Build(QuickBlocksInstruction quickBlocksInstruction) 48 | { 49 | if (quickBlocksInstruction == null || 50 | (string.IsNullOrWhiteSpace(quickBlocksInstruction.Url ?? "") 51 | && string.IsNullOrWhiteSpace(quickBlocksInstruction.HtmlBody ?? ""))) 52 | return BadRequest("Missing Url Parameter or HtmlBody Parameter in API Request"); 53 | 54 | var doc = new HtmlDocument(); 55 | 56 | if (!string.IsNullOrWhiteSpace(quickBlocksInstruction.HtmlBody)) 57 | { 58 | doc.LoadHtml(quickBlocksInstruction.HtmlBody); 59 | } 60 | else 61 | { 62 | string contentRootPath = _webHostEnvironment.ContentRootPath; 63 | if (!System.IO.File.Exists(Path.Combine(contentRootPath,quickBlocksInstruction.Url))) 64 | { 65 | return new ActionResult(new ContentTypeModel(_shortStringHelper,"",""){Message = "The specified file does not exist"}); 66 | } 67 | doc.Load(quickBlocksInstruction.Url); 68 | } 69 | 70 | var folderStructure = _blockCreationService.CreateFolderStructure(); 71 | var parentDataTypeId = _blockCreationService.CreateSupportingDataTypes(); 72 | _blockCreationService.CreateSupportingContentTypes(folderStructure.CompositionsSettingsModelsId); 73 | 74 | var contentType = _blockParsingService.GetContentType(doc.DocumentNode); 75 | 76 | var lists = _blockParsingService.GetLists(contentType.Html, false); 77 | 78 | foreach (var list in lists) 79 | { 80 | var rows = _blockParsingService.GetRows(list.Html, false); 81 | list.Rows = rows; 82 | foreach (var row in rows) 83 | { 84 | var sublists = _blockParsingService.GetLists(row.Html, true); 85 | row.SubLists = sublists; 86 | foreach (var sublist in row.SubLists) 87 | { 88 | var subRows = _blockParsingService.GetRows(sublist.Html, true); 89 | sublist.Rows = subRows; 90 | foreach (var subRow in sublist.Rows) 91 | { 92 | var subRowProperties = _blockParsingService.GetProperties(subRow.Html); 93 | subRow.Properties = subRowProperties; 94 | } 95 | 96 | if (!quickBlocksInstruction.ReadOnly) 97 | { 98 | _blockCreationService.CreateList(sublist, folderStructure, parentDataTypeId); 99 | } 100 | } 101 | var rowProperties = _blockParsingService.GetProperties(row.Html); 102 | row.Properties = rowProperties; 103 | } 104 | if (!quickBlocksInstruction.ReadOnly) 105 | { 106 | _blockCreationService.CreateList(list, folderStructure, parentDataTypeId); 107 | } 108 | } 109 | 110 | var pageProperties = _blockParsingService.GetProperties(contentType.Html); 111 | contentType.Properties = pageProperties; 112 | 113 | contentType.Lists = lists; 114 | 115 | if (quickBlocksInstruction.ReadOnly) return contentType; 116 | 117 | var partialViews = _blockParsingService.GetPartialViews(doc.DocumentNode); 118 | _blockCreationService.CreatePartialViews(partialViews); 119 | 120 | if (!lists.Any()) return contentType; 121 | 122 | foreach (var list in lists) 123 | { 124 | _blockCreationService.CreateList(list, folderStructure, parentDataTypeId); 125 | } 126 | 127 | if (contentType != null) 128 | { 129 | var newContentType = _blockCreationService.CreateContentType(contentType.Name, contentType.Alias, folderStructure.PagesId, false, false, iconClass: "icon-home", true); 130 | 131 | if (newContentType != null && contentType.Properties != null && contentType.Properties.Any()) 132 | { 133 | _blockCreationService.AddPropertiesToContentType(newContentType, contentType.Properties, "Content"); 134 | } 135 | 136 | var masterTemplate = _fileService.CreateTemplateWithIdentity("Master", "master", doc.Text); 137 | 138 | var masterDoc = new HtmlDocument(); 139 | 140 | masterDoc.LoadHtml(doc.DocumentNode.OuterHtml); 141 | 142 | var mainBody = masterDoc.DocumentNode.SelectNodes("//*[@data-content-type-name]").FirstOrDefault(); 143 | 144 | if (mainBody != null) 145 | { 146 | var textNode = HtmlTextNode.CreateNode("@RenderBody()"); 147 | mainBody.ParentNode.ReplaceChild(textNode, mainBody); 148 | } 149 | 150 | _blockCreationService.ReplaceAllPartialAttributesWithCalls(masterDoc); 151 | 152 | _blockCreationService.RemoveAllQuickBlocksAttributes(masterDoc); 153 | 154 | 155 | masterTemplate.Content = masterTemplate.Content + Environment.NewLine + masterDoc.DocumentNode.OuterHtml; 156 | _fileService.SaveTemplate((masterTemplate)); 157 | 158 | var tryCreateTemplate = _fileService.CreateTemplateForContentType(contentType.Alias, contentType.Name); 159 | if (tryCreateTemplate.Success) 160 | { 161 | var template = tryCreateTemplate.Result.Entity; 162 | if (template != null) 163 | { 164 | newContentType.SetDefaultTemplate(template); 165 | _contentTypeService.Save(newContentType); 166 | } 167 | 168 | template.SetMasterTemplate(masterTemplate); 169 | _fileService.SaveTemplate(template); 170 | 171 | var contentTypeDoc = new HtmlDocument(); 172 | contentTypeDoc.LoadHtml(contentType.Html); 173 | 174 | 175 | var templateContent = new StringBuilder(); 176 | templateContent.AppendLine("@using Umbraco.Cms.Web.Common.PublishedModels;"); 177 | templateContent.AppendLine($"@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage"); 178 | templateContent.AppendLine(" @using ContentModels = Umbraco.Cms.Web.Common.PublishedModels;"); 179 | templateContent.AppendLine("@{"); 180 | templateContent.AppendLine(" Layout = \"master.cshtml\";"); 181 | templateContent.AppendLine("}"); 182 | templateContent.AppendLine(); 183 | 184 | var listProperties = contentTypeDoc.DocumentNode.SelectNodes("//*[@data-list-name]"); 185 | 186 | _blockCreationService.RenderListPropertyCalls(listProperties, "Model"); 187 | 188 | var subListProperties = contentTypeDoc.DocumentNode.SelectNodes("//*[@data-sub-list-name]"); 189 | 190 | _blockCreationService.RenderListPropertyCalls(subListProperties, "Model"); 191 | 192 | var properties = contentTypeDoc.DocumentNode.SelectNodes("//*[@data-prop-name]"); 193 | 194 | _blockCreationService.RenderProperties(properties, "Model"); 195 | 196 | _blockCreationService.RemoveAllQuickBlocksAttributes(contentTypeDoc); 197 | 198 | templateContent.AppendLine(contentTypeDoc.DocumentNode.OuterHtml); 199 | 200 | template.Content = templateContent.ToString(); 201 | _fileService.SaveTemplate(template); 202 | } 203 | 204 | 205 | } 206 | 207 | return contentType; 208 | } 209 | } -------------------------------------------------------------------------------- /src/QuickBlocks/DataTypeMappersCollection.cs: -------------------------------------------------------------------------------- 1 | using Umbraco.Cms.Core.Composing; 2 | using Umbraco.Cms.Core.DependencyInjection; 3 | using Umbraco.Community.QuickBlocks.Models; 4 | 5 | namespace Umbraco.Community.QuickBlocks; 6 | 7 | 8 | 9 | public class DataTypeMappersCollection : BuilderCollectionBase 10 | { 11 | public DataTypeMappersCollection(Func> items) : base(items) 12 | { 13 | } 14 | } 15 | 16 | public class DataTypeMappersCollectionBuilder : OrderedCollectionBuilderBase 17 | { 18 | protected override DataTypeMappersCollectionBuilder This => this; 19 | } 20 | 21 | public static class WebCompositionExtensions 22 | { 23 | public static DataTypeMappersCollectionBuilder QuickBlockDataTypeMappers(this IUmbracoBuilder builder) 24 | => builder.WithCollectionBuilder(); 25 | 26 | 27 | } 28 | -------------------------------------------------------------------------------- /src/QuickBlocks/Models/BlockConfigModel.cs: -------------------------------------------------------------------------------- 1 | namespace Umbraco.Community.QuickBlocks.Models; 2 | 3 | public class BlockListConfigurationModel 4 | { 5 | public Block[] blocks { get; set; } 6 | public Validationlimit validationLimit { get; set; } 7 | public bool useSingleBlockMode { get; set; } 8 | public bool useLiveEditing { get; set; } 9 | public bool useInlineEditingAsDefault { get; set; } 10 | public string maxPropertyWidth { get; set; } 11 | } 12 | 13 | public class Validationlimit 14 | { 15 | } 16 | 17 | public class Block 18 | { 19 | public string backgroundColor { get; set; } 20 | public string iconColor { get; set; } 21 | public string contentElementTypeKey { get; set; } 22 | public string settingsElementTypeKey { get; set; } 23 | public string view { get; set; } 24 | public string stylesheet { get; set; } 25 | public string label { get; set; } 26 | public string editorSize { get; set; } 27 | public bool forceHideContentEditorInOverlay { get; set; } 28 | } 29 | -------------------------------------------------------------------------------- /src/QuickBlocks/Models/BlockItemModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using HtmlAgilityPack; 3 | using Umbraco.Cms.Core.Strings; 4 | using Umbraco.Extensions; 5 | 6 | namespace Umbraco.Community.QuickBlocks.Models; 7 | 8 | public class BlockItemModel 9 | { 10 | public string Name { get; set; } 11 | public string Alias { get; set; } 12 | public string ConventionName { get; } 13 | public IEnumerable Properties { get; set; } 14 | public string Html { get; set; } 15 | public string IconClass { get; set; } 16 | 17 | public BlockItemModel(IShortStringHelper shortStringHelper, string name, HtmlNode node, 18 | string suffix = " Item", string iconClass = "icon-science") 19 | { 20 | Name = name; 21 | var conventionName = name.TrimEnd(suffix) + suffix; 22 | ConventionName = conventionName; 23 | Alias = conventionName.ToSafeAlias(shortStringHelper, true); 24 | Html = node.OuterHtml; 25 | IconClass = iconClass; 26 | } 27 | } -------------------------------------------------------------------------------- /src/QuickBlocks/Models/BlockListModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Umbraco.Community.QuickBlocks.Models; 4 | 5 | public class BlockListModel 6 | { 7 | public string Name { get; set; } 8 | public IEnumerable Rows { get; set; } 9 | public string MaxPropertyWidth { get; set; } 10 | public bool UseSingleBlockMode { get; set; } 11 | public bool UseLiveEditing { get; set; } 12 | public bool UseInlineEditingAsDefault { get; set; } 13 | public int ValidationLimitMin { get; set; } 14 | public int ValidationLimitMax { get; set; } 15 | public string Html { get; set; } 16 | public string PreviewView { get; set; } 17 | public string PreviewCss { get; set; } 18 | 19 | public BlockListModel(string name, bool useCommunityPreview = false, 20 | string previewCss = "", string previewView = "") 21 | { 22 | Name = name; 23 | 24 | PreviewCss = previewCss; 25 | PreviewView = !string.IsNullOrWhiteSpace(PreviewView) ? previewView : ""; 26 | 27 | if (useCommunityPreview && string.IsNullOrWhiteSpace(PreviewView)) 28 | { 29 | PreviewView = "~/App_Plugins/Umbraco.Community.BlockPreview/views/block-preview.html"; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/QuickBlocks/Models/ContentTypeModel.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | using Umbraco.Cms.Core.Strings; 4 | using Umbraco.Extensions; 5 | 6 | namespace Umbraco.Community.QuickBlocks.Models; 7 | 8 | public class ContentTypeModel 9 | { 10 | public string Name { get; set; } 11 | public string Alias { get; set; } 12 | public string ConventionName { get; } 13 | public IEnumerable Properties { get; set; } 14 | public IEnumerable Lists { get; set; } 15 | public string Html { get; set; } 16 | public string Message { get; set; } 17 | 18 | public ContentTypeModel(IShortStringHelper shortStringHelper, string name, string html) 19 | { 20 | Name = name; 21 | Alias = Name.Replace(" ", "").ToSafeAlias(shortStringHelper, true); 22 | Html = html; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/QuickBlocks/Models/DataTypeMappers/DataTypeMappers.cs: -------------------------------------------------------------------------------- 1 | namespace Umbraco.Community.QuickBlocks.Models.DataTypeMappers; 2 | 3 | 4 | public class ImgDataTypeMapper : IDataTypeMapper 5 | { 6 | public IEnumerable HtmlElements => new[] { "img" }; 7 | public string DataTypeName => "Image Media Picker"; 8 | } 9 | 10 | public class HeadersDataTypeMapper : IDataTypeMapper 11 | { 12 | public IEnumerable HtmlElements => new[] { "h1", "h2", "h3", "h4", "h5", "h6" }; 13 | public string DataTypeName => "Textstring"; 14 | } 15 | 16 | public class ParagraphDataTypeMapper : IDataTypeMapper 17 | { 18 | public IEnumerable HtmlElements => new[] { "p" }; 19 | public string DataTypeName => "Richtext editor"; 20 | } 21 | 22 | public class AnchorDataTypeMapper : IDataTypeMapper 23 | { 24 | public IEnumerable HtmlElements => new[] { "a" }; 25 | public string DataTypeName => "Single Url Picker"; 26 | } 27 | 28 | -------------------------------------------------------------------------------- /src/QuickBlocks/Models/FolderStructure.cs: -------------------------------------------------------------------------------- 1 | namespace Umbraco.Community.QuickBlocks.Models; 2 | 3 | public class FolderStructure 4 | { 5 | public int ComponentsId { get; set; } 6 | public int CompositionsId { get; set; } 7 | public int CompositionsContentBlocksId { get; set; } 8 | public int CompositionsContentModelsId { get; set; } 9 | public int CompositionsSettingsModelsId { get; set; } 10 | public int ElementsId { get; set; } 11 | public int ElementsContentBlocksId { get; set; } 12 | public int ElementsContentModelsId { get; set; } 13 | public int ElementsSettingsModelsId { get; set; } 14 | public int FoldersId { get; set; } 15 | public int PagesId { get; set; } 16 | } 17 | -------------------------------------------------------------------------------- /src/QuickBlocks/Models/IDataTypeMapper.cs: -------------------------------------------------------------------------------- 1 | namespace Umbraco.Community.QuickBlocks.Models; 2 | 3 | public interface IDataTypeMapper 4 | { 5 | IEnumerable HtmlElements { get; } 6 | string DataTypeName { get; } 7 | } -------------------------------------------------------------------------------- /src/QuickBlocks/Models/PartialViewModel.cs: -------------------------------------------------------------------------------- 1 | using HtmlAgilityPack; 2 | 3 | namespace Umbraco.Community.QuickBlocks.Models; 4 | 5 | public class PartialViewModel 6 | { 7 | public string Name { get; set; } 8 | public string Html { get; set; } 9 | 10 | public PartialViewModel(string name, HtmlNode node) 11 | { 12 | Name = name; 13 | Html = node?.OuterHtml; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/QuickBlocks/Models/PropertyModel.cs: -------------------------------------------------------------------------------- 1 | using HtmlAgilityPack; 2 | 3 | namespace Umbraco.Community.QuickBlocks.Models; 4 | 5 | public class PropertyModel 6 | { 7 | public string Name { get; } 8 | public string PropertyType { get; set; } 9 | public string Html { get; set; } 10 | public string Value { get; set; } 11 | 12 | public PropertyModel(string name, string propertyType, HtmlNode node) 13 | { 14 | Name = name; 15 | PropertyType = propertyType; 16 | Html = node?.OuterHtml; 17 | Value = node?.InnerHtml; 18 | } 19 | } -------------------------------------------------------------------------------- /src/QuickBlocks/Models/QuickBlocksInstruction.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Html; 2 | 3 | namespace Umbraco.Community.QuickBlocks.Models; 4 | 5 | public class QuickBlocksInstruction 6 | { 7 | public string Url { get; set; } 8 | public string HtmlBody { get; set; } 9 | public bool ReadOnly { get; set; } 10 | } -------------------------------------------------------------------------------- /src/QuickBlocks/Models/RowModel.cs: -------------------------------------------------------------------------------- 1 | using HtmlAgilityPack; 2 | using System.Collections.Generic; 3 | using System.Reflection.PortableExecutable; 4 | using Umbraco.Cms.Core.Strings; 5 | using Umbraco.Extensions; 6 | 7 | namespace Umbraco.Community.QuickBlocks.Models; 8 | 9 | public class RowModel 10 | { 11 | public string Name { get; set; } 12 | public string Alias { get; set; } 13 | public string SettingsName { get; set; } 14 | public string SettingsAlias { get; set; } 15 | public IEnumerable Properties { get; set; } 16 | public bool IgnoreNamingConvention { get; set; } 17 | public bool HasSettings { get; set; } 18 | public string Html { get; set; } 19 | public string IconClass { get; set; } 20 | public List SubLists { get; set; } 21 | public string LabelProperty { get; set; } 22 | public string PreviewView { get; set; } 23 | public string PreviewCss { get; set; } 24 | 25 | public RowModel(IShortStringHelper shortStringHelper, string name, HtmlNode node, 26 | string settingsName, bool hasSettings = true, bool ignoreNamingConvention = false, 27 | string suffix = "Row", string settingsSuffix = "Settings", 28 | string iconClass = "icon-science", string labelProperty = "Title", 29 | bool useCommunityPreview = false, string previewCss = "", string previewView = "") 30 | { 31 | IgnoreNamingConvention = ignoreNamingConvention; 32 | HasSettings = hasSettings; 33 | 34 | if (ignoreNamingConvention) 35 | { 36 | Name = name; 37 | SettingsName = hasSettings ? settingsName : ""; 38 | } 39 | else 40 | { 41 | Name = name + " " + suffix; 42 | SettingsName = hasSettings ? Name + " " + settingsSuffix : ""; 43 | } 44 | 45 | PreviewCss = previewCss; 46 | PreviewView = !string.IsNullOrWhiteSpace(PreviewView) ? previewView : ""; 47 | 48 | if (useCommunityPreview && string.IsNullOrWhiteSpace(PreviewView)) 49 | { 50 | PreviewView = "~/App_Plugins/Umbraco.Community.BlockPreview/views/block-preview.html"; 51 | } 52 | 53 | Alias = Name.ToCleanString(shortStringHelper, CleanStringType.Alias | CleanStringType.UmbracoCase).ToSafeAlias(shortStringHelper, true); 54 | SettingsAlias = hasSettings ? SettingsName.ToCleanString(shortStringHelper, CleanStringType.Alias | CleanStringType.UmbracoCase).ToSafeAlias(shortStringHelper, true) : ""; 55 | Html = node.OuterHtml; 56 | IconClass = iconClass; 57 | LabelProperty = labelProperty.Replace(" ", "").ToSafeAlias(shortStringHelper, true); 58 | } 59 | } -------------------------------------------------------------------------------- /src/QuickBlocks/NotificationHandlers/ServerVariablesParsingNotificationHandler.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Routing; 2 | using Umbraco.Community.QuickBlocks.Controllers; 3 | using Umbraco.Cms.Core.Events; 4 | using Umbraco.Cms.Core.Notifications; 5 | using Umbraco.Extensions; 6 | 7 | namespace Umbraco.Community.QuickBlocks.NotificationHandlers; 8 | 9 | public class ServerVariablesParsingNotificationHandler : INotificationHandler 10 | { 11 | private readonly LinkGenerator _linkGenerator; 12 | 13 | public ServerVariablesParsingNotificationHandler(LinkGenerator linkGenerator) 14 | { 15 | _linkGenerator = linkGenerator; 16 | } 17 | 18 | public void Handle(ServerVariablesParsingNotification notification) 19 | { 20 | 21 | notification.ServerVariables.Add("QuickBlocks", new 22 | { 23 | QuickBlocksApi = _linkGenerator.GetPathByAction(nameof(QuickBlocksApiController.Build), 24 | ControllerExtensions.GetControllerName()) 25 | }); 26 | } 27 | } -------------------------------------------------------------------------------- /src/QuickBlocks/QuickBlocks.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | net6.0 4 | enable 5 | enable 6 | . 7 | Umbraco.Community.QuickBlocks 8 | Umbraco.Community.QuickBlocks 9 | QuickBlocks 10 | A package for quickly building block list based Umbraco websites all from data attributes in your HTMl 11 | umbraco;umbraco-marketplace;quickblocks;fast;builder 12 | Umbraco.Community.QuickBlocks 13 | True 14 | 1.0.0 15 | Paul Seal 16 | 2023 © Paul Seal 17 | https://github.com/prjseal/QuickBlocks 18 | https://github.com/prjseal/QuickBlocks 19 | https://github.com/prjseal/QuickBlocks/blob/main/images/logo.png?raw=true 20 | README_nuget.md 21 | git 22 | MIT 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | True 40 | \ 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /src/QuickBlocks/QuickBlocksComposer.cs: -------------------------------------------------------------------------------- 1 | using Umbraco.Cms.Core.Composing; 2 | using Umbraco.Cms.Core.DependencyInjection; 3 | using Umbraco.Community.QuickBlocks.Models.DataTypeMappers; 4 | 5 | namespace Umbraco.Community.QuickBlocks; 6 | 7 | public class QuickBlocksComposer : IComposer 8 | { 9 | public void Compose(IUmbracoBuilder builder) 10 | { 11 | builder.ManifestFilters().Append(); 12 | 13 | builder.QuickBlockDataTypeMappers() 14 | .Append() 15 | .Append() 16 | .Append() 17 | .Append(); 18 | } 19 | } 20 | 21 | -------------------------------------------------------------------------------- /src/QuickBlocks/QuickBlocksDefaultOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Umbraco.Community.QuickBlocks; 2 | public class QuickBlocksDefaultOptions 3 | { 4 | public string DefaultDataTypeName { get; set; } = "Textstring"; 5 | } 6 | -------------------------------------------------------------------------------- /src/QuickBlocks/QuickBlocksManifestFilter.cs: -------------------------------------------------------------------------------- 1 | using Umbraco.Cms.Core.Manifest; 2 | 3 | namespace Umbraco.Community.QuickBlocks; 4 | 5 | internal class QuickBlocksManifestFilter : IManifestFilter 6 | { 7 | public void Filter(List manifests) 8 | { 9 | var assembly = typeof(QuickBlocksManifestFilter).Assembly; 10 | 11 | manifests.Add(new PackageManifest 12 | { 13 | PackageName = "QuickBlocks", 14 | Version = assembly.GetName()?.Version?.ToString(3) ?? "1.0.0", 15 | AllowPackageTelemetry = true 16 | }); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/QuickBlocks/Services/BlockCreationService.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Umbraco.Community.QuickBlocks.Models; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using File = System.IO.File; 7 | using System.Linq; 8 | using Umbraco.Cms.Core.Mapping; 9 | using Umbraco.Cms.Core.Models; 10 | using Umbraco.Cms.Core.PropertyEditors; 11 | using Umbraco.Cms.Core.Serialization; 12 | using Umbraco.Cms.Core.Services; 13 | using Umbraco.Cms.Core.Strings; 14 | using Umbraco.Cms.Core.Services.Implement; 15 | using Umbraco.Extensions; 16 | using Microsoft.Extensions.Logging; 17 | using HtmlAgilityPack; 18 | using System.Text; 19 | 20 | namespace Umbraco.Community.QuickBlocks.Services; 21 | 22 | public class BlockCreationService : IBlockCreationService 23 | { 24 | private const string DefaultIconColour = "#ffffff"; 25 | private const string DefaultBackgroundColour = "#1b264f"; 26 | private const string DefaultEditorSize = "medium"; 27 | private readonly IShortStringHelper _shortStringHelper; 28 | private readonly IWebHostEnvironment _webHostEnvironment; 29 | private readonly IDataTypeService _dataTypeService; 30 | private readonly IConfigurationEditorJsonSerializer _configurationEditorJsonSerializer; 31 | private readonly PropertyEditorCollection _propertyEditorCollection; 32 | private readonly IContentTypeService _contentTypeService; 33 | private readonly ILogger _logger; 34 | private readonly IFileService _fileService; 35 | 36 | public BlockCreationService(IShortStringHelper shortStringHelper, IWebHostEnvironment webHostEnvironment, 37 | IDataTypeService dataTypeService, IConfigurationEditorJsonSerializer configurationEditorJsonSerializer, 38 | PropertyEditorCollection propertyEditorCollection, IContentTypeService contentTypeService, 39 | ILogger logger, IFileService fileService) 40 | { 41 | _shortStringHelper = shortStringHelper; 42 | _webHostEnvironment = webHostEnvironment; 43 | _dataTypeService = dataTypeService; 44 | _configurationEditorJsonSerializer = configurationEditorJsonSerializer; 45 | _propertyEditorCollection = propertyEditorCollection; 46 | _contentTypeService = contentTypeService; 47 | _logger = logger; 48 | _fileService = fileService; 49 | } 50 | 51 | public bool CreateRowPartial(RowModel row) 52 | { 53 | string contentRootPath = _webHostEnvironment.ContentRootPath; 54 | 55 | var blocklistComponentsFolderPath = 56 | Path.Combine(contentRootPath, "Views\\", "Partials\\", "blocklist\\", "Components\\"); 57 | 58 | var filePath = Path.Combine(blocklistComponentsFolderPath, row.Alias + ".cshtml"); 59 | if (File.Exists(filePath)) return false; 60 | 61 | if (!Directory.Exists(blocklistComponentsFolderPath)) 62 | { 63 | Directory.CreateDirectory(blocklistComponentsFolderPath); 64 | } 65 | 66 | using (StreamWriter outputFile = new StreamWriter(filePath)) 67 | { 68 | outputFile.WriteLine( 69 | "@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage"); 70 | outputFile.WriteLine(""); 71 | outputFile.WriteLine("@{"); 72 | outputFile.WriteLine($" var row = ({row.Name.ToCleanString(_shortStringHelper, CleanStringType.ConvertCase | CleanStringType.PascalCase)})Model.Content;"); 73 | outputFile.WriteLine($" var settings = ({row.SettingsName.ToCleanString(_shortStringHelper, CleanStringType.ConvertCase | CleanStringType.PascalCase)})Model.Settings;"); 74 | outputFile.WriteLine(""); 75 | outputFile.WriteLine(" if (settings.Hide) { return; }"); 76 | outputFile.WriteLine("}"); 77 | outputFile.WriteLine(""); 78 | 79 | var lines = row.Html.Split("\n"); 80 | var lastLine = lines.LastOrDefault(); 81 | int spaces = lastLine.TakeWhile(Char.IsWhiteSpace).Count(); 82 | 83 | var spacesToAdd = lastLine.Substring(0, spaces >= 0 ? spaces : 0); 84 | 85 | var doc = new HtmlDocument(); 86 | 87 | doc.LoadHtml(row.Html); 88 | 89 | var listProperties = doc.DocumentNode.SelectNodes("//*[@data-list-name]"); 90 | 91 | RenderListPropertyCalls(listProperties, "row"); 92 | 93 | var subListProperties = doc.DocumentNode.SelectNodes("//*[@data-sub-list-name]"); 94 | 95 | RenderListPropertyCalls(subListProperties, "row"); 96 | 97 | var properties = doc.DocumentNode.SelectNodes("//*[@data-prop-name]"); 98 | 99 | RenderProperties(properties, "row"); 100 | 101 | RemoveAllQuickBlocksAttributes(doc); 102 | 103 | outputFile.WriteLine(spacesToAdd + doc.DocumentNode.OuterHtml); 104 | } 105 | 106 | return true; 107 | } 108 | 109 | public void RenderProperties(HtmlNodeCollection properties, string context) 110 | { 111 | if (properties == null) return; 112 | 113 | foreach (var item in properties) 114 | { 115 | var name = item.Attributes["data-prop-name"].Value; 116 | var propValue = item.Attributes["data-prop-value"]?.Value ?? ""; 117 | var propType = item.Attributes["data-prop-type"]?.Value ?? ""; 118 | var listName = item.Attributes["data-list-name"]?.Value ?? ""; 119 | var subListName = item.Attributes["data-sub-list-name"]?.Value ?? ""; 120 | var replaceMarker = item.Attributes["data-replace-marker"]?.Value ?? ""; 121 | var replaceInner = item.Attributes["data-replace-inner"]?.Value ?? ""; 122 | var multiple = item.Attributes["data-multiple"]?.Value ?? "false"; 123 | var isMultiple = multiple == "true"; 124 | var objectReference = context + "." + name.ToCleanString(_shortStringHelper, CleanStringType.ConvertCase | CleanStringType.PascalCase); 125 | var originalObjectReference = objectReference; 126 | 127 | if (!string.IsNullOrWhiteSpace(listName) || !string.IsNullOrWhiteSpace(subListName)) 128 | { 129 | continue; 130 | } 131 | 132 | var text = HtmlTextNode.CreateNode("@" + objectReference); 133 | switch (item.OriginalName) 134 | { 135 | case "h1": 136 | case "h2": 137 | case "h3": 138 | case "h4": 139 | case "h5": 140 | case "h6": 141 | case "span": 142 | if (!string.IsNullOrWhiteSpace(replaceMarker)) 143 | { 144 | ReplaceAttributesAndInnerHtmlWithValue(item, propValue, replaceMarker, objectReference, replaceInner); 145 | } 146 | else 147 | { 148 | item.InnerHtml = "@" + objectReference; 149 | } 150 | break; 151 | case "img": 152 | if (item.Attributes.Contains("src")) 153 | { 154 | item.Attributes["src"].Value = "@" + objectReference + ".Url()"; 155 | } 156 | else 157 | { 158 | item.Attributes.Add("src", "@" + objectReference + ".Url()"); 159 | } 160 | 161 | if (!string.IsNullOrWhiteSpace(replaceMarker)) 162 | { 163 | ReplaceAttributesAndInnerHtmlWithValue(item, string.IsNullOrWhiteSpace(propValue) ? ".Url()" : propValue, replaceMarker, objectReference, replaceInner); 164 | } 165 | 166 | WrapNullCheck(objectReference, item); 167 | 168 | break; 169 | case "p": 170 | item.ParentNode.ReplaceChild(text, item); 171 | break; 172 | case "a": 173 | if (isMultiple) 174 | { 175 | objectReference = "item"; 176 | } 177 | 178 | if (item.Attributes.Contains("href")) 179 | { 180 | item.Attributes["href"].Value = "@" + objectReference + ".Url"; 181 | } 182 | else 183 | { 184 | item.Attributes.Add("href", "@" + objectReference + ".Url"); 185 | } 186 | 187 | if (item.Attributes.Contains("target")) 188 | { 189 | item.Attributes["target"].Value = "@" + objectReference + ".Target"; 190 | } 191 | else 192 | { 193 | item.Attributes.Add("target", "@" + objectReference + ".Target"); 194 | } 195 | 196 | if (multiple == "true") 197 | { 198 | var openingHtmlString = new StringBuilder(); 199 | openingHtmlString.AppendLine("@if(" + originalObjectReference + " != null && " + originalObjectReference + ".Any())"); 200 | openingHtmlString.AppendLine("{"); 201 | openingHtmlString.AppendLine(" foreach(var item in " + originalObjectReference + ")"); 202 | openingHtmlString.AppendLine(" {"); 203 | var openingHtmlNode = HtmlTextNode.CreateNode(openingHtmlString.ToString()); 204 | item.ParentNode.InsertBefore(openingHtmlNode, item); 205 | 206 | WrapNullCheck(originalObjectReference, item); 207 | 208 | var closingHtmlString = new StringBuilder(); 209 | closingHtmlString.AppendLine(" }"); 210 | closingHtmlString.AppendLine("}"); 211 | var closingHtmlNode = HtmlTextNode.CreateNode(closingHtmlString.ToString()); 212 | item.ParentNode.InsertAfter(closingHtmlNode, item); 213 | } 214 | else 215 | { 216 | WrapNullCheck(originalObjectReference, item); 217 | } 218 | 219 | if (!string.IsNullOrWhiteSpace(replaceMarker)) 220 | { 221 | ReplaceAttributesAndInnerHtmlWithValue(item, string.IsNullOrWhiteSpace(propValue) ? ".Url()" : propValue, replaceMarker, objectReference, replaceInner); 222 | } 223 | else if(replaceInner.ToLower() != "false") 224 | { 225 | item.InnerHtml = "@" + objectReference + ".Name"; 226 | } 227 | break; 228 | default: 229 | var newPropValue = propValue; 230 | if (!string.IsNullOrWhiteSpace(replaceMarker)) 231 | { 232 | if(string.IsNullOrWhiteSpace(propValue)) 233 | { 234 | if (propType.Equals("Image Media Picker", StringComparison.CurrentCultureIgnoreCase)) 235 | { 236 | newPropValue = ".Url()"; 237 | } 238 | else if (propType.Equals("Single Url Picker", StringComparison.CurrentCultureIgnoreCase)) 239 | { 240 | newPropValue = ".Name"; 241 | } 242 | } 243 | } 244 | ReplaceAttributesAndInnerHtmlWithValue(item, newPropValue, replaceMarker, objectReference, replaceInner); 245 | break; 246 | } 247 | 248 | //if (!string.IsNullOrWhiteSpace(replaceMarker)) 249 | //{ 250 | // var attributeValue = item.Attributes[replaceAttribute]?.Value ?? ""; 251 | // if (!string.IsNullOrWhiteSpace(attributeValue)) 252 | // { 253 | // var newAttributeValue = attributeValue.Replace(replaceMarker, "@" + objectReference + (!string.IsNullOrWhiteSpace(propValue) ? propValue : "")); 254 | // item.Attributes[replaceAttribute].Value = newAttributeValue; 255 | // } 256 | // if (replaceInner == "false") 257 | // { 258 | // continue; 259 | // } 260 | //} 261 | } 262 | } 263 | 264 | private static void WrapNullCheck(string originalObjectReference, HtmlNode item) 265 | { 266 | var openingHtmlString = new StringBuilder(); 267 | openingHtmlString.AppendLine("@if(" + originalObjectReference + " != null)"); 268 | openingHtmlString.AppendLine("{"); 269 | HtmlNode openingHtmlNode; 270 | openingHtmlNode = HtmlTextNode.CreateNode(openingHtmlString.ToString()); 271 | item.ParentNode.InsertBefore(openingHtmlNode, item); 272 | 273 | var closingHtmlString = new StringBuilder(); 274 | closingHtmlString.AppendLine("}"); 275 | HtmlNode closingHtmlNode; 276 | closingHtmlNode = HtmlTextNode.CreateNode(closingHtmlString.ToString()); 277 | item.ParentNode.InsertAfter(closingHtmlNode, item); 278 | } 279 | 280 | 281 | public void ReplaceAttributesAndInnerHtmlWithValue(HtmlNode item, string propValue, string replaceMarker, string objectReference, string replaceInner) 282 | { 283 | var replaceInnerVal = replaceInner.Equals("true", StringComparison.CurrentCultureIgnoreCase); 284 | if (!string.IsNullOrWhiteSpace(replaceMarker)) 285 | { 286 | var attributes = item.Attributes.Where(x => !x.OriginalName.StartsWith("data-")); 287 | foreach (var attr in attributes) 288 | { 289 | var currentValue = attr.Value; 290 | var newValue = currentValue.Replace(replaceMarker, "@" + objectReference + (!string.IsNullOrWhiteSpace(propValue) ? propValue : "")); 291 | attr.Value = newValue; 292 | } 293 | 294 | if(replaceInnerVal) 295 | { 296 | var existingInnerHtml = item.InnerHtml; 297 | existingInnerHtml = existingInnerHtml.Replace(replaceMarker, "@" + objectReference + (!string.IsNullOrWhiteSpace(propValue) ? propValue : "")); 298 | item.InnerHtml = existingInnerHtml; 299 | } 300 | } 301 | else if(replaceInnerVal) 302 | { 303 | item.InnerHtml = "@" + objectReference + (!string.IsNullOrWhiteSpace(propValue) ? propValue : ""); 304 | } 305 | } 306 | 307 | public void RenderListPropertyCalls(HtmlNodeCollection listProperties, string context) 308 | { 309 | if (listProperties != null) 310 | { 311 | foreach (var listProperty in listProperties) 312 | { 313 | var name = listProperty.Attributes["data-prop-name"].Value.ToCleanString(_shortStringHelper, CleanStringType.ConvertCase | CleanStringType.PascalCase); 314 | 315 | if (!string.IsNullOrWhiteSpace(name)) 316 | { 317 | listProperty.InnerHtml = Environment.NewLine + "@Html.GetBlockListHtml(" + context + "." + name + ")" + Environment.NewLine; 318 | } 319 | } 320 | } 321 | } 322 | 323 | public void RemoveAllQuickBlocksAttributes(HtmlDocument doc) 324 | { 325 | foreach (var node in doc.DocumentNode.DescendantNodesAndSelf()) 326 | { 327 | node.Attributes.RemoveAll(x => 328 | x.Name.StartsWith("data-prop") 329 | || x.Name.StartsWith("data-row") 330 | || x.Name.StartsWith("data-icon") 331 | || x.Name.StartsWith("data-sub-list") 332 | || x.Name.StartsWith("data-list") 333 | || x.Name.StartsWith("data-content-type") 334 | || x.Name.StartsWith("data-item") 335 | || x.Name.StartsWith("data-partial") 336 | || x.Name.StartsWith("data-replace")); 337 | } 338 | } 339 | 340 | public void ReplaceAllPartialAttributesWithCalls(HtmlDocument doc) 341 | { 342 | var partials = doc.DocumentNode.SelectNodes("//*[@data-partial-name]"); 343 | 344 | if (partials != null && partials.Any()) 345 | { 346 | foreach (var partial in partials) 347 | { 348 | var itemName = partial.GetAttributeValue("data-partial-name", ""); 349 | if (!string.IsNullOrWhiteSpace("itemName")) 350 | { 351 | var text = HtmlTextNode.CreateNode("@await Html.PartialAsync(\"~/Views/Partials/" + itemName + ".cshtml\")"); 352 | partial.ParentNode.ReplaceChild(text, partial); 353 | } 354 | } 355 | } 356 | } 357 | 358 | public void CreateList(BlockListModel list, FolderStructure folderStructure, int parentDataTypeId) 359 | { 360 | var existingDataType = _dataTypeService.GetDataType(list.Name); 361 | 362 | if (existingDataType != null) return; 363 | 364 | if (list?.Rows == null || !list.Rows.Any()) return; 365 | 366 | foreach (var row in list.Rows) 367 | { 368 | CreateRowPartial(row); 369 | } 370 | 371 | if (list.Rows == null || !list.Rows.Any()) return; 372 | 373 | List blocks = CreateBlockConfigurations(list, folderStructure); 374 | 375 | if (blocks == null || !blocks.Any()) return; 376 | 377 | CreateBlockListDataType(list, blocks, parentDataTypeId); 378 | } 379 | 380 | public List CreateBlockConfigurations(BlockListModel list, FolderStructure folderStructure) 381 | { 382 | var blocks = new List(); 383 | 384 | foreach (var row in list.Rows) 385 | { 386 | var block = CreateBlockConfiguration(row, folderStructure, list); 387 | 388 | if (block == null) continue; 389 | 390 | blocks.Add(block); 391 | } 392 | 393 | return blocks; 394 | } 395 | 396 | public FolderStructure CreateFolderStructure() 397 | { 398 | var componentsId = GetOrCreateFolder("Components", -1); 399 | var compositionsId = GetOrCreateFolder("Compositions", -1); 400 | var compositionsContentBlocksId = GetOrCreateFolder("Content Blocks", compositionsId, 2); 401 | var compositionsContentModelsId = GetOrCreateFolder("Content Models", compositionsContentBlocksId, 3); 402 | var compositionsSettingsModelsId = GetOrCreateFolder("Settings Models", compositionsContentBlocksId, 3); 403 | var elementsId = GetOrCreateFolder("Elements", -1); 404 | var elementsContentBlocksId = GetOrCreateFolder("Content Blocks", elementsId, 2); 405 | var elementsContentModelsId = GetOrCreateFolder("Content Models", elementsContentBlocksId, 3); 406 | var elementsSettingsModelsId = GetOrCreateFolder("Settings Models", elementsContentBlocksId, 3); 407 | var foldersId = GetOrCreateFolder("Folders", -1); 408 | var pagesId = GetOrCreateFolder("Pages", -1); 409 | 410 | var folderStructure = new FolderStructure(); 411 | folderStructure.ComponentsId = componentsId; 412 | folderStructure.CompositionsId = compositionsId; 413 | folderStructure.CompositionsContentBlocksId = compositionsContentBlocksId; 414 | folderStructure.CompositionsContentModelsId = compositionsContentModelsId; 415 | folderStructure.CompositionsSettingsModelsId = compositionsSettingsModelsId; 416 | folderStructure.ElementsId = elementsId; 417 | folderStructure.ElementsContentBlocksId = elementsContentBlocksId; 418 | folderStructure.ElementsContentModelsId = elementsContentModelsId; 419 | folderStructure.ElementsSettingsModelsId = elementsSettingsModelsId; 420 | folderStructure.FoldersId = foldersId; 421 | folderStructure.PagesId = pagesId; 422 | 423 | return folderStructure; 424 | } 425 | 426 | private int GetOrCreateFolder(string folderName, int parentId, int level = 1) 427 | { 428 | var containers = _contentTypeService.GetAll().Where(x => x.IsContainer); 429 | 430 | IContentType matchingFolder = null; 431 | 432 | if (containers != null && containers.Any()) 433 | { 434 | matchingFolder = containers.FirstOrDefault(x => x.Name == folderName && x.ParentId == parentId); 435 | } 436 | 437 | if (matchingFolder == null) 438 | { 439 | var tryCreateContainer = _contentTypeService.CreateContainer(parentId, Guid.NewGuid(), folderName); 440 | if (tryCreateContainer.Success) 441 | { 442 | return tryCreateContainer.Result!.Entity!.Id; 443 | } 444 | return -1; 445 | } 446 | return matchingFolder.Id; 447 | } 448 | 449 | public BlockListConfiguration.BlockConfiguration CreateBlockConfiguration(RowModel row, FolderStructure folderStructure, BlockListModel list) 450 | { 451 | var contentDocType = _contentTypeService.Get(row.Alias); 452 | if (contentDocType == null) 453 | { 454 | contentDocType = CreateContentType(row.Name, row.Alias, folderStructure.ElementsContentModelsId, true, false, row.IconClass); 455 | 456 | if (contentDocType != null && row.Properties != null && row.Properties.Any()) 457 | { 458 | AddPropertiesToContentType(contentDocType, row.Properties, "Content"); 459 | } 460 | } 461 | 462 | var settingsDocType = row.HasSettings ? _contentTypeService.Get(row.SettingsAlias) : null; 463 | if (settingsDocType == null && row.HasSettings) 464 | { 465 | settingsDocType = CreateContentType(row.SettingsName, row.SettingsAlias, folderStructure.ElementsSettingsModelsId, true, false, "icon-settings color-indigo"); 466 | if (settingsDocType != null) 467 | { 468 | AddCompositionsToContentType(settingsDocType, new List() { "blockVisibilitySettings" }); 469 | } 470 | } 471 | 472 | if (contentDocType == null) return null; 473 | 474 | var stylesheet = !string.IsNullOrWhiteSpace(row.PreviewCss) ? row.PreviewCss : 475 | !string.IsNullOrWhiteSpace(list.PreviewCss) ? list.PreviewCss : null; 476 | 477 | var view = !string.IsNullOrWhiteSpace(row.PreviewView) ? row.PreviewView : 478 | !string.IsNullOrWhiteSpace(list.PreviewView) ? list.PreviewView : null; 479 | 480 | return new BlockListConfiguration.BlockConfiguration 481 | { 482 | ContentElementTypeKey = contentDocType.Key, 483 | SettingsElementTypeKey = settingsDocType?.Key ?? null, 484 | Label = "{{ !" + row.LabelProperty + " || " + row.LabelProperty + " == '' ? '" + row.Name + "' : " + row.LabelProperty + " }}", 485 | EditorSize = DefaultEditorSize, 486 | ForceHideContentEditorInOverlay = false, 487 | Stylesheet = stylesheet, 488 | View = view, 489 | IconColor = DefaultIconColour, 490 | BackgroundColor = DefaultBackgroundColour 491 | }; 492 | } 493 | 494 | public void CreateSupportingContentTypes(int parentId) 495 | { 496 | CreateHideSettings(parentId); 497 | } 498 | 499 | public int CreateSupportingDataTypes() 500 | { 501 | try 502 | { 503 | var parentId = GetOrCreateQuickBlocksDataTypeContainer(); 504 | CreateUrlPickerDataType(parentId, "Single Url Picker", 0, 1); 505 | return parentId; 506 | } 507 | catch (Exception ex) 508 | { 509 | _logger.LogError(ex, "Error when trying to create supporting Data Types"); 510 | return -1; 511 | } 512 | } 513 | 514 | public int GetOrCreateQuickBlocksDataTypeContainer() 515 | { 516 | var existingDataTypes = _dataTypeService.GetContainers("QuickBlocks", 1); 517 | 518 | if (existingDataTypes != null && existingDataTypes.Any()) return existingDataTypes.FirstOrDefault().Id; 519 | 520 | var tryCreateContainer = _dataTypeService.CreateContainer(-1, Guid.NewGuid(), "QuickBlocks"); 521 | if (tryCreateContainer.Success) 522 | { 523 | return tryCreateContainer.Result!.Entity!.Id; 524 | } 525 | 526 | return -1; 527 | } 528 | 529 | public void CreateUrlPickerDataType(int parentId, string name, int minNumber, int maxNumber) 530 | { 531 | var existingDataTypes = _dataTypeService.GetDataType(name); 532 | 533 | if (existingDataTypes != null) return; 534 | 535 | var editor = _propertyEditorCollection.First(x => x.Alias == "Umbraco.MultiUrlPicker"); 536 | 537 | var newDataType = new DataType(editor, _configurationEditorJsonSerializer) 538 | { 539 | Name = name, 540 | Configuration = new MultiUrlPickerConfiguration 541 | { 542 | MinNumber = minNumber, 543 | MaxNumber = maxNumber, 544 | }, 545 | ParentId = parentId 546 | }; 547 | 548 | _dataTypeService.Save(newDataType); 549 | } 550 | 551 | public void CreateBlockListDataType(BlockListModel list, List blocks, int parentDataTypeId) 552 | { 553 | var editor = _propertyEditorCollection.First(x => x.Alias == "Umbraco.BlockList"); 554 | 555 | var blockConfiguration = new BlockListConfiguration 556 | { 557 | Blocks = blocks.ToArray(), 558 | MaxPropertyWidth = list.MaxPropertyWidth, 559 | UseSingleBlockMode = list.UseSingleBlockMode, 560 | UseLiveEditing = list.UseLiveEditing, 561 | UseInlineEditingAsDefault = list.UseInlineEditingAsDefault, 562 | }; 563 | 564 | if (list.ValidationLimitMin != 0 && list.ValidationLimitMax != 0) 565 | { 566 | blockConfiguration.ValidationLimit = new BlockListConfiguration.NumberRange() 567 | { 568 | Min = list.ValidationLimitMin, 569 | Max = list.ValidationLimitMax 570 | }; 571 | } 572 | 573 | var newDataType = new DataType(editor, _configurationEditorJsonSerializer) 574 | { 575 | Name = list.Name, 576 | Configuration = blockConfiguration, 577 | ParentId = parentDataTypeId 578 | }; 579 | 580 | _dataTypeService.Save(newDataType); 581 | } 582 | 583 | public IContentType CreateHideSettings(int parentId) 584 | { 585 | var name = "Block Visibility Settings"; 586 | 587 | var contentType = CreateContentType(name, name.ToSafeAlias(_shortStringHelper, true), parentId, true, false, "icon-defrag color-pink"); 588 | 589 | var properties = new List() 590 | { 591 | new PropertyModel("Hide", "True/false", null) 592 | }; 593 | 594 | if (contentType != null) 595 | { 596 | AddPropertiesToContentType(contentType, properties, "Settings"); 597 | } 598 | 599 | return contentType; 600 | } 601 | 602 | public IContentType CreateContentType(string name, string alias, int parentId = -1, 603 | bool isElement = true, bool isContainer = false, string iconClass = "icon-science", 604 | bool allowedAsRoot = false, bool updateDoctype = false) 605 | { 606 | var existingDocType = _contentTypeService.Get(alias); 607 | if (existingDocType != null) return existingDocType; 608 | 609 | IContentType contentDocType; 610 | var contentType = new ContentType(_shortStringHelper, parentId); 611 | contentType.Name = name; 612 | contentType.Alias = alias; 613 | contentType.IsElement = isElement; 614 | contentType.IsContainer = isContainer; 615 | contentType.Icon = iconClass; 616 | contentType.AllowedAsRoot = allowedAsRoot; 617 | _contentTypeService.Save(contentType); 618 | contentDocType = _contentTypeService.Get(alias); 619 | return contentDocType; 620 | } 621 | 622 | public void AddCompositionsToContentType(string contentTypeAlias, List compositionAliases) 623 | { 624 | IContentType? contentType = _contentTypeService.Get(contentTypeAlias); 625 | 626 | if (contentType != null) 627 | { 628 | _logger.LogError("Content Type is null"); 629 | return; 630 | } 631 | 632 | AddCompositionsToContentType(contentType, compositionAliases); 633 | } 634 | 635 | public void AddCompositionsToContentType(IContentType contentType, List compositionAliases) 636 | { 637 | List compositions = contentType.ContentTypeComposition.ToList(); 638 | 639 | foreach (var compositionAlias in compositionAliases) 640 | { 641 | IContentType? composition = _contentTypeService.Get(compositionAlias); 642 | 643 | 644 | if (composition == null) 645 | { 646 | _logger.LogError("Composition is null"); 647 | continue; 648 | } 649 | 650 | compositions.Add(composition); 651 | } 652 | 653 | contentType.ContentTypeComposition = compositions; 654 | 655 | _contentTypeService.Save(contentType); 656 | } 657 | 658 | public void AddPropertiesToContentType(IContentType contentType, IEnumerable properties, string groupName) 659 | { 660 | if (contentType == null || properties == null) return; 661 | 662 | var success = contentType.AddPropertyGroup(groupName.ToSafeAlias(_shortStringHelper, true), groupName); 663 | if (success) 664 | { 665 | var contentGroup = contentType.PropertyGroups.FirstOrDefault(x => x.Name == groupName); 666 | foreach (var propertyModel in properties) 667 | { 668 | var dataType = _dataTypeService.GetDataType(propertyModel.PropertyType); 669 | 670 | var alias = propertyModel.Name.ToSafeAlias(_shortStringHelper, true); 671 | 672 | var propertyType = new PropertyType(_shortStringHelper, dataType, alias) 673 | { 674 | Name = propertyModel.Name, 675 | Alias = alias 676 | }; 677 | contentGroup.PropertyTypes!.Add(propertyType); 678 | } 679 | _contentTypeService.Save(contentType); 680 | } 681 | } 682 | 683 | public void CreatePartialViews(List partialViews) 684 | { 685 | if (partialViews == null) return; 686 | 687 | foreach (var partialView in partialViews) 688 | { 689 | var fileName = $"{partialView.Name}.cshtml"; 690 | var tryCreatePartialView = _fileService.CreatePartialView(new PartialView(PartialViewType.PartialView, "/Views/Partials/" + fileName)); 691 | if (tryCreatePartialView.Success) 692 | { 693 | var file = tryCreatePartialView.Result; 694 | if (file != null) 695 | { 696 | var partialDoc = new HtmlDocument(); 697 | 698 | partialDoc.LoadHtml(partialView.Html); 699 | 700 | RemoveAllQuickBlocksAttributes(partialDoc); 701 | 702 | var content = "@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage" + Environment.NewLine + Environment.NewLine; 703 | content += partialDoc.DocumentNode.OuterHtml; 704 | 705 | 706 | content = 707 | file.Content = content; 708 | } 709 | _fileService.SavePartialView(file); 710 | } 711 | } 712 | } 713 | } 714 | -------------------------------------------------------------------------------- /src/QuickBlocks/Services/BlockParsingService.cs: -------------------------------------------------------------------------------- 1 | using HtmlAgilityPack; 2 | 3 | using Umbraco.Cms.Core.Strings; 4 | using Umbraco.Community.QuickBlocks.Models; 5 | using Umbraco.Community.QuickBlocks.Services.Resolvers; 6 | 7 | namespace Umbraco.Community.QuickBlocks.Services; 8 | 9 | public class BlockParsingService : IBlockParsingService 10 | { 11 | private readonly IShortStringHelper _shortStringHelper; 12 | private readonly IDataTypeNameResolver _dataTypeNameResolver; 13 | 14 | public BlockParsingService(IShortStringHelper shortStringHelper, IDataTypeNameResolver dataTypeNameResolver) 15 | { 16 | _shortStringHelper = shortStringHelper; 17 | _dataTypeNameResolver = dataTypeNameResolver; 18 | } 19 | 20 | public List GetLists(string html, bool isNestedList, string prefix = "[BlockList]") 21 | { 22 | var doc = new HtmlDocument(); 23 | 24 | doc.LoadHtml(html); 25 | 26 | var xpath = isNestedList ? "//*[@data-sub-list-name]" : "//*[@data-list-name]"; 27 | var name = isNestedList ? "data-sub-list-name" : "data-list-name"; 28 | 29 | var lists = new List(); 30 | 31 | var listNodes = doc.DocumentNode.SelectNodes(xpath); 32 | 33 | if (listNodes == null || !listNodes.Any()) return lists; 34 | 35 | foreach (var listNode in listNodes) 36 | { 37 | var listName = listNode.GetAttributeValue(name, ""); 38 | var maxPropertyWidth = listNode.GetAttributeValue("data-list-maxwidth", ""); 39 | var useSingleBlockMode = listNode.GetAttributeValue("data-list-single", "false"); 40 | var useLiveEditing = listNode.GetAttributeValue("data-list-live", "false"); 41 | var useInlineEditingAsDefault = listNode.GetAttributeValue("data-list-inline", "false"); 42 | var validationLimitMin = listNode.GetAttributeValue("data-list-min", "0"); 43 | var validationLimitMax = listNode.GetAttributeValue("data-list-max", "0"); 44 | var useCommunityPreview = listNode.GetAttributeValue("data-use-community-preview", "false"); 45 | var previewCss = listNode.GetAttributeValue("data-preview-css", ""); 46 | var previewView = listNode.GetAttributeValue("data-preview-view", ""); 47 | 48 | var list = new BlockListModel(prefix + " " + listName, useCommunityPreview.ToLower() == "true", 49 | previewCss: previewCss, previewView: previewView); 50 | if (!string.IsNullOrWhiteSpace(maxPropertyWidth)) 51 | { 52 | list.MaxPropertyWidth = maxPropertyWidth; 53 | } 54 | 55 | if (bool.TryParse(useLiveEditing, out var live)) 56 | { 57 | list.UseLiveEditing = live; 58 | } 59 | 60 | if (bool.TryParse(useInlineEditingAsDefault, out var inline)) 61 | { 62 | list.UseInlineEditingAsDefault = inline; 63 | } 64 | 65 | if (bool.TryParse(useSingleBlockMode, out var single)) 66 | { 67 | list.UseSingleBlockMode = single; 68 | } 69 | 70 | if (single) 71 | { 72 | list.ValidationLimitMin = 1; 73 | list.ValidationLimitMax = 1; 74 | } 75 | else 76 | { 77 | if (!int.TryParse(validationLimitMin, out var min)) 78 | { 79 | min = 0; 80 | } 81 | 82 | if (!int.TryParse(validationLimitMax, out var max)) 83 | { 84 | max = 0; 85 | } 86 | 87 | list.ValidationLimitMin = min; 88 | list.ValidationLimitMax = max; 89 | } 90 | 91 | list.Html = listNode.OuterHtml; 92 | 93 | lists.Add(list); 94 | } 95 | 96 | return lists; 97 | } 98 | 99 | public List GetRows(string html, bool isNestedList) 100 | { 101 | var doc = new HtmlDocument(); 102 | 103 | doc.LoadHtml(html); 104 | 105 | var xpath = isNestedList ? "//*[@data-item-name]" : "//*[@data-row-name]"; 106 | var name = isNestedList ? "data-item-name" : "data-row-name"; 107 | 108 | var rows = new List(); 109 | 110 | var rowNodes = doc.DocumentNode.SelectNodes(xpath); 111 | 112 | if (rowNodes == null || !rowNodes.Any()) return rows; 113 | 114 | foreach (var rowNode in rowNodes) 115 | { 116 | var rowName = rowNode.GetAttributeValue(name, ""); 117 | var settingsName = rowNode.GetAttributeValue("data-settings-name", ""); 118 | var hasSettingsValue = rowNode.GetAttributeValue("data-has-settings", "true"); 119 | var iconClass = rowNode.GetAttributeValue("data-icon-class", "icon-science"); 120 | var iconColour = rowNode.GetAttributeValue("data-icon-colour", "color-indigo"); 121 | var labelProperty = rowNode.GetAttributeValue("data-label-property", "title"); 122 | var useCommunityPreview = rowNode.GetAttributeValue("data-use-community-preview", "false"); 123 | var previewCss = rowNode.GetAttributeValue("data-preview-css", ""); 124 | var previewView = rowNode.GetAttributeValue("data-preview-view", ""); 125 | 126 | bool.TryParse(hasSettingsValue, out var hasSettings); 127 | 128 | var ignoreNamingConventionValue = rowNode.GetAttributeValue("data-ignore-convention", "false"); 129 | 130 | bool.TryParse(ignoreNamingConventionValue, out var ignoreNamingConvention); 131 | 132 | var row = new RowModel(_shortStringHelper, rowName, rowNode, 133 | settingsName, hasSettings, ignoreNamingConvention, 134 | iconClass: string.Join(" ", (new List() { iconClass, iconColour }).Where(x => !string.IsNullOrWhiteSpace(x))), 135 | labelProperty: labelProperty, useCommunityPreview: useCommunityPreview.ToLower() == "true", previewCss: previewCss, previewView: previewView); 136 | 137 | var properties = GetProperties(rowNode.OuterHtml); 138 | row.Properties = properties; 139 | 140 | rows.Add(row); 141 | } 142 | 143 | return rows; 144 | } 145 | 146 | public List GetBlocks(string html, string rowName) 147 | { 148 | var doc = new HtmlDocument(); 149 | 150 | doc.LoadHtml(html); 151 | 152 | var blocks = new List(); 153 | 154 | var descendants = doc.DocumentNode.Descendants(); 155 | if (descendants == null || !descendants.Any()) return blocks; 156 | 157 | foreach (var descendant in descendants) 158 | { 159 | var itemName = descendant.GetAttributeValue("data-item-name", ""); 160 | if (!string.IsNullOrWhiteSpace(itemName)) 161 | { 162 | var item = new BlockItemModel(_shortStringHelper, itemName, descendant); 163 | 164 | var properties = GetProperties(descendant.OuterHtml); 165 | item.Properties = properties; 166 | 167 | blocks.Add(item); 168 | } 169 | } 170 | 171 | return blocks; 172 | } 173 | 174 | public List GetProperties(string html) 175 | { 176 | var doc = new HtmlDocument(); 177 | 178 | doc.LoadHtml(html); 179 | 180 | var properties = new List(); 181 | 182 | var propertyNodes = doc.DocumentNode.SelectNodes("//*[@data-prop-name][not(ancestor::*[@data-list-name]) and not(ancestor::*[@data-sub-list-name])]"); 183 | 184 | var descendants = doc.DocumentNode.Descendants(); 185 | if (propertyNodes == null || descendants == null || !descendants.Any()) return properties; 186 | 187 | foreach (var propertyNode in propertyNodes) 188 | { 189 | var itemName = propertyNode.GetAttributeValue("data-prop-name", ""); 190 | var itemType = propertyNode.GetAttributeValue("data-prop-type", ""); 191 | 192 | if (!string.IsNullOrWhiteSpace(itemName) && string.IsNullOrWhiteSpace(itemType)) 193 | { 194 | itemType = _dataTypeNameResolver.GetDataTypeName(propertyNode.OriginalName.ToLower()); 195 | } 196 | 197 | if (!string.IsNullOrWhiteSpace(itemName)) 198 | { 199 | var item = new PropertyModel(itemName, itemType, propertyNode); 200 | properties.Add(item); 201 | } 202 | } 203 | 204 | return properties; 205 | } 206 | 207 | public ContentTypeModel GetContentType(HtmlNode node) 208 | { 209 | var descendants = node.Descendants(); 210 | if (descendants == null || !descendants.Any()) return null; 211 | 212 | foreach(var descendant in descendants) 213 | { 214 | var itemName = descendant.GetAttributeValue("data-content-type-name", ""); 215 | if (!string.IsNullOrWhiteSpace(itemName)) 216 | { 217 | var item = new ContentTypeModel(_shortStringHelper, itemName, descendant.OuterHtml); 218 | return item; 219 | } 220 | } 221 | 222 | return null; 223 | } 224 | 225 | public List GetPartialViews(HtmlNode node) 226 | { 227 | var partialViews = new List(); 228 | 229 | var descendants = node.Descendants(); 230 | if (descendants == null || !descendants.Any()) return null; 231 | 232 | foreach (var descendant in descendants) 233 | { 234 | var itemName = descendant.GetAttributeValue("data-partial-name", ""); 235 | if (!string.IsNullOrWhiteSpace(itemName)) 236 | { 237 | var item = new PartialViewModel(itemName, descendant); 238 | partialViews.Add(item); 239 | } 240 | } 241 | 242 | return partialViews; 243 | } 244 | } -------------------------------------------------------------------------------- /src/QuickBlocks/Services/IBlockCreationService.cs: -------------------------------------------------------------------------------- 1 | using HtmlAgilityPack; 2 | 3 | using Microsoft.AspNetCore.Hosting; 4 | using Umbraco.Community.QuickBlocks.Models; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.IO; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | using Umbraco.Cms.Core.Models; 12 | using Umbraco.Cms.Core.PropertyEditors; 13 | using Umbraco.Cms.Core.Strings; 14 | 15 | namespace Umbraco.Community.QuickBlocks.Services; 16 | 17 | public interface IBlockCreationService 18 | { 19 | public bool CreateRowPartial(RowModel row); 20 | 21 | void CreateList(BlockListModel list, FolderStructure folderStructure, int parentDataTypeId); 22 | 23 | List CreateBlockConfigurations(BlockListModel list, FolderStructure folderStructure); 24 | 25 | BlockListConfiguration.BlockConfiguration CreateBlockConfiguration(RowModel row, FolderStructure folderStructure, BlockListModel list); 26 | 27 | void CreateBlockListDataType(BlockListModel list, List blocks, int parentDataTypeId); 28 | 29 | IContentType CreateContentType(string name, string alias, int parentId = -1, 30 | bool isElement = true, bool isContainer = false, string iconClass = "icon-science", 31 | bool allowedAtRoot = false, bool updateDoctype = false); 32 | 33 | void AddPropertiesToContentType(IContentType contentType, IEnumerable properties, string groupName); 34 | 35 | FolderStructure CreateFolderStructure(); 36 | 37 | int CreateSupportingDataTypes(); 38 | 39 | void CreateSupportingContentTypes(int parentId); 40 | 41 | void RemoveAllQuickBlocksAttributes(HtmlDocument doc); 42 | 43 | void CreatePartialViews(List partialViews); 44 | 45 | void ReplaceAllPartialAttributesWithCalls(HtmlDocument doc); 46 | 47 | void RenderProperties(HtmlNodeCollection properties, string context); 48 | 49 | void RenderListPropertyCalls(HtmlNodeCollection listProperties, string context); 50 | } 51 | -------------------------------------------------------------------------------- /src/QuickBlocks/Services/IBlockParsingService.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using HtmlAgilityPack; 3 | using Umbraco.Community.QuickBlocks.Models; 4 | 5 | namespace Umbraco.Community.QuickBlocks.Services; 6 | 7 | public interface IBlockParsingService 8 | { 9 | List GetLists(string html, bool isNestedList, string prefix = "[BlockList]"); 10 | List GetRows(string html, bool isNestedList); 11 | List GetBlocks(string html, string rowName); 12 | List GetProperties(string html); 13 | ContentTypeModel GetContentType(HtmlNode node); 14 | List GetPartialViews(HtmlNode node); 15 | } -------------------------------------------------------------------------------- /src/QuickBlocks/Services/Resolvers/DataTypeNameResolver.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.Options; 2 | 3 | namespace Umbraco.Community.QuickBlocks.Services.Resolvers; 4 | public class DataTypeNameResolver : IDataTypeNameResolver 5 | { 6 | private readonly DataTypeMappersCollection _dataTypeMappers; 7 | private readonly IOptions _defaultOptions; 8 | 9 | public DataTypeNameResolver(DataTypeMappersCollection dataTypeMappers, IOptions defaultOptions) 10 | { 11 | _dataTypeMappers = dataTypeMappers; 12 | _defaultOptions = defaultOptions; 13 | } 14 | 15 | public string GetDataTypeName(string htmlElement) 16 | { 17 | 18 | var dt = _dataTypeMappers.LastOrDefault(dt=>dt.HtmlElements.Contains(htmlElement)); 19 | 20 | return dt?.DataTypeName ?? _defaultOptions.Value.DefaultDataTypeName; 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/QuickBlocks/Services/Resolvers/IDataTypeNameResolver.cs: -------------------------------------------------------------------------------- 1 | namespace Umbraco.Community.QuickBlocks.Services.Resolvers; 2 | 3 | public interface IDataTypeNameResolver 4 | { 5 | string GetDataTypeName(string htmlElement); 6 | } -------------------------------------------------------------------------------- /src/QuickBlocks/buildTransitive/Umbraco.Community.QuickBlocks.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | $(MSBuildThisFileDirectory)..\App_Plugins\QuickBlocks\**\*.* 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /umbraco-marketplace.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://marketplace.umbraco.com/umbraco-marketplace-schema.json", 3 | "AlternatePackageNames": [ 4 | "QuickBlocks" 5 | ], 6 | "AuthorDetails": { 7 | "Name": "Paul Seal", 8 | "Description": "Paul is an Umbraco Master and 5 x Umbraco MVP who loves making tutorials and small Umbraco packages. He works for the Umbraco Gold Partner ClerksWell", 9 | "Url": "https://github.com/prjseal", 10 | "ImageUrl": "https://github.com/prjseal.png", 11 | "Contributors": [ 12 | { 13 | "Name": "Paul Seal", 14 | "Url": "https://codeshare.co.uk" 15 | }, 16 | { 17 | "Name": "ClerksWell", 18 | "Url": "https://clerkswell.com" 19 | }, 20 | { 21 | "Name": "Mario Lopez", 22 | "Url": "https://github.com/skartknet" 23 | } 24 | ], 25 | "SyncContributorsFromRepository": true 26 | }, 27 | "Category": "Developer Tools", 28 | "Description": "A package for quickly building block list based Umbraco websites all from data attributes in your HTMl", 29 | "LicenseTypes": [ "Free" ], 30 | "IssueTrackerUrl": "https://github.com/prjseal/QuickBlocks/issues", 31 | "PackageType": "Package", 32 | "Tags": [ "HTML", "Fast", "Quick", "Blocks" ], 33 | "Title": "QuickBlocks", 34 | "Screenshots": [ 35 | { 36 | "ImageUrl": "https://raw.githubusercontent.com/prjseal/QuickBlocks/main/images/1.png", 37 | "Caption": "QuickBlocks Dashboard with some custom HTML with data attributes in it." 38 | }, 39 | { 40 | "ImageUrl": "https://raw.githubusercontent.com/prjseal/QuickBlocks/main/images/2.png", 41 | "Caption": "Block List automatically created for you with a portfolio row" 42 | }, 43 | { 44 | "ImageUrl": "https://raw.githubusercontent.com/prjseal/QuickBlocks/main/images/3.png", 45 | "Caption": "The block list data type is used for a property on the home page" 46 | }, 47 | { 48 | "ImageUrl": "https://raw.githubusercontent.com/prjseal/QuickBlocks/main/images/4.png", 49 | "Caption": "Editing a portfolio row with properties including another list" 50 | }, 51 | { 52 | "ImageUrl": "https://raw.githubusercontent.com/prjseal/QuickBlocks/main/images/5.jpg", 53 | "Caption": "Backoffice view of a portfolio item being edited" 54 | } 55 | ], 56 | "VideoUrl": "https://www.youtube.com/embed/Ja7ynDvCGQY" 57 | } 58 | --------------------------------------------------------------------------------