ssg: remove PostUrlFormat. this field is currently not required, and can be a potential cause for end-user confusion

This commit is contained in:
Nick Vella 2019-08-02 22:36:41 +10:00
parent 27e979f19a
commit a64ae677a0
4 changed files with 4 additions and 94 deletions

View File

@ -20,7 +20,6 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite
private const string CONFIG_OUTPUT_PATH = "OutputPath";
private const string CONFIG_BUILD_COMMAND = "BuildCommand";
private const string CONFIG_PUBLISH_COMMAND = "PublishCommand";
private const string CONFIG_POST_URL_FORMAT = "PostUrlFormat";
private const string CONFIG_SITE_URL = "SiteUrl"; // Store Site Url in credentials as well, for acccess by StaticSiteClient
private const string CONFIG_SHOW_CMD_WINDOWS = "ShowCmdWindows";
private const string CONFIG_CMD_TIMEOUT_MS = "CmdTimeoutMs";
@ -103,13 +102,6 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite
/// </summary>
public string SiteTitle { get; set; } = "";
/// <summary>
/// Post URL format, appended to end of Site URL, automatically opened on publish completion.
/// Supports %y for four-digit year, %m and %d for two-digit months and days, %f for post filename.
/// Default is Jekyll format: "%y/%m/%d/%f"
/// </summary>
public string PostUrlFormat { get; set; } = "%y/%m/%d/%f";
/// <summary>
/// Show CMD windows. Useful for debugging. Default is false.
/// </summary>
@ -152,8 +144,6 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite
BuildCommand = creds.GetCustomValue(CONFIG_BUILD_COMMAND);
PublishCommand = creds.GetCustomValue(CONFIG_PUBLISH_COMMAND);
// Don't overwrite the default value if we fail to find a value;
if (creds.GetCustomValue(CONFIG_POST_URL_FORMAT) != string.Empty) PostUrlFormat = creds.GetCustomValue(CONFIG_POST_URL_FORMAT);
SiteUrl = creds.GetCustomValue(CONFIG_SITE_URL); // This will be overidden in LoadFromBlogSettings, HomepageUrl is considered a more accurate source of truth
@ -200,7 +190,6 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite
creds.SetCustomValue(CONFIG_BUILD_COMMAND, BuildCommand);
creds.SetCustomValue(CONFIG_PUBLISH_COMMAND, PublishCommand);
creds.SetCustomValue(CONFIG_POST_URL_FORMAT, PostUrlFormat);
creds.SetCustomValue(CONFIG_SITE_URL, SiteUrl);
creds.SetCustomValue(CONFIG_SHOW_CMD_WINDOWS, ShowCmdWindows ? "1" : "0");
@ -231,7 +220,6 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite
PublishCommand = PublishCommand,
SiteUrl = SiteUrl,
SiteTitle = SiteTitle,
PostUrlFormat = PostUrlFormat,
ShowCmdWindows = ShowCmdWindows,
CmdTimeoutMs = CmdTimeoutMs,
Initialised = Initialised,

View File

@ -27,7 +27,6 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite
.ValidateDraftsPath()
.ValidateImagesPath()
.ValidateOutputPath()
.ValidatePostUrlFormat()
.ValidateBuildCommand()
.ValidatePublishCommand();
@ -156,16 +155,6 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite
#endregion
public StaticSiteConfigValidator ValidatePostUrlFormat()
{
if (!_config.PostUrlFormat.Contains("%f"))
throw new StaticSiteConfigValidationException(
"Invalid Post URL format",
"Post URL format does not contain filename variable (%f)");
return this;
}
public StaticSiteConfigValidator ValidateBuildCommand()
{
if (!_config.BuildingEnabled) return this; // Don't validate if building isn't enabled

View File

@ -52,17 +52,9 @@ namespace OpenLiveWriter.BlogClient.Clients.StaticSite
}
/// <summary>
/// Get the site path for the published post
/// eg. /2019/01/slug.html
/// We currently do not take configuration for specifiying a post path format
/// </summary>
public override string SitePath
{
get => SiteConfig.PostUrlFormat
.Replace("%y", BlogPost.DatePublished.ToString("yyyy"))
.Replace("%m", BlogPost.DatePublished.ToString("MM"))
.Replace("%d", BlogPost.DatePublished.ToString("dd"))
.Replace("%f", $"{Slug}{PUBLISH_FILE_EXTENSION}");
}
public override string SitePath => throw new NotImplementedException();
/// <summary>
/// Gets filename based on slug with prepended date

View File

