MCPcopy Index your code
hub / github.com/Justineo/github-hovercard / getCardHTML

Function getCardHTML

src/hovercard.js:1047–1294  ·  view source on GitHub ↗
(type, raw)

Source from the content-addressed store, hash-verified

1045 }
1046
1047 function getCardHTML(type, raw) {
1048 let data
1049 if (type === EXTRACT_TYPE.USER) {
1050 data = {
1051 avatar: raw.avatar_url,
1052 userUrl: raw.html_url,
1053 loginName: raw.login,
1054 realName: raw.name,
1055 location: raw.location,
1056 isAdmin: raw.site_admin,
1057 isOrg: raw.type === 'Organization',
1058 company: raw.company,
1059 followers: formatNumber(raw.followers),
1060 following: formatNumber(raw.following),
1061 followingMe: raw.following_me,
1062 followedByMe: raw.followed_by_me,
1063 repos: formatNumber(raw.public_repos),
1064 hasSubtitle: raw.name || raw.following_me,
1065 hasMeta: raw.site_admin || raw.type === 'Organization',
1066 hasToken: !!token,
1067 isSelf: raw.login === me,
1068 followersUrl: `//${GH_DOMAIN}/${raw.login}?tab=followers`,
1069 followingUrl: `//${GH_DOMAIN}/${raw.login}?tab=following`,
1070 reposUrl: `//${GH_DOMAIN}/${raw.login}?tab=repositories`,
1071 icons: {
1072 location: getIcon('location', 0.875),
1073 organization: getIcon('organization', 0.875)
1074 },
1075 hasContexts: raw.hovercard && raw.hovercard.length > 0,
1076 contexts: (raw.hovercard || []).map(({ message, octicon }) => {
1077 return {
1078 message,
1079 icon: getIcon(octicon, 0.875)
1080 }
1081 })
1082 }
1083 } else if (type === EXTRACT_TYPE.REPO) {
1084 data = {
1085 owner: raw.owner.login,
1086 ownerAvatar: raw.owner.avatar_url,
1087 ownerUrl: raw.owner.html_url,
1088 repo: raw.name,
1089 repoUrl: raw.html_url,
1090 desc: raw.description
1091 ? compose(
1092 replaceEmoji,
1093 replaceLink
1094 )(encodeHTML`${raw.description}`)
1095 : '',
1096 language: raw.language,
1097 stars: formatNumber(raw.stargazers_count),
1098 forks: formatNumber(raw.forks_count),
1099 issues: formatNumber(raw.open_issues_count),
1100 hasIssues: raw.has_issues,
1101 homepage: raw.homepage
1102 ? raw.homepage.match(/^https?:\/\//)
1103 ? raw.homepage
1104 : `http://${raw.homepage}`

Callers 1

getCardContentFunction · 0.70

Calls 5

formatNumberFunction · 0.70
getIconFunction · 0.70
composeFunction · 0.70
encodeHTMLFunction · 0.70
formatTimeFunction · 0.70

Tested by

no test coverage detected