Skip to content

Commit 83af111

Browse files
committedNov 7, 2022
#361: changed from Title, and added DisplayName for Pages instead
1 parent 51624cd commit 83af111

File tree

6 files changed

+35
-14
lines changed

6 files changed

+35
-14
lines changed
 

‎docs/release-notes.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
```plain
66
### Enhancements
77
* #340: Add new `-MaxLength` for textboxes (thanks @thekamilpro!)
8-
* #361: Add DisplayName for Tables/Charts, and use the Title in the sidebar for Pages
8+
* #361: Add DisplayName for Tables/Charts, and also for Pages for their name in the sidebar
99
1010
### Bugs
1111
* #255: Fixes page group names not allowing spaces

‎examples/language.ps1

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Start-PodeServer -StatusPageExceptions Show {
5252
)
5353
)
5454

55-
Set-PodeWebHomePage -Layouts $grid1 -Title ''
55+
Set-PodeWebHomePage -Layouts $grid1 -DisplayName ''
5656

5757

5858
# add a page to search and filter services (output in a new table element) [note: requires auth]
@@ -113,7 +113,7 @@ Start-PodeServer -StatusPageExceptions Show {
113113
}
114114
}
115115

116-
Add-PodeWebPage -Name Services -Title 'サービス' -Icon 'cogs' -Group Tools -Layouts $editModal, $helpModal, $table -ScriptBlock {
116+
Add-PodeWebPage -Name Services -DisplayName 'サービス' -Icon 'cogs' -Group Tools -Layouts $editModal, $helpModal, $table -ScriptBlock {
117117
$name = $WebEvent.Query['value']
118118
if ([string]::IsNullOrWhiteSpace($name)) {
119119
return
@@ -131,7 +131,7 @@ Start-PodeServer -StatusPageExceptions Show {
131131

132132

133133
# open twitter
134-
Add-PodeWebPageLink -Name Twitter -Title 'Tweet' -Icon Twitter -Group Social -ScriptBlock {
134+
Add-PodeWebPageLink -Name Twitter -DisplayName 'Tweet' -Icon Twitter -Group Social -ScriptBlock {
135135
Move-PodeWebUrl -Url 'https://twitter.com' -NewTab
136136
}
137137
}

‎src/Private/Helpers.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ function Get-PodeWebState
304304

305305
function Get-PodeWebHomeName
306306
{
307-
$name = (Get-PodeWebState -Name 'pages')['/'].Title
307+
$name = (Get-PodeWebState -Name 'pages')['/'].DisplayName
308308
if ([string]::IsNullOrWhiteSpace($name)) {
309309
return 'Home'
310310
}

‎src/Public/Pages.ps1

+27-7
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ function Set-PodeWebLoginPage
174174
Page = @{
175175
Name = 'Home'
176176
Title = 'Home'
177+
DisplayName = 'Home'
177178
Path = '/'
178179
IsSystem = $true
179180
}
@@ -203,6 +204,10 @@ function Set-PodeWebHomePage
203204
[hashtable[]]
204205
$Layouts,
205206

207+
[Parameter()]
208+
[string]
209+
$DisplayName,
210+
206211
[Parameter()]
207212
[string]
208213
$Title,
@@ -229,8 +234,12 @@ function Set-PodeWebHomePage
229234
}
230235

231236
# set page title
237+
if ([string]::IsNullOrWhiteSpace($DisplayName)) {
238+
$DisplayName = 'Home'
239+
}
240+
232241
if ([string]::IsNullOrWhiteSpace($Title)) {
233-
$Title = 'Home'
242+
$Title = $DisplayName
234243
}
235244

236245
# route path
@@ -242,7 +251,8 @@ function Set-PodeWebHomePage
242251
ObjectType = 'Page'
243252
Path = $routePath
244253
Name = 'Home'
245-
Title = $Title
254+
Title = [System.Net.WebUtility]::HtmlEncode($Title)
255+
DisplayName = [System.Net.WebUtility]::HtmlEncode($DisplayName)
246256
NoTitle = $NoTitle.IsPresent
247257
Navigation = $Navigation
248258
Layouts = $Layouts
@@ -317,6 +327,10 @@ function Add-PodeWebPage
317327
[string]
318328
$Name,
319329

330+
[Parameter()]
331+
[string]
332+
$DisplayName,
333+
320334
[Parameter()]
321335
[string]
322336
$Title,
@@ -400,8 +414,12 @@ function Add-PodeWebPage
400414
}
401415

402416
# set page title
417+
if ([string]::IsNullOrWhiteSpace($DisplayName)) {
418+
$DisplayName = $Name
419+
}
420+
403421
if ([string]::IsNullOrWhiteSpace($Title)) {
404-
$Title = $Name
422+
$Title = $DisplayName
405423
}
406424

407425
# build the route path
@@ -414,6 +432,7 @@ function Add-PodeWebPage
414432
Path = $routePath
415433
Name = $Name
416434
Title = [System.Net.WebUtility]::HtmlEncode($Title)
435+
DisplayName = [System.Net.WebUtility]::HtmlEncode($DisplayName)
417436
NoTitle = $NoTitle.IsPresent
418437
NoBackArrow = $NoBackArrow.IsPresent
419438
NoBreadcrumb = $NoBreadcrumb.IsPresent
@@ -515,6 +534,7 @@ function Add-PodeWebPage
515534
Write-PodeWebViewResponse -Path 'index' -Data @{
516535
Page = $global:PageData
517536
Title = $global:PageData.Title
537+
DisplayName = $global:PageData.DisplayName
518538
Theme = $theme
519539
Navigation = $navigation
520540
Breadcrumb = $breadcrumb
@@ -579,7 +599,7 @@ function Add-PodeWebPageLink
579599

580600
[Parameter()]
581601
[string]
582-
$Title,
602+
$DisplayName,
583603

584604
[Parameter()]
585605
[string]
@@ -633,16 +653,16 @@ function Add-PodeWebPageLink
633653
}
634654

635655
# set page title
636-
if ([string]::IsNullOrWhiteSpace($Title)) {
637-
$Title = $Name
656+
if ([string]::IsNullOrWhiteSpace($DisplayName)) {
657+
$DisplayName = $Name
638658
}
639659

640660
# setup page meta
641661
$pageMeta = @{
642662
ComponentType = 'Page'
643663
ObjectType = 'Link'
644664
Name = $Name
645-
Title = [System.Net.WebUtility]::HtmlEncode($Title)
665+
DisplayName = [System.Net.WebUtility]::HtmlEncode($DisplayName)
646666
NewTab = $NewTab.IsPresent
647667
Icon = $Icon
648668
Group = $Group

‎src/Public/Utilities.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ function Use-PodeWebTemplates
8484
Name = 'Home'
8585
Path = '/'
8686
TItle = 'Home'
87+
DisplayName = 'Home'
8788
IsSystem = $true
8889
}
8990
}

‎src/Templates/Views/index.pode

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<html>
22
$(Use-PodeWebPartialView -Path 'shared/head' -Data @{
3-
Title = $data.Page.Title
3+
Title = $data.Page.DisplayName
44
Theme = $data.Theme
55
AppPath = $data.AppPath
66
})
@@ -182,7 +182,7 @@
182182
<a class='nav-link $($activePage)' name='$($page.Name)' pode-page-group='$($pageGroup.Name)' pode-page-type='$($page.ObjectType)' pode-dynamic='$($page.IsDynamic)' $($href)>
183183
<div>
184184
<span class='mdi mdi-$($page.Icon.ToLowerInvariant()) mdi-size-22 mRight02'></span>
185-
$([System.Net.WebUtility]::HtmlEncode($page.Title))
185+
$([System.Net.WebUtility]::HtmlEncode($page.DisplayName))
186186
</div>
187187
</a>
188188
</li>"

0 commit comments

Comments
 (0)