Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(mmc): add mmc information #35

Merged
merged 1 commit into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added public/images/CreatorJam.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/stylesheets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,8 @@ footer {
clip: rect(0 0 0 0);
clip-path: inset(50%);
overflow: hidden;
}

.mmc h2 img {
width: 1.5em;
}
88 changes: 87 additions & 1 deletion routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ async function handle(type, req, res, next, reqInit = undefined) {
json = preProcess(json, type);
json = addMetadata(type, json, req, reqInit);

if (type =="world") {
json = addMMC(json);
}

res.status(200).render(type, json);
} catch (error) {
console.log(error);
Expand Down Expand Up @@ -204,8 +208,90 @@ function renderCredits(req, res, next) {
const contributorsFile = fs.readFileSync('./.all-contributorsrc');
contributorsJson = JSON.parse(contributorsFile);

console.log(contributorsJson);
return res.render('credits', contributorsJson);
}

var competitionTag = "mmc25"; //TODO: handle years.

var categories = [
{
title: "World Social",
requiredTags: ["world", "social"]
},
{
title: "World Game",
requiredTags: ["world", "game"]
},
{
title: "World Misc",
requiredTags: ["world", "misc"]
},
// Avatars
{
title: "Avatars",
requiredTags: ["avatar", "avatars"]
},
{
title: "Avatar Miscellaneous",
requiredTags: ["avatar", "misc"]
},
// Other
{
title: "Other: Tools, Apps & Utilities",
requiredTags: ["other", "tau"]
},
{
title: "Other: Miscellaneous",
requiredTags: ["other", "misc"]
},
// Single tag categories
{
title: "Art",
requiredTags: ["art"]
},
{
title: "Education, Science and Data Visualization",
requiredTags: ["esd"]
},
{
title: "Meme",
requiredTags: ["meme"]
},
{
title: "Narrative",
requiredTags: ["narrative"]
}
]

function matchCategories(tags) {
var cats = [];
for(const category of categories) {
var entered = category.requiredTags.every(tag => tags.includes(tag));

if (!entered)
continue;

cats.push(category);
}

return cats;
}

function addMMC(worldRecord) {
if (!worldRecord.tags.includes(competitionTag))
return worldRecord;

var categories = matchCategories(worldRecord.tags);

var multipleCategories = categories.length > 1; // IN MULTIPLE BAD

worldRecord.mmc = {
entered:true,
categories,
multipleCategories
}

return worldRecord;
}

export default router;
13 changes: 13 additions & 0 deletions views/mixins/mmc.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mixin mmcMixin(mmcData)
section.mmc
h2
| MMC 2025 Information
img(src='/images/CreatorJam.png')
ul
li ✅ This world is entered into the MMC 2025!
li It is entered into the following Categories:
ul
each category in mmcData.categories
li ✅ !{category.title}
if mmcData.multipleCategories
li ❌ It is entered into more than one category, please fix this!
4 changes: 4 additions & 0 deletions views/world.pug
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
extends layout

include mixins/mmc.pug

block head
meta(property="og:type" content="resonite.world")
meta(property="og:image" content=thumbnailUri)
Expand Down Expand Up @@ -36,3 +38,5 @@ block content
h2.subheading Alternative URLs
ul
li #[strong Record Url:] #{`resrec:///${ownerId}/${id}`}
if mmc
+mmcMixin(mmc)