mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-07-31 17:28:39 +00:00
Implement LBP3 community tab
This commit is contained in:
parent
d240a7480b
commit
d6a0b7fd9c
6 changed files with 141 additions and 3 deletions
|
@ -89,6 +89,7 @@
|
|||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpUseContinuousIndentInsideBracesMigration/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Affero/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=airfryer/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=BCAS/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=BCES/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=BCET/@EntryIndexedValue">True</s:Boolean>
|
||||
|
@ -100,6 +101,7 @@
|
|||
<s:Boolean x:Key="/Default/UserDictionary/Words/=ezoiar/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=farc/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=friendscores/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Ingame/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Kettu/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=lbpme/@EntryIndexedValue">True</s:Boolean>
|
||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=LBPU/@EntryIndexedValue">True</s:Boolean>
|
||||
|
|
61
ProjectLighthouse/Controllers/CollectionController.cs
Normal file
61
ProjectLighthouse/Controllers/CollectionController.cs
Normal file
|
@ -0,0 +1,61 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
using LBPUnion.ProjectLighthouse.Types.Categories;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("LITTLEBIGPLANETPS3_XML/")]
|
||||
[Produces("text/xml")]
|
||||
public class CollectionController : ControllerBase
|
||||
{
|
||||
private readonly Database database;
|
||||
|
||||
public CollectionController(Database database)
|
||||
{
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
[HttpGet("user/{username}/playlists")]
|
||||
public IActionResult GetUserPlaylists(string username) => this.Ok();
|
||||
|
||||
[HttpGet("searches")]
|
||||
[HttpGet("genres")]
|
||||
public async Task<IActionResult> GenresAndSearches()
|
||||
{
|
||||
List<Category> categories = new()
|
||||
{
|
||||
new TeamPicksCategory(),
|
||||
new TeamPicksCategory(),
|
||||
new NewestLevelsCategory(),
|
||||
new NewestLevelsCategory(),
|
||||
};
|
||||
|
||||
string categoriesSerialized = categories.Aggregate(string.Empty, (current, category) => current + category.Serialize(this.database));
|
||||
|
||||
return this.Ok
|
||||
(
|
||||
LbpSerializer.TaggedStringElement
|
||||
(
|
||||
"categories",
|
||||
categoriesSerialized,
|
||||
new Dictionary<string, object>
|
||||
{
|
||||
{
|
||||
"hint", ""
|
||||
},
|
||||
{
|
||||
"hint_start", 1
|
||||
},
|
||||
{
|
||||
"total", categories.Count
|
||||
},
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -58,9 +58,6 @@ namespace LBPUnion.ProjectLighthouse.Controllers
|
|||
return this.Ok(LbpSerializer.StringElement("users", serialized));
|
||||
}
|
||||
|
||||
[HttpGet("user/{username}/playlists")]
|
||||
public IActionResult GetUserPlaylists(string username) => this.Ok();
|
||||
|
||||
[HttpPost("updateUser")]
|
||||
public async Task<IActionResult> UpdateUser()
|
||||
{
|
||||
|
|
48
ProjectLighthouse/Types/Categories/Category.cs
Normal file
48
ProjectLighthouse/Types/Categories/Category.cs
Normal file
|
@ -0,0 +1,48 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Serialization;
|
||||
using LBPUnion.ProjectLighthouse.Serialization;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Types.Categories
|
||||
{
|
||||
[XmlType("category")]
|
||||
[XmlRoot("category")]
|
||||
public abstract class Category
|
||||
{
|
||||
[XmlElement("name")]
|
||||
public abstract string Name { get; set; }
|
||||
|
||||
[XmlElement("description")]
|
||||
public abstract string Description { get; set; }
|
||||
|
||||
[XmlElement("icon")]
|
||||
public abstract string IconHash { get; set; }
|
||||
|
||||
[XmlIgnore]
|
||||
public abstract string Endpoint { get; set; }
|
||||
|
||||
[XmlElement("url")]
|
||||
public string IngameEndpoint {
|
||||
get => $"/searches/{this.Endpoint}";
|
||||
set => this.Endpoint = value.Replace("/searches/", "");
|
||||
}
|
||||
|
||||
public abstract IEnumerable<Slot> Slots(Database database);
|
||||
|
||||
public string Serialize(Database database)
|
||||
{
|
||||
string slots = this.Slots(database).Aggregate(string.Empty, (current, slot) => current + slot.Serialize());
|
||||
|
||||
return LbpSerializer.StringElement
|
||||
(
|
||||
"category",
|
||||
LbpSerializer.StringElement("name", this.Name) +
|
||||
LbpSerializer.StringElement("description", this.Description) +
|
||||
LbpSerializer.StringElement("url", this.IngameEndpoint) +
|
||||
LbpSerializer.StringElement("results", slots) +
|
||||
LbpSerializer.StringElement("icon", IconHash)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
15
ProjectLighthouse/Types/Categories/NewestLevelsCategory.cs
Normal file
15
ProjectLighthouse/Types/Categories/NewestLevelsCategory.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Types.Categories
|
||||
{
|
||||
public class NewestLevelsCategory : Category
|
||||
{
|
||||
public override string Name { get; set; } = "Newest Levels";
|
||||
public override string Description { get; set; } = "Levels recently published";
|
||||
public override string IconHash { get; set; } = "g820623";
|
||||
public override string Endpoint { get; set; } = "newest";
|
||||
public override IEnumerable<Slot> Slots(Database database) => database.Slots.OrderByDescending(s => s.FirstUploaded).Take(1);
|
||||
}
|
||||
}
|
15
ProjectLighthouse/Types/Categories/TeamPicksCategory.cs
Normal file
15
ProjectLighthouse/Types/Categories/TeamPicksCategory.cs
Normal file
|
@ -0,0 +1,15 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using LBPUnion.ProjectLighthouse.Types.Levels;
|
||||
|
||||
namespace LBPUnion.ProjectLighthouse.Types.Categories
|
||||
{
|
||||
public class TeamPicksCategory : Category
|
||||
{
|
||||
public override string Name { get; set; } = "Team Picks";
|
||||
public override string Description { get; set; } = "Levels given awards by your instance admin";
|
||||
public override string IconHash { get; set; } = "g820626";
|
||||
public override string Endpoint { get; set; } = "team_picks";
|
||||
public override IEnumerable<Slot> Slots(Database database) => database.Slots.OrderByDescending(s => s.FirstUploaded).Where(s => s.TeamPick).Take(1);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue