Skip to content

Commit

Permalink
quick patch, old galleries are there for debugging just in case
Browse files Browse the repository at this point in the history
  • Loading branch information
svioletg committed May 4, 2024
1 parent 2800211 commit 8028d94
Show file tree
Hide file tree
Showing 10 changed files with 1,675 additions and 151 deletions.
11 changes: 6 additions & 5 deletions bcrmc/gallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ import { extract_number, json } from './utils.js';
function author_from_filename(filename) {
return PHOTO_AUTHORS[filename.split('-')[0]];
}
function create_figure(image_filename, image_title, server_season) {
function create_figure(image_filename, image_title, server_season, has_png) {
var figure_string = FIGURE_TEMPLATE
.replace(/%IMAGE%/g, image_filename)
.replace(/%TITLE%/g, image_title)
.replace(/%SEASON%/g, server_season)
.replace(/%AUTHOR%/g, author_from_filename(image_filename));
.replace(/%AUTHOR%/g, author_from_filename(image_filename))
.replace(/%%HAS_PNG(.*)HAS_PNG%%/g, has_png ? '$1' : '');
return figure_string;
}
function build_gallery(server_season) {
Expand All @@ -55,8 +56,8 @@ import { extract_number, json } from './utils.js';
new_gallery.setAttribute('name', server_season);
// Run through images
for (var _i = 0, _a = Object.entries(PHOTO_TITLES[server_season]); _i < _a.length; _i++) {
var _b = _a[_i], key = _b[0], value = _b[1];
var new_figure = create_figure(key, value, server_season);
var _b = _a[_i], filename = _b[0], attrs = _b[1];
var new_figure = create_figure(filename, attrs.title, server_season, attrs.has_png);
new_gallery.innerHTML += new_figure;
}
// Add it
Expand Down Expand Up @@ -130,7 +131,7 @@ import { extract_number, json } from './utils.js';
case 0:
LATEST_SERVER = 5;
FIGURE_TEMPLATE = "<figure style=\"background-image: url('/bcrmc/%SEASON%/jpg/%IMAGE%.jpg');\">" +
"<figcaption>%TITLE%<a href=\"/bcrmc/%SEASON%/png/%IMAGE%.png\">[PNG]</a>" +
"<figcaption>%TITLE% %%HAS_PNG<a href=\"/bcrmc/%SEASON%/png/%IMAGE%.png\">[PNG]</a>HAS_PNG%%" +
"<br><sup>(from %AUTHOR%)</sup></figcaption></figure>";
PHOTO_AUTHORS = {
"desu": "Desu",
Expand Down
13 changes: 7 additions & 6 deletions bcrmc/gallery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const LATEST_SERVER: number = 5;

// Concatenation for readability, mainly
const FIGURE_TEMPLATE: string = `<figure style="background-image: url('/bcrmc/%SEASON%/jpg/%IMAGE%.jpg');">`+
`<figcaption>%TITLE%<a href="/bcrmc/%SEASON%/png/%IMAGE%.png">[PNG]</a>`+
`<figcaption>%TITLE% %%HAS_PNG<a href="/bcrmc/%SEASON%/png/%IMAGE%.png">[PNG]</a>HAS_PNG%%`+
`<br><sup>(from %AUTHOR%)</sup></figcaption></figure>`

const PHOTO_AUTHORS: { [key: string]: string } = {
Expand All @@ -15,18 +15,19 @@ const PHOTO_AUTHORS: { [key: string]: string } = {
"vi": "Violet"
}

let PHOTO_TITLES: { [key: string]: { [key: string]: string } } = await json('/bcrmc/photo_titles.json');
let PHOTO_TITLES: { [key: string]: object } = await json('/bcrmc/photo_titles.json');

function author_from_filename(filename: string): string {
return PHOTO_AUTHORS[filename.split('-')[0]];
}

function create_figure(image_filename: string, image_title: string, server_season: string): string {
function create_figure(image_filename: string, image_title: string, server_season: string, has_png: boolean): string {
let figure_string: string = FIGURE_TEMPLATE
.replace(/%IMAGE%/g, image_filename)
.replace(/%TITLE%/g, image_title)
.replace(/%SEASON%/g, server_season)
.replace(/%AUTHOR%/g, author_from_filename(image_filename));
.replace(/%AUTHOR%/g, author_from_filename(image_filename))
.replace(/%%HAS_PNG(.*)HAS_PNG%%/g, has_png ? '$1' : '');
return figure_string;
}

Expand All @@ -37,8 +38,8 @@ function build_gallery(server_season: string): void {
new_gallery.setAttribute('name', server_season);

// Run through images
for (const [key, value] of Object.entries(PHOTO_TITLES[server_season])) {
let new_figure: string = create_figure(key, value, server_season);
for (const [filename, attrs] of Object.entries(PHOTO_TITLES[server_season])) {
let new_figure: string = create_figure(filename, attrs.title, server_season, attrs.has_png);
new_gallery.innerHTML += new_figure;
}

Expand Down
Loading

0 comments on commit 8028d94

Please sign in to comment.