From b609aec479a22e7bcccebee3b83b20e3a8bccf87 Mon Sep 17 00:00:00 2001 From: rulasg Date: Thu, 31 Jul 2025 08:49:06 +0200 Subject: [PATCH 1/4] feat: add New-NoteTodayMeeting function for meeting note creation --- public/newNotes.ps1 | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/public/newNotes.ps1 b/public/newNotes.ps1 index d8d440a..beb18de 100644 --- a/public/newNotes.ps1 +++ b/public/newNotes.ps1 @@ -133,6 +133,45 @@ function New-NoteTodayClient{ } Export-ModuleMember -Function New-NoteTodayClient -Alias cnote +function New-NoteTodayMeeting{ + [CmdletBinding()] + [alias("mnote")] + param( + [Parameter(Mandatory,Position = 0)][string] $Name, + [Parameter(Mandatory,Position = 1)][string] $Title, + [Parameter(Position = 2)][string] $Notes, + [Parameter(ValueFromPipeline)][string] $IssueUrl, + [Parameter()][switch] $NoOpen, + [Parameter()][switch] $Force + ) + + begin { + $category = "meetings" + $section = $Name + } + + process{ + + $folder = Get-NoteFolder -Category $category -Section $section -Force:$Force + + if (-not $folder) { + Write-Error "Client folder for '$section' does not exist and Force was not specified." + return + } + + New-NoteToday ` + -Category $category ` + -Section $section ` + -Title $Title ` + -Notes $Notes ` + -IssueUrl $IssueUrl ` + -Template "meetingmini" ` + -NoOpen:$NoOpen ` + -AvoidChildFolder # Add all the notes in the same client folder + } + +} Export-ModuleMember -Function New-NoteTodayMeeting -Alias mnote + function NewNoteToday{ # Add Force parameter to support creation of client folder if it doesn't exist [CmdletBinding()] From 3ad00e091c45a308eff7333671c5165557659072 Mon Sep 17 00:00:00 2001 From: rulasg Date: Wed, 6 Aug 2025 08:21:26 +0200 Subject: [PATCH 2/4] refactor: remove redundant New-NoteToday function implementation --- public/newNotes.ps1 | 77 +-------------------------------------------- 1 file changed, 1 insertion(+), 76 deletions(-) diff --git a/public/newNotes.ps1 b/public/newNotes.ps1 index beb18de..72ca6bf 100644 --- a/public/newNotes.ps1 +++ b/public/newNotes.ps1 @@ -170,79 +170,4 @@ function New-NoteTodayMeeting{ -AvoidChildFolder # Add all the notes in the same client folder } -} Export-ModuleMember -Function New-NoteTodayMeeting -Alias mnote - -function NewNoteToday{ - # Add Force parameter to support creation of client folder if it doesn't exist - [CmdletBinding()] - [alias("note")] - param( - [Parameter(Mandatory)][string] $Category, - [Parameter(Mandatory)][string] $Section, - [Parameter(Mandatory)][string] $Title, - [Parameter()][string] $Notes, - [Parameter()][string] $IssueUrl, - [Parameter()][string] [ValidateSet("none","meetingmini")] $Template = "none", - [Parameter()][switch] $NoOpen, - [Parameter()][switch] $AvoidChildFolder, - [Parameter()][switch] $Force - ) - - # FILENAME - - $folder = Get-NoteFolder -Category $Category -Section $Section -Force:$Force - - # Extract just the folder name from the path - $today = Get-Date -Format "yyMMdd" - - # Create FullTitle using folder name and title, replacing spaces with underscores - $fullTitle = "{0}-{1}-{2}" -f $today, $category, $Title - - # Normilize fullTitle by removing special characters and replacing spaces with underscores - $fullTitle = $fullTitle -replace '\s+', '_' - - if($AvoidChildFolder){ - # use folder as the parent folder of the note - $fullPath = Join-Path -Path $folder -ChildPath "$fullTitle.md" - } else { - # Create full path for the note file - $fullPath = Join-Path -Path $folder -ChildPath $fullTitle | Join-Path -ChildPath "$fullTitle.md" - } - - # Check if file already exists - if (-Not (Test-Path -Path $fullPath)) { - - # Get template content - $content = Get-TemplatePath $Template | Get-FileContent - - # Replace placeholders in the template with actual values - $content = $content -replace '{title}' , $Title - $content = $content -replace '{categoryname}', $category - $content = $content -replace '{date}' , $today - $content = $content -replace '{notes}' , ([string]::IsNullOrWhiteSpace($Notes) ? '-' : $Notes) - $content = $content -replace '{issueurl}' , ([string]::IsNullOrWhiteSpace($IssueUrl) ? '' : $IssueUrl) - - - # If $Force check that the folders of $fullPath exists and if not create it - if ($Force) { - $parentFolder = Split-Path -Path $fullPath -Parent - if (-Not (Test-Path -Path $parentFolder)) { - New-Item -Path $parentFolder -ItemType Directory -Force | Out-Null - Write-Verbose "Created folder: $parentFolder" - } - } - - # Create the file with content - Set-Content -Path $fullPath -Value $content -Force - } - - if( -not $NoOpen) { - # Open file in VS Code with cursor at the end - $gotocmd = "{0}{1}" -f $fullPath, ":9999" - code --goto $gotocmd - } - - # Return file just created - return $fullPath - -} \ No newline at end of file +} Export-ModuleMember -Function New-NoteTodayMeeting -Alias mnote \ No newline at end of file From 4161ecaeb36e1b0e7cfea0108215b3e7c706a236 Mon Sep 17 00:00:00 2001 From: rulasg Date: Wed, 6 Aug 2025 08:26:39 +0200 Subject: [PATCH 3/4] refactor: rename titleHeader to header for consistency in note templates --- public/newNotes.ps1 | 6 +++--- public/notes/templates/meetingmini.template.md | 2 +- public/notes/templates/none.template.md | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/public/newNotes.ps1 b/public/newNotes.ps1 index 72ca6bf..34094af 100644 --- a/public/newNotes.ps1 +++ b/public/newNotes.ps1 @@ -31,10 +31,10 @@ function New-NoteToday{ # Extract just the folder name from the path $today = Get-Date -Format "yyMMdd" - $titleHeader = [string]::IsNullOrWhiteSpace($Section) ? $Category : $Section + $header = [string]::IsNullOrWhiteSpace($Section) ? $Category : $Section # Create FullTitle using folder name and title, replacing spaces with underscores - $fullTitle = "{0}-{1}-{2}" -f $today, $titleHeader, $Title + $fullTitle = "{0}-{1}-{2}" -f $today, $header, $Title # Normilize fullTitle by removing special characters and replacing spaces with underscores $fullTitle = $fullTitle -replace '\s+', '_' @@ -64,7 +64,7 @@ function New-NoteToday{ # Replace placeholders in the template with actual values $content = $content -replace '{title}' , $Title - $content = $content -replace '{categoryname}', $category + $content = $content -replace '{header}' , $header $content = $content -replace '{date}' , $today $content = $content -replace '{notes}' , ([string]::IsNullOrWhiteSpace($Notes) ? '-' : $Notes) $content = $content -replace '{issueurl}' , ([string]::IsNullOrWhiteSpace($IssueUrl) ? '' : $IssueUrl) diff --git a/public/notes/templates/meetingmini.template.md b/public/notes/templates/meetingmini.template.md index bc29e8c..ec376e7 100644 --- a/public/notes/templates/meetingmini.template.md +++ b/public/notes/templates/meetingmini.template.md @@ -1,4 +1,4 @@ -# {categoryname} - {title} ({date}) +# {header} - {title} ({date}) > {issueurl} diff --git a/public/notes/templates/none.template.md b/public/notes/templates/none.template.md index 6ef3db6..27e88b1 100644 --- a/public/notes/templates/none.template.md +++ b/public/notes/templates/none.template.md @@ -1,4 +1,4 @@ -# {categoryname} - {title} ({date}) +# {header} - {title} ({date}) > {issueurl} From 794632de971a01aeba376653a513a604e270cf8e Mon Sep 17 00:00:00 2001 From: rulasg Date: Wed, 6 Aug 2025 08:26:56 +0200 Subject: [PATCH 4/4] fix (test): update header format to include client name in note creation tests --- Test/public/newNotes.test.ps1 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Test/public/newNotes.test.ps1 b/Test/public/newNotes.test.ps1 index 4ec4b0d..b36d4c8 100644 --- a/Test/public/newNotes.test.ps1 +++ b/Test/public/newNotes.test.ps1 @@ -107,13 +107,14 @@ function Test_AddNotesToday_Client_Simple{ MockCallToString 'Invoke-NotesHelperNotesRoot' -OutString "./TestNotesRoot" $category = "Clients" + $clientName = "TestClientName" $title = "This is the title of the note" $date = (Get-Date).ToString("yyMMdd") $clientName = "TestClientName" - $header = "# {category} - {title} ({date})" - $header = $header -replace "{category}", $category + $header = "# {header} - {title} ({date})" + $header = $header -replace "{header}", $clientName $header = $header -replace "{title}", $title $header = $header -replace "{date}", $date