Merge remote-tracking branch 'origin/temp8' into temp8-4037

# Conflicts:
#	src/Umbraco.Web/PropertyEditors/MultiNodePickerConfigurationTreeSource.cs
This commit is contained in:
Bjarke Berg
2019-01-18 13:28:57 +01:00
256 changed files with 2755 additions and 5441 deletions
+4 -1
View File
@@ -34,4 +34,7 @@ dotnet_naming_style.prefix_underscore.required_prefix = _
csharp_style_var_for_built_in_types = true:suggestion
csharp_style_var_when_type_is_apparent = true:suggestion
csharp_style_var_elsewhere = true:suggestion
csharp_prefer_braces = false : none
csharp_prefer_braces = false : none
[*.{js,less}]
trim_trailing_whitespace = false
+1 -1
View File
@@ -6,7 +6,7 @@ _Ready to try out Version 8? [See the quick start guide](V8_GETTING_STARTED.md).
When is Umbraco 8 coming?
=========================
When it's ready. We're done with the major parts of the architecture work and are focusing on three seperate tracks to prepare Umbraco 8 for release:
When it's ready. We're done with the major parts of the architecture work and are focusing on three separate tracks to prepare Umbraco 8 for release:
1) Editor Track (_currently in progress_). Without editors, there's no market for Umbraco. So we want to make sure that Umbraco 8 is full of love for editors.
2) Partner Track. Without anyone implementing Umbraco, there's nothing for editors to update. So we want to make sure that Umbraco 8 is a joy to implement
3) Contributor Track. Without our fabulous ecosystem of both individual Umbracians and 3rd party ISVs, Umbraco wouldn't be as rich a platform as it is today. We want to make sure that it's easy, straight forward and as backwards-compatible as possible to create packages for Umbraco
+2 -1
View File
@@ -13,6 +13,7 @@
*.suo
*.vs10x
*.ndproj
*.ignorer.*
# common directories
.DS_Store
@@ -156,4 +157,4 @@ build/temp/
# eof
# eof
-2
View File
@@ -52,10 +52,8 @@
<!-- config transforms -->
<!-- beware! config transforms not supported by PackageReference -->
<file src="tools\Web.config.install.xdt" target="Content\Web.config.install.xdt" />
<file src="tools\applications.config.install.xdt" target="Content\config\applications.config.install.xdt" />
<file src="tools\ClientDependency.config.install.xdt" target="Content\config\ClientDependency.config.install.xdt" />
<file src="tools\Dashboard.config.install.xdt" target="Content\config\Dashboard.config.install.xdt" />
<file src="tools\trees.config.install.xdt" target="Content\config\trees.config.install.xdt" />
<file src="tools\umbracoSettings.config.install.xdt" target="Content\config\umbracoSettings.config.install.xdt" />
<file src="tools\Views.Web.config.install.xdt" target="Views\Web.config.install.xdt" /> <!-- FIXME Content\ !! and then... transform?! -->
@@ -15,7 +15,6 @@ namespace Umbraco.Core.Composing.Composers
// register others
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Content);
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Templates);
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().RequestHandler);
composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Security);
@@ -73,11 +73,6 @@ namespace Umbraco.Core.Composing.Composers
factory.GetInstance<CompiledPackageXmlParser>(), factory.GetInstance<IPackageActionRunner>(),
new DirectoryInfo(IOHelper.GetRootDirectorySafe())));
//TODO: These are replaced in the web project - we need to declare them so that
// something is wired up, just not sure this is very nice but will work for now.
composition.RegisterUnique<IApplicationTreeService, EmptyApplicationTreeService>();
composition.RegisterUnique<ISectionService, EmptySectionService>();
return composition;
}
@@ -88,7 +83,7 @@ namespace Umbraco.Core.Composing.Composers
/// <param name="packageRepoFileName"></param>
/// <returns></returns>
private static PackagesRepository CreatePackageRepository(IFactory factory, string packageRepoFileName)
=> new PackagesRepository(
=> new PackagesRepository(
factory.GetInstance<IContentService>(), factory.GetInstance<IContentTypeService>(), factory.GetInstance<IDataTypeService>(), factory.GetInstance<IFileService>(), factory.GetInstance<IMacroService>(), factory.GetInstance<ILocalizationService>(), factory.GetInstance<IEntityXmlSerializer>(), factory.GetInstance<ILogger>(),
packageRepoFileName);
+1 -3
View File
@@ -185,9 +185,7 @@ namespace Umbraco.Core.Composing
// the app code folder and everything in it
new Tuple<FileSystemInfo, bool>(new DirectoryInfo(IOHelper.MapPath("~/App_Code")), false),
// global.asax (the app domain also monitors this, if it changes will do a full restart)
new Tuple<FileSystemInfo, bool>(new FileInfo(IOHelper.MapPath("~/global.asax")), false),
// trees.config - use the contents to create the hash since this gets resaved on every app startup!
new Tuple<FileSystemInfo, bool>(new FileInfo(IOHelper.MapPath(SystemDirectories.Config + "/trees.config")), true)
new Tuple<FileSystemInfo, bool>(new FileInfo(IOHelper.MapPath("~/global.asax")), false)
}, _logger);
return _currentAssembliesHash;
@@ -1,9 +0,0 @@
using System;
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public interface ITemplatesSection : IUmbracoConfigurationSection
{
RenderingEngine DefaultRenderingEngine { get; }
}
}
@@ -1,5 +1,4 @@
using System;
using System.ComponentModel;
namespace Umbraco.Core.Configuration.UmbracoSettings
{
@@ -12,8 +11,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
ISecuritySection Security { get; }
IRequestHandlerSection RequestHandler { get; }
ITemplatesSection Templates { get; }
ILoggingSection Logging { get; }
@@ -22,6 +19,5 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
IProvidersSection Providers { get; }
IWebRoutingSection WebRouting { get; }
}
}
@@ -1,20 +0,0 @@
using System;
using System.Configuration;
namespace Umbraco.Core.Configuration.UmbracoSettings
{
internal class TemplatesElement : UmbracoConfigurationElement, ITemplatesSection
{
[ConfigurationProperty("defaultRenderingEngine", IsRequired = true)]
internal InnerTextConfigurationElement<RenderingEngine> DefaultRenderingEngine
{
get { return GetOptionalTextElement("defaultRenderingEngine", RenderingEngine.Mvc); }
}
RenderingEngine ITemplatesSection.DefaultRenderingEngine
{
get { return DefaultRenderingEngine; }
}
}
}
@@ -1,11 +1,7 @@
using System;
using System.ComponentModel;
using System.Configuration;
using System.Linq;
using System.Configuration;
namespace Umbraco.Core.Configuration.UmbracoSettings
{
public class UmbracoSettingsSection : ConfigurationSection, IUmbracoSettingsSection
{
[ConfigurationProperty("backOffice")]
@@ -32,12 +28,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
get { return (RequestHandlerElement)this["requestHandler"]; }
}
[ConfigurationProperty("templates")]
internal TemplatesElement Templates
{
get { return (TemplatesElement)this["templates"]; }
}
[ConfigurationProperty("logging")]
internal LoggingElement Logging
{
@@ -77,11 +67,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
get { return RequestHandler; }
}
ITemplatesSection IUmbracoSettingsSection.Templates
{
get { return Templates; }
}
IBackOfficeSection IUmbracoSettingsSection.BackOffice
{
get { return BackOffice; }
@@ -106,6 +91,5 @@ namespace Umbraco.Core.Configuration.UmbracoSettings
{
get { return WebRouting; }
}
}
}
@@ -22,20 +22,17 @@ namespace Umbraco.Core.Deploy
/// Gets the value to be deployed from the control value as a string.
/// </summary>
/// <param name="gridControl">The control containing the value.</param>
/// <param name="property">The property where the control is located. Do not modify - only used for context</param>
/// <param name="dependencies">The dependencies of the property.</param>
/// <returns>The grid cell value to be deployed.</returns>
/// <remarks>Note that </remarks>
string GetValue(GridValue.GridControl gridControl, Property property, ICollection<ArtifactDependency> dependencies);
string GetValue(GridValue.GridControl gridControl, ICollection<ArtifactDependency> dependencies);
/// <summary>
/// Allows you to modify the value of a control being deployed.
/// </summary>
/// <param name="gridControl">The control being deployed.</param>
/// <param name="property">The property where the <paramref name="gridControl"/> is located. Do not modify - only used for context.</param>
/// <remarks>Follows the pattern of the property value connectors (<see cref="IValueConnector"/>). The SetValue method is used to modify the value of the <paramref name="gridControl"/>.</remarks>
/// <remarks>Note that only the <paramref name="gridControl"/> value should be modified - not the <paramref name="property"/>.</remarks>
/// <remarks>The <paramref name="property"/> should only be used to assist with context data relevant when setting the <paramref name="gridControl"/> value.</remarks>
void SetValue(GridValue.GridControl gridControl, Property property);
void SetValue(GridValue.GridControl gridControl);
}
}
+4 -2
View File
@@ -20,16 +20,18 @@ namespace Umbraco.Core.Deploy
/// Gets the deploy property value corresponding to a content property value, and gather dependencies.
/// </summary>
/// <param name="value">The content property value.</param>
/// <param name="propertyType">The value property type</param>
/// <param name="dependencies">The content dependencies.</param>
/// <returns>The deploy property value.</returns>
string ToArtifact(object value, ICollection<ArtifactDependency> dependencies);
string ToArtifact(object value, PropertyType propertyType, ICollection<ArtifactDependency> dependencies);
/// <summary>
/// Gets the content property value corresponding to a deploy property value.
/// </summary>
/// <param name="value">The deploy property value.</param>
/// <param name="propertyType">The value property type<</param>
/// <param name="currentValue">The current content property value.</param>
/// <returns>The content property value.</returns>
object FromArtifact(string value, object currentValue);
object FromArtifact(string value, PropertyType propertyType, object currentValue);
}
}
-14
View File
@@ -19,7 +19,6 @@ namespace Umbraco.Core.IO
private ShadowWrapper _partialViewsFileSystem;
private ShadowWrapper _stylesheetsFileSystem;
private ShadowWrapper _scriptsFileSystem;
private ShadowWrapper _masterPagesFileSystem;
private ShadowWrapper _mvcViewsFileSystem;
// well-known file systems lazy initialization
@@ -102,16 +101,6 @@ namespace Umbraco.Core.IO
}
}
/// <inheritdoc />
public IFileSystem MasterPagesFileSystem
{
get
{
if (Volatile.Read(ref _wkfsInitialized) == false) EnsureWellKnownFileSystems();
return _masterPagesFileSystem;
}
}
/// <inheritdoc />
public IFileSystem MvcViewsFileSystem
{
@@ -135,14 +124,12 @@ namespace Umbraco.Core.IO
var partialViewsFileSystem = new PhysicalFileSystem(SystemDirectories.PartialViews);
var stylesheetsFileSystem = new PhysicalFileSystem(SystemDirectories.Css);
var scriptsFileSystem = new PhysicalFileSystem(SystemDirectories.Scripts);
var masterPagesFileSystem = new PhysicalFileSystem(SystemDirectories.Masterpages);
var mvcViewsFileSystem = new PhysicalFileSystem(SystemDirectories.MvcViews);
_macroPartialFileSystem = new ShadowWrapper(macroPartialFileSystem, "Views/MacroPartials", IsScoped);
_partialViewsFileSystem = new ShadowWrapper(partialViewsFileSystem, "Views/Partials", IsScoped);
_stylesheetsFileSystem = new ShadowWrapper(stylesheetsFileSystem, "css", IsScoped);
_scriptsFileSystem = new ShadowWrapper(scriptsFileSystem, "scripts", IsScoped);
_masterPagesFileSystem = new ShadowWrapper(masterPagesFileSystem, "masterpages", IsScoped);
_mvcViewsFileSystem = new ShadowWrapper(mvcViewsFileSystem, "Views", IsScoped);
// fixme locking?
@@ -150,7 +137,6 @@ namespace Umbraco.Core.IO
_shadowWrappers.Add(_partialViewsFileSystem);
_shadowWrappers.Add(_stylesheetsFileSystem);
_shadowWrappers.Add(_scriptsFileSystem);
_shadowWrappers.Add(_masterPagesFileSystem);
_shadowWrappers.Add(_mvcViewsFileSystem);
return null;
-5
View File
@@ -25,11 +25,6 @@
/// </summary>
IFileSystem ScriptsFileSystem { get; }
/// <summary>
/// Gets the masterpages filesystem.
/// </summary>
IFileSystem MasterPagesFileSystem { get; }
/// <summary>
/// Gets the MVC views filesystem.
/// </summary>
-445
View File
@@ -1,445 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Services;
using Umbraco.Core.Xml;
namespace Umbraco.Core.IO
{
internal class MasterPageHelper
{
private readonly IFileSystem _masterPageFileSystem;
internal static readonly string DefaultMasterTemplate = SystemDirectories.Umbraco + "/masterpages/default.master";
//private static readonly char[] NewLineChars = Environment.NewLine.ToCharArray();
public MasterPageHelper(IFileSystem masterPageFileSystem)
{
if (masterPageFileSystem == null) throw new ArgumentNullException("masterPageFileSystem");
_masterPageFileSystem = masterPageFileSystem;
}
public bool MasterPageExists(ITemplate t)
{
return _masterPageFileSystem.FileExists(GetFilePath(t));
}
private string GetFilePath(ITemplate t)
{
return GetFilePath(t.Alias);
}
private string GetFilePath(string alias)
{
return alias + ".master";
}
public string CreateMasterPage(ITemplate t, ITemplateRepository templateRepo, bool overWrite = false)
{
string masterpageContent = "";
var filePath = GetFilePath(t);
if (_masterPageFileSystem.FileExists(filePath) == false || overWrite)
{
masterpageContent = t.Content.IsNullOrWhiteSpace() ? CreateDefaultMasterPageContent(t, templateRepo) : t.Content;
var data = Encoding.UTF8.GetBytes(masterpageContent);
var withBom = Encoding.UTF8.GetPreamble().Concat(data).ToArray();
using (var ms = new MemoryStream(withBom))
{
_masterPageFileSystem.AddFile(filePath, ms, true);
}
}
else
{
using (var s = _masterPageFileSystem.OpenFile(filePath))
using (var tr = new StreamReader(s, Encoding.UTF8))
{
masterpageContent = tr.ReadToEnd();
tr.Close();
}
}
return masterpageContent;
}
//internal string GetFileContents(ITemplate t)
//{
// var masterpageContent = "";
// if (_masterPageFileSystem.FileExists(GetFilePath(t)))
// {
// using (var s = _masterPageFileSystem.OpenFile(GetFilePath(t)))
// using (var tr = new StreamReader(s))
// {
// masterpageContent = tr.ReadToEnd();
// tr.Close();
// }
// }
// return masterpageContent;
//}
public string UpdateMasterPageFile(ITemplate t, string currentAlias, ITemplateRepository templateRepo)
{
var template = UpdateMasterPageContent(t, currentAlias);
UpdateChildTemplates(t, currentAlias, templateRepo);
var filePath = GetFilePath(t);
var data = Encoding.UTF8.GetBytes(template);
var withBom = Encoding.UTF8.GetPreamble().Concat(data).ToArray();
using (var ms = new MemoryStream(withBom))
{
_masterPageFileSystem.AddFile(filePath, ms, true);
}
return template;
}
private string CreateDefaultMasterPageContent(ITemplate template, ITemplateRepository templateRepo)
{
var design = new StringBuilder();
design.Append(GetMasterPageHeader(template) + Environment.NewLine);
if (template.MasterTemplateAlias.IsNullOrWhiteSpace() == false)
{
var master = templateRepo.Get(template.MasterTemplateAlias);
if (master != null)
{
foreach (var cpId in GetContentPlaceholderIds(master))
{
design.Append("<asp:content ContentPlaceHolderId=\"" + cpId + "\" runat=\"server\">" +
Environment.NewLine +
Environment.NewLine +
"</asp:content>" +
Environment.NewLine +
Environment.NewLine);
}
return design.ToString();
}
}
design.Append(GetMasterContentElement(template) + Environment.NewLine);
design.Append(template.Content + Environment.NewLine);
design.Append("</asp:Content>" + Environment.NewLine);
return design.ToString();
}
public static IEnumerable<string> GetContentPlaceholderIds(ITemplate template)
{
var retVal = new List<string>();
var mp = template.Content;
var path = "<asp:ContentPlaceHolder+(\\s+[a-zA-Z]+\\s*=\\s*(\"([^\"]*)\"|'([^']*)'))*\\s*/?>";
var r = new Regex(path, RegexOptions.IgnoreCase);
var m = r.Match(mp);
while (m.Success)
{
var cc = m.Groups[3].Captures;
retVal.AddRange(cc.Cast<Capture>().Where(c => c.Value != "server").Select(c => c.Value));
m = m.NextMatch();
}
return retVal;
}
private static string UpdateMasterPageContent(ITemplate template, string currentAlias)
{
var masterPageContent = template.Content;
if (string.IsNullOrEmpty(currentAlias) == false && currentAlias != template.Alias)
{
var masterHeader =
masterPageContent.Substring(0, masterPageContent.IndexOf("%>", StringComparison.Ordinal) + 2).Trim(
Environment.NewLine.ToCharArray());
// find the masterpagefile attribute
var m = Regex.Matches(masterHeader, "(?<attributeName>\\S*)=\"(?<attributeValue>[^\"]*)\"",
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
foreach (Match attributeSet in m)
{
if (attributeSet.Groups["attributeName"].Value.ToLower() == "masterpagefile")
{
// validate the masterpagefile
var currentMasterPageFile = attributeSet.Groups["attributeValue"].Value;
var currentMasterTemplateFile = ParentTemplatePath(template);
if (currentMasterPageFile != currentMasterTemplateFile)
{
masterPageContent =
masterPageContent.Replace(
attributeSet.Groups["attributeName"].Value + "=\"" + currentMasterPageFile + "\"",
attributeSet.Groups["attributeName"].Value + "=\"" + currentMasterTemplateFile +
"\"");
}
}
}
}
return masterPageContent;
}
private void UpdateChildTemplates(ITemplate template, string currentAlias, ITemplateRepository templateRepo)
{
//if we have a Old Alias if the alias and therefor the masterpage file name has changed...
//so before we save the new masterfile, we'll clear the old one, so we don't up with
//Unused masterpage files
if (string.IsNullOrEmpty(currentAlias) == false && currentAlias != template.Alias)
{
//Ensure that child templates have the right master masterpage file name
if (template.IsMasterTemplate)
{
var children = templateRepo.GetChildren(template.Id);
foreach (var t in children)
UpdateMasterPageFile(t, null, templateRepo);
}
}
}
//private void SaveDesignToFile(ITemplate t, string currentAlias, string design)
//{
// //kill the old file..
// if (string.IsNullOrEmpty(currentAlias) == false && currentAlias != t.Alias)
// {
// var oldFile =
// IOHelper.MapPath(SystemDirectories.Masterpages + "/" + currentAlias.Replace(" ", "") + ".master");
// if (System.IO.File.Exists(oldFile))
// System.IO.File.Delete(oldFile);
// }
// // save the file in UTF-8
// System.IO.File.WriteAllText(GetFilePath(t), design, Encoding.UTF8);
//}
//internal static void RemoveMasterPageFile(string alias)
//{
// if (string.IsNullOrWhiteSpace(alias) == false)
// {
// string file = IOHelper.MapPath(SystemDirectories.Masterpages + "/" + alias.Replace(" ", "") + ".master");
// if (System.IO.File.Exists(file))
// System.IO.File.Delete(file);
// }
//}
//internal string SaveTemplateToFile(ITemplate template, string currentAlias, ITemplateRepository templateRepo)
//{
// var masterPageContent = template.Content;
// if (IsMasterPageSyntax(masterPageContent) == false)
// masterPageContent = ConvertToMasterPageSyntax(template);
// // Add header to master page if it doesn't exist
// if (masterPageContent.TrimStart().StartsWith("<%@") == false)
// {
// masterPageContent = GetMasterPageHeader(template) + Environment.NewLine + masterPageContent;
// }
// else
// {
// // verify that the masterpage attribute is the same as the masterpage
// var masterHeader =
// masterPageContent.Substring(0, masterPageContent.IndexOf("%>", StringComparison.Ordinal) + 2).Trim(NewLineChars);
// // find the masterpagefile attribute
// var m = Regex.Matches(masterHeader, "(?<attributeName>\\S*)=\"(?<attributeValue>[^\"]*)\"",
// RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
// foreach (Match attributeSet in m)
// {
// if (attributeSet.Groups["attributeName"].Value.ToLower() == "masterpagefile")
// {
// // validate the masterpagefile
// var currentMasterPageFile = attributeSet.Groups["attributeValue"].Value;
// var currentMasterTemplateFile = ParentTemplatePath(template);
// if (currentMasterPageFile != currentMasterTemplateFile)
// {
// masterPageContent =
// masterPageContent.Replace(
// attributeSet.Groups["attributeName"].Value + "=\"" + currentMasterPageFile + "\"",
// attributeSet.Groups["attributeName"].Value + "=\"" + currentMasterTemplateFile +
// "\"");
// }
// }
// }
// }
// //we have a Old Alias if the alias and therefor the masterpage file name has changed...
// //so before we save the new masterfile, we'll clear the old one, so we don't up with
// //Unused masterpage files
// if (string.IsNullOrEmpty(currentAlias) == false && currentAlias != template.Alias)
// {
// //Ensure that child templates have the right master masterpage file name
// if (template.IsMasterTemplate)
// {
// var children = templateRepo.GetChildren(template.Id);
// foreach (var t in children)
// UpdateMasterPageFile(t, null, templateRepo);
// }
// //then kill the old file..
// var oldFile = GetFilePath(currentAlias);
// if (_masterPageFileSystem.FileExists(oldFile))
// _masterPageFileSystem.DeleteFile(oldFile);
// }
// // save the file in UTF-8
// System.IO.File.WriteAllText(GetFilePath(template), masterPageContent, Encoding.UTF8);
// return masterPageContent;
//}
//internal static string ConvertToMasterPageSyntax(ITemplate template)
//{
// string masterPageContent = GetMasterContentElement(template) + Environment.NewLine;
// masterPageContent += template.Content;
// // Parse the design for getitems
// masterPageContent = EnsureMasterPageSyntax(template.Alias, masterPageContent);
// // append ending asp:content element
// masterPageContent += Environment.NewLine + "</asp:Content>" + Environment.NewLine;
// return masterPageContent;
//}
public static bool IsMasterPageSyntax(string code)
{
return Regex.IsMatch(code, @"<%@\s*Master", RegexOptions.IgnoreCase) ||
code.InvariantContains("<umbraco:Item") || code.InvariantContains("<asp:") || code.InvariantContains("<umbraco:Macro");
}
private static string GetMasterPageHeader(ITemplate template)
{
return String.Format("<%@ Master Language=\"C#\" MasterPageFile=\"{0}\" AutoEventWireup=\"true\" %>", ParentTemplatePath(template)) + Environment.NewLine;
}
private static string ParentTemplatePath(ITemplate template)
{
var masterTemplate = DefaultMasterTemplate;
if (template.MasterTemplateAlias.IsNullOrWhiteSpace() == false)
masterTemplate = SystemDirectories.Masterpages + "/" + template.MasterTemplateAlias + ".master";
return masterTemplate;
}
internal static string GetMasterContentElement(ITemplate template)
{
if (template.MasterTemplateAlias.IsNullOrWhiteSpace() == false)
{
string masterAlias = template.MasterTemplateAlias;
return
String.Format("<asp:Content ContentPlaceHolderID=\"{0}ContentPlaceHolder\" runat=\"server\">", masterAlias);
}
else
return
String.Format("<asp:Content ContentPlaceHolderID=\"ContentPlaceHolderDefault\" runat=\"server\">");
}
internal static string EnsureMasterPageSyntax(string templateAlias, string masterPageContent)
{
ReplaceElement(ref masterPageContent, "?UMBRACO_GETITEM", "umbraco:Item", true);
ReplaceElement(ref masterPageContent, "?UMBRACO_GETITEM", "umbraco:Item", false);
// Parse the design for macros
ReplaceElement(ref masterPageContent, "?UMBRACO_MACRO", "umbraco:Macro", true);
ReplaceElement(ref masterPageContent, "?UMBRACO_MACRO", "umbraco:Macro", false);
// Parse the design for load childs
masterPageContent = masterPageContent.Replace("<?UMBRACO_TEMPLATE_LOAD_CHILD/>", CreateDefaultPlaceHolder(templateAlias))
.Replace("<?UMBRACO_TEMPLATE_LOAD_CHILD />", CreateDefaultPlaceHolder(templateAlias));
// Parse the design for aspnet forms
GetAspNetMasterPageForm(ref masterPageContent, templateAlias);
masterPageContent = masterPageContent.Replace("</?ASPNET_FORM>", "</form>");
// Parse the design for aspnet heads
masterPageContent = masterPageContent.Replace("</ASPNET_HEAD>", String.Format("<head id=\"{0}Head\" runat=\"server\">", templateAlias.Replace(" ", "")));
masterPageContent = masterPageContent.Replace("</?ASPNET_HEAD>", "</head>");
return masterPageContent;
}
private static void GetAspNetMasterPageForm(ref string design, string templateAlias)
{
var formElement = Regex.Match(design, GetElementRegExp("?ASPNET_FORM", false), RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
if (string.IsNullOrEmpty(formElement.Value) == false)
{
string formReplace = String.Format("<form id=\"{0}Form\" runat=\"server\">", templateAlias.Replace(" ", ""));
if (formElement.Groups.Count == 0)
{
formReplace += "<asp:scriptmanager runat=\"server\"></asp:scriptmanager>";
}
design = design.Replace(formElement.Value, formReplace);
}
}
private static string CreateDefaultPlaceHolder(string templateAlias)
{
return String.Format("<asp:ContentPlaceHolder ID=\"{0}ContentPlaceHolder\" runat=\"server\"></asp:ContentPlaceHolder>", templateAlias.Replace(" ", ""));
}
private static void ReplaceElement(ref string design, string elementName, string newElementName, bool checkForQuotes)
{
var m =
Regex.Matches(design, GetElementRegExp(elementName, checkForQuotes),
RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace);
foreach (Match match in m)
{
GroupCollection groups = match.Groups;
// generate new element (compensate for a closing trail on single elements ("/"))
string elementAttributes = groups[1].Value;
// test for macro alias
if (elementName == "?UMBRACO_MACRO")
{
var tags = XmlHelper.GetAttributesFromElement(match.Value);
if (tags["macroAlias"] != null)
elementAttributes = String.Format(" Alias=\"{0}\"", tags["macroAlias"]) + elementAttributes;
else if (tags["macroalias"] != null)
elementAttributes = String.Format(" Alias=\"{0}\"", tags["macroalias"]) + elementAttributes;
}
string newElement = "<" + newElementName + " runat=\"server\" " + elementAttributes.Trim() + ">";
if (elementAttributes.EndsWith("/"))
{
elementAttributes = elementAttributes.Substring(0, elementAttributes.Length - 1);
}
else if (groups[0].Value.StartsWith("</"))
// It's a closing element, so generate that instead of a starting element
newElement = "</" + newElementName + ">";
if (checkForQuotes)
{
// if it's inside quotes, we'll change element attribute quotes to single quotes
newElement = newElement.Replace("\"", "'");
newElement = String.Format("\"{0}\"", newElement);
}
design = design.Replace(match.Value, newElement);
}
}
private static string GetElementRegExp(string elementName, bool checkForQuotes)
{
if (checkForQuotes)
return String.Format("\"<[^>\\s]*\\b{0}(\\b[^>]*)>\"", elementName);
else
return String.Format("<[^>\\s]*\\b{0}(\\b[^>]*)>", elementName);
}
}
}
-4
View File
@@ -18,10 +18,6 @@ namespace Umbraco.Core.IO
public static string Install => "~/install";
//fixme: remove this
[Obsolete("Master pages are obsolete and code should be removed")]
public static string Masterpages => "~/masterpages";
public static string AppCode => "~/App_Code";
public static string AppPlugins => "~/App_Plugins";
@@ -92,7 +92,7 @@ namespace Umbraco.Core.Logging.Serilog
/// <summary>
/// Reads settings from /config/serilog.user.config
/// That allows a seperate logging pipeline to be configured that wil not affect the main Umbraco log
/// That allows a separate logging pipeline to be configured that wil not affect the main Umbraco log
/// </summary>
/// <param name="logConfig">A Serilog LoggerConfiguration</param>
public static LoggerConfiguration ReadFromUserConfigFile(this LoggerConfiguration logConfig)
@@ -0,0 +1,15 @@
using System.Runtime.Serialization;
using Umbraco.Core.Models.Trees;
namespace Umbraco.Core.Manifest
{
[DataContract(Name = "section", Namespace = "")]
public class ManifestBackOfficeSection : IBackOfficeSection
{
[DataMember(Name = "alias")]
public string Alias { get; set; }
[DataMember(Name = "name")]
public string Name { get; set; }
}
}
+5 -1
View File
@@ -9,6 +9,7 @@ using Umbraco.Core.Exceptions;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Models.ContentEditing;
using Umbraco.Core.Models.Trees;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Core.Manifest
@@ -101,6 +102,7 @@ namespace Umbraco.Core.Manifest
var gridEditors = new List<GridEditor>();
var contentApps = new List<ManifestContentAppDefinition>();
var dashboards = new List<ManifestDashboardDefinition>();
var sections = new List<ManifestBackOfficeSection>();
foreach (var manifest in manifests)
{
@@ -111,6 +113,7 @@ namespace Umbraco.Core.Manifest
if (manifest.GridEditors != null) gridEditors.AddRange(manifest.GridEditors);
if (manifest.ContentApps != null) contentApps.AddRange(manifest.ContentApps);
if (manifest.Dashboards != null) dashboards.AddRange(manifest.Dashboards);
if (manifest.Sections != null) sections.AddRange(manifest.Sections.DistinctBy(x => x.Alias.ToLowerInvariant()));
}
return new PackageManifest
@@ -121,7 +124,8 @@ namespace Umbraco.Core.Manifest
ParameterEditors = parameterEditors.ToArray(),
GridEditors = gridEditors.ToArray(),
ContentApps = contentApps.ToArray(),
Dashboards = dashboards.ToArray()
Dashboards = dashboards.ToArray(),
Sections = sections.ToArray()
};
}
+28 -2
View File
@@ -1,6 +1,5 @@
using System;
using Newtonsoft.Json;
using Umbraco.Core.Models.ContentEditing;
using Umbraco.Core.PropertyEditors;
namespace Umbraco.Core.Manifest
@@ -10,25 +9,52 @@ namespace Umbraco.Core.Manifest
/// </summary>
public class PackageManifest
{
/// <summary>
/// Gets or sets the scripts listed in the manifest.
/// </summary>
[JsonProperty("javascript")]
public string[] Scripts { get; set; } = Array.Empty<string>();
/// <summary>
/// Gets or sets the stylesheets listed in the manifest.
/// </summary>
[JsonProperty("css")]
public string[] Stylesheets { get; set; }= Array.Empty<string>();
public string[] Stylesheets { get; set; } = Array.Empty<string>();
/// <summary>
/// Gets or sets the property editors listed in the manifest.
/// </summary>
[JsonProperty("propertyEditors")]
public IDataEditor[] PropertyEditors { get; set; } = Array.Empty<IDataEditor>();
/// <summary>
/// Gets or sets the parameter editors listed in the manifest.
/// </summary>
[JsonProperty("parameterEditors")]
public IDataEditor[] ParameterEditors { get; set; } = Array.Empty<IDataEditor>();
/// <summary>
/// Gets or sets the grid editors listed in the manifest.
/// </summary>
[JsonProperty("gridEditors")]
public GridEditor[] GridEditors { get; set; } = Array.Empty<GridEditor>();
/// <summary>
/// Gets or sets the content apps listed in the manifest.
/// </summary>
[JsonProperty("contentApps")]
public ManifestContentAppDefinition[] ContentApps { get; set; } = Array.Empty<ManifestContentAppDefinition>();
/// <summary>
/// Gets or sets the dashboards listed in the manifest.
/// </summary>
[JsonProperty("dashboards")]
public ManifestDashboardDefinition[] Dashboards { get; set; } = Array.Empty<ManifestDashboardDefinition>();
/// <summary>
/// Gets or sets the sections listed in the manifest.
/// </summary>
[JsonProperty("sections")]
public ManifestBackOfficeSection[] Sections { get; set; } = Array.Empty<ManifestBackOfficeSection>();
}
}
@@ -3,6 +3,7 @@ using System.Configuration;
using Semver;
using Umbraco.Core.Configuration;
using Umbraco.Core.Migrations.Upgrade.V_7_12_0;
using Umbraco.Core.Migrations.Upgrade.V_7_14_0;
using Umbraco.Core.Migrations.Upgrade.V_8_0_0;
namespace Umbraco.Core.Migrations.Upgrade
@@ -122,6 +123,7 @@ namespace Umbraco.Core.Migrations.Upgrade
To<MakeTagsVariant>("{C39BF2A7-1454-4047-BBFE-89E40F66ED63}");
To<MakeRedirectUrlVariant>("{64EBCE53-E1F0-463A-B40B-E98EFCCA8AE2}");
To<AddContentTypeIsElementColumn>("{0009109C-A0B8-4F3F-8FEB-C137BBDDA268}");
To<UpdateMemberGroupPickerData>("{8A027815-D5CD-4872-8B88-9A51AB5986A6}"); // from 7.14.0
//FINAL
@@ -145,12 +147,23 @@ namespace Umbraco.Core.Migrations.Upgrade
// main chain, skipping the migrations
//
From("{init-7.12.0}");
// start stop target
// clone start / clone stop / target
ToWithClone("{init-7.10.0}", "{1350617A-4930-4D61-852F-E3AA9E692173}", "{BBD99901-1545-40E4-8A5A-D7A675C7D2F2}");
From("{init-7.12.1}").To("{init-7.10.0}"); // same as 7.12.0
From("{init-7.12.2}").To("{init-7.10.0}"); // same as 7.12.0
From("{init-7.12.3}").To("{init-7.10.0}"); // same as 7.12.0
From("{init-7.12.4}").To("{init-7.10.0}"); // same as 7.12.0
From("{init-7.13.0}").To("{init-7.10.0}"); // same as 7.12.0
From("{init-7.13.1}").To("{init-7.10.0}"); // same as 7.12.0
// 7.14.0 has migrations, handle it...
// clone going from 7.10 to 1350617A (the last one before we started to merge 7.12 migrations), then
// clone going from CF51B39B (after 7.12 migrations) to 0009109C (the last one before we started to merge 7.12 migrations),
// ending in 8A027815 (after 7.14 migrations)
From("{init-7.14.0}")
.ToWithClone("{init-7.10.0}", "{1350617A-4930-4D61-852F-E3AA9E692173}", "{9109B8AF-6B34-46EE-9484-7434196D0C79}")
.ToWithClone("{CF51B39B-9B9A-4740-BB7C-EAF606A7BFBF}", "{0009109C-A0B8-4F3F-8FEB-C137BBDDA268}", "{8A027815-D5CD-4872-8B88-9A51AB5986A6}");
}
}
}
@@ -0,0 +1,29 @@
namespace Umbraco.Core.Migrations.Upgrade.V_7_14_0
{
/// <summary>
/// Migrates member group picker properties from NVarchar to NText. See https://github.com/umbraco/Umbraco-CMS/issues/3268.
/// </summary>
public class UpdateMemberGroupPickerData : MigrationBase
{
/// <summary>
/// Migrates member group picker properties from NVarchar to NText. See https://github.com/umbraco/Umbraco-CMS/issues/3268.
/// </summary>
public UpdateMemberGroupPickerData(IMigrationContext context)
: base(context)
{ }
public override void Migrate()
{
Database.Execute($@"UPDATE umbracoPropertyData SET textValue = varcharValue, varcharValue = NULL
WHERE textValue IS NULL AND id IN (
SELECT id FROM umbracoPropertyData WHERE propertyTypeId in (
SELECT id from cmsPropertyType where dataTypeId IN (
SELECT nodeId FROM umbracoDataType WHERE propertyEditorAlias = '{Constants.PropertyEditors.Aliases.MemberGroupPicker}'
)
)
)");
Database.Execute($"UPDATE umbracoDataType SET dbType = 'Ntext' WHERE propertyEditorAlias = '{Constants.PropertyEditors.Aliases.MemberGroupPicker}'");
}
}
}
-170
View File
@@ -1,170 +0,0 @@
using System;
using System.Collections.Concurrent;
using System.Diagnostics;
using Umbraco.Core.Services;
namespace Umbraco.Core.Models
{
[DebuggerDisplay("Tree - {Title} ({ApplicationAlias})")]
public class ApplicationTree
{
private static readonly ConcurrentDictionary<string, Type> ResolvedTypes = new ConcurrentDictionary<string, Type>();
/// <summary>
/// Initializes a new instance of the <see cref="ApplicationTree"/> class.
/// </summary>
public ApplicationTree() { }
/// <summary>
/// Initializes a new instance of the <see cref="ApplicationTree"/> class.
/// </summary>
/// <param name="initialize">if set to <c>true</c> [initialize].</param>
/// <param name="sortOrder">The sort order.</param>
/// <param name="applicationAlias">The application alias.</param>
/// <param name="alias">The tree alias.</param>
/// <param name="title">The tree title.</param>
/// <param name="iconClosed">The icon closed.</param>
/// <param name="iconOpened">The icon opened.</param>
/// <param name="type">The tree type.</param>
public ApplicationTree(bool initialize, int sortOrder, string applicationAlias, string alias, string title, string iconClosed, string iconOpened, string type)
{
Initialize = initialize;
SortOrder = sortOrder;
ApplicationAlias = applicationAlias;
Alias = alias;
Title = title;
IconClosed = iconClosed;
IconOpened = iconOpened;
Type = type;
}
/// <summary>
/// Gets or sets a value indicating whether this <see cref="ApplicationTree"/> should initialize.
/// </summary>
/// <value><c>true</c> if initialize; otherwise, <c>false</c>.</value>
public bool Initialize { get; set; }
/// <summary>
/// Gets or sets the sort order.
/// </summary>
/// <value>The sort order.</value>
public int SortOrder { get; set; }
/// <summary>
/// Gets the application alias.
/// </summary>
/// <value>The application alias.</value>
public string ApplicationAlias { get; }
/// <summary>
/// Gets the tree alias.
/// </summary>
/// <value>The alias.</value>
public string Alias { get; }
/// <summary>
/// Gets or sets the tree title.
/// </summary>
/// <value>The title.</value>
public string Title { get; set; }
/// <summary>
/// Gets or sets the icon closed.
/// </summary>
/// <value>The icon closed.</value>
public string IconClosed { get; set; }
/// <summary>
/// Gets or sets the icon opened.
/// </summary>
/// <value>The icon opened.</value>
public string IconOpened { get; set; }
/// <summary>
/// Gets or sets the tree type assembly name.
/// </summary>
/// <value>The type.</value>
public string Type { get; set; }
/// <summary>
/// Returns the localized root node display name
/// </summary>
/// <param name="textService"></param>
/// <returns></returns>
public string GetRootNodeDisplayName(ILocalizedTextService textService)
{
var label = $"[{Alias}]";
// try to look up a the localized tree header matching the tree alias
var localizedLabel = textService.Localize("treeHeaders/" + Alias);
// if the localizedLabel returns [alias] then return the title attribute from the trees.config file, if it's defined
if (localizedLabel != null && localizedLabel.Equals(label, StringComparison.InvariantCultureIgnoreCase))
{
if (string.IsNullOrEmpty(Title) == false)
label = Title;
}
else
{
// the localizedLabel translated into something that's not just [alias], so use the translation
label = localizedLabel;
}
return label;
}
private Type _runtimeType;
/// <summary>
/// Returns the CLR type based on it's assembly name stored in the config
/// </summary>
/// <returns></returns>
public Type GetRuntimeType()
{
return _runtimeType ?? (_runtimeType = System.Type.GetType(Type));
}
/// <summary>
/// Used to try to get and cache the tree type
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
internal static Type TryGetType(string type)
{
try
{
return ResolvedTypes.GetOrAdd(type, s =>
{
var result = System.Type.GetType(type);
if (result != null)
{
return result;
}
//we need to implement a bit of a hack here due to some trees being renamed and backwards compat
var parts = type.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
if (parts.Length != 2)
throw new InvalidOperationException("Could not resolve type");
if (parts[1].Trim() != "Umbraco.Web" || parts[0].StartsWith("Umbraco.Web.Trees") == false || parts[0].EndsWith("Controller"))
throw new InvalidOperationException("Could not resolve type");
//if it's one of our controllers but it's not suffixed with "Controller" then add it and try again
var tempType = parts[0] + "Controller, Umbraco.Web";
result = System.Type.GetType(tempType);
if (result != null)
return result;
throw new InvalidOperationException("Could not resolve type");
});
}
catch (InvalidOperationException)
{
//swallow, this is our own exception, couldn't find the type
// fixme bad use of exceptions here!
return null;
}
}
}
}
+2 -4
View File
@@ -1,11 +1,9 @@
using System;
using System.Runtime.Serialization;
using Umbraco.Core.Models.Entities;
using Umbraco.Core.Models.Entities;
namespace Umbraco.Core.Models
{
/// <summary>
/// Defines a Template File (Masterpage or Mvc View)
/// Defines a Template File (Mvc View)
/// </summary>
public interface ITemplate : IFile, IRememberBeingDirty, ICanBeDirty
{
@@ -23,7 +23,7 @@ namespace Umbraco.Core.Models.Packaging
public string Author { get; set; }
public string AuthorUrl { get; set; }
public string Readme { get; set; }
public string Control { get; set; }
public string PackageView { get; set; }
public string IconUrl { get; set; }
public string Actions { get; set; } //fixme: Should we make this strongly typed to IEnumerable<PackageAction> ?
@@ -13,7 +13,12 @@ namespace Umbraco.Core.Models.Packaging
string Author { get; }
string AuthorUrl { get; }
string Readme { get; }
string Control { get; } //fixme - this needs to be an angular view
/// <summary>
/// This is the angular view path that will be loaded when the package installs
/// </summary>
string PackageView { get; }
string IconUrl { get; }
}
}
@@ -25,7 +25,7 @@ namespace Umbraco.Core.Models.Packaging
Actions = compiled.Actions,
Author = compiled.Author,
AuthorUrl = compiled.AuthorUrl,
Control = compiled.Control,
PackageView = compiled.PackageView,
IconUrl = compiled.IconUrl,
License = compiled.License,
LicenseUrl = compiled.LicenseUrl,
@@ -115,9 +115,9 @@ namespace Umbraco.Core.Models.Packaging
[DataMember(Name = "files")]
public IList<string> Files { get; set; } = new List<string>();
//fixme: Change this to angular view
[DataMember(Name = "loadControl")]
public string Control { get; set; } = string.Empty;
/// <inheritdoc />
[DataMember(Name = "packageView")]
public string PackageView { get; set; } = string.Empty;
[DataMember(Name = "actions")]
public string Actions { get; set; } = "<actions></actions>";
@@ -127,38 +127,7 @@ namespace Umbraco.Core.Models.Packaging
[DataMember(Name = "iconUrl")]
public string IconUrl { get; set; } = string.Empty;
public PackageDefinition Clone()
{
return new PackageDefinition
{
Id = Id,
PackagePath = PackagePath,
Name = Name,
Files = new List<string>(Files),
UmbracoVersion = (Version) UmbracoVersion.Clone(),
Version = Version,
Url = Url,
Readme = Readme,
AuthorUrl = AuthorUrl,
Author = Author,
LicenseUrl = LicenseUrl,
Actions = Actions,
PackageId = PackageId,
Control = Control,
DataTypes = new List<string>(DataTypes),
IconUrl = IconUrl,
License = License,
Templates = new List<string>(Templates),
Languages = new List<string>(Languages),
Macros = new List<string>(Macros),
Stylesheets = new List<string>(Stylesheets),
DocumentTypes = new List<string>(DocumentTypes),
DictionaryItems = new List<string>(DictionaryItems),
ContentNodeId = ContentNodeId,
ContentLoadChildNodes = ContentLoadChildNodes
};
}
}
@@ -68,7 +68,7 @@ namespace Umbraco.Core.Models.PublishedContent
var typeName = attribute == null ? type.Name : attribute.ContentTypeAlias;
if (modelInfos.TryGetValue(typeName, out var modelInfo))
throw new InvalidOperationException($"Both types {type.FullName} and {modelInfo.ModelType.FullName} want to be a model type for content type with alias \"{typeName}\".");
throw new InvalidOperationException($"Both types '{type.AssemblyQualifiedName}' and '{modelInfo.ModelType.AssemblyQualifiedName}' want to be a model type for content type with alias \"{typeName}\".");
// have to use an unsafe ctor because we don't know the types, really
var modelCtor = ReflectionUtilities.EmitConstructorUnsafe<Func<object, object>>(constructor);
-22
View File
@@ -1,22 +0,0 @@
namespace Umbraco.Core.Models
{
/// <summary>
/// Represents a section defined in the app.config file.
/// </summary>
public class Section
{
public Section(string name, string @alias, int sortOrder)
{
Name = name;
Alias = alias;
SortOrder = sortOrder;
}
public Section()
{ }
public string Name { get; set; }
public string Alias { get; set; }
public int SortOrder { get; set; }
}
}
@@ -0,0 +1,18 @@
namespace Umbraco.Core.Models.Trees
{
/// <summary>
/// Defines a back office section.
/// </summary>
public interface IBackOfficeSection
{
/// <summary>
/// Gets the alias of the section.
/// </summary>
string Alias { get; }
/// <summary>
/// Gets the name of the section.
/// </summary>
string Name { get; }
}
}
@@ -51,7 +51,7 @@ namespace Umbraco.Core.Packaging
IconUrl = package.Element("iconUrl")?.Value,
UmbracoVersion = new Version((int)requirements.Element("major"), (int)requirements.Element("minor"), (int)requirements.Element("patch")),
UmbracoVersionRequirementsType = requirements.AttributeValue<string>("type").IsNullOrWhiteSpace() ? RequirementsType.Legacy : Enum<RequirementsType>.Parse(requirements.AttributeValue<string>("type"), true),
Control = package.Element("control")?.Value,
PackageView = xml.Root.Element("view")?.Value,
Actions = xml.Root.Element("Actions")?.ToString(SaveOptions.None) ?? "<Actions></Actions>", //take the entire outer xml value
Files = xml.Root.Element("files")?.Elements("file")?.Select(CompiledPackageFile.Create).ToList() ?? new List<CompiledPackageFile>(),
Macros = xml.Root.Element("Macros")?.Elements("macro") ?? Enumerable.Empty<XElement>(),
@@ -1234,10 +1234,7 @@ namespace Umbraco.Core.Packaging
var alias = templateElement.Element("Alias").Value;
var design = templateElement.Element("Design").Value;
var masterElement = templateElement.Element("Master");
var isMasterPage = IsMasterPageSyntax(design);
var path = isMasterPage ? MasterpagePath(alias) : ViewPath(alias);
var existingTemplate = _fileService.GetTemplate(alias) as Template;
var template = existingTemplate ?? new Template(templateName, alias);
template.Content = design;
@@ -1257,23 +1254,11 @@ namespace Umbraco.Core.Packaging
return templates;
}
private bool IsMasterPageSyntax(string code)
{
return Regex.IsMatch(code, @"<%@\s*Master", RegexOptions.IgnoreCase) ||
code.InvariantContains("<umbraco:Item") || code.InvariantContains("<asp:") || code.InvariantContains("<umbraco:Macro");
}
private string ViewPath(string alias)
{
return SystemDirectories.MvcViews + "/" + alias.Replace(" ", "") + ".cshtml";
}
private string MasterpagePath(string alias)
{
return IOHelper.MapPath(SystemDirectories.Masterpages + "/" + alias.Replace(" ", "") + ".master");
}
#endregion
}
}
@@ -34,6 +34,7 @@ namespace Umbraco.Core.Packaging
PackageId = xml.AttributeValue<Guid>("packageGuid"),
IconUrl = xml.AttributeValue<string>("iconUrl") ?? string.Empty,
UmbracoVersion = xml.AttributeValue<Version>("umbVersion"),
PackageView = xml.AttributeValue<string>("view") ?? string.Empty,
License = xml.Element("license")?.Value ?? string.Empty,
LicenseUrl = xml.Element("license")?.AttributeValue<string>("url") ?? string.Empty,
Author = xml.Element("author")?.Value ?? string.Empty,
@@ -49,8 +50,7 @@ namespace Umbraco.Core.Packaging
Languages = xml.Element("languages")?.Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List<string>(),
DictionaryItems = xml.Element("dictionaryitems")?.Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List<string>(),
DataTypes = xml.Element("datatypes")?.Value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList() ?? new List<string>(),
Files = xml.Element("files")?.Elements("file").Select(x => x.Value).ToList() ?? new List<string>(),
Control = xml.Element("loadcontrol")?.Value ?? string.Empty
Files = xml.Element("files")?.Elements("file").Select(x => x.Value).ToList() ?? new List<string>()
};
return retVal;
@@ -77,6 +77,7 @@ namespace Umbraco.Core.Packaging
new XAttribute("iconUrl", def.IconUrl ?? string.Empty),
new XAttribute("umbVersion", def.UmbracoVersion),
new XAttribute("packageGuid", def.PackageId),
new XAttribute("view", def.PackageView ?? string.Empty),
new XElement("license",
new XCData(def.License ?? string.Empty),
@@ -100,8 +101,7 @@ namespace Umbraco.Core.Packaging
new XElement("macros", string.Join(",", def.Macros ?? Array.Empty<string>())),
new XElement("files", (def.Files ?? Array.Empty<string>()).Where(x => !x.IsNullOrWhiteSpace()).Select(x => new XElement("file", x))),
new XElement("languages", string.Join(",", def.Languages ?? Array.Empty<string>())),
new XElement("dictionaryitems", string.Join(",", def.DictionaryItems ?? Array.Empty<string>())),
new XElement("loadcontrol", def.Control ?? string.Empty)); //fixme: no more loadcontrol, needs to be an angular view
new XElement("dictionaryitems", string.Join(",", def.DictionaryItems ?? Array.Empty<string>())));
return packageXml;
}
@@ -161,30 +161,30 @@ namespace Umbraco.Core.Packaging
try
{
//Init package file
var packageManifest = CreatePackageManifest(out var manifestRoot, out var filesXml);
var compiledPackageXml = CreateCompiledPackageXml(out var root, out var filesXml);
//Info section
manifestRoot.Add(GetPackageInfoXml(definition));
root.Add(GetPackageInfoXml(definition));
PackageDocumentsAndTags(definition, manifestRoot);
PackageDocumentTypes(definition, manifestRoot);
PackageTemplates(definition, manifestRoot);
PackageStylesheets(definition, manifestRoot);
PackageMacros(definition, manifestRoot, filesXml, temporaryPath);
PackageDictionaryItems(definition, manifestRoot);
PackageLanguages(definition, manifestRoot);
PackageDataTypes(definition, manifestRoot);
PackageDocumentsAndTags(definition, root);
PackageDocumentTypes(definition, root);
PackageTemplates(definition, root);
PackageStylesheets(definition, root);
PackageMacros(definition, root, filesXml, temporaryPath);
PackageDictionaryItems(definition, root);
PackageLanguages(definition, root);
PackageDataTypes(definition, root);
//Files
foreach (var fileName in definition.Files)
AppendFileToManifest(fileName, temporaryPath, filesXml);
AppendFileToPackage(fileName, temporaryPath, filesXml);
//Load control on install...
if (!string.IsNullOrEmpty(definition.Control))
//Load view on install...
if (!string.IsNullOrEmpty(definition.PackageView))
{
var control = new XElement("control", definition.Control);
AppendFileToManifest(definition.Control, temporaryPath, filesXml);
manifestRoot.Add(control);
var control = new XElement("view", definition.PackageView);
AppendFileToPackage(definition.PackageView, temporaryPath, filesXml);
root.Add(control);
}
//Actions
@@ -196,20 +196,20 @@ namespace Umbraco.Core.Packaging
//this will be formatted like a full xml block like <actions>...</actions> and we want the child nodes
var parsed = XElement.Parse(definition.Actions);
actionsXml.Add(parsed.Elements());
manifestRoot.Add(actionsXml);
root.Add(actionsXml);
}
catch (Exception e)
{
_logger.Warn<PackagesRepository>(e, "Could not add package actions to the package manifest, the xml did not parse");
_logger.Warn<PackagesRepository>(e, "Could not add package actions to the package, the xml did not parse");
}
}
var manifestFileName = temporaryPath + "/package.xml";
var packageXmlFileName = temporaryPath + "/package.xml";
if (File.Exists(manifestFileName))
File.Delete(manifestFileName);
if (File.Exists(packageXmlFileName))
File.Delete(packageXmlFileName);
packageManifest.Save(manifestFileName);
compiledPackageXml.Save(packageXmlFileName);
// check if there's a packages directory below media
@@ -242,7 +242,7 @@ namespace Umbraco.Core.Packaging
throw new InvalidOperationException("Validation failed, there is invalid data on the model: " + string.Join(", ", results.Select(x => x.ErrorMessage)));
}
private void PackageDataTypes(PackageDefinition definition, XContainer manifestRoot)
private void PackageDataTypes(PackageDefinition definition, XContainer root)
{
var dataTypes = new XElement("DataTypes");
foreach (var dtId in definition.DataTypes)
@@ -252,10 +252,10 @@ namespace Umbraco.Core.Packaging
if (dataType == null) continue;
dataTypes.Add(_serializer.Serialize(dataType));
}
manifestRoot.Add(dataTypes);
root.Add(dataTypes);
}
private void PackageLanguages(PackageDefinition definition, XContainer manifestRoot)
private void PackageLanguages(PackageDefinition definition, XContainer root)
{
var languages = new XElement("Languages");
foreach (var langId in definition.Languages)
@@ -265,10 +265,10 @@ namespace Umbraco.Core.Packaging
if (lang == null) continue;
languages.Add(_serializer.Serialize(lang));
}
manifestRoot.Add(languages);
root.Add(languages);
}
private void PackageDictionaryItems(PackageDefinition definition, XContainer manifestRoot)
private void PackageDictionaryItems(PackageDefinition definition, XContainer root)
{
var dictionaryItems = new XElement("DictionaryItems");
foreach (var dictionaryId in definition.DictionaryItems)
@@ -278,10 +278,10 @@ namespace Umbraco.Core.Packaging
if (di == null) continue;
dictionaryItems.Add(_serializer.Serialize(di, false));
}
manifestRoot.Add(dictionaryItems);
root.Add(dictionaryItems);
}
private void PackageMacros(PackageDefinition definition, XContainer manifestRoot, XContainer filesXml, string temporaryPath)
private void PackageMacros(PackageDefinition definition, XContainer root, XContainer filesXml, string temporaryPath)
{
var macros = new XElement("Macros");
foreach (var macroId in definition.Macros)
@@ -291,14 +291,14 @@ namespace Umbraco.Core.Packaging
var macroXml = GetMacroXml(outInt, out var macro);
if (macroXml == null) continue;
macros.Add(macroXml);
//if the macro has a file copy it to the manifest
//if the macro has a file copy it to the xml
if (!string.IsNullOrEmpty(macro.MacroSource))
AppendFileToManifest(macro.MacroSource, temporaryPath, filesXml);
AppendFileToPackage(macro.MacroSource, temporaryPath, filesXml);
}
manifestRoot.Add(macros);
root.Add(macros);
}
private void PackageStylesheets(PackageDefinition definition, XContainer manifestRoot)
private void PackageStylesheets(PackageDefinition definition, XContainer root)
{
var stylesheetsXml = new XElement("Stylesheets");
foreach (var stylesheetName in definition.Stylesheets)
@@ -308,10 +308,10 @@ namespace Umbraco.Core.Packaging
if (xml != null)
stylesheetsXml.Add(xml);
}
manifestRoot.Add(stylesheetsXml);
root.Add(stylesheetsXml);
}
private void PackageTemplates(PackageDefinition definition, XContainer manifestRoot)
private void PackageTemplates(PackageDefinition definition, XContainer root)
{
var templatesXml = new XElement("Templates");
foreach (var templateId in definition.Templates)
@@ -321,10 +321,10 @@ namespace Umbraco.Core.Packaging
if (template == null) continue;
templatesXml.Add(_serializer.Serialize(template));
}
manifestRoot.Add(templatesXml);
root.Add(templatesXml);
}
private void PackageDocumentTypes(PackageDefinition definition, XContainer manifestRoot)
private void PackageDocumentTypes(PackageDefinition definition, XContainer root)
{
var contentTypes = new HashSet<IContentType>();
var docTypesXml = new XElement("DocumentTypes");
@@ -338,10 +338,10 @@ namespace Umbraco.Core.Packaging
foreach (var contentType in contentTypes)
docTypesXml.Add(_serializer.Serialize(contentType));
manifestRoot.Add(docTypesXml);
root.Add(docTypesXml);
}
private void PackageDocumentsAndTags(PackageDefinition definition, XContainer manifestRoot)
private void PackageDocumentsAndTags(PackageDefinition definition, XContainer root)
{
//Documents and tags
if (string.IsNullOrEmpty(definition.ContentNodeId) == false && int.TryParse(definition.ContentNodeId, out var contentNodeId))
@@ -356,7 +356,7 @@ namespace Umbraco.Core.Packaging
//Create the Documents/DocumentSet node
manifestRoot.Add(
root.Add(
new XElement("Documents",
new XElement("DocumentSet",
new XAttribute("importMode", "root"),
@@ -438,12 +438,12 @@ namespace Umbraco.Core.Packaging
}
/// <summary>
/// Appends a file to package manifest and copies the file to the correct folder.
/// Appends a file to package and copies the file to the correct folder.
/// </summary>
/// <param name="path">The path.</param>
/// <param name="packageDirectory">The package directory.</param>
/// <param name="filesXml">The files xml node</param>
private static void AppendFileToManifest(string path, string packageDirectory, XContainer filesXml)
private static void AppendFileToPackage(string path, string packageDirectory, XContainer filesXml)
{
if (!path.StartsWith("~/") && !path.StartsWith("/"))
path = "~/" + path;
@@ -584,12 +584,12 @@ namespace Umbraco.Core.Packaging
return info;
}
private static XDocument CreatePackageManifest(out XElement root, out XElement files)
private static XDocument CreateCompiledPackageXml(out XElement root, out XElement files)
{
files = new XElement("files");
root = new XElement("umbPackage", files);
var packageManifest = new XDocument(root);
return packageManifest;
var compiledPackageXml = new XDocument(root);
return compiledPackageXml;
}
private XDocument EnsureStorage(out string packagesFile)
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Collections.Generic;
using System.IO;
using Umbraco.Core.Models;
@@ -18,21 +16,6 @@ namespace Umbraco.Core.Persistence.Repositories
IEnumerable<ITemplate> GetDescendants(int masterTemplateId);
IEnumerable<ITemplate> GetDescendants(string alias);
/// <summary>
/// This checks what the default rendering engine is set in config but then also ensures that there isn't already
/// a template that exists in the opposite rendering engine's template folder, then returns the appropriate
/// rendering engine to use.
/// </summary>
/// <returns></returns>
/// <remarks>
/// The reason this is required is because for example, if you have a master page file already existing under ~/masterpages/Blah.aspx
/// and then you go to create a template in the tree called Blah and the default rendering engine is MVC, it will create a Blah.cshtml
/// empty template in ~/Views. This means every page that is using Blah will go to MVC and render an empty page.
/// This is mostly related to installing packages since packages install file templates to the file system and then create the
/// templates in business logic. Without this, it could cause the wrong rendering engine to be used for a package.
/// </remarks>
RenderingEngine DetermineTemplateRenderingEngine(ITemplate template);
/// <summary>
/// Validates a <see cref="ITemplate"/>
/// </summary>
@@ -5,7 +5,6 @@ using System.Linq;
using System.Text;
using NPoco;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
@@ -23,20 +22,14 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
/// </summary>
internal class TemplateRepository : NPocoRepositoryBase<int, ITemplate>, ITemplateRepository
{
private readonly IFileSystem _masterpagesFileSystem;
private readonly IFileSystem _viewsFileSystem;
private readonly ITemplatesSection _templateConfig;
private readonly ViewHelper _viewHelper;
private readonly MasterPageHelper _masterPageHelper;
public TemplateRepository(IScopeAccessor scopeAccessor, CacheHelper cache, ILogger logger, ITemplatesSection templateConfig, IFileSystems fileSystems)
public TemplateRepository(IScopeAccessor scopeAccessor, CacheHelper cache, ILogger logger, IFileSystems fileSystems)
: base(scopeAccessor, cache, logger)
{
_masterpagesFileSystem = fileSystems.MasterPagesFileSystem;
_viewsFileSystem = fileSystems.MvcViewsFileSystem;
_templateConfig = templateConfig;
_viewHelper = new ViewHelper(_viewsFileSystem);
_masterPageHelper = new MasterPageHelper(_masterpagesFileSystem);
}
protected override IRepositoryCachePolicy<ITemplate, int> CreateCachePolicy()
@@ -255,18 +248,9 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
else
{
// else, create or write template.Content to disk
if (DetermineTemplateRenderingEngine(template) == RenderingEngine.Mvc)
{
content = originalAlias == null
? _viewHelper.CreateView(template, true)
: _viewHelper.UpdateViewFile(template, originalAlias);
}
else
{
content = originalAlias == null
? _masterPageHelper.CreateMasterPage(template, this, true)
: _masterPageHelper.UpdateMasterPageFile(template, originalAlias, this);
}
content = originalAlias == null
? _viewHelper.CreateView(template, true)
: _viewHelper.UpdateViewFile(template, originalAlias);
}
// once content has been set, "template on disk" are not "on disk" anymore
@@ -298,16 +282,8 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
Database.Execute(delete, new { id = GetEntityId(entity) });
}
if (DetermineTemplateRenderingEngine(entity) == RenderingEngine.Mvc)
{
var viewName = string.Concat(entity.Alias, ".cshtml");
_viewsFileSystem.DeleteFile(viewName);
}
else
{
var masterpageName = string.Concat(entity.Alias, ".master");
_masterpagesFileSystem.DeleteFile(masterpageName);
}
var viewName = string.Concat(entity.Alias, ".cshtml");
_viewsFileSystem.DeleteFile(viewName);
entity.DeleteDate = DateTime.Now;
}
@@ -388,27 +364,11 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
template.VirtualPath = _viewsFileSystem.GetUrl(path);
return;
}
path = string.Concat(template.Alias, ".master");
if (_masterpagesFileSystem.FileExists(path))
{
template.VirtualPath = _masterpagesFileSystem.GetUrl(path);
return;
}
}
else
{
// we know the path already
var ext = Path.GetExtension(path);
switch (ext)
{
case ".cshtml":
case ".vbhtml":
template.VirtualPath = _viewsFileSystem.GetUrl(path);
return;
case ".master":
template.VirtualPath = _masterpagesFileSystem.GetUrl(path);
return;
}
template.VirtualPath = _viewsFileSystem.GetUrl(path);
}
template.VirtualPath = string.Empty; // file not found...
@@ -426,25 +386,15 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
path = string.Concat(template.Alias, ".vbhtml");
if (_viewsFileSystem.FileExists(path))
return GetFileContent(template, _viewsFileSystem, path, init);
path = string.Concat(template.Alias, ".master");
if (_masterpagesFileSystem.FileExists(path))
return GetFileContent(template, _masterpagesFileSystem, path, init);
}
else
{
// we know the path already
var ext = Path.GetExtension(path);
switch (ext)
{
case ".cshtml":
case ".vbhtml":
return GetFileContent(template, _viewsFileSystem, path, init);
case ".master":
return GetFileContent(template, _masterpagesFileSystem, path, init);
}
return GetFileContent(template, _viewsFileSystem, path, init);
}
template.VirtualPath = string.Empty; // file not found...
return string.Empty;
}
@@ -514,9 +464,6 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
case ".vbhtml":
fs = _viewsFileSystem;
break;
case ".master":
fs = _masterpagesFileSystem;
break;
default:
throw new Exception("Unsupported extension " + ext + ".");
}
@@ -625,56 +572,6 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
}
}
/// <summary>
/// This checks what the default rendering engine is set in config but then also ensures that there isn't already
/// a template that exists in the opposite rendering engine's template folder, then returns the appropriate
/// rendering engine to use.
/// </summary>
/// <returns></returns>
/// <remarks>
/// The reason this is required is because for example, if you have a master page file already existing under ~/masterpages/Blah.aspx
/// and then you go to create a template in the tree called Blah and the default rendering engine is MVC, it will create a Blah.cshtml
/// empty template in ~/Views. This means every page that is using Blah will go to MVC and render an empty page.
/// This is mostly related to installing packages since packages install file templates to the file system and then create the
/// templates in business logic. Without this, it could cause the wrong rendering engine to be used for a package.
/// </remarks>
public RenderingEngine DetermineTemplateRenderingEngine(ITemplate template)
{
var engine = _templateConfig.DefaultRenderingEngine;
var viewHelper = new ViewHelper(_viewsFileSystem);
if (viewHelper.ViewExists(template) == false)
{
if (template.Content.IsNullOrWhiteSpace() == false && MasterPageHelper.IsMasterPageSyntax(template.Content))
{
//there is a design but its definitely a webforms design and we haven't got a MVC view already for it
return RenderingEngine.WebForms;
}
}
var masterPageHelper = new MasterPageHelper(_masterpagesFileSystem);
switch (engine)
{
case RenderingEngine.Mvc:
//check if there's a view in ~/masterpages
if (masterPageHelper.MasterPageExists(template) && viewHelper.ViewExists(template) == false)
{
//change this to webforms since there's already a file there for this template alias
engine = RenderingEngine.WebForms;
}
break;
case RenderingEngine.WebForms:
//check if there's a view in ~/views
if (viewHelper.ViewExists(template) && masterPageHelper.MasterPageExists(template) == false)
{
//change this to mvc since there's already a file there for this template alias
engine = RenderingEngine.Mvc;
}
break;
}
return engine;
}
/// <summary>
/// Validates a <see cref="ITemplate"/>
/// </summary>
@@ -689,21 +586,12 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
var path = template.VirtualPath;
// get valid paths
var validDirs = _templateConfig.DefaultRenderingEngine == RenderingEngine.Mvc
? new[] { SystemDirectories.Masterpages, SystemDirectories.MvcViews }
: new[] { SystemDirectories.Masterpages };
var validDirs = new[] { SystemDirectories.MvcViews };
// get valid extensions
var validExts = new List<string>();
if (_templateConfig.DefaultRenderingEngine == RenderingEngine.Mvc)
{
validExts.Add("cshtml");
validExts.Add("vbhtml");
}
else
{
validExts.Add("master");
}
validExts.Add("cshtml");
validExts.Add("vbhtml");
// validate path and extension
var validFile = IOHelper.VerifyEditPath(path, validDirs);
@@ -1,152 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Umbraco.Core.Models;
namespace Umbraco.Core.Services
{
public interface IApplicationTreeService
{
/// <summary>
/// Creates a new application tree.
/// </summary>
/// <param name="initialize">if set to <c>true</c> [initialize].</param>
/// <param name="sortOrder">The sort order.</param>
/// <param name="applicationAlias">The application alias.</param>
/// <param name="alias">The alias.</param>
/// <param name="title">The title.</param>
/// <param name="iconClosed">The icon closed.</param>
/// <param name="iconOpened">The icon opened.</param>
/// <param name="type">The type.</param>
void MakeNew(bool initialize, int sortOrder, string applicationAlias, string alias, string title, string iconClosed, string iconOpened, string type);
/// <summary>
/// Saves this instance.
/// </summary>
void SaveTree(ApplicationTree tree);
/// <summary>
/// Deletes this instance.
/// </summary>
void DeleteTree(ApplicationTree tree);
/// <summary>
/// Gets an ApplicationTree by it's tree alias.
/// </summary>
/// <param name="treeAlias">The tree alias.</param>
/// <returns>An ApplicationTree instance</returns>
ApplicationTree GetByAlias(string treeAlias);
/// <summary>
/// Gets all applicationTrees registered in umbraco from the umbracoAppTree table..
/// </summary>
/// <returns>Returns a ApplicationTree Array</returns>
IEnumerable<ApplicationTree> GetAll();
/// <summary>
/// Gets the application tree for the applcation with the specified alias
/// </summary>
/// <param name="applicationAlias">The application alias.</param>
/// <returns>Returns a ApplicationTree Array</returns>
IEnumerable<ApplicationTree> GetApplicationTrees(string applicationAlias);
/// <summary>
/// Gets the application tree for the applcation with the specified alias
/// </summary>
/// <param name="applicationAlias">The application alias.</param>
/// <param name="onlyInitialized"></param>
/// <returns>Returns a ApplicationTree Array</returns>
IEnumerable<ApplicationTree> GetApplicationTrees(string applicationAlias, bool onlyInitialized);
/// <summary>
/// Gets the grouped application trees for the application with the specified alias
/// </summary>
/// <param name="applicationAlias"></param>
/// <param name="onlyInitialized"></param>
/// <returns></returns>
IDictionary<string, IEnumerable<ApplicationTree>> GetGroupedApplicationTrees(string applicationAlias, bool onlyInitialized);
}
/// <summary>
/// Purely used to allow a service context to create the default services
/// </summary>
internal class EmptyApplicationTreeService : IApplicationTreeService
{
/// <summary>
/// Creates a new application tree.
/// </summary>
/// <param name="initialize">if set to <c>true</c> [initialize].</param>
/// <param name="sortOrder">The sort order.</param>
/// <param name="applicationAlias">The application alias.</param>
/// <param name="alias">The alias.</param>
/// <param name="title">The title.</param>
/// <param name="iconClosed">The icon closed.</param>
/// <param name="iconOpened">The icon opened.</param>
/// <param name="type">The type.</param>
public void MakeNew(bool initialize, int sortOrder, string applicationAlias, string alias, string title, string iconClosed, string iconOpened, string type)
{
throw new System.NotImplementedException();
}
/// <summary>
/// Saves this instance.
/// </summary>
public void SaveTree(ApplicationTree tree)
{
throw new System.NotImplementedException();
}
/// <summary>
/// Deletes this instance.
/// </summary>
public void DeleteTree(ApplicationTree tree)
{
throw new System.NotImplementedException();
}
/// <summary>
/// Gets an ApplicationTree by it's tree alias.
/// </summary>
/// <param name="treeAlias">The tree alias.</param>
/// <returns>An ApplicationTree instance</returns>
public ApplicationTree GetByAlias(string treeAlias)
{
throw new System.NotImplementedException();
}
/// <summary>
/// Gets all applicationTrees registered in umbraco from the umbracoAppTree table..
/// </summary>
/// <returns>Returns a ApplicationTree Array</returns>
public IEnumerable<ApplicationTree> GetAll()
{
throw new System.NotImplementedException();
}
public IDictionary<string, IEnumerable<ApplicationTree>> GetGroupedApplicationTrees(string applicationAlias, bool onlyInitialized)
{
throw new System.NotImplementedException();
}
/// <summary>
/// Gets the application tree for the applcation with the specified alias
/// </summary>
/// <param name="applicationAlias">The application alias.</param>
/// <returns>Returns a ApplicationTree Array</returns>
public IEnumerable<ApplicationTree> GetApplicationTrees(string applicationAlias)
{
throw new System.NotImplementedException();
}
/// <summary>
/// Gets the application tree for the applcation with the specified alias
/// </summary>
/// <param name="applicationAlias">The application alias.</param>
/// <param name="onlyInitialized"></param>
/// <returns>Returns a ApplicationTree Array</returns>
public IEnumerable<ApplicationTree> GetApplicationTrees(string applicationAlias, bool onlyInitialized)
{
throw new System.NotImplementedException();
}
}
}
-15
View File
@@ -210,21 +210,6 @@ namespace Umbraco.Core.Services
/// <param name="userId">Optional id of the user</param>
void SaveTemplate(IEnumerable<ITemplate> templates, int userId = 0);
/// <summary>
/// This checks what the default rendering engine is set in config but then also ensures that there isn't already
/// a template that exists in the opposite rendering engine's template folder, then returns the appropriate
/// rendering engine to use.
/// </summary>
/// <returns></returns>
/// <remarks>
/// The reason this is required is because for example, if you have a master page file already existing under ~/masterpages/Blah.aspx
/// and then you go to create a template in the tree called Blah and the default rendering engine is MVC, it will create a Blah.cshtml
/// empty template in ~/Views. This means every page that is using Blah will go to MVC and render an empty page.
/// This is mostly related to installing packages since packages install file templates to the file system and then create the
/// templates in business logic. Without this, it could cause the wrong rendering engine to be used for a package.
/// </remarks>
RenderingEngine DetermineTemplateRenderingEngine(ITemplate template);
/// <summary>
/// Gets the content of a template as a stream.
/// </summary>
@@ -1,114 +0,0 @@
using System.Collections.Generic;
using Umbraco.Core.Models;
namespace Umbraco.Core.Services
{
public interface ISectionService
{
/// <summary>
/// The cache storage for all applications
/// </summary>
IEnumerable<Section> GetSections();
/// <summary>
/// Get the user group's allowed sections
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
IEnumerable<Section> GetAllowedSections(int userId);
/// <summary>
/// Gets the application by its alias.
/// </summary>
/// <param name="appAlias">The application alias.</param>
/// <returns></returns>
Section GetByAlias(string appAlias);
/// <summary>
/// Creates a new applcation if no application with the specified alias is found.
/// </summary>
/// <param name="name">The application name.</param>
/// <param name="alias">The application alias.</param>
/// <param name="icon">The application icon, which has to be located in umbraco/images/tray folder.</param>
void MakeNew(string name, string alias, string icon);
/// <summary>
/// Makes the new.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="alias">The alias.</param>
/// <param name="icon">The icon.</param>
/// <param name="sortOrder">The sort order.</param>
void MakeNew(string name, string alias, string icon, int sortOrder);
/// <summary>
/// Deletes the section
/// </summary>
void DeleteSection(Section section);
}
/// <summary>
/// Purely used to allow a service context to create the default services
/// </summary>
internal class EmptySectionService : ISectionService
{
/// <summary>
/// The cache storage for all applications
/// </summary>
public IEnumerable<Section> GetSections()
{
throw new System.NotImplementedException();
}
/// <summary>
/// Get the user's allowed sections
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public IEnumerable<Section> GetAllowedSections(int userId)
{
throw new System.NotImplementedException();
}
/// <summary>
/// Gets the application by its alias.
/// </summary>
/// <param name="appAlias">The application alias.</param>
/// <returns></returns>
public Section GetByAlias(string appAlias)
{
throw new System.NotImplementedException();
}
/// <summary>
/// Creates a new applcation if no application with the specified alias is found.
/// </summary>
/// <param name="name">The application name.</param>
/// <param name="alias">The application alias.</param>
/// <param name="icon">The application icon, which has to be located in umbraco/images/tray folder.</param>
public void MakeNew(string name, string alias, string icon)
{
throw new System.NotImplementedException();
}
/// <summary>
/// Makes the new.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="alias">The alias.</param>
/// <param name="icon">The icon.</param>
/// <param name="sortOrder">The sort order.</param>
public void MakeNew(string name, string alias, string icon, int sortOrder)
{
throw new System.NotImplementedException();
}
/// <summary>
/// Deletes the section
/// </summary>
public void DeleteSection(Section section)
{
throw new System.NotImplementedException();
}
}
}
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
@@ -556,27 +555,6 @@ namespace Umbraco.Core.Services.Implement
}
}
/// <summary>
/// This checks what the default rendering engine is set in config but then also ensures that there isn't already
/// a template that exists in the opposite rendering engine's template folder, then returns the appropriate
/// rendering engine to use.
/// </summary>
/// <returns></returns>
/// <remarks>
/// The reason this is required is because for example, if you have a master page file already existing under ~/masterpages/Blah.aspx
/// and then you go to create a template in the tree called Blah and the default rendering engine is MVC, it will create a Blah.cshtml
/// empty template in ~/Views. This means every page that is using Blah will go to MVC and render an empty page.
/// This is mostly related to installing packages since packages install file templates to the file system and then create the
/// templates in business logic. Without this, it could cause the wrong rendering engine to be used for a package.
/// </remarks>
public RenderingEngine DetermineTemplateRenderingEngine(ITemplate template)
{
using (var scope = ScopeProvider.CreateScope(autoComplete: true))
{
return _templateRepository.DetermineTemplateRenderingEngine(template);
}
}
/// <summary>
/// Deletes a template by its alias
/// </summary>
@@ -1043,7 +1021,7 @@ namespace Umbraco.Core.Services.Implement
_auditRepository.Save(new AuditItem(objectId, type, userId, entityType));
}
//TODO Method to change name and/or alias of view/masterpage template
//TODO Method to change name and/or alias of view template
#region Event Handlers
+1 -19
View File
@@ -25,8 +25,6 @@ namespace Umbraco.Core.Services
private readonly Lazy<IServerRegistrationService> _serverRegistrationService;
private readonly Lazy<IEntityService> _entityService;
private readonly Lazy<IRelationService> _relationService;
private readonly Lazy<IApplicationTreeService> _treeService;
private readonly Lazy<ISectionService> _sectionService;
private readonly Lazy<IMacroService> _macroService;
private readonly Lazy<IMemberTypeService> _memberTypeService;
private readonly Lazy<IMemberGroupService> _memberGroupService;
@@ -38,7 +36,7 @@ namespace Umbraco.Core.Services
/// <summary>
/// Initializes a new instance of the <see cref="ServiceContext"/> class with lazy services.
/// </summary>
public ServiceContext(Lazy<IPublicAccessService> publicAccessService, Lazy<IDomainService> domainService, Lazy<IAuditService> auditService, Lazy<ILocalizedTextService> localizedTextService, Lazy<ITagService> tagService, Lazy<IContentService> contentService, Lazy<IUserService> userService, Lazy<IMemberService> memberService, Lazy<IMediaService> mediaService, Lazy<IContentTypeService> contentTypeService, Lazy<IMediaTypeService> mediaTypeService, Lazy<IDataTypeService> dataTypeService, Lazy<IFileService> fileService, Lazy<ILocalizationService> localizationService, Lazy<IPackagingService> packagingService, Lazy<IServerRegistrationService> serverRegistrationService, Lazy<IEntityService> entityService, Lazy<IRelationService> relationService, Lazy<IApplicationTreeService> treeService, Lazy<ISectionService> sectionService, Lazy<IMacroService> macroService, Lazy<IMemberTypeService> memberTypeService, Lazy<IMemberGroupService> memberGroupService, Lazy<INotificationService> notificationService, Lazy<IExternalLoginService> externalLoginService, Lazy<IRedirectUrlService> redirectUrlService, Lazy<IConsentService> consentService)
public ServiceContext(Lazy<IPublicAccessService> publicAccessService, Lazy<IDomainService> domainService, Lazy<IAuditService> auditService, Lazy<ILocalizedTextService> localizedTextService, Lazy<ITagService> tagService, Lazy<IContentService> contentService, Lazy<IUserService> userService, Lazy<IMemberService> memberService, Lazy<IMediaService> mediaService, Lazy<IContentTypeService> contentTypeService, Lazy<IMediaTypeService> mediaTypeService, Lazy<IDataTypeService> dataTypeService, Lazy<IFileService> fileService, Lazy<ILocalizationService> localizationService, Lazy<IPackagingService> packagingService, Lazy<IServerRegistrationService> serverRegistrationService, Lazy<IEntityService> entityService, Lazy<IRelationService> relationService, Lazy<IMacroService> macroService, Lazy<IMemberTypeService> memberTypeService, Lazy<IMemberGroupService> memberGroupService, Lazy<INotificationService> notificationService, Lazy<IExternalLoginService> externalLoginService, Lazy<IRedirectUrlService> redirectUrlService, Lazy<IConsentService> consentService)
{
_publicAccessService = publicAccessService;
_domainService = domainService;
@@ -58,8 +56,6 @@ namespace Umbraco.Core.Services
_serverRegistrationService = serverRegistrationService;
_entityService = entityService;
_relationService = relationService;
_treeService = treeService;
_sectionService = sectionService;
_macroService = macroService;
_memberTypeService = memberTypeService;
_memberGroupService = memberGroupService;
@@ -90,8 +86,6 @@ namespace Umbraco.Core.Services
IMemberTypeService memberTypeService = null,
IMemberService memberService = null,
IUserService userService = null,
ISectionService sectionService = null,
IApplicationTreeService treeService = null,
ITagService tagService = null,
INotificationService notificationService = null,
ILocalizedTextService localizedTextService = null,
@@ -125,8 +119,6 @@ namespace Umbraco.Core.Services
Lazy(serverRegistrationService),
Lazy(entityService),
Lazy(relationService),
Lazy(treeService),
Lazy(sectionService),
Lazy(macroService),
Lazy(memberTypeService),
Lazy(memberGroupService),
@@ -236,16 +228,6 @@ namespace Umbraco.Core.Services
/// </summary>
public IMemberService MemberService => _memberService.Value;
/// <summary>
/// Gets the <see cref="SectionService"/>
/// </summary>
public ISectionService SectionService => _sectionService.Value;
/// <summary>
/// Gets the <see cref="ApplicationTreeService"/>
/// </summary>
public IApplicationTreeService ApplicationTreeService => _treeService.Value;
/// <summary>
/// Gets the MemberTypeService
/// </summary>
+1 -1
View File
@@ -892,7 +892,7 @@ namespace Umbraco.Core
}
/// <summary>
/// Ensures that the folder path ends with a DirectorySeperatorChar
/// Ensures that the folder path ends with a DirectorySeparatorChar
/// </summary>
/// <param name="currentFolder"></param>
/// <returns></returns>
+3 -7
View File
@@ -291,7 +291,6 @@
<Compile Include="Configuration\UmbracoSettings\IScheduledTask.cs" />
<Compile Include="Configuration\UmbracoSettings\IScheduledTasksSection.cs" />
<Compile Include="Configuration\UmbracoSettings\ISecuritySection.cs" />
<Compile Include="Configuration\UmbracoSettings\ITemplatesSection.cs" />
<Compile Include="Configuration\UmbracoSettings\ITourSection.cs" />
<Compile Include="Configuration\UmbracoSettings\IUmbracoSettingsSection.cs" />
<Compile Include="Configuration\UmbracoSettings\IWebRoutingSection.cs" />
@@ -304,7 +303,6 @@
<Compile Include="Configuration\UmbracoSettings\ScheduledTasksCollection.cs" />
<Compile Include="Configuration\UmbracoSettings\ScheduledTasksElement.cs" />
<Compile Include="Configuration\UmbracoSettings\SecurityElement.cs" />
<Compile Include="Configuration\UmbracoSettings\TemplatesElement.cs" />
<Compile Include="Configuration\UmbracoSettings\TourConfigElement.cs" />
<Compile Include="Configuration\UmbracoSettings\UmbracoConfigurationElement.cs" />
<Compile Include="Configuration\UmbracoSettings\UmbracoSettingsSection.cs" />
@@ -355,6 +353,7 @@
<Compile Include="Logging\Serilog\LoggerConfigExtensions.cs" />
<Compile Include="Logging\Serilog\Enrichers\Log4NetLevelMapperEnricher.cs" />
<Compile Include="Manifest\DashboardAccessRuleConverter.cs" />
<Compile Include="Manifest\ManifestBackOfficeSection.cs" />
<Compile Include="Manifest\ManifestContentAppDefinition.cs" />
<Compile Include="Manifest\ManifestContentAppFactory.cs" />
<Compile Include="Manifest\ManifestDashboardDefinition.cs" />
@@ -367,6 +366,7 @@
<Compile Include="Migrations\Upgrade\V_7_12_0\RenameTrueFalseField.cs" />
<Compile Include="Migrations\Upgrade\V_7_12_0\SetDefaultTagsStorageType.cs" />
<Compile Include="Migrations\Upgrade\V_7_12_0\UpdateUmbracoConsent.cs" />
<Compile Include="Migrations\Upgrade\V_7_14_0\UpdateMemberGroupPickerData.cs" />
<Compile Include="Migrations\Upgrade\V_7_8_0\AddIndexToPropertyTypeAliasColumn.cs" />
<Compile Include="Migrations\Upgrade\V_7_8_0\AddInstructionCountColumn.cs" />
<Compile Include="Migrations\Upgrade\V_7_8_0\AddMediaVersionTable.cs" />
@@ -448,6 +448,7 @@
<Compile Include="Models\PublishedContent\VariationContext.cs" />
<Compile Include="Models\PublishedContent\ThreadCultureVariationContextAccessor.cs" />
<Compile Include="Models\PublishedContent\VariationContextAccessorExtensions.cs" />
<Compile Include="Models\Trees\IBackOfficeSection.cs" />
<Compile Include="Packaging\CompiledPackageXmlParser.cs" />
<Compile Include="Packaging\ICreatedPackagesRepository.cs" />
<Compile Include="Packaging\IInstalledPackagesRepository.cs" />
@@ -630,7 +631,6 @@
<Compile Include="IO\FileSystemWrapper.cs" />
<Compile Include="IO\IFileSystem.cs" />
<Compile Include="IO\IOHelper.cs" />
<Compile Include="IO\MasterPageHelper.cs" />
<Compile Include="IO\MediaFileSystem.cs" />
<Compile Include="IO\PhysicalFileSystem.cs" />
<Compile Include="IO\ShadowFileSystem.cs" />
@@ -678,7 +678,6 @@
<Compile Include="Migrations\Upgrade\UmbracoUpgrader.cs" />
<Compile Include="Migrations\Upgrade\Upgrader.cs" />
<Compile Include="Migrations\Upgrade\V_8_0_0\DropMigrationsTable.cs" />
<Compile Include="Models\ApplicationTree.cs" />
<Compile Include="Models\AuditItem.cs" />
<Compile Include="Models\AuditType.cs" />
<Compile Include="Models\Content.cs" />
@@ -875,7 +874,6 @@
<Compile Include="Models\Relation.cs" />
<Compile Include="Models\RelationType.cs" />
<Compile Include="Models\Script.cs" />
<Compile Include="Models\Section.cs" />
<Compile Include="Models\ServerRegistration.cs" />
<Compile Include="Models\Stylesheet.cs" />
<Compile Include="Models\StylesheetProperty.cs" />
@@ -1390,7 +1388,6 @@
<Compile Include="Services\Implement\EntityXmlSerializer.cs" />
<Compile Include="Services\Implement\ExternalLoginService.cs" />
<Compile Include="Services\Implement\FileService.cs" />
<Compile Include="Services\IApplicationTreeService.cs" />
<Compile Include="Services\IAuditService.cs" />
<Compile Include="Services\IContentService.cs" />
<Compile Include="Services\IContentServiceBase.cs" />
@@ -1420,7 +1417,6 @@
<Compile Include="Services\IPublicAccessService.cs" />
<Compile Include="Services\IRedirectUrlService.cs" />
<Compile Include="Services\IRelationService.cs" />
<Compile Include="Services\ISectionService.cs" />
<Compile Include="Services\IServerRegistrationService.cs" />
<Compile Include="Services\IService.cs" />
<Compile Include="Services\ITagService.cs" />
@@ -47,13 +47,6 @@ namespace Umbraco.Tests.Cache
//Permission.Deleted += PermissionDeleted;
//PermissionRepository<IContent>.AssignedPermissions += CacheRefresherEventHandler_AssignedPermissions;
new EventDefinition<IApplicationTreeService, EventArgs>(null, serviceContext.ApplicationTreeService, new EventArgs(), "Deleted"),
new EventDefinition<IApplicationTreeService, EventArgs>(null, serviceContext.ApplicationTreeService, new EventArgs(), "Updated"),
new EventDefinition<IApplicationTreeService, EventArgs>(null, serviceContext.ApplicationTreeService, new EventArgs(), "New"),
new EventDefinition<ISectionService, EventArgs>(null, serviceContext.SectionService, new EventArgs(), "Deleted"),
new EventDefinition<ISectionService, EventArgs>(null, serviceContext.SectionService, new EventArgs(), "New"),
new EventDefinition<IUserService, SaveEventArgs<IUser>>(null, serviceContext.UserService, new SaveEventArgs<IUser>(Enumerable.Empty<IUser>())),
new EventDefinition<IUserService, DeleteEventArgs<IUser>>(null, serviceContext.UserService, new DeleteEventArgs<IUser>(Enumerable.Empty<IUser>())),
new EventDefinition<IUserService, SaveEventArgs<UserGroupWithUsers>>(null, serviceContext.UserService, new SaveEventArgs<UserGroupWithUsers>(Enumerable.Empty<UserGroupWithUsers>())),
@@ -90,7 +90,7 @@ namespace Umbraco.Tests.Composing
Assert.AreEqual(0, typesFound.Count()); // 0 classes in _assemblies are marked with [Tree]
typesFound = TypeFinder.FindClassesWithAttribute<TreeAttribute>(new[] { typeof (UmbracoContext).Assembly });
Assert.AreEqual(22, typesFound.Count()); // + classes in Umbraco.Web are marked with [Tree]
Assert.AreEqual(21, typesFound.Count()); // + classes in Umbraco.Web are marked with [Tree]
}
private static IProfilingLogger GetTestProfilingLogger()
@@ -1,13 +0,0 @@
using NUnit.Framework;
namespace Umbraco.Tests.Configurations.UmbracoSettings
{
[TestFixture]
public class TemplateElementDefaultTests : TemplateElementTests
{
protected override bool TestingDefaults
{
get { return true; }
}
}
}
@@ -1,16 +0,0 @@
using NUnit.Framework;
using Umbraco.Core;
namespace Umbraco.Tests.Configurations.UmbracoSettings
{
[TestFixture]
public class TemplateElementTests : UmbracoSettingsTests
{
[Test]
public void DefaultRenderingEngine()
{
Assert.IsTrue(SettingsSection.Templates.DefaultRenderingEngine == RenderingEngine.Mvc);
}
}
}
@@ -145,10 +145,6 @@
</urlReplacing>
</requestHandler>
<templates>
<defaultRenderingEngine>Mvc</defaultRenderingEngine>
</templates>
<logging>
<autoCleanLogs>false</autoCleanLogs>
<enableLogging>true</enableLogging>
@@ -37,11 +37,6 @@
<!-- https://our.umbraco.com/documentation/using-umbraco/config-files/umbracoSettings/#RequestHandler
<requestHandler/> -->
<!-- https://our.umbraco.com/documentation/using-umbraco/config-files/umbracoSettings/#Templates -->
<templates>
<defaultRenderingEngine>Mvc</defaultRenderingEngine>
</templates>
<!-- https://our.umbraco.com/documentation/using-umbraco/config-files/umbracoSettings/#Logging -->
<logging/>
-1
View File
@@ -37,7 +37,6 @@ namespace Umbraco.Tests.IO
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Css, true), IOHelper.MapPath(SystemDirectories.Css, false));
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Data, true), IOHelper.MapPath(SystemDirectories.Data, false));
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Install, true), IOHelper.MapPath(SystemDirectories.Install, false));
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Masterpages, true), IOHelper.MapPath(SystemDirectories.Masterpages, false));
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Media, true), IOHelper.MapPath(SystemDirectories.Media, false));
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Packages, true), IOHelper.MapPath(SystemDirectories.Packages, false));
Assert.AreEqual(IOHelper.MapPath(SystemDirectories.Preview, true), IOHelper.MapPath(SystemDirectories.Preview, false));
@@ -429,5 +429,21 @@ javascript: ['~/test.js',/*** some note about stuff asd09823-4**09234*/ '~/test2
Assert.AreEqual(1, db1.Sections.Length);
Assert.AreEqual("forms", db1.Sections[0]);
}
[Test]
public void CanParseManifest_Sections()
{
const string json = @"{'sections': [
{ ""alias"": ""content"", ""name"": ""Content"" },
{ ""alias"": ""hello"", ""name"": ""World"" }
]}";
var manifest = _parser.ParseManifest(json);
Assert.AreEqual(2, manifest.Sections.Length);
Assert.AreEqual("content", manifest.Sections[0].Alias);
Assert.AreEqual("hello", manifest.Sections[1].Alias);
Assert.AreEqual("Content", manifest.Sections[0].Name);
Assert.AreEqual("World", manifest.Sections[1].Name);
}
}
}
@@ -7,12 +7,9 @@ using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.IO;
using Umbraco.Core.Models;
using Umbraco.Core.Models.Entities;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Dtos;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Persistence.Repositories.Implement;
using Umbraco.Core.Scoping;
using Umbraco.Tests.TestHelpers;
@@ -36,7 +33,7 @@ namespace Umbraco.Tests.Persistence.Repositories
private DocumentRepository CreateRepository(IScopeAccessor scopeAccessor, out ContentTypeRepository contentTypeRepository)
{
var cacheHelper = CacheHelper.Disabled;
var templateRepository = new TemplateRepository(scopeAccessor, cacheHelper, Logger, Mock.Of<ITemplatesSection>(), TestObjects.GetFileSystemsMock());
var templateRepository = new TemplateRepository(scopeAccessor, cacheHelper, Logger, TestObjects.GetFileSystemsMock());
var tagRepository = new TagRepository(scopeAccessor, cacheHelper, Logger);
contentTypeRepository = new ContentTypeRepository(scopeAccessor, cacheHelper, Logger, templateRepository);
var languageRepository = new LanguageRepository(scopeAccessor, cacheHelper, Logger);
@@ -46,7 +43,7 @@ namespace Umbraco.Tests.Persistence.Repositories
private ContentTypeRepository CreateRepository(IScopeAccessor scopeAccessor)
{
var templateRepository = new TemplateRepository(scopeAccessor, CacheHelper.Disabled, Logger, Mock.Of<ITemplatesSection>(), TestObjects.GetFileSystemsMock());
var templateRepository = new TemplateRepository(scopeAccessor, CacheHelper.Disabled, Logger, TestObjects.GetFileSystemsMock());
var contentTypeRepository = new ContentTypeRepository(scopeAccessor, CacheHelper.Disabled, Logger, templateRepository);
return contentTypeRepository;
}
@@ -71,7 +68,7 @@ namespace Umbraco.Tests.Persistence.Repositories
var provider = TestObjects.GetScopeProvider(Logger);
using (var scope = provider.CreateScope())
{
var templateRepo = new TemplateRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger, Mock.Of<ITemplatesSection>(), TestObjects.GetFileSystemsMock());
var templateRepo = new TemplateRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger, TestObjects.GetFileSystemsMock());
var repository = CreateRepository((IScopeAccessor) provider);
var templates = new[]
{
@@ -64,7 +64,7 @@ namespace Umbraco.Tests.Persistence.Repositories
{
cacheHelper = cacheHelper ?? CacheHelper;
templateRepository = new TemplateRepository(scopeAccessor, cacheHelper, Logger, Mock.Of<ITemplatesSection>(), TestObjects.GetFileSystemsMock());
templateRepository = new TemplateRepository(scopeAccessor, cacheHelper, Logger, TestObjects.GetFileSystemsMock());
var tagRepository = new TagRepository(scopeAccessor, cacheHelper, Logger);
contentTypeRepository = new ContentTypeRepository(scopeAccessor, cacheHelper, Logger, templateRepository);
var languageRepository = new LanguageRepository(scopeAccessor, cacheHelper, Logger);
@@ -4,9 +4,7 @@ using System.Linq;
using Moq;
using NUnit.Framework;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.IO;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Persistence.Repositories.Implement;
using Umbraco.Core.Scoping;
using Umbraco.Tests.TestHelpers;
@@ -22,7 +20,7 @@ namespace Umbraco.Tests.Persistence.Repositories
private DomainRepository CreateRepository(IScopeProvider provider, out ContentTypeRepository contentTypeRepository, out DocumentRepository documentRepository, out LanguageRepository languageRepository)
{
var accessor = (IScopeAccessor) provider;
var templateRepository = new TemplateRepository(accessor, Core.Cache.CacheHelper.Disabled, Logger, Mock.Of<ITemplatesSection>(), TestObjects.GetFileSystemsMock());
var templateRepository = new TemplateRepository(accessor, Core.Cache.CacheHelper.Disabled, Logger, TestObjects.GetFileSystemsMock());
var tagRepository = new TagRepository(accessor, Core.Cache.CacheHelper.Disabled, Logger);
contentTypeRepository = new ContentTypeRepository(accessor, Core.Cache.CacheHelper.Disabled, Logger, templateRepository);
languageRepository = new LanguageRepository(accessor, Core.Cache.CacheHelper.Disabled, Logger);
@@ -4,10 +4,8 @@ using System.Linq;
using Moq;
using NUnit.Framework;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.IO;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence;
using Umbraco.Core.Persistence.Repositories;
using Umbraco.Core.Persistence.Repositories.Implement;
using Umbraco.Core.Scoping;
using Umbraco.Tests.TestHelpers;
@@ -307,7 +305,7 @@ namespace Umbraco.Tests.Persistence.Repositories
private DocumentRepository CreateRepository(IScopeProvider provider, out ContentTypeRepository contentTypeRepository)
{
var accessor = (IScopeAccessor) provider;
var templateRepository = new TemplateRepository(accessor, CacheHelper, Logger, Mock.Of<ITemplatesSection>(), TestObjects.GetFileSystemsMock());
var templateRepository = new TemplateRepository(accessor, CacheHelper, Logger, TestObjects.GetFileSystemsMock());
var tagRepository = new TagRepository(accessor, CacheHelper, Logger);
contentTypeRepository = new ContentTypeRepository(accessor, CacheHelper, Logger, templateRepository);
var languageRepository = new LanguageRepository(accessor, CacheHelper, Logger);
@@ -953,7 +953,7 @@ namespace Umbraco.Tests.Persistence.Repositories
private DocumentRepository CreateContentRepository(IScopeProvider provider, out ContentTypeRepository contentTypeRepository)
{
var accessor = (IScopeAccessor) provider;
var templateRepository = new TemplateRepository(accessor, CacheHelper.Disabled, Logger, Mock.Of<ITemplatesSection>(), TestObjects.GetFileSystemsMock());
var templateRepository = new TemplateRepository(accessor, CacheHelper.Disabled, Logger, TestObjects.GetFileSystemsMock());
var tagRepository = new TagRepository(accessor, CacheHelper.Disabled, Logger);
contentTypeRepository = new ContentTypeRepository(accessor, CacheHelper.Disabled, Logger, templateRepository);
var languageRepository = new LanguageRepository(accessor, CacheHelper.Disabled, Logger);
@@ -25,11 +25,9 @@ namespace Umbraco.Tests.Persistence.Repositories
{
private IFileSystems _fileSystems;
private ITemplateRepository CreateRepository(IScopeProvider provider, ITemplatesSection templatesSection = null)
private ITemplateRepository CreateRepository(IScopeProvider provider)
{
return new TemplateRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger,
templatesSection ?? Mock.Of<ITemplatesSection>(t => t.DefaultRenderingEngine == RenderingEngine.Mvc),
_fileSystems);
return new TemplateRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger, _fileSystems);
}
public override void SetUp()
@@ -37,8 +35,6 @@ namespace Umbraco.Tests.Persistence.Repositories
base.SetUp();
_fileSystems = Mock.Of<IFileSystems>();
var masterPageFileSystem = new PhysicalFileSystem(SystemDirectories.Masterpages);
Mock.Get(_fileSystems).Setup(x => x.MasterPagesFileSystem).Returns(masterPageFileSystem);
var viewsFileSystem = new PhysicalFileSystem(SystemDirectories.MvcViews);
Mock.Get(_fileSystems).Setup(x => x.MvcViewsFileSystem).Returns(viewsFileSystem);
}
@@ -56,77 +52,6 @@ namespace Umbraco.Tests.Persistence.Repositories
}
}
[Test]
public void Can_Perform_Add_MasterPage_Detect_Content()
{
// Arrange
using (ScopeProvider.CreateScope())
{
var repository = CreateRepository(ScopeProvider);
// Act
var template = new Template("test", "test")
{
Content = @"<%@ Master Language=""C#"" %>"
};
repository.Save(template);
//Assert
Assert.That(repository.Get("test"), Is.Not.Null);
Assert.That(_fileSystems.MasterPagesFileSystem.FileExists("test.master"), Is.True);
}
}
[Test]
public void Can_Perform_Add_MasterPage_With_Default_Content()
{
// Arrange
using (ScopeProvider.CreateScope())
{
var repository = CreateRepository(ScopeProvider, Mock.Of<ITemplatesSection>(x => x.DefaultRenderingEngine == RenderingEngine.WebForms));
// Act
var template = new Template("test", "test");
repository.Save(template);
//Assert
Assert.That(repository.Get("test"), Is.Not.Null);
Assert.That(_fileSystems.MasterPagesFileSystem.FileExists("test.master"), Is.True);
Assert.AreEqual(@"<%@ Master Language=""C#"" MasterPageFile=""~/umbraco/masterpages/default.master"" AutoEventWireup=""true"" %>
<asp:Content ContentPlaceHolderID=""ContentPlaceHolderDefault"" runat=""server"">
</asp:Content>
".StripWhitespace(), template.Content.StripWhitespace());
}
}
[Test]
public void Can_Perform_Add_MasterPage_With_Default_Content_With_Parent()
{
// Arrange
using (ScopeProvider.CreateScope())
{
var repository = CreateRepository(ScopeProvider, Mock.Of<ITemplatesSection>(x => x.DefaultRenderingEngine == RenderingEngine.WebForms));
//NOTE: This has to be persisted first
var template = new Template("test", "test");
repository.Save(template);
// Act
var template2 = new Template("test2", "test2");
template2.SetMasterTemplate(template);
repository.Save(template2);
//Assert
Assert.That(repository.Get("test2"), Is.Not.Null);
Assert.That(_fileSystems.MasterPagesFileSystem.FileExists("test2.master"), Is.True);
Assert.AreEqual(@"<%@ Master Language=""C#"" MasterPageFile=""~/masterpages/test.master"" AutoEventWireup=""true"" %>
".StripWhitespace(), template2.Content.StripWhitespace());
}
}
[Test]
public void Can_Perform_Add_View()
{
@@ -253,32 +178,6 @@ namespace Umbraco.Tests.Persistence.Repositories
}
}
[Test]
public void Can_Perform_Update_MasterPage()
{
// Arrange
using (ScopeProvider.CreateScope())
{
var repository = CreateRepository(ScopeProvider);
// Act
var template = new Template("test", "test")
{
Content = @"<%@ Master Language=""C#"" %>"
};
repository.Save(template);
template.Content = @"<%@ Master Language=""VB"" %>";
repository.Save(template);
var updated = repository.Get("test");
// Assert
Assert.That(_fileSystems.MasterPagesFileSystem.FileExists("test.master"), Is.True);
Assert.That(updated.Content, Is.EqualTo(@"<%@ Master Language=""VB"" %>"));
}
}
[Test]
public void Can_Perform_Update_View()
{
@@ -305,31 +204,6 @@ namespace Umbraco.Tests.Persistence.Repositories
}
}
[Test]
public void Can_Perform_Delete_MasterPage()
{
// Arrange
using (ScopeProvider.CreateScope())
{
var repository = CreateRepository(ScopeProvider);
var template = new Template("test", "test")
{
Content = @"<%@ Master Language=""C#"" %>"
};
repository.Save(template);
// Act
var templates = repository.Get("test");
Assert.That(_fileSystems.MasterPagesFileSystem.FileExists("test.master"), Is.True);
repository.Delete(templates);
// Assert
Assert.IsNull(repository.Get("test"));
Assert.That(_fileSystems.MasterPagesFileSystem.FileExists("test.master"), Is.False);
}
}
[Test]
public void Can_Perform_Delete_View()
{
@@ -651,11 +525,6 @@ namespace Umbraco.Tests.Persistence.Repositories
_fileSystems = null;
//Delete all files
var fsMaster = new PhysicalFileSystem(SystemDirectories.Masterpages);
var masterPages = fsMaster.GetFiles("", "*.master");
foreach (var file in masterPages)
fsMaster.DeleteFile(file);
var fsViews = new PhysicalFileSystem(SystemDirectories.MvcViews);
var views = fsViews.GetFiles("", "*.cshtml");
foreach (var file in views)
@@ -41,7 +41,7 @@ namespace Umbraco.Tests.Persistence.Repositories
private DocumentRepository CreateContentRepository(IScopeProvider provider, out IContentTypeRepository contentTypeRepository, out ITemplateRepository templateRepository)
{
var accessor = (IScopeAccessor) provider;
templateRepository = new TemplateRepository(accessor, CacheHelper, Logger, Mock.Of<ITemplatesSection>(), TestObjects.GetFileSystemsMock());
templateRepository = new TemplateRepository(accessor, CacheHelper, Logger, TestObjects.GetFileSystemsMock());
var tagRepository = new TagRepository(accessor, CacheHelper, Logger);
contentTypeRepository = new ContentTypeRepository(accessor, CacheHelper, Logger, templateRepository);
var languageRepository = new LanguageRepository(accessor, CacheHelper, Logger);
@@ -97,7 +97,7 @@ namespace Umbraco.Tests.PublishedContent
{
var doc = GetContent(true, 1);
//change a doc type alias
var c = (TestPublishedContent) doc.Children.ElementAt(0);
var c = (TestPublishedContent)doc.Children.ElementAt(0);
c.ContentType = new PublishedContentType(22, "DontMatch", PublishedItemType.Content, Enumerable.Empty<string>(), Enumerable.Empty<PublishedPropertyType>(), ContentVariation.Nothing);
var dt = doc.ChildrenAsTable(Current.Services, "Child");
@@ -163,7 +163,7 @@ namespace Umbraco.Tests.Services
var provider = TestObjects.GetScopeProvider(Logger);
using (var scope = provider.CreateScope())
{
var tRepository = new TemplateRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger, Mock.Of<ITemplatesSection>(), TestObjects.GetFileSystemsMock());
var tRepository = new TemplateRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger, TestObjects.GetFileSystemsMock());
var tagRepo = new TagRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger);
var ctRepository = new ContentTypeRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger, tRepository);
var languageRepository = new LanguageRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger);
@@ -196,7 +196,7 @@ namespace Umbraco.Tests.Services
var provider = TestObjects.GetScopeProvider(Logger);
using (var scope = provider.CreateScope())
{
var tRepository = new TemplateRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger, Mock.Of<ITemplatesSection>(), TestObjects.GetFileSystemsMock());
var tRepository = new TemplateRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger, TestObjects.GetFileSystemsMock());
var tagRepo = new TagRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger);
var ctRepository = new ContentTypeRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger, tRepository);
var languageRepository = new LanguageRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger);
@@ -227,7 +227,7 @@ namespace Umbraco.Tests.Services
var provider = TestObjects.GetScopeProvider(Logger);
using (var scope = provider.CreateScope())
{
var tRepository = new TemplateRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger, Mock.Of<ITemplatesSection>(), TestObjects.GetFileSystemsMock());
var tRepository = new TemplateRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger, TestObjects.GetFileSystemsMock());
var tagRepo = new TagRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger);
var ctRepository = new ContentTypeRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger, tRepository);
var languageRepository = new LanguageRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger);
@@ -261,7 +261,7 @@ namespace Umbraco.Tests.Services
var provider = TestObjects.GetScopeProvider(Logger);
using (var scope = provider.CreateScope())
{
var tRepository = new TemplateRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger, Mock.Of<ITemplatesSection>(), TestObjects.GetFileSystemsMock());
var tRepository = new TemplateRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger, TestObjects.GetFileSystemsMock());
var tagRepo = new TagRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger);
var ctRepository = new ContentTypeRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger, tRepository);
var languageRepository = new LanguageRepository((IScopeAccessor) provider, CacheHelper.Disabled, Logger);
@@ -3037,7 +3037,7 @@ namespace Umbraco.Tests.Services
private DocumentRepository CreateRepository(IScopeProvider provider, out ContentTypeRepository contentTypeRepository)
{
var accessor = (IScopeAccessor) provider;
var templateRepository = new TemplateRepository(accessor, CacheHelper.Disabled, Logger, Mock.Of<ITemplatesSection>(), TestObjects.GetFileSystemsMock());
var templateRepository = new TemplateRepository(accessor, CacheHelper.Disabled, Logger, TestObjects.GetFileSystemsMock());
var tagRepository = new TagRepository(accessor, CacheHelper.Disabled, Logger);
contentTypeRepository = new ContentTypeRepository(accessor, CacheHelper.Disabled, Logger, templateRepository);
var languageRepository = new LanguageRepository(accessor, CacheHelper.Disabled, Logger);
@@ -4163,7 +4163,7 @@ html {
text-align: center;
}
.text--center .seperator {
.text--center .separator {
margin-right: auto;
margin-left: auto;
}
@@ -4998,4 +4998,4 @@ nav > ul li.active ul li a {
</PreValues>
</DataType>
</DataTypes>
</umbPackage>
</umbPackage>
@@ -1,8 +1,10 @@
using NUnit.Framework;
using System.Linq;
using System.Threading;
using Umbraco.Core.Composing;
using Umbraco.Core.Models.Membership;
using Umbraco.Tests.Testing;
using Umbraco.Web.Services;
namespace Umbraco.Tests.Services
{
@@ -14,15 +16,7 @@ namespace Umbraco.Tests.Services
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest, WithApplication = true)]
public class SectionServiceTests : TestWithSomeContentBase
{
public override void CreateTestData()
{
base.CreateTestData();
ServiceContext.SectionService.MakeNew("Content", "content", "icon-content");
ServiceContext.SectionService.MakeNew("Media", "media", "icon-media");
ServiceContext.SectionService.MakeNew("Settings", "settings", "icon-settings");
ServiceContext.SectionService.MakeNew("Developer", "developer", "icon-developer");
}
private ISectionService SectionService => Factory.GetInstance<ISectionService>();
[Test]
public void SectionService_Can_Get_Allowed_Sections_For_User()
@@ -31,7 +25,7 @@ namespace Umbraco.Tests.Services
var user = CreateTestUser();
// Act
var result = ServiceContext.SectionService.GetAllowedSections(user.Id).ToList();
var result = SectionService.GetAllowedSections(user.Id).ToList();
// Assert
Assert.AreEqual(3, result.Count);
@@ -63,7 +57,7 @@ namespace Umbraco.Tests.Services
Name = "Group B"
};
userGroupB.AddAllowedSection("settings");
userGroupB.AddAllowedSection("developer");
userGroupB.AddAllowedSection("member");
ServiceContext.UserService.Save(userGroupB, new[] { user.Id }, false);
return ServiceContext.UserService.GetUserById(user.Id);
@@ -1,21 +0,0 @@
using NUnit.Framework;
using Umbraco.Core.IO;
namespace Umbraco.Tests.Templates
{
[TestFixture]
public class MasterPageHelperTests
{
[TestCase(@"<%@ master language=""C#"" masterpagefile=""~/masterpages/umbMaster.master"" autoeventwireup=""true"" %>")]
[TestCase(@"<%@ Master language=""C#"" masterpagefile=""~/masterpages/umbMaster.master"" autoeventwireup=""true"" %>")]
[TestCase(@"<%@Master language=""C#"" masterpagefile=""~/masterpages/umbMaster.master"" autoeventwireup=""true"" %>")]
[TestCase(@"<%@ Master language=""C#"" masterpagefile=""~/masterpages/umbMaster.master"" autoeventwireup=""true"" %>")]
[TestCase(@"<%@master language=""C#"" masterpagefile=""~/masterpages/umbMaster.master"" autoeventwireup=""true"" %>")]
public void IsMasterPageSyntax(string design)
{
Assert.IsTrue(MasterPageHelper.IsMasterPageSyntax(design));
}
}
}
@@ -1,121 +0,0 @@
using Moq;
using NUnit.Framework;
using Umbraco.Core;
using Umbraco.Core.Cache;
using Umbraco.Core.Configuration.UmbracoSettings;
using Umbraco.Core.IO;
using Umbraco.Core.Logging;
using Umbraco.Core.Models;
using Umbraco.Core.Persistence.Repositories.Implement;
using Umbraco.Core.Scoping;
using Umbraco.Tests.TestHelpers;
namespace Umbraco.Tests.Templates
{
[TestFixture]
public class TemplateRepositoryTests
{
private readonly Mock<CacheHelper> _cacheMock = new Mock<CacheHelper>();
private readonly Mock<ITemplatesSection> _templateConfigMock = new Mock<ITemplatesSection>();
private readonly IFileSystems _fileSystems = Mock.Of<IFileSystems>();
private TemplateRepository _templateRepository;
private readonly TestObjects _testObjects = new TestObjects(null);
[SetUp]
public void Setup()
{
var logger = Mock.Of<ILogger>();
var accessorMock = new Mock<IScopeAccessor>();
var scopeMock = new Mock<IScope>();
var database = _testObjects.GetUmbracoSqlCeDatabase(logger);
scopeMock.Setup(x => x.Database).Returns(database);
accessorMock.Setup(x => x.AmbientScope).Returns(scopeMock.Object);
var mvcFs = Mock.Of<IFileSystem>();
var masterFs = Mock.Of<IFileSystem>();
Mock.Get(_fileSystems).Setup(x => x.MvcViewsFileSystem).Returns(mvcFs);
Mock.Get(_fileSystems).Setup(x => x.MasterPagesFileSystem).Returns(masterFs);
_templateRepository = new TemplateRepository(accessorMock.Object, _cacheMock.Object, logger, _templateConfigMock.Object, _fileSystems);
}
[Test]
public void DetermineTemplateRenderingEngine_Returns_MVC_When_ViewFile_Exists_And_Content_Has_Webform_Markup()
{
// Project in MVC mode
_templateConfigMock.Setup(x => x.DefaultRenderingEngine).Returns(RenderingEngine.Mvc);
// Template has masterpage content
var templateMock = new Mock<ITemplate>();
templateMock.Setup(x => x.Alias).Returns("Something");
templateMock.Setup(x => x.Content).Returns("<asp:Content />");
// but MVC View already exists
Mock.Get(_fileSystems.MvcViewsFileSystem)
.Setup(x => x.FileExists(It.IsAny<string>())).Returns(true);
var res = _templateRepository.DetermineTemplateRenderingEngine(templateMock.Object);
Assert.AreEqual(RenderingEngine.Mvc, res);
}
[Test]
public void DetermineTemplateRenderingEngine_Returns_WebForms_When_ViewFile_Doesnt_Exist_And_Content_Has_Webform_Markup()
{
// Project in MVC mode
_templateConfigMock.Setup(x => x.DefaultRenderingEngine).Returns(RenderingEngine.Mvc);
// Template has masterpage content
var templateMock = new Mock<ITemplate>();
templateMock.Setup(x => x.Alias).Returns("Something");
templateMock.Setup(x => x.Content).Returns("<asp:Content />");
// MVC View doesn't exist
Mock.Get(_fileSystems.MvcViewsFileSystem)
.Setup(x => x.FileExists(It.IsAny<string>())).Returns(false);
var res = _templateRepository.DetermineTemplateRenderingEngine(templateMock.Object);
Assert.AreEqual(RenderingEngine.WebForms, res);
}
[Test]
public void DetermineTemplateRenderingEngine_Returns_WebForms_When_MasterPage_Exists_And_In_Mvc_Mode()
{
// Project in MVC mode
_templateConfigMock.Setup(x => x.DefaultRenderingEngine).Returns(RenderingEngine.Mvc);
var templateMock = new Mock<ITemplate>();
templateMock.Setup(x => x.Alias).Returns("Something");
// but masterpage already exists
Mock.Get(_fileSystems.MvcViewsFileSystem)
.Setup(x => x.FileExists(It.IsAny<string>())).Returns(false);
Mock.Get(_fileSystems.MasterPagesFileSystem)
.Setup(x => x.FileExists(It.IsAny<string>())).Returns(true);
var res = _templateRepository.DetermineTemplateRenderingEngine(templateMock.Object);
Assert.AreEqual(RenderingEngine.WebForms, res);
}
[Test]
public void DetermineTemplateRenderingEngine_Returns_Mvc_When_ViewPage_Exists_And_In_Webforms_Mode()
{
// Project in WebForms mode
_templateConfigMock.Setup(x => x.DefaultRenderingEngine).Returns(RenderingEngine.WebForms);
var templateMock = new Mock<ITemplate>();
templateMock.Setup(x => x.Alias).Returns("Something");
// but MVC View already exists
Mock.Get(_fileSystems.MvcViewsFileSystem)
.Setup(x => x.FileExists(It.IsAny<string>())).Returns(true);
Mock.Get(_fileSystems.MasterPagesFileSystem)
.Setup(x => x.FileExists(It.IsAny<string>())).Returns(false);
var res = _templateRepository.DetermineTemplateRenderingEngine(templateMock.Object);
Assert.AreEqual(RenderingEngine.Mvc, res);
}
}
}
@@ -60,8 +60,7 @@ namespace Umbraco.Tests.TestHelpers.ControllerTesting
memberTypeService: mockedMemberTypeService,
dataTypeService: mockedDataTypeService,
contentTypeService: mockedContentTypeService,
localizedTextService:Mock.Of<ILocalizedTextService>(),
sectionService:Mock.Of<ISectionService>());
localizedTextService:Mock.Of<ILocalizedTextService>());
var globalSettings = SettingsForTests.GenerateMockGlobalSettings();
@@ -38,7 +38,6 @@ namespace Umbraco.Tests.TestHelpers
var content = new Mock<IContentSection>();
var security = new Mock<ISecuritySection>();
var requestHandler = new Mock<IRequestHandlerSection>();
var templates = new Mock<ITemplatesSection>();
var logging = new Mock<ILoggingSection>();
var tasks = new Mock<IScheduledTasksSection>();
var providers = new Mock<IProvidersSection>();
@@ -47,7 +46,6 @@ namespace Umbraco.Tests.TestHelpers
settings.Setup(x => x.Content).Returns(content.Object);
settings.Setup(x => x.Security).Returns(security.Object);
settings.Setup(x => x.RequestHandler).Returns(requestHandler.Object);
settings.Setup(x => x.Templates).Returns(templates.Object);
settings.Setup(x => x.Logging).Returns(logging.Object);
settings.Setup(x => x.ScheduledTasks).Returns(tasks.Object);
settings.Setup(x => x.Providers).Returns(providers.Object);
@@ -61,7 +59,6 @@ namespace Umbraco.Tests.TestHelpers
settings.Setup(x => x.RequestHandler.UseDomainPrefixes).Returns(false);
settings.Setup(x => x.RequestHandler.CharCollection).Returns(RequestHandlerElement.GetDefaultCharReplacements());
settings.Setup(x => x.WebRouting.UrlProviderMode).Returns("AutoLegacy");
settings.Setup(x => x.Templates.DefaultRenderingEngine).Returns(RenderingEngine.Mvc);
settings.Setup(x => x.Providers.DefaultBackOfficeUserProvider).Returns("UsersMembershipProvider");
return settings.Object;
+2 -3
View File
@@ -55,12 +55,12 @@ namespace Umbraco.Tests.TestHelpers
public static void InitializeContentDirectories()
{
CreateDirectories(new[] { SystemDirectories.Masterpages, SystemDirectories.MvcViews, SystemDirectories.Media, SystemDirectories.AppPlugins });
CreateDirectories(new[] { SystemDirectories.MvcViews, SystemDirectories.Media, SystemDirectories.AppPlugins });
}
public static void CleanContentDirectories()
{
CleanDirectories(new[] { SystemDirectories.Masterpages, SystemDirectories.MvcViews, SystemDirectories.Media });
CleanDirectories(new[] { SystemDirectories.MvcViews, SystemDirectories.Media });
}
public static void CreateDirectories(string[] directories)
@@ -77,7 +77,6 @@ namespace Umbraco.Tests.TestHelpers
{
var preserves = new Dictionary<string, string[]>
{
{ SystemDirectories.Masterpages, new[] {"dummy.txt"} },
{ SystemDirectories.MvcViews, new[] {"dummy.txt"} }
};
foreach (var directory in directories)
@@ -73,8 +73,6 @@ namespace Umbraco.Tests.TestHelpers
MockService<IMemberTypeService>(container),
MockService<IMemberService>(container),
MockService<IUserService>(container),
MockService<ISectionService>(container),
MockService<IApplicationTreeService>(container),
MockService<ITagService>(container),
MockService<INotificationService>(container),
MockService<ILocalizedTextService>(container),
@@ -145,8 +143,7 @@ namespace Umbraco.Tests.TestHelpers
public IFileSystems GetFileSystemsMock()
{
var fileSystems = Mock.Of<IFileSystems>();
MockFs(fileSystems, x => x.MasterPagesFileSystem);
MockFs(fileSystems, x => x.MacroPartialsFileSystem);
MockFs(fileSystems, x => x.MvcViewsFileSystem);
MockFs(fileSystems, x => x.PartialViewsFileSystem);
+1 -5
View File
@@ -188,9 +188,7 @@ namespace Umbraco.Tests.TestHelpers
new DirectoryInfo(IOHelper.GetRootDirectorySafe())));
});
var relationService = GetLazyService<IRelationService>(factory, c => new RelationService(scopeProvider, logger, eventMessagesFactory, entityService.Value, GetRepo<IRelationRepository>(c), GetRepo<IRelationTypeRepository>(c)));
var treeService = GetLazyService<IApplicationTreeService>(factory, c => new ApplicationTreeService(logger, cache, typeLoader));
var tagService = GetLazyService<ITagService>(factory, c => new TagService(scopeProvider, logger, eventMessagesFactory, GetRepo<ITagRepository>(c)));
var sectionService = GetLazyService<ISectionService>(factory, c => new SectionService(userService.Value, treeService.Value, scopeProvider, cache));
var tagService = GetLazyService<ITagService>(factory, c => new TagService(scopeProvider, logger, eventMessagesFactory, GetRepo<ITagRepository>(c)));
var redirectUrlService = GetLazyService<IRedirectUrlService>(factory, c => new RedirectUrlService(scopeProvider, logger, eventMessagesFactory, GetRepo<IRedirectUrlRepository>(c)));
var consentService = GetLazyService<IConsentService>(factory, c => new ConsentService(scopeProvider, logger, eventMessagesFactory, GetRepo<IConsentRepository>(c)));
@@ -213,8 +211,6 @@ namespace Umbraco.Tests.TestHelpers
serverRegistrationService,
entityService,
relationService,
treeService,
sectionService,
macroService,
memberTypeService,
memberGroupService,
@@ -8,10 +8,6 @@ namespace Umbraco.Tests.Testing.Objects.Accessors
public class TestVariationContextAccessor : IVariationContextAccessor
{
/// <inheritdoc />
public VariationContext VariationContext
{
get;
set;
}
public VariationContext VariationContext { get; set; }
}
}
+12 -2
View File
@@ -40,6 +40,7 @@ using Umbraco.Web.Composing.Composers;
using Umbraco.Web.ContentApps;
using Current = Umbraco.Core.Composing.Current;
using Umbraco.Web.Routing;
using Umbraco.Web.Trees;
namespace Umbraco.Tests.Testing
{
@@ -216,6 +217,16 @@ namespace Umbraco.Tests.Testing
Composition.WithCollectionBuilder<ContentFinderCollectionBuilder>();
Composition.RegisterUnique<IContentLastChanceFinder, TestLastChanceFinder>();
Composition.RegisterUnique<IVariationContextAccessor, TestVariationContextAccessor>();
// register back office sections in the order we want them rendered
Composition.WithCollectionBuilder<BackOfficeSectionCollectionBuilder>().Append<ContentBackOfficeSection>()
.Append<MediaBackOfficeSection>()
.Append<SettingsBackOfficeSection>()
.Append<PackagesBackOfficeSection>()
.Append<UsersBackOfficeSection>()
.Append<MembersBackOfficeSection>()
.Append<TranslationBackOfficeSection>();
Composition.RegisterUnique<ISectionService, SectionService>();
}
protected virtual void ComposeWtf()
@@ -304,7 +315,6 @@ namespace Umbraco.Tests.Testing
// register basic stuff that might need to be there for some container resolvers to work
Composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Content);
Composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().Templates);
Composition.RegisterUnique(factory => factory.GetInstance<IUmbracoSettingsSection>().WebRouting);
Composition.RegisterUnique<IExamineManager>(factory => ExamineManager.Instance);
@@ -342,7 +352,7 @@ namespace Umbraco.Tests.Testing
Composition.ComposeServices();
// composition root is doing weird things, fix
Composition.RegisterUnique<IApplicationTreeService, ApplicationTreeService>();
Composition.RegisterUnique<ITreeService, TreeService>();
Composition.RegisterUnique<ISectionService, SectionService>();
// somehow property editor ends up wanting this
@@ -1,397 +0,0 @@
using System.IO;
using NUnit.Framework;
using Umbraco.Core.Services;
using Umbraco.Tests.TestHelpers;
using System;
using System.Linq;
using System.Threading;
using Umbraco.Tests.Testing;
using Umbraco.Web.Services;
using Current = Umbraco.Web.Composing.Current;
namespace Umbraco.Tests.TreesAndSections
{
/// <summary>
///This is a test class for ApplicationTreeTest and is intended
///to contain all ApplicationTreeTest Unit Tests
///</summary>
[TestFixture]
[Apartment(ApartmentState.STA)]
[UmbracoTest(Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class ApplicationTreeTest : TestWithDatabaseBase
{
public override void SetUp()
{
base.SetUp();
var treesConfig = TestHelper.MapPathForTest("~/TEMP/TreesAndSections/trees.config");
var appConfig = TestHelper.MapPathForTest("~/TEMP/TreesAndSections/applications.config");
Directory.CreateDirectory(TestHelper.MapPathForTest("~/TEMP/TreesAndSections"));
using (var writer = File.CreateText(treesConfig))
{
writer.Write(ResourceFiles.trees);
}
using (var writer = File.CreateText(appConfig))
{
writer.Write(ResourceFiles.applications);
}
ApplicationTreeService.TreeConfigFilePath = treesConfig;
SectionService.AppConfigFilePath = appConfig;
}
public override void TearDown()
{
base.TearDown();
if (Directory.Exists(TestHelper.MapPathForTest("~/TEMP/TreesAndSections")))
{
Directory.Delete(TestHelper.MapPathForTest("~/TEMP/TreesAndSections"), true);
}
ApplicationTreeService.TreeConfigFilePath = null;
SectionService.AppConfigFilePath = null;
}
/// <summary>
/// Creates a new app tree linked to an application, then delete the application and make sure the tree is gone as well
///</summary>
[Test()]
public void ApplicationTree_Make_New_Then_Delete_App()
{
//create new app
var appName = Guid.NewGuid().ToString("N");
var treeName = Guid.NewGuid().ToString("N");
Current.Services.SectionService.MakeNew(appName, appName, "icon.jpg");
//check if it exists
var app = Current.Services.SectionService.GetByAlias(appName);
Assert.IsNotNull(app);
//create the new app tree assigned to the new app
Current.Services.ApplicationTreeService.MakeNew(false, 0, app.Alias, treeName, treeName, "icon.jpg", "icon.jpg", "Umbraco.Web.Trees.ContentTreeController, Umbraco.Web");
var tree = Current.Services.ApplicationTreeService.GetByAlias(treeName);
Assert.IsNotNull(tree);
//now delete the app
Current.Services.SectionService.DeleteSection(app);
//check that the tree is gone
Assert.AreEqual(0, Current.Services.ApplicationTreeService.GetApplicationTrees(treeName).Count());
}
#region Tests to write
///// <summary>
/////A test for ApplicationTree Constructor
/////</summary>
//[TestMethod()]
//public void ApplicationTreeConstructorTest()
//{
// bool silent = false; // TODO: Initialize to an appropriate value
// bool initialize = false; // TODO: Initialize to an appropriate value
// byte sortOrder = 0; // TODO: Initialize to an appropriate value
// string applicationAlias = string.Empty; // TODO: Initialize to an appropriate value
// string alias = string.Empty; // TODO: Initialize to an appropriate value
// string title = string.Empty; // TODO: Initialize to an appropriate value
// string iconClosed = string.Empty; // TODO: Initialize to an appropriate value
// string iconOpened = string.Empty; // TODO: Initialize to an appropriate value
// string assemblyName = string.Empty; // TODO: Initialize to an appropriate value
// string type = string.Empty; // TODO: Initialize to an appropriate value
// string action = string.Empty; // TODO: Initialize to an appropriate value
// ApplicationTree target = new ApplicationTree(silent, initialize, sortOrder, applicationAlias, alias, title, iconClosed, iconOpened, assemblyName, type, action);
// Assert.Inconclusive("TODO: Implement code to verify target");
//}
///// <summary>
/////A test for ApplicationTree Constructor
/////</summary>
//[TestMethod()]
//public void ApplicationTreeConstructorTest1()
//{
// ApplicationTree target = new ApplicationTree();
// Assert.Inconclusive("TODO: Implement code to verify target");
//}
///// <summary>
/////A test for Delete
/////</summary>
//[TestMethod()]
//public void DeleteTest()
//{
// ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
// target.Delete();
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
//}
///// <summary>
/////A test for Save
/////</summary>
//[TestMethod()]
//public void SaveTest()
//{
// ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
// target.Save();
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
//}
///// <summary>
/////A test for getAll
/////</summary>
//[TestMethod()]
//public void getAllTest()
//{
// ApplicationTree[] expected = null; // TODO: Initialize to an appropriate value
// ApplicationTree[] actual;
// actual = ApplicationTree.getAll();
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for getApplicationTree
/////</summary>
//[TestMethod()]
//public void getApplicationTreeTest()
//{
// string applicationAlias = string.Empty; // TODO: Initialize to an appropriate value
// ApplicationTree[] expected = null; // TODO: Initialize to an appropriate value
// ApplicationTree[] actual;
// actual = ApplicationTree.getApplicationTree(applicationAlias);
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for getApplicationTree
/////</summary>
//[TestMethod()]
//public void getApplicationTreeTest1()
//{
// string applicationAlias = string.Empty; // TODO: Initialize to an appropriate value
// bool onlyInitializedApplications = false; // TODO: Initialize to an appropriate value
// ApplicationTree[] expected = null; // TODO: Initialize to an appropriate value
// ApplicationTree[] actual;
// actual = ApplicationTree.getApplicationTree(applicationAlias, onlyInitializedApplications);
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for getByAlias
/////</summary>
//[TestMethod()]
//public void getByAliasTest()
//{
// string treeAlias = string.Empty; // TODO: Initialize to an appropriate value
// ApplicationTree expected = null; // TODO: Initialize to an appropriate value
// ApplicationTree actual;
// actual = ApplicationTree.getByAlias(treeAlias);
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for Action
/////</summary>
//[TestMethod()]
//public void ActionTest()
//{
// ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
// string expected = string.Empty; // TODO: Initialize to an appropriate value
// string actual;
// target.Action = expected;
// actual = target.Action;
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for Alias
/////</summary>
//[TestMethod()]
//public void AliasTest()
//{
// ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
// string actual;
// actual = target.Alias;
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for ApplicationAlias
/////</summary>
//[TestMethod()]
//public void ApplicationAliasTest()
//{
// ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
// string actual;
// actual = target.ApplicationAlias;
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for AssemblyName
/////</summary>
//[TestMethod()]
//public void AssemblyNameTest()
//{
// ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
// string expected = string.Empty; // TODO: Initialize to an appropriate value
// string actual;
// target.AssemblyName = expected;
// actual = target.AssemblyName;
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for IconClosed
/////</summary>
//[TestMethod()]
//public void IconClosedTest()
//{
// ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
// string expected = string.Empty; // TODO: Initialize to an appropriate value
// string actual;
// target.IconClosed = expected;
// actual = target.IconClosed;
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for IconOpened
/////</summary>
//[TestMethod()]
//public void IconOpenedTest()
//{
// ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
// string expected = string.Empty; // TODO: Initialize to an appropriate value
// string actual;
// target.IconOpened = expected;
// actual = target.IconOpened;
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for Initialize
/////</summary>
//[TestMethod()]
//public void InitializeTest()
//{
// ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
// bool expected = false; // TODO: Initialize to an appropriate value
// bool actual;
// target.Initialize = expected;
// actual = target.Initialize;
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for Silent
/////</summary>
//[TestMethod()]
//public void SilentTest()
//{
// ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
// bool expected = false; // TODO: Initialize to an appropriate value
// bool actual;
// target.Silent = expected;
// actual = target.Silent;
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for SortOrder
/////</summary>
//[TestMethod()]
//public void SortOrderTest()
//{
// ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
// byte expected = 0; // TODO: Initialize to an appropriate value
// byte actual;
// target.SortOrder = expected;
// actual = target.SortOrder;
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for SqlHelper
/////</summary>
//[TestMethod()]
//public void SqlHelperTest()
//{
// ISqlHelper actual;
// actual = ApplicationTree.SqlHelper;
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for Title
/////</summary>
//[TestMethod()]
//public void TitleTest()
//{
// ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
// string expected = string.Empty; // TODO: Initialize to an appropriate value
// string actual;
// target.Title = expected;
// actual = target.Title;
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for Type
/////</summary>
//[TestMethod()]
//public void TypeTest()
//{
// ApplicationTree target = new ApplicationTree(); // TODO: Initialize to an appropriate value
// string expected = string.Empty; // TODO: Initialize to an appropriate value
// string actual;
// target.Type = expected;
// actual = target.Type;
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
#endregion
#region Additional test attributes
//
//You can use the following additional attributes as you write your tests:
//
//Use ClassInitialize to run code before running the first test in the class
//[ClassInitialize()]
//public static void MyClassInitialize(TestContext testContext)
//{
//}
//
//Use ClassCleanup to run code after all tests in a class have run
//[ClassCleanup()]
//public static void MyClassCleanup()
//{
//}
//
//Use TestInitialize to run code before running each test
//[TestInitialize()]
//public void MyTestInitialize()
//{
//}
//
//Use TestCleanup to run code after each test has run
//[TestCleanup()]
//public void MyTestCleanup()
//{
//}
//
#endregion
}
}
@@ -1,91 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Umbraco.Tests.TreesAndSections {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "15.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class ResourceFiles {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal ResourceFiles() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Umbraco.Tests.TreesAndSections.ResourceFiles", typeof(ResourceFiles).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
///&lt;applications&gt;
/// &lt;add alias=&quot;content&quot; name=&quot;content&quot; icon=&quot;file&quot; sortOrder=&quot;0&quot; /&gt;
/// &lt;add alias=&quot;0b486ac9c0f1456996192c6ed1f03e57&quot; name=&quot;0b486ac9c0f1456996192c6ed1f03e57&quot; icon=&quot;icon.jpg&quot; sortOrder=&quot;1&quot; /&gt;
/// &lt;add alias=&quot;1ffbc301744c4e75ae3054d741954c7b&quot; name=&quot;1ffbc301744c4e75ae3054d741954c7b&quot; icon=&quot;icon.jpg&quot; sortOrder=&quot;2&quot; /&gt;
/// &lt;add alias=&quot;1838c3e1591f4008bbafe59a06a00a31&quot; name=&quot;1838c3e1591f4008bbafe59a06a00a31&quot; icon=&quot;icon.jpg&quot; sortOrder=&quot;3&quot; /&gt;
/// &lt;add alias=&quot;e5badae2 [rest of string was truncated]&quot;;.
/// </summary>
internal static string applications {
get {
return ResourceManager.GetString("applications", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
///&lt;trees&gt;
/// &lt;add initialize=&quot;false&quot; sortOrder=&quot;0&quot; alias=&quot;1838c3e1591f4008bbafe59a06a00a31&quot; application=&quot;1838c3e1591f4008bbafe59a06a00a31&quot; title=&quot;1838c3e1591f4008bbafe59a06a00a31&quot; iconClosed=&quot;icon.jpg&quot; iconOpen=&quot;icon.jpg&quot; type=&quot;nulltype&quot; /&gt;
/// &lt;add initialize=&quot;false&quot; sortOrder=&quot;0&quot; alias=&quot;e5badae2fc5e4cd7acb3700320e33b8b&quot; application=&quot;e5badae2fc5e4cd7acb3700320e33b8b&quot; title=&quot;e5badae2fc5e4cd7acb3700320e33b8b&quot; iconClosed=&quot;icon.jpg&quot; iconOpen=&quot;icon.jpg&quot; type=&quot;nulltype&quot; /&gt;
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string trees {
get {
return ResourceManager.GetString("trees", resourceCulture);
}
}
}
}
@@ -1,127 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="applications" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>applications.config;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="trees" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>trees.config;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>
@@ -1,252 +0,0 @@
using System.IO;
using NUnit.Framework;
using Umbraco.Core.Services;
using Umbraco.Tests.TestHelpers;
using System;
using Umbraco.Core.Composing;
using Umbraco.Tests.Testing;
using Umbraco.Web.Services;
namespace Umbraco.Tests.TreesAndSections
{
/// <summary>
///This is a test class for ApplicationTest and is intended
///to contain all ApplicationTest Unit Tests
///</summary>
[TestFixture]
[UmbracoTest(AutoMapper = true, Database = UmbracoTestOptions.Database.NewSchemaPerTest)]
public class SectionTests : TestWithDatabaseBase
{
protected override void Compose()
{
base.Compose();
Composition.RegisterUnique<ISectionService, SectionService>();
}
public override void SetUp()
{
base.SetUp();
var treesConfig = TestHelper.MapPathForTest("~/TEMP/TreesAndSections/trees.config");
var appConfig = TestHelper.MapPathForTest("~/TEMP/TreesAndSections/applications.config");
Directory.CreateDirectory(TestHelper.MapPathForTest("~/TEMP/TreesAndSections"));
using (var writer = File.CreateText(treesConfig))
{
writer.Write(ResourceFiles.trees);
}
using (var writer = File.CreateText(appConfig))
{
writer.Write(ResourceFiles.applications);
}
ApplicationTreeService.TreeConfigFilePath = treesConfig;
SectionService.AppConfigFilePath = appConfig;
}
public override void TearDown()
{
base.TearDown();
if (Directory.Exists(TestHelper.MapPathForTest("~/TEMP/TreesAndSections")))
{
Directory.Delete(TestHelper.MapPathForTest("~/TEMP/TreesAndSections"), true);
}
ApplicationTreeService.TreeConfigFilePath = null;
SectionService.AppConfigFilePath = null;
}
/// <summary>
/// Create a new application and delete it
///</summary>
[Test()]
public void Application_Make_New()
{
var name = Guid.NewGuid().ToString("N");
ServiceContext.SectionService.MakeNew(name, name, "icon.jpg");
//check if it exists
var app = ServiceContext.SectionService.GetByAlias(name);
Assert.IsNotNull(app);
//now remove it
ServiceContext.SectionService.DeleteSection(app);
Assert.IsNull(ServiceContext.SectionService.GetByAlias(name));
}
#region Tests to write
///// <summary>
/////A test for Application Constructor
/////</summary>
//[TestMethod()]
//public void ApplicationConstructorTest()
//{
// string name = string.Empty; // TODO: Initialize to an appropriate value
// string alias = string.Empty; // TODO: Initialize to an appropriate value
// string icon = string.Empty; // TODO: Initialize to an appropriate value
// Application target = new Application(name, alias, icon);
// Assert.Inconclusive("TODO: Implement code to verify target");
//}
///// <summary>
/////A test for Application Constructor
/////</summary>
//[TestMethod()]
//public void ApplicationConstructorTest1()
//{
// Application target = new Application();
// Assert.Inconclusive("TODO: Implement code to verify target");
//}
///// <summary>
/////A test for Delete
/////</summary>
//[TestMethod()]
//public void DeleteTest()
//{
// Application target = new Application(); // TODO: Initialize to an appropriate value
// target.Delete();
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
//}
///// <summary>
/////A test for MakeNew
/////</summary>
//[TestMethod()]
//public void MakeNewTest1()
//{
// string name = string.Empty; // TODO: Initialize to an appropriate value
// string alias = string.Empty; // TODO: Initialize to an appropriate value
// string icon = string.Empty; // TODO: Initialize to an appropriate value
// Application.MakeNew(name, alias, icon);
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
//}
///// <summary>
/////A test for RegisterIApplications
/////</summary>
//[TestMethod()]
//public void RegisterIApplicationsTest()
//{
// Application.RegisterIApplications();
// Assert.Inconclusive("A method that does not return a value cannot be verified.");
//}
///// <summary>
/////A test for getAll
/////</summary>
//[TestMethod()]
//public void getAllTest()
//{
// List<Application> expected = null; // TODO: Initialize to an appropriate value
// List<Application> actual;
// actual = Application.getAll();
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for getByAlias
/////</summary>
//[TestMethod()]
//public void getByAliasTest()
//{
// string appAlias = string.Empty; // TODO: Initialize to an appropriate value
// Application expected = null; // TODO: Initialize to an appropriate value
// Application actual;
// actual = Application.getByAlias(appAlias);
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for SqlHelper
/////</summary>
//[TestMethod()]
//public void SqlHelperTest()
//{
// ISqlHelper actual;
// actual = Application.SqlHelper;
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for alias
/////</summary>
//[TestMethod()]
//public void aliasTest()
//{
// Application target = new Application(); // TODO: Initialize to an appropriate value
// string expected = string.Empty; // TODO: Initialize to an appropriate value
// string actual;
// target.alias = expected;
// actual = target.alias;
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for icon
/////</summary>
//[TestMethod()]
//public void iconTest()
//{
// Application target = new Application(); // TODO: Initialize to an appropriate value
// string expected = string.Empty; // TODO: Initialize to an appropriate value
// string actual;
// target.icon = expected;
// actual = target.icon;
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
///// <summary>
/////A test for name
/////</summary>
//[TestMethod()]
//public void nameTest()
//{
// Application target = new Application(); // TODO: Initialize to an appropriate value
// string expected = string.Empty; // TODO: Initialize to an appropriate value
// string actual;
// target.name = expected;
// actual = target.name;
// Assert.AreEqual(expected, actual);
// Assert.Inconclusive("Verify the correctness of this test method.");
//}
#endregion
#region Additional test attributes
//
//You can use the following additional attributes as you write your tests:
//
//Use ClassInitialize to run code before running the first test in the class
//[ClassInitialize()]
//public static void MyClassInitialize(TestContext testContext)
//{
//}
//
//Use ClassCleanup to run code after all tests in a class have run
//[ClassCleanup()]
//public static void MyClassCleanup()
//{
//}
//
//Use TestInitialize to run code before running each test
//[TestInitialize()]
//public void MyTestInitialize()
//{
//}
//
//Use TestCleanup to run code after each test has run
//[TestCleanup()]
//public void MyTestCleanup()
//{
//}
//
#endregion
}
}
@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<applications>
<add alias="content" name="content" icon="file" sortOrder="0" />
<add alias="0b486ac9c0f1456996192c6ed1f03e57" name="0b486ac9c0f1456996192c6ed1f03e57" icon="icon.jpg" sortOrder="1" />
<add alias="1ffbc301744c4e75ae3054d741954c7b" name="1ffbc301744c4e75ae3054d741954c7b" icon="icon.jpg" sortOrder="2" />
<add alias="1838c3e1591f4008bbafe59a06a00a31" name="1838c3e1591f4008bbafe59a06a00a31" icon="icon.jpg" sortOrder="3" />
<add alias="e5badae2fc5e4cd7acb3700320e33b8b" name="e5badae2fc5e4cd7acb3700320e33b8b" icon="icon.jpg" sortOrder="4" />
<add alias="7ef5094e98b44c7c81049cac17fd0566" name="7ef5094e98b44c7c81049cac17fd0566" icon="icon.jpg" sortOrder="5" />
<add alias="39e14506a6034c9a9aea471878b54733" name="39e14506a6034c9a9aea471878b54733" icon="icon.jpg" sortOrder="6" />
<add alias="a3c13383b3e444b5bc25a79749eb3176" name="a3c13383b3e444b5bc25a79749eb3176" icon="icon.jpg" sortOrder="7" />
<add alias="77c0d250606c4e6da6c7cd14937a38f0" name="77c0d250606c4e6da6c7cd14937a38f0" icon="icon.jpg" sortOrder="8" />
<add alias="9243924456694c6097b04f98e25591bb" name="9243924456694c6097b04f98e25591bb" icon="icon.jpg" sortOrder="9" />
<add alias="b9c3e6664fa348f2a997577650676019" name="b9c3e6664fa348f2a997577650676019" icon="icon.jpg" sortOrder="10" />
<add alias="f3fd12acb6d44d62a3a3e7cddc8dca43" name="f3fd12acb6d44d62a3a3e7cddc8dca43" icon="icon.jpg" sortOrder="11" />
<add alias="05469a0804f3487ebd3882818b098228" name="05469a0804f3487ebd3882818b098228" icon="icon.jpg" sortOrder="12" />
</applications>
@@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<trees>
<add initialize="false" sortOrder="0" alias="1838c3e1591f4008bbafe59a06a00a31" application="1838c3e1591f4008bbafe59a06a00a31" title="1838c3e1591f4008bbafe59a06a00a31" iconClosed="icon.jpg" iconOpen="icon.jpg" type="nulltype" />
<add initialize="false" sortOrder="0" alias="e5badae2fc5e4cd7acb3700320e33b8b" application="e5badae2fc5e4cd7acb3700320e33b8b" title="e5badae2fc5e4cd7acb3700320e33b8b" iconClosed="icon.jpg" iconOpen="icon.jpg" type="nulltype" />
<add initialize="false" sortOrder="0" alias="78e10185a30e4cd889a6d76b9d61603b" application="7ef5094e98b44c7c81049cac17fd0566" title="78e10185a30e4cd889a6d76b9d61603b" iconClosed="icon.jpg" iconOpen="icon.jpg" type="Umbraco.Web.Trees.ContentTreeController, umbraco" />
<add initialize="false" sortOrder="0" alias="f6f8547da73c43268b2866ce46c827cf" application="39e14506a6034c9a9aea471878b54733" title="f6f8547da73c43268b2866ce46c827cf" iconClosed="icon.jpg" iconOpen="icon.jpg" type="Umbraco.Web.Trees.ContentTreeController, umbraco" />
<add initialize="false" sortOrder="0" alias="db96609af99344fbb24b4c418ff64938" application="b9c3e6664fa348f2a997577650676019" title="db96609af99344fbb24b4c418ff64938" iconClosed="icon.jpg" iconOpen="icon.jpg" type="Umbraco.Web.Trees.ContentTreeController, umbraco" />
</trees>
-17
View File
@@ -305,8 +305,6 @@
<Compile Include="Configurations\UmbracoSettings\ScheduledTasksElementTests.cs" />
<Compile Include="Configurations\UmbracoSettings\SecurityElementDefaultTests.cs" />
<Compile Include="Configurations\UmbracoSettings\SecurityElementTests.cs" />
<Compile Include="Configurations\UmbracoSettings\TemplateElementDefaultTests.cs" />
<Compile Include="Configurations\UmbracoSettings\TemplateElementTests.cs" />
<Compile Include="Configurations\UmbracoSettings\UmbracoSettingsTests.cs" />
<Compile Include="Configurations\UmbracoSettings\WebRoutingElementDefaultTests.cs" />
<Compile Include="Configurations\UmbracoSettings\WebRoutingElementTests.cs" />
@@ -354,7 +352,6 @@
<Compile Include="Services\MacroServiceTests.cs" />
<Compile Include="Services\UserServiceTests.cs" />
<Compile Include="Manifest\ManifestParserTests.cs" />
<Compile Include="Templates\TemplateRepositoryTests.cs" />
<Compile Include="Templates\ViewHelperTests.cs" />
<Compile Include="CoreXml\NavigableNavigatorTests.cs" />
<Compile Include="Cache\PublishedCache\PublishedMediaCacheTests.cs" />
@@ -423,13 +420,6 @@
<Compile Include="TestHelpers\Entities\MockedMember.cs" />
<Compile Include="TestHelpers\Entities\MockedUser.cs" />
<Compile Include="TestHelpers\Stubs\TestProfiler.cs" />
<Compile Include="TreesAndSections\ResourceFiles.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>ResourceFiles.resx</DependentUpon>
</Compile>
<Compile Include="TreesAndSections\SectionTests.cs" />
<Compile Include="TreesAndSections\ApplicationTreeTest.cs" />
<Compile Include="CoreThings\ObjectExtensionsTests.cs" />
<Compile Include="Cache\PublishedCache\PublishedContentCacheTests.cs" />
<Compile Include="Composing\LazyCollectionBuilderTests.cs" />
@@ -453,7 +443,6 @@
<Compile Include="Services\ThreadSafetyServiceTest.cs" />
<Compile Include="Web\Controllers\PluginControllerAreaTests.cs" />
<Compile Include="Cache\DistributedCache\DistributedCacheTests.cs" />
<Compile Include="Templates\MasterPageHelperTests.cs" />
<Compile Include="TestHelpers\TestWithDatabaseBase.cs" />
<Compile Include="TestHelpers\SettingsForTests.cs" />
<Compile Include="Configurations\GlobalSettingsTests.cs" />
@@ -525,8 +514,6 @@
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<EmbeddedResource Include="TreesAndSections\applications.config" />
<EmbeddedResource Include="TreesAndSections\trees.config" />
<None Include="Packaging\Packages\Document_Type_Picker_1.1.umb" />
<None Include="UmbracoExamine\TestFiles\umbraco-sort.config">
<SubType>Designer</SubType>
@@ -561,10 +548,6 @@
<LastGenOutput>ImportResources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="TreesAndSections\ResourceFiles.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ResourceFiles.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="UmbracoExamine\TestFiles.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>TestFiles.Designer.cs</LastGenOutput>
+52
View File
@@ -0,0 +1,52 @@
'use strict';
module.exports = {
sources: {
//less files used by backoffice and preview
//processed in the less task
less: {
installer: { files: ["./src/less/installer.less"], out: "installer.css" },
nonodes: { files: ["./src/less/pages/nonodes.less"], out: "nonodes.style.min.css"},
preview: { files: ["./src/less/canvas-designer.less"], out: "canvasdesigner.css" },
umbraco: { files: ["./src/less/belle.less"], out: "umbraco.css" }
},
//js files for backoffie
//processed in the js task
js: {
preview: { files: ["./src/preview/**/*.js"], out: "umbraco.preview.js" },
installer: { files: ["./src/installer/**/*.js"], out: "umbraco.installer.js" },
controllers: { files: ["./src/{views,controllers}/**/*.controller.js"], out: "umbraco.controllers.js" },
directives: { files: ["./src/common/directives/**/*.js"], out: "umbraco.directives.js" },
filters: { files: ["./src/common/filters/**/*.js"], out: "umbraco.filters.js" },
resources: { files: ["./src/common/resources/**/*.js"], out: "umbraco.resources.js" },
services: { files: ["./src/common/services/**/*.js"], out: "umbraco.services.js" },
security: { files: ["./src/common/interceptors/**/*.js"], out: "umbraco.interceptors.js" }
},
//selectors for copying all views into the build
//processed in the views task
views:{
umbraco: {files: ["./src/views/**/*.html"], folder: ""},
installer: {files: ["./src/installer/steps/*.html"], folder: "install/"}
},
//globs for file-watching
globs:{
views: "./src/views/**/*.html",
less: "./src/less/**/*.less",
js: "./src/*.js",
lib: "./lib/**/*",
assets: "./src/assets/**"
}
},
root: "../Umbraco.Web.UI/Umbraco/",
targets: {
js: "js/",
lib: "lib/",
views: "views/",
css: "assets/css/",
assets: "assets/"
}
};
+10
View File
@@ -0,0 +1,10 @@
'use strict';
var fs = require('fs');
var onlyScripts = require('./util/scriptFilter');
var tasks = fs.readdirSync('./gulp/tasks/').filter(onlyScripts);
tasks.forEach(function(task) {
require('./tasks/' + task);
});
@@ -0,0 +1,10 @@
'use strict';
var config = require('../config');
var gulp = require('gulp');
var runSequence = require('run-sequence');
// Build - build the files ready for production
gulp.task('build', function(cb) {
runSequence(["dependencies", "js", "less", "views"], cb);
});
@@ -0,0 +1,288 @@
'use strict';
var config = require('../config');
var gulp = require('gulp');
var MergeStream = require('merge-stream');
var imagemin = require('gulp-imagemin');
/**************************
* Task processes and copies all dependencies, either installed by npm or stored locally in the project
**************************/
gulp.task('dependencies', function () {
//as we do multiple things in this task, we merge the multiple streams
var stream = new MergeStream();
// Pick the dependencies we need from each package
// so we don't just ship with a lot of files that aren't needed
const nodeModules = [
{
"name": "ace-builds",
"src": [
"./node_modules/ace-builds/src-min-noconflict/ace.js",
"./node_modules/ace-builds/src-min-noconflict/ext-language_tools.js",
"./node_modules/ace-builds/src-min-noconflict/ext-searchbox.js",
"./node_modules/ace-builds/src-min-noconflict/ext-settings_menu.js",
"./node_modules/ace-builds/src-min-noconflict/snippets/text.js",
"./node_modules/ace-builds/src-min-noconflict/snippets/javascript.js",
"./node_modules/ace-builds/src-min-noconflict/snippets/css.js",
"./node_modules/ace-builds/src-min-noconflict/theme-chrome.js",
"./node_modules/ace-builds/src-min-noconflict/mode-razor.js",
"./node_modules/ace-builds/src-min-noconflict/mode-javascript.js",
"./node_modules/ace-builds/src-min-noconflict/mode-css.js",
"./node_modules/ace-builds/src-min-noconflict/worker-javascript.js",
"./node_modules/ace-builds/src-min-noconflict/worker-css.js"
],
"base": "./node_modules/ace-builds"
},
{
"name": "angular",
"src": ["./node_modules/angular/angular.js"],
"base": "./node_modules/angular"
},
{
"name": "angular-cookies",
"src": ["./node_modules/angular-cookies/angular-cookies.js"],
"base": "./node_modules/angular-cookies"
},
{
"name": "angular-dynamic-locale",
"src": [
"./node_modules/angular-dynamic-locale/dist/tmhDynamicLocale.min.js",
"./node_modules/angular-dynamic-locale/dist/tmhDynamicLocale.min.js.map"
],
"base": "./node_modules/angular-dynamic-locale/dist"
},
{
"name": "angular-sanitize",
"src": ["./node_modules/angular-sanitize/angular-sanitize.js"],
"base": "./node_modules/angular-sanitize"
},
{
"name": "angular-touch",
"src": ["./node_modules/angular-touch/angular-touch.js"],
"base": "./node_modules/angular-touch"
},
{
"name": "angular-ui-sortable",
"src": ["./node_modules/angular-ui-sortable/dist/sortable.js"],
"base": "./node_modules/angular-ui-sortable/dist"
},
{
"name": "angular-route",
"src": ["./node_modules/angular-route/angular-route.js"],
"base": "./node_modules/angular-route"
},
{
"name": "angular-animate",
"src": ["./node_modules/angular-animate/angular-animate.js"],
"base": "./node_modules/angular-animate"
},
{
"name": "angular-i18n",
"src": [
"./node_modules/angular-i18n/angular-i18n.js",
"./node_modules/angular-i18n/angular-locale_*.js"
],
"base": "./node_modules/angular-i18n"
},
{
"name": "angular-local-storage",
"src": [
"./node_modules/angular-local-storage/dist/angular-local-storage.min.js",
"./node_modules/angular-local-storage/dist/angular-local-storage.min.js.map"
],
"base": "./node_modules/angular-local-storage/dist"
},
{
"name": "angular-messages",
"src": ["./node_modules/angular-messages/angular-messages.js"],
"base": "./node_modules/angular-messages"
},
{
"name": "angular-mocks",
"src": ["./node_modules/angular-mocks/angular-mocks.js"],
"base": "./node_modules/angular-mocks"
},
{
"name": "animejs",
"src": ["./node_modules/animejs/anime.min.js"],
"base": "./node_modules/animejs"
},
{
"name": "bootstrap-social",
"src": ["./node_modules/bootstrap-social/bootstrap-social.css"],
"base": "./node_modules/bootstrap-social"
},
{
"name": "angular-chart.js",
"src": ["./node_modules/angular-chart.js/dist/angular-chart.min.js"],
"base": "./node_modules/angular-chart.js/dist"
},
{
"name": "chart.js",
"src": ["./node_modules/chart.js/dist/chart.min.js"],
"base": "./node_modules/chart.js/dist"
},
{
"name": "clipboard",
"src": ["./node_modules/clipboard/dist/clipboard.min.js"],
"base": "./node_modules/clipboard/dist"
},
{
"name": "jsdiff",
"src": ["./node_modules/diff/dist/diff.min.js"],
"base": "./node_modules/diff/dist"
},
{
"name": "flatpickr",
"src": [
"./node_modules/flatpickr/dist/flatpickr.js",
"./node_modules/flatpickr/dist/flatpickr.css"
],
"base": "./node_modules/flatpickr/dist"
},
{
"name": "font-awesome",
"src": [
"./node_modules/font-awesome/fonts/*",
"./node_modules/font-awesome/css/font-awesome.min.css"
],
"base": "./node_modules/font-awesome"
},
{
"name": "jquery",
"src": [
"./node_modules/jquery/dist/jquery.min.js",
"./node_modules/jquery/dist/jquery.min.map"
],
"base": "./node_modules/jquery/dist"
},
{
"name": "jquery-ui",
"src": ["./node_modules/jquery-ui-dist/jquery-ui.min.js"],
"base": "./node_modules/jquery-ui-dist"
},
{
"name": "jquery-ui-touch-punch",
"src": ["./node_modules/jquery-ui-touch-punch/jquery.ui.touch-punch.min.js"],
"base": "./node_modules/jquery-ui-touch-punch"
},
{
"name": "lazyload-js",
"src": ["./node_modules/lazyload-js/lazyload.min.js"],
"base": "./node_modules/lazyload-js"
},
{
"name": "moment",
"src": ["./node_modules/moment/min/moment.min.js"],
"base": "./node_modules/moment/min"
},
{
"name": "moment",
"src": ["./node_modules/moment/locale/*.js"],
"base": "./node_modules/moment/locale"
},
{
"name": "ng-file-upload",
"src": ["./node_modules/ng-file-upload/dist/ng-file-upload.min.js"],
"base": "./node_modules/ng-file-upload/dist"
},
{
"name": "nouislider",
"src": [
"./node_modules/nouislider/distribute/nouislider.min.js",
"./node_modules/nouislider/distribute/nouislider.min.css"
],
"base": "./node_modules/nouislider/distribute"
},
{
"name": "signalr",
"src": ["./node_modules/signalr/jquery.signalR.js"],
"base": "./node_modules/signalr"
},
{
"name": "spectrum",
"src": [
"./node_modules/spectrum-colorpicker/spectrum.js",
"./node_modules/spectrum-colorpicker/spectrum.css"
],
"base": "./node_modules/spectrum-colorpicker"
},
{
"name": "tinymce",
"src": [
"./node_modules/tinymce/tinymce.min.js",
"./node_modules/tinymce/plugins/**",
"./node_modules/tinymce/skins/**",
"./node_modules/tinymce/themes/**"
],
"base": "./node_modules/tinymce"
},
{
"name": "typeahead.js",
"src": ["./node_modules/typeahead.js/dist/typeahead.bundle.min.js"],
"base": "./node_modules/typeahead.js/dist"
},
{
"name": "underscore",
"src": ["node_modules/underscore/underscore-min.js"],
"base": "./node_modules/underscore"
}
];
// add streams for node modules
nodeModules.forEach(module => {
stream.add(
gulp.src(module.src,
{ base: module.base })
.pipe(gulp.dest(config.root + config.targets.lib + "/" + module.name))
);
});
//copy over libs which are not on npm (/lib)
stream.add(
gulp.src(config.sources.globs.lib)
.pipe(gulp.dest(config.root + config.targets.lib))
);
//Copies all static assets into /root / assets folder
//css, fonts and image files
stream.add(
gulp.src(config.sources.globs.assets)
.pipe(imagemin([
imagemin.gifsicle({interlaced: true}),
imagemin.jpegtran({progressive: true}),
imagemin.optipng({optimizationLevel: 5}),
imagemin.svgo({
plugins: [
{removeViewBox: true},
{cleanupIDs: false}
]
})
]))
.pipe(gulp.dest(config.root + config.targets.assets))
);
// Copies all the less files related to the preview into their folder
//these are not pre-processed as preview has its own less combiler client side
stream.add(
gulp.src("src/canvasdesigner/editors/*.less")
.pipe(gulp.dest(config.root + config.targets.assets + "/less"))
);
// Todo: check if we need these fileSize
stream.add(
gulp.src("src/views/propertyeditors/grid/config/*.*")
.pipe(gulp.dest(config.root + config.targets.views + "/propertyeditors/grid/config"))
);
stream.add(
gulp.src("src/views/dashboard/default/*.jpg")
.pipe(gulp.dest(config.root + config.targets.views + "/dashboard/default"))
);
return stream;
});
@@ -0,0 +1,10 @@
'use strict';
var config = require('../config');
var gulp = require('gulp');
var runSequence = require('run-sequence');
// Dev - build the files ready for development and start watchers
gulp.task('dev', function(cb) {
runSequence(["dependencies", "js", "less", "views"], "watch", cb);
});
@@ -0,0 +1,55 @@
'use strict';
var config = require('../config');
var gulp = require('gulp');
var connect = require('gulp-connect');
var open = require('gulp-open');
var gulpDocs = require('gulp-ngdocs');
/**************************
* Build Backoffice UI API documentation
**************************/
gulp.task('docs', [], function (cb) {
var options = {
html5Mode: false,
startPage: '/api',
title: "Umbraco Backoffice UI API Documentation",
dest: 'docs/api',
styles: ['docs/umb-docs.css'],
image: "https://our.umbraco.com/assets/images/logo.svg"
}
return gulpDocs.sections({
api: {
glob: ['src/common/**/*.js', 'docs/src/api/**/*.ngdoc'],
api: true,
title: 'API Documentation'
}
})
.pipe(gulpDocs.process(options))
.pipe(gulp.dest('docs/api'));
cb();
});
gulp.task('connect:docs', function (cb) {
connect.server({
root: 'docs/api',
livereload: true,
fallback: 'docs/api/index.html',
port: 8880
});
cb();
});
gulp.task('open:docs', function (cb) {
var options = {
uri: 'http://localhost:8880/index.html'
};
gulp.src(__filename)
.pipe(open(options));
cb();
});
@@ -0,0 +1,10 @@
'use strict';
var config = require('../config');
var gulp = require('gulp');
var runSequence = require('run-sequence');
// Docserve - build and open the back office documentation
gulp.task('docserve', function(cb) {
runSequence('docs', 'connect:docs', 'open:docs', cb);
});
@@ -0,0 +1,13 @@
'use strict';
var config = require('../config');
var gulp = require('gulp');
var runSequence = require('run-sequence');
// Dev - build the files ready for development and start watchers
gulp.task('fastdev', function(cb) {
global.isProd = false;
runSequence(["dependencies", "js", "less", "views"], "watch", cb);
});
@@ -0,0 +1,29 @@
'use strict';
var config = require('../config');
var gulp = require('gulp');
var _ = require('lodash');
var MergeStream = require('merge-stream');
var processJs = require('../util/processJs');
/**************************
* Copies all angular JS files into their seperate umbraco.*.js file
**************************/
gulp.task('js', function () {
//we run multiple streams, so merge them all together
var stream = new MergeStream();
stream.add(
gulp.src(config.sources.globs.js)
.pipe(gulp.dest(config.root + config.targets.js))
);
_.forEach(config.sources.js, function (group) {
stream.add (processJs(group.files, group.out) );
});
return stream;
});
@@ -0,0 +1,20 @@
'use strict';
var config = require('../config');
var gulp = require('gulp');
var _ = require('lodash');
var MergeStream = require('merge-stream');
var processLess = require('../util/processLess');
gulp.task('less', function () {
var stream = new MergeStream();
_.forEach(config.sources.less, function (group) {
stream.add( processLess(group.files, group.out) );
});
return stream;
});
@@ -0,0 +1,26 @@
'use strict';
var config = require('../config');
var gulp = require('gulp');
var karmaServer = require('karma').Server;
/**************************
* Build tests
**************************/
// Karma test
gulp.task('test:unit', function() {
new karmaServer({
configFile: __dirname + "/test/config/karma.conf.js",
keepalive: true
})
.start();
});
gulp.task('test:e2e', function() {
new karmaServer({
configFile: __dirname + "/test/config/e2e.js",
keepalive: true
})
.start();
});
@@ -0,0 +1,25 @@
'use strict';
var config = require('../config');
var gulp = require('gulp');
var _ = require('lodash');
var MergeStream = require('merge-stream');
gulp.task('views', function () {
var stream = new MergeStream();
_.forEach(config.sources.views, function (group) {
console.log("copying " + group.files + " to " + config.root + config.targets.views + group.folder)
stream.add (
gulp.src(group.files)
.pipe( gulp.dest(config.root + config.targets.views + group.folder) )
);
});
return stream;
});
@@ -0,0 +1,58 @@
'use strict';
var config = require('../config');
var gulp = require('gulp');
var _ = require('lodash');
var MergeStream = require('merge-stream');
var processJs = require('../util/processJs');
var watch = require('gulp-watch');
gulp.task('watch', function () {
var stream = new MergeStream();
var watchInterval = 500;
//Setup a watcher for all groups of javascript files
_.forEach(config.sources.js, function (group) {
if(group.watch !== false){
stream.add(
watch(group.files, { ignoreInitial: true, interval: watchInterval }, function (file) {
console.info(file.path + " has changed, added to: " + group.out);
processJs(group.files, group.out);
})
);
}
});
stream.add(
//watch all less files and trigger the less task
watch(config.sources.globs.less, { ignoreInitial: true, interval: watchInterval }, function () {
gulp.run(['less']);
})
);
//watch all views - copy single file changes
stream.add(
watch(config.sources.globs.views, { interval: watchInterval })
.pipe(gulp.dest(config.root + config.targets.views))
);
//watch all app js files that will not be merged - copy single file changes
stream.add(
watch(config.sources.globs.js, { interval: watchInterval })
.pipe(gulp.dest(config.root + config.targets.js))
);
return stream;
});
+18
View File
@@ -0,0 +1,18 @@
'use strict';
var notify = require('gulp-notify');
module.exports = function(error) {
var args = Array.prototype.slice.call(arguments);
// Send error to notification center with gulp-notify
notify.onError({
title: 'Compile Error',
message: '<%= error.message %>'
}).apply(this, args);
// Keep gulp from hanging on this task
this.emit('end');
};
@@ -0,0 +1,32 @@
var config = require('../config');
var gulp = require('gulp');
var eslint = require('gulp-eslint');
var babel = require("gulp-babel");
var sort = require('gulp-sort');
var concat = require('gulp-concat');
var wrap = require("gulp-wrap-js");
module.exports = function(files, out) {
var task = gulp.src(files);
if (global.isProd === true) {
// check for js errors
task = task.pipe(eslint());
// outputs the lint results to the console
task = task.pipe(eslint.format());
}
// sort files in stream by path or any custom sort comparator
task = task.pipe(babel())
.pipe(sort())
.pipe(concat(out))
.pipe(wrap('(function(){\n%= body %\n})();'))
.pipe(gulp.dest(config.root + config.targets.js));
return task;
};
@@ -0,0 +1,33 @@
var config = require('../config');
var gulp = require('gulp');
var postcss = require('gulp-postcss');
var less = require('gulp-less');
var autoprefixer = require('autoprefixer');
var cssnano = require('cssnano');
var cleanCss = require("gulp-clean-css");
var rename = require('gulp-rename');
module.exports = function(files, out) {
var processors = [
autoprefixer,
cssnano({zindex: false})
];
var task = gulp.src(files)
.pipe(less());
if (global.isProd === true) {
task = task.pipe(cleanCss());
}
task = task.pipe(postcss(processors))
.pipe(rename(out))
.pipe(gulp.dest(config.root + config.targets.css));
return task;
};
+9
View File
@@ -0,0 +1,9 @@
'use strict';
var path = require('path');
// Filters out non .js files. Prevents
// accidental inclusion of possible hidden files
module.exports = function(name) {
return /(\.(js)$)/i.test(path.extname(name));
};
+16 -587
View File
@@ -1,587 +1,16 @@
var gulp = require('gulp');
var watch = require('gulp-watch');
var concat = require('gulp-concat');
var rename = require('gulp-rename');
var wrap = require("gulp-wrap-js");
var sort = require('gulp-sort');
var connect = require('gulp-connect');
var open = require('gulp-open');
var babel = require("gulp-babel");
var runSequence = require('run-sequence');
var imagemin = require('gulp-imagemin');
var _ = require('lodash');
var MergeStream = require('merge-stream');
// js
var eslint = require('gulp-eslint');
//Less + css
var postcss = require('gulp-postcss');
var less = require('gulp-less');
var autoprefixer = require('autoprefixer');
var cssnano = require('cssnano');
var cleanCss = require("gulp-clean-css");
// Documentation
var gulpDocs = require('gulp-ngdocs');
// Testing
var karmaServer = require('karma').Server;
/***************************************************************
Helper functions
***************************************************************/
function processJs(files, out) {
return gulp.src(files)
// check for js errors
.pipe(eslint())
// outputs the lint results to the console
.pipe(eslint.format())
// sort files in stream by path or any custom sort comparator
.pipe(babel())
.pipe(sort())
.pipe(concat(out))
.pipe(wrap('(function(){\n%= body %\n})();'))
.pipe(gulp.dest(root + targets.js));
console.log(out + " compiled");
}
function processLess(files, out) {
var processors = [
autoprefixer,
cssnano({zindex: false})
];
return gulp.src(files)
.pipe(less())
.pipe(cleanCss())
.pipe(postcss(processors))
.pipe(rename(out))
.pipe(gulp.dest(root + targets.css));
console.log(out + " compiled");
}
/***************************************************************
Paths and destinations
Each group is iterated automatically in the setup tasks below
***************************************************************/
var sources = {
//less files used by backoffice and preview
//processed in the less task
less: {
installer: { files: ["src/less/installer.less"], out: "installer.css" },
nonodes: { files: ["src/less/pages/nonodes.less"], out: "nonodes.style.min.css"},
preview: { files: ["src/less/canvas-designer.less"], out: "canvasdesigner.css" },
umbraco: { files: ["src/less/belle.less"], out: "umbraco.css" }
},
//js files for backoffie
//processed in the js task
js: {
preview: { files: ["src/preview/**/*.js"], out: "umbraco.preview.js" },
installer: { files: ["src/installer/**/*.js"], out: "umbraco.installer.js" },
controllers: { files: ["src/{views,controllers}/**/*.controller.js"], out: "umbraco.controllers.js" },
directives: { files: ["src/common/directives/**/*.js"], out: "umbraco.directives.js" },
filters: { files: ["src/common/filters/**/*.js"], out: "umbraco.filters.js" },
resources: { files: ["src/common/resources/**/*.js"], out: "umbraco.resources.js" },
services: { files: ["src/common/services/**/*.js"], out: "umbraco.services.js" },
security: { files: ["src/common/interceptors/**/*.js"], out: "umbraco.interceptors.js" }
},
//selectors for copying all views into the build
//processed in the views task
views:{
umbraco: {files: ["src/views/**/*.html"], folder: ""},
installer: {files: ["src/installer/steps/*.html"], folder: "install"}
},
//globs for file-watching
globs:{
views: "./src/views/**/*.html",
less: "./src/less/**/*.less",
js: "./src/*.js",
lib: "./lib/**/*",
assets: "./src/assets/**"
}
};
var root = "../Umbraco.Web.UI/Umbraco/";
var targets = {
js: "js/",
lib: "lib/",
views: "views/",
css: "assets/css/",
assets: "assets/"
};
/**************************
* Main tasks for the project to prepare backoffice files
**************************/
// Build - build the files ready for production
gulp.task('build', function(cb) {
runSequence(["dependencies", "js", "less", "views"], cb);
});
// Dev - build the files ready for development and start watchers
gulp.task('dev', function(cb) {
runSequence(["dependencies", "js", "less", "views"], "watch", cb);
});
// Docserve - build and open the back office documentation
gulp.task('docserve', function(cb) {
runSequence('docs', 'connect:docs', 'open:docs', cb);
});
/**************************
* Task processes and copies all dependencies, either installed by npm or stored locally in the project
**************************/
gulp.task('dependencies', function () {
//as we do multiple things in this task, we merge the multiple streams
var stream = new MergeStream();
// Pick the dependencies we need from each package
// so we don't just ship with a lot of files that aren't needed
const nodeModules = [
{
"name": "ace-builds",
"src": [
"./node_modules/ace-builds/src-min-noconflict/ace.js",
"./node_modules/ace-builds/src-min-noconflict/ext-language_tools.js",
"./node_modules/ace-builds/src-min-noconflict/ext-searchbox.js",
"./node_modules/ace-builds/src-min-noconflict/ext-settings_menu.js",
"./node_modules/ace-builds/src-min-noconflict/snippets/text.js",
"./node_modules/ace-builds/src-min-noconflict/snippets/javascript.js",
"./node_modules/ace-builds/src-min-noconflict/snippets/css.js",
"./node_modules/ace-builds/src-min-noconflict/theme-chrome.js",
"./node_modules/ace-builds/src-min-noconflict/mode-razor.js",
"./node_modules/ace-builds/src-min-noconflict/mode-javascript.js",
"./node_modules/ace-builds/src-min-noconflict/mode-css.js",
"./node_modules/ace-builds/src-min-noconflict/worker-javascript.js",
"./node_modules/ace-builds/src-min-noconflict/worker-css.js"
],
"base": "./node_modules/ace-builds"
},
{
"name": "angular",
"src": ["./node_modules/angular/angular.js"],
"base": "./node_modules/angular"
},
{
"name": "angular-cookies",
"src": ["./node_modules/angular-cookies/angular-cookies.js"],
"base": "./node_modules/angular-cookies"
},
{
"name": "angular-dynamic-locale",
"src": [
"./node_modules/angular-dynamic-locale/dist/tmhDynamicLocale.min.js",
"./node_modules/angular-dynamic-locale/dist/tmhDynamicLocale.min.js.map"
],
"base": "./node_modules/angular-dynamic-locale/dist"
},
{
"name": "angular-sanitize",
"src": ["./node_modules/angular-sanitize/angular-sanitize.js"],
"base": "./node_modules/angular-sanitize"
},
{
"name": "angular-touch",
"src": ["./node_modules/angular-touch/angular-touch.js"],
"base": "./node_modules/angular-touch"
},
{
"name": "angular-ui-sortable",
"src": ["./node_modules/angular-ui-sortable/dist/sortable.js"],
"base": "./node_modules/angular-ui-sortable/dist"
},
{
"name": "angular-route",
"src": ["./node_modules/angular-route/angular-route.js"],
"base": "./node_modules/angular-route"
},
{
"name": "angular-animate",
"src": ["./node_modules/angular-animate/angular-animate.js"],
"base": "./node_modules/angular-animate"
},
{
"name": "angular-i18n",
"src": [
"./node_modules/angular-i18n/angular-i18n.js",
"./node_modules/angular-i18n/angular-locale_*.js"
],
"base": "./node_modules/angular-i18n"
},
{
"name": "angular-local-storage",
"src": [
"./node_modules/angular-local-storage/dist/angular-local-storage.min.js",
"./node_modules/angular-local-storage/dist/angular-local-storage.min.js.map"
],
"base": "./node_modules/angular-local-storage/dist"
},
{
"name": "angular-messages",
"src": ["./node_modules/angular-messages/angular-messages.js"],
"base": "./node_modules/angular-messages"
},
{
"name": "angular-mocks",
"src": ["./node_modules/angular-mocks/angular-mocks.js"],
"base": "./node_modules/angular-mocks"
},
{
"name": "animejs",
"src": ["./node_modules/animejs/anime.min.js"],
"base": "./node_modules/animejs"
},
{
"name": "bootstrap-social",
"src": ["./node_modules/bootstrap-social/bootstrap-social.css"],
"base": "./node_modules/bootstrap-social"
},
{
"name": "angular-chart.js",
"src": ["./node_modules/angular-chart.js/dist/angular-chart.min.js"],
"base": "./node_modules/angular-chart.js/dist"
},
{
"name": "chart.js",
"src": ["./node_modules/chart.js/dist/chart.min.js"],
"base": "./node_modules/chart.js/dist"
},
{
"name": "clipboard",
"src": ["./node_modules/clipboard/dist/clipboard.min.js"],
"base": "./node_modules/clipboard/dist"
},
{
"name": "jsdiff",
"src": ["./node_modules/diff/dist/diff.min.js"],
"base": "./node_modules/diff/dist"
},
{
"name": "flatpickr",
"src": [
"./node_modules/flatpickr/dist/flatpickr.js",
"./node_modules/flatpickr/dist/flatpickr.css"
],
"base": "./node_modules/flatpickr/dist"
},
{
"name": "font-awesome",
"src": [
"./node_modules/font-awesome/fonts/*",
"./node_modules/font-awesome/css/font-awesome.min.css"
],
"base": "./node_modules/font-awesome"
},
{
"name": "jquery",
"src": [
"./node_modules/jquery/dist/jquery.min.js",
"./node_modules/jquery/dist/jquery.min.map"
],
"base": "./node_modules/jquery/dist"
},
{
"name": "jquery-ui",
"src": ["./node_modules/jquery-ui-dist/jquery-ui.min.js"],
"base": "./node_modules/jquery-ui-dist"
},
{
"name": "jquery-ui-touch-punch",
"src": ["./node_modules/jquery-ui-touch-punch/jquery.ui.touch-punch.min.js"],
"base": "./node_modules/jquery-ui-touch-punch"
},
{
"name": "lazyload-js",
"src": ["./node_modules/lazyload-js/lazyload.min.js"],
"base": "./node_modules/lazyload-js"
},
{
"name": "moment",
"src": ["./node_modules/moment/min/moment.min.js"],
"base": "./node_modules/moment/min"
},
{
"name": "moment",
"src": ["./node_modules/moment/locale/*.js"],
"base": "./node_modules/moment/locale"
},
{
"name": "ng-file-upload",
"src": ["./node_modules/ng-file-upload/dist/ng-file-upload.min.js"],
"base": "./node_modules/ng-file-upload/dist"
},
{
"name": "nouislider",
"src": [
"./node_modules/nouislider/distribute/nouislider.min.js",
"./node_modules/nouislider/distribute/nouislider.min.css"
],
"base": "./node_modules/nouislider/distribute"
},
{
"name": "signalr",
"src": ["./node_modules/signalr/jquery.signalR.js"],
"base": "./node_modules/signalr"
},
{
"name": "spectrum",
"src": [
"./node_modules/spectrum-colorpicker/spectrum.js",
"./node_modules/spectrum-colorpicker/spectrum.css"
],
"base": "./node_modules/spectrum-colorpicker"
},
{
"name": "tinymce",
"src": [
"./node_modules/tinymce/tinymce.min.js",
"./node_modules/tinymce/plugins/**",
"./node_modules/tinymce/skins/**",
"./node_modules/tinymce/themes/**"
],
"base": "./node_modules/tinymce"
},
{
"name": "typeahead.js",
"src": ["./node_modules/typeahead.js/dist/typeahead.bundle.min.js"],
"base": "./node_modules/typeahead.js/dist"
},
{
"name": "underscore",
"src": ["node_modules/underscore/underscore-min.js"],
"base": "./node_modules/underscore"
}
];
// add streams for node modules
nodeModules.forEach(module => {
stream.add(
gulp.src(module.src,
{ base: module.base })
.pipe(gulp.dest(root + targets.lib + "/" + module.name))
);
});
//copy over libs which are not on npm (/lib)
stream.add(
gulp.src(sources.globs.lib)
.pipe(gulp.dest(root + targets.lib))
);
//Copies all static assets into /root / assets folder
//css, fonts and image files
stream.add(
gulp.src(sources.globs.assets)
.pipe(imagemin([
imagemin.gifsicle({interlaced: true}),
imagemin.jpegtran({progressive: true}),
imagemin.optipng({optimizationLevel: 5}),
imagemin.svgo({
plugins: [
{removeViewBox: true},
{cleanupIDs: false}
]
})
]))
.pipe(gulp.dest(root + targets.assets))
);
// Copies all the less files related to the preview into their folder
//these are not pre-processed as preview has its own less combiler client side
stream.add(
gulp.src("src/canvasdesigner/editors/*.less")
.pipe(gulp.dest(root + targets.assets + "/less"))
);
// Todo: check if we need these fileSize
stream.add(
gulp.src("src/views/propertyeditors/grid/config/*.*")
.pipe(gulp.dest(root + targets.views + "/propertyeditors/grid/config"))
);
stream.add(
gulp.src("src/views/dashboard/default/*.jpg")
.pipe(gulp.dest(root + targets.views + "/dashboard/default"))
);
return stream;
});
/**************************
* Copies all angular JS files into their seperate umbraco.*.js file
**************************/
gulp.task('js', function () {
//we run multiple streams, so merge them all together
var stream = new MergeStream();
stream.add(
gulp.src(sources.globs.js)
.pipe(gulp.dest(root + targets.js))
);
_.forEach(sources.js, function (group) {
stream.add (processJs(group.files, group.out) );
});
return stream;
});
gulp.task('less', function () {
var stream = new MergeStream();
_.forEach(sources.less, function (group) {
stream.add( processLess(group.files, group.out) );
});
return stream;
});
gulp.task('views', function () {
var stream = new MergeStream();
_.forEach(sources.views, function (group) {
console.log("copying " + group.files + " to " + root + targets.views + group.folder)
stream.add (
gulp.src(group.files)
.pipe( gulp.dest(root + targets.views + group.folder) )
);
});
return stream;
});
gulp.task('watch', function () {
var stream = new MergeStream();
var watchInterval = 500;
//Setup a watcher for all groups of javascript files
_.forEach(sources.js, function (group) {
if(group.watch !== false){
stream.add(
watch(group.files, { ignoreInitial: true, interval: watchInterval }, function (file) {
console.info(file.path + " has changed, added to: " + group.out);
processJs(group.files, group.out);
})
);
}
});
stream.add(
//watch all less files and trigger the less task
watch(sources.globs.less, { ignoreInitial: true, interval: watchInterval }, function () {
gulp.run(['less']);
})
);
//watch all views - copy single file changes
stream.add(
watch(sources.globs.views, { interval: watchInterval })
.pipe(gulp.dest(root + targets.views))
);
//watch all app js files that will not be merged - copy single file changes
stream.add(
watch(sources.globs.js, { interval: watchInterval })
.pipe(gulp.dest(root + targets.js))
);
return stream;
});
/**************************
* Build Backoffice UI API documentation
**************************/
gulp.task('docs', [], function (cb) {
var options = {
html5Mode: false,
startPage: '/api',
title: "Umbraco Backoffice UI API Documentation",
dest: 'docs/api',
styles: ['docs/umb-docs.css'],
image: "https://our.umbraco.com/assets/images/logo.svg"
}
return gulpDocs.sections({
api: {
glob: ['src/common/**/*.js', 'docs/src/api/**/*.ngdoc'],
api: true,
title: 'API Documentation'
}
})
.pipe(gulpDocs.process(options))
.pipe(gulp.dest('docs/api'));
cb();
});
gulp.task('connect:docs', function (cb) {
connect.server({
root: 'docs/api',
livereload: true,
fallback: 'docs/api/index.html',
port: 8880
});
cb();
});
gulp.task('open:docs', function (cb) {
var options = {
uri: 'http://localhost:8880/index.html'
};
gulp.src(__filename)
.pipe(open(options));
cb();
});
/**************************
* Build tests
**************************/
// Karma test
gulp.task('test:unit', function() {
new karmaServer({
configFile: __dirname + "/test/config/karma.conf.js",
keepalive: true
})
.start();
});
gulp.task('test:e2e', function() {
new karmaServer({
configFile: __dirname + "/test/config/e2e.js",
keepalive: true
})
.start();
});
'use strict';
/*
* gulpfile.js
* ===========
* Rather than manage one giant configuration file responsible
* for creating multiple tasks, each task has been broken out into
* its own file in gulp/tasks. Any file in that folder gets automatically
* required by the loop in ./gulp/index.js (required below).
*
* To add a new task, simply add a new task file to gulp/tasks.
*/
global.isProd = true;
require('./gulp');
+126
View File
@@ -5115,6 +5115,12 @@
"integrity": "sha1-g8YK/Fi5xWmXAH7Rp2izqzA6RP4=",
"dev": true
},
"fs": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.2.tgz",
"integrity": "sha1-4fJE7zkzwbKmS9R5kTYGDQ9ZFPg=",
"dev": true
},
"fs-constants": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
@@ -6119,6 +6125,12 @@
"integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=",
"dev": true
},
"growly": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz",
"integrity": "sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE=",
"dev": true
},
"gulp": {
"version": "3.9.1",
"resolved": "http://registry.npmjs.org/gulp/-/gulp-3.9.1.tgz",
@@ -6916,6 +6928,102 @@
}
}
},
"gulp-notify": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/gulp-notify/-/gulp-notify-3.2.0.tgz",
"integrity": "sha512-qEocs1UVoDKKUjfsxJNMNwkRla0PbsyJwsqNNXpzYWsLQ29LhxRMY3wnTGZcc4hMHtalnvah/Dwlwb4NijH/0A==",
"dev": true,
"requires": {
"ansi-colors": "^1.0.1",
"fancy-log": "^1.3.2",
"lodash.template": "^4.4.0",
"node-notifier": "^5.2.1",
"node.extend": "^2.0.0",
"plugin-error": "^0.1.2",
"through2": "^2.0.3"
},
"dependencies": {
"arr-diff": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-1.1.0.tgz",
"integrity": "sha1-aHwydYFjWI/vfeezb6vklesaOZo=",
"dev": true,
"requires": {
"arr-flatten": "^1.0.1",
"array-slice": "^0.2.3"
}
},
"arr-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/arr-union/-/arr-union-2.1.0.tgz",
"integrity": "sha1-IPnqtexw9cfSFbEHexw5Fh0pLH0=",
"dev": true
},
"array-slice": {
"version": "0.2.3",
"resolved": "https://registry.npmjs.org/array-slice/-/array-slice-0.2.3.tgz",
"integrity": "sha1-3Tz7gO15c6dRF82sabC5nshhhvU=",
"dev": true
},
"extend-shallow": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-1.1.4.tgz",
"integrity": "sha1-Gda/lN/AnXa6cR85uHLSH/TdkHE=",
"dev": true,
"requires": {
"kind-of": "^1.1.0"
}
},
"kind-of": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-1.1.0.tgz",
"integrity": "sha1-FAo9LUGjbS78+pN3tiwk+ElaXEQ=",
"dev": true
},
"lodash.template": {
"version": "4.4.0",
"resolved": "https://registry.npmjs.org/lodash.template/-/lodash.template-4.4.0.tgz",
"integrity": "sha1-5zoDhcg1VZF0bgILmWecaQ5o+6A=",
"dev": true,
"requires": {
"lodash._reinterpolate": "~3.0.0",
"lodash.templatesettings": "^4.0.0"
}
},
"lodash.templatesettings": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/lodash.templatesettings/-/lodash.templatesettings-4.1.0.tgz",
"integrity": "sha1-K01OlbpEDZFf8IvImeRVNmZxMxY=",
"dev": true,
"requires": {
"lodash._reinterpolate": "~3.0.0"
}
},
"node.extend": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/node.extend/-/node.extend-2.0.2.tgz",
"integrity": "sha512-pDT4Dchl94/+kkgdwyS2PauDFjZG0Hk0IcHIB+LkW27HLDtdoeMxHTxZh39DYbPP8UflWXWj9JcdDozF+YDOpQ==",
"dev": true,
"requires": {
"has": "^1.0.3",
"is": "^3.2.1"
}
},
"plugin-error": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/plugin-error/-/plugin-error-0.1.2.tgz",
"integrity": "sha1-O5uzM1zPAPQl4HQ34ZJ2ln2kes4=",
"dev": true,
"requires": {
"ansi-cyan": "^0.1.1",
"ansi-red": "^0.1.1",
"arr-diff": "^1.0.1",
"arr-union": "^2.0.1",
"extend-shallow": "^1.1.2"
}
}
}
},
"gulp-open": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/gulp-open/-/gulp-open-3.0.1.tgz",
@@ -9368,6 +9476,18 @@
"integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==",
"dev": true
},
"node-notifier": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-5.3.0.tgz",
"integrity": "sha512-AhENzCSGZnZJgBARsUjnQ7DnZbzyP+HxlVXuD0xqAnvL8q+OqtSX7lGg9e8nHzwXkMMXNdVeqq4E2M3EUAqX6Q==",
"dev": true,
"requires": {
"growly": "^1.3.0",
"semver": "^5.5.0",
"shellwords": "^0.1.1",
"which": "^1.3.0"
}
},
"node-releases": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.0.5.tgz",
@@ -14124,6 +14244,12 @@
"integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=",
"dev": true
},
"shellwords": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz",
"integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==",
"dev": true
},
"sigmund": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz",

Some files were not shown because too many files have changed in this diff Show More