Skip to content

Commit 2484cb3

Browse files
committed
2sxc 14 migration
1 parent d77924e commit 2484cb3

15 files changed

+3028
-2744
lines changed

.data/app.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
2-
<SexyContent FileVersion="07.00.00" MinimumRequiredVersion="07.04.02" ModuleVersion="13.11.00" ExportDate="2022-05-10T15:31:39.2306414+02:00">
2+
<SexyContent FileVersion="07.00.00" MinimumRequiredVersion="07.04.02" ModuleVersion="14.04.00" ExportDate="2022-06-29T13:31:54.4294117+02:00">
33
<Header>
44
<App Guid="3bfab1bb-e102-4176-adcf-f70594a6bdfe" />
55
<Language Default="en-us" />
@@ -1094,15 +1094,15 @@
10941094
<Value Key="RequiredOqtaneVersion" Value="03.01.00" Type="String">
10951095
<Dimension DimensionID="186" ReadOnly="false" />
10961096
</Value>
1097-
<Value Key="RequiredVersion" Value="13.10.00" Type="String">
1097+
<Value Key="RequiredVersion" Value="14.07.00" Type="String">
10981098
<Dimension DimensionID="185" ReadOnly="false" />
10991099
<Dimension DimensionID="186" ReadOnly="false" />
11001100
</Value>
11011101
<Value Key="SupportsAjaxReload" Value="True" Type="Boolean">
11021102
<Dimension DimensionID="185" ReadOnly="false" />
11031103
<Dimension DimensionID="186" ReadOnly="false" />
11041104
</Value>
1105-
<Value Key="Version" Value="07.02.00" Type="String">
1105+
<Value Key="Version" Value="07.03.00" Type="String">
11061106
<Dimension DimensionID="185" ReadOnly="false" />
11071107
<Dimension DimensionID="186" ReadOnly="false" />
11081108
</Value>
@@ -1644,7 +1644,7 @@
16441644
<Value Key="Advanced" Value="" Type="String">
16451645
<Dimension DimensionID="186" ReadOnly="false" />
16461646
</Value>
1647-
<Value Key="ByUrlParameters" Value="False" Type="Boolean">
1647+
<Value Key="ByUrlParameters" Value="True" Type="Boolean">
16481648
<Dimension DimensionID="186" ReadOnly="false" />
16491649
</Value>
16501650
<Value Key="Duration" Value="14400" Type="Number">

bs4/SortImages.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using ToSic.Razor.Blade;
33
using Dynlist = System.Collections.Generic.IEnumerable<dynamic>;
44

5-
public class SortImages: Custom.Hybrid.Code12
5+
public class SortImages: Custom.Hybrid.Code14
66
{
77
/**
88
* Returns the images, sorted by the passed setting

bs4/_Album.Part-Title-Description.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@inherits Custom.Hybrid.Razor12
1+
@inherits Custom.Hybrid.Razor14
22
@using ToSic.Razor.Blade;
33
@{
44
/* This part shows album title and introduction */

bs4/_Album.cshtml

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1-
@inherits Custom.Hybrid.Razor12
1+
@inherits Custom.Hybrid.Razor14
22
@using ToSic.Razor.Blade;
3-
@using ToSic.Sxc.Services;
43
@{
54
/* 1. Pre-Checks: Determine which Album to show or show error
65
* This will check if the url specifies a specific album, and if yes, use that
76
* If not, use the one configured in the module (for single-album scenarios)
87
* If nothing is found, it will stop after this code block (see `return` below)
98
*/
10-
11-
// Get the PageServices for setting Titles and HTTP error headers
12-
var pageSvc = GetService<IPageService>();
13-
var scrubSvc = GetService<IScrub>();
14-
var imgSvc = GetService<IImageService>();
15-
var tlbSvc = GetService<IToolbarService>();
169

1710
// Get page Parameters (works on Dnn & Oqtane)
1811
var albumInUrl = CmsContext.Page.Parameters["Album"];
@@ -32,7 +25,7 @@
3225
<div>@Html.Raw(Resources.AlbumNotFoundText)</div>
3326
<a href="@Link.To()" class="btn btn-outline-primary btn-sm">@Resources.BackToOverview</a>
3427

35-
pageSvc.SetHttpStatus(404);
28+
Kit.Page.SetHttpStatus(404);
3629
return;
3730
}
3831
}
@@ -44,8 +37,8 @@
4437
*/
4538

