From 897abf926fd33b011eff7c00cf4677cd6d6349c3 Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Thu, 1 May 2025 20:51:16 -0700 Subject: [PATCH 1/5] feat: `OpenGraph.ToString()` ( Fixes #10 ) --- Types/OpenGraph/ToString.ps1 | 1 + 1 file changed, 1 insertion(+) create mode 100644 Types/OpenGraph/ToString.ps1 diff --git a/Types/OpenGraph/ToString.ps1 b/Types/OpenGraph/ToString.ps1 new file mode 100644 index 0000000..3e4d43a --- /dev/null +++ b/Types/OpenGraph/ToString.ps1 @@ -0,0 +1 @@ +$this.HTML \ No newline at end of file From dc83fb6bbca195b863335ae385cc55a8911d3518 Mon Sep 17 00:00:00 2001 From: StartAutomating Date: Fri, 2 May 2025 03:52:46 +0000 Subject: [PATCH 2/5] feat: `OpenGraph.ToString()` ( Fixes #10 ) --- OpenGraph.types.ps1xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OpenGraph.types.ps1xml b/OpenGraph.types.ps1xml index e3f8c5c..2297999 100644 --- a/OpenGraph.types.ps1xml +++ b/OpenGraph.types.ps1xml @@ -3,6 +3,12 @@ OpenGraph + + ToString + + HTML From 0d1ae669212f09298cd5a3e72490f5a2c340e16a Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Mon, 16 Jun 2025 19:05:46 -0700 Subject: [PATCH 3/5] feat: Get-OpenGraph caching ( Fixes #11 ) --- Commands/Get-OpenGraph.ps1 | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Commands/Get-OpenGraph.ps1 b/Commands/Get-OpenGraph.ps1 index db226bc..111a52f 100644 --- a/Commands/Get-OpenGraph.ps1 +++ b/Commands/Get-OpenGraph.ps1 @@ -17,30 +17,42 @@ function Get-OpenGraph 'https://cnn.com/', 'https://msnbc.com/', 'https://fox.com/' | - Get-OpenGraph + Get-OpenGraph #> [Alias('openGraph','ogp')] - param( + [CmdletBinding(PositionalBinding=$false)] + param( # The URL that may contain Open Graph metadata - [Parameter(ValueFromPipeline, ValueFromPipelineByPropertyName)] + [Parameter(ValueFromPipelineByPropertyName)] [Uri] $Url, # A dictionary of additional Open Graph metadata to include in the result [Parameter(ValueFromPipelineByPropertyName)] [Collections.IDictionary] - $Data + $Data, + + # If set, forces the function to retrieve the Open Graph metadata even if it is already cached. + [Parameter(ValueFromPipelineByPropertyName)] + [switch] + $Force ) begin { # Make a regex to match meta tags $metaRegex = [Regex]::new('','IgnoreCase','00:00:00.1') + if (-not $script:OpenGraphCache) { + $script:OpenGraphCache = [Ordered]@{} + } } process { # Declare an empty object to hold the Open Graph metadata $openGraphMetadata = [Ordered]@{PSTypeName='OpenGraph'} if ($Url) { + if ($script:OpenGraphCache[$url] -and -not $Force) { + return $script:OpenGraphCache[$url] + } $restResponse = Invoke-RestMethod -Uri $Url foreach ($match in $metaRegex.Matches("$restResponse")) { $matchXml = "$match" -as [xml] @@ -48,6 +60,7 @@ function Get-OpenGraph $openGraphMetadata[$matchXml.meta.property] = $matchXml.meta.content } } + $script:OpenGraphCache[$url] = $openGraphMetadata } if ($Data) { foreach ($key in $Data.Keys) { @@ -55,7 +68,7 @@ function Get-OpenGraph } } - if (-not $openGraphMetadata.Count) { return } + if (-not $openGraphMetadata.Count) { return } [PSCustomObject]$openGraphMetadata } From 7a954e41f711fd6ffebf2a24df791cacfd96ea77 Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Tue, 17 Jun 2025 19:06:55 -0700 Subject: [PATCH 4/5] release: OpenGraph 0.1 Adding CHANGELOG and updating module version and release notes --- CHANGELOG.md | 5 +++++ OpenGraph.psd1 | 14 +++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..8720e84 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +## OpenGraph 0.0.1 + +* Initial Release of OpenGraph Module (#1) + * `Get-OpenGraph` gets open graph information (#2) + * OpenGraph objects can get `.HTML` (#8) diff --git a/OpenGraph.psd1 b/OpenGraph.psd1 index e1e7bea..0664cc5 100644 --- a/OpenGraph.psd1 +++ b/OpenGraph.psd1 @@ -11,21 +11,21 @@ TypesToProcess = 'OpenGraph.types.ps1xml' PrivateData = @{ PSData = @{ - Tags = @('OpenGraph','SEO', 'Web','PowerShellWeb') + Tags = @('OpenGraph','SEO','Web','PowerShellWeb' ) ProjectURI = 'https://github.com/PowerShellWeb/OpenGraph' LicenseURI = 'https://github.com/PowerShellWeb/OpenGraph/blob/main/LICENSE' ReleaseNotes = @' - > Like It? [Star It](https://github.com/PowerShellWeb/OpenGraph) > Love It? [Support It](https://github.com/sponsors/StartAutomating) -Embed content from anywhere on the internet +## OpenGraph 0.1 + +* `OpenGraph.ToString()` now returns HTML (#10) +* `Get-OpenGraph` now caches results (#11) -## OpenGraph 0.0.1 +--- -* Initial Release of OpenGraph Module (#1) - * `Get-OpenGraph` gets open graph information (#2) - * OpenGraph objects can get `.HTML` (#8) +Additional release notes can be found at [CHANGELOG.md](https://github.com/PowerShellWeb/OpenGraph/blob/main/CHANGELOG.md) '@ } } From f33a9e27103f75fb355ff4aa3bb1a8d09672f0da Mon Sep 17 00:00:00 2001 From: James Brundage <+@noreply.github.com> Date: Fri, 20 Jun 2025 15:07:12 -0700 Subject: [PATCH 5/5] release: OpenGraph 0.1 Updating module version --- OpenGraph.psd1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OpenGraph.psd1 b/OpenGraph.psd1 index 0664cc5..ff3ec4b 100644 --- a/OpenGraph.psd1 +++ b/OpenGraph.psd1 @@ -1,6 +1,6 @@ @{ RootModule = 'OpenGraph.psm1' - ModuleVersion = '0.0.1' + ModuleVersion = '0.1' GUID = 'be4e4070-1ea6-4a2e-8b6a-c6b7755e5ace' Author = 'JamesBrundage' CompanyName = 'Start-Automating'