Skip to content

Commit

Permalink
[Big] Fix more classics formatting, convert popup divs to dialogs, se…
Browse files Browse the repository at this point in the history
…mantic HTML and CSS improvements, refactor server endpoints and WIP redesigned API
  • Loading branch information
Zekiah-A committed Oct 6, 2024
1 parent 8d8454d commit d6e8266
Show file tree
Hide file tree
Showing 55 changed files with 1,091 additions and 1,031 deletions.
2 changes: 1 addition & 1 deletion 404.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html><script>location.replace(location.origin+"/poem"+"?path="+location.pathname)</script>
<script>location.replace(location.origin+"/poem?path="+location.pathname)</script>
14 changes: 7 additions & 7 deletions Other/login-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class LoginSignup extends HTMLElement {
this.shadowThis.validateUsername(this)">
<input id="loginSigninEmail" type="text" class="popup-input" placeholder="Email">
<input id="loginQRInput" type="file" accept="image/*" capture="environment" style="display: none;">
<button class="popup-button" onclick="this.shadowThis.signin(this.shadowThis.loginSigninUsername.value, this.shadowThis.loginSigninEmail.value); this.shadowThis.login();"
<button class="popup-button" onclick="this.shadowThis.signin(this.shadowThis.loginSigninUsername.value, this.shadowThis.loginSigninEmail.value);"
style="margin-bottom: 8px;">Login</button>
<div style="display:flex;column-gap:8px;margin-top:8px">
Expand Down Expand Up @@ -85,7 +85,7 @@ class LoginSignup extends HTMLElement {
<div id="loginError" class="page">
<div id="errorMessage"><!--Erorr message text--></div>
<div style="display:flex;column-gap:8px;margin-top:8px">
<button class="popup-button" onclick="this.shadowThis.close();">Ok</button>
<button class="popup-button" onclick="this.shadowThis.login.close();">Ok</button>
</div>
</div>
</dialog>
Expand All @@ -97,7 +97,7 @@ class LoginSignup extends HTMLElement {
display: flex;
flex-direction: column;
max-width: 400px;
height: 230px;
height: 236px;
transition: .2s height;
}
Expand Down Expand Up @@ -145,7 +145,7 @@ class LoginSignup extends HTMLElement {
}
#login[currentpage="signin"] > #loginSignin, #login[currentpage="signup"] > #loginSignup,
#login[currentpage="loginerror"] > #loginError, #login[currentpage="code"] > #loginCode {
#login[currentpage="error"] > #loginError, #login[currentpage="code"] > #loginCode {
display: flex !important;
}
Expand Down Expand Up @@ -184,7 +184,7 @@ class LoginSignup extends HTMLElement {

async signup(username, email) {
try {
const response = await fetch(serverBaseAddress + "/Signup", {
const response = await fetch(serverBaseAddress + "/auth/signup", {
method: "POST",
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ Username: username, Email: email }) // Convert to JSON format
Expand All @@ -206,7 +206,7 @@ class LoginSignup extends HTMLElement {
//Impossible to log in without code, GUID can be retrieved though
async signin(username, email) {
try {
const signinResponse = await fetch(serverBaseAddress + "/Signin", {
const signinResponse = await fetch(serverBaseAddress + "/auth/signin", {
method: "POST",
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ Username: username, Email: email })
Expand Down Expand Up @@ -249,7 +249,7 @@ class LoginSignup extends HTMLElement {

confirmFail(err) {
this.errorMessage.textContent = err
this.login.setAttribute("currentPage", "loginerror")
this.login.setAttribute("currentpage", "error")
}

validateLoginSignup() {
Expand Down
11 changes: 8 additions & 3 deletions Other/purgatory-entry-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class PurgatoryEntry extends HTMLElement {
`
this.shadowRoot.append(style)
defineAndInject(this, this.shadowRoot)
this.setAttribute("tabindex", "0")

if (this.getAttribute("tooltip")) {

Expand All @@ -114,7 +115,7 @@ class PurgatoryEntry extends HTMLElement {
this.approves.textContent = this.getAttribute("approves")
this.vetoes.textContent = this.getAttribute("vetoes")

if (this.getAttribute('new')) {
if (this.getAttribute("new")) {
setTimeout(() => {
this.classList.add("entry-new")
this.setAttribute("style", `
Expand All @@ -131,8 +132,12 @@ class PurgatoryEntry extends HTMLElement {
this.classList.remove("entry-new")
}, 1600)
}
this.onclick = () =>
window.location.href = './purgatory-poem?guid=' + this.getAttribute('guid')
this.onclick = function() {
const guid = this.getAttribute("guid")
if (guid) {
window.location.href = "./purgatory-poem?guid=" + guid
}
}
}
}

Expand Down
5 changes: 3 additions & 2 deletions Other/server.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const serverBaseAddress =
localStorage.server || "https://server.poemanthology.org/subliminal"
const editServerAddress =
localStorage.editServer ||
"https://server.poemanthology.org/subliminaledit"
localStorage.editServer || "https://server.poemanthology.org/subliminal/edit"
const soundsServerAddress =
localStorage.soundsServer || "https://server.poemanthology.org/subliminal/sounds"
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace SubliminalServer.DataModel.Api;
namespace SubliminalServer.ApiModel;

public record LoginDetails(string Username, string Email);
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using SubliminalServer.DataModel.Purgatory;

namespace SubliminalServer.DataModel.Api;
namespace SubliminalServer.ApiModel;

public class UploadableEntry
{
public string? Summary { get; set; }
public bool ContentWarning { get; set; }
public PageStyle PageStyle { get; set; }
public string? Background { get; set; }
public IReadOnlyList<string> PoemTags { get; set; }

public List<string> PoemTags { get; set; }
public string PoemName { get; set; }
public string PoemContent { get; set; }

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SubliminalServer.DataModel.Account;

namespace SubliminalServer.DataModel.Api;
namespace SubliminalServer.ApiModel;

public class UploadableProfile
{
Expand All @@ -27,17 +27,17 @@ public class UploadableProfile

public UploadableProfile(AccountData account)
{
AccountKey = account.AccountKey;
AccountKey = account.Id;
Username = account.Username;
PenName = account.PenName;
Biography = account.Biography;
Location = account.Location;
Role = account.Role;
AvatarUrl = account.AvatarUrl;
Badges = account.Badges.Select(badge => badge.BadgeKey).ToList();
PinnedPoems = account.PinnedPoems.Select(entry => entry.EntryKey).ToList();
Poems = account.Poems.Select(entry => entry.EntryKey).ToList();
Following = account.Following.Select(profile => profile.AccountKey).ToList();
Badges = account.Badges.Select(badge => badge.Id).ToList();
PinnedPoems = account.PinnedPoems.Select(entry => entry.Id).ToList();
Poems = account.Poems.Select(entry => entry.Id).ToList();
Following = account.Following.Select(profile => profile.Id).ToList();
JoinDate = account.JoinDate;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using SubliminalServer.DataModel.Purgatory;
using SubliminalServer.DataModel.Rating;

namespace SubliminalServer.DataModel.Api;
namespace SubliminalServer.ApiModel;

public record UploadableRating(int EntryKey, RatingType Rating);
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using SubliminalServer.DataModel.Report;

namespace SubliminalServer.DataModel.Api;
namespace SubliminalServer.ApiModel;

public class UploadableReport
{
Expand Down
9 changes: 0 additions & 9 deletions SubliminalServer/Config.cs

This file was deleted.

5 changes: 3 additions & 2 deletions SubliminalServer/DataModel/Account/AccountAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@

namespace SubliminalServer.DataModel.Account;

[PrimaryKey(nameof(AddressKey))]
[PrimaryKey(nameof(Id))]
public class AccountAddress
{
// Unique, Primary key
[Required]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int AddressKey { get; set; }
public int Id { get; set; }
public string IpAddress { get; set; }
public DateTime LastUsed { get; set; }

// Foreign key AccountData
public int AccountKey { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions SubliminalServer/DataModel/Account/AccountBadge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

namespace SubliminalServer.DataModel.Account;

[PrimaryKey(nameof(BadgeKey))]
[PrimaryKey(nameof(Id))]
public class AccountBadge
{
// Unique, Primary key
[Required]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int BadgeKey { get; set; }
public int Id { get; set; }

public BadgeType Badge { get; set; }
public DateTime DateAwarded { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion SubliminalServer/DataModel/Account/AccountData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace SubliminalServer.DataModel.Account;
/// <summary>
/// Constructor for account data, contains the private info for an account, and inherits from account profile
/// </summary>
[PrimaryKey(nameof(AccountKey))]
[PrimaryKey(nameof(Id))]
public class AccountData : AccountProfile
{
// Unique
Expand Down
2 changes: 1 addition & 1 deletion SubliminalServer/DataModel/Account/AccountProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class AccountProfile
// Unique, Primary key
[Required]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int AccountKey { get; set; }
public int Id { get; set; }

// Unique
[Required]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ public class AccountAddressConfiguration : IEntityTypeConfiguration<AccountAddre
{
public void Configure(EntityTypeBuilder<AccountAddress> builder)
{
builder.HasKey(address => address.AddressKey);
builder.Property(address => address.AddressKey)
builder.HasKey(address => address.Id);
builder.Property(address => address.Id)
.ValueGeneratedOnAdd();

// One to many (AccountData)
builder.HasOne(address => address.Account)
.WithMany(account => account.KnownIPs)
.HasForeignKey(address => address.AddressKey);
.HasForeignKey(address => address.Id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class AccountBadgeConfiguration : IEntityTypeConfiguration<AccountBadge>
{
public void Configure(EntityTypeBuilder<AccountBadge> builder)
{
builder.HasKey(badge => badge.BadgeKey);
builder.HasKey(badge => badge.Id);

// One to many (AccountData)
builder.HasOne(badge => badge.Account)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class AccountDataConfiguration : IEntityTypeConfiguration<AccountData>
public void Configure(EntityTypeBuilder<AccountData> builder)
{
// Define the primary key
builder.HasKey(account => account.AccountKey);
builder.HasKey(account => account.Id);

// Unique email
builder.HasIndex(account => account.Username).IsUnique();
Expand All @@ -19,12 +19,12 @@ public void Configure(EntityTypeBuilder<AccountData> builder)
// One to many Poems (PurgatoryEntry)
builder.HasMany(account => account.Poems)
.WithOne(entry => entry.Author)
.HasForeignKey(entry => entry.AuthorKey);
.HasForeignKey(entry => entry.AuthorId);

// One to many Drafts (PurgatoryEntry)
builder.HasMany(account => account.Drafts)
.WithOne(draft => draft.Author)
.HasForeignKey(draft => draft.AuthorKey);
.HasForeignKey(draft => draft.AuthorId);

// One to many Badges (AccountBadge)
builder.HasMany(account => account.Badges)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public class PurgatoryAnnotationRatingConfiguration : IEntityTypeConfiguration<P
{
public void Configure(EntityTypeBuilder<PurgatoryRating> builder)
{
builder.HasKey(rating => rating.RatingKey);
builder.HasKey(rating => rating.Id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ public class PurgatoryDraftConfiguration : IEntityTypeConfiguration<PurgatoryDr
public void Configure(EntityTypeBuilder<PurgatoryDraft> builder)
{
// Define the primary key
builder.HasKey(entry => entry.DraftKey);
builder.HasKey(entry => entry.Id);

// Many to one (AccountData)
builder.HasOne(draft => draft.Author)
.WithMany(account => account.Drafts) // Use the correct navigation property
.HasForeignKey(draft => draft.AuthorKey);
.HasForeignKey(draft => draft.AuthorId);

// One to many PurgatoryEntry (Amends), PurgatoryEntry (AmendedBy)
builder.HasOne(draft => draft.Amends)
.WithMany()
.HasForeignKey(draft => draft.AmendsKey);
.HasForeignKey(draft => draft.AmendsId);

// One to many PurgatoryEntry (Edits), PurgatoryEntry (AmendedBy)
builder.HasOne(draft => draft.Edits)
.WithMany()
.HasForeignKey(draft => draft.EditsKey);
.HasForeignKey(draft => draft.EditsId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ public class PurgatoryEntryConfiguration : IEntityTypeConfiguration<PurgatoryEnt
public void Configure(EntityTypeBuilder<PurgatoryEntry> builder)
{
// Define the primary key
builder.HasKey(entry => entry.EntryKey);
builder.HasKey(entry => entry.Id);

builder.HasOne(entry => entry.Author)
.WithMany(account => account.Poems) // Use the correct navigation property
.HasForeignKey(entry => entry.AuthorKey);
.HasForeignKey(entry => entry.AuthorId);

// One to many PurgatoryEntry (Amends), PurgatoryEntry (AmendedBy)
builder.HasOne(entry => entry.Amends)
.WithMany()
.HasForeignKey(entry => entry.AmendsKey);
.HasForeignKey(entry => entry.AmendsId);

// One to many PurgatoryEntry (Edits), PurgatoryEntry (AmendedBy)
builder.HasOne(entry => entry.Edits)
.WithMany()
.HasForeignKey(entry => entry.EditsKey);
.HasForeignKey(entry => entry.EditsId);

// Many to one (PoemTags)
builder.HasMany(entry => entry.Tags)
.WithOne(tag => tag.PurgatoryEntry)
.HasForeignKey(tag => tag.EntryKey);
.HasForeignKey(tag => tag.EntryId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public class PurgatoryRatingConfiguration : IEntityTypeConfiguration<PurgatoryRa
{
public void Configure(EntityTypeBuilder<PurgatoryRating> builder)
{
builder.HasKey(rating => rating.RatingKey);
builder.HasKey(rating => rating.Id);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ public class PurgatoryTagConfiguration : IEntityTypeConfiguration<PurgatoryTag>
{
public void Configure(EntityTypeBuilder<PurgatoryTag> builder)
{
builder.HasKey(tag => tag.TagKey);
builder.HasKey(tag => tag.Id);

// One to many (PurgatoryEntry)
builder.HasOne(tag => tag.PurgatoryEntry)
.WithMany(entry => entry.Tags)
.HasForeignKey(tag => tag.EntryKey);
.HasForeignKey(tag => tag.EntryId);
}
}
Loading

0 comments on commit d6e8266

Please sign in to comment.