Skip to content
This repository has been archived by the owner on Jun 6, 2021. It is now read-only.

Commit

Permalink
Updated release script, added last fixes to core
Browse files Browse the repository at this point in the history
  • Loading branch information
BlackDragonBE committed Mar 24, 2018
1 parent 46b0dc0 commit f1e95a2
Show file tree
Hide file tree
Showing 10 changed files with 265 additions and 75 deletions.
35 changes: 25 additions & 10 deletions MarkdownToRW/CreateReleaseZips.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,38 @@ echo }
echo }
) > "%~dp0\MarkdownConverter\DragonVersion.cs"

:: GUI
:: Build Release in Visual Studio first
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe" "%~dp0\MarkdownToRW.sln" /Build Release
"%~dp0/7z/7za.exe" a -tzip "%~dp0\Release\MarkdownToRW_DotNetFramework_Mono_GUI_%version%.zip" "%~dp0\MarkdownToRW\bin\Release\*"
:: Winforms / Mono GUI
:: "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe" "%~dp0\MarkdownToRW.sln" /Build Release
::"%~dp0/7z/7za.exe" a -tzip "%~dp0\Release\MarkdownToRW_DotNetFramework_Mono_GUI_%version%.zip" "%~dp0\MarkdownToRW\bin\Release\*"

:: Portable
:: CORE Portable Console
cd MarkdownToRWCore
call QuickPublish.cmd
call CreateReleases.cmd
cd ..

"%~dp0/7z/7za.exe" a -tzip "%~dp0\Release\MarkdownToRW_DotNetCore_Portable_%version%.zip" "%~dp0\MarkdownToRWCore\bin\Debug\netcoreapp2.0\publish\*"
"%~dp0/7z/7za.exe" a -tzip "%~dp0\Release\MarkdownToRW_Console_Portable_%version%.zip" "%~dp0\MarkdownToRWCore\bin\Debug\netcoreapp2.0\publish\*"

:: Self Contained
:: CORE Self Contained Console

"%~dp0/7z/7za.exe" a -tzip "%~dp0\Release\MarkdownToRW_DotNetCore_Windows_SelfContained_%version%.zip" "%~dp0\MarkdownToRWCore\bin\Release\netcoreapp2.0\win10-x64\publish\*"
"%~dp0/7z/7za.exe" a -tzip "%~dp0\Release\MarkdownToRW_Console_Windows_SelfContained_%version%.zip" "%~dp0\MarkdownToRWCore\bin\Release\netcoreapp2.0\win10-x64\publish\*"

"%~dp0/7z/7za.exe" a -tzip "%~dp0\Release\MarkdownToRW_DotNetCore_macOS_SelfContained_%version%.zip" "%~dp0\MarkdownToRWCore\bin\Release\netcoreapp2.0\osx-x64\publish\*"
"%~dp0/7z/7za.exe" a -tzip "%~dp0\Release\MarkdownToRW_macOS_Console_SelfContained_%version%.zip" "%~dp0\MarkdownToRWCore\bin\Release\netcoreapp2.0\osx-x64\publish\*"

"%~dp0/7z/7za.exe" a -tzip "%~dp0\Release\MarkdownToRW_DotNetCore_linux_SelfContained_%version%.zip" "%~dp0\MarkdownToRWCore\bin\Release\netcoreapp2.0\linux-x64\publish\*"
"%~dp0/7z/7za.exe" a -tzip "%~dp0\Release\MarkdownToRW_linux_Console_SelfContained_%version%.zip" "%~dp0\MarkdownToRWCore\bin\Release\netcoreapp2.0\linux-x64\publish\*"

:: CORE Portable GUI
cd MarkdownToRWGUI
call QuickPublish.cmd
call CreateReleases.cmd
cd ..

"%~dp0/7z/7za.exe" a -tzip "%~dp0\Release\MarkdownToRW_GUI_Portable_%version%.zip" "%~dp0\MarkdownToRWGUI\bin\Debug\netcoreapp2.0\publish\*"

:: CORE Self Contained GUI

"%~dp0/7z/7za.exe" a -tzip "%~dp0\Release\MarkdownToRW_GUI_Windows_SelfContained_%version%.zip" "%~dp0\MarkdownToRWGUI\bin\Release\netcoreapp2.0\win10-x64\publish\*"

"%~dp0/7z/7za.exe" a -tzip "%~dp0\Release\MarkdownToRW_GUI_macOS_SelfContained_%version%.zip" "%~dp0\MarkdownToRWGUI\bin\Release\netcoreapp2.0\osx-x64\publish\*"