4639
// 2.1 Set the title of the page
47-
pageSvc.SetTitle(album.Title + " | "); // will prepend to the existing title
48-
// pageSvc.SetTitle(album.Title, "[album]"); // Alternative: this would replace a placeholder [album] in the title with the title
40+
Kit.Page.SetTitle(album.Title + " | "); // will prepend to the existing title
41+
// Kit.Page.SetTitle(album.Title, "[album]"); // Alternative: this would replace a placeholder [album] in the title with the title
4942
5043
// 2.2 Determine if we should show as Masonry
5144
var albumTiling = Text.Has(album.Presentation.TileStructure)
@@ -70,7 +63,7 @@
7063
// 2.9 Helpers used later in the Template
7164
var helpers = CreateInstance("SortImages.cs"); // Has helper code for sorting
7265
73-
var gallerySettings = CmsContext.View.Identifier == "masonry" ? imgSvc.Settings("Content", resizeMode:"max") : Settings.Images.Content;
66+
var gallerySettings = CmsContext.View.Identifier == "masonry" ? Kit.Image.Settings("Content", resizeMode:"max") : Settings.Images.Content;
7467
}
7568
@* 4. Show the Album *@
7669
<div class="app-ga7-main" @Edit.TagToolbar(album)>
@@ -88,7 +81,7 @@
8881

8982
// Build the Caption for the Lightbox - will later be converted to an attribute
9083
var caption = (Content.Presentation.ShowImageTitle && Text.Has(pic.Metadata.Title))
91-
? Tag.H6().Wrap(scrubSvc.All(pic.Metadata.Title)) + Tag.P().Wrap(scrubSvc.All(pic.Metadata.Description))
84+
? Tag.H6().Wrap(Kit.Scrub.All(pic.Metadata.Title)) + Tag.P().Wrap(Kit.Scrub.All(pic.Metadata.Description))
9285
: "";
9386

9487
// Toolbar parameters (for admins) to ensure the metadata-button does what's needed
@@ -97,17 +90,19 @@
9790
"metadata?entityId=" + pic.Metadata.EntityId + "&contentType=ImageMetadata&for=file:" + pic.FileId
9891
};
9992

100-
@* 4.3a Optionally wrap inside a special <div> if it's not Masonry-layout *@
93+
var picToolbar = Kit.Toolbar.Empty().Metadata(pic, "ImageMetadata").Condition(!Content.IsDemoItem);
94+
95+
@* 4.3a Optionally wrap inside a special <div> if it's not Masonrylayout *@
10196
if(!useMasonry) { @Tag.Div().Class("col-12 col-sm-6 col-md-4 col-lg-3 mb-4").TagStart }
10297
@* 4.4 Now show each image *@
103-
var lbPic = imgSvc.Picture(pic.Url, settings:"Lightbox");
98+
var lbPic = Kit.Image.Picture(pic.Url, settings:"Lightbox");
10499
<a class="app-ga7" @fancyboxAttribute data-src="@pic.Url" data-srcset="@lbPic.SrcSet" data-sizes="@lbPic.Sizes" data-preload="false" data-caption="@caption">
105-
<figure class="app-ga7-image @effect" @Edit.TagToolbar(toolbar: tlbSvc.Metadata(pic, "ImageMetadata"), condition: !Content.IsDemoItem)>
100+
<figure class="app-ga7-image @effect" @picToolbar>
106101
@* 4.5 Show the Overlay, an optional title (based on settings) and the image itself *@
107102
<figcaption class="overlay d-flex align-items-end">
108103
@if(Text.Has(picTitle)) { <div class="caption">@picTitle</div> }
109104
</figcaption>
110-
@imgSvc.Picture(pic.Url, settings: gallerySettings)
105+
@Kit.Image.Picture(pic.Url, settings: gallerySettings)
111106
</figure>
112107
</a>
113108
@* 4.3b close <div> if we opened it above *@

