Inner links

This commit is contained in:
Mike Phares 2025-02-02 14:12:21 -07:00
parent 3c4e465084
commit c64143f320
3 changed files with 49 additions and 21 deletions

2
.gitignore vendored
View File

@ -335,3 +335,5 @@ ASALocalRun/
.vscode/.UserSecrets/secrets.json .vscode/.UserSecrets/secrets.json
.vscode/jsonl/* .vscode/jsonl/*
.vscode/.year-season-source
.vscode/.year-season-destination

31
.vscode/tasks.json vendored
View File

@ -89,8 +89,8 @@
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
}, },
{ {
"label": "dockerLogin", "label": "podmanLogin",
"command": "docker", "command": "podman",
"type": "process", "type": "process",
"args": [ "args": [
"login", "login",
@ -99,19 +99,20 @@
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
}, },
{ {
"label": "dockerBuild", "label": "podmanBuild",
"command": "docker", "command": "podman",
"type": "process", "type": "process",
"args": [ "args": [
"build", "build",
"-t", "-t",
"kanbn-to-quartz" "kanbn-to-quartz",
"."
], ],
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
}, },
{ {
"label": "dockerImageList", "label": "podmanImageList",
"command": "docker", "command": "podman",
"type": "process", "type": "process",
"args": [ "args": [
"image", "image",
@ -120,8 +121,8 @@
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
}, },
{ {
"label": "dockerRun", "label": "podmanRun",
"command": "docker", "command": "podman",
"type": "process", "type": "process",
"args": [ "args": [
"run", "run",
@ -129,24 +130,24 @@
"5001:5001", "5001:5001",
"--name", "--name",
"kanbn-to-quartz-api-001", "kanbn-to-quartz-api-001",
"cb5bbb2e84e7" "a3de856b5731"
], ],
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
}, },
{ {
"label": "dockerTag", "label": "podmanTag",
"command": "docker", "command": "podman",
"type": "process", "type": "process",
"args": [ "args": [
"tag", "tag",
"b84c1f73de01", "a3de856b5731",
"gitea.phares.duckdns.org:443/phares3757/kanbn-to-quartz:latest" "gitea.phares.duckdns.org:443/phares3757/kanbn-to-quartz:latest"
], ],
"problemMatcher": "$msCompile" "problemMatcher": "$msCompile"
}, },
{ {
"label": "dockerPush", "label": "podmanPush",
"command": "docker", "command": "podman",
"type": "process", "type": "process",
"args": [ "args": [
"push", "push",

View File

@ -19,6 +19,8 @@ public class CopyService
string path; string path;
string fileB; string fileB;
string pathB; string pathB;
string pathC;
string pathD;
string textB; string textB;
string? text; string? text;
Record record; Record record;
@ -26,6 +28,7 @@ public class CopyService
string[] lines; string[] lines;
string pathName; string pathName;
string directory; string directory;
string[] segments;
string destination; string destination;
string relativePath; string relativePath;
string directoryName; string directoryName;
@ -55,13 +58,33 @@ public class CopyService
relativeDirectory = Path.GetRelativePath(sourceDirectoryName, directoryName); relativeDirectory = Path.GetRelativePath(sourceDirectoryName, directoryName);
for (int i = 0; i < lines.Length; i++) for (int i = 0; i < lines.Length; i++)
{ {
if (!lines[i].StartsWith(textBFindReplace)) if (!lines[i].Contains(textBFindReplace))
continue; continue;
path = lines[i].Substring(textBFindReplace.Length, lines[i].Length - 1 - textBFindReplace.Length); if (!lines[i].EndsWith(')') && !lines[i].EndsWith(")~~"))
pathB = string.IsNullOrEmpty(directoryBFindReplace[0]) ? path : path.Replace(directoryBFindReplace[0], directoryBFindReplace[1]); continue;
pathName = Path.GetFileName(pathB); if (lines[i].StartsWith(textBFindReplace))
relativePath = Path.GetRelativePath(sourceDirectoryName, pathB); path = lines[i].Substring(textBFindReplace.Length, lines[i].Length - 1 - textBFindReplace.Length);
lines[i] = $"- [{pathName}]({relativePath})"; else
{
segments = lines[i].Split("~~");
if (segments.Length < 2 || !segments[1].StartsWith(textBFindReplace))
continue;
path = segments[1].Substring(textBFindReplace.Length, segments[1].Length - 1 - textBFindReplace.Length);
}
if (string.IsNullOrEmpty(directoryBFindReplace[0]))
{
pathD = path;
pathName = Path.GetFileName(path);
}
else
{
pathB = path.Replace(directoryBFindReplace[0], directoryBFindReplace[1]);
pathC = directoryBFindReplace[1][0] != '/' ? pathB : pathB.Replace('\\', '/');
pathName = Path.GetFileName(pathC);
pathD = $"{pathC}{directoryFindReplace[1]}{pathName}";
}
relativePath = Path.GetRelativePath(sourceDirectoryName, pathD);
lines[i] = lines[i].Replace($"{textBFindReplace}{path}", $"- [{pathName}]({relativePath}");
} }
textB = string.Join(Environment.NewLine, lines); textB = string.Join(Environment.NewLine, lines);
text = textB.Replace(textFindReplace[0], textFindReplace[1].Replace("%", relativeDirectory)); text = textB.Replace(textFindReplace[0], textFindReplace[1].Replace("%", relativeDirectory));
@ -91,6 +114,8 @@ public class CopyService
public void CopyDirectory() public void CopyDirectory()
{ {
if (!Directory.Exists(_AppSettings.Source))
_ = Directory.CreateDirectory(_AppSettings.Source);
if (Directory.Exists(_AppSettings.Destination)) if (Directory.Exists(_AppSettings.Destination))
Directory.Delete(_AppSettings.Destination, recursive: true); Directory.Delete(_AppSettings.Destination, recursive: true);
ReadOnlyCollection<Record> records = GetRecords(_AppSettings); ReadOnlyCollection<Record> records = GetRecords(_AppSettings);