Skip to content

Commit

Permalink
Merge pull request #192 from Artur-Galstyan/v2.0
Browse files Browse the repository at this point in the history
V2.0
  • Loading branch information
Artur-Galstyan authored Sep 26, 2023
2 parents 7dfe233 + f30d469 commit 81d1571
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion frontend/src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const PUBLIC_REPO_URL = 'Artur-Galstyan/leaderboard';
export const PUBLIC_REPO_URL = 'KGQA/leaderboard';

export const NUMERIC_FIELDS = [
'Accuracy',
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/lib/utils/githubUrlBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
export function getRawGitHubContent(repo: string, path: string, branch: string = 'main'): string {
export function getRawGitHubContent(repo: string, path: string, branch: string = 'v2.0'): string {
const url = `https://raw.githubusercontent.com/${repo}/${branch}/${path}`;
return url;
}

export function getGitHubFilesInFolder(
repo: string,
path: string,
branch: string = 'main',
githubUser: string = 'Artur-Galstyan'
branch: string = 'v2.0',
githubUser: string = 'KGQA'
): string {
const url = `https://api.github.com/repos/${githubUser}/${repo}/contents/${path}?ref=${branch}`;

Expand Down
8 changes: 4 additions & 4 deletions frontend/src/lib/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NUMERIC_FIELDS } from '$lib/constants';
import { NUMERIC_FIELDS, PUBLIC_REPO_URL } from '$lib/constants';
import matter from 'gray-matter';
import { marked } from 'marked';
import { getRawGitHubContent } from '$lib/utils/githubUrlBuilder';
Expand Down Expand Up @@ -197,7 +197,7 @@ async function loadFromGithub(db: string | null, dataset: string | null, systems
let headerPath = systems ? `^systems_updated.md` : `${db}/^${dataset}.md`;
let footerPath = systems ? `$systems_updated.md` : `${db}/$${dataset}.md`;
try {
const githubUrl = getRawGitHubContent(`Artur-Galstyan/leaderboard`, mainPath);
const githubUrl = getRawGitHubContent(PUBLIC_REPO_URL, mainPath);
const githubUrlReq = await fetch(githubUrl);
const githubMarkdownText = await githubUrlReq.text();
const parsed = matter(githubMarkdownText);
Expand All @@ -209,15 +209,15 @@ async function loadFromGithub(db: string | null, dataset: string | null, systems
const htmlContent = marked.parse(parsed.content, { mangle: false, headerIds: false });
const parsedTable = htmlToJson.parse(htmlContent).results[0];

const githubUrlInfo = getRawGitHubContent(`Artur-Galstyan/leaderboard`, headerPath);
const githubUrlInfo = getRawGitHubContent(PUBLIC_REPO_URL, headerPath);
const githubUrlInfoReq = await fetch(githubUrlInfo);
const githubMarkdownTextInfo = await githubUrlInfoReq.text();
const parsedInfo = matter(githubMarkdownTextInfo);
const htmlContentInfo = marked.parse(parsedInfo.content, { mangle: false, headerIds: false });

let htmlFooter = undefined;
try {
const githubUrlFooter = getRawGitHubContent(`Artur-Galstyan/leaderboard`, footerPath);
const githubUrlFooter = getRawGitHubContent(PUBLIC_REPO_URL, footerPath);
const githubUrlFooterReq = await fetch(githubUrlFooter);
if (githubUrlFooterReq.status == 404) {
throw Error('Not found');
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import { base } from '$app/paths';
import { page } from '$app/stores';
import { PUBLIC_REPO_URL } from '$lib/constants';
import { getRawGitHubContent } from '$lib/utils/githubUrlBuilder';
import Fuse from 'fuse.js';
import matter from 'gray-matter';
Expand All @@ -17,7 +18,7 @@
async function load() {
try {
const githubUrl = getRawGitHubContent(`Artur-Galstyan/leaderboard/`, 'README.md');
const githubUrl = getRawGitHubContent(PUBLIC_REPO_URL, 'README.md');
const githubMarkdownTextReq = await fetch(githubUrl);
const githubMarkdownText = await githubMarkdownTextReq.text();
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/routes/datasets/[db]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<script lang="ts">
import { page } from '$app/stores';
import KnowledgeGraphNavbar from '$lib/components/KnowledgeGraphNavbar.svelte';
import { PUBLIC_REPO_URL } from '$lib/constants';
import { getGitHubFilesInFolder, getRawGitHubContent } from '$lib/utils/githubUrlBuilder';
import { marked } from 'marked';
import { onMount } from 'svelte';
Expand All @@ -11,7 +12,7 @@
async function load(params: any) {
try {
const githubUrl = getRawGitHubContent(`Artur-Galstyan/leaderboard`, `${params.db}/README.md`);
const githubUrl = getRawGitHubContent(PUBLIC_REPO_URL, `${params.db}/README.md`);
const githubMarkdownTextReq = await fetch(githubUrl);
const githubMarkdownText = await githubMarkdownTextReq.text();
Expand Down

0 comments on commit 81d1571

Please sign in to comment.