Skip to content

Commit aaf9361

Browse files
authored
Merge pull request #3 from SeongilHeo/main
Add Photos page, Remove News page
2 parents d6fac8a + ef7af21 commit aaf9361

File tree

19 files changed

+143
-961
lines changed

19 files changed

+143
-961
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ RESEARCH_SHEET=https://docs.google.com/spreadsheets/d/1CPDVN579fjmiVVpo1qVcCeDRU
44
PUBLICATIONS_SHEET=https://docs.google.com/spreadsheets/d/1CPDVN579fjmiVVpo1qVcCeDRUN1BEw_P8n_X12rXVBY/export?format=tsv&gid=698372256
55
VIDEOS_SHEET=https://docs.google.com/spreadsheets/d/1CPDVN579fjmiVVpo1qVcCeDRUN1BEw_P8n_X12rXVBY/export?format=tsv&gid=889428793
66
NEWS_SHEET=https://docs.google.com/spreadsheets/d/1CPDVN579fjmiVVpo1qVcCeDRUN1BEw_P8n_X12rXVBY/export?format=tsv&gid=1018366792
7+
PHOTOS_SHEET=https://docs.google.com/spreadsheets/d/1CPDVN579fjmiVVpo1qVcCeDRUN1BEw_P8n_X12rXVBY/export?format=tsv&gid=1578379541
78
GDRIVE_UA=aria-gdrive-downloader/1.0

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ For more detailed information, please ask to [Seongil Heo](https://github.com/Se
3333
│ ├── robots.txt # Web crawler rules
3434
│ └── images # Image folders
3535
│ ├── placeholder.png # Default placeholder image
36-
│ ├── banner/ # Banner images
36+
│ ├── photos/ # Gallery images
3737
│ ├── people/ # Member profile images
3838
│ ├── publications/ # Publication figures
3939
│ └── videos/ # Video preview thumbnails
File renamed without changes.
File renamed without changes.
File renamed without changes.

scripts/fetch-sheet.js

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ function parseTsv(filePath) {
1313
const content = fs.readFileSync(filePath, 'utf8');
1414
const lines = content.trim().split('\n');
1515
if (lines.length < 2) {
16-
console.error(`No data found in TSV file: ${filePath}`);
17-
process.exit(1);
16+
console.warn(`No data found in TSV file: ${filePath}`);
17+
return [];
1818
}
1919
const headers = lines[0].split('\t').map(h => h.trim());
2020
const data = lines.slice(1).map(line => {
@@ -69,7 +69,7 @@ function preHome(allRecords) {
6969

7070
allRecords.forEach(item => {
7171
if (item.Id === 'BannerImage') {
72-
const filename = path.join("/images/banner", item.Filename)
72+
const filename = path.join("/images/photos", item.Filename)
7373
BannerImages.push(filename);
7474
imageArchive.push({ link: String(item.Url).trim(), out: filename });
7575
} else {
@@ -170,6 +170,18 @@ function preVideos(allRecords) {
170170
return allRecords;
171171
}
172172

173+
function prePhotos(allRecords) {
174+
allRecords.forEach(item => {
175+
if (!item.Image) return;
176+
// Set Image path
177+
item.Image = path.join("/images/photos", item.Filename);
178+
// Collect image archive entry
179+
imageArchive.push({ link: String(item.Url).trim(), out: item.Image });
180+
});
181+
182+
return allRecords;
183+
}
184+
173185
function processHome() {
174186
const tsvPath = path.resolve(__dirname, '../home.tsv');
175187
const outPath = path.resolve(__dirname, '../src/data/home.json');
@@ -218,7 +230,6 @@ function processResearch() {
218230
console.log(`Deleted TSV file: ${tsvPath}`);
219231
}
220232

221-
222233
function processVideos() {
223234
const tsvPath = path.resolve(__dirname, '../videos.tsv');
224235
const outPath = path.resolve(__dirname, '../src/data/videos.json');
@@ -266,19 +277,41 @@ function processNews() {
266277
console.log(`Deleted TSV file: ${tsvPath}`);
267278
}
268279

280+
function processPhotos() {
281+
const tsvPath = path.resolve(__dirname, '../photos.tsv');
282+
const outPath = path.resolve(__dirname, '../src/data/photos.json');
283+
const url = process.env.PHOTOS_SHEET;
284+
if (!url) {
285+
console.error('Environment variable PHOTOS_SHEET not set');
286+
process.exit(1);
287+
}
288+
execSync(`curl -L "${url}" -o "${tsvPath}"`, { stdio: 'inherit' });
289+
const allRecords = parseTsv(tsvPath);
290+
const data = prePhotos(allRecords);
291+
writeJson(outPath, data);
292+
fs.unlinkSync(tsvPath);
293+
console.log(`Deleted TSV file: ${tsvPath}`);
294+
}
295+
269296
function main() {
270297
processHome();
271298
processPeople();
272299
processResearch();
273300
processVideos();
274301
processPublications();
275302
processNews();
303+
processPhotos();
276304

277-
278-
// Write aggregated image archive (if any)
279-
if (imageArchive.length > 0) {
280-
const archivePath = path.resolve(__dirname, 'image-archive.json');
281-
writeJson(archivePath, imageArchive);
305+
const archivePath = path.resolve(__dirname, 'image-archive.json');
306+
// Remove duplicate entries from imageArchive based on 'link' and 'out'
307+
const uniqueArchive = Array.from(
308+
new Map(imageArchive.map(item => [`${item.link}|${item.out}`, item])).values()
309+
);
310+
311+
312+
// Write aggregated image archive
313+
if (uniqueArchive.length > 0) {
314+
writeJson(archivePath, uniqueArchive);
282315
} else {
283316
console.log('No image archive entries found.');
284317
}

scripts/image-archive.json

Lines changed: 0 additions & 142 deletions
This file was deleted.

src/data/home.json

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/data/index.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ import research from './research.json';
44
import publications from './publications.json';
55
import videos from './videos.json';
66
import news from './news.json';
7+
import photos from './photos.json';
78

89
export {
910
home,
1011
people,
1112
research,
1213
publications,
1314
videos,
14-
news
15+
news,
16+
photos
1517
};
1618

src/data/news.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)