mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-08-08 21:08:39 +00:00
news reimplementation testing
trying to fix it for lbp1
This commit is contained in:
parent
bc5c0a1b27
commit
73cb3d9e0a
2 changed files with 70 additions and 0 deletions
|
@ -0,0 +1,35 @@
|
|||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
using static LBPUnion.ProjectLighthouse.Types.News.News;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers;
|
||||
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/news")]
|
||||
[Produces("text/xml")]
|
||||
public class NewsController : ControllerBase
|
||||
{
|
||||
[HttpGet]
|
||||
public IActionResult Get()
|
||||
{
|
||||
string newsEntry = LbpSerializer.StringElement
|
||||
(
|
||||
"item",
|
||||
new NewsEntry
|
||||
{
|
||||
Summary = "test summary",
|
||||
Image = new NewsImage
|
||||
{
|
||||
Hash = "4947269c5f7061b27225611ee58a9a91a8031bbe",
|
||||
Alignment = "right",
|
||||
},
|
||||
Id = 1,
|
||||
Title = "Test Title",
|
||||
Text = "Test Text",
|
||||
Date = 1348755214000,
|
||||
}.Serialize()
|
||||
);
|
||||
|
||||
return this.Ok(LbpSerializer.StringElement("news", newsEntry));
|
||||
}
|
||||
}
|
35
ProjectLighthouse/Types/News.cs
Normal file
35
ProjectLighthouse/Types/News.cs
Normal file
|
@ -0,0 +1,35 @@
|
|||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Types.News;
|
||||
|
||||
/// <summary>
|
||||
/// Used on the info moon on LBP1. Broken for unknown reasons
|
||||
/// </summary>
|
||||
public static class News {
|
||||
public class NewsEntry
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Summary { get; set; }
|
||||
public string Text { get; set; }
|
||||
public NewsImage Image { get; set; }
|
||||
public long Date { get; set; }
|
||||
|
||||
public string Serialize()
|
||||
=> LbpSerializer.StringElement("id", this.Id) +
|
||||
LbpSerializer.StringElement("title", this.Title) +
|
||||
LbpSerializer.StringElement("summary", this.Summary) +
|
||||
LbpSerializer.StringElement("text", this.Text) +
|
||||
LbpSerializer.StringElement("date", this.Date) +
|
||||
this.Image.Serialize();
|
||||
}
|
||||
|
||||
public class NewsImage
|
||||
{
|
||||
public string Hash { get; set; }
|
||||
public string Alignment { get; set; }
|
||||
|
||||
public string Serialize()
|
||||
=> LbpSerializer.StringElement("image", LbpSerializer.StringElement("hash", this.Hash) + LbpSerializer.StringElement("alignment", this.Alignment));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue