Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions PSHTML/Functions/Public/Install-PSHTMLVSCodeSnippets.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function Install-PSHTMLVSCodeSnippets {
<#
.SYNOPSIS
Copy the PSHTML VSCode Snippets to the right location
.DESCRIPTION
Gets the PSHTML VSCode snippet files and copies them to users appdata folder
.NOTES
Current version 0.1
History:
2018.10.16;FishFenly;Creation.
#>

$callstack = Get-PSCallStack | Select-Object -ExpandProperty scriptname

$path = Split-path -path (
Split-path -Path (
Split-Path -path $callstack -Parent) -Parent) -Parent

$snippetsfolder = join-path $path -ChildPath "Snippets"


foreach ($snippet in (Get-Item $snippetsfolder\*.code-snippets | Select-Object -ExpandProperty FullName)) {
Write-Verbose "Copying $snippet to $($env:APPDATA)\Code\User\snippets"
Copy-Item -Path $snippet `
-Destination "$($env:APPDATA)\Code\User\snippets" -Force
}
}
57 changes: 57 additions & 0 deletions PSHTML/Snippets/PsHtml_BoilerPlate_full.Snippet.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"PsHtml_full": {
"prefix": "pshtml",
"body": [
"# The following example called 'tribute to Snover' grasps information for the 'shellfather' from around the internet, and generates a html page with the information.",
"html {",
"\thead {",
"\t\ttitle 'Tribute to snover'",
"\t\tlink -href 'mystylesheet' -rel 'stylesheet'",
"\t}",
"\tbody {",
"\t\th1 'Tribute to Jeffery Snover' -class 'Title'",
"\t\tdiv -class 'Photo' {",
"\t\t\timg -src 'https://pbs.twimg.com/profile_images/618804166631145473/2q6yharL_400x400.jpg' -alt 'Jeffrey Snover photo' -height '400' -width '400' -Class 'Photo'",
"\t\t}",
"\t\tdiv -id 'Bio' {",
"\t\t\t$wikirootsite = 'https://en.wikipedia.org'",
"\t\t\t$source = a {'Wikipedia'} -href $wikirootsite",
"\t\t\th2 'Biography'",
"\t\t\th4 'Source -->' $source",
"\t\t\t$wiki = Invoke-WebRequest -Uri ($wikirootsite + '/wiki/Jeffrey_Snover')",
"\t\t\t$output = $wiki.ParsedHtml.getElementById('mw-content-text').children | Where-Object -FilterScript {$_.ClassName -eq 'mw-parser-output'}",
"\t\t\t$bio = $output.Children | Where-Object -FilterScript {$_.TagName -eq 'p'} | Select-Object -Property Tagname,InnerHtml",
"\t\t\tforeach ($p in $bio) {",
"\t\t\t\tif($p.InnerHtml -ne $null) {",
"\t\t\t\t\t$corrected = $p.innerHTML.Replace('/wiki/','$wikirootsite/wiki/')",
"\t\t\t\t\tp {",
"\t\t\t\t\t\t$corrected",
"\t\t\t\t\t}",
"\t\t\t\t}",
"\t\t\t}",
"\t\t}",
"\t\tdiv -id 'Snoverisms' {",
"\t\t\t$snoverismssite = 'http://snoverisms.com/'",
"\t\t\th2 'Snoverisms'",
"\t\t\th4 'Source --> $snoverismssite'",
"\t\t\t$Page = Invoke-WebRequest -Uri $SnoverismsSite",
"\t\t\t$Snoverisms = $Page.ParsedHtml.getElementsByTagName('p') | Where-Object -FilterScript {$_.ClassName -ne 'site-description'} | Select-Object -Property innerhtml",
"\t\t\t$Snoverisms += (Invoke-WebRequest -uri 'http://snoverisms.com/page/2/').ParsedHtml.getElementsByTagName('p') | Where-Object -FilterScript {$_.ClassName -ne 'site-description'} | Select-Object -Property innerhtml",
"\t\t\tul -id 'snoverism-list' -Content {",
"\t\t\t\tForeach ($snov in $Snoverisms) {",
"\t\t\t\t\tli -Class 'snoverism' -content {",
"\t\t\t\t\t\t$snov.innerHTML",
"\t\t\t\t\t}",
"\t\t\t\t}",
"\t\t\t}",
"\t\t}",
"\t\tfooter {",
"\t\t\t$PSHTMLlink = a {'PSHTML'} -href 'https://github.com/Stephanevg/PSHTML'",
"\t\t\th6 'Generated with' + $PSHTMLlink",
"\t\t}",
"\t}",
"}"
],
"description": "PsHtml Full Snippet"
}
}
57 changes: 57 additions & 0 deletions PSHTML/Snippets/PsHtml_BoilerPlate_medium.Snippet.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
"PsHtml_medium": {
"prefix": "pshtml",
"body": [
"html {",
"\thead {",
"\t\ttitle 'woop title'",
"\t\tlink -href 'assets/home.css' -rel 'stylesheet'",
"\t}",
"\tbody {",
"\t\tHeader {",
"\t\t\timg 'https://i0.wp.com/powershelldistrict.com/wp-content/uploads/2016/01/logo_pd_quadri.png' 'logo powershell' -height 100 -width 400",
"\t\t\th1 'This is a h1 Title in a header'",
"\t\t\tdiv {",
"\t\t\t\tp {",
"\t\t\t\t\t'This is a paragraph in a div'",
"\t\t\t\t}",
"\t\t\t}",
"\t\t}",
"\t\ttable {",
"\t\t\tcaption 'A table generated with PSHTML'",
"\t\t\tthead {",
"\t\t\t\ttr {",
"\t\t\t\t\tth 'head 1'",
"\t\t\t\t\tth 'head 2'",
"\t\t\t\t\tth 'head 3'",
"\t\t\t\t}",
"\t\t\t}",
"\t\t\ttbody {",
"\t\t\t\ttr {",
"\t\t\t\t\ttd 'row 1.1'",
"\t\t\t\t\tth 'row 2.1'",
"\t\t\t\t\tth 'row 3.1'",
"\t\t\t\t}",
"\t\t\t\ttr {",
"\t\t\t\t\ttd 'row 1.2'",
"\t\t\t\t\tth 'row 2.2'",
"\t\t\t\t\tth 'row 3.2'",
"\t\t\t\t}",
"\t\t\t}",
"\t\t\ttfoot {",
"\t\t\t\ttr {",
"\t\t\t\t\ttd 'Table footer'",
"\t\t\t\t}",
"\t\t\t}",
"\t\t\tdiv {",
"\t\t\t\ta {",
"\t\t\t\t\t'This points to PowershellDistrict'",
"\t\t\t\t} -href 'http://powershellDistrict.com'",
"\t\t\t}",
"\t\t}",
"\t}",
"}"
],
"description": "PsHtml Medium Snippet"
}
}
17 changes: 17 additions & 0 deletions PSHTML/Snippets/PsHtml_BoilerPlate_small.Snippet.code-snippets
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"PsHtml_small": {
"prefix": "pshtml",
"body": [
"html {",
"\thead {",
"\t\ttitle 'iPortal Home Page'",
"\t\tlink -href 'assets/home.css' -rel 'stylesheet'",
"\t}",
"\tbody {",
"\t\t h1 'iPortal'",
"\t}",
"}"
],
"description": "PsHtml Small Snippet"
}
}
13 changes: 13 additions & 0 deletions Tests/Install-PSHTMLVSCodeSnippets.tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Describe "VSCode Snippets store with PSHTML Snippets" {
Context "Testing PSHTML Snippets exist" {
It "has the Small snippet" {
Test-Path "$($env:APPDATA)\Code\User\snippets\PsHtml_BoilerPlate_small.Snippet.code-snippets" | Should Be $true
}
It "has the Medium snippet" {
Test-Path "$($env:APPDATA)\Code\User\snippets\PsHtml_BoilerPlate_small.Snippet.code-snippets" | Should Be $true
}
It "has the Full snippet" {
Test-Path "$($env:APPDATA)\Code\User\snippets\PsHtml_BoilerPlate_small.Snippet.code-snippets" | Should Be $true
}
}
}