Skip to content

Commit

Permalink
feat: change osgraph api (#941)
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyantong2000 authored Jan 18, 2025
1 parent 4decf0e commit 5d87114
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
15 changes: 10 additions & 5 deletions src/pages/ContentScripts/features/developer-networks/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ const logoStyle = {
};

const baseOSGraphUrls = {
developmentActivityNetwork: 'https://osgraph.com/graphs/dev-activity/github/{userName}?repo-limit=10',
openSourcePartnersNetwork: 'https://osgraph.com/graphs/dev-partner/github/{userName}?partner-limit=10',
openSourceInterestsNetwork: 'https://osgraph.com/graphs/dev-interest/github/{userName}?repo-limit=3&topic-limit=5',
developmentActivityNetwork:
'https://osgraph.com/graphs/developer-activity/github/{userName}?lang={lang}&user-limit=10',
openSourcePartnersNetwork: 'https://osgraph.com/graphs/os-partner/github/{userName}?lang={lang}&user-limit=10',
openSourceInterestsNetwork:
'https://osgraph.com/graphs/os-interest/github/{userName}?lang={lang}&repo-limit=3&topic-limit=5',
};
const View = ({ userName }: Props): JSX.Element => {
const [options, setOptions] = useState<HypercrxOptions>(defaults);
Expand All @@ -34,14 +36,17 @@ const View = ({ userName }: Props): JSX.Element => {
const { t, i18n } = useTranslation();
const osGraphLogo = chrome.runtime.getURL('osGraphLogo.png');
const OSGraphUrls = Object.fromEntries(
Object.entries(baseOSGraphUrls).map(([key, url]) => [key, url.replace('{userName}', userName)])
Object.entries(baseOSGraphUrls).map(([key, url]) => [
key,
url.replace('{userName}', userName).replace('{lang}', i18n.language == 'en' ? 'en-US' : 'zh-CN'),
])
);
useEffect(() => {
(async function () {
setOptions(await optionsStorage.getAll());
i18n.changeLanguage(options.locale);
})();
}, [options.locale]);

return (
<div className="border-top color-border-secondary pt-3 mt-3">
<h2 className="h4 mb-2">Perceptor</h2>
Expand Down
13 changes: 9 additions & 4 deletions src/pages/ContentScripts/features/repo-networks/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,22 @@ const logoStyle = {
marginRight: '50px',
marginTop: '5px',
};

const baseOSGraphUrls = {
projectContributionNetwork: 'https://osgraph.com/graphs/repo-contrib/github/{repoName}?contrib-limit=10',
projectEcosystemNetwork: 'https://osgraph.com/graphs/repo-eco/github/{repoName}?repo-limit=10',
projectContributionNetwork:
'https://osgraph.com/graphs/project-contribution/github/{repoName}?lang={lang}&repo-limit=10',
projectEcosystemNetwork: 'https://osgraph.com/graphs/project-ecosystem/github/{repoName}?lang={lang}&repo-limit=10',
projectCommunityNetwork:
'https://osgraph.com/graphs/repo-community/github/{repoName}?country-limit=5&org-limit=5&contrib-limit=3',
'https://osgraph.com/graphs/project-community/github/{repoName}?lang={lang}&country-limit=5&company-limit=5&user-limit=3',
};
const View = ({ repoName }: Props): JSX.Element => {
const [options, setOptions] = useState<HypercrxOptions>(defaults);
const { t, i18n } = useTranslation();
const OSGraphUrls = Object.fromEntries(
Object.entries(baseOSGraphUrls).map(([key, url]) => [key, url.replace('{repoName}', repoName)])
Object.entries(baseOSGraphUrls).map(([key, url]) => [
key,
url.replace('{repoName}', repoName).replace('{lang}', i18n.language == 'en' ? 'en-US' : 'zh-CN'),
])
);
const osGraphLogo = chrome.runtime.getURL('osGraphLogo.png');
useEffect(() => {
Expand Down

0 comments on commit 5d87114

Please sign in to comment.