Skip to content

Commit

Permalink
added HeadContent property to Site and replaced Meta property on Page…
Browse files Browse the repository at this point in the history
… with HeadContent property.
  • Loading branch information
sbwalker committed May 16, 2023
1 parent 89ada83 commit 8d2f644
Show file tree
Hide file tree
Showing 10 changed files with 359 additions and 294 deletions.
36 changes: 18 additions & 18 deletions Oqtane.Client/Modules/Admin/Pages/Add.razor
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@
<input id="url" class="form-control" @bind="@_url" />
</div>
</div>
<div class="row mb-1 align-items-center">
<Label Class="col-sm-3" For="personalizable" HelpText="Select whether you would like users to be able to personalize this page with their own content" ResourceKey="Personalizable">Personalizable? </Label>
<div class="col-sm-9">
<select id="personalizable" class="form-select" @bind="@_ispersonalizable" required>
<option value="True">@SharedLocalizer["Yes"]</option>
<option value="False">@SharedLocalizer["No"]</option>
</select>
</div>
</div>
</div>

<Section Name="Appearance" ResourceKey="Appearance">
Expand All @@ -96,9 +105,9 @@
</div>
</div>
<div class="row mb-1 align-items-center">
<Label Class="col-sm-3" For="meta" HelpText="Optionally enter meta tags (in exactly the form you want them to be included in the page output)." ResourceKey="Meta">Meta: </Label>
<Label Class="col-sm-3" For="icon" HelpText="Optionally provide an icon class name for this page which will be displayed in the site navigation" ResourceKey="Icon">Icon: </Label>
<div class="col-sm-9">
<textarea id="meta" class="form-control" @bind="@_meta" rows="3"></textarea>
<input id="icon" class="form-control" @bind="@_icon" />
</div>
</div>
<div class="row mb-1 align-items-center">
Expand All @@ -125,21 +134,12 @@
</div>
</div>
<div class="row mb-1 align-items-center">
<Label Class="col-sm-3" For="icon" HelpText="Optionally provide an icon class name for this page which will be displayed in the site navigation" ResourceKey="Icon">Icon: </Label>
<div class="col-sm-9">
<input id="icon" class="form-control" @bind="@_icon" />
</div>
</div>
<div class="row mb-1 align-items-center">
<Label Class="col-sm-3" For="personalizable" HelpText="Select whether you would like users to be able to personalize this page with their own content" ResourceKey="Personalizable">Personalizable? </Label>
<Label Class="col-sm-3" For="headcontent" HelpText="Optionally enter content to be included in the page head (ie. meta and link tags are valid, script tags are not)." ResourceKey="HeadContent">Head Content: </Label>
<div class="col-sm-9">
<select id="personalizable" class="form-select" @bind="@_ispersonalizable" required>
<option value="True">@SharedLocalizer["Yes"]</option>
<option value="False">@SharedLocalizer["No"]</option>
</select>
<textarea id="headcontent" class="form-control" @bind="@_headcontent" rows="3"></textarea>
</div>
</div>
</div>
</div>
</Section>
}
</TabPanel>
Expand Down Expand Up @@ -170,7 +170,6 @@
private List<ThemeControl> _containers = new List<ThemeControl>();
private string _name;
private string _title;
private string _meta;
private string _path = string.Empty;
private string _parentid = "-1";
private string _insert = ">>";
Expand All @@ -182,7 +181,8 @@
private string _ispersonalizable = "False";
private string _themetype = string.Empty;
private string _containertype = string.Empty;
private string _icon = string.Empty;
private string _headcontent;
private string _icon = string.Empty;
private string _permissions = null;
private PermissionGrid _permissionGrid;
private Type _themeSettingsType;
Expand Down Expand Up @@ -376,11 +376,11 @@
{
page.DefaultContainerType = string.Empty;
}
page.Icon = (_icon == null ? string.Empty : _icon);
page.HeadContent = _headcontent;
page.Icon = (_icon == null ? string.Empty : _icon);
page.PermissionList = _permissionGrid.GetPermissionList();
page.IsPersonalizable = (_ispersonalizable == null ? false : Boolean.Parse(_ispersonalizable));
page.UserId = null;
page.Meta = _meta;