bs4/_Albums.cshtml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
@inherits Custom.Hybrid.Razor12
1+
@inherits Custom.Hybrid.Razor14
22
@using ToSic.Razor.Blade;
3-
@using ToSic.Sxc.Services;
43
@using Dynlist = System.Collections.Generic.IEnumerable<dynamic>;
54
@{
65
// Determine the widths of each part, based on 12 Bootstrap columns
76
var imgResizeFactor = "4/12"; // Each Album uses 4 columns
87
98
// visual effect for mouse interaction
109
var effect = "effect-zoom"; // alternative: "effect-darken";
11-
12-
// Image Service used to generate optimal images
13-
var imgSvc = GetService<IImageService>();
1410
}
1511

1612
<div class="app-ga7-main">
@@ -36,7 +32,7 @@
3632
<span class="badge badge-pill">@images.Count()</span>
3733
</div>
3834
</figcaption>
39-
@imgSvc.Picture(albumThumbUrl, settings: "Content", factor: imgResizeFactor, imgAlt: altText)
35+
@Kit.Image.Picture(albumThumbUrl, settings: "Content", factor: imgResizeFactor, imgAlt: altText)
4036
</figure>
4137
</a>
4238
</div>

bs4/shared/_Assets.cshtml

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
1-
@inherits Custom.Hybrid.Razor12
2-
@using ToSic.Sxc.Services;
1+
@inherits Custom.Hybrid.Razor14
32
@{
4-
// 1. Get Services for Css and Page
5-
var pageCss = GetService<Connect.Koi.ICss>(); // Service to get CSS information about the current Theme
6-
var pageSvc = GetService<IPageService>(); // Service to activate features or set titles etc.
7-
83
// 2. Include Bootstrap4 if the framework isn't known
9-
if (pageCss.IsUnknown) {
10-
pageSvc.Activate("Bootstrap4");
4+
if (Kit.Css.IsUnknown) {
5+
Kit.Page.Activate("Bootstrap4");
116
}
127

138
// 3. Show warning for admin if koi.json is missing
14-
if (pageCss.IsUnknown && CmsContext.User.IsSiteAdmin) {
9+
if (Kit.Css.IsUnknown && CmsContext.User.IsSiteAdmin) {
1510
<div class='dnnFormMessage dnnFormWarning'>
1611
@Html.Raw(Connect.Koi.Messages.CssInformationMissing) <br>
1712
@Html.Raw(Connect.Koi.Messages.OnlyAdminsSeeThis)
1813
</div>
1914
}
2015

2116
// 4. Include styles of the App
22-
<link rel="stylesheet" href="@App.Path/bs4/dist/styles.min.css" @pageSvc.AssetAttributes()/>
17+
<link rel="stylesheet" href="@App.Path/bs4/dist/styles.min.css" @Kit.Page.AssetAttributes()/>
2318

2419
// 5. If we need scripts (only on the single-album-view) activate these. Note that DynamicModel contains the parameters
2520
if(DynamicModel.scripts == true) {
2621
// Activate turnOn and Fancybox4 - see https://r.2sxc.org/turnon - fancybox4 is a standard WebResources in 2sxc
27-
pageSvc.Activate("turnOn", "fancybox4");
22+
Kit.Page.Activate("turnOn", "fancybox4");
2823

2924
// Init options for fancybox binding
3025
// This is only partial - if you want to see more, see https://fancyapps.com/docs/ui/fancybox/options
@@ -36,7 +31,7 @@
3631
}
3732
};
3833

39-
<script type="text/javascript" src="@App.Path/bs4/dist/scripts.min.js" @pageSvc.AssetAttributes(position:"bottom")></script>
40-
<turnOn turn-on='{"await": ["window.Fancybox"], "run": "window.appGalleryV7.init()", "data": { "attribute": "@DynamicModel.FancyboxAttribute", "options": @Html.Raw(Convert.Json.ToJson(fancyboxOptions)) }}'></turnOn>
34+
<script type="text/javascript" src="@App.Path/bs4/dist/scripts.min.js" @Kit.Page.AssetAttributes(position:"bottom")></script>
35+
<turnOn turn-on='{"await": ["window.Fancybox"], "run": "window.appGalleryV7.init()", "data": { "attribute": "@DynamicModel.FancyboxAttribute", "options": @Html.Raw(Kit.Json.ToJson(fancyboxOptions)) }}'></turnOn>
4136
}
4237
}

