First approach

This commit is contained in:
antoine
2014-05-22 22:20:13 +02:00
parent 9626e91c83
commit 7508613d13
5 changed files with 390 additions and 101 deletions

View File

@@ -121,7 +121,7 @@ var initTuningPanel = function () {
// Init panel
if (parent.setFrameIsLoaded) {
parent.setFrameIsLoaded(tuningParameterUrl);
parent.setFrameIsLoaded(tuningParameterUrl, tuningGridStyleUrl);
}
}

View File

@@ -40,10 +40,11 @@ var refrechIntelTuning = function (schema) {
}
var setFrameIsLoaded = function (tuningParameterUrl) {
console.info("iframe id loaded " + tuningParameterUrl);
var setFrameIsLoaded = function (tuningParameterUrl, tuningGridStyleUrl) {
console.info("iframe id loaded " + tuningParameterUrl + " " + tuningGridStyleUrl);
var scope = angular.element($("#tuningPanel")).scope();
scope.tuningParameterUrl = tuningParameterUrl;
scope.tuningGridStyleUrl = tuningGridStyleUrl;
scope.frameLoaded++;
scope.frameFirstLoaded = true;
scope.$apply();
@@ -63,6 +64,7 @@ angular.module("umbraco.tuning", ['ui.bootstrap', 'spectrumcolorpicker', 'ui.sli
$scope.frameLoaded = 0;
$scope.frameFirstLoaded = false;
$scope.tuningParameterUrl = "";
$scope.tuningGridStyleUrl = "";
$scope.schemaFocus = "body";
$scope.settingIsOpen = 'previewDevice';
$scope.BackgroundPositions = ['center', 'left', 'right', 'bottom center', 'bottom left', 'bottom right', 'top center', 'top left', 'top right'];
@@ -83,12 +85,107 @@ angular.module("umbraco.tuning", ['ui.bootstrap', 'spectrumcolorpicker', 'ui.sli
];
$scope.previewDevice = $scope.devices[0];
//*****************************************************************************
// Grid row model
//*****************************************************************************
var rows = ['grid-row-0', 'grid-row-1'];
var rowModel = {
name: "Grid",
sections: [{
name: "Main",
subSections: []
}]
};
$.each(rows, function (index, row) {
var newIndex = rowModel.sections[0].subSections.length + 1;
var rowFieldModel = {
name: "Row",
schema: "",
fields: [
{
name: "Background color",
alias: "backgroundRowColor",
description: "Background body color",
type: "colorPicker",
value: "",
colorPaletteProperty: "colorBodyBackground"
},
{
name: "Image/Pattern",
alias: "backgroundRowImageOrPattern",
description: "Use an image for the background instead of a solid colour/gradient",
type: "bgImagePicker",
value: ""
},
{
name: "Image position",
alias: "backgroundRowPosition",
description: "Background body position",
type: "bgPositionPicker",
value: ""
},
{
name: "Stretch background",
alias: "backgroundRowCover",
description: "Checked: stretches the chosen image to fill the.\nUnchecked: the image is tiled according to the Repeat setting below",
type: "checkbox",
value: ""
},
{
name: "Background tiling",
alias: "backgroundRowRepeat",
description: "How to tile the background image",
type: "bgRepeatPicker",
value: ""
},
{
name: "Background scrolling behaviour",
alias: "backgroundRowAttachment",
description: "When fixed the background doesn't scroll with the content",
type: "bgAttachmentPicker",
value: ""
}
]
};
rowModel.sections[0].subSections.splice(newIndex, 0, rowFieldModel);
rowModel.sections[0].subSections[newIndex - 1].schema = "." + row;
$.each(rowModel.sections[0].subSections[newIndex - 1].fields, function (indexField, field) {
field.alias = field.alias + "__" + row;
});
})
tuningConfig.categories.splice(tuningConfig.categories.length + 1, 0, rowModel);
//*****************************************************************************
// Load parameters from GetLessParameters and init data of the tuning config
var initTuning = function () {
console.info("url " + $scope.tuningParameterUrl);
$http.get('/Umbraco/Api/tuning/Load', { params: { param: $scope.tuningParameterUrl } })
$http.get('/Umbraco/Api/tuning/Load', { params: { tuningStyleUrl: $scope.tuningParameterUrl, tuningGridStyleUrl: $scope.tuningGridStyleUrl } })
.success(function (data) {
$.each(tuningConfig.categories, function (indexCategory, category) {
@@ -96,18 +193,24 @@ angular.module("umbraco.tuning", ['ui.bootstrap', 'spectrumcolorpicker', 'ui.sli
$.each(section.subSections, function (indexSubSection, subSection) {
$.each(subSection.fields, function (indexField, field) {
// value
field.value = eval("data." + field.alias.replace("@", ""));
if (field.value == "''") { field.value = ""; }
try {
// special init for font family picker
if (field.type == "fontFamilyPicker") {
field.fontWeight = eval("data." + field.alias.replace("@", "") + "_weight");
field.fontStyle = eval("data." + field.alias.replace("@", "") + "_style");
field.fontType = eval("data." + field.alias.replace("@", "") + "_type");
if (field.fontWeight == "''") { field.fontWeight = ""; }
if (field.fontStyle == "''") { field.fontStyle = ""; }
if (field.fontType == "''") { field.fontType = ""; }
// value
field.value = eval("data." + field.alias.replace("@", ""));
if (field.value == "''") { field.value = ""; }
// special init for font family picker
if (field.type == "fontFamilyPicker") {
field.fontWeight = eval("data." + field.alias.replace("@", "") + "_weight");
field.fontStyle = eval("data." + field.alias.replace("@", "") + "_style");
field.fontType = eval("data." + field.alias.replace("@", "") + "_type");
if (field.fontWeight == "''") { field.fontWeight = ""; }
if (field.fontStyle == "''") { field.fontStyle = ""; }
if (field.fontType == "''") { field.fontType = ""; }
}
}
catch (err) {
console.info("Style parameter not found " + field.alias);
}
})
@@ -123,33 +226,35 @@ angular.module("umbraco.tuning", ['ui.bootstrap', 'spectrumcolorpicker', 'ui.sli
}
});
}
// Refresh all less parameters for every changes watching tuningModel
var refreshtuning = function () {
var parameters = [];
$.each($scope.tuningModel.categories, function (indexCategory, category) {
$.each(category.sections, function (indexSection, section) {
$.each(section.subSections, function (indexSubSection, subSection) {
$.each(subSection.fields, function (indexField, field) {
if ($scope.tuningModel) {
$.each($scope.tuningModel.categories, function (indexCategory, category) {
$.each(category.sections, function (indexSection, section) {
$.each(section.subSections, function (indexSubSection, subSection) {
$.each(subSection.fields, function (indexField, field) {
// value
parameters.splice(parameters.length + 1, 0, "'@" + field.alias + "':'" + field.value + "'");
// value
parameters.splice(parameters.length + 1, 0, "'@" + field.alias + "':'" + field.value + "'");
// special init for font family picker
if (field.type == "fontFamilyPicker") {
parameters.splice(parameters.length + 1, 0, "'@" + field.alias + "_weight':'" + field.fontWeight + "'");
parameters.splice(parameters.length + 1, 0, "'@" + field.alias + "_Style':'" + field.fontStyle + "'");
}
// special init for font family picker
if (field.type == "fontFamilyPicker") {
parameters.splice(parameters.length + 1, 0, "'@" + field.alias + "_weight':'" + field.fontWeight + "'");
parameters.splice(parameters.length + 1, 0, "'@" + field.alias + "_Style':'" + field.fontStyle + "'");
}
})
})
})
})
});
// Refrech page style
document.getElementById("resultFrame").contentWindow.refrechLayout(parameters);
});
// Refrech page style
document.getElementById("resultFrame").contentWindow.refrechLayout(parameters);
}
}
var openIntelTuning = function () {
@@ -192,30 +297,39 @@ angular.module("umbraco.tuning", ['ui.bootstrap', 'spectrumcolorpicker', 'ui.sli
$scope.saveLessParameters = function () {
var parameters = [];
var parametersGrid = [];
$.each($scope.tuningModel.categories, function (indexCategory, category) {
$.each(category.sections, function (indexSection, section) {
$.each(section.subSections, function (indexSubSection, subSection) {
$.each(subSection.fields, function (indexField, field) {
// value
var value = (field.value != 0 && (field.value == undefined || field.value == "")) ? "''" : field.value;
parameters.splice(parameters.length + 1, 0, "@" + field.alias + ":" + value + ";");
if (subSection.schema && subSection.schema.indexOf("grid-row-") >= 0)
{
var value = (field.value != 0 && (field.value == undefined || field.value == "")) ? "''" : field.value;
parametersGrid.splice(parametersGrid.length + 1, 0, "@" + field.alias + ":" + value + ";");
}
else
{
// value
var value = (field.value != 0 && (field.value == undefined || field.value == "")) ? "''" : field.value;
parameters.splice(parameters.length + 1, 0, "@" + field.alias + ":" + value + ";");
// special init for font family picker
if (field.type == "fontFamilyPicker") {
if (field.fontType == "google" && value != "''") {
var variant = field.fontWeight != "" || field.fontStyle != "" ? ":" + field.fontWeight + field.fontStyle : "";
var gimport = "@import url('http://fonts.googleapis.com/css?family=" + value + variant + "');";
if ($.inArray(gimport, parameters) < 0) {
parameters.splice(0, 0, gimport);
// special init for font family picker
if (field.type == "fontFamilyPicker") {
if (field.fontType == "google" && value != "''") {
var variant = field.fontWeight != "" || field.fontStyle != "" ? ":" + field.fontWeight + field.fontStyle : "";
var gimport = "@import url('http://fonts.googleapis.com/css?family=" + value + variant + "');";
if ($.inArray(gimport, parameters) < 0) {
parameters.splice(0, 0, gimport);
}
}
var fontWeight = (field.fontWeight != 0 && (field.fontWeight == undefined || field.fontWeight == "")) ? "''" : field.fontWeight;
var fontStyle = (field.fontStyle != 0 && (field.fontStyle == undefined || field.fontStyle == "")) ? "''" : field.fontStyle;
var fontType = (field.fontType != 0 && (field.fontType == undefined || field.fontType == "")) ? "''" : field.fontType;
parameters.splice(parameters.length + 1, 0, "@" + field.alias + "_weight:" + fontWeight + ";");
parameters.splice(parameters.length + 1, 0, "@" + field.alias + "_style:" + fontStyle + ";");
parameters.splice(parameters.length + 1, 0, "@" + field.alias + "_type:" + fontType + ";");
}
var fontWeight = (field.fontWeight != 0 && (field.fontWeight == undefined || field.fontWeight == "")) ? "''" : field.fontWeight;
var fontStyle = (field.fontStyle != 0 && (field.fontStyle == undefined || field.fontStyle == "")) ? "''" : field.fontStyle;
var fontType = (field.fontType != 0 && (field.fontType == undefined || field.fontType == "")) ? "''" : field.fontType;
parameters.splice(parameters.length + 1, 0, "@" + field.alias + "_weight:" + fontWeight + ";");
parameters.splice(parameters.length + 1, 0, "@" + field.alias + "_style:" + fontStyle + ";");
parameters.splice(parameters.length + 1, 0, "@" + field.alias + "_type:" + fontType + ";");
}
})
@@ -223,7 +337,7 @@ angular.module("umbraco.tuning", ['ui.bootstrap', 'spectrumcolorpicker', 'ui.sli
})
});
var resultParameters = { result: parameters.join(""), pageId: $location.search().id };
var resultParameters = { parameters: parameters.join(""), parametersGrid: parametersGrid.join(""), pageId: $location.search().id };
var transform = function (result) {
return $.param(result);
}

View File

@@ -12,53 +12,53 @@
<div class="col-md-@column.grid column usky-grid-column">
@foreach (var row in column.rows)
{
<div class="@row.cssClass @(row.fullScreen == "True" ? "usky-grid-full-size" : "")">
<div>
<div class="row clearfix usky-grid-row">
<div id="@Html.Raw(Guid.NewGuid().ToString())" class="grid-row-@column.rows.IndexOf(row) @row.cssClass @(row.fullScreen == "True" ? "usky-grid-full-size" : "")">
<div>
<div class="row clearfix usky-grid-row">
@foreach (var cell in row.cells)
{
<div class="col-md-@cell.model.grid column">
<div class="usky-grid-cell @(row.skipTopMargin == "True" ? "usky-grid-skip-top-margin" : "") @(row.skipBottomMargin == "True" ? "usky-grid-skip-bottom-margin" : "")">
@foreach (var cell in row.cells)
{
<div class="col-md-@cell.model.grid column">
<div class="usky-grid-cell @(row.skipTopMargin == "True" ? "usky-grid-skip-top-margin" : "") @(row.skipBottomMargin == "True" ? "usky-grid-skip-bottom-margin" : "")">
@foreach (var control in cell.controls)
@foreach (var control in cell.controls)
{
if (control != null && control.macro != null)
{
if (control != null && control.macro != null)
string macroAlias = control.macro.macroAlias.ToString();
ViewDataDictionary parameters = new ViewDataDictionary();
foreach (dynamic mpd in control.macro.marcoParamsDictionary)
{
string macroAlias = control.macro.macroAlias.ToString();
ViewDataDictionary parameters = new ViewDataDictionary();
foreach (dynamic mpd in control.macro.marcoParamsDictionary)
{
parameters.Add(mpd.Name, mpd.Value);
}
@Umbraco.RenderMacro(macroAlias, parameters)
parameters.Add(mpd.Name, mpd.Value);
}
if (control != null && control.tinyMCE != null)
{
@Umbraco.RenderMacro(macroAlias, parameters)
}
if (control != null && control.tinyMCE != null)
{
<div class="@(row.boxed == "True" ? "jumbotron" : "")">
@Html.Raw(TemplateUtilities.ParseInternalLinks(control.tinyMCE.value.ToString()))
</div>
}
if (control != null && control.media != null)
{
<img src="@control.media.src">
}
if (control != null && control.embed != null)
{
@Html.Raw(control.embed.content)
}
}
</div>
if (control != null && control.media != null)
{
<img src="@control.media.src">
}
if (control != null && control.embed != null)
{
@Html.Raw(control.embed.content)
}
}
</div>
}
</div>
</div>
}
</div>
</div>
}
</div>
}
</div>
}
</div>

View File

@@ -12,6 +12,7 @@ using System;
using System.Net.Http.Headers;
using System.Web;
using System.IO;
using Umbraco.Core.Models;
namespace Umbraco.Web.Editors
{
@@ -23,6 +24,8 @@ namespace Umbraco.Web.Editors
static string frontBasePath = HttpContext.Current.Server.MapPath(@"\Css\tuning\");
static string resultCssPath = @"\Css\tuning\{0}.css";
static string resultLessPath = @"\Css\tuning\{0}.less";
static string resultGridLessPath = @"\Css\tuning\grid_{0}.less";
static string resultGridCssPath = @"\Css\tuning\grid_{0}.css";
static string tuningStylePath = basePath + @"tuning.defaultStyle.less";
[HttpGet]
@@ -54,19 +57,30 @@ namespace Umbraco.Web.Editors
public HttpResponseMessage Load()
{
var tuningParametersPath = HttpContext.Current.Request["param"];
// Get style less url
var tuningStyleUrl = HttpContext.Current.Request["tuningStyleUrl"];
var tuningGridStyleUrl = HttpContext.Current.Request["tuningGridStyleUrl"];
if (string.IsNullOrEmpty(tuningParametersPath))
tuningParametersPath = tuningStylePath;
if (string.IsNullOrEmpty(tuningStyleUrl))
tuningStyleUrl = tuningStylePath;
else
tuningParametersPath = HttpContext.Current.Server.MapPath(tuningParametersPath);
tuningStyleUrl = HttpContext.Current.Server.MapPath(tuningStyleUrl);
// Get all parameters
string paramBlock = string.Empty;
using (System.IO.StreamReader sr = new System.IO.StreamReader(tuningParametersPath))
using (System.IO.StreamReader sr = new System.IO.StreamReader(tuningStyleUrl))
{
paramBlock = GetStyleBloque("lessParam", sr.ReadToEnd());
}
if (!string.IsNullOrEmpty(tuningGridStyleUrl))
{
using (System.IO.StreamReader sr = new System.IO.StreamReader(HttpContext.Current.Server.MapPath(tuningGridStyleUrl)))
{
paramBlock += GetStyleBloque("lessParam", sr.ReadToEnd());
}
}
// Prepare string parameter result
string[] paramLines = paramBlock.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
IList<string> parameters = new List<string>();
foreach (var line in paramLines)
@@ -75,6 +89,7 @@ namespace Umbraco.Web.Editors
parameters.Add("\"" + line.Replace(":", "\":\"").Replace(";", "\"").Replace("@", "").Replace(";", ""));
}
// Response
var resp = new HttpResponseMessage()
{
Content = new StringContent("{" + String.Join(",", parameters) + "}")
@@ -87,9 +102,55 @@ namespace Umbraco.Web.Editors
public HttpResponseMessage Save()
{
var result = HttpContext.Current.Request["result"];
// Get parameters
var parameters = HttpContext.Current.Request["parameters"];
var parametersGrid = HttpContext.Current.Request["parametersGrid"];
var pageId = HttpContext.Current.Request["pageId"];
/*********************************************/
/* Grid parameters */
/*********************************************/
// Path to the new grid less
string newResultGridLessPath = HttpContext.Current.Server.MapPath(string.Format(resultGridLessPath, pageId));
string newResultGridCssPath = HttpContext.Current.Server.MapPath(string.Format(resultGridCssPath, pageId));
// Load current grid Less
string gridLessContent = string.Empty;
using (System.IO.StreamReader sr = new System.IO.StreamReader(newResultGridLessPath))
{
gridLessContent = sr.ReadToEnd();
}
// Prepare grid parameters
string newGridParamBlock = string.Empty;
foreach (string parameter in parametersGrid.Trim().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries))
{
newGridParamBlock += (parameter + ";").Replace(":;", ":'';") + Environment.NewLine;
}
gridLessContent = gridLessContent.Replace(GetStyleBloque("lessParam", gridLessContent), Environment.NewLine + newGridParamBlock);
// Save Grid less file
using (System.IO.StreamWriter file = new System.IO.StreamWriter(newResultGridLessPath))
{
file.Write(gridLessContent);
}
// Compile the Grid Less file
string compiledGridStyle = GetCssFromLessString(gridLessContent, false, true, true);
// Save compiled file
using (System.IO.StreamWriter file = new System.IO.StreamWriter(newResultGridCssPath))
{
file.Write(compiledGridStyle);
}
/*********************************************/
/* Main parameters */
/*********************************************/
// Path to the new less and css files
string newResultLessPath = HttpContext.Current.Server.MapPath(string.Format(resultLessPath, pageId));
string newResultCssPath = HttpContext.Current.Server.MapPath(string.Format(resultCssPath, pageId));
@@ -101,22 +162,22 @@ namespace Umbraco.Web.Editors
lessContent = sr.ReadToEnd();
}
// Create font directory
// Create front directory
if (!Directory.Exists(frontBasePath))
Directory.CreateDirectory(frontBasePath);
// Prepare parameters and gf block
string newParamBlock = string.Empty;
string newGfBlock = string.Empty;
foreach (string parameters in result.Trim().Split(new string[] {";"}, StringSplitOptions.RemoveEmptyEntries))
foreach (string parameter in parameters.Trim().Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries))
{
if (parameters.IndexOf("@import") < 0)
if (parameter.IndexOf("@import") < 0)
{
newParamBlock += (parameters + ";").Replace(":;", ":'';") + Environment.NewLine;
newParamBlock += (parameter + ";").Replace(":;", ":'';") + Environment.NewLine;
}
else
{
newGfBlock += parameters + ";" + Environment.NewLine;
newGfBlock += parameter + ";" + Environment.NewLine;
}
}
lessContent = lessContent.Replace(GetStyleBloque("lessParam", lessContent), Environment.NewLine + newParamBlock);
@@ -166,7 +227,98 @@ namespace Umbraco.Web.Editors
resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
return resp;
}
}
[HttpGet]
public HttpResponseMessage GridStyle() {
// Load current content
int pageId = int.TryParse(HttpContext.Current.Request["pageId"], out pageId) ? pageId : -1;
var contentService = Services.ContentService;
IContent content = contentService.GetById(pageId);
// Path to the new grid less
string newResultGridLessPath = HttpContext.Current.Server.MapPath(string.Format(resultGridLessPath, pageId));
// Load current grid Less
string gridLessContent = string.Empty;
using (System.IO.StreamReader sr = new System.IO.StreamReader(newResultGridLessPath))
{
gridLessContent = sr.ReadToEnd();
}
//Get parameter block
string lessParam = GetStyleBloque("lessParam", gridLessContent);
//Get style block
string gridStyle = GetStyleBloque("gridStyle", gridLessContent);
// Look after grid properies
foreach (var property in content.Properties)
{
if (property.PropertyType.PropertyEditorAlias == "Umbraco.Grid")
{
dynamic grid = Newtonsoft.Json.Linq.JObject.Parse(property.Value.ToString());
foreach (var column in grid.columns)
{
foreach (var row in column.rows)
{
string newTag = "grid-row-" + column.rows.IndexOf(row);
if (gridStyle.IndexOf(newTag + " ") < 0)
{
lessParam += string.Format("@backgroundRowColor__{0}:;\r\n" +
"@backgroundRowImageOrPattern__{0}:;\r\n" +
"@backgroundRowGradientColor__{0}:;\r\n" +
"@backgroundRowPosition__{0}:;\r\n" +
"@backgroundRowCover__{0}:;\r\n" +
"@backgroundRowRepeat__{0}:;\r\n" +
"@backgroundRowAttachment__{0}:;\r\n", newTag);
gridStyle += string.Format("\r\n\r\n.Row-cover__{0} () when (@backgroundRowCover__{0} = true) {{ \r\n" +
"-webkit-background-size: cover; \r\n" +
"-moz-background-size: cover; \r\n" +
"-o-background-size: cover; \r\n" +
"background-size: cover; \r\n" +
"}} \r\n\r\n" +
".{0} {{ \r\n" +
"background-color:@backgroundRowColor__{0}; \r\n" +
"background: -moz-linear-gradient(top, @backgroundRowColor__{0} 41%,@backgroundRowGradientColor__{0} 100%); \r\n" +
"background: -webkit-gradient(linear, left top, left bottom, color-stop(41%,@backgroundRowColor__{0}), color-stop(100%,@backgroundRowGradientColor__{0})); \r\n" +
"background: -webkit-linear-gradient(top, @backgroundRowColor__{0} 41%,@backgroundRowGradientColor__{0} 100%); \r\n" +
"background: -o-linear-gradient(top, @backgroundRowColor__{0} 41%,@backgroundRowGradientColor__{0} 100%); \r\n" +
"background: -ms-linear-gradient(top, @backgroundRowColor__{0} 41%,@backgroundRowGradientColor__{0} 100%); \r\n" +
"background: linear-gradient(to bottom, @backgroundRowColor__{0} 41%,@backgroundRowGradientColor__{0} 100%); \r\n" +
"background-image: @backgroundRowImageOrPattern__{0}; \r\n" +
"background-position: @backgroundRowPosition__{0}; \r\n" +
"background-repeat: @backgroundRowRepeat__{0}; \r\n" +
"background-attachment: @backgroundRowAttachment__{0}; \r\n" +
".Row-cover__{0};}}", newTag);
}
}
}
}
}
string result = "/***start-lessParam***/\r\n{0}/***end-lessParam***/\r\n\r\n/***start-gridStyle***/{1}/***end-gridStyle***/";
result = string.Format(result, lessParam, gridStyle);
// Save compiled file
using (System.IO.StreamWriter file = new System.IO.StreamWriter(newResultGridLessPath))
{
file.Write(result);
}
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(result, Encoding.UTF8, "text/css")
};
}
private static string GetCssFromLessString(string css, Boolean cacheEnabled, Boolean minifyOutput, Boolean disableVariableRedefines)
{

View File

@@ -1308,10 +1308,11 @@ namespace Umbraco.Web
string previewLink = @"<link href=""/Umbraco/lib/bootstrap/css/bootstrap.min.3.0.1.css"" type=""text/css"" rel=""stylesheet"" />" +
@"<link href=""{0}"" rel=""stylesheet/less"" type=""text/css"" />" +
@"<link href=""/Umbraco/Api/Tuning/GridStyle?pageId={1}"" rel=""stylesheet/less"" type=""text/css"" />" +
@"<script src=""/Umbraco/lib/jquery/jquery-2.0.3.min.js"" type=""text/javascript""></script>" +
@"<script src=""/Umbraco/lib/bootstrap/js/bootstrap.3.0.1.min.js"" type=""text/javascript""></script>" +
@"<script src=""/Umbraco/lib/Less/less-1.7.0.min.js"" type=""text/javascript""></script>" +
@"<script type=""text/javascript"">var tuningParameterUrl='{0}';</script>" +
@"<script type=""text/javascript"">var tuningParameterUrl='{0}';var tuningGridStyleUrl='/Css/tuning/grid_{1}.less'</script>" +
@"<script src=""/umbraco/js/tuning.front.js"" type=""text/javascript""></script>";
string noPreviewLinks = @"<link href=""/Umbraco/lib/bootstrap/css/bootstrap.min.3.0.1.css"" type=""text/css"" rel=""stylesheet"">" +
@@ -1327,6 +1328,8 @@ namespace Umbraco.Web
int pageId = UmbracoContext.PublishedContentRequest.UmbracoPage.PageID;
string[] path = UmbracoContext.PublishedContentRequest.UmbracoPage.SplitPath;
// Looking for style folder
string linkResult = string.Empty;
foreach (var page in path.OrderByDescending(r => path.IndexOf(r)))
@@ -1339,13 +1342,33 @@ namespace Umbraco.Web
}
}
string result = string.Empty;
if (UmbracoContext.Current.InPreviewMode) {
result = string.IsNullOrEmpty(linkResult) ? string.Format(previewLink, defaultLessStyle) : string.Format(previewLink, linkResult);
result = string.IsNullOrEmpty(linkResult) ? string.Format(previewLink, defaultLessStyle, pageId) : string.Format(previewLink, linkResult, pageId);
}
else {
result = string.IsNullOrEmpty(linkResult) ? string.Format(noPreviewLinks, defaultCssStyle) : string.Format(noPreviewLinks, linkResult);
result = string.IsNullOrEmpty(linkResult) ? string.Format(noPreviewLinks, defaultCssStyle, pageId) : string.Format(noPreviewLinks, linkResult, pageId);
}
//// Grid Styles
//var previewGridStyleLink = "/Umbraco/Api/Tuning/GridStyle?pageId={0}";
//if
//var gridStyleLink = string.Empty;
//string styleGridPath = HttpContext.Current.Server.MapPath(string.Format(gridStyleLink, pageId));
//if (System.IO.File.Exists(styleGridPath))
//{
// gridStyleLink = UmbracoContext.Current.InPreviewMode ? @"<link href=""/Css/tuning/grid{0}.less"" rel=""stylesheet/less"" type=""text/css"" />" :
// @"<link href=""/Css/tuning/grid{0}.css"" type=""text/css"" rel=""stylesheet"" />";
// gridStyleLink = string.Format(gridStyleLink, pageId);
//}
return new HtmlString(result);
}