Skip to content

Commit

Permalink
Remove some un-need properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed Dec 21, 2023
1 parent e5436db commit 379a748
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public partial class TestSceneKaraokeChangeLogMarkdownContainer : OsuTestScene
[SetUp]
public void SetUp() => Schedule(() =>
{
var build = new APIChangelogBuild("karaoke-dev", "karaoke-dev.github.io")
var build = new APIChangelogBuild
{
Path = "content/changelog/2020.0620",
DocumentUrl = "https://raw.githubusercontent.com/karaoke-dev/karaoke-dev.github.io/master/content/changelog/2020.0620",
RootUrl = "https://github.com/karaoke-dev/karaoke-dev.github.io/tree/master/content/changelog/2020.0620",
Content = "---\ntitle: \"2020.0620\"\ndate: 2020-06-20\n---\n\n## Achievement\n\n- Might support convert `UTAU`/`SynthV` project into karaoke beatmap in future. [karaoke](#100#101@andy840119)",
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ private static async Task<List<APIChangelogBuild>> getAllBuilds(IGitHubClient cl

private static APIChangelogBuild createBuild(RepositoryContent content)
{
return new APIChangelogBuild(ORGANIZATION_NAME, PROJECT_NAME)
return new APIChangelogBuild
{
DocumentUrl = getDocumentUrl(content.Path),
RootUrl = content.HtmlUrl,
Path = content.Path,
Version = content.Name,
PublishedAt = getPublishDateFromName(content.Name),
};
Expand All @@ -76,6 +76,9 @@ static DateTimeOffset getPublishDateFromName(string name)

return new DateTimeOffset(new DateTime(year, month, day));
}

string getDocumentUrl(string path)
=> $"https://raw.githubusercontent.com/{ORGANIZATION_NAME}/{PROJECT_NAME}/{BRANCH_NAME}/{path}/";
}

private static async Task<APIChangelogBuild> createPreviewBuild(IGitHubClient client, APIChangelogBuild originBuild)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public abstract class GithubChangeLogAPIRequest<T> : GithubAPIRequest<T> where T
{
protected const string ORGANIZATION_NAME = "karaoke-dev";
protected const string PROJECT_NAME = $"{ORGANIZATION_NAME}.github.io";
protected const string BRANCH_NAME = "master";
protected const string CHANGELOG_PATH = "content/changelog";

protected GithubChangeLogAPIRequest()
Expand All @@ -33,10 +34,10 @@ protected static async Task<string> GetChangelogContent(IGitHubClient client, st

protected static APIChangelogBuild CreateBuildWithContent(APIChangelogBuild originBuild, string content)
{
return new APIChangelogBuild(originBuild.OrganizationName, originBuild.ProjectName)
return new APIChangelogBuild
{
DocumentUrl = originBuild.DocumentUrl,
RootUrl = originBuild.RootUrl,
Path = originBuild.Path,
Version = originBuild.Version,
Content = content,
Versions =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,16 @@ namespace osu.Game.Rulesets.Karaoke.Online.API.Requests.Responses;

public class APIChangelogBuild
{
/// <summary>
///
/// </summary>
/// <param name="organization">Account or organization name</param>
/// <param name="project">Project name</param>
/// <param name="branch">Branch name</param>
public APIChangelogBuild(string organization, string project, string branch = "master")
{
OrganizationName = organization;
ProjectName = project;
Branch = branch;
Versions = new VersionNavigation();
}

/// <summary>
/// Organization name
/// </summary>
public string OrganizationName { get; }

/// <summary>
/// Project name
/// </summary>
public string ProjectName { get; }

/// <summary>
/// Branch name
/// </summary>
public string Branch { get; }

/// <summary>
/// The URL of the loaded document.
/// </summary>
public string DocumentUrl => $"https://raw.githubusercontent.com/{OrganizationName}/{ProjectName}/{Branch}/{Path}/";
public string DocumentUrl { get; set; } = null!;

/// <summary>
/// The base URL for all root-relative links.
/// </summary>
public string RootUrl { get; set; } = null!;

/// <summary>
/// Path of the project
/// </summary>
public string Path { get; set; } = null!;

/// <summary>
/// Path to download readme url
/// </summary>
public string ReadmeDownloadUrl => $"{DocumentUrl}index.md";

/// <summary>
/// Version number
/// </summary>
Expand All @@ -70,13 +31,14 @@ public APIChangelogBuild(string organization, string project, string branch = "m

/// <summary>
/// Might be preview or detail markdown content.
/// And the content is markdown format.
/// </summary>
public string Content { get; set; } = null!;
public string? Content { get; set; }

/// <summary>
/// Version
/// </summary>
public VersionNavigation Versions { get; }
public VersionNavigation Versions { get; } = new();

/// <summary>
/// Created date.
Expand Down

0 comments on commit 379a748

Please sign in to comment.