"%~dp0/7z/7za.exe" a -tzip "%~dp0\Release\MarkdownToRW_GUI_linux_SelfContained_%version%.zip" "%~dp0\MarkdownToRWGUI\bin\Release\netcoreapp2.0\linux-x64\publish\*"
9 changes: 7 additions & 2 deletions MarkdownToRW/MarkdownConverter/Converter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static void AddClassToImages(ref string html)
doc.LoadHtml(html);
HtmlNodeCollection imgNodes = doc.DocumentNode.SelectNodes("//img");

if (imgNodes == null)
if (imgNodes == null || imgNodes.Count == 0)
{
return;
}
Expand Down Expand Up @@ -119,7 +119,7 @@ private static void AddExtraAttributesToLinks(ref string html)
doc.LoadHtml(html);
HtmlNodeCollection linkNodes = doc.DocumentNode.SelectNodes("//a");

if (linkNodes == null)
if (linkNodes == null || linkNodes.Count == 0)
{
return;
}
Expand All @@ -144,6 +144,11 @@ private static void ConvertSpoilers(ref string html)
doc.LoadHtml(html);
HtmlNodeCollection divNodes = doc.DocumentNode.SelectNodes("//div");

if (divNodes == null || divNodes.Count == 0)
{
return;
}

foreach (HtmlNode divNode in divNodes)
{
if (divNode.InnerHtml.StartsWith("\n<em>Spoiler:"))
Expand Down
2 changes: 1 addition & 1 deletion MarkdownToRW/MarkdownConverter/DragonVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace DragonMarkdown
{
public static class DragonVersion
{
public static readonly decimal VERSION = 1.02m;
public static readonly decimal VERSION = 1.10m;
}
}
5 changes: 4 additions & 1 deletion MarkdownToRW/MarkdownConverter/Utility/DragonUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@ public static string BatchReplaceText(string text, List<string> originals, List<
return newText;
}

public static void QuickWriteFile(string path, string content)
public static bool QuickWriteFile(string path, string content)
{
if (!CheckFolderWritePermission(Path.GetDirectoryName(path))) return false;

using (StreamWriter sw = new StreamWriter(path))
{
sw.Write(content);
sw.Flush();
sw.Close();
return true;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,5 @@ public class ConvertAndUploadArguments
[ArgRequired(PromptIfMissing = true)]
[ArgPosition(4)]
public string Password { get; set; }

}
}
64 changes: 54 additions & 10 deletions MarkdownToRW/MarkdownToRWCore/CoreConsoleShared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Text;
using DragonMarkdown;
using DragonMarkdown.Utility;
using MarkdownToRWCore.DragonConsole;

namespace MarkdownToRWCore
{
Expand All @@ -19,12 +20,13 @@ public static void WriteIntro()
Console.WriteLine(" │ | | | | .'| _| '_| . | . | | | | | | | | . | | ─| | | | │");
Console.WriteLine(" │ |_|_|_|__,|_| |_,_|___|___|_____|_|_| |_| |___| |__|__|_____| │");
Console.WriteLine(" │ │");
Console.WriteLine(" │ CORE VERSION vx.xx │".Replace("x.xx",DragonVersion.VERSION.ToString()));
Console.WriteLine(" │ CORE CONSOLE VERSION vx.xx │".Replace("x.xx", DragonVersion.VERSION.ToString()));
Console.WriteLine(" └───────────────────────────────────────────────────────────────────┘");
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(" Developed by Eric Van de Kerckhove (BlackDragonBE)");

Console.Write(" Developed by Eric Van de Kerckhove (BlackDragonBE)");
Console.WriteLine("");
Console.WriteLine("");
Console.ResetColor();

}

public static void OpenHtmlResult(string generatedHtmlPath)
Expand All @@ -42,9 +44,7 @@ public static string GetExistingFilePath()
return path;
}

Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("File " + path + " doesn't exist!");
Console.ResetColor();
ColoredConsole.WriteLineWithColor("File " + path + " doesn't exist!", ConsoleColor.Red);
Console.WriteLine("");
return null;
}
Expand All @@ -61,11 +61,55 @@ public static string GetNewFilePath()
return path;
}

Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("Invalid folder, can't write to to: " + directoryName);
Console.ResetColor();
ColoredConsole.WriteLineWithColor("Invalid folder, can't write to to: " + directoryName, ConsoleColor.Red);

Console.WriteLine("");
return null;
}