page = await PageService.AddPageAsync(page);
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, page.ParentId);
Expand Down
40 changes: 20 additions & 20 deletions Oqtane.Client/Modules/Admin/Pages/Edit.razor
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@
<input id="url" class="form-control" @bind="@_url" maxlength="500"/>
</div>
</div>
<div class="row mb-1 align-items-center">
<Label Class="col-sm-3" For="personalizable" HelpText="Select whether you would like users to be able to personalize this page with their own content" ResourceKey="Personalizable">Personalizable? </Label>
<div class="col-sm-9">
<select id="personalizable" class="form-select" @bind="@_ispersonalizable" required>
<option value="True">@SharedLocalizer["Yes"]</option>
<option value="False">@SharedLocalizer["No"]</option>
</select>
</div>
</div>
</div>
<Section Name="Appearance" ResourceKey="Appearance">
<div class="container">
Expand All @@ -103,9 +112,9 @@
</div>
</div>
<div class="row mb-1 align-items-center">
<Label Class="col-sm-3" For="meta" HelpText="Optionally enter meta tags (in exactly the form you want them to be included in the page output)." ResourceKey="Meta">Meta: </Label>
<Label Class="col-sm-3" For="icon" HelpText="Optionally provide an icon class name for this page which will be displayed in the site navigation" ResourceKey="Icon">Icon: </Label>
<div class="col-sm-9">
<textarea id="meta" class="form-control" @bind="@_meta" rows="3"></textarea>
<input id="icon" class="form-control" @bind="@_icon" maxlength="50" />
</div>
</div>
<div class="row mb-1 align-items-center">
Expand All @@ -132,18 +141,9 @@
</div>
</div>
<div class="row mb-1 align-items-center">
<Label Class="col-sm-3" For="icon" HelpText="Optionally provide an icon class name for this page which will be displayed in the site navigation" ResourceKey="Icon">Icon: </Label>
<Label Class="col-sm-3" For="headcontent" HelpText="Optionally enter content to be included in the page head (ie. meta and link tags are valid, script tags are not)." ResourceKey="HeadContent">Head Content: </Label>
<div class="col-sm-9">
<input id="icon" class="form-control" @bind="@_icon" maxlength="50"/>
</div>
</div>
<div class="row mb-1 align-items-center">
<Label Class="col-sm-3" For="personalizable" HelpText="Select whether you would like users to be able to personalize this page with their own content" ResourceKey="Personalizable">Personalizable? </Label>
<div class="col-sm-9">
<select id="personalizable" class="form-select" @bind="@_ispersonalizable" required>
<option value="True">@SharedLocalizer["Yes"]</option>
<option value="False">@SharedLocalizer["No"]</option>
</select>
<textarea id="headcontent" class="form-control" @bind="@_headcontent" rows="3"></textarea>
</div>
</div>
</div>
Expand Down Expand Up @@ -207,8 +207,7 @@
private int _pageId;
private string _name;
private string _title;
private string _meta;
private string _path;
private string _path;
private string _currentparentid;
private string _parentid = "-1";
private string _insert = "=";
Expand All @@ -220,7 +219,8 @@
private string _ispersonalizable;
private string _themetype;
private string _containertype = "-";
private string _icon;
private string _headcontent;
private string _icon;
private List<Permission> _permissions = null;
private string _createdby;
private DateTime _createdon;
Expand Down Expand Up @@ -250,7 +250,6 @@
{
_name = page.Name;
_title = page.Title;
_meta = page.Meta;
_path = page.Path;
_pageModules = PageState.Modules.Where(m => m.PageId == page.PageId).ToList();

Expand Down Expand Up @@ -291,7 +290,8 @@
{
_containertype = PageState.Site.DefaultContainerType;
}
_icon = page.Icon;
_headcontent = page.HeadContent;
_icon = page.Icon;
_permissions = page.PermissionList;
_createdby = page.CreatedBy;
_createdon = page.CreatedOn;
Expand Down Expand Up @@ -508,11 +508,11 @@
{
page.DefaultContainerType = string.Empty;
}
page.Icon = _icon ?? string.Empty;
page.HeadContent = _headcontent;
page.Icon = _icon ?? string.Empty;
page.PermissionList = _permissionGrid.GetPermissionList();
page.IsPersonalizable = (_ispersonalizable != null && Boolean.Parse(_ispersonalizable));
page.UserId = null;
page.Meta = _meta;

page = await PageService.UpdatePageAsync(page);
await PageService.UpdatePageOrderAsync(page.SiteId, page.PageId, page.ParentId);
Expand Down
Loading

3 comments on commit 8d2f644

@vnetonline
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbwalker is there going to be a similar implementation for the BodyContent and is that where we can put our Google Analytics Script tag ... it seems that the HeadContent doesn't support Script tags

image

Also, keep in mind that Googles suggests that the Google Analytics tag should go between the Head and Body Tags

image

@sbwalker
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vnetonline correct, this is not complete yet. A few other comments:

  1. There is an entire thread about adding Google Analytics here: Unclear how to add JavaScript (Google Analytics) to Theme Header #2488
  2. Blazor components cannot render JavaScript - they actually remove them from the output... JS Interop is required
  3. I do not believe your interpretation of the GA screen shot is correct - from my experience it is always placed within the head section - ie. after the < head > tag. I did some research on this and I cannot find a single example where it suggests adding it between the head and body - in fact if you place it there, I believe it will be out of compliance with the HTML5 spec
  4. Have you thought about how GA is going to work in Oqtane - since it is a single page application, simply adding the standard script will only capture the initial page view - all subsequent navigations by the user occur client-side and will not be captured by GA.

@vnetonline
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sbwalker thanks for your insights .... seems I have a lot to learn about Oqtane and Blazor architecture

Please sign in to comment.