diff --git a/.github/README.md b/.github/README.md index 854146f..1c82290 100644 --- a/.github/README.md +++ b/.github/README.md @@ -1,8 +1,9 @@ # Umbraco.Community.SimpleDashboards -[![Downloads](https://img.shields.io/nuget/dt/Umbraco.Community.SimpleDashboards?color=cc9900)](https://www.nuget.org/packages/Umbraco.Community.SimpleDashboards/) +[![Umbraco Version](https://img.shields.io/badge/Umbraco-10.4+-%233544B1?style=flat&logo=umbraco)](https://umbraco.com/products/umbraco-cms/) [![NuGet](https://img.shields.io/nuget/vpre/Umbraco.Community.SimpleDashboards?color=0273B3)](https://www.nuget.org/packages/Umbraco.Community.SimpleDashboards) [![GitHub license](https://img.shields.io/github/license/jcdcdev/Umbraco.Community.SimpleDashboards?color=8AB803)](https://github.com/jcdcdev/Umbraco.Community.SimpleDashboards/blob/main/LICENSE) +[![Downloads](https://img.shields.io/nuget/dt/Umbraco.Community.SimpleDashboards?color=cc9900)](https://www.nuget.org/packages/Umbraco.Community.SimpleDashboards/) This packages aims to help developers quickly put together Umbraco Dashboards using C# only. diff --git a/src/.editorconfig b/src/.editorconfig index ceda871..8e325af 100644 --- a/src/.editorconfig +++ b/src/.editorconfig @@ -1,404 +1,15 @@ -# This .editorconfig has been taken from Umbraco CMS, licensed under MIT. -# https://raw.githubusercontent.com/umbraco/Umbraco-CMS/release-10.2.0/.editorconfig - -# Version: 1.6.2 (Using https://semver.org/) -# Updated: 2020-11-02 -# See https://github.com/RehanSaeed/EditorConfig/releases for release notes. -# See https://github.com/RehanSaeed/EditorConfig for updates to this file. -# See http://EditorConfig.org for more information about .editorconfig files. - -########################################## -# Common Settings -########################################## - -# This file is the top-most EditorConfig file -root = true - -# All Files [*] -charset = utf-8 -indent_style = space -indent_size = 4 -insert_final_newline = true -trim_trailing_whitespace = true -max_line_length = 160 - -########################################## -# File Extension Settings -########################################## - -# Visual Studio Solution Files -[*.sln] +max_line_length = 200 indent_style = tab - -# Visual Studio XML Project Files -[*.{csproj,vbproj,vcxproj.filters,proj,projitems,shproj}] -indent_size = 2 - -# XML Configuration Files -[*.{xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct}] -indent_size = 2 - -# JSON Files -[*.{json,json5,webmanifest}] -indent_size = 2 - -# YAML Files -[*.{yml,yaml}] -indent_size = 2 - -# Markdown Files -[*.md] -trim_trailing_whitespace = false - -# Web Files -[*.{htm,html,js,jsm,ts,tsx,css,sass,scss,less,svg,vue}] -indent_size = 2 - -# Batch Files -[*.{cmd,bat}] -end_of_line = crlf - -# Bash Files -[*.sh] -end_of_line = lf - -# Makefiles -[Makefile] -indent_style = tab - - -[*.js] -trim_trailing_whitespace = true - -[*.less] -trim_trailing_whitespace = false - -########################################## -# File Header (Uncomment to support file headers) -# https://docs.microsoft.com/visualstudio/ide/reference/add-file-header -########################################## - -# [*.{cs,csx,cake,vb,vbx}] -file_header_template = Copyright (c) Umbraco.\nSee LICENSE for more details. - -# SA1636: File header copyright text should match -# 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. -# dotnet_diagnostic.SA1636.severity = none - -########################################## -# .NET Language Conventions -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions -########################################## - -# .NET Code Style Settings -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#net-code-style-settings -[*.{cs,csx,cake,vb,vbx}] -# "this." and "Me." qualifiers -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#this-and-me -dotnet_style_qualification_for_field = false:suggestion -dotnet_style_qualification_for_property = false:suggestion -dotnet_style_qualification_for_method = false:suggestion -dotnet_style_qualification_for_event = false:suggestion -# Language keywords instead of framework type names for type references -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#language-keywords -dotnet_style_predefined_type_for_locals_parameters_members = true:warning -dotnet_style_predefined_type_for_member_access = true:warning -# Modifier preferences -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#normalize-modifiers -dotnet_style_require_accessibility_modifiers = always:warning -csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning -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 -dotnet_style_readonly_field = true:warning -# Parentheses preferences -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#parentheses-preferences -dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning -dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning -dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning -dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion -# Expression-level preferences -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-level-preferences -dotnet_style_object_initializer = true:warning -dotnet_style_collection_initializer = true:warning -dotnet_style_explicit_tuple_names = true:warning -dotnet_style_prefer_inferred_tuple_names = true:warning -dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning -dotnet_style_prefer_auto_properties = true:warning -dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning -dotnet_style_prefer_conditional_expression_over_assignment = false:suggestion -dotnet_style_prefer_conditional_expression_over_return = false:suggestion -dotnet_style_prefer_compound_assignment = true:warning -# Null-checking preferences -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#null-checking-preferences -dotnet_style_coalesce_expression = true:warning -dotnet_style_null_propagation = true:warning -# Parameter preferences -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#parameter-preferences -dotnet_code_quality_unused_parameters = all:warning -# More style options (Undocumented) -# https://github.com/MicrosoftDocs/visualstudio-docs/issues/3641 -dotnet_style_operator_placement_when_wrapping = end_of_line -# https://github.com/dotnet/roslyn/pull/40070 -dotnet_style_prefer_simplified_interpolation = true:warning - -# C# Code Style Settings -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#c-code-style-settings -[*.{cs,csx,cake}] -# Implicit and explicit types -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#implicit-and-explicit-types -csharp_style_var_for_built_in_types = never -csharp_style_var_when_type_is_apparent = false -csharp_style_var_elsewhere = false -# Expression-bodied members -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-bodied-members -csharp_style_expression_bodied_methods = false:suggestion -csharp_style_expression_bodied_constructors = true:suggestion -csharp_style_expression_bodied_operators = true:suggestion -csharp_style_expression_bodied_properties = true:suggestion -csharp_style_expression_bodied_indexers = true:suggestion -csharp_style_expression_bodied_accessors = true:suggestion -csharp_style_expression_bodied_lambdas = true:suggestion -csharp_style_expression_bodied_local_functions = true:suggestion -# Pattern matching -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#pattern-matching -csharp_style_pattern_matching_over_is_with_cast_check = true:warning -csharp_style_pattern_matching_over_as_with_null_check = true:warning -# Inlined variable declarations -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#inlined-variable-declarations -csharp_style_inlined_variable_declaration = true:warning -# Expression-level preferences -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-level-preferences -csharp_prefer_simple_default_expression = true:warning -# "Null" checking preferences -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#c-null-checking-preferences -csharp_style_throw_expression = true:warning -csharp_style_conditional_delegate_call = true:warning -# Code block preferences -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#code-block-preferences -csharp_prefer_braces = true:warning -# Unused value preferences -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#unused-value-preferences -csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion -csharp_style_unused_value_assignment_preference = discard_variable:suggestion -# Index and range preferences -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#index-and-range-preferences -csharp_style_prefer_index_operator = true:warning -csharp_style_prefer_range_operator = true:warning -# Miscellaneous preferences -# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#miscellaneous-preferences -csharp_style_deconstructed_variable_declaration = true:warning -csharp_style_pattern_local_over_anonymous_function = true:warning -csharp_using_directive_placement = outside_namespace:warning -csharp_prefer_static_local_function = true:warning -csharp_prefer_simple_using_statement = true:suggestion - -########################################## -# .NET Formatting Conventions -# https://docs.microsoft.com/visualstudio/ide/editorconfig-code-style-settings-reference#formatting-conventions -########################################## - -# Organize usings -# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#organize-using-directives -dotnet_sort_system_directives_first = true -# Newline options -# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#new-line-options -csharp_new_line_before_open_brace = all -csharp_new_line_before_else = true -csharp_new_line_before_catch = true -csharp_new_line_before_finally = true -csharp_new_line_before_members_in_object_initializers = true -csharp_new_line_before_members_in_anonymous_types = true -csharp_new_line_between_query_expression_clauses = true -# Indentation options -# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#indentation-options -csharp_indent_case_contents = true -csharp_indent_switch_labels = true -csharp_indent_labels = no_change -csharp_indent_block_contents = true -csharp_indent_braces = false -csharp_indent_case_contents_when_block = false -# Spacing options -# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#spacing-options -csharp_space_after_cast = false -csharp_space_after_keywords_in_control_flow_statements = true -csharp_space_between_parentheses = false -csharp_space_before_colon_in_inheritance_clause = true -csharp_space_after_colon_in_inheritance_clause = true -csharp_space_around_binary_operators = before_and_after -csharp_space_between_method_declaration_parameter_list_parentheses = false -csharp_space_between_method_declaration_empty_parameter_list_parentheses = false -csharp_space_between_method_declaration_name_and_open_parenthesis = false -csharp_space_between_method_call_parameter_list_parentheses = false -csharp_space_between_method_call_empty_parameter_list_parentheses = false -csharp_space_between_method_call_name_and_opening_parenthesis = false -csharp_space_after_comma = true -csharp_space_before_comma = false -csharp_space_after_dot = false -csharp_space_before_dot = false -csharp_space_after_semicolon_in_for_statement = true -csharp_space_before_semicolon_in_for_statement = false -csharp_space_around_declaration_statements = false -csharp_space_before_open_square_brackets = false -csharp_space_between_empty_square_brackets = false -csharp_space_between_square_brackets = false -# Wrapping options -# https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#wrap-options -csharp_preserve_single_line_statements = false -csharp_preserve_single_line_blocks = true - -########################################## -# .NET Naming Conventions -# https://docs.microsoft.com/visualstudio/ide/editorconfig-naming-conventions -########################################## - -[*.{cs,csx,cake,vb,vbx}] - -########################################## -# Styles -########################################## - -# camel_case_style - Define the camelCase style -dotnet_naming_style.camel_case_style.capitalization = camel_case -# pascal_case_style - Define the PascalCase style -dotnet_naming_style.pascal_case_style.capitalization = pascal_case -# first_upper_style - The first character must start with an upper-case character -dotnet_naming_style.first_upper_style.capitalization = first_word_upper -# prefix_interface_with_i_style - Interfaces must be PascalCase and the first character of an interface must be an 'I' -dotnet_naming_style.prefix_interface_with_i_style.capitalization = pascal_case -dotnet_naming_style.prefix_interface_with_i_style.required_prefix = I -# prefix_type_parameters_with_t_style - Generic Type Parameters must be PascalCase and the first character must be a 'T' -dotnet_naming_style.prefix_type_parameters_with_t_style.capitalization = pascal_case -dotnet_naming_style.prefix_type_parameters_with_t_style.required_prefix = T -# disallowed_style - Anything that has this style applied is marked as disallowed -dotnet_naming_style.disallowed_style.capitalization = pascal_case -dotnet_naming_style.disallowed_style.required_prefix = ____RULE_VIOLATION____ -dotnet_naming_style.disallowed_style.required_suffix = ____RULE_VIOLATION____ -# internal_error_style - This style should never occur... if it does, it indicates a bug in file or in the parser using the file -dotnet_naming_style.internal_error_style.capitalization = pascal_case -dotnet_naming_style.internal_error_style.required_prefix = ____INTERNAL_ERROR____ -dotnet_naming_style.internal_error_style.required_suffix = ____INTERNAL_ERROR____ - -########################################## -# .NET Design Guideline Field Naming Rules -# Naming rules for fields follow the .NET Framework design guidelines -# https://docs.microsoft.com/dotnet/standard/design-guidelines/index -########################################## - -# All public/protected/protected_internal constant fields must be PascalCase -# https://docs.microsoft.com/dotnet/standard/design-guidelines/field -dotnet_naming_symbols.public_protected_constant_fields_group.applicable_accessibilities = public, protected, protected_internal, internal, private -dotnet_naming_symbols.public_protected_constant_fields_group.required_modifiers = const -dotnet_naming_symbols.public_protected_constant_fields_group.applicable_kinds = field -dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.symbols = public_protected_constant_fields_group -dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.style = pascal_case_style -dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.severity = warning - -# All public/protected/protected_internal static readonly fields must be PascalCase -# https://docs.microsoft.com/dotnet/standard/design-guidelines/field -dotnet_naming_symbols.public_protected_static_readonly_fields_group.applicable_accessibilities = public, protected, protected_internal -dotnet_naming_symbols.public_protected_static_readonly_fields_group.required_modifiers = static, readonly -dotnet_naming_symbols.public_protected_static_readonly_fields_group.applicable_kinds = field -dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.symbols = public_protected_static_readonly_fields_group -dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.style = pascal_case_style -dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.severity = warning - -# No other public/protected/protected_internal fields are allowed -# https://docs.microsoft.com/dotnet/standard/design-guidelines/field -dotnet_naming_symbols.other_public_protected_fields_group.applicable_accessibilities = public, protected, protected_internal -dotnet_naming_symbols.other_public_protected_fields_group.applicable_kinds = field -dotnet_naming_rule.other_public_protected_fields_disallowed_rule.symbols = other_public_protected_fields_group -dotnet_naming_rule.other_public_protected_fields_disallowed_rule.style = disallowed_style -dotnet_naming_rule.other_public_protected_fields_disallowed_rule.severity = error - -# This rule should never fire. However, it's included for at least two purposes: -# First, it helps to understand, reason about, and root-case certain types of issues, such as bugs in .editorconfig parsers. -# Second, it helps to raise immediate awareness if a new field type is added (as occurred recently in C#). -dotnet_naming_symbols.sanity_check_uncovered_field_case_group.applicable_accessibilities = * -dotnet_naming_symbols.sanity_check_uncovered_field_case_group.applicable_kinds = field -dotnet_naming_rule.sanity_check_uncovered_field_case_rule.symbols = sanity_check_uncovered_field_case_group -dotnet_naming_rule.sanity_check_uncovered_field_case_rule.style = internal_error_style -dotnet_naming_rule.sanity_check_uncovered_field_case_rule.severity = error - -########################################## -# Other Naming Rules -########################################## - -# All of the following must be PascalCase: -# - Namespaces -# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-namespaces -# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1300.md -# - Classes and Enumerations -# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces -# https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1300.md -# - Delegates -# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces#names-of-common-types -# - Constructors, Properties, Events, Methods -# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-type-members -dotnet_naming_symbols.element_group.applicable_kinds = namespace, class, enum, struct, delegate, event, method, property -dotnet_naming_rule.element_rule.symbols = element_group -dotnet_naming_rule.element_rule.style = pascal_case_style -dotnet_naming_rule.element_rule.severity = warning - -# Interfaces use PascalCase and are prefixed with uppercase 'I' -# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces -dotnet_naming_symbols.interface_group.applicable_kinds = interface -dotnet_naming_rule.interface_rule.symbols = interface_group -dotnet_naming_rule.interface_rule.style = prefix_interface_with_i_style -dotnet_naming_rule.interface_rule.severity = warning - -# Generics Type Parameters use PascalCase and are prefixed with uppercase 'T' -# https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces -dotnet_naming_symbols.type_parameter_group.applicable_kinds = type_parameter -dotnet_naming_rule.type_parameter_rule.symbols = type_parameter_group -dotnet_naming_rule.type_parameter_rule.style = prefix_type_parameters_with_t_style -dotnet_naming_rule.type_parameter_rule.severity = warning - -# Function parameters use camelCase -# https://docs.microsoft.com/dotnet/standard/design-guidelines/naming-parameters -dotnet_naming_symbols.parameters_group.applicable_kinds = parameter -dotnet_naming_rule.parameters_rule.symbols = parameters_group -dotnet_naming_rule.parameters_rule.style = camel_case_style -dotnet_naming_rule.parameters_rule.severity = warning - -# Instance fields use camelCase and are prefixed with '_' -dotnet_naming_rule.instance_fields_should_be_camel_case.severity = warning -dotnet_naming_rule.instance_fields_should_be_camel_case.symbols = instance_fields -dotnet_naming_rule.instance_fields_should_be_camel_case.style = instance_field_style -dotnet_naming_symbols.instance_fields.applicable_kinds = field -dotnet_naming_style.instance_field_style.capitalization = camel_case -dotnet_naming_style.instance_field_style.required_prefix = _ - -########################################## -# License -########################################## -# The following applies as to the .editorconfig file ONLY, and is -# included below for reference, per the requirements of the license -# corresponding to this .editorconfig file. -# See: https://github.com/RehanSaeed/EditorConfig -# -# MIT License -# -# Copyright (c) 2017-2019 Muhammad Rehan Saeed -# Copyright (c) 2019 Henry Gabryjelski -# -# Permission is hereby granted, free of charge, to any -# person obtaining a copy of this software and associated -# documentation files (the "Software"), to deal in the -# Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, -# sublicense, and/or sell copies of the Software, and to permit -# persons to whom the Software is furnished to do so, subject -# to the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -# OTHER DEALINGS IN THE SOFTWARE. -########################################## +indent_size = 4 +tab_width = 4 + +# ReSharper properties +resharper_braces_redundant = false +resharper_csharp_indent_style = space +resharper_csharp_wrap_after_declaration_lpar = true +resharper_csharp_wrap_parameters_style = chop_if_long +resharper_instance_members_qualify_declared_in = base_class +resharper_method_or_operator_body = expression_body +resharper_place_expr_method_on_single_line = true +resharper_braces_for_ifelse = required \ No newline at end of file diff --git a/src/Umbraco.Community.SimpleDashboards.TestSite/.gitignore b/src/TestSite.10/.gitignore similarity index 95% rename from src/Umbraco.Community.SimpleDashboards.TestSite/.gitignore rename to src/TestSite.10/.gitignore index 62e742f..d183720 100644 --- a/src/Umbraco.Community.SimpleDashboards.TestSite/.gitignore +++ b/src/TestSite.10/.gitignore @@ -466,16 +466,13 @@ appsettings-schema.json # Temp folder containing Examine indexes, NuCache, MediaCache, etc. /umbraco/Data/TEMP/ -# SQLite database files - enable if you don't want to commit your test DB to the repo -#/umbraco/Data/*.sqlite.db -#/umbraco/Data/*.sqlite.db-shm -#/umbraco/Data/*.sqlite.db-wal +# SQLite database files +/umbraco/Data/*.sqlite.db +/umbraco/Data/*.sqlite.db-shm +/umbraco/Data/*.sqlite.db-wal # Log files /umbraco/Logs/ # Media files /wwwroot/media/ - -# Test Site App_Plugins packages folder (exclude here as in Umbraco.Community.SimpleDashboards project) -/App_Plugins/Umbraco.Community.SimpleDashboards/ diff --git a/src/Umbraco.Community.SimpleDashboards.TestSite/Dashboards/BasicDashboard.cs b/src/TestSite.10/Dashboards/BasicDashboard.cs similarity index 67% rename from src/Umbraco.Community.SimpleDashboards.TestSite/Dashboards/BasicDashboard.cs rename to src/TestSite.10/Dashboards/BasicDashboard.cs index cde8da5..f3d706c 100644 --- a/src/Umbraco.Community.SimpleDashboards.TestSite/Dashboards/BasicDashboard.cs +++ b/src/TestSite.10/Dashboards/BasicDashboard.cs @@ -1,6 +1,6 @@ using Umbraco.Community.SimpleDashboards.Core; -namespace Umbraco.Community.SimpleDashboards.TestSite.Dashboards; +namespace TestSite.Ten.Dashboards; public class BasicDashboard : SimpleDashboard { diff --git a/src/Umbraco.Community.SimpleDashboards.TestSite/Dashboards/ExampleDashboard.cs b/src/TestSite.10/Dashboards/ExampleDashboard.cs similarity index 80% rename from src/Umbraco.Community.SimpleDashboards.TestSite/Dashboards/ExampleDashboard.cs rename to src/TestSite.10/Dashboards/ExampleDashboard.cs index 7de3451..eb101e8 100644 --- a/src/Umbraco.Community.SimpleDashboards.TestSite/Dashboards/ExampleDashboard.cs +++ b/src/TestSite.10/Dashboards/ExampleDashboard.cs @@ -1,7 +1,7 @@ using jcdcdev.Umbraco.Core.AccessRule; using Umbraco.Community.SimpleDashboards.Core; -namespace Umbraco.Community.SimpleDashboards.TestSite.Dashboards; +namespace TestSite.Ten.Dashboards; // Control order of where dashboard shows [Umbraco.Cms.Core.Composing.Weight(-100)] @@ -15,8 +15,8 @@ public ExampleDashboard() SetName("Example Dashboard Name (en-GB)", "en-GB"); // Show dashboard in the Media & Content sections - AddSection(Cms.Core.Constants.Applications.Media); - AddSection(Cms.Core.Constants.Applications.Content); + AddSection(Umbraco.Cms.Core.Constants.Applications.Media); + AddSection(Umbraco.Cms.Core.Constants.Applications.Content); // Allow Editors AddAccessRule(SimpleAccessRule.AllowEditorGroup); diff --git a/src/Umbraco.Community.SimpleDashboards.TestSite/Dashboards/NoViewDashboard.cs b/src/TestSite.10/Dashboards/NoViewDashboard.cs similarity index 60% rename from src/Umbraco.Community.SimpleDashboards.TestSite/Dashboards/NoViewDashboard.cs rename to src/TestSite.10/Dashboards/NoViewDashboard.cs index a491cf7..3ef0d0b 100644 --- a/src/Umbraco.Community.SimpleDashboards.TestSite/Dashboards/NoViewDashboard.cs +++ b/src/TestSite.10/Dashboards/NoViewDashboard.cs @@ -1,6 +1,6 @@ using Umbraco.Community.SimpleDashboards.Core; -namespace Umbraco.Community.SimpleDashboards.TestSite.Dashboards; +namespace TestSite.Ten.Dashboards; public class NoViewDashboard : SimpleDashboard { diff --git a/src/Umbraco.Community.SimpleDashboards.TestSite/Program.cs b/src/TestSite.10/Program.cs similarity index 84% rename from src/Umbraco.Community.SimpleDashboards.TestSite/Program.cs rename to src/TestSite.10/Program.cs index 0928fe3..04691ed 100644 --- a/src/Umbraco.Community.SimpleDashboards.TestSite/Program.cs +++ b/src/TestSite.10/Program.cs @@ -1,4 +1,7 @@ -namespace Umbraco.Community.SimpleDashboards.TestSite +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace TestSite.Ten { public class Program { diff --git a/src/Umbraco.Community.SimpleDashboards.TestSite/Properties/launchSettings.json b/src/TestSite.10/Properties/launchSettings.json similarity index 80% rename from src/Umbraco.Community.SimpleDashboards.TestSite/Properties/launchSettings.json rename to src/TestSite.10/Properties/launchSettings.json index cfa1ef6..89b0fe2 100644 --- a/src/Umbraco.Community.SimpleDashboards.TestSite/Properties/launchSettings.json +++ b/src/TestSite.10/Properties/launchSettings.json @@ -4,8 +4,8 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:59495", - "sslPort": 44315 + "applicationUrl": "http://localhost:16958", + "sslPort": 44316 } }, "profiles": { @@ -20,7 +20,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, - "applicationUrl": "https://localhost:44315;http://localhost:59495", + "applicationUrl": "https://localhost:44316;http://localhost:16958", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/src/Umbraco.Community.SimpleDashboards.TestSite/Startup.cs b/src/TestSite.10/Startup.cs similarity index 88% rename from src/Umbraco.Community.SimpleDashboards.TestSite/Startup.cs rename to src/TestSite.10/Startup.cs index 95698d2..b38e047 100644 --- a/src/Umbraco.Community.SimpleDashboards.TestSite/Startup.cs +++ b/src/TestSite.10/Startup.cs @@ -1,4 +1,13 @@ -namespace Umbraco.Community.SimpleDashboards.TestSite +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Umbraco.Cms.Core.DependencyInjection; +using Umbraco.Extensions; + +namespace TestSite.Ten { public class Startup { diff --git a/src/Umbraco.Community.SimpleDashboards.TestSite/Umbraco.Community.SimpleDashboards.TestSite.csproj b/src/TestSite.10/TestSite.10.csproj similarity index 73% rename from src/Umbraco.Community.SimpleDashboards.TestSite/Umbraco.Community.SimpleDashboards.TestSite.csproj rename to src/TestSite.10/TestSite.10.csproj index c4baaa7..948f0ef 100644 --- a/src/Umbraco.Community.SimpleDashboards.TestSite/Umbraco.Community.SimpleDashboards.TestSite.csproj +++ b/src/TestSite.10/TestSite.10.csproj @@ -3,16 +3,27 @@ net6.0 enable enable + TestSite.Ten - + - - + + + + + + + appsettings.json + + + + + @@ -26,21 +37,4 @@ false - - - - - - - appsettings.json - - - - - <_ContentIncludedByDefault Remove="Views\Partials\blockgrid\area.cshtml" /> - <_ContentIncludedByDefault Remove="Views\Partials\blockgrid\areas.cshtml" /> - <_ContentIncludedByDefault Remove="Views\Partials\blockgrid\default.cshtml" /> - <_ContentIncludedByDefault Remove="Views\Partials\blockgrid\items.cshtml" /> - <_ContentIncludedByDefault Remove="Views\Partials\blocklist\default.cshtml" /> - diff --git a/src/TestSite.10/Views/Components/ExampleDashboardAsyncViewComponent.cs b/src/TestSite.10/Views/Components/ExampleDashboardAsyncViewComponent.cs new file mode 100644 index 0000000..08eae7c --- /dev/null +++ b/src/TestSite.10/Views/Components/ExampleDashboardAsyncViewComponent.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Umbraco.Community.SimpleDashboards.Web; + +namespace TestSite.Ten.Views.Components; + +public class ExampleDashboardAsyncViewComponent : DashboardAsyncViewComponent +{ + public override async Task InvokeAsync(DashboardModel model) + { + // Simulate async workload + await Task.Delay(TimeSpan.FromMilliseconds(1)); + return Content($"Hello {model.Dashboard.Alias}"); + } +} diff --git a/src/Umbraco.Community.SimpleDashboards.TestSite/Views/Components/ExampleDashboardViewComponent.cs b/src/TestSite.10/Views/Components/ExampleDashboardViewComponent.cs similarity index 80% rename from src/Umbraco.Community.SimpleDashboards.TestSite/Views/Components/ExampleDashboardViewComponent.cs rename to src/TestSite.10/Views/Components/ExampleDashboardViewComponent.cs index c32010c..acc1933 100644 --- a/src/Umbraco.Community.SimpleDashboards.TestSite/Views/Components/ExampleDashboardViewComponent.cs +++ b/src/TestSite.10/Views/Components/ExampleDashboardViewComponent.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Mvc; using Umbraco.Community.SimpleDashboards.Web; -namespace Umbraco.Community.SimpleDashboards.TestSite.Views.Components; +namespace TestSite.Ten.Views.Components; public class ExampleDashboardViewComponent : DashboardViewComponent { diff --git a/src/Umbraco.Community.SimpleDashboards.TestSite/Views/Dashboards/Basic.cshtml b/src/TestSite.10/Views/Dashboards/Basic.cshtml similarity index 100% rename from src/Umbraco.Community.SimpleDashboards.TestSite/Views/Dashboards/Basic.cshtml rename to src/TestSite.10/Views/Dashboards/Basic.cshtml diff --git a/src/TestSite.10/Views/Partials/blockgrid/area.cshtml b/src/TestSite.10/Views/Partials/blockgrid/area.cshtml new file mode 100644 index 0000000..3614847 --- /dev/null +++ b/src/TestSite.10/Views/Partials/blockgrid/area.cshtml @@ -0,0 +1,10 @@ +@using Umbraco.Extensions +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +
+ @await Html.GetBlockGridItemsHtmlAsync(Model) +
diff --git a/src/TestSite.10/Views/Partials/blockgrid/areas.cshtml b/src/TestSite.10/Views/Partials/blockgrid/areas.cshtml new file mode 100644 index 0000000..30f987c --- /dev/null +++ b/src/TestSite.10/Views/Partials/blockgrid/areas.cshtml @@ -0,0 +1,13 @@ +@using Umbraco.Extensions +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage +@{ + if (Model?.Areas.Any() != true) { return; } +} + +
+ @foreach (var area in Model.Areas) + { + @await Html.GetBlockGridItemAreaHtmlAsync(area) + } +
diff --git a/src/TestSite.10/Views/Partials/blockgrid/default.cshtml b/src/TestSite.10/Views/Partials/blockgrid/default.cshtml new file mode 100644 index 0000000..e25839e --- /dev/null +++ b/src/TestSite.10/Views/Partials/blockgrid/default.cshtml @@ -0,0 +1,11 @@ +@using Umbraco.Extensions +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage +@{ + if (Model?.Any() != true) { return; } +} + +
+ @await Html.GetBlockGridItemsHtmlAsync(Model) +
diff --git a/src/TestSite.10/Views/Partials/blockgrid/items.cshtml b/src/TestSite.10/Views/Partials/blockgrid/items.cshtml new file mode 100644 index 0000000..2703fa5 --- /dev/null +++ b/src/TestSite.10/Views/Partials/blockgrid/items.cshtml @@ -0,0 +1,36 @@ +@using Umbraco.Cms.Core.Models.Blocks +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage> +@{ + if (Model?.Any() != true) { return; } +} + +
+ @foreach (var item in Model) + { + +
+ @{ + var partialViewName = "blockgrid/Components/" + item.Content.ContentType.Alias; + try + { + @await Html.PartialAsync(partialViewName, item) + } + catch (InvalidOperationException) + { +

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

+ } + } +
+ } +
diff --git a/src/TestSite.10/Views/Partials/blocklist/default.cshtml b/src/TestSite.10/Views/Partials/blocklist/default.cshtml new file mode 100644 index 0000000..accca2e --- /dev/null +++ b/src/TestSite.10/Views/Partials/blocklist/default.cshtml @@ -0,0 +1,13 @@ +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage +@{ + if (Model?.Any() != true) { return; } +} +
+ @foreach (var block in Model) + { + if (block?.ContentUdi == null) { continue; } + var data = block.Content; + + @await Html.PartialAsync("blocklist/Components/" + data.ContentType.Alias, block) + } +
diff --git a/src/TestSite.10/Views/Partials/grid/bootstrap3-fluid.cshtml b/src/TestSite.10/Views/Partials/grid/bootstrap3-fluid.cshtml new file mode 100644 index 0000000..b92734e --- /dev/null +++ b/src/TestSite.10/Views/Partials/grid/bootstrap3-fluid.cshtml @@ -0,0 +1,106 @@ +@using System.Web +@using Microsoft.AspNetCore.Html +@using Newtonsoft.Json.Linq +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +@* + Razor helpers located at the bottom of this file +*@ + +@if (Model is JObject && Model?.sections is not null) +{ + var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1; + +
+ @if (oneColumn) + { + foreach (var section in Model.sections) + { +
+ @foreach (var row in section.rows) + { + renderRow(row); + } +
+ } + } + else + { +
+ @foreach (var sec in Model.sections) + { +
+
+ @foreach (var row in sec.rows) + { + renderRow(row); + } +
+
+ } +
+ } +
+} + +@functions{ + + private async Task renderRow(dynamic row) + { +
+
+ @foreach (var area in row.areas) + { +
+
+ @foreach (var control in area.controls) + { + if (control?.editor?.view != null) + { + @await Html.PartialAsync("grid/editors/base", (object)control) + } + } +
+
+ } +
+
+ } +} + +@functions{ + + public static HtmlString RenderElementAttributes(dynamic contentItem) + { + var attrs = new List(); + JObject cfg = contentItem.config; + + if (cfg != null) + { + foreach (JProperty property in cfg.Properties()) + { + var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString()); + attrs.Add(property.Name + "=\"" + propertyValue + "\""); + } + } + + JObject style = contentItem.styles; + + if (style != null) { + var cssVals = new List(); + foreach (JProperty property in style.Properties()) + { + var propertyValue = property.Value.ToString(); + if (string.IsNullOrWhiteSpace(propertyValue) == false) + { + cssVals.Add(property.Name + ":" + propertyValue + ";"); + } + } + + if (cssVals.Any()) + attrs.Add("style='" + HttpUtility.HtmlAttributeEncode(string.Join(" ", cssVals)) + "'"); + } + + return new HtmlString(string.Join(" ", attrs)); + } +} diff --git a/src/TestSite.10/Views/Partials/grid/bootstrap3.cshtml b/src/TestSite.10/Views/Partials/grid/bootstrap3.cshtml new file mode 100644 index 0000000..8863788 --- /dev/null +++ b/src/TestSite.10/Views/Partials/grid/bootstrap3.cshtml @@ -0,0 +1,112 @@ +@using System.Web +@using Microsoft.AspNetCore.Html +@using Newtonsoft.Json.Linq +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +@if (Model is JObject && Model?.sections is not null) +{ + var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1; + +
+ @if (oneColumn) + { + foreach (var section in Model.sections) + { +
+ @foreach (var row in section.rows) + { + renderRow(row, true); + } +
+ } + } + else + { +
+
+ @foreach (var sec in Model.sections) + { +
+
+ @foreach (var row in sec.rows) + { + renderRow(row, false); + } +
+
+ } +
+
+ } +
+} + +@functions{ + + private async Task renderRow(dynamic row, bool singleColumn) + { +
+ @if (singleColumn) { + @:
+ } +
+ @foreach (var area in row.areas) + { +
+
+ @foreach (var control in area.controls) + { + if (control?.editor?.view != null) + { + @await Html.PartialAsync("grid/editors/base", (object)control) + } + } +
+
+ } +
+ @if (singleColumn) { + @:
+ } +
+ } + +} + +@functions{ + + public static HtmlString RenderElementAttributes(dynamic contentItem) + { + var attrs = new List(); + JObject cfg = contentItem.config; + + if (cfg != null) + { + foreach (JProperty property in cfg.Properties()) + { + var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString()); + attrs.Add(property.Name + "=\"" + propertyValue + "\""); + } + } + + JObject style = contentItem.styles; + + if (style != null) + { + var cssVals = new List(); + foreach (JProperty property in style.Properties()) + { + var propertyValue = property.Value.ToString(); + if (string.IsNullOrWhiteSpace(propertyValue) == false) + { + cssVals.Add(property.Name + ":" + propertyValue + ";"); + } + } + + if (cssVals.Any()) + attrs.Add("style=\"" + HttpUtility.HtmlAttributeEncode(string.Join(" ", cssVals)) + "\""); + } + + return new HtmlString(string.Join(" ", attrs)); + } +} diff --git a/src/TestSite.10/Views/Partials/grid/editors/base.cshtml b/src/TestSite.10/Views/Partials/grid/editors/base.cshtml new file mode 100644 index 0000000..e40543b --- /dev/null +++ b/src/TestSite.10/Views/Partials/grid/editors/base.cshtml @@ -0,0 +1,27 @@ +@model dynamic + +@try +{ + string editor = EditorView(Model); + @await Html.PartialAsync(editor, Model as object) +} +catch (Exception ex) +{ +
@ex.ToString()
+} + +@functions{ + + public static string EditorView(dynamic contentItem) + { + string view = contentItem.editor.render != null ? contentItem.editor.render.ToString() : contentItem.editor.view.ToString(); + view = view.Replace(".html", ".cshtml"); + + if (!view.Contains("/")) + { + view = "grid/editors/" + view; + } + + return view; + } +} diff --git a/src/TestSite.10/Views/Partials/grid/editors/embed.cshtml b/src/TestSite.10/Views/Partials/grid/editors/embed.cshtml new file mode 100644 index 0000000..74c8fe2 --- /dev/null +++ b/src/TestSite.10/Views/Partials/grid/editors/embed.cshtml @@ -0,0 +1,11 @@ +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +@if (Model is not null) +{ + string embedValue = Convert.ToString(Model.value); + embedValue = embedValue.DetectIsJson() ? Model.value.preview : Model.value; + +
+ @Html.Raw(embedValue) +
+} diff --git a/src/TestSite.10/Views/Partials/grid/editors/macro.cshtml b/src/TestSite.10/Views/Partials/grid/editors/macro.cshtml new file mode 100644 index 0000000..a4450d1 --- /dev/null +++ b/src/TestSite.10/Views/Partials/grid/editors/macro.cshtml @@ -0,0 +1,15 @@ +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +@if (Model?.value is not null) +{ + string macroAlias = Model.value.macroAlias.ToString(); + var parameters = new Dictionary(); + foreach (var mpd in Model.value.macroParamsDictionary) + { + parameters.Add(mpd.Name, mpd.Value); + } + + + @await Umbraco.RenderMacroAsync(macroAlias, parameters) + +} diff --git a/src/TestSite.10/Views/Partials/grid/editors/media.cshtml b/src/TestSite.10/Views/Partials/grid/editors/media.cshtml new file mode 100644 index 0000000..bc3b111 --- /dev/null +++ b/src/TestSite.10/Views/Partials/grid/editors/media.cshtml @@ -0,0 +1,64 @@ +@model dynamic +@using Umbraco.Cms.Core.Media +@using Umbraco.Cms.Core.PropertyEditors.ValueConverters +@inject IImageUrlGenerator ImageUrlGenerator + +@if (Model?.value is not null) +{ + var url = Model.value.image; + + if (Model.editor.config != null && Model.editor.config.size != null) + { + if (Model.value.coordinates != null) + { + url = ImageCropperTemplateCoreExtensions.GetCropUrl( + (string)url, + ImageUrlGenerator, + width: (int)Model.editor.config.size.width, + height: (int)Model.editor.config.size.height, + cropAlias: "default", + cropDataSet: new ImageCropperValue + { + Crops = new[] + { + new ImageCropperValue.ImageCropperCrop + { + Alias = "default", + Coordinates = new ImageCropperValue.ImageCropperCropCoordinates + { + X1 = (decimal)Model.value.coordinates.x1, + Y1 = (decimal)Model.value.coordinates.y1, + X2 = (decimal)Model.value.coordinates.x2, + Y2 = (decimal)Model.value.coordinates.y2 + } + } + } + }); + } + else + { + url = ImageCropperTemplateCoreExtensions.GetCropUrl( + (string)url, + ImageUrlGenerator, + width: (int)Model.editor.config.size.width, + height: (int)Model.editor.config.size.height, + cropDataSet: new ImageCropperValue + { + FocalPoint = new ImageCropperValue.ImageCropperFocalPoint + { + Top = Model.value.focalPoint == null ? 0.5m : Model.value.focalPoint.top, + Left = Model.value.focalPoint == null ? 0.5m : Model.value.focalPoint.left + } + }); + } + } + + var altText = Model.value.altText ?? Model.value.caption ?? string.Empty; + + @altText + + if (Model.value.caption != null) + { +

@Model.value.caption

+ } +} diff --git a/src/TestSite.10/Views/Partials/grid/editors/rte.cshtml b/src/TestSite.10/Views/Partials/grid/editors/rte.cshtml new file mode 100644 index 0000000..9445666 --- /dev/null +++ b/src/TestSite.10/Views/Partials/grid/editors/rte.cshtml @@ -0,0 +1,13 @@ +@using Umbraco.Cms.Core.Templates +@model dynamic +@inject HtmlLocalLinkParser HtmlLocalLinkParser; +@inject HtmlUrlParser HtmlUrlParser; +@inject HtmlImageSourceParser HtmlImageSourceParser; + +@{ + var value = HtmlLocalLinkParser.EnsureInternalLinks(Model?.value.ToString()); + value = HtmlUrlParser.EnsureUrls(value); + value = HtmlImageSourceParser.EnsureImageSources(value); +} + +@Html.Raw(value) diff --git a/src/TestSite.10/Views/Partials/grid/editors/textstring.cshtml b/src/TestSite.10/Views/Partials/grid/editors/textstring.cshtml new file mode 100644 index 0000000..e6b9352 --- /dev/null +++ b/src/TestSite.10/Views/Partials/grid/editors/textstring.cshtml @@ -0,0 +1,22 @@ +@model dynamic + +@if (Model?.editor.config.markup is not null) +{ + string markup = Model.editor.config.markup.ToString(); + markup = markup.Replace("#value#", Html.ReplaceLineBreaks((string)Model.value.ToString()).ToString()); + + if (Model.editor.config.style != null) + { + markup = markup.Replace("#style#", Model.editor.config.style.ToString()); + } + + + @Html.Raw(markup) + +} +else +{ + +
@Model?.value
+
+} diff --git a/src/Umbraco.Community.SimpleDashboards.TestSite/Views/_ViewImports.cshtml b/src/TestSite.10/Views/_ViewImports.cshtml similarity index 85% rename from src/Umbraco.Community.SimpleDashboards.TestSite/Views/_ViewImports.cshtml rename to src/TestSite.10/Views/_ViewImports.cshtml index f32b459..91d671e 100644 --- a/src/Umbraco.Community.SimpleDashboards.TestSite/Views/_ViewImports.cshtml +++ b/src/TestSite.10/Views/_ViewImports.cshtml @@ -1,5 +1,4 @@ @using Umbraco.Extensions -@using Umbraco.Community.SimpleDashboards.TestSite @using Umbraco.Cms.Web.Common.PublishedModels @using Umbraco.Cms.Web.Common.Views @using Umbraco.Cms.Core.Models.PublishedContent diff --git a/src/Umbraco.Community.SimpleDashboards.TestSite/appsettings.Development.json b/src/TestSite.10/appsettings.Development.json similarity index 58% rename from src/Umbraco.Community.SimpleDashboards.TestSite/appsettings.Development.json rename to src/TestSite.10/appsettings.Development.json index 91cd2da..39cf2ae 100644 --- a/src/Umbraco.Community.SimpleDashboards.TestSite/appsettings.Development.json +++ b/src/TestSite.10/appsettings.Development.json @@ -17,8 +17,18 @@ } ] }, + "ConnectionStrings": { + "umbracoDbDSN": "Data Source=|DataDirectory|/Umbraco.sqlite.db;Cache=Shared;Foreign Keys=True;Pooling=True", + "umbracoDbDSN_ProviderName": "Microsoft.Data.Sqlite" + }, "Umbraco": { "CMS": { + "Unattended": { + "InstallUnattended": true, + "UnattendedUserName": "Administrator", + "UnattendedUserEmail": "admin@example.com", + "UnattendedUserPassword": "1234567890" + }, "Content": { "MacroErrors": "Throw" }, diff --git a/src/Umbraco.Community.SimpleDashboards.TestSite/appsettings.json b/src/TestSite.10/appsettings.json similarity index 90% rename from src/Umbraco.Community.SimpleDashboards.TestSite/appsettings.json rename to src/TestSite.10/appsettings.json index 0681b5c..b9705b2 100644 --- a/src/Umbraco.Community.SimpleDashboards.TestSite/appsettings.json +++ b/src/TestSite.10/appsettings.json @@ -13,7 +13,6 @@ "Umbraco": { "CMS": { "Global": { - "Id": "12890910-b1c3-4bba-9544-a9beeb851ed0", "SanitizeTinyMce": true }, "Content": { @@ -24,4 +23,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/Umbraco.Community.SimpleDashboards.TestSite/wwwroot/favicon.ico b/src/TestSite.10/wwwroot/favicon.ico similarity index 100% rename from src/Umbraco.Community.SimpleDashboards.TestSite/wwwroot/favicon.ico rename to src/TestSite.10/wwwroot/favicon.ico diff --git a/src/TestSite.11/.gitignore b/src/TestSite.11/.gitignore new file mode 100644 index 0000000..8bcfaae --- /dev/null +++ b/src/TestSite.11/.gitignore @@ -0,0 +1,479 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# JetBrains Rider +.idea/ +*.sln.iml + +## +## Visual Studio Code +## +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +## +## Umbraco CMS +## + +# JSON schema files for appsettings.json +appsettings-schema.json +appsettings-schema.*.json + +# Packages created from the backoffice (package.xml/package.zip) +/umbraco/Data/CreatedPackages/ + +# Temp folder containing Examine indexes, NuCache, MediaCache, etc. +/umbraco/Data/TEMP/ + +# SQLite database files +/umbraco/Data/*.sqlite.db +/umbraco/Data/*.sqlite.db-shm +/umbraco/Data/*.sqlite.db-wal + +# Log files +/umbraco/Logs/ + +# Media files +/wwwroot/media/ diff --git a/src/TestSite.11/Dashboards/BasicDashboard.cs b/src/TestSite.11/Dashboards/BasicDashboard.cs new file mode 100644 index 0000000..dc7f5f8 --- /dev/null +++ b/src/TestSite.11/Dashboards/BasicDashboard.cs @@ -0,0 +1,8 @@ +using Umbraco.Community.SimpleDashboards.Core; + +namespace TestSite.Eleven.Dashboards; + +public class BasicDashboard : SimpleDashboard +{ + public BasicDashboard() { } +} diff --git a/src/TestSite.11/Dashboards/ExampleDashboard.cs b/src/TestSite.11/Dashboards/ExampleDashboard.cs new file mode 100644 index 0000000..c4eed3c --- /dev/null +++ b/src/TestSite.11/Dashboards/ExampleDashboard.cs @@ -0,0 +1,29 @@ +using jcdcdev.Umbraco.Core.AccessRule; +using Umbraco.Community.SimpleDashboards.Core; + +namespace TestSite.Eleven.Dashboards; + +// Control order of where dashboard shows +[Umbraco.Cms.Core.Composing.Weight(-100)] +public class ExampleDashboard : SimpleDashboard +{ + public ExampleDashboard() + { + // Set dashboard name + SetName("Example Dashboard Name (default)"); + // Set culture specific dashboard name + SetName("Example Dashboard Name (en-GB)", "en-GB"); + + // Show dashboard in the Media & Content sections + AddSection(Umbraco.Cms.Core.Constants.Applications.Media); + AddSection(Umbraco.Cms.Core.Constants.Applications.Content); + + // Allow Editors + AddAccessRule(SimpleAccessRule.AllowEditorGroup); + + // Allow custom User Group + Allow(x=>x.UserGroup("myGroup")); + // Deny custom User Group + Deny(x=>x.UserGroup("myOtherGroup")); + } +} diff --git a/src/TestSite.11/Dashboards/NoViewDashboard.cs b/src/TestSite.11/Dashboards/NoViewDashboard.cs new file mode 100644 index 0000000..6a1e7aa --- /dev/null +++ b/src/TestSite.11/Dashboards/NoViewDashboard.cs @@ -0,0 +1,7 @@ +using Umbraco.Community.SimpleDashboards.Core; + +namespace TestSite.Eleven.Dashboards; + +public class NoViewDashboard : SimpleDashboard +{ +} diff --git a/src/TestSite.11/Program.cs b/src/TestSite.11/Program.cs new file mode 100644 index 0000000..a4af172 --- /dev/null +++ b/src/TestSite.11/Program.cs @@ -0,0 +1,22 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace TestSite.Eleven +{ + public class Program + { + public static void Main(string[] args) + => CreateHostBuilder(args) + .Build() + .Run(); + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureUmbracoDefaults() + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStaticWebAssets(); + webBuilder.UseStartup(); + }); + } +} diff --git a/src/TestSite.11/Properties/launchSettings.json b/src/TestSite.11/Properties/launchSettings.json new file mode 100644 index 0000000..5e4321e --- /dev/null +++ b/src/TestSite.11/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:39997", + "sslPort": 44339 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Umbraco.Web.UI": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:44339;http://localhost:39997", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/TestSite.11/Startup.cs b/src/TestSite.11/Startup.cs new file mode 100644 index 0000000..a8dc5fd --- /dev/null +++ b/src/TestSite.11/Startup.cs @@ -0,0 +1,74 @@ +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Umbraco.Cms.Core.DependencyInjection; +using Umbraco.Extensions; + +namespace TestSite.Eleven +{ + public class Startup + { + private readonly IWebHostEnvironment _env; + private readonly IConfiguration _config; + + /// + /// Initializes a new instance of the class. + /// + /// The web hosting environment. + /// The configuration. + /// + /// Only a few services are possible to be injected here https://github.com/dotnet/aspnetcore/issues/9337. + /// + public Startup(IWebHostEnvironment webHostEnvironment, IConfiguration config) + { + _env = webHostEnvironment ?? throw new ArgumentNullException(nameof(webHostEnvironment)); + _config = config ?? throw new ArgumentNullException(nameof(config)); + } + + /// + /// Configures the services. + /// + /// The services. + /// + /// This method gets called by the runtime. Use this method to add services to the container. + /// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940. + /// + public void ConfigureServices(IServiceCollection services) + { + services.AddUmbraco(_env, _config) + .AddBackOffice() + .AddWebsite() + .AddComposers() + .Build(); + } + + /// + /// Configures the application. + /// + /// The application builder. + /// The web hosting environment. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseUmbraco() + .WithMiddleware(u => + { + u.UseBackOffice(); + u.UseWebsite(); + }) + .WithEndpoints(u => + { + u.UseInstallerEndpoints(); + u.UseBackOfficeEndpoints(); + u.UseWebsiteEndpoints(); + }); + } + } +} diff --git a/src/TestSite.11/TestSite.11.csproj b/src/TestSite.11/TestSite.11.csproj new file mode 100644 index 0000000..7bb675a --- /dev/null +++ b/src/TestSite.11/TestSite.11.csproj @@ -0,0 +1,41 @@ + + + net7.0 + enable + enable + TestSite.Eleven + + + + + + + + + + + + + + + + appsettings.json + + + + + + + + + + true + + + + + false + false + + + diff --git a/src/TestSite.11/Views/Components/ExampleDashboardAsyncViewComponent.cs b/src/TestSite.11/Views/Components/ExampleDashboardAsyncViewComponent.cs new file mode 100644 index 0000000..39ae4a5 --- /dev/null +++ b/src/TestSite.11/Views/Components/ExampleDashboardAsyncViewComponent.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Umbraco.Community.SimpleDashboards.Web; + +namespace TestSite.Eleven.Views.Components; + +public class ExampleDashboardAsyncViewComponent : DashboardAsyncViewComponent +{ + public override async Task InvokeAsync(DashboardModel model) + { + // Simulate async workload + await Task.Delay(TimeSpan.FromMilliseconds(1)); + return Content($"Hello {model.Dashboard.Alias}"); + } +} diff --git a/src/TestSite.11/Views/Components/ExampleDashboardViewComponent.cs b/src/TestSite.11/Views/Components/ExampleDashboardViewComponent.cs new file mode 100644 index 0000000..273fa77 --- /dev/null +++ b/src/TestSite.11/Views/Components/ExampleDashboardViewComponent.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc; +using Umbraco.Community.SimpleDashboards.Web; + +namespace TestSite.Eleven.Views.Components; + +public class ExampleDashboardViewComponent : DashboardViewComponent +{ + public override IViewComponentResult Invoke(DashboardModel model) + { + return Content($"Hello {model.Dashboard.Alias}"); + } +} diff --git a/src/TestSite.11/Views/Dashboards/Basic.cshtml b/src/TestSite.11/Views/Dashboards/Basic.cshtml new file mode 100644 index 0000000..850488f --- /dev/null +++ b/src/TestSite.11/Views/Dashboards/Basic.cshtml @@ -0,0 +1,4 @@ +@inherits Umbraco.Community.SimpleDashboards.Web.DashboardViewPage + +

Hello Umbraco

+

My Dashboard is: @Model.Dashboard.Alias

diff --git a/src/TestSite.11/Views/Partials/blockgrid/area.cshtml b/src/TestSite.11/Views/Partials/blockgrid/area.cshtml new file mode 100644 index 0000000..3614847 --- /dev/null +++ b/src/TestSite.11/Views/Partials/blockgrid/area.cshtml @@ -0,0 +1,10 @@ +@using Umbraco.Extensions +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +
+ @await Html.GetBlockGridItemsHtmlAsync(Model) +
diff --git a/src/TestSite.11/Views/Partials/blockgrid/areas.cshtml b/src/TestSite.11/Views/Partials/blockgrid/areas.cshtml new file mode 100644 index 0000000..30f987c --- /dev/null +++ b/src/TestSite.11/Views/Partials/blockgrid/areas.cshtml @@ -0,0 +1,13 @@ +@using Umbraco.Extensions +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage +@{ + if (Model?.Areas.Any() != true) { return; } +} + +
+ @foreach (var area in Model.Areas) + { + @await Html.GetBlockGridItemAreaHtmlAsync(area) + } +
diff --git a/src/TestSite.11/Views/Partials/blockgrid/default.cshtml b/src/TestSite.11/Views/Partials/blockgrid/default.cshtml new file mode 100644 index 0000000..e25839e --- /dev/null +++ b/src/TestSite.11/Views/Partials/blockgrid/default.cshtml @@ -0,0 +1,11 @@ +@using Umbraco.Extensions +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage +@{ + if (Model?.Any() != true) { return; } +} + +
+ @await Html.GetBlockGridItemsHtmlAsync(Model) +
diff --git a/src/TestSite.11/Views/Partials/blockgrid/items.cshtml b/src/TestSite.11/Views/Partials/blockgrid/items.cshtml new file mode 100644 index 0000000..2703fa5 --- /dev/null +++ b/src/TestSite.11/Views/Partials/blockgrid/items.cshtml @@ -0,0 +1,36 @@ +@using Umbraco.Cms.Core.Models.Blocks +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage> +@{ + if (Model?.Any() != true) { return; } +} + +
+ @foreach (var item in Model) + { + +
+ @{ + var partialViewName = "blockgrid/Components/" + item.Content.ContentType.Alias; + try + { + @await Html.PartialAsync(partialViewName, item) + } + catch (InvalidOperationException) + { +

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

+ } + } +
+ } +
diff --git a/src/TestSite.11/Views/Partials/blocklist/default.cshtml b/src/TestSite.11/Views/Partials/blocklist/default.cshtml new file mode 100644 index 0000000..accca2e --- /dev/null +++ b/src/TestSite.11/Views/Partials/blocklist/default.cshtml @@ -0,0 +1,13 @@ +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage +@{ + if (Model?.Any() != true) { return; } +} +
+ @foreach (var block in Model) + { + if (block?.ContentUdi == null) { continue; } + var data = block.Content; + + @await Html.PartialAsync("blocklist/Components/" + data.ContentType.Alias, block) + } +
diff --git a/src/TestSite.11/Views/Partials/grid/bootstrap3-fluid.cshtml b/src/TestSite.11/Views/Partials/grid/bootstrap3-fluid.cshtml new file mode 100644 index 0000000..b92734e --- /dev/null +++ b/src/TestSite.11/Views/Partials/grid/bootstrap3-fluid.cshtml @@ -0,0 +1,106 @@ +@using System.Web +@using Microsoft.AspNetCore.Html +@using Newtonsoft.Json.Linq +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +@* + Razor helpers located at the bottom of this file +*@ + +@if (Model is JObject && Model?.sections is not null) +{ + var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1; + +
+ @if (oneColumn) + { + foreach (var section in Model.sections) + { +
+ @foreach (var row in section.rows) + { + renderRow(row); + } +
+ } + } + else + { +
+ @foreach (var sec in Model.sections) + { +
+
+ @foreach (var row in sec.rows) + { + renderRow(row); + } +
+
+ } +
+ } +
+} + +@functions{ + + private async Task renderRow(dynamic row) + { +
+
+ @foreach (var area in row.areas) + { +
+
+ @foreach (var control in area.controls) + { + if (control?.editor?.view != null) + { + @await Html.PartialAsync("grid/editors/base", (object)control) + } + } +
+
+ } +
+
+ } +} + +@functions{ + + public static HtmlString RenderElementAttributes(dynamic contentItem) + { + var attrs = new List(); + JObject cfg = contentItem.config; + + if (cfg != null) + { + foreach (JProperty property in cfg.Properties()) + { + var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString()); + attrs.Add(property.Name + "=\"" + propertyValue + "\""); + } + } + + JObject style = contentItem.styles; + + if (style != null) { + var cssVals = new List(); + foreach (JProperty property in style.Properties()) + { + var propertyValue = property.Value.ToString(); + if (string.IsNullOrWhiteSpace(propertyValue) == false) + { + cssVals.Add(property.Name + ":" + propertyValue + ";"); + } + } + + if (cssVals.Any()) + attrs.Add("style='" + HttpUtility.HtmlAttributeEncode(string.Join(" ", cssVals)) + "'"); + } + + return new HtmlString(string.Join(" ", attrs)); + } +} diff --git a/src/TestSite.11/Views/Partials/grid/bootstrap3.cshtml b/src/TestSite.11/Views/Partials/grid/bootstrap3.cshtml new file mode 100644 index 0000000..8863788 --- /dev/null +++ b/src/TestSite.11/Views/Partials/grid/bootstrap3.cshtml @@ -0,0 +1,112 @@ +@using System.Web +@using Microsoft.AspNetCore.Html +@using Newtonsoft.Json.Linq +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +@if (Model is JObject && Model?.sections is not null) +{ + var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1; + +
+ @if (oneColumn) + { + foreach (var section in Model.sections) + { +
+ @foreach (var row in section.rows) + { + renderRow(row, true); + } +
+ } + } + else + { +
+
+ @foreach (var sec in Model.sections) + { +
+
+ @foreach (var row in sec.rows) + { + renderRow(row, false); + } +
+
+ } +
+
+ } +
+} + +@functions{ + + private async Task renderRow(dynamic row, bool singleColumn) + { +
+ @if (singleColumn) { + @:
+ } +
+ @foreach (var area in row.areas) + { +
+
+ @foreach (var control in area.controls) + { + if (control?.editor?.view != null) + { + @await Html.PartialAsync("grid/editors/base", (object)control) + } + } +
+
+ } +
+ @if (singleColumn) { + @:
+ } +
+ } + +} + +@functions{ + + public static HtmlString RenderElementAttributes(dynamic contentItem) + { + var attrs = new List(); + JObject cfg = contentItem.config; + + if (cfg != null) + { + foreach (JProperty property in cfg.Properties()) + { + var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString()); + attrs.Add(property.Name + "=\"" + propertyValue + "\""); + } + } + + JObject style = contentItem.styles; + + if (style != null) + { + var cssVals = new List(); + foreach (JProperty property in style.Properties()) + { + var propertyValue = property.Value.ToString(); + if (string.IsNullOrWhiteSpace(propertyValue) == false) + { + cssVals.Add(property.Name + ":" + propertyValue + ";"); + } + } + + if (cssVals.Any()) + attrs.Add("style=\"" + HttpUtility.HtmlAttributeEncode(string.Join(" ", cssVals)) + "\""); + } + + return new HtmlString(string.Join(" ", attrs)); + } +} diff --git a/src/TestSite.11/Views/Partials/grid/editors/base.cshtml b/src/TestSite.11/Views/Partials/grid/editors/base.cshtml new file mode 100644 index 0000000..e40543b --- /dev/null +++ b/src/TestSite.11/Views/Partials/grid/editors/base.cshtml @@ -0,0 +1,27 @@ +@model dynamic + +@try +{ + string editor = EditorView(Model); + @await Html.PartialAsync(editor, Model as object) +} +catch (Exception ex) +{ +
@ex.ToString()
+} + +@functions{ + + public static string EditorView(dynamic contentItem) + { + string view = contentItem.editor.render != null ? contentItem.editor.render.ToString() : contentItem.editor.view.ToString(); + view = view.Replace(".html", ".cshtml"); + + if (!view.Contains("/")) + { + view = "grid/editors/" + view; + } + + return view; + } +} diff --git a/src/TestSite.11/Views/Partials/grid/editors/embed.cshtml b/src/TestSite.11/Views/Partials/grid/editors/embed.cshtml new file mode 100644 index 0000000..74c8fe2 --- /dev/null +++ b/src/TestSite.11/Views/Partials/grid/editors/embed.cshtml @@ -0,0 +1,11 @@ +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +@if (Model is not null) +{ + string embedValue = Convert.ToString(Model.value); + embedValue = embedValue.DetectIsJson() ? Model.value.preview : Model.value; + +
+ @Html.Raw(embedValue) +
+} diff --git a/src/TestSite.11/Views/Partials/grid/editors/macro.cshtml b/src/TestSite.11/Views/Partials/grid/editors/macro.cshtml new file mode 100644 index 0000000..a4450d1 --- /dev/null +++ b/src/TestSite.11/Views/Partials/grid/editors/macro.cshtml @@ -0,0 +1,15 @@ +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +@if (Model?.value is not null) +{ + string macroAlias = Model.value.macroAlias.ToString(); + var parameters = new Dictionary(); + foreach (var mpd in Model.value.macroParamsDictionary) + { + parameters.Add(mpd.Name, mpd.Value); + } + + + @await Umbraco.RenderMacroAsync(macroAlias, parameters) + +} diff --git a/src/TestSite.11/Views/Partials/grid/editors/media.cshtml b/src/TestSite.11/Views/Partials/grid/editors/media.cshtml new file mode 100644 index 0000000..bc3b111 --- /dev/null +++ b/src/TestSite.11/Views/Partials/grid/editors/media.cshtml @@ -0,0 +1,64 @@ +@model dynamic +@using Umbraco.Cms.Core.Media +@using Umbraco.Cms.Core.PropertyEditors.ValueConverters +@inject IImageUrlGenerator ImageUrlGenerator + +@if (Model?.value is not null) +{ + var url = Model.value.image; + + if (Model.editor.config != null && Model.editor.config.size != null) + { + if (Model.value.coordinates != null) + { + url = ImageCropperTemplateCoreExtensions.GetCropUrl( + (string)url, + ImageUrlGenerator, + width: (int)Model.editor.config.size.width, + height: (int)Model.editor.config.size.height, + cropAlias: "default", + cropDataSet: new ImageCropperValue + { + Crops = new[] + { + new ImageCropperValue.ImageCropperCrop + { + Alias = "default", + Coordinates = new ImageCropperValue.ImageCropperCropCoordinates + { + X1 = (decimal)Model.value.coordinates.x1, + Y1 = (decimal)Model.value.coordinates.y1, + X2 = (decimal)Model.value.coordinates.x2, + Y2 = (decimal)Model.value.coordinates.y2 + } + } + } + }); + } + else + { + url = ImageCropperTemplateCoreExtensions.GetCropUrl( + (string)url, + ImageUrlGenerator, + width: (int)Model.editor.config.size.width, + height: (int)Model.editor.config.size.height, + cropDataSet: new ImageCropperValue + { + FocalPoint = new ImageCropperValue.ImageCropperFocalPoint + { + Top = Model.value.focalPoint == null ? 0.5m : Model.value.focalPoint.top, + Left = Model.value.focalPoint == null ? 0.5m : Model.value.focalPoint.left + } + }); + } + } + + var altText = Model.value.altText ?? Model.value.caption ?? string.Empty; + + @altText + + if (Model.value.caption != null) + { +

@Model.value.caption

+ } +} diff --git a/src/TestSite.11/Views/Partials/grid/editors/rte.cshtml b/src/TestSite.11/Views/Partials/grid/editors/rte.cshtml new file mode 100644 index 0000000..9445666 --- /dev/null +++ b/src/TestSite.11/Views/Partials/grid/editors/rte.cshtml @@ -0,0 +1,13 @@ +@using Umbraco.Cms.Core.Templates +@model dynamic +@inject HtmlLocalLinkParser HtmlLocalLinkParser; +@inject HtmlUrlParser HtmlUrlParser; +@inject HtmlImageSourceParser HtmlImageSourceParser; + +@{ + var value = HtmlLocalLinkParser.EnsureInternalLinks(Model?.value.ToString()); + value = HtmlUrlParser.EnsureUrls(value); + value = HtmlImageSourceParser.EnsureImageSources(value); +} + +@Html.Raw(value) diff --git a/src/TestSite.11/Views/Partials/grid/editors/textstring.cshtml b/src/TestSite.11/Views/Partials/grid/editors/textstring.cshtml new file mode 100644 index 0000000..e6b9352 --- /dev/null +++ b/src/TestSite.11/Views/Partials/grid/editors/textstring.cshtml @@ -0,0 +1,22 @@ +@model dynamic + +@if (Model?.editor.config.markup is not null) +{ + string markup = Model.editor.config.markup.ToString(); + markup = markup.Replace("#value#", Html.ReplaceLineBreaks((string)Model.value.ToString()).ToString()); + + if (Model.editor.config.style != null) + { + markup = markup.Replace("#style#", Model.editor.config.style.ToString()); + } + + + @Html.Raw(markup) + +} +else +{ + +
@Model?.value
+
+} diff --git a/src/TestSite.11/Views/_ViewImports.cshtml b/src/TestSite.11/Views/_ViewImports.cshtml new file mode 100644 index 0000000..097d0db --- /dev/null +++ b/src/TestSite.11/Views/_ViewImports.cshtml @@ -0,0 +1,9 @@ +@using Umbraco.Extensions +@using TestSite.Eleven +@using Umbraco.Cms.Web.Common.PublishedModels +@using Umbraco.Cms.Web.Common.Views +@using Umbraco.Cms.Core.Models.PublishedContent +@using Microsoft.AspNetCore.Html +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, Smidge +@inject Smidge.SmidgeHelper SmidgeHelper diff --git a/src/TestSite.11/appsettings.Development.json b/src/TestSite.11/appsettings.Development.json new file mode 100644 index 0000000..b33453b --- /dev/null +++ b/src/TestSite.11/appsettings.Development.json @@ -0,0 +1,44 @@ +{ + "$schema": "appsettings-schema.json", + "Serilog": { + "MinimumLevel": { + "Default": "Information" + }, + "WriteTo": [ + { + "Name": "Async", + "Args": { + "configure": [ + { + "Name": "Console" + } + ] + } + } + ] + }, + "ConnectionStrings": { + "umbracoDbDSN": "Data Source=|DataDirectory|/Umbraco.sqlite.db;Cache=Shared;Foreign Keys=True;Pooling=True", + "umbracoDbDSN_ProviderName": "Microsoft.Data.Sqlite" + }, + "Umbraco": { + "CMS": { + "Unattended": { + "InstallUnattended": true, + "UnattendedUserName": "Administrator", + "UnattendedUserEmail": "admin@example.com", + "UnattendedUserPassword": "1234567890" + }, + "Content": { + "MacroErrors": "Throw" + }, + "Hosting": { + "Debug": true + }, + "RuntimeMinification": { + "UseInMemoryCache": true, + "CacheBuster": "Timestamp" + } + } + } +} diff --git a/src/TestSite.11/appsettings.json b/src/TestSite.11/appsettings.json new file mode 100644 index 0000000..78953b0 --- /dev/null +++ b/src/TestSite.11/appsettings.json @@ -0,0 +1,26 @@ +{ + "$schema": "appsettings-schema.json", + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information", + "System": "Warning" + } + } + }, + "Umbraco": { + "CMS": { + "Global": { + "SanitizeTinyMce": true + }, + "Content": { + "AllowEditInvariantFromNonDefault": true, + "ContentVersionCleanupPolicy": { + "EnableCleanup": true + } + } + } + } +} diff --git a/src/TestSite.11/wwwroot/favicon.ico b/src/TestSite.11/wwwroot/favicon.ico new file mode 100644 index 0000000..c0749dd Binary files /dev/null and b/src/TestSite.11/wwwroot/favicon.ico differ diff --git a/src/TestSite.12/.gitignore b/src/TestSite.12/.gitignore new file mode 100644 index 0000000..8bcfaae --- /dev/null +++ b/src/TestSite.12/.gitignore @@ -0,0 +1,479 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# JetBrains Rider +.idea/ +*.sln.iml + +## +## Visual Studio Code +## +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +## +## Umbraco CMS +## + +# JSON schema files for appsettings.json +appsettings-schema.json +appsettings-schema.*.json + +# Packages created from the backoffice (package.xml/package.zip) +/umbraco/Data/CreatedPackages/ + +# Temp folder containing Examine indexes, NuCache, MediaCache, etc. +/umbraco/Data/TEMP/ + +# SQLite database files +/umbraco/Data/*.sqlite.db +/umbraco/Data/*.sqlite.db-shm +/umbraco/Data/*.sqlite.db-wal + +# Log files +/umbraco/Logs/ + +# Media files +/wwwroot/media/ diff --git a/src/TestSite.12/Dashboards/BasicDashboard.cs b/src/TestSite.12/Dashboards/BasicDashboard.cs new file mode 100644 index 0000000..4cb768c --- /dev/null +++ b/src/TestSite.12/Dashboards/BasicDashboard.cs @@ -0,0 +1,8 @@ +using Umbraco.Community.SimpleDashboards.Core; + +namespace TestSite.Twelve.Dashboards; + +public class BasicDashboard : SimpleDashboard +{ + public BasicDashboard() { } +} diff --git a/src/TestSite.12/Dashboards/ExampleDashboard.cs b/src/TestSite.12/Dashboards/ExampleDashboard.cs new file mode 100644 index 0000000..f174d3a --- /dev/null +++ b/src/TestSite.12/Dashboards/ExampleDashboard.cs @@ -0,0 +1,29 @@ +using jcdcdev.Umbraco.Core.AccessRule; +using Umbraco.Community.SimpleDashboards.Core; + +namespace TestSite.Twelve.Dashboards; + +// Control order of where dashboard shows +[Umbraco.Cms.Core.Composing.Weight(-100)] +public class ExampleDashboard : SimpleDashboard +{ + public ExampleDashboard() + { + // Set dashboard name + SetName("Example Dashboard Name (default)"); + // Set culture specific dashboard name + SetName("Example Dashboard Name (en-GB)", "en-GB"); + + // Show dashboard in the Media & Content sections + AddSection(Umbraco.Cms.Core.Constants.Applications.Media); + AddSection(Umbraco.Cms.Core.Constants.Applications.Content); + + // Allow Editors + AddAccessRule(SimpleAccessRule.AllowEditorGroup); + + // Allow custom User Group + Allow(x=>x.UserGroup("myGroup")); + // Deny custom User Group + Deny(x=>x.UserGroup("myOtherGroup")); + } +} diff --git a/src/TestSite.12/Dashboards/NoViewDashboard.cs b/src/TestSite.12/Dashboards/NoViewDashboard.cs new file mode 100644 index 0000000..25ce42f --- /dev/null +++ b/src/TestSite.12/Dashboards/NoViewDashboard.cs @@ -0,0 +1,7 @@ +using Umbraco.Community.SimpleDashboards.Core; + +namespace TestSite.Twelve.Dashboards; + +public class NoViewDashboard : SimpleDashboard +{ +} diff --git a/src/TestSite.12/Program.cs b/src/TestSite.12/Program.cs new file mode 100644 index 0000000..d14b758 --- /dev/null +++ b/src/TestSite.12/Program.cs @@ -0,0 +1,22 @@ +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Hosting; + +namespace TestSite.Twelve +{ + public class Program + { + public static void Main(string[] args) + => CreateHostBuilder(args) + .Build() + .Run(); + + public static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .ConfigureUmbracoDefaults() + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStaticWebAssets(); + webBuilder.UseStartup(); + }); + } +} diff --git a/src/TestSite.12/Properties/launchSettings.json b/src/TestSite.12/Properties/launchSettings.json new file mode 100644 index 0000000..083f2e5 --- /dev/null +++ b/src/TestSite.12/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:16149", + "sslPort": 44344 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Umbraco.Web.UI": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:44344;http://localhost:16149", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/TestSite.12/Startup.cs b/src/TestSite.12/Startup.cs new file mode 100644 index 0000000..69beae8 --- /dev/null +++ b/src/TestSite.12/Startup.cs @@ -0,0 +1,75 @@ +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Umbraco.Cms.Core.DependencyInjection; +using Umbraco.Extensions; + +namespace TestSite.Twelve +{ + public class Startup + { + private readonly IWebHostEnvironment _env; + private readonly IConfiguration _config; + + /// + /// Initializes a new instance of the class. + /// + /// The web hosting environment. + /// The configuration. + /// + /// Only a few services are possible to be injected here https://github.com/dotnet/aspnetcore/issues/9337. + /// + public Startup(IWebHostEnvironment webHostEnvironment, IConfiguration config) + { + _env = webHostEnvironment ?? throw new ArgumentNullException(nameof(webHostEnvironment)); + _config = config ?? throw new ArgumentNullException(nameof(config)); + } + + /// + /// Configures the services. + /// + /// The services. + /// + /// This method gets called by the runtime. Use this method to add services to the container. + /// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940. + /// + public void ConfigureServices(IServiceCollection services) + { + services.AddUmbraco(_env, _config) + .AddBackOffice() + .AddWebsite() + .AddDeliveryApi() + .AddComposers() + .Build(); + } + + /// + /// Configures the application. + /// + /// The application builder. + /// The web hosting environment. + public void Configure(IApplicationBuilder app, IWebHostEnvironment env) + { + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseUmbraco() + .WithMiddleware(u => + { + u.UseBackOffice(); + u.UseWebsite(); + }) + .WithEndpoints(u => + { + u.UseInstallerEndpoints(); + u.UseBackOfficeEndpoints(); + u.UseWebsiteEndpoints(); + }); + } + } +} diff --git a/src/TestSite.12/TestSite.12.csproj b/src/TestSite.12/TestSite.12.csproj new file mode 100644 index 0000000..f39ceda --- /dev/null +++ b/src/TestSite.12/TestSite.12.csproj @@ -0,0 +1,42 @@ + + + net7.0 + enable + enable + TestSite.Twelve + + + + + + + + + + + + + + + + appsettings.json + + + + + + + + + + + true + + + + + false + false + + + diff --git a/src/TestSite.12/Views/Components/ExampleDashboardAsyncViewComponent.cs b/src/TestSite.12/Views/Components/ExampleDashboardAsyncViewComponent.cs new file mode 100644 index 0000000..ad205ec --- /dev/null +++ b/src/TestSite.12/Views/Components/ExampleDashboardAsyncViewComponent.cs @@ -0,0 +1,16 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Umbraco.Community.SimpleDashboards.Web; + +namespace TestSite.Twelve.Views.Components; + +public class ExampleDashboardAsyncViewComponent : DashboardAsyncViewComponent +{ + public override async Task InvokeAsync(DashboardModel model) + { + // Simulate async workload + await Task.Delay(TimeSpan.FromMilliseconds(1)); + return Content($"Hello {model.Dashboard.Alias}"); + } +} diff --git a/src/TestSite.12/Views/Components/ExampleDashboardViewComponent.cs b/src/TestSite.12/Views/Components/ExampleDashboardViewComponent.cs new file mode 100644 index 0000000..0489ba0 --- /dev/null +++ b/src/TestSite.12/Views/Components/ExampleDashboardViewComponent.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc; +using Umbraco.Community.SimpleDashboards.Web; + +namespace TestSite.Twelve.Views.Components; + +public class ExampleDashboardViewComponent : DashboardViewComponent +{ + public override IViewComponentResult Invoke(DashboardModel model) + { + return Content($"Hello {model.Dashboard.Alias}"); + } +} diff --git a/src/TestSite.12/Views/Dashboards/Basic.cshtml b/src/TestSite.12/Views/Dashboards/Basic.cshtml new file mode 100644 index 0000000..850488f --- /dev/null +++ b/src/TestSite.12/Views/Dashboards/Basic.cshtml @@ -0,0 +1,4 @@ +@inherits Umbraco.Community.SimpleDashboards.Web.DashboardViewPage + +

Hello Umbraco

+

My Dashboard is: @Model.Dashboard.Alias

diff --git a/src/TestSite.12/Views/Partials/blockgrid/area.cshtml b/src/TestSite.12/Views/Partials/blockgrid/area.cshtml new file mode 100644 index 0000000..3614847 --- /dev/null +++ b/src/TestSite.12/Views/Partials/blockgrid/area.cshtml @@ -0,0 +1,10 @@ +@using Umbraco.Extensions +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +
+ @await Html.GetBlockGridItemsHtmlAsync(Model) +
diff --git a/src/TestSite.12/Views/Partials/blockgrid/areas.cshtml b/src/TestSite.12/Views/Partials/blockgrid/areas.cshtml new file mode 100644 index 0000000..30f987c --- /dev/null +++ b/src/TestSite.12/Views/Partials/blockgrid/areas.cshtml @@ -0,0 +1,13 @@ +@using Umbraco.Extensions +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage +@{ + if (Model?.Areas.Any() != true) { return; } +} + +
+ @foreach (var area in Model.Areas) + { + @await Html.GetBlockGridItemAreaHtmlAsync(area) + } +
diff --git a/src/TestSite.12/Views/Partials/blockgrid/default.cshtml b/src/TestSite.12/Views/Partials/blockgrid/default.cshtml new file mode 100644 index 0000000..e25839e --- /dev/null +++ b/src/TestSite.12/Views/Partials/blockgrid/default.cshtml @@ -0,0 +1,11 @@ +@using Umbraco.Extensions +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage +@{ + if (Model?.Any() != true) { return; } +} + +
+ @await Html.GetBlockGridItemsHtmlAsync(Model) +
diff --git a/src/TestSite.12/Views/Partials/blockgrid/items.cshtml b/src/TestSite.12/Views/Partials/blockgrid/items.cshtml new file mode 100644 index 0000000..2703fa5 --- /dev/null +++ b/src/TestSite.12/Views/Partials/blockgrid/items.cshtml @@ -0,0 +1,36 @@ +@using Umbraco.Cms.Core.Models.Blocks +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage> +@{ + if (Model?.Any() != true) { return; } +} + +
+ @foreach (var item in Model) + { + +
+ @{ + var partialViewName = "blockgrid/Components/" + item.Content.ContentType.Alias; + try + { + @await Html.PartialAsync(partialViewName, item) + } + catch (InvalidOperationException) + { +

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

+ } + } +
+ } +
diff --git a/src/TestSite.12/Views/Partials/blocklist/default.cshtml b/src/TestSite.12/Views/Partials/blocklist/default.cshtml new file mode 100644 index 0000000..accca2e --- /dev/null +++ b/src/TestSite.12/Views/Partials/blocklist/default.cshtml @@ -0,0 +1,13 @@ +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage +@{ + if (Model?.Any() != true) { return; } +} +
+ @foreach (var block in Model) + { + if (block?.ContentUdi == null) { continue; } + var data = block.Content; + + @await Html.PartialAsync("blocklist/Components/" + data.ContentType.Alias, block) + } +
diff --git a/src/TestSite.12/Views/Partials/grid/bootstrap3-fluid.cshtml b/src/TestSite.12/Views/Partials/grid/bootstrap3-fluid.cshtml new file mode 100644 index 0000000..b92734e --- /dev/null +++ b/src/TestSite.12/Views/Partials/grid/bootstrap3-fluid.cshtml @@ -0,0 +1,106 @@ +@using System.Web +@using Microsoft.AspNetCore.Html +@using Newtonsoft.Json.Linq +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +@* + Razor helpers located at the bottom of this file +*@ + +@if (Model is JObject && Model?.sections is not null) +{ + var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1; + +
+ @if (oneColumn) + { + foreach (var section in Model.sections) + { +
+ @foreach (var row in section.rows) + { + renderRow(row); + } +
+ } + } + else + { +
+ @foreach (var sec in Model.sections) + { +
+
+ @foreach (var row in sec.rows) + { + renderRow(row); + } +
+
+ } +
+ } +
+} + +@functions{ + + private async Task renderRow(dynamic row) + { +
+
+ @foreach (var area in row.areas) + { +
+
+ @foreach (var control in area.controls) + { + if (control?.editor?.view != null) + { + @await Html.PartialAsync("grid/editors/base", (object)control) + } + } +
+
+ } +
+
+ } +} + +@functions{ + + public static HtmlString RenderElementAttributes(dynamic contentItem) + { + var attrs = new List(); + JObject cfg = contentItem.config; + + if (cfg != null) + { + foreach (JProperty property in cfg.Properties()) + { + var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString()); + attrs.Add(property.Name + "=\"" + propertyValue + "\""); + } + } + + JObject style = contentItem.styles; + + if (style != null) { + var cssVals = new List(); + foreach (JProperty property in style.Properties()) + { + var propertyValue = property.Value.ToString(); + if (string.IsNullOrWhiteSpace(propertyValue) == false) + { + cssVals.Add(property.Name + ":" + propertyValue + ";"); + } + } + + if (cssVals.Any()) + attrs.Add("style='" + HttpUtility.HtmlAttributeEncode(string.Join(" ", cssVals)) + "'"); + } + + return new HtmlString(string.Join(" ", attrs)); + } +} diff --git a/src/TestSite.12/Views/Partials/grid/bootstrap3.cshtml b/src/TestSite.12/Views/Partials/grid/bootstrap3.cshtml new file mode 100644 index 0000000..8863788 --- /dev/null +++ b/src/TestSite.12/Views/Partials/grid/bootstrap3.cshtml @@ -0,0 +1,112 @@ +@using System.Web +@using Microsoft.AspNetCore.Html +@using Newtonsoft.Json.Linq +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +@if (Model is JObject && Model?.sections is not null) +{ + var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1; + +
+ @if (oneColumn) + { + foreach (var section in Model.sections) + { +
+ @foreach (var row in section.rows) + { + renderRow(row, true); + } +
+ } + } + else + { +
+
+ @foreach (var sec in Model.sections) + { +
+
+ @foreach (var row in sec.rows) + { + renderRow(row, false); + } +
+
+ } +
+
+ } +
+} + +@functions{ + + private async Task renderRow(dynamic row, bool singleColumn) + { +
+ @if (singleColumn) { + @:
+ } +
+ @foreach (var area in row.areas) + { +
+
+ @foreach (var control in area.controls) + { + if (control?.editor?.view != null) + { + @await Html.PartialAsync("grid/editors/base", (object)control) + } + } +
+
+ } +
+ @if (singleColumn) { + @:
+ } +
+ } + +} + +@functions{ + + public static HtmlString RenderElementAttributes(dynamic contentItem) + { + var attrs = new List(); + JObject cfg = contentItem.config; + + if (cfg != null) + { + foreach (JProperty property in cfg.Properties()) + { + var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString()); + attrs.Add(property.Name + "=\"" + propertyValue + "\""); + } + } + + JObject style = contentItem.styles; + + if (style != null) + { + var cssVals = new List(); + foreach (JProperty property in style.Properties()) + { + var propertyValue = property.Value.ToString(); + if (string.IsNullOrWhiteSpace(propertyValue) == false) + { + cssVals.Add(property.Name + ":" + propertyValue + ";"); + } + } + + if (cssVals.Any()) + attrs.Add("style=\"" + HttpUtility.HtmlAttributeEncode(string.Join(" ", cssVals)) + "\""); + } + + return new HtmlString(string.Join(" ", attrs)); + } +} diff --git a/src/TestSite.12/Views/Partials/grid/editors/base.cshtml b/src/TestSite.12/Views/Partials/grid/editors/base.cshtml new file mode 100644 index 0000000..e40543b --- /dev/null +++ b/src/TestSite.12/Views/Partials/grid/editors/base.cshtml @@ -0,0 +1,27 @@ +@model dynamic + +@try +{ + string editor = EditorView(Model); + @await Html.PartialAsync(editor, Model as object) +} +catch (Exception ex) +{ +
@ex.ToString()
+} + +@functions{ + + public static string EditorView(dynamic contentItem) + { + string view = contentItem.editor.render != null ? contentItem.editor.render.ToString() : contentItem.editor.view.ToString(); + view = view.Replace(".html", ".cshtml"); + + if (!view.Contains("/")) + { + view = "grid/editors/" + view; + } + + return view; + } +} diff --git a/src/TestSite.12/Views/Partials/grid/editors/embed.cshtml b/src/TestSite.12/Views/Partials/grid/editors/embed.cshtml new file mode 100644 index 0000000..74c8fe2 --- /dev/null +++ b/src/TestSite.12/Views/Partials/grid/editors/embed.cshtml @@ -0,0 +1,11 @@ +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +@if (Model is not null) +{ + string embedValue = Convert.ToString(Model.value); + embedValue = embedValue.DetectIsJson() ? Model.value.preview : Model.value; + +
+ @Html.Raw(embedValue) +
+} diff --git a/src/TestSite.12/Views/Partials/grid/editors/macro.cshtml b/src/TestSite.12/Views/Partials/grid/editors/macro.cshtml new file mode 100644 index 0000000..a4450d1 --- /dev/null +++ b/src/TestSite.12/Views/Partials/grid/editors/macro.cshtml @@ -0,0 +1,15 @@ +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +@if (Model?.value is not null) +{ + string macroAlias = Model.value.macroAlias.ToString(); + var parameters = new Dictionary(); + foreach (var mpd in Model.value.macroParamsDictionary) + { + parameters.Add(mpd.Name, mpd.Value); + } + + + @await Umbraco.RenderMacroAsync(macroAlias, parameters) + +} diff --git a/src/TestSite.12/Views/Partials/grid/editors/media.cshtml b/src/TestSite.12/Views/Partials/grid/editors/media.cshtml new file mode 100644 index 0000000..bc3b111 --- /dev/null +++ b/src/TestSite.12/Views/Partials/grid/editors/media.cshtml @@ -0,0 +1,64 @@ +@model dynamic +@using Umbraco.Cms.Core.Media +@using Umbraco.Cms.Core.PropertyEditors.ValueConverters +@inject IImageUrlGenerator ImageUrlGenerator + +@if (Model?.value is not null) +{ + var url = Model.value.image; + + if (Model.editor.config != null && Model.editor.config.size != null) + { + if (Model.value.coordinates != null) + { + url = ImageCropperTemplateCoreExtensions.GetCropUrl( + (string)url, + ImageUrlGenerator, + width: (int)Model.editor.config.size.width, + height: (int)Model.editor.config.size.height, + cropAlias: "default", + cropDataSet: new ImageCropperValue + { + Crops = new[] + { + new ImageCropperValue.ImageCropperCrop + { + Alias = "default", + Coordinates = new ImageCropperValue.ImageCropperCropCoordinates + { + X1 = (decimal)Model.value.coordinates.x1, + Y1 = (decimal)Model.value.coordinates.y1, + X2 = (decimal)Model.value.coordinates.x2, + Y2 = (decimal)Model.value.coordinates.y2 + } + } + } + }); + } + else + { + url = ImageCropperTemplateCoreExtensions.GetCropUrl( + (string)url, + ImageUrlGenerator, + width: (int)Model.editor.config.size.width, + height: (int)Model.editor.config.size.height, + cropDataSet: new ImageCropperValue + { + FocalPoint = new ImageCropperValue.ImageCropperFocalPoint + { + Top = Model.value.focalPoint == null ? 0.5m : Model.value.focalPoint.top, + Left = Model.value.focalPoint == null ? 0.5m : Model.value.focalPoint.left + } + }); + } + } + + var altText = Model.value.altText ?? Model.value.caption ?? string.Empty; + + @altText + + if (Model.value.caption != null) + { +

@Model.value.caption

+ } +} diff --git a/src/TestSite.12/Views/Partials/grid/editors/rte.cshtml b/src/TestSite.12/Views/Partials/grid/editors/rte.cshtml new file mode 100644 index 0000000..9445666 --- /dev/null +++ b/src/TestSite.12/Views/Partials/grid/editors/rte.cshtml @@ -0,0 +1,13 @@ +@using Umbraco.Cms.Core.Templates +@model dynamic +@inject HtmlLocalLinkParser HtmlLocalLinkParser; +@inject HtmlUrlParser HtmlUrlParser; +@inject HtmlImageSourceParser HtmlImageSourceParser; + +@{ + var value = HtmlLocalLinkParser.EnsureInternalLinks(Model?.value.ToString()); + value = HtmlUrlParser.EnsureUrls(value); + value = HtmlImageSourceParser.EnsureImageSources(value); +} + +@Html.Raw(value) diff --git a/src/TestSite.12/Views/Partials/grid/editors/textstring.cshtml b/src/TestSite.12/Views/Partials/grid/editors/textstring.cshtml new file mode 100644 index 0000000..e6b9352 --- /dev/null +++ b/src/TestSite.12/Views/Partials/grid/editors/textstring.cshtml @@ -0,0 +1,22 @@ +@model dynamic + +@if (Model?.editor.config.markup is not null) +{ + string markup = Model.editor.config.markup.ToString(); + markup = markup.Replace("#value#", Html.ReplaceLineBreaks((string)Model.value.ToString()).ToString()); + + if (Model.editor.config.style != null) + { + markup = markup.Replace("#style#", Model.editor.config.style.ToString()); + } + + + @Html.Raw(markup) + +} +else +{ + +
@Model?.value
+
+} diff --git a/src/TestSite.12/Views/_ViewImports.cshtml b/src/TestSite.12/Views/_ViewImports.cshtml new file mode 100644 index 0000000..45d51e5 --- /dev/null +++ b/src/TestSite.12/Views/_ViewImports.cshtml @@ -0,0 +1,9 @@ +@using Umbraco.Extensions +@using TestSite.Twelve +@using Umbraco.Cms.Web.Common.PublishedModels +@using Umbraco.Cms.Web.Common.Views +@using Umbraco.Cms.Core.Models.PublishedContent +@using Microsoft.AspNetCore.Html +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, Smidge +@inject Smidge.SmidgeHelper SmidgeHelper diff --git a/src/TestSite.12/appsettings.Development.json b/src/TestSite.12/appsettings.Development.json new file mode 100644 index 0000000..b33453b --- /dev/null +++ b/src/TestSite.12/appsettings.Development.json @@ -0,0 +1,44 @@ +{ + "$schema": "appsettings-schema.json", + "Serilog": { + "MinimumLevel": { + "Default": "Information" + }, + "WriteTo": [ + { + "Name": "Async", + "Args": { + "configure": [ + { + "Name": "Console" + } + ] + } + } + ] + }, + "ConnectionStrings": { + "umbracoDbDSN": "Data Source=|DataDirectory|/Umbraco.sqlite.db;Cache=Shared;Foreign Keys=True;Pooling=True", + "umbracoDbDSN_ProviderName": "Microsoft.Data.Sqlite" + }, + "Umbraco": { + "CMS": { + "Unattended": { + "InstallUnattended": true, + "UnattendedUserName": "Administrator", + "UnattendedUserEmail": "admin@example.com", + "UnattendedUserPassword": "1234567890" + }, + "Content": { + "MacroErrors": "Throw" + }, + "Hosting": { + "Debug": true + }, + "RuntimeMinification": { + "UseInMemoryCache": true, + "CacheBuster": "Timestamp" + } + } + } +} diff --git a/src/TestSite.12/appsettings.json b/src/TestSite.12/appsettings.json new file mode 100644 index 0000000..78953b0 --- /dev/null +++ b/src/TestSite.12/appsettings.json @@ -0,0 +1,26 @@ +{ + "$schema": "appsettings-schema.json", + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information", + "System": "Warning" + } + } + }, + "Umbraco": { + "CMS": { + "Global": { + "SanitizeTinyMce": true + }, + "Content": { + "AllowEditInvariantFromNonDefault": true, + "ContentVersionCleanupPolicy": { + "EnableCleanup": true + } + } + } + } +} diff --git a/src/TestSite.12/wwwroot/favicon.ico b/src/TestSite.12/wwwroot/favicon.ico new file mode 100644 index 0000000..c0749dd Binary files /dev/null and b/src/TestSite.12/wwwroot/favicon.ico differ diff --git a/src/TestSite.13/.gitignore b/src/TestSite.13/.gitignore new file mode 100644 index 0000000..8bcfaae --- /dev/null +++ b/src/TestSite.13/.gitignore @@ -0,0 +1,479 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# Mac bundle stuff +*.dmg +*.app + +# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# JetBrains Rider +.idea/ +*.sln.iml + +## +## Visual Studio Code +## +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json + +## +## Umbraco CMS +## + +# JSON schema files for appsettings.json +appsettings-schema.json +appsettings-schema.*.json + +# Packages created from the backoffice (package.xml/package.zip) +/umbraco/Data/CreatedPackages/ + +# Temp folder containing Examine indexes, NuCache, MediaCache, etc. +/umbraco/Data/TEMP/ + +# SQLite database files +/umbraco/Data/*.sqlite.db +/umbraco/Data/*.sqlite.db-shm +/umbraco/Data/*.sqlite.db-wal + +# Log files +/umbraco/Logs/ + +# Media files +/wwwroot/media/ diff --git a/src/TestSite.13/Dashboards/BasicDashboard.cs b/src/TestSite.13/Dashboards/BasicDashboard.cs new file mode 100644 index 0000000..fc742e3 --- /dev/null +++ b/src/TestSite.13/Dashboards/BasicDashboard.cs @@ -0,0 +1,8 @@ +using Umbraco.Community.SimpleDashboards.Core; + +namespace TestSite.Thirteen.Dashboards; + +public class BasicDashboard : SimpleDashboard +{ + public BasicDashboard() { } +} diff --git a/src/TestSite.13/Dashboards/ExampleDashboard.cs b/src/TestSite.13/Dashboards/ExampleDashboard.cs new file mode 100644 index 0000000..ac3777a --- /dev/null +++ b/src/TestSite.13/Dashboards/ExampleDashboard.cs @@ -0,0 +1,29 @@ +using jcdcdev.Umbraco.Core.AccessRule; +using Umbraco.Community.SimpleDashboards.Core; + +namespace TestSite.Thirteen.Dashboards; + +// Control order of where dashboard shows +[Umbraco.Cms.Core.Composing.Weight(-100)] +public class ExampleDashboard : SimpleDashboard +{ + public ExampleDashboard() + { + // Set dashboard name + SetName("Example Dashboard Name (default)"); + // Set culture specific dashboard name + SetName("Example Dashboard Name (en-GB)", "en-GB"); + + // Show dashboard in the Media & Content sections + AddSection(Umbraco.Cms.Core.Constants.Applications.Media); + AddSection(Umbraco.Cms.Core.Constants.Applications.Content); + + // Allow Editors + AddAccessRule(SimpleAccessRule.AllowEditorGroup); + + // Allow custom User Group + Allow(x=>x.UserGroup("myGroup")); + // Deny custom User Group + Deny(x=>x.UserGroup("myOtherGroup")); + } +} diff --git a/src/TestSite.13/Dashboards/NoViewDashboard.cs b/src/TestSite.13/Dashboards/NoViewDashboard.cs new file mode 100644 index 0000000..956896b --- /dev/null +++ b/src/TestSite.13/Dashboards/NoViewDashboard.cs @@ -0,0 +1,7 @@ +using Umbraco.Community.SimpleDashboards.Core; + +namespace TestSite.Thirteen.Dashboards; + +public class NoViewDashboard : SimpleDashboard +{ +} diff --git a/src/TestSite.13/Program.cs b/src/TestSite.13/Program.cs new file mode 100644 index 0000000..86de348 --- /dev/null +++ b/src/TestSite.13/Program.cs @@ -0,0 +1,28 @@ +WebApplicationBuilder builder = WebApplication.CreateBuilder(args); + +builder.CreateUmbracoBuilder() + .AddBackOffice() + .AddWebsite() + .AddDeliveryApi() + .AddComposers() + .Build(); + +WebApplication app = builder.Build(); + +await app.BootUmbracoAsync(); + + +app.UseUmbraco() + .WithMiddleware(u => + { + u.UseBackOffice(); + u.UseWebsite(); + }) + .WithEndpoints(u => + { + u.UseInstallerEndpoints(); + u.UseBackOfficeEndpoints(); + u.UseWebsiteEndpoints(); + }); + +await app.RunAsync(); diff --git a/src/TestSite.13/Properties/launchSettings.json b/src/TestSite.13/Properties/launchSettings.json new file mode 100644 index 0000000..2aaf199 --- /dev/null +++ b/src/TestSite.13/Properties/launchSettings.json @@ -0,0 +1,29 @@ +{ + "$schema": "https://json.schemastore.org/launchsettings.json", + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:6343", + "sslPort": 44333 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Umbraco.Web.UI": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:44333;http://localhost:6343", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/TestSite.13/TestSite.13.csproj b/src/TestSite.13/TestSite.13.csproj new file mode 100644 index 0000000..b5cec25 --- /dev/null +++ b/src/TestSite.13/TestSite.13.csproj @@ -0,0 +1,40 @@ + + + net8.0 + enable + enable + TestSite.Thirteen + + + + + + + + + + + + + + + appsettings.json + + + + + + + + + + true + + + + + false + false + + + diff --git a/src/Umbraco.Community.SimpleDashboards.TestSite/Views/Components/ExampleDashboardAsyncViewComponent.cs b/src/TestSite.13/Views/Components/ExampleDashboardAsyncViewComponent.cs similarity index 85% rename from src/Umbraco.Community.SimpleDashboards.TestSite/Views/Components/ExampleDashboardAsyncViewComponent.cs rename to src/TestSite.13/Views/Components/ExampleDashboardAsyncViewComponent.cs index 0d08377..2ae1d7a 100644 --- a/src/Umbraco.Community.SimpleDashboards.TestSite/Views/Components/ExampleDashboardAsyncViewComponent.cs +++ b/src/TestSite.13/Views/Components/ExampleDashboardAsyncViewComponent.cs @@ -1,7 +1,7 @@ using Microsoft.AspNetCore.Mvc; using Umbraco.Community.SimpleDashboards.Web; -namespace Umbraco.Community.SimpleDashboards.TestSite.Views.Components; +namespace TestSite.Thirteen.Views.Components; public class ExampleDashboardAsyncViewComponent : DashboardAsyncViewComponent { diff --git a/src/TestSite.13/Views/Components/ExampleDashboardViewComponent.cs b/src/TestSite.13/Views/Components/ExampleDashboardViewComponent.cs new file mode 100644 index 0000000..90c644a --- /dev/null +++ b/src/TestSite.13/Views/Components/ExampleDashboardViewComponent.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc; +using Umbraco.Community.SimpleDashboards.Web; + +namespace TestSite.Thirteen.Views.Components; + +public class ExampleDashboardViewComponent : DashboardViewComponent +{ + public override IViewComponentResult Invoke(DashboardModel model) + { + return Content($"Hello {model.Dashboard.Alias}"); + } +} diff --git a/src/TestSite.13/Views/Dashboards/Basic.cshtml b/src/TestSite.13/Views/Dashboards/Basic.cshtml new file mode 100644 index 0000000..850488f --- /dev/null +++ b/src/TestSite.13/Views/Dashboards/Basic.cshtml @@ -0,0 +1,4 @@ +@inherits Umbraco.Community.SimpleDashboards.Web.DashboardViewPage + +

Hello Umbraco

+

My Dashboard is: @Model.Dashboard.Alias

diff --git a/src/TestSite.13/Views/Partials/blockgrid/area.cshtml b/src/TestSite.13/Views/Partials/blockgrid/area.cshtml new file mode 100644 index 0000000..3614847 --- /dev/null +++ b/src/TestSite.13/Views/Partials/blockgrid/area.cshtml @@ -0,0 +1,10 @@ +@using Umbraco.Extensions +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +
+ @await Html.GetBlockGridItemsHtmlAsync(Model) +
diff --git a/src/TestSite.13/Views/Partials/blockgrid/areas.cshtml b/src/TestSite.13/Views/Partials/blockgrid/areas.cshtml new file mode 100644 index 0000000..30f987c --- /dev/null +++ b/src/TestSite.13/Views/Partials/blockgrid/areas.cshtml @@ -0,0 +1,13 @@ +@using Umbraco.Extensions +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage +@{ + if (Model?.Areas.Any() != true) { return; } +} + +
+ @foreach (var area in Model.Areas) + { + @await Html.GetBlockGridItemAreaHtmlAsync(area) + } +
diff --git a/src/TestSite.13/Views/Partials/blockgrid/default.cshtml b/src/TestSite.13/Views/Partials/blockgrid/default.cshtml new file mode 100644 index 0000000..e25839e --- /dev/null +++ b/src/TestSite.13/Views/Partials/blockgrid/default.cshtml @@ -0,0 +1,11 @@ +@using Umbraco.Extensions +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage +@{ + if (Model?.Any() != true) { return; } +} + +
+ @await Html.GetBlockGridItemsHtmlAsync(Model) +
diff --git a/src/TestSite.13/Views/Partials/blockgrid/items.cshtml b/src/TestSite.13/Views/Partials/blockgrid/items.cshtml new file mode 100644 index 0000000..2703fa5 --- /dev/null +++ b/src/TestSite.13/Views/Partials/blockgrid/items.cshtml @@ -0,0 +1,36 @@ +@using Umbraco.Cms.Core.Models.Blocks +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage> +@{ + if (Model?.Any() != true) { return; } +} + +
+ @foreach (var item in Model) + { + +
+ @{ + var partialViewName = "blockgrid/Components/" + item.Content.ContentType.Alias; + try + { + @await Html.PartialAsync(partialViewName, item) + } + catch (InvalidOperationException) + { +

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

+ } + } +
+ } +
diff --git a/src/TestSite.13/Views/Partials/blocklist/default.cshtml b/src/TestSite.13/Views/Partials/blocklist/default.cshtml new file mode 100644 index 0000000..accca2e --- /dev/null +++ b/src/TestSite.13/Views/Partials/blocklist/default.cshtml @@ -0,0 +1,13 @@ +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage +@{ + if (Model?.Any() != true) { return; } +} +
+ @foreach (var block in Model) + { + if (block?.ContentUdi == null) { continue; } + var data = block.Content; + + @await Html.PartialAsync("blocklist/Components/" + data.ContentType.Alias, block) + } +
diff --git a/src/TestSite.13/Views/Partials/grid/bootstrap3-fluid.cshtml b/src/TestSite.13/Views/Partials/grid/bootstrap3-fluid.cshtml new file mode 100644 index 0000000..b92734e --- /dev/null +++ b/src/TestSite.13/Views/Partials/grid/bootstrap3-fluid.cshtml @@ -0,0 +1,106 @@ +@using System.Web +@using Microsoft.AspNetCore.Html +@using Newtonsoft.Json.Linq +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +@* + Razor helpers located at the bottom of this file +*@ + +@if (Model is JObject && Model?.sections is not null) +{ + var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1; + +
+ @if (oneColumn) + { + foreach (var section in Model.sections) + { +
+ @foreach (var row in section.rows) + { + renderRow(row); + } +
+ } + } + else + { +
+ @foreach (var sec in Model.sections) + { +
+
+ @foreach (var row in sec.rows) + { + renderRow(row); + } +
+
+ } +
+ } +
+} + +@functions{ + + private async Task renderRow(dynamic row) + { +
+
+ @foreach (var area in row.areas) + { +
+
+ @foreach (var control in area.controls) + { + if (control?.editor?.view != null) + { + @await Html.PartialAsync("grid/editors/base", (object)control) + } + } +
+
+ } +
+
+ } +} + +@functions{ + + public static HtmlString RenderElementAttributes(dynamic contentItem) + { + var attrs = new List(); + JObject cfg = contentItem.config; + + if (cfg != null) + { + foreach (JProperty property in cfg.Properties()) + { + var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString()); + attrs.Add(property.Name + "=\"" + propertyValue + "\""); + } + } + + JObject style = contentItem.styles; + + if (style != null) { + var cssVals = new List(); + foreach (JProperty property in style.Properties()) + { + var propertyValue = property.Value.ToString(); + if (string.IsNullOrWhiteSpace(propertyValue) == false) + { + cssVals.Add(property.Name + ":" + propertyValue + ";"); + } + } + + if (cssVals.Any()) + attrs.Add("style='" + HttpUtility.HtmlAttributeEncode(string.Join(" ", cssVals)) + "'"); + } + + return new HtmlString(string.Join(" ", attrs)); + } +} diff --git a/src/TestSite.13/Views/Partials/grid/bootstrap3.cshtml b/src/TestSite.13/Views/Partials/grid/bootstrap3.cshtml new file mode 100644 index 0000000..8863788 --- /dev/null +++ b/src/TestSite.13/Views/Partials/grid/bootstrap3.cshtml @@ -0,0 +1,112 @@ +@using System.Web +@using Microsoft.AspNetCore.Html +@using Newtonsoft.Json.Linq +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +@if (Model is JObject && Model?.sections is not null) +{ + var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1; + +
+ @if (oneColumn) + { + foreach (var section in Model.sections) + { +
+ @foreach (var row in section.rows) + { + renderRow(row, true); + } +
+ } + } + else + { +
+
+ @foreach (var sec in Model.sections) + { +
+
+ @foreach (var row in sec.rows) + { + renderRow(row, false); + } +
+
+ } +
+
+ } +
+} + +@functions{ + + private async Task renderRow(dynamic row, bool singleColumn) + { +
+ @if (singleColumn) { + @:
+ } +
+ @foreach (var area in row.areas) + { +
+
+ @foreach (var control in area.controls) + { + if (control?.editor?.view != null) + { + @await Html.PartialAsync("grid/editors/base", (object)control) + } + } +
+
+ } +
+ @if (singleColumn) { + @:
+ } +
+ } + +} + +@functions{ + + public static HtmlString RenderElementAttributes(dynamic contentItem) + { + var attrs = new List(); + JObject cfg = contentItem.config; + + if (cfg != null) + { + foreach (JProperty property in cfg.Properties()) + { + var propertyValue = HttpUtility.HtmlAttributeEncode(property.Value.ToString()); + attrs.Add(property.Name + "=\"" + propertyValue + "\""); + } + } + + JObject style = contentItem.styles; + + if (style != null) + { + var cssVals = new List(); + foreach (JProperty property in style.Properties()) + { + var propertyValue = property.Value.ToString(); + if (string.IsNullOrWhiteSpace(propertyValue) == false) + { + cssVals.Add(property.Name + ":" + propertyValue + ";"); + } + } + + if (cssVals.Any()) + attrs.Add("style=\"" + HttpUtility.HtmlAttributeEncode(string.Join(" ", cssVals)) + "\""); + } + + return new HtmlString(string.Join(" ", attrs)); + } +} diff --git a/src/TestSite.13/Views/Partials/grid/editors/base.cshtml b/src/TestSite.13/Views/Partials/grid/editors/base.cshtml new file mode 100644 index 0000000..e40543b --- /dev/null +++ b/src/TestSite.13/Views/Partials/grid/editors/base.cshtml @@ -0,0 +1,27 @@ +@model dynamic + +@try +{ + string editor = EditorView(Model); + @await Html.PartialAsync(editor, Model as object) +} +catch (Exception ex) +{ +
@ex.ToString()
+} + +@functions{ + + public static string EditorView(dynamic contentItem) + { + string view = contentItem.editor.render != null ? contentItem.editor.render.ToString() : contentItem.editor.view.ToString(); + view = view.Replace(".html", ".cshtml"); + + if (!view.Contains("/")) + { + view = "grid/editors/" + view; + } + + return view; + } +} diff --git a/src/TestSite.13/Views/Partials/grid/editors/embed.cshtml b/src/TestSite.13/Views/Partials/grid/editors/embed.cshtml new file mode 100644 index 0000000..74c8fe2 --- /dev/null +++ b/src/TestSite.13/Views/Partials/grid/editors/embed.cshtml @@ -0,0 +1,11 @@ +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +@if (Model is not null) +{ + string embedValue = Convert.ToString(Model.value); + embedValue = embedValue.DetectIsJson() ? Model.value.preview : Model.value; + +
+ @Html.Raw(embedValue) +
+} diff --git a/src/TestSite.13/Views/Partials/grid/editors/macro.cshtml b/src/TestSite.13/Views/Partials/grid/editors/macro.cshtml new file mode 100644 index 0000000..a4450d1 --- /dev/null +++ b/src/TestSite.13/Views/Partials/grid/editors/macro.cshtml @@ -0,0 +1,15 @@ +@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage + +@if (Model?.value is not null) +{ + string macroAlias = Model.value.macroAlias.ToString(); + var parameters = new Dictionary(); + foreach (var mpd in Model.value.macroParamsDictionary) + { + parameters.Add(mpd.Name, mpd.Value); + } + + + @await Umbraco.RenderMacroAsync(macroAlias, parameters) + +} diff --git a/src/TestSite.13/Views/Partials/grid/editors/media.cshtml b/src/TestSite.13/Views/Partials/grid/editors/media.cshtml new file mode 100644 index 0000000..bc3b111 --- /dev/null +++ b/src/TestSite.13/Views/Partials/grid/editors/media.cshtml @@ -0,0 +1,64 @@ +@model dynamic +@using Umbraco.Cms.Core.Media +@using Umbraco.Cms.Core.PropertyEditors.ValueConverters +@inject IImageUrlGenerator ImageUrlGenerator + +@if (Model?.value is not null) +{ + var url = Model.value.image; + + if (Model.editor.config != null && Model.editor.config.size != null) + { + if (Model.value.coordinates != null) + { + url = ImageCropperTemplateCoreExtensions.GetCropUrl( + (string)url, + ImageUrlGenerator, + width: (int)Model.editor.config.size.width, + height: (int)Model.editor.config.size.height, + cropAlias: "default", + cropDataSet: new ImageCropperValue + { + Crops = new[] + { + new ImageCropperValue.ImageCropperCrop + { + Alias = "default", + Coordinates = new ImageCropperValue.ImageCropperCropCoordinates + { + X1 = (decimal)Model.value.coordinates.x1, + Y1 = (decimal)Model.value.coordinates.y1, + X2 = (decimal)Model.value.coordinates.x2, + Y2 = (decimal)Model.value.coordinates.y2 + } + } + } + }); + } + else + { + url = ImageCropperTemplateCoreExtensions.GetCropUrl( + (string)url, + ImageUrlGenerator, + width: (int)Model.editor.config.size.width, + height: (int)Model.editor.config.size.height, + cropDataSet: new ImageCropperValue + { + FocalPoint = new ImageCropperValue.ImageCropperFocalPoint + { + Top = Model.value.focalPoint == null ? 0.5m : Model.value.focalPoint.top, + Left = Model.value.focalPoint == null ? 0.5m : Model.value.focalPoint.left + } + }); + } + } + + var altText = Model.value.altText ?? Model.value.caption ?? string.Empty; + + @altText + + if (Model.value.caption != null) + { +

@Model.value.caption

+ } +} diff --git a/src/TestSite.13/Views/Partials/grid/editors/rte.cshtml b/src/TestSite.13/Views/Partials/grid/editors/rte.cshtml new file mode 100644 index 0000000..9445666 --- /dev/null +++ b/src/TestSite.13/Views/Partials/grid/editors/rte.cshtml @@ -0,0 +1,13 @@ +@using Umbraco.Cms.Core.Templates +@model dynamic +@inject HtmlLocalLinkParser HtmlLocalLinkParser; +@inject HtmlUrlParser HtmlUrlParser; +@inject HtmlImageSourceParser HtmlImageSourceParser; + +@{ + var value = HtmlLocalLinkParser.EnsureInternalLinks(Model?.value.ToString()); + value = HtmlUrlParser.EnsureUrls(value); + value = HtmlImageSourceParser.EnsureImageSources(value); +} + +@Html.Raw(value) diff --git a/src/TestSite.13/Views/Partials/grid/editors/textstring.cshtml b/src/TestSite.13/Views/Partials/grid/editors/textstring.cshtml new file mode 100644 index 0000000..e6b9352 --- /dev/null +++ b/src/TestSite.13/Views/Partials/grid/editors/textstring.cshtml @@ -0,0 +1,22 @@ +@model dynamic + +@if (Model?.editor.config.markup is not null) +{ + string markup = Model.editor.config.markup.ToString(); + markup = markup.Replace("#value#", Html.ReplaceLineBreaks((string)Model.value.ToString()).ToString()); + + if (Model.editor.config.style != null) + { + markup = markup.Replace("#style#", Model.editor.config.style.ToString()); + } + + + @Html.Raw(markup) + +} +else +{ + +
@Model?.value
+
+} diff --git a/src/TestSite.13/Views/_ViewImports.cshtml b/src/TestSite.13/Views/_ViewImports.cshtml new file mode 100644 index 0000000..91d671e --- /dev/null +++ b/src/TestSite.13/Views/_ViewImports.cshtml @@ -0,0 +1,8 @@ +@using Umbraco.Extensions +@using Umbraco.Cms.Web.Common.PublishedModels +@using Umbraco.Cms.Web.Common.Views +@using Umbraco.Cms.Core.Models.PublishedContent +@using Microsoft.AspNetCore.Html +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers +@addTagHelper *, Smidge +@inject Smidge.SmidgeHelper SmidgeHelper diff --git a/src/TestSite.13/appsettings.Development.json b/src/TestSite.13/appsettings.Development.json new file mode 100644 index 0000000..b33453b --- /dev/null +++ b/src/TestSite.13/appsettings.Development.json @@ -0,0 +1,44 @@ +{ + "$schema": "appsettings-schema.json", + "Serilog": { + "MinimumLevel": { + "Default": "Information" + }, + "WriteTo": [ + { + "Name": "Async", + "Args": { + "configure": [ + { + "Name": "Console" + } + ] + } + } + ] + }, + "ConnectionStrings": { + "umbracoDbDSN": "Data Source=|DataDirectory|/Umbraco.sqlite.db;Cache=Shared;Foreign Keys=True;Pooling=True", + "umbracoDbDSN_ProviderName": "Microsoft.Data.Sqlite" + }, + "Umbraco": { + "CMS": { + "Unattended": { + "InstallUnattended": true, + "UnattendedUserName": "Administrator", + "UnattendedUserEmail": "admin@example.com", + "UnattendedUserPassword": "1234567890" + }, + "Content": { + "MacroErrors": "Throw" + }, + "Hosting": { + "Debug": true + }, + "RuntimeMinification": { + "UseInMemoryCache": true, + "CacheBuster": "Timestamp" + } + } + } +} diff --git a/src/TestSite.13/appsettings.json b/src/TestSite.13/appsettings.json new file mode 100644 index 0000000..4ba5e65 --- /dev/null +++ b/src/TestSite.13/appsettings.json @@ -0,0 +1,32 @@ +{ + "$schema": "appsettings-schema.json", + "Serilog": { + "MinimumLevel": { + "Default": "Information", + "Override": { + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information", + "System": "Warning" + } + } + }, + "Umbraco": { + "CMS": { + "Global": { + "SanitizeTinyMce": true + }, + "Content": { + "AllowEditInvariantFromNonDefault": true, + "ContentVersionCleanupPolicy": { + "EnableCleanup": true + } + }, + "Unattended": { + "UpgradeUnattended": true + }, + "Security": { + "AllowConcurrentLogins": false + } + } + } +} diff --git a/src/TestSite.13/wwwroot/favicon.ico b/src/TestSite.13/wwwroot/favicon.ico new file mode 100644 index 0000000..c0749dd Binary files /dev/null and b/src/TestSite.13/wwwroot/favicon.ico differ diff --git a/src/Umbraco.Community.SimpleDashboards.sln b/src/Umbraco.Community.SimpleDashboards.sln index b2cfaaa..ca963e9 100644 --- a/src/Umbraco.Community.SimpleDashboards.sln +++ b/src/Umbraco.Community.SimpleDashboards.sln @@ -12,8 +12,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Community.SimpleDashboards", "Umbraco.Community.SimpleDashboards\Umbraco.Community.SimpleDashboards.csproj", "{EC825C30-A30B-4ABF-AD64-FCA92C9EA75C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Umbraco.Community.SimpleDashboards.TestSite", "Umbraco.Community.SimpleDashboards.TestSite\Umbraco.Community.SimpleDashboards.TestSite.csproj", "{989D710F-EC50-4EFF-AE9D-26A68694FDB5}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -24,10 +22,22 @@ Global {EC825C30-A30B-4ABF-AD64-FCA92C9EA75C}.Debug|Any CPU.Build.0 = Debug|Any CPU {EC825C30-A30B-4ABF-AD64-FCA92C9EA75C}.Release|Any CPU.ActiveCfg = Release|Any CPU {EC825C30-A30B-4ABF-AD64-FCA92C9EA75C}.Release|Any CPU.Build.0 = Release|Any CPU - {989D710F-EC50-4EFF-AE9D-26A68694FDB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {989D710F-EC50-4EFF-AE9D-26A68694FDB5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {989D710F-EC50-4EFF-AE9D-26A68694FDB5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {989D710F-EC50-4EFF-AE9D-26A68694FDB5}.Release|Any CPU.Build.0 = Release|Any CPU + {22165B0B-C1A9-48EA-8876-774C7A97BA89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {22165B0B-C1A9-48EA-8876-774C7A97BA89}.Debug|Any CPU.Build.0 = Debug|Any CPU + {22165B0B-C1A9-48EA-8876-774C7A97BA89}.Release|Any CPU.ActiveCfg = Release|Any CPU + {22165B0B-C1A9-48EA-8876-774C7A97BA89}.Release|Any CPU.Build.0 = Release|Any CPU + {6700224E-C322-46C2-B9F4-D924E5620126}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6700224E-C322-46C2-B9F4-D924E5620126}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6700224E-C322-46C2-B9F4-D924E5620126}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6700224E-C322-46C2-B9F4-D924E5620126}.Release|Any CPU.Build.0 = Release|Any CPU + {EA8041D3-BA8A-44F8-A403-A3DCC883FD15}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EA8041D3-BA8A-44F8-A403-A3DCC883FD15}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EA8041D3-BA8A-44F8-A403-A3DCC883FD15}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EA8041D3-BA8A-44F8-A403-A3DCC883FD15}.Release|Any CPU.Build.0 = Release|Any CPU + {08392887-CCC4-42E8-A4DD-6E88941940AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {08392887-CCC4-42E8-A4DD-6E88941940AB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {08392887-CCC4-42E8-A4DD-6E88941940AB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {08392887-CCC4-42E8-A4DD-6E88941940AB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -42,3 +52,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Github", "Github", "{5830A8 ..\.github\workflows\build.yml = ..\.github\workflows\build.yml EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestSite.10", "TestSite.10\TestSite.10.csproj", "{22165B0B-C1A9-48EA-8876-774C7A97BA89}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestSite.11", "TestSite.11\TestSite.11.csproj", "{6700224E-C322-46C2-B9F4-D924E5620126}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestSite.12", "TestSite.12\TestSite.12.csproj", "{EA8041D3-BA8A-44F8-A403-A3DCC883FD15}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestSite.13", "TestSite.13\TestSite.13.csproj", "{08392887-CCC4-42E8-A4DD-6E88941940AB}" +EndProject diff --git a/src/Umbraco.Community.SimpleDashboards/Web/DashboardAsyncViewComponent.cs b/src/Umbraco.Community.SimpleDashboards/Web/DashboardAsyncViewComponent.cs index c2a4737..a0ab417 100644 --- a/src/Umbraco.Community.SimpleDashboards/Web/DashboardAsyncViewComponent.cs +++ b/src/Umbraco.Community.SimpleDashboards/Web/DashboardAsyncViewComponent.cs @@ -1,4 +1,5 @@ -using Microsoft.AspNetCore.Mvc; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; namespace Umbraco.Community.SimpleDashboards.Web;