added router support for url fragments, added language attribute to HTML document tag to improve validation, fixed Theme Settings so they can only be invoked via the Control Panel, added support for webp image files

This commit is contained in:
Shaun Walker
2022-01-22 19:34:30 -05:00
parent 1fbab5db2b
commit f964e0e502
10 changed files with 336 additions and 267 deletions

View File

@ -3,7 +3,7 @@
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@model Oqtane.Pages.HostModel
<!DOCTYPE html>
<html>
<html lang="@Model.Language">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width">

View File

@ -52,6 +52,7 @@ namespace Oqtane.Pages
_settings = settings;
}
public string Language = "en";
public string AntiForgeryToken = "";
public string Runtime = "Server";
public RenderMode RenderMode = RenderMode.Server;
@ -174,19 +175,29 @@ namespace Oqtane.Pages
}
// set culture if not specified
if (HttpContext.Request.Cookies[CookieRequestCultureProvider.DefaultCookieName] == null)
string culture = HttpContext.Request.Cookies[CookieRequestCultureProvider.DefaultCookieName];
if (culture == null)
{
// set default language for site if the culture is not supported
// get default language for site
var languages = _languages.GetLanguages(alias.SiteId);
if (languages.Any() && languages.All(l => l.Code != CultureInfo.CurrentUICulture.Name))
if (languages.Any())
{
var defaultLanguage = languages.Where(l => l.IsDefault).SingleOrDefault() ?? languages.First();
SetLocalizationCookie(defaultLanguage.Code);
// use default language if specified otherwise use first language in collection
culture = (languages.Where(l => l.IsDefault).SingleOrDefault() ?? languages.First()).Code;
}
else
{
SetLocalizationCookie(_localizationManager.GetDefaultCulture());
culture = _localizationManager.GetDefaultCulture();
}
SetLocalizationCookie(culture);
}
// set language for page
if (!string.IsNullOrEmpty(culture))
{
// localization cookie value in form of c=en|uic=en
Language = culture.Split('|')[0];
Language = Language.Replace("c=", "");
}
}
}

View File

@ -125,15 +125,18 @@ namespace Oqtane.Repository
foreach (Type containertype in containertypes)
{
var containerobject = Activator.CreateInstance(containertype) as IThemeControl;
theme.Containers.Add(
new ThemeControl
{
TypeName = containertype.FullName + ", " + themeControlType.Assembly.GetName().Name,
Name = (string.IsNullOrEmpty(containerobject.Name)) ? Utilities.GetTypeNameLastSegment(containertype.FullName, 0) : containerobject.Name,
Thumbnail = containerobject.Thumbnail,
Panes = ""
}
);
if (theme.Containers.FirstOrDefault(item => item.TypeName == containertype.FullName + ", " + themeControlType.Assembly.GetName().Name) == null)
{
theme.Containers.Add(
new ThemeControl
{
TypeName = containertype.FullName + ", " + themeControlType.Assembly.GetName().Name,
Name = (string.IsNullOrEmpty(containerobject.Name)) ? Utilities.GetTypeNameLastSegment(containertype.FullName, 0) : containerobject.Name,
Thumbnail = containerobject.Thumbnail,
Panes = ""
}
);
}
}
themes[index] = theme;

View File

@ -126,6 +126,10 @@ app {
margin-bottom: 15px;
}
.app-moduletitle a {
scroll-margin-top: 7rem;
}
/* Tooltips */
.app-tooltip {
cursor: help;

View File

@ -376,5 +376,14 @@ Oqtane.Interop = {
left: left,
behavior: behavior
});
},
scrollToId: function (id) {
var element = document.getElementById(id);
if (element instanceof HTMLElement) {
element.scrollIntoView({
behavior: "smooth",
block: "start",
inline: "nearest"
});
}
};
}};