Skip to content

Commit f0f33f2

Browse files
Merge pull request #9 from PowerShellWeb/OpenGraph-Init
OpenGraph Initial Release
2 parents 4feaf83 + b9894db commit f0f33f2

11 files changed

+763
-1
lines changed

.github/workflows/OpenGraph-Build.yml

+510
Large diffs are not rendered by default.

Build/GitHub/Jobs/OpenGraph.psd1

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
@{
2+
"runs-on" = "ubuntu-latest"
3+
if = '${{ success() }}'
4+
steps = @(
5+
@{
6+
name = 'Check out repository'
7+
uses = 'actions/checkout@v2'
8+
},
9+
@{
10+
name = 'GitLogger'
11+
uses = 'GitLogging/GitLoggerAction@main'
12+
id = 'GitLogger'
13+
},
14+
@{
15+
name = 'Use PSSVG Action'
16+
uses = 'StartAutomating/PSSVG@main'
17+
id = 'PSSVG'
18+
},
19+
@{
20+
name = 'Use PipeScript Action'
21+
uses = 'StartAutomating/PipeScript@main'
22+
id = 'PipeScript'
23+
},
24+
'RunEZOut',
25+
'RunHelpOut',
26+
@{
27+
name = 'Use PSJekyll Action'
28+
uses = 'PowerShellWeb/PSJekyll@main'
29+
id = 'PSJekyll'
30+
}
31+
)
32+
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
@{
2+
name = 'PublishTestResults'
3+
uses = 'actions/upload-artifact@main'
4+
with = @{
5+
name = 'PesterResults'
6+
path = '**.TestResults.xml'
7+
}
8+
if = '${{always()}}'
9+
}
10+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#requires -Module PSDevOps
2+
Import-BuildStep -SourcePath (
3+
Join-Path $PSScriptRoot 'GitHub'
4+
) -BuildSystem GitHubWorkflow
5+
6+
Push-Location ($PSScriptRoot | Split-Path)
7+
New-GitHubWorkflow -Name "OpenGraph Module Build" -On Push,
8+
PullRequest,
9+
Demand -Job TestPowerShellOnLinux,
10+
TagReleaseAndPublish, OpenGraph -OutputPath .\.github\workflows\OpenGraph-Build.yml
11+
12+
Pop-Location

Build/OpenGraph.ezout.ps1

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#requires -Module EZOut
2+
# Install-Module EZOut or https://github.com/StartAutomating/EZOut
3+
$myFile = $MyInvocation.MyCommand.ScriptBlock.File
4+
$myRoot = $myFile | Split-Path | Split-Path
5+
$myModuleName = $myFile | Split-Path | Split-Path | Split-Path -Leaf
6+
Push-Location $myRoot
7+
$formatting = @(
8+
# Add your own Write-FormatView here,
9+
# or put them in a Formatting or Views directory
10+
foreach ($potentialDirectory in 'Formatting','Views','Types') {
11+
Join-Path $myRoot $potentialDirectory |
12+
Get-ChildItem -ea ignore |
13+
Import-FormatView -FilePath {$_.Fullname}
14+
}
15+
)
16+
17+
$destinationRoot = $myRoot
18+
19+
if ($formatting) {
20+
$myFormatFilePath = Join-Path $destinationRoot "$myModuleName.format.ps1xml"
21+
# You can also output to multiple paths by passing a hashtable to -OutputPath.
22+
$formatting | Out-FormatData -Module $MyModuleName -OutputPath $myFormatFilePath
23+
}
24+
25+
$types = @(
26+
# Add your own Write-TypeView statements here
27+
# or declare them in the 'Types' directory
28+
Join-Path $myRoot Types |
29+
Get-Item -ea ignore |
30+
Import-TypeView
31+
32+
)
33+
34+
if ($types) {
35+
$myTypesFilePath = Join-Path $destinationRoot "$myModuleName.types.ps1xml"
36+
# You can also output to multiple paths by passing a hashtable to -OutputPath.
37+
$types | Out-TypeData -OutputPath $myTypesFilePath
38+
}
39+
Pop-Location

OpenGraph.ps.psm1

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
$commandsPath = Join-Path $PSScriptRoot Commands
2+
[include('*-*')]$commandsPath
3+
4+
$myModule = $MyInvocation.MyCommand.ScriptBlock.Module
5+
$ExecutionContext.SessionState.PSVariable.Set($myModule.Name, $myModule)
6+
$myModule.pstypenames.insert(0, $myModule.Name)
7+
8+
New-PSDrive -Name $MyModule.Name -PSProvider FileSystem -Scope Global -Root $PSScriptRoot -ErrorAction Ignore
9+
10+
if ($home) {
11+
$MyModuleProfileDirectory = Join-Path ([Environment]::GetFolderPath("LocalApplicationData")) $MyModule.Name
12+
if (-not (Test-Path $MyModuleProfileDirectory)) {
13+
$null = New-Item -ItemType Directory -Path $MyModuleProfileDirectory -Force
14+
}
15+
New-PSDrive -Name "My$($MyModule.Name)" -PSProvider FileSystem -Scope Global -Root $MyModuleProfileDirectory -ErrorAction Ignore
16+
}
17+
18+
# Set a script variable of this, set to the module
19+
# (so all scripts in this scope default to the correct `$this`)
20+
$script:this = $myModule
21+
22+
#region Custom
23+
#endregion Custom
24+
25+
Export-ModuleMember -Alias * -Function * -Variable $myModule.Name
26+

OpenGraph.psd1

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
@{
2+
RootModule = 'OpenGraph.psm1'
3+
ModuleVersion = '0.0.1'
4+
GUID = 'be4e4070-1ea6-4a2e-8b6a-c6b7755e5ace'
5+
Author = 'JamesBrundage'
6+
CompanyName = 'Start-Automating'
7+
Copyright = '(c) 2025 Start-Automating'
8+
Description = 'Get OpenGraph with PowerShell'
9+
FunctionsToExport = 'Get-OpenGraph'
10+
AliasesToExport = 'OpenGraph', 'ogp'
11+
TypesToProcess = 'OpenGraph.types.ps1xml'
12+
PrivateData = @{
13+
PSData = @{
14+
Tags = @('OpenGraph','SEO', 'Web','PowerShellWeb')
15+
ProjectURI = 'https://github.com/PowerShellWeb/OpenGraph'
16+
LicenseURI = 'https://github.com/PowerShellWeb/OpenGraph/blob/main/LICENSE'
17+
ReleaseNotes = @'
18+
19+
> Like It? [Star It](https://github.com/PowerShellWeb/OpenGraph)
20+
> Love It? [Support It](https://github.com/sponsors/StartAutomating)
21+
22+
Embed content from anywhere on the internet
23+
24+
## OpenGraph 0.0.1
25+
26+
* Initial Release of OpenGraph Module (#1)
27+
* `Get-OpenGraph` gets open graph information (#2)
28+
* OpenGraph objects can get `.HTML` (#8)
29+
'@
30+
}
31+
}
32+
}
33+

OpenGraph.psm1

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
$commandsPath = Join-Path $PSScriptRoot Commands
2+
:ToIncludeFiles foreach ($file in (Get-ChildItem -Path "$commandsPath" -Filter "*-*" -Recurse)) {
3+
if ($file.Extension -ne '.ps1') { continue } # Skip if the extension is not .ps1
4+
foreach ($exclusion in '\.[^\.]+\.ps1$') {
5+
if (-not $exclusion) { continue }
6+
if ($file.Name -match $exclusion) {
7+
continue ToIncludeFiles # Skip excluded files
8+
}
9+
}
10+
. $file.FullName
11+
}
12+
13+
$myModule = $MyInvocation.MyCommand.ScriptBlock.Module
14+
$ExecutionContext.SessionState.PSVariable.Set($myModule.Name, $myModule)
15+
$myModule.pstypenames.insert(0, $myModule.Name)
16+
17+
New-PSDrive -Name $MyModule.Name -PSProvider FileSystem -Scope Global -Root $PSScriptRoot -ErrorAction Ignore
18+
19+
if ($home) {
20+
$MyModuleProfileDirectory = Join-Path ([Environment]::GetFolderPath("LocalApplicationData")) $MyModule.Name
21+
if (-not (Test-Path $MyModuleProfileDirectory)) {
22+
$null = New-Item -ItemType Directory -Path $MyModuleProfileDirectory -Force
23+
}
24+
New-PSDrive -Name "My$($MyModule.Name)" -PSProvider FileSystem -Scope Global -Root $MyModuleProfileDirectory -ErrorAction Ignore
25+
}
26+
27+
# Set a script variable of this, set to the module
28+
# (so all scripts in this scope default to the correct `$this`)
29+
$script:this = $myModule
30+
31+
#region Custom
32+
#endregion Custom
33+
34+
Export-ModuleMember -Alias * -Function * -Variable $myModule.Name
35+
36+

OpenGraph.types.ps1xml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!-- Generated with EZOut 2.0.6: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
2+
<Types>
3+
<Type>
4+
<Name>OpenGraph</Name>
5+
<Members>
6+
<ScriptProperty>
7+
<Name>HTML</Name>
8+
<GetScriptBlock>
9+
@(if ($this -is [Management.Automation.PSModuleInfo]) {
10+
if ($this.Description) {
11+
"&lt;meta name='description' content='$([Web.HttpUtility]::HtmlAttributeEncode($this.Description))' /&gt;"
12+
}
13+
if ($this.Author) {
14+
"&lt;meta name='article:author' content='$([Web.HttpUtility]::HtmlAttributeEncode($this.Author))' /&gt;"
15+
}
16+
if ($this.PrivateData.PSData.IconUri) {
17+
"&lt;meta property='og:image' content='$([Web.HttpUtility]::HtmlAttributeEncode($this.PrivateData.PSData.IconUri))' /&gt;"
18+
}
19+
} else {
20+
foreach ($property in $this.PSObject.Properties) {
21+
if ($property.Name -match ':') {
22+
$value = $property.Value
23+
if ($value -is [DateTime]) {
24+
$value = $value.ToUniversalTime().ToString('o')
25+
}
26+
"&lt;meta property='$($property.Name)' content='$([Web.HttpUtility]::HtmlAttributeEncode($value))' /&gt;"
27+
}
28+
}
29+
}) -join [Environment]::Newline
30+
31+
</GetScriptBlock>
32+
</ScriptProperty>
33+
</Members>
34+
</Type>
35+
</Types>

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
# OpenGraph
2-
Get OpenGraph with PowerShell
2+
3+
[OpenGraph](https://ogp.me) is a protocol for embedding information in a page search optimization and social media.
4+
5+
The OpenGraph module lets you see this information for any page that has it.
6+
7+
~~~PowerShell
8+
Get-OpenGraph https://abc.com/
9+
~~~
10+

Types/OpenGraph/get_HTML.ps1

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@(if ($this -is [Management.Automation.PSModuleInfo]) {
2+
if ($this.Description) {
3+
"<meta name='description' content='$([Web.HttpUtility]::HtmlAttributeEncode($this.Description))' />"
4+
}
5+
if ($this.Author) {
6+
"<meta name='article:author' content='$([Web.HttpUtility]::HtmlAttributeEncode($this.Author))' />"
7+
}
8+
if ($this.PrivateData.PSData.IconUri) {
9+
"<meta property='og:image' content='$([Web.HttpUtility]::HtmlAttributeEncode($this.PrivateData.PSData.IconUri))' />"
10+
}
11+
} else {
12+
foreach ($property in $this.PSObject.Properties) {
13+
if ($property.Name -match ':') {
14+
$value = $property.Value
15+
if ($value -is [DateTime]) {
16+
$value = $value.ToUniversalTime().ToString('o')
17+
}
18+
"<meta property='$($property.Name)' content='$([Web.HttpUtility]::HtmlAttributeEncode($value))' />"
19+
}
20+
}
21+
}) -join [Environment]::Newline

0 commit comments

Comments
 (0)