bs5/SortImages.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using ToSic.Razor.Blade;
33
using Dynlist = System.Collections.Generic.IEnumerable<dynamic>;
44

5-
public class SortImages: Custom.Hybrid.Code12
5+
public class SortImages: Custom.Hybrid.Code14
66
{
77
/**
88
* Returns the images, sorted by the passed setting

bs5/_Album.Part-Title-Description.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@inherits Custom.Hybrid.Razor12
1+
@inherits Custom.Hybrid.Razor14
22
@using ToSic.Razor.Blade;
33
@{
44
/* This part shows album title and introduction */

bs5/_Album.cshtml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,11 @@
1-
@inherits Custom.Hybrid.Razor12
1+
@inherits Custom.Hybrid.Razor14
22
@using ToSic.Razor.Blade;
3-
@using ToSic.Sxc.Services;
43
@{
54
/* 1. Pre-Checks: Determine which Album to show or show error
65
* This will check if the url specifies a specific album, and if yes, use that
76
* If not, use the one configured in the module (for single-album scenarios)
87
* If nothing is found, it will stop after this code block (see `return` below)
98
*/
10-
11-
// Get the PageServices for setting Titles and HTTP error headers
12-
var pageSvc = GetService<IPageService>();
13-
var imgSvc = GetService<IImageService>();
14-
var scrubSvc = GetService<IScrub>();
15-
var toolbarSvc = GetService<IToolbarService>();
16-
179
// Get page Parameters (works on Dnn & Oqtane)
1810
var albumInUrl = CmsContext.Page.Parameters["Album"];
1911
var isDetailViewOfAlbum = Text.Has(albumInUrl);
@@ -32,7 +24,7 @@
3224
<div>@Html.Raw(Resources.AlbumNotFoundText)</div>
3325
<a href="@Link.To()" class="btn btn-outline-primary btn-sm">@Resources.BackToOverview</a>
3426

35-
pageSvc.SetHttpStatus(404);
27+
Kit.Page.SetHttpStatus(404);
3628
return;
3729
}
3830
}
@@ -44,8 +36,8 @@
4436
*/
4537

4638
// 2.1 Set the title of the page
47-
pageSvc.SetTitle(album.Title + " | "); // will prepend to the existing title
48-
// pageSvc.SetTitle(album.Title, "[album]"); // Alternative: this would replace a placeholder [album] in the title with the title
39+
Kit.Page.SetTitle(album.Title + " | "); // will prepend to the existing title
40+
// Kit.Page.SetTitle(album.Title, "[album]"); // Alternative: this would replace a placeholder [album] in the title with the title
4941
5042
// 2.2 Determine if we should show as Masonry
5143
var albumTiling = Text.Has(album.Presentation.TileStructure)
@@ -70,7 +62,7 @@
7062
// 2.9 Helpers used later in the Template
7163
var helpers = CreateInstance("SortImages.cs"); // Has helper code for sorting
7264
73-
var gallerySettings = CmsContext.View.Identifier == "masonry" ? imgSvc.Settings("Content", resizeMode:"max") : Settings.Images.Content;
65+
var gallerySettings = CmsContext.View.Identifier == "masonry" ? Kit.Image.Settings("Content", resizeMode:"max") : Settings.Images.Content;
7466
var galleryFactor = CmsContext.View.Identifier == "masonry" ? "4/12" : "3/12";
7567
}
7668
@* 4. Show the Album *@
@@ -88,7 +80,7 @@
8880

