Skip to content

Commit

Permalink
Merge pull request #469 from webmaster442/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
webmaster442 authored Aug 5, 2024
2 parents c4cc310 + e057ead commit aa6eda1
Show file tree
Hide file tree
Showing 107 changed files with 6,081 additions and 715 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ csharp_style_prefer_local_over_anonymous_function = true:suggestion
csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion
csharp_style_prefer_tuple_swap = true:suggestion
csharp_style_prefer_utf8_string_literals = true:suggestion
csharp_style_prefer_primary_constructors = true:suggestion

#### Naming styles ####
[*.{cs,vb}]
Expand Down Expand Up @@ -373,4 +374,5 @@ tab_width = 4
indent_size = 4
end_of_line = crlf
dotnet_style_namespace_match_folder = true:suggestion
dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion

2 changes: 1 addition & 1 deletion .github/releases.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
👁‍🗨 Change: Removed ZIP format release
👁‍🗨 Change: Folder locking is now process based
👁‍🗨 Change: Improved stat command
👁‍🗨 Change: HTTP server has favicons & last acces time is sent in header
👁‍🗨 Change: HTTP server has favicons & last acces time is sent in header
👁‍🗨 Change: Replaces File based folder locking wiht a process based one
👁‍🗨 Change: Auto updater removed, because of multiple platform issues
👁‍🗨 Change: Launcher file browser usability improvements
Expand Down
7 changes: 7 additions & 0 deletions BookGen.sln
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookGen.Settings", "Libs\Bo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookGen.RenderEngine", "Libs\BookGen.RenderEngine\BookGen.RenderEngine.csproj", "{4E7C4D96-32DD-4E72-8B28-F4DCDB74E177}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookGen.FormulaEdit", "Prog\BookGen.FormulaEdit\BookGen.FormulaEdit.csproj", "{C03D39B0-697B-4A51-AEF8-BFE094A45F4F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -138,6 +140,10 @@ Global
{4E7C4D96-32DD-4E72-8B28-F4DCDB74E177}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E7C4D96-32DD-4E72-8B28-F4DCDB74E177}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E7C4D96-32DD-4E72-8B28-F4DCDB74E177}.Release|Any CPU.Build.0 = Release|Any CPU
{C03D39B0-697B-4A51-AEF8-BFE094A45F4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C03D39B0-697B-4A51-AEF8-BFE094A45F4F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C03D39B0-697B-4A51-AEF8-BFE094A45F4F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C03D39B0-697B-4A51-AEF8-BFE094A45F4F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -161,6 +167,7 @@ Global
{985728E4-6353-44A1-87BB-77BF366A5977} = {05B69A0E-343B-4E7C-B77B-24E84B57D5D2}
{B1905B26-0649-4911-BA5F-9781BBC3D3E2} = {9C47BBFF-ACD8-40D8-9FB1-A3FA524B27C4}
{4E7C4D96-32DD-4E72-8B28-F4DCDB74E177} = {9C47BBFF-ACD8-40D8-9FB1-A3FA524B27C4}
{C03D39B0-697B-4A51-AEF8-BFE094A45F4F} = {05B69A0E-343B-4E7C-B77B-24E84B57D5D2}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {772515BA-79D4-4C5D-AF16-29DE649EC13E}
Expand Down
146 changes: 140 additions & 6 deletions BookGenShell.ps1
Original file line number Diff line number Diff line change
@@ -1,9 +1,112 @@
# -----------------------------------------------------------------------------
# BookGen PowerShell Registration script
# Version 2.9.0
# Last modified: 2024-05-20
# Version 3.0
# Last modified: 2024-07-21
# -----------------------------------------------------------------------------

# NodeJS install test
function Test-NodeJs
{
try
{
# Try to get the node version
$nodeVersion = node --version
if ($nodeVersion)
{
return $true
}
}
catch
{
return $false
}
}

# Node commands

function Get-NodePath
{
try
{
$nodePath = (Get-Command node.exe -ErrorAction Stop).Source
$nodeDir = Split-Path $nodePath
return $nodeDir
}
catch
{
Write-Error "node.exe not found in the system PATH."
}
}

function npm {
param (
[string[]]$Args
)

$scriptPath = Get-NodePath
$nodeExe = Join-Path $scriptPath "node.exe"

if (-Not (Test-Path $nodeExe))
{
$nodeExe = "node"
}

$npmPrefixJs = Join-Path $scriptPath "node_modules/npm/bin/npm-prefix.js"
$npmCliJs = Join-Path $scriptPath "node_modules/npm/bin/npm-cli.js"

$npmPrefixNpmCliJs = & $nodeExe $npmPrefixJs
$npmPrefixNpmCliJsPath = Join-Path $npmPrefixNpmCliJs "node_modules/npm/bin/npm-cli.js"

if (Test-Path $npmPrefixNpmCliJsPath)
{
$npmCliJs = $npmPrefixNpmCliJsPath
}

& $nodeExe $npmCliJs @Args
}

function npx {
param (
[string[]]$Args
)

$scriptPath = Get-NodePath
$nodeExe = Join-Path $scriptPath "node.exe"

if (-Not (Test-Path $nodeExe)) {
$nodeExe = "node"
}

$npmPrefixJs = Join-Path $scriptPath "node_modules/npm/bin/npm-prefix.js"
$npxCliJs = Join-Path $scriptPath "node_modules/npm/bin/npx-cli.js"

$npmPrefixNpxCliJsPath = & $nodeExe $npmPrefixJs
$npmPrefixNpxCliJs = Join-Path $npmPrefixNpxCliJsPath "node_modules/npm/bin/npx-cli.js"

if (Test-Path $npmPrefixNpxCliJs) {
$npxCliJs = $npmPrefixNpxCliJs
}

& $nodeExe $npxCliJs @Args
}

function corepack {
param (
[string[]]$Args
)

$scriptPath = Get-NodePath
$nodeExe = Join-Path $scriptPath "node.exe"
$corepackJs = Join-Path $scriptPath "node_modules/corepack/dist/corepack.js"

if (Test-Path $nodeExe) {
& $nodeExe $corepackJs @Args
} else {
$env:PATHEXT = $env:PATHEXT -replace ";.JS;", ";"
& node $corepackJs @Args
}
}

# cdg command
function cdg
{
Expand Down Expand Up @@ -80,14 +183,22 @@ function intro()
Write-Host " .( o )."

Bookgen.exe terminalinstall -t
if ($LastExitCode -eq 0) {
if ($LastExitCode -eq 0)
{
Bookgen.exe terminalinstall -c
if ($LastExitCode -ne 0) {
if ($LastExitCode -ne 0)
{
Write-Host ""
Write-Host "To install this shell as a windows terminal profile run:";
Write-Host "Bookgen terminalinstall"
}
}
}

if (Test-NodeJs)
{
$nodeVersion = node --version
Write-Host "Node version: $nodeVersion"
}
}

#Set UTF8 encoding
Expand All @@ -100,6 +211,24 @@ $env:BookGenPath = $PSScriptRoot
# register scripts folder to the path
$env:Path += ";$PSScriptRoot"

if (-not (Test-NodeJs)) {
#check if it's bundled
$nodeDirs = Get-ChildItem -Path $PSScriptRoot -Directory | Where-Object { $_.Name -like "node-*" }
foreach ($dir in $nodeDirs)
{
$nodePath = Join-Path -Path $dir.FullName -ChildPath "node.exe"
if (Test-Path -Path $nodePath)
{
$env:NodeJsDir = "$($dir.FullName)"
$env:NodeExe = $nodePath

$env:Path += ";$($dir.FullName)"
Write-Host "Added $($dir.FullName) to PATH."
break
}
}
}

# set colors
Set-PSReadLineOption -Colors @{
Parameter = 'Red'
Expand Down Expand Up @@ -141,7 +270,12 @@ Register-ArgumentCompleter -Native -CommandName git -ScriptBlock {
# set prompt
function prompt {
$git = $(BookGen.Shell.exe "prompt" $(Get-Location).Path)
'PS ' + $(Get-Location) + ' '+$git+ $(if ($NestedPromptLevel -ge 1) { '>>' }) + ' > '
if (-not [string]::IsNullOrWhiteSpace($git)) {
'PS ' + $(Get-Location) + "`n"+$git+ $(if ($NestedPromptLevel -ge 1) { '>>' }) + ' > '
}
else {
'PS ' + $(Get-Location) + $(if ($NestedPromptLevel -ge 1) { '>>' }) + ' > '
}
}


Expand Down
16 changes: 16 additions & 0 deletions Bootstrappers/BookGen.FormulaEdit/BookGen.FormulaEdit.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net4.8</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<OutputPath>..\..\bin\bootstaper\$(Configuration)\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ApplicationIcon>..\..\Branding\icon-formulaedit.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Bookgen.Win\Bookgen.Win.csproj" />
</ItemGroup>

</Project>
34 changes: 34 additions & 0 deletions Bootstrappers/BookGen.FormulaEdit/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
//-----------------------------------------------------------------------------
// (c) 2023 Ruzsinszki Gábor
// This code is licensed under MIT license (see LICENSE for details)
//-----------------------------------------------------------------------------

using Bookgen.Win;

namespace BookGen.Launcher
{
public static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
public static void Main(string[] args)
{
ExceptionHandler.Try(() =>
{
InstallVerify.ThrowIfNotExist();
using (var process =
new ProcessBuilder()
.SetProgram(AppDomain.CurrentDomain.BaseDirectory, Constants.DataFolder, Constants.BookGenFormulaEditor)
.SetWorkDir(AppDomain.CurrentDomain.BaseDirectory, Constants.DataFolder)
.SetArguments(args)
.Build())
{
process.Start();
}
});
}
}
}
2 changes: 1 addition & 1 deletion Bootstrappers/BookGen.Launcher/BookGen.Launcher.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<UseWindowsForms>true</UseWindowsForms>
<OutputPath>..\..\bin\bootstaper\$(Configuration)\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ApplicationIcon>..\..\Icon.ico</ApplicationIcon>
<ApplicationIcon>..\..\Branding\icon-laucher.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Bootstrappers/BookGen/BookGen.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<UseWindowsForms>true</UseWindowsForms>
<OutputPath>..\..\bin\bootstaper\$(Configuration)\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<ApplicationIcon>..\..\Icon.ico</ApplicationIcon>
<ApplicationIcon>..\..\Branding\icon-bookgen.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions Bootstrappers/Bookgen.Win/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public static class Constants
{
public const string BookGen = "BookGen.exe";
public const string BookGenLauncher = "BookGen.Launcher.exe";
public const string BookGenFormulaEditor = "BookGen.FormulaEdit.exe";
public const string DataFolder = "Data";
public const string WindowsTerminal = "wt.exe";
public const string PowershellCore = "pwsh.exe";
Expand Down
2 changes: 0 additions & 2 deletions Bootstrappers/Bookgen.Win/ProcessBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
using System.IO;
using System.Linq;

using Bookgen.Win.Properties;

namespace Bookgen.Win
{
public sealed class ProcessBuilder
Expand Down
2 changes: 1 addition & 1 deletion Bootstrappers/Bookgen.Win/Try.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public static void Try(Action action)
catch (Exception ex)
{
#if DEBUG
Debug.WriteLine(ex);
Trace.TraceError(ex.Message);
#endif
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Expand Down
6 changes: 6 additions & 0 deletions Bootstrappers/Bootstrappers.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookGen.Launcher", "BookGen
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bookgen.Win", "Bookgen.Win\Bookgen.Win.csproj", "{9832DC6D-3F44-4221-BB59-2FF64D650C56}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookGen.FormulaEdit", "BookGen.FormulaEdit\BookGen.FormulaEdit.csproj", "{9C1A7AB7-8703-4CAD-8A7E-13A753F25778}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -27,6 +29,10 @@ Global
{9832DC6D-3F44-4221-BB59-2FF64D650C56}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9832DC6D-3F44-4221-BB59-2FF64D650C56}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9832DC6D-3F44-4221-BB59-2FF64D650C56}.Release|Any CPU.Build.0 = Release|Any CPU
{9C1A7AB7-8703-4CAD-8A7E-13A753F25778}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9C1A7AB7-8703-4CAD-8A7E-13A753F25778}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C1A7AB7-8703-4CAD-8A7E-13A753F25778}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9C1A7AB7-8703-4CAD-8A7E-13A753F25778}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
8 changes: 8 additions & 0 deletions Branding/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
icon-laucher.ico filter=lfs diff=lfs merge=lfs -text
icon-shell.ico filter=lfs diff=lfs merge=lfs -text
icon-bookgen.ico filter=lfs diff=lfs merge=lfs -text
icon-formulaedit.ico filter=lfs diff=lfs merge=lfs -text
icon-bookgen.png filter=lfs diff=lfs merge=lfs -text
icon-formulaedit.png filter=lfs diff=lfs merge=lfs -text
icon-launcher.png filter=lfs diff=lfs merge=lfs -text
icon-shell.png filter=lfs diff=lfs merge=lfs -text
Binary file added Branding/background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit aa6eda1

Please sign in to comment.