Skip to content

Commit a3bf3ba

Browse files
committed
feat: keep terminal self record outside repository order
1 parent d29512c commit a3bf3ba

1 file changed

Lines changed: 30 additions & 5 deletions

File tree

app.js

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
'use strict';
33

44
var OWNER = 'temesotejam';
5+
var SELF_REPO = 'github-tavern';
56
var API = 'https://api.github.com';
67
var SUMMARY_URL = './data/summaries.json';
78
var TIMEOUT = 8000;
@@ -17,10 +18,11 @@
1718
detailTitle: id('detailTitle'), detailRepo: id('detailRepo'), keeperText: id('keeperText'), detailMeta: id('detailMeta'),
1819
detailDescription: id('detailDescription'), featureSection: id('featureSection'), featureList: id('featureList'),
1920
techSection: id('techSection'), techList: id('techList'), repoLink: id('repoLink'), pagesLink: id('pagesLink'),
20-
summarySource: id('summarySource')
21+
summarySource: id('summarySource'), selfSummary: id('selfSummary'), selfUpdated: id('selfUpdated'),
22+
selfSource: id('selfSource'), selfKeeperRow: id('selfKeeperRow'), selfKeeper: id('selfKeeper'), selfRepoLink: id('selfRepoLink')
2123
};
2224

23-
var state = { repos: [], summaries: {}, category: 'all', query: '', sort: 'updated', selectedRow: 0, pendingRepo: null, liveApi: false };
25+
var state = { repos: [], selfRepo: null, summaries: {}, category: 'all', query: '', sort: 'updated', selectedRow: 0, pendingRepo: null, liveApi: false };
2426

2527
var RULES = [
2628
{ id: 'learning', label: '学習・AI', words: ['reinforcement','learning','ppo','sac','td3','acrobot','cartpole','強化学習','機械学習',' ai '] },
@@ -55,6 +57,29 @@
5557
return fetch(url, opts).finally(function(){ clearTimeout(timer); });
5658
}
5759
function summaryFor(repo) { return state.summaries[repo.name] || null; }
60+
function setRepos(list) {
61+
var archive = [];
62+
var self = null;
63+
(list || []).forEach(function(repo){
64+
if (repo && repo.name === SELF_REPO) self = repo;
65+
else if (repo) archive.push(repo);
66+
});
67+
if (self) state.selfRepo = self;
68+
state.repos = archive;
69+
}
70+
function renderSelf() {
71+
var s = state.summaries[SELF_REPO] || {};
72+
var repo = state.selfRepo || {};
73+
var summary = s.summary || repo.description || 'Project Tavernは、公開GitHubリポジトリを古い情報端末のように探索するためのアーカイブ端末だ。';
74+
var updated = repo.pushed_at || repo.updated_at || s.sourcePushedAt || s.generatedAt || '';
75+
els.selfSummary.textContent = summary;
76+
els.selfUpdated.textContent = 'UPDATED ' + fmtDate(updated);
77+
els.selfSource.textContent = s.summary ? 'COPILOT ANALYSIS / ' + fmtDate(s.generatedAt) : 'REPOSITORY METADATA';
78+
els.selfRepoLink.href = repo.html_url || ('https://github.com/' + OWNER + '/' + SELF_REPO);
79+
var closing = String(s.closingRemark || '').trim();
80+
els.selfKeeperRow.hidden = !closing;
81+
els.selfKeeper.textContent = closing;
82+
}
5883
function textFor(repo) {
5984
var s = summaryFor(repo) || {};
6085
return [repo.name, repo.description, repo.language].concat(repo.topics || [], [s.title,s.summary,s.detail], s.technologies || [], s.categories || []).filter(Boolean).join(' ').toLowerCase();
@@ -297,14 +322,14 @@
297322
var liveError=null;
298323
var livePromise=fetchLive().catch(function(e){liveError=e;return null;});
299324
fetchCache().then(function(data){
300-
state.summaries=data.repositories||{}; state.repos=reposFromCache(data); status('CACHE'); renderRepos();
325+
state.summaries=data.repositories||{}; setRepos(reposFromCache(data)); renderSelf(); status('CACHE'); renderRepos();
301326
return livePromise;
302327
}).then(function(live){
303-
if(live&&live.length){state.repos=live;state.liveApi=true;status('LIVE API');renderRepos();}
328+
if(live&&live.length){setRepos(live);state.liveApi=true;renderSelf();status('LIVE API');renderRepos();}
304329
else if(state.repos.length){status(liveError&&liveError.name==='AbortError'?'API TIMEOUT / CACHE':'API UNAVAILABLE / CACHE');}
305330
}).catch(function(err){
306331
livePromise.then(function(live){
307-
if(live&&live.length){state.repos=live;state.liveApi=true;status('LIVE API / SUMMARY unavailable');renderRepos();}
332+
if(live&&live.length){setRepos(live);state.liveApi=true;renderSelf();status('LIVE API / SUMMARY unavailable');renderRepos();}
308333
else {els.notice.classList.add('is-error');els.noticeText.textContent='記録を取得できませんでした: '+err.message;els.count.textContent='0 RECORDS';els.grid.innerHTML='';}
309334
});
310335
});

0 commit comments

Comments
 (0)