Add WebCms
This commit is contained in:
@@ -0,0 +1,80 @@
|
||||
@inherits UmbracoViewPage<dynamic>
|
||||
@using Umbraco.Web.Templates
|
||||
@using Newtonsoft.Json.Linq
|
||||
|
||||
@if (Model != null && Model.sections != null)
|
||||
{
|
||||
var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1;
|
||||
|
||||
<div class="umb-grid">
|
||||
@if (oneColumn)
|
||||
{
|
||||
foreach (var section in Model.sections) {
|
||||
<div class="grid-section">
|
||||
@foreach (var row in section.rows) {
|
||||
@renderRow(row, true);
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}else {
|
||||
<div class="container">
|
||||
<div class="row clearfix">
|
||||
@foreach (var s in Model.sections) {
|
||||
<div class="grid-section">
|
||||
<div class="@("span" + s.grid) column">
|
||||
@foreach (var row in s.rows) {
|
||||
@renderRow(row, false);
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@helper renderRow(dynamic row, bool singleColumn){
|
||||
<div @RenderElementAttributes(row)>
|
||||
@Umbraco.If(singleColumn, "<div class='container'>")
|
||||
<div class="row clearfix">
|
||||
@foreach ( var area in row.areas ) {
|
||||
<div class="@("span" + area.grid) column">
|
||||
<div @RenderElementAttributes(area)>
|
||||
@foreach (var control in area.controls) {
|
||||
if (control !=null && control.editor != null && control.editor.view != null ) {
|
||||
<text>@Html.Partial("grid/editors/base", (object)control)</text>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>}
|
||||
</div>
|
||||
@Umbraco.If(singleColumn, "</div>")
|
||||
</div>
|
||||
}
|
||||
|
||||
@functions {
|
||||
public static MvcHtmlString RenderElementAttributes(dynamic contentItem)
|
||||
{
|
||||
var attrs = new List<string>();
|
||||
JObject cfg = contentItem.config;
|
||||
|
||||
if(cfg != null)
|
||||
foreach (JProperty property in cfg.Properties()) {
|
||||
attrs.Add(property.Name + "='" + property.Value.ToString() + "'");
|
||||
}
|
||||
|
||||
JObject style = contentItem.styles;
|
||||
|
||||
if (style != null) {
|
||||
var cssVals = new List<string>();
|
||||
foreach (JProperty property in style.Properties())
|
||||
cssVals.Add(property.Name + ":" + property.Value.ToString() + ";");
|
||||
|
||||
if (cssVals.Any())
|
||||
attrs.Add("style='" + string.Join(" ", cssVals) + "'");
|
||||
}
|
||||
|
||||
return new MvcHtmlString(string.Join(" ", attrs));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
@inherits UmbracoViewPage<dynamic>
|
||||
@using Umbraco.Web.Templates
|
||||
@using Newtonsoft.Json.Linq
|
||||
|
||||
@if (Model != null && Model.sections != null)
|
||||
{
|
||||
var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1;
|
||||
|
||||
<div class="umb-grid">
|
||||
@if (oneColumn)
|
||||
{
|
||||
foreach (var section in Model.sections) {
|
||||
<div class="grid-section">
|
||||
@foreach (var row in section.rows) {
|
||||
@renderRow(row, true);
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}else {
|
||||
<div class="container">
|
||||
<div class="row clearfix">
|
||||
@foreach (var s in Model.sections) {
|
||||
<div class="grid-section">
|
||||
<div class="col-md-@s.grid column">
|
||||
@foreach (var row in s.rows) {
|
||||
@renderRow(row, false);
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@helper renderRow(dynamic row, bool singleColumn){
|
||||
<div @RenderElementAttributes(row)>
|
||||
@Umbraco.If(singleColumn, "<div class='container'>")
|
||||
<div class="row clearfix">
|
||||
@foreach ( var area in row.areas ) {
|
||||
<div class="col-md-@area.grid column">
|
||||
<div @RenderElementAttributes(area)>
|
||||
@foreach (var control in area.controls) {
|
||||
if (control !=null && control.editor != null && control.editor.view != null ) {
|
||||
<text>@Html.Partial("grid/editors/base", (object)control)</text>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>}
|
||||
</div>
|
||||
@Umbraco.If(singleColumn, "</div>")
|
||||
</div>
|
||||
}
|
||||
|
||||
@functions {
|
||||
public static MvcHtmlString RenderElementAttributes(dynamic contentItem)
|
||||
{
|
||||
var attrs = new List<string>();
|
||||
JObject cfg = contentItem.config;
|
||||
|
||||
if(cfg != null)
|
||||
foreach (JProperty property in cfg.Properties()) {
|
||||
attrs.Add(property.Name + "='" + property.Value.ToString() + "'");
|
||||
}
|
||||
|
||||
JObject style = contentItem.styles;
|
||||
|
||||
if (style != null) {
|
||||
var cssVals = new List<string>();
|
||||
foreach (JProperty property in style.Properties())
|
||||
cssVals.Add(property.Name + ":" + property.Value.ToString() + ";");
|
||||
|
||||
if (cssVals.Any())
|
||||
attrs.Add("style='" + string.Join(" ", cssVals) + "'");
|
||||
}
|
||||
|
||||
return new MvcHtmlString(string.Join(" ", attrs));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
@model dynamic
|
||||
@using Umbraco.Web.Templates
|
||||
|
||||
@functions {
|
||||
public static string EditorView(dynamic contentItem)
|
||||
{
|
||||
string view = contentItem.editor.render != null ? contentItem.editor.render.ToString() : contentItem.editor.view.ToString();
|
||||
view = view.ToLower().Replace(".html", ".cshtml");
|
||||
|
||||
if (!view.Contains("/")) {
|
||||
view = "grid/editors/" + view;
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@try
|
||||
{
|
||||
string editor = EditorView(Model);
|
||||
<text>@Html.Partial(editor, (object)Model)</text>
|
||||
}
|
||||
catch (Exception ex) {
|
||||
<pre>@ex.ToString()</pre>
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
@model dynamic
|
||||
@using Umbraco.Web.Templates
|
||||
|
||||
|
||||
<div class="video-wrapper">
|
||||
@Html.Raw(Model.value)
|
||||
</div>
|
||||
@@ -0,0 +1,17 @@
|
||||
@inherits UmbracoViewPage<dynamic>
|
||||
@using Umbraco.Web.Templates
|
||||
|
||||
|
||||
@if (Model.value != null)
|
||||
{
|
||||
string macroAlias = Model.value.macroAlias.ToString();
|
||||
ViewDataDictionary parameters = new ViewDataDictionary();
|
||||
foreach (dynamic mpd in Model.value.macroParamsDictionary)
|
||||
{
|
||||
parameters.Add(mpd.Name, mpd.Value);
|
||||
}
|
||||
|
||||
<text>
|
||||
@Umbraco.RenderMacro(macroAlias, parameters)
|
||||
</text>
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
@model dynamic
|
||||
@using Umbraco.Web.Templates
|
||||
|
||||
@if (Model.value != null)
|
||||
{
|
||||
var url = Model.value.image;
|
||||
if(Model.editor.config != null && Model.editor.config.size != null){
|
||||
url += "?width=" + Model.editor.config.size.width;
|
||||
url += "&height=" + Model.editor.config.size.height;
|
||||
|
||||
if(Model.value.focalPoint != null){
|
||||
url += "¢er=" + Model.value.focalPoint.top +"," + Model.value.focalPoint.left;
|
||||
url += "&mode=crop";
|
||||
}
|
||||
}
|
||||
|
||||
<img src="@url" alt="@Model.value.caption">
|
||||
|
||||
if (Model.value.caption != null)
|
||||
{
|
||||
<p class="caption">@Model.value.caption</p>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
@model dynamic
|
||||
@using Umbraco.Web.Templates
|
||||
|
||||
@Html.Raw(TemplateUtilities.ParseInternalLinks(Model.value.ToString()))
|
||||
@@ -0,0 +1,20 @@
|
||||
@model dynamic
|
||||
@using Umbraco.Web.Templates
|
||||
|
||||
@if (Model.editor.config.markup != null)
|
||||
{
|
||||
string markup = Model.editor.config.markup.ToString();
|
||||
|
||||
markup = markup.Replace("#value#", Model.value.ToString());
|
||||
markup = markup.Replace("#style#", Model.editor.config.style.ToString());
|
||||
|
||||
<text>
|
||||
@Html.Raw(markup)
|
||||
</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<text>
|
||||
<div style="@Model.editor.config.style">@Model.value</div>
|
||||
</text>
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
@inherits UmbracoViewPage<dynamic>
|
||||
@using Umbraco.Web.Templates
|
||||
@using Newtonsoft.Json.Linq
|
||||
|
||||
@if (Model != null && Model.sections != null)
|
||||
{
|
||||
var oneColumn = ((System.Collections.ICollection)Model.sections).Count == 1;
|
||||
|
||||
<div class="umb-grid">
|
||||
@if (oneColumn)
|
||||
{
|
||||
foreach (var section in Model.sections)
|
||||
{
|
||||
<div class="grid-section">
|
||||
@foreach (var row in section.rows)
|
||||
{
|
||||
@renderRow(row, true);
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="container">
|
||||
<div class="row clearfix">
|
||||
@foreach (var s in Model.sections)
|
||||
{
|
||||
<div class="grid-section">
|
||||
<div class="col-md-@s.grid column">
|
||||
@foreach (var row in s.rows)
|
||||
{
|
||||
@renderRow(row, false);
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@helper renderRow(dynamic row, bool singleColumn)
|
||||
{
|
||||
<div @RenderElementAttributes(row)>
|
||||
@Umbraco.If(singleColumn, "<div class='container'>")
|
||||
<div class="row clearfix">
|
||||
@foreach ( var area in row.areas ) {
|
||||
<div class="col-md-@area.grid column">
|
||||
<div @RenderElementAttributes(area)>
|
||||
@foreach (var control in area.controls) {
|
||||
if (control !=null && control.editor != null && control.editor.view != null ) {
|
||||
<text>@Html.Partial("grid/editors/base", (object)control)</text>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>}
|
||||
</div>
|
||||
@Umbraco.If(singleColumn, "</div>")
|
||||
</div>
|
||||
}
|
||||
|
||||
@functions
|
||||
{
|
||||
public static MvcHtmlString RenderElementAttributes(dynamic contentItem)
|
||||
{
|
||||
var attrs = new List<string>();
|
||||
JObject cfg = contentItem.config;
|
||||
|
||||
if(cfg != null)
|
||||
{
|
||||
foreach (JProperty property in cfg.Properties())
|
||||
{
|
||||
attrs.Add(property.Name + "='" + property.Value.ToString() + "'");
|
||||
}
|
||||
}
|
||||
|
||||
JObject style = contentItem.styles;
|
||||
|
||||
if (style != null)
|
||||
{
|
||||
var cssVals = new List<string>();
|
||||
foreach (JProperty property in style.Properties())
|
||||
{
|
||||
cssVals.Add(property.Name + ":" + property.Value.ToString() + ";");
|
||||
}
|
||||
|
||||
if (cssVals.Any())
|
||||
{
|
||||
attrs.Add("style='" + string.Join(" ", cssVals) + "'");
|
||||
}
|
||||
}
|
||||
|
||||
return new MvcHtmlString(string.Join(" ", attrs));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user