更新: タイトルのWindows禁止文字全角置換および本文先頭への日本語タイトル配置
This commit is contained in:
1 parent
6be0d060bf
commit
20ff5b2eac
1 file changed
+51
-4
@@ -258,10 +258,11 @@ internal class ryuugames
|
|||||||
SyndicationItem item;
|
SyndicationItem item;
|
||||||
LanguageType langType;
|
LanguageType langType;
|
||||||
|
|
||||||
// 最新フォーマット(ダウンロードセクションおよび英語タイトル表示)が含まれているキャッシュのみ再利用
|
// 最新フォーマット(ダウンロードセクション、英語タイトル、および日本語タイトル表示 v4)が含まれているキャッシュのみ再利用
|
||||||
bool isLatestFormat = prevEntry != null &&
|
bool isLatestFormat = prevEntry != null &&
|
||||||
prevEntry.SummaryHtml.Contains("ryuu-dl-section") &&
|
prevEntry.SummaryHtml.Contains("ryuu-dl-section") &&
|
||||||
prevEntry.SummaryHtml.Contains("ryuu-eng-title");
|
prevEntry.SummaryHtml.Contains("ryuu-eng-title") &&
|
||||||
|
prevEntry.SummaryHtml.Contains("ryuu-jp-title-v4");
|
||||||
|
|
||||||
if (prevEntry != null && !string.IsNullOrEmpty(prevEntry.SummaryHtml) && isLatestFormat)
|
if (prevEntry != null && !string.IsNullOrEmpty(prevEntry.SummaryHtml) && isLatestFormat)
|
||||||
{
|
{
|
||||||
@@ -787,7 +788,36 @@ internal class ryuugames
|
|||||||
developerPrefix = string.Empty;
|
developerPrefix = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $"{langPrefix} {developerPrefix}{mainTitle}".Trim();
|
string rawTitle = $"{langPrefix} {developerPrefix}{mainTitle}".Trim();
|
||||||
|
|
||||||
|
// Windowsのフォルダ名・ファイル名に使用できない禁止文字を全角へサニタイズ
|
||||||
|
return SanitizeWindowsFileName(rawTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Windows のフォルダ名・ファイル名に使用できない禁止文字(\ / : * ? " < > |)を全角文字に置換し、
|
||||||
|
/// 安全な文字列へサニタイズします。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">対象文字列</param>
|
||||||
|
/// <returns>禁止文字が全角に置換された文字列</returns>
|
||||||
|
private static string SanitizeWindowsFileName(string text)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(text))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return text
|
||||||
|
.Replace('\\', '¥')
|
||||||
|
.Replace('/', '/')
|
||||||
|
.Replace(':', ':')
|
||||||
|
.Replace('*', '*')
|
||||||
|
.Replace('?', '?')
|
||||||
|
.Replace('"', '”')
|
||||||
|
.Replace('<', '<')
|
||||||
|
.Replace('>', '>')
|
||||||
|
.Replace('|', '|')
|
||||||
|
.Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -818,7 +848,7 @@ internal class ryuugames
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// RSSリーダー(FreshRSS等)で美しく視認性の高い本文 HTML を構築します。
|
/// RSSリーダー(FreshRSS等)で美しく視認性の高い本文 HTML を構築します。
|
||||||
/// 本文先頭に英語タイトルを明記します。
|
/// 本文先頭に日本語タイトルおよび英語タイトルを明記します。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="info">記事詳細情報</param>
|
/// <param name="info">記事詳細情報</param>
|
||||||
/// <param name="articleUrl">記事URL</param>
|
/// <param name="articleUrl">記事URL</param>
|
||||||
@@ -848,6 +878,23 @@ internal class ryuugames
|
|||||||
}
|
}
|
||||||
sb.Append("</div>");
|
sb.Append("</div>");
|
||||||
|
|
||||||
|
// 1.4. 日本語タイトル (Japanese Title) の明記(本文先頭)
|
||||||
|
string jpTitle = !string.IsNullOrWhiteSpace(info.OriginalTitle)
|
||||||
|
? info.OriginalTitle
|
||||||
|
: (info.Language == LanguageType.Japanese ? info.GameTitle : string.Empty);
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(jpTitle))
|
||||||
|
{
|
||||||
|
sb.Append("<div class=\"ryuu-jp-title ryuu-jp-title-v4\" style=\"background-color: #f1f8e9; border-left: 4px solid #43a047; padding: 8px 12px; margin-bottom: 8px; font-size: 14px; border-radius: 0 4px 4px 0;\">");
|
||||||
|
sb.Append("<strong style=\"color: #2e7d32;\">日本語タイトル (Japanese Title):</strong> ");
|
||||||
|
sb.Append($"<span>{WebUtility.HtmlEncode(jpTitle)}</span>");
|
||||||
|
sb.Append("</div>");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.Append("<!-- ryuu-jp-title-v4 -->");
|
||||||
|
}
|
||||||
|
|
||||||
// 1.5. 英語タイトル (English Title) の明記(本文先頭)
|
// 1.5. 英語タイトル (English Title) の明記(本文先頭)
|
||||||
if (!string.IsNullOrWhiteSpace(info.OriginalArticleTitle))
|
if (!string.IsNullOrWhiteSpace(info.OriginalArticleTitle))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user