@ -30,14 +30,6 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard
private TextBox textBoxImagesPath;
private Label labelOutputPath;
private TextBox textBoxOutputPath;
private Label labelUrlFormat;
private Label labelUrlFormatSubtitle;
private TextBox textBoxUrlFormat;
/// <summary>
/// Local site path, loaded from config, used for validation
/// </summary>
private string _localSitePath;
/// <summary>
/// Required designer variable.
@ -52,9 +44,6 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard
this.labelHeader.Text = Res.Get(StringId.CWStaticSitePathsTitle);
this.labelImagesPath.Text = Res.Get(StringId.CWStaticSitePathsImagesPath);
this.labelOutputPath.Text = Res.Get(StringId.CWStaticSitePathsOutputPath);
this.labelUrlFormat.Text = Res.Get(StringId.CWStaticSitePathsUrlFormat);
this.labelUrlFormatSubtitle.Text = Res.Get(StringId.CWStaticSitePathsUrlFormatSubtitle);
this.labelUrlFormatSubtitle.ForeColor = !SystemInformation.HighContrast ? Color.FromArgb(136, 136, 136) : SystemColors.GrayText;
}
public override void NaturalizeLayout()
@ -66,20 +55,13 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard
MaximizeWidth(textBoxImagesPath);
MaximizeWidth(labelOutputPath);
MaximizeWidth(textBoxOutputPath);
MaximizeWidth(labelUrlFormat);
MaximizeWidth(labelUrlFormatSubtitle);
MaximizeWidth(textBoxUrlFormat);
LayoutHelper.NaturalizeHeight(labelUrlFormatSubtitle);
LayoutHelper.NaturalizeHeightAndDistributeNoScale(3, labelImagesPath, textBoxImagesPath);
LayoutHelper.NaturalizeHeightAndDistributeNoScale(3, labelOutputPath, textBoxOutputPath);
LayoutHelper.NaturalizeHeightAndDistributeNoScale(3, labelUrlFormat, labelUrlFormatSubtitle, textBoxUrlFormat);
LayoutHelper.DistributeVerticallyNoScale(10, false,
new ControlGroup(labelImagesPath, textBoxImagesPath),
new ControlGroup(labelOutputPath, textBoxOutputPath),
new ControlGroup(labelUrlFormat, labelUrlFormatSubtitle, textBoxUrlFormat)
new ControlGroup(labelOutputPath, textBoxOutputPath)
);
}
@ -114,17 +96,10 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard
set => textBoxOutputPath.Text = value;
}
public string UrlFormat
{
get => textBoxUrlFormat.Text;
set => textBoxUrlFormat.Text = value;
}
public void ValidateWithConfig(StaticSiteConfig config)
=> config.Validator
.ValidateImagesPath()
.ValidateOutputPath()
.ValidatePostUrlFormat();
.ValidateOutputPath();
/// <summary>
/// Saves panel form fields into a StaticSiteConfig
@ -134,7 +109,6 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard
{
config.ImagesPath = ImagesPath;
config.OutputPath = OutputPath;
config.PostUrlFormat = UrlFormat;
}
/// <summary>
@ -143,12 +117,10 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard
/// <param name="config">a StaticSiteConfig instance</param>
public void LoadFromConfig(StaticSiteConfig config)
{
_localSitePath = config.LocalSitePath;
ImagesEnabled = config.ImagesEnabled;
ImagesPath = config.ImagesPath;
BuildingEnabled = config.BuildingEnabled;
OutputPath = config.OutputPath;
UrlFormat = config.PostUrlFormat;
}
/// <summary>
@ -177,9 +149,6 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard
this.textBoxImagesPath = new System.Windows.Forms.TextBox();
this.labelOutputPath = new System.Windows.Forms.Label();
this.textBoxOutputPath = new System.Windows.Forms.TextBox();
this.labelUrlFormat = new System.Windows.Forms.Label();
this.labelUrlFormatSubtitle = new System.Windows.Forms.Label();
this.textBoxUrlFormat = new System.Windows.Forms.TextBox();
this.panelMain.SuspendLayout();
this.SuspendLayout();
//
@ -189,9 +158,6 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard
this.panelMain.Controls.Add(this.textBoxImagesPath);
this.panelMain.Controls.Add(this.labelOutputPath);
this.panelMain.Controls.Add(this.textBoxOutputPath);
this.panelMain.Controls.Add(this.labelUrlFormat);
this.panelMain.Controls.Add(this.labelUrlFormatSubtitle);
this.panelMain.Controls.Add(this.textBoxUrlFormat);
this.panelMain.Size = new System.Drawing.Size(435, 242);
//
// labelImagesPath
@ -228,31 +194,6 @@ namespace OpenLiveWriter.PostEditor.Configuration.Wizard
this.textBoxOutputPath.Size = new System.Drawing.Size(368, 20);
this.textBoxOutputPath.TabIndex = 3;
//
// labelUrlFormat
//
this.labelUrlFormat.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.labelUrlFormat.Location = new System.Drawing.Point(20, 90);
this.labelUrlFormat.Name = "labelUrlFormat";
this.labelUrlFormat.Size = new System.Drawing.Size(83, 13);
this.labelUrlFormat.TabIndex = 4;
this.labelUrlFormat.Text = "Blog post URL format:";
//
// labelUrlFormatSubtitle
//
this.labelUrlFormatSubtitle.FlatStyle = System.Windows.Forms.FlatStyle.System;
this.labelUrlFormatSubtitle.Location = new System.Drawing.Point(20, 107);
this.labelUrlFormatSubtitle.Name = "labelUrlFormatSubtitle";
this.labelUrlFormatSubtitle.Size = new System.Drawing.Size(83, 13);
this.labelUrlFormatSubtitle.TabIndex = 5;
this.labelUrlFormatSubtitle.Text = "Subtitle";
//
// textBoxUrlFormat
//
this.textBoxUrlFormat.Location = new System.Drawing.Point(20, 125);
this.textBoxUrlFormat.Name = "textBoxUrlFormat";
this.textBoxUrlFormat.Size = new System.Drawing.Size(368, 20);
this.textBoxUrlFormat.TabIndex = 6;
//
// WeblogConfigurationWizardPanelStaticSitePaths2
//
this.AutoSize = true;