8981
// Build the Caption for the Lightbox - will later be converted to an attribute
9082
var caption = (Content.Presentation.ShowImageTitle && Text.Has(pic.Metadata.Title))
91-
? Tag.H6().Wrap(scrubSvc.All(pic.Metadata.Title)) + Tag.P().Wrap(scrubSvc.All(pic.Metadata.Description))
83+
? Tag.H6().Wrap(Kit.Scrub.All(pic.Metadata.Title)) + Tag.P().Wrap(Kit.Scrub.All(pic.Metadata.Description))
9284
: "";
9385

9486
// Toolbar parameters (for admins) to ensure the metadata-button does what's needed
@@ -97,19 +89,21 @@
9789
"metadata?entityId=" + pic.Metadata.EntityId + "&contentType=ImageMetadata&for=file:" + pic.FileId
9890
};
9991

100-
@* 4.3a Optionally wrap inside a special <div> if it's not Masonry-layout *@
92+
var picToolbar = Kit.Toolbar.Empty().Metadata(pic, "ImageMetadata").Condition(!Content.IsDemoItem);
93+
94+
@* 4.3a Optionally wrap inside a special <div> if it's not Masonrylayout *@
10195
if(!useMasonry) { @Tag.Div().Class("col-12 col-sm-6 col-md-4 col-lg-3 mb-4").TagStart }
10296
@* 4.4 Now show each image *@
103-
var lbPic = imgSvc.Picture(pic.Url, settings:"Lightbox");
97+
var lbPic = Kit.Image.Picture(pic.Url, settings:"Lightbox");
10498
<a class="app-ga7" @fancyboxAttribute data-src="@pic.Url" data-srcset="@lbPic.SrcSet" data-sizes="@lbPic.Sizes" data-preload="false" data-caption="@caption">
10599

106-
<figure class="app-ga7-image @effect" @Edit.TagToolbar(toolbar: metaToolbarConfig, condition: !Content.IsDemoItem)>
100+
<figure class="app-ga7-image @effect" @pic.Toolb>
107101
@* 4.5 Show the Overlay, an optional title (based on settings) and the image itself *@
108102
<figcaption class="overlay d-flex align-items-end">
109103
@if(Text.Has(picTitle)) { <div class="caption">@picTitle</div> }
110104
</figcaption>
111105

112-
@imgSvc.Picture(pic.Url, settings: gallerySettings, factor: galleryFactor)
106+
@Kit.Image.Picture(pic.Url, settings: gallerySettings, factor: galleryFactor)
113107
</figure>
114108
</a>
115109
@* 4.3b close <div> if we opened it above *@

bs5/_Albums.cshtml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
@inherits Custom.Hybrid.Razor12
1+
@inherits Custom.Hybrid.Razor14
22
@using ToSic.Razor.Blade;
3-
@using ToSic.Sxc.Services;
43
@using Dynlist = System.Collections.Generic.IEnumerable<dynamic>;
54
@{
65
// Determine the widths of each part, based on 12 Bootstrap columns
76
var imgResizeFactor = "4/12"; // Each Album uses 4 columns
87
98
// visual effect for mouse interaction
109
var effect = "effect-zoom"; // alternative: "effect-darken";
11-
12-
// Image Service used to generate optimal images
13-
var imgSvc = GetService<IImageService>();
1410
}
1511

1612
<div class="app-ga7-main">
@@ -36,7 +32,7 @@
3632
<span class="badge rounded-pill">@images.Count()</span>
3733
</div>
3834
</figcaption>
39-
@imgSvc.Picture(albumThumbUrl, settings: "Content", factor: imgResizeFactor, imgAlt:album.Title)
35+
@Kit.Image.Picture(albumThumbUrl, settings: "Content", factor: imgResizeFactor, imgAlt:album.Title)
4036
</figure>
4137
</a>
4238
</div>

0 commit comments

Comments
 (0)