diff --git a/app/data/redirects.json b/app/data/redirects.json index 49d9145..e180629 100644 --- a/app/data/redirects.json +++ b/app/data/redirects.json @@ -9,11 +9,11 @@ "/resources/schema": "/spec#metadata", "/resources/signing-claim": "/resources/claim-signing", "/resources/uri": "/spec#urls", - "/resources/video-lbrysdk": "https://spee.ch/967f99344308f1e90f0620d91b6c93e4dfb240e0/lbrynet-dev-setup", + "/resources/video-lbryandroid": "https://spee.ch/e781060bc708247f07afebc02d5f75cfba8e2c4b/video-2018-10-15053403", "/resources/video-lbrycrd": "https://spee.ch/5803b66dca7707584b36fe6b644f278fc39d1adf/intro-to-LBRYcrd", "/resources/video-lbrydesktop": "https://spee.ch/7da73fc508ffc4ff8b2711e3c3950110430b0c5f/LBRYAppDesign", - "/resources/video-lbryandroid": "https://spee.ch/e781060bc708247f07afebc02d5f75cfba8e2c4b/video-2018-10-15053403", - "/tour": "/playground", + "/resources/video-lbrysdk": "https://spee.ch/967f99344308f1e90f0620d91b6c93e4dfb240e0/lbrynet-dev-setup", "/specification": "/spec", + "/tour": "/playground", "/whitepaper": "/spec" } diff --git a/app/dist/scripts/api.js b/app/dist/scripts/api.js index bd279d0..d0a6feb 100644 --- a/app/dist/scripts/api.js +++ b/app/dist/scripts/api.js @@ -60,6 +60,10 @@ handleApiLanguageToggles("python"); // H E L P E R S +function changeDocumentationVersion(value) { + console.log(value); +} + function handleApiLanguageToggles(language) { if (!document.getElementById(`toggle-${language}`)) return; diff --git a/app/modules/relative-date.js b/app/modules/relative-date.js index 2d38cf9..e37647c 100644 --- a/app/modules/relative-date.js +++ b/app/modules/relative-date.js @@ -4,7 +4,7 @@ // P R O G R A M -const relativeDate = (undefined => { +const relativeDate = (() => { const SECOND = 1000; const MINUTE = 60 * SECOND; const HOUR = 60 * MINUTE; @@ -53,6 +53,5 @@ const relativeDate = (undefined => { // E X P O R T -if (typeof module !== "undefined" && module.exports) { +if (typeof module !== "undefined" && module.exports) module.exports = exports = relativeDate; -} diff --git a/app/sass/pages/_api.scss b/app/sass/pages/_api.scss index c131e6f..afc5ae7 100644 --- a/app/sass/pages/_api.scss +++ b/app/sass/pages/_api.scss @@ -55,18 +55,27 @@ } } -.api-toc__search { - position: relative; -} - +.api-toc__select, .api-toc__search-field { width: 100%; - padding: 0.25rem calc(2rem + 4px) 0.25rem 0.75rem; border-top: none; border-right: none; border-bottom: 1px solid $lbry-gray-1; border-left: none; +} + +.api-toc__select { + background-position-x: 95%; +} + +.api-toc__search { + position: relative; +} + +.api-toc__search-field { + padding: 0.25rem calc(2rem + 4px) 0.25rem 0.75rem; + border-radius: 0; // TODO: Put this rule in components on inputs font-size: 0.8rem; line-height: 2rem; diff --git a/app/views/api.js b/app/views/api.js index 934f84e..796ec42 100644 --- a/app/views/api.js +++ b/app/views/api.js @@ -7,6 +7,7 @@ import asyncHtml from "choo-async/html"; import dedent from "dedent"; import got from "got"; +import Octokit from "@octokit/rest"; // U T I L S @@ -14,31 +15,45 @@ import headerBlockchain from "~component/api/header-blockchain"; import headerSdk from "~component/api/header-sdk"; import redirects from "~data/redirects.json"; -const blockchainApi = "https://raw.githubusercontent.com/lbryio/lbrycrd/master/contrib/devtools/generated/api_v1.json"; const cache = new Map(); -const sdkApi = "https://raw.githubusercontent.com/lbryio/lbry-sdk/master/lbry/docs/api.json"; +const filePathBlockchain = "/contrib/devtools/generated/api_v1.json"; +const filePathSdk = "/lbry/docs/api.json"; +const rawGitHubBase = "https://raw.githubusercontent.com/lbryio/"; + +if (!process.env.GITHUB_OAUTH_TOKEN) // No point in rendering this page + throw new Error("Missing GitHub token"); + +const octokit = new Octokit({ + auth: `token ${process.env.GITHUB_OAUTH_TOKEN}` +}); // E X P O R T export default async(state) => { - // below is evil, I just inherited it -- Jeremy - const apilabel = state.params.wildcard === "sdk" ? - "SDK" : - state.params.wildcard.charAt(0).toLocaleUpperCase() + state.params.wildcard.substring(1); - state.lbry = { - title: apilabel + " API Documentation", - description: "See API documentation, signatures, and sample calls for the LBRY " + apilabel + " APIs." + title: "API Documentation", + description: "See API documentation, signatures, and sample calls for the LBRY APIs." }; + const { wildcard } = state.params; + + const repository = wildcard === "sdk" ? + "lbry-sdk" : + "lbrycrd"; + + const tags = await getTags(repository); + try { - const apiResponse = await parseApiFile(state.params.wildcard); + const apiResponse = await parseApiFile({ repo: repository, tag: tags[0] }); return asyncHtml`