public static void StartFileDeletion(List<string> imageIDs)
{
Console.WriteLine("------------------------------------------------");

Console.WriteLine(" _ __ ");
Console.WriteLine(" ____ | |_ _____ _ | |");
Console.WriteLine("| \\ ___ ___|_| |_ | _ |___ ___|_|___| |");
Console.WriteLine("| | | . | | | _| | __| .'| | | _|__|");
Console.WriteLine("|____/|___|_|_| |_| |__| |__,|_|_|_|___|__|");
Console.WriteLine("");
Console.WriteLine("------------------------------------------------");

Console.WriteLine("Open source Hacked Core Restorative Automatic Program (OH CRAP) v2");
Console.WriteLine("------------");
Console.WriteLine("Deleting uploaded images...");

foreach (string iD in imageIDs)
{
var result = WordPressConnector.Delete(Convert.ToInt32(iD));
if (result)
{
Console.WriteLine("Deleted file with id " + iD);
}
else
{
ColoredConsole.WriteLineWithColor("Failed to delete file with id " + iD, ConsoleColor.Red);
}
}

Console.WriteLine("Cleanup complete! Press any key to exit.");
Console.ReadKey();
}

public static void QuitConsole()
{
Environment.Exit(0);
}

public static void PauseAndQuit()
{
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
QuitConsole();
}
}
}
16 changes: 16 additions & 0 deletions MarkdownToRW/MarkdownToRWCore/DragonConsole/ColoredConsole.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System;

namespace MarkdownToRWCore.DragonConsole
{
public static class ColoredConsole
{
public static void WriteLineWithColor(string text, ConsoleColor color)
{
ConsoleColor previousColor = Console.ForegroundColor;
Console.ForegroundColor = color;
Console.WriteLine(text);
Console.ForegroundColor = previousColor;

}
}
}
45 changes: 4 additions & 41 deletions MarkdownToRW/MarkdownToRWCore/InteractiveConsole.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using DragonMarkdown;
using DragonMarkdown.DragonWordPressXml.Responses;
using DragonMarkdown.Utility;
using MarkdownToRWCore.DragonConsole;

namespace MarkdownToRWCore
{
Expand Down Expand Up @@ -99,8 +100,6 @@ public static void StartInteractive()
}
}



private static void DoConversion(string markdownPath, string htmlPath, bool uploadImages, bool onlyUpdateHtml)
{
Console.WriteLine("------------");
Expand Down Expand Up @@ -191,7 +190,7 @@ private static bool UploadImages(string markdownPath, string htmlPath, bool only
else
{
Console.WriteLine("Image upload failed! Aborting upload and going into file cleanup mode...");
StartFileDeletion(imageIDs);
CoreConsoleShared.StartFileDeletion(imageIDs);
return false;
}
}
Expand All @@ -216,47 +215,12 @@ private static GetProfileResponse AskForCredentials(GetProfileResponse user)

if (user == null)
{
Console.WriteLine("Incorrect credentials / can't connect to RW WordPress.");
ColoredConsole.WriteLineWithColor("Incorrect credentials / can't connect to RW WordPress.", ConsoleColor.Red);
Console.WriteLine("Please try again.");
}
return user;
}



private static void StartFileDeletion(List<string> imageIDs)
{
Console.WriteLine("------------------------------------------------");

Console.WriteLine(" _ __ ");
Console.WriteLine(" ____ | |_ _____ _ | |");
Console.WriteLine("| \\ ___ ___|_| |_ | _ |___ ___|_|___| |");
Console.WriteLine("| | | . | | | _| | __| .'| | | _|__|");
Console.WriteLine("|____/|___|_|_| |_| |__| |__,|_|_|_|___|__|");
Console.WriteLine("");
Console.WriteLine("------------------------------------------------");

Console.WriteLine("Open source Hacked Core Restorative Automatic Program (OH CRAP) v2");
Console.WriteLine("------------");
Console.WriteLine("Deleting uploaded images...");

foreach (string iD in imageIDs)
{
var result = WordPressConnector.Delete(Convert.ToInt32(iD));
if (result)
{
Console.WriteLine("Deleted file with id " + iD);
}
else
{
Console.WriteLine("Failed to delete file with id " + iD);
}
}

Console.WriteLine("Cleanup complete! Press any key to exit.");
Console.ReadKey();
}

private static void ConversionFinished(string generatedHtmlPath)
{
Console.WriteLine("------------");
Expand All @@ -276,8 +240,7 @@ private static void ConversionFinished(string generatedHtmlPath)
CoreConsoleShared.OpenHtmlResult(generatedHtmlPath);
}

Console.WriteLine("Press any key to exit.");
Console.ReadKey();
CoreConsoleShared.PauseAndQuit();
}


Expand Down
Loading

0 comments on commit f1e95a2

Please sign in to comment.