forked from mirrored/github-readme-stats
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c624fe9507 | ||
|
|
bcda6ce01e | ||
|
|
af041ba9b8 | ||
|
|
a7d3aaa7b4 | ||
|
|
1617c3fb22 |
@@ -1,33 +0,0 @@
|
||||
{
|
||||
"name": "GitHub Readme Stats Dev",
|
||||
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/node:1": { "version": "22" }
|
||||
},
|
||||
"forwardPorts": [3000],
|
||||
"portsAttributes": {
|
||||
"3000": { "label": "HTTP" }
|
||||
},
|
||||
"appPort": [],
|
||||
|
||||
// Use 'postCreateCommand' to run commands after the container is created.
|
||||
"postCreateCommand": "npm install -g vercel",
|
||||
|
||||
// Use 'postStartCommand' to run commands after the container is started.
|
||||
"postStartCommand": "hostname dev && npm install",
|
||||
|
||||
// Configure tool-specific properties.
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"yzhang.markdown-all-in-one",
|
||||
"esbenp.prettier-vscode",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"github.vscode-github-actions"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
"remoteUser": "root",
|
||||
"privileged": true
|
||||
}
|
||||
-234
@@ -1,234 +0,0 @@
|
||||
// {
|
||||
// "env": {
|
||||
// "node": true,
|
||||
// "browser": true,
|
||||
// "es2021": true
|
||||
// },
|
||||
// "extends": [
|
||||
// // "eslint:recommended",
|
||||
// "prettier"
|
||||
// ],
|
||||
// "parserOptions": {
|
||||
// "sourceType": "module",
|
||||
// "ecmaVersion": 2022
|
||||
// },
|
||||
// "rules": {
|
||||
// // Possible Errors (overrides from recommended set)
|
||||
|
||||
// // "no-extra-parens": "error",
|
||||
// "no-unexpected-multiline": "error",
|
||||
|
||||
// // All JSDoc comments must be valid
|
||||
|
||||
// "valid-jsdoc": [ "error", {
|
||||
// "requireReturn": true,
|
||||
// "requireReturnDescription": true,
|
||||
// "requireParamDescription": true,
|
||||
// "prefer": {
|
||||
// "return": "returns"
|
||||
// }
|
||||
// }],
|
||||
|
||||
// // Best Practices
|
||||
|
||||
// // Allowed a getter without setter, but all setters require getters
|
||||
|
||||
// "accessor-pairs": [ "error", {
|
||||
// "getWithoutSet": false,
|
||||
// "setWithoutGet": true
|
||||
// }],
|
||||
// "block-scoped-var": "warn",
|
||||
// "consistent-return": "error",
|
||||
// "curly": "error",
|
||||
// // "default-case": "warn",
|
||||
|
||||
// // the dot goes with the property when doing multiline
|
||||
|
||||
// // "dot-location": [ "warn", "property" ],
|
||||
// // "dot-notation": "warn",
|
||||
// // "eqeqeq": [ "error", "smart" ],
|
||||
// // "guard-for-in": "warn",
|
||||
// "no-alert": "error",
|
||||
// "no-caller": "error",
|
||||
// // "no-case-declarations": "warn",
|
||||
// // "no-div-regex": "warn",
|
||||
// // "no-else-return": "warn",
|
||||
// // "no-empty-label": "warn",
|
||||
// // "no-empty-pattern": "warn",
|
||||
// // "no-eq-null": "warn",
|
||||
// // "no-eval": "error",
|
||||
// // "no-extend-native": "error",
|
||||
// // "no-extra-bind": "warn",
|
||||
// // "no-floating-decimal": "warn",
|
||||
// // "no-implicit-coercion": [ "warn", {
|
||||
// // "boolean": true,
|
||||
// // "number": true,
|
||||
// // "string": true
|
||||
// // }],
|
||||
// // "no-implied-eval": "error",
|
||||
// // "no-invalid-this": "error",
|
||||
// // "no-iterator": "error",
|
||||
// // "no-labels": "warn",
|
||||
// // "no-lone-blocks": "warn",
|
||||
// // "no-loop-func": "error",
|
||||
// // "no-magic-numbers": "warn",
|
||||
// // "no-multi-spaces": "error",
|
||||
// // "no-multi-str": "warn",
|
||||
// // "no-native-reassign": "error",
|
||||
// // "no-new-func": "error",
|
||||
// // "no-new-wrappers": "error",
|
||||
// // "no-new": "error",
|
||||
// // "no-octal-escape": "error",
|
||||
// // "no-param-reassign": "error",
|
||||
// // "no-process-env": "warn",
|
||||
// // "no-proto": "error",
|
||||
// // "no-redeclare": "error",
|
||||
// // "no-return-assign": "error",
|
||||
// // "no-script-url": "error",
|
||||
// // "no-self-compare": "error",
|
||||
// // "no-throw-literal": "error",
|
||||
// // "no-unused-expressions": "error",
|
||||
// // "no-useless-call": "error",
|
||||
// // "no-useless-concat": "error",
|
||||
// // "no-void": "warn",
|
||||
|
||||
// // Produce warnings when something is commented as TODO or FIXME
|
||||
|
||||
// "no-warning-comments": [ "warn", {
|
||||
// "terms": [ "TODO", "FIXME" ],
|
||||
// "location": "start"
|
||||
// }],
|
||||
// "no-with": "warn",
|
||||
// "radix": "warn",
|
||||
// // "vars-on-top": "error",
|
||||
|
||||
// // Enforces the style of wrapped functions
|
||||
// // "wrap-iife": [ "error", "outside" ],
|
||||
// // "yoda": "error",
|
||||
|
||||
// // Strict Mode - for ES6, never use strict.
|
||||
// // "strict": [ "error", "never" ],
|
||||
|
||||
// // Variables
|
||||
|
||||
// // "init-declarations": [ "error", "always" ],
|
||||
// // "no-catch-shadow": "warn",
|
||||
// "no-delete-var": "error",
|
||||
// // "no-label-var": "error",
|
||||
// // "no-shadow-restricted-names": "error",
|
||||
// // "no-shadow": "warn",
|
||||
|
||||
// // We require all vars to be initialized (see init-declarations)
|
||||
// // If we NEED a var to be initialized to undefined, it needs to be explicit
|
||||
|
||||
// "no-undef-init": "off",
|
||||
// "no-undef": "error",
|
||||
// "no-undefined": "off",
|
||||
// "no-unused-vars": "warn",
|
||||
|
||||
// // Disallow hoisting - let & const don't allow hoisting anyhow
|
||||
|
||||
// "no-use-before-define": "error",
|
||||
|
||||
// // Node.js and CommonJS
|
||||
|
||||
// // "callback-return": [ "warn", [ "callback", "next" ]],
|
||||
// // "global-require": "error",
|
||||
// // "handle-callback-err": "warn",
|
||||
// // "no-mixed-requires": "warn",
|
||||
// // "no-new-require": "error",
|
||||
|
||||
// // Use path.concat instead
|
||||
|
||||
// // "no-path-concat": "error",
|
||||
// // "no-process-exit": "error",
|
||||
// // "no-restricted-modules": "off",
|
||||
// // "no-sync": "warn",
|
||||
|
||||
// // ECMAScript 6 support
|
||||
|
||||
// // "arrow-body-style": [ "error", "always" ],
|
||||
// // "arrow-parens": [ "error", "always" ],
|
||||
// // "arrow-spacing": [ "error", { "before": true, "after": true }],
|
||||
// "constructor-super": "error",
|
||||
// // "generator-star-spacing": [ "error", "before" ],
|
||||
// // "no-arrow-condition": "error",
|
||||
// "no-class-assign": "error",
|
||||
// "no-const-assign": "error",
|
||||
// "no-dupe-class-members": "error",
|
||||
// "no-this-before-super": "error",
|
||||
// // "no-var": "warn",
|
||||
// "object-shorthand": [ "warn" ],
|
||||
// // "prefer-arrow-callback": "warn",
|
||||
// // "prefer-spread": "warn",
|
||||
// // "prefer-template": "warn",
|
||||
// // "require-yield": "error",
|
||||
|
||||
// // Stylistic - everything here is a warning because of style.
|
||||
|
||||
// // "array-bracket-spacing": [ "warn", "always" ],
|
||||
// // "block-spacing": [ "warn", "always" ],
|
||||
// // "brace-style": [ "warn", "1tbs", { "allowSingleLine": false } ],
|
||||
// // "camelcase": "warn",
|
||||
// // "comma-spacing": [ "warn", { "before": false, "after": true } ],
|
||||
// // "comma-style": [ "warn", "last" ],
|
||||
// // "computed-property-spacing": [ "warn", "never" ],
|
||||
// // "consistent-this": [ "warn", "self" ],
|
||||
// // "eol-last": "warn",
|
||||
// // "func-names": "warn",
|
||||
// // "func-style": [ "warn", "declaration" ],
|
||||
// // "id-length": [ "warn", { "min": 2, "max": 32 } ],
|
||||
// // "indent": [ "warn", 4 ],
|
||||
// // "jsx-quotes": [ "warn", "prefer-double" ],
|
||||
// // "linebreak-style": [ "warn", "unix" ],
|
||||
// // "lines-around-comment": [ "warn", { "beforeBlockComment": true } ],
|
||||
// // "max-depth": [ "warn", 8 ],
|
||||
// // "max-len": [ "warn", 132 ],
|
||||
// // "max-nested-callbacks": [ "warn", 8 ],
|
||||
// // "max-params": [ "warn", 8 ],
|
||||
// // "new-cap": "warn",
|
||||
// // "new-parens": "warn",
|
||||
// // "no-array-constructor": "warn",
|
||||
// // "no-bitwise": "off",
|
||||
// // "no-continue": "off",
|
||||
// // "no-inline-comments": "off",
|
||||
// // "no-lonely-if": "warn",
|
||||
// "no-mixed-spaces-and-tabs": "warn",
|
||||
// "no-multiple-empty-lines": "warn",
|
||||
// "no-negated-condition": "warn",
|
||||
// // "no-nested-ternary": "warn",
|
||||
// // "no-new-object": "warn",
|
||||
// // "no-plusplus": "off",
|
||||
// // "no-spaced-func": "warn",
|
||||
// // "no-ternary": "off",
|
||||
// // "no-trailing-spaces": "warn",
|
||||
// // "no-underscore-dangle": "warn",
|
||||
// "no-unneeded-ternary": "warn",
|
||||
// // "object-curly-spacing": [ "warn", "always" ],
|
||||
// // "one-var": "off",
|
||||
// // "operator-assignment": [ "warn", "never" ],
|
||||
// // "operator-linebreak": [ "warn", "after" ],
|
||||
// // "padded-blocks": [ "warn", "never" ],
|
||||
// // "quote-props": [ "warn", "consistent-as-needed" ],
|
||||
// // "quotes": [ "warn", "single" ],
|
||||
// "require-jsdoc": [ "warn", {
|
||||
// "require": {
|
||||
// "FunctionDeclaration": true,
|
||||
// "MethodDefinition": true,
|
||||
// "ClassDeclaration": false
|
||||
// }
|
||||
// }],
|
||||
// // "semi-spacing": [ "warn", { "before": false, "after": true }],
|
||||
// // "semi": [ "error", "always" ],
|
||||
// // "sort-vars": "off",
|
||||
// "keyword-spacing": ["error", { "before": true, "after": true }]
|
||||
// // "space-before-blocks": [ "warn", "always" ],
|
||||
// // "space-before-function-paren": [ "warn", "never" ],
|
||||
// // "space-in-parens": [ "warn", "never" ],
|
||||
// // "space-infix-ops": [ "warn", { "int32Hint": true } ],
|
||||
// // "space-return-throw-case": "error",
|
||||
// // "space-unary-ops": "error",
|
||||
// // "spaced-comment": [ "warn", "always" ],
|
||||
// // "wrap-regex": "warn"
|
||||
// }
|
||||
// }
|
||||
@@ -0,0 +1 @@
|
||||
dist/* linguist-vendored=false
|
||||
@@ -1,36 +0,0 @@
|
||||
name: Push Develop
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'main'
|
||||
- 'develop'
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: docker/Dockerfile
|
||||
# for this project, we keep docker in its own folder, to keep it isolated from upstream
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: |
|
||||
${{ vars.DOCKERHUB_TARGET }}:develop
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
name: Push Docker
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '*-*-*'
|
||||
# for this project, we do "YYYY-MM-DD" for version numbers, due to unversioned upstream
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build image
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: docker/Dockerfile
|
||||
# for this project, we keep docker in its own folder, to keep it isolated from upstream
|
||||
push: true
|
||||
platforms: linux/amd64,linux/arm64
|
||||
tags: |
|
||||
${{ vars.DOCKERHUB_TARGET }}:latest
|
||||
${{ vars.DOCKERHUB_TARGET }}:${{ github.ref_name }}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
name: Sync GitHub
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
|
||||
jobs:
|
||||
sync:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Configure Git
|
||||
run: |
|
||||
git config --global user.name "Andrew Sync"
|
||||
git config --global user.email "sync@digitaladapt.com"
|
||||
|
||||
- name: Add GitHub Remote
|
||||
env:
|
||||
SYNC_TOKEN: ${{ secrets.SYNC_GITHUB_TOKEN }}
|
||||
SYNC_TARGET: ${{ vars.SYNC_GITHUB_TARGET }}
|
||||
run: |
|
||||
git remote add github "https://digitaladapt:${SYNC_TOKEN}@github.com/$SYNC_TARGET"
|
||||
|
||||
- name: Push Current Branch
|
||||
run: |
|
||||
git push github HEAD:${GITHUB_REF_NAME}
|
||||
|
||||
- name: Push Tags
|
||||
run: |
|
||||
git push github --tags
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
# This file is used to define code owners for the repository.
|
||||
# Code owners are automatically requested for review when someone opens a pull request that modifies code they own.
|
||||
|
||||
# Assign @qwerty541 as the owner for package.json and package-lock.json
|
||||
package.json @qwerty541
|
||||
package-lock.json @qwerty541
|
||||
@@ -0,0 +1,43 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ""
|
||||
labels: ""
|
||||
assignees: ""
|
||||
---
|
||||
<!--PLEASE FIRST READ THE FAQ (#1770) AND COMMON ERROR CODES (#1772)!!!-->
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**Expected behaviour**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots / Live demo link (paste the github-readme-stats link as markdown image)**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
||||
|
||||
<!-- FAQ
|
||||
Below are some questions that are found in the FAQ. The full FAQ can be found in #1770.
|
||||
|
||||
Q: My card displays an error
|
||||
Ans: First, check the common error codes (i.e. https://github.com/anuraghazra/github-readme-stats/issues/1772) and existing issues before creating a new one.
|
||||
|
||||
Q: How to hide jupyter Notebook?
|
||||
Ans: &hide=jupyter%20notebook
|
||||
|
||||
Q: I could not figure out how to deploy on my own vercel instance
|
||||
Ans:
|
||||
- docs: https://github.com/anuraghazra/github-readme-stats/#deploy-on-your-own-vercel-instance
|
||||
- YT tutorial by codeSTACKr: https://www.youtube.com/watch?v=n6d4KHSKqGk&feature=youtu.be&t=107
|
||||
|
||||
Q: Language Card is incorrect
|
||||
Ans: Please read all the issues/comments before opening any issues regarding language card stats:
|
||||
- https://github.com/anuraghazra/github-readme-stats/issues/136#issuecomment-665164174
|
||||
- https://github.com/anuraghazra/github-readme-stats/issues/136#issuecomment-665172181
|
||||
|
||||
Q: How to count private stats?
|
||||
Ans: We can only count private commits & we cannot access any other private info of any users, so it's impossible. The only way is to deploy on your own instance & use your own PAT (Personal Access Token)
|
||||
-->
|
||||
@@ -1,60 +0,0 @@
|
||||
name: Bug report
|
||||
description: Create a report to help us improve.
|
||||
labels:
|
||||
- "bug"
|
||||
body:
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
:warning: PLEASE FIRST READ THE FAQ [(#1770)](https://github.com/anuraghazra/github-readme-stats/discussions/1770) AND COMMON ERROR CODES [(#1772)](https://github.com/anuraghazra/github-readme-stats/issues/1772)!!!
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Describe the bug
|
||||
description: A clear and concise description of what the bug is.
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Expected behavior
|
||||
description:
|
||||
A clear and concise description of what you expected to happen.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Screenshots / Live demo link
|
||||
description: If applicable, add screenshots to help explain your problem.
|
||||
placeholder: Paste the github-readme-stats link as markdown image
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Additional context
|
||||
description: Add any other context about the problem here.
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
---
|
||||
### FAQ (Snippet)
|
||||
|
||||
Below are some questions that are found in the FAQ. The full FAQ can be found in [#1770](https://github.com/anuraghazra/github-readme-stats/discussions/1770).
|
||||
|
||||
#### Q: My card displays an error
|
||||
|
||||
**Ans:** First, check the common error codes (i.e. https://github.com/anuraghazra/github-readme-stats/issues/1772) and existing issues before creating a new one.
|
||||
|
||||
#### Q: How to hide jupyter Notebook?
|
||||
|
||||
**Ans:** `&hide=jupyter%20notebook`.
|
||||
|
||||
#### Q: I could not figure out how to deploy on my own vercel instance
|
||||
|
||||
**Ans:** Please check:
|
||||
- Docs: https://github.com/anuraghazra/github-readme-stats/#deploy-on-your-own-vercel-instance
|
||||
- YT tutorial by codeSTACKr: https://www.youtube.com/watch?v=n6d4KHSKqGk&feature=youtu.be&t=107
|
||||
|
||||
#### Q: Language Card is incorrect
|
||||
|
||||
**Ans:** Please read these issues/comments before opening any issues regarding language card stats:
|
||||
- https://github.com/anuraghazra/github-readme-stats/issues/136#issuecomment-665164174
|
||||
- https://github.com/anuraghazra/github-readme-stats/issues/136#issuecomment-665172181
|
||||
|
||||
#### Q: How to count private stats?
|
||||
|
||||
**Ans:** We can only count private commits & we cannot access any other private info of any users, so it's impossible. The only way is to deploy on your own instance & use your own PAT (Personal Access Token).
|
||||
@@ -1,12 +0,0 @@
|
||||
blank_issues_enabled: true
|
||||
contact_links:
|
||||
- name: Question
|
||||
url: https://github.com/anuraghazra/github-readme-stats/discussions
|
||||
about: Please ask and answer questions here.
|
||||
- name: Error
|
||||
url: https://github.com/anuraghazra/github-readme-stats/issues/1772
|
||||
about:
|
||||
Before opening a bug report, please check the 'Common Error Codes' issue.
|
||||
- name: FAQ
|
||||
url: https://github.com/anuraghazra/github-readme-stats/discussions/1770
|
||||
about: Please first check the FAQ before asking a question.
|
||||
@@ -0,0 +1,41 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ""
|
||||
labels: ""
|
||||
assignees: ""
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
|
||||
<!--
|
||||
|
||||
PLEASE READ THE FAQs!!!
|
||||
|
||||
Q: How to hide jupyter Notebook?
|
||||
Ans: &hide=jupyter%20notebook
|
||||
|
||||
Q: I could not figure out how to deploy on my own vercel instance
|
||||
Ans:
|
||||
- docs: https://github.com/anuraghazra/github-readme-stats/#deploy-on-your-own-vercel-instance
|
||||
- YT tutorial by codeSTACKr: https://www.youtube.com/watch?v=n6d4KHSKqGk&feature=youtu.be&t=107
|
||||
|
||||
Q: Language Card is incorrect
|
||||
Ans: Please read all the issues / comments before opening any issues regarding language card stats:
|
||||
- https://github.com/anuraghazra/github-readme-stats/issues/136#issuecomment-665164174
|
||||
- https://github.com/anuraghazra/github-readme-stats/issues/136#issuecomment-665172181
|
||||
|
||||
Q: How to count private stats?
|
||||
Ans: We can only count private commits & we cannot access any other private info of any users, so it's not possible. only way is to deploy on your own instance & use your own PAT (Personal Access Token)
|
||||
|
||||
-->
|
||||
@@ -1,28 +0,0 @@
|
||||
name: Feature request
|
||||
description: Suggest an idea for this project.
|
||||
labels:
|
||||
- "enhancement"
|
||||
body:
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Is your feature request related to a problem? Please describe.
|
||||
description:
|
||||
A clear and concise description of what the problem is. Ex. I'm always
|
||||
frustrated when [...]
|
||||
validations:
|
||||
required: true
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Describe the solution you'd like
|
||||
description: A clear and concise description of what you want to happen.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Describe alternatives you've considered
|
||||
description:
|
||||
A clear and concise description of any alternative solutions or features
|
||||
you've considered.
|
||||
- type: textarea
|
||||
attributes:
|
||||
label: Additional context
|
||||
description:
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -1,31 +0,0 @@
|
||||
version: 2
|
||||
updates:
|
||||
# Maintain dependencies for npm
|
||||
- package-ecosystem: npm
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
open-pull-requests-limit: 10
|
||||
commit-message:
|
||||
prefix: "build(deps)"
|
||||
prefix-development: "build(deps-dev)"
|
||||
|
||||
# Maintain dependencies for GitHub Actions
|
||||
- package-ecosystem: github-actions
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
open-pull-requests-limit: 10
|
||||
commit-message:
|
||||
prefix: "ci(deps)"
|
||||
prefix-development: "ci(deps-dev)"
|
||||
|
||||
# Maintain dependencies for Devcontainers
|
||||
- package-ecosystem: devcontainers
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: weekly
|
||||
open-pull-requests-limit: 10
|
||||
commit-message:
|
||||
prefix: "build(deps)"
|
||||
prefix-development: "build(deps-dev)"
|
||||
+3
-90
@@ -1,90 +1,3 @@
|
||||
themes:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- themes/index.js
|
||||
|
||||
card-i18n:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- src/translations.js
|
||||
- src/common/I18n.js
|
||||
|
||||
documentation:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- readme.md
|
||||
- CONTRIBUTING.md
|
||||
- CODE_OF_CONDUCT.md
|
||||
- SECURITY.md
|
||||
|
||||
dependencies:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- package.json
|
||||
- package-lock.json
|
||||
|
||||
lang-card:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- api/top-langs.js
|
||||
- src/cards/top-languages.js
|
||||
- src/fetchers/top-languages.js
|
||||
- tests/fetchTopLanguages.test.js
|
||||
- tests/renderTopLanguagesCard.test.js
|
||||
- tests/top-langs.test.js
|
||||
|
||||
repo-card:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- api/pin.js
|
||||
- src/cards/repo.js
|
||||
- src/fetchers/repo.js
|
||||
- tests/fetchRepo.test.js
|
||||
- tests/renderRepoCard.test.js
|
||||
- tests/pin.test.js
|
||||
|
||||
stats-card:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- api/index.js
|
||||
- src/cards/stats.js
|
||||
- src/fetchers/stats.js
|
||||
- tests/fetchStats.test.js
|
||||
- tests/renderStatsCard.test.js
|
||||
- tests/api.test.js
|
||||
|
||||
wakatime-card:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- api/wakatime.js
|
||||
- src/cards/wakatime.js
|
||||
- src/fetchers/wakatime.js
|
||||
- tests/fetchWakatime.test.js
|
||||
- tests/renderWakatimeCard.test.js
|
||||
- tests/wakatime.test.js
|
||||
|
||||
gist-card:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- api/gist.js
|
||||
- src/cards/gist.js
|
||||
- src/fetchers/gist.js
|
||||
- tests/fetchGist.test.js
|
||||
- tests/renderGistCard.test.js
|
||||
- tests/gist.test.js
|
||||
|
||||
ranks:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- src/calculateRank.js
|
||||
|
||||
ci:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- .github/workflows/*
|
||||
- scripts/*
|
||||
|
||||
infrastructure:
|
||||
- changed-files:
|
||||
- any-glob-to-any-file:
|
||||
- .eslintrc.json
|
||||
themes: themes/index.js
|
||||
doc-translation: docs/*
|
||||
card-i18n: src/translations.js
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
name: "Static code analysis workflow (CodeQL)"
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
checks: read
|
||||
contents: read
|
||||
deployments: read
|
||||
issues: read
|
||||
discussions: read
|
||||
packages: read
|
||||
pages: read
|
||||
pull-requests: read
|
||||
repository-projects: read
|
||||
security-events: write
|
||||
statuses: read
|
||||
|
||||
jobs:
|
||||
CodeQL-Build:
|
||||
if: github.repository == 'anuraghazra/github-readme-stats'
|
||||
|
||||
# CodeQL runs on ubuntu-latest, windows-latest, and macos-latest
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@46a6823b81f2d7c67ddf123851eea88365bc8a67 # v2.13.5
|
||||
with:
|
||||
languages: javascript
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@46a6823b81f2d7c67ddf123851eea88365bc8a67 # v2.13.5
|
||||
@@ -1,10 +0,0 @@
|
||||
import os
|
||||
|
||||
file = open('./vercel.json', 'r')
|
||||
str = file.read()
|
||||
file = open('./vercel.json', 'w')
|
||||
|
||||
str = str.replace('"maxDuration": 10', '"maxDuration": 15')
|
||||
|
||||
file.write(str)
|
||||
file.close()
|
||||
@@ -1,20 +0,0 @@
|
||||
name: Deployment Prep
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
config:
|
||||
if: github.repository == 'anuraghazra/github-readme-stats'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
- name: Deployment Prep
|
||||
run: python ./.github/workflows/deploy-prep.py
|
||||
- uses: stefanzweifel/git-auto-commit-action@28e16e81777b558cc906c8750092100bbb34c5e3 # v7.0.0
|
||||
with:
|
||||
branch: vercel
|
||||
create_branch: true
|
||||
push_options: "--force"
|
||||
@@ -1,31 +1,23 @@
|
||||
name: Test Deployment
|
||||
on:
|
||||
# Temporarily disabled automatic triggers; manual-only for now.
|
||||
workflow_dispatch:
|
||||
# Original trigger (restore to re-enable):
|
||||
# deployment_status:
|
||||
|
||||
permissions: read-all
|
||||
deployment_status:
|
||||
|
||||
jobs:
|
||||
e2eTests:
|
||||
# Temporarily disabled; set to the original condition to re-enable.
|
||||
# if:
|
||||
# github.repository == 'anuraghazra/github-readme-stats' &&
|
||||
# github.event_name == 'deployment_status' &&
|
||||
# github.event.deployment_status.state == 'success'
|
||||
if: false
|
||||
name: Perform e2e tests
|
||||
if:
|
||||
github.event_name == 'deployment_status' &&
|
||||
github.event.deployment_status.state == 'success'
|
||||
name: Perform 2e2 tests
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [22.x]
|
||||
node-version: [16.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
@@ -37,5 +29,5 @@ jobs:
|
||||
|
||||
- name: Run end-to-end tests.
|
||||
run: npm run test:e2e
|
||||
# env:
|
||||
# VERCEL_PREVIEW_URL: ${{ github.event.deployment_status.target_url }}
|
||||
env:
|
||||
VERCEL_PREVIEW_URL: ${{ github.event.deployment_status.target_url }}
|
||||
|
||||
+2
-18
@@ -6,31 +6,15 @@ on:
|
||||
- opened
|
||||
- edited
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
checks: read
|
||||
contents: read
|
||||
deployments: read
|
||||
issues: write
|
||||
discussions: read
|
||||
packages: read
|
||||
pages: read
|
||||
pull-requests: read
|
||||
repository-projects: read
|
||||
security-events: read
|
||||
statuses: read
|
||||
|
||||
jobs:
|
||||
closeEmptyIssuesAndTemplates:
|
||||
if: github.repository == 'anuraghazra/github-readme-stats'
|
||||
name: Close empty issues
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
# NOTE: Retrieve issue templates.
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
- uses: actions/checkout@v3 # NOTE: Retrieve issue templates.
|
||||
|
||||
- name: Run empty issues closer action
|
||||
uses: rickstaa/empty-issues-closer-action@e96914613221511279ca25f50fd4acc85e331d99 # v1.1.74
|
||||
uses: rickstaa/empty-issues-closer-action@v1
|
||||
env:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
@@ -5,21 +5,6 @@ on:
|
||||
- master
|
||||
paths:
|
||||
- "themes/index.js"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
checks: read
|
||||
contents: write
|
||||
deployments: read
|
||||
issues: read
|
||||
discussions: read
|
||||
packages: read
|
||||
pages: read
|
||||
pull-requests: read
|
||||
repository-projects: read
|
||||
security-events: read
|
||||
statuses: read
|
||||
|
||||
jobs:
|
||||
generateThemeDoc:
|
||||
@@ -27,21 +12,17 @@ jobs:
|
||||
name: Generate theme doc
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [22.x]
|
||||
node-version: [16.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
|
||||
# Fix the unsafe repo error which was introduced by the CVE-2022-24765 git patches.
|
||||
- name: Fix unsafe repo error
|
||||
run: git config --global --add safe.directory ${{ github.workspace }}
|
||||
|
||||
- name: npm install, generate readme
|
||||
run: |
|
||||
npm ci
|
||||
@@ -50,7 +31,7 @@ jobs:
|
||||
CI: true
|
||||
|
||||
- name: Run Script
|
||||
uses: skx/github-action-tester@e29768ff4ff67be9d1fdbccd8836ab83233bebb1 # v0.10.0
|
||||
uses: skx/github-action-tester@master
|
||||
with:
|
||||
script: ./scripts/push-theme-readme.sh
|
||||
env:
|
||||
|
||||
@@ -2,26 +2,10 @@ name: "Pull Request Labeler"
|
||||
on:
|
||||
- pull_request_target
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
checks: read
|
||||
contents: read
|
||||
deployments: read
|
||||
issues: read
|
||||
discussions: read
|
||||
packages: read
|
||||
pages: read
|
||||
pull-requests: write
|
||||
repository-projects: read
|
||||
security-events: read
|
||||
statuses: read
|
||||
|
||||
jobs:
|
||||
triage:
|
||||
if: github.repository == 'anuraghazra/github-readme-stats'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/labeler@634933edcd8ababfe52f92936142cc22ac488b1b # v6.0.1
|
||||
- uses: actions/labeler@v4
|
||||
with:
|
||||
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
sync-labels: true
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
name: OSSF Scorecard analysis workflow
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
if: github.repository == 'anuraghazra/github-readme-stats'
|
||||
name: Scorecard analysis
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# Needed if using Code scanning alerts
|
||||
security-events: write
|
||||
# Needed for GitHub OIDC token if publish_results is true
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
publish_results: true
|
||||
|
||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||
# format to the repository Actions tab.
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
retention-days: 5
|
||||
|
||||
# required for Code scanning alerts
|
||||
- name: "Upload SARIF results to code scanning"
|
||||
uses: github/codeql-action/upload-sarif@fdcae64e1484d349b3366718cdfef3d404390e85 # v2.22.1
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
@@ -1,28 +1,11 @@
|
||||
name: Theme preview
|
||||
on:
|
||||
# Temporary disabled due to paused themes addition.
|
||||
# See: https://github.com/anuraghazra/github-readme-stats/issues/3404
|
||||
# pull_request_target:
|
||||
# types: [opened, edited, reopened, synchronize]
|
||||
# branches:
|
||||
# - master
|
||||
# paths:
|
||||
# - "themes/index.js"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
checks: read
|
||||
contents: read
|
||||
deployments: read
|
||||
issues: read
|
||||
discussions: read
|
||||
packages: read
|
||||
pages: read
|
||||
pull-requests: write
|
||||
repository-projects: read
|
||||
security-events: read
|
||||
statuses: read
|
||||
pull_request_target:
|
||||
types: [opened, edited, reopened, synchronize]
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- "themes/index.js"
|
||||
|
||||
jobs:
|
||||
previewTheme:
|
||||
@@ -30,18 +13,18 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [22.x]
|
||||
node-version: [16.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
|
||||
- uses: bahmutov/npm-install@3e063b974f0d209807684aa23e534b3dde517fd9 # v1.11.2
|
||||
- uses: bahmutov/npm-install@v1
|
||||
with:
|
||||
useLockFile: false
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
name: Cleanup closed pull requests cache
|
||||
on:
|
||||
pull_request:
|
||||
types:
|
||||
- closed
|
||||
|
||||
permissions:
|
||||
actions: write
|
||||
checks: read
|
||||
contents: read
|
||||
deployments: read
|
||||
issues: read
|
||||
discussions: read
|
||||
packages: read
|
||||
pages: read
|
||||
pull-requests: read
|
||||
repository-projects: read
|
||||
security-events: read
|
||||
statuses: read
|
||||
|
||||
jobs:
|
||||
cleanup:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Cleanup
|
||||
run: |
|
||||
gh extension install actions/gh-actions-cache
|
||||
|
||||
REPO=${{ github.repository }}
|
||||
BRANCH="refs/pull/${{ github.event.pull_request.number }}/merge"
|
||||
|
||||
echo "Fetching list of cache key"
|
||||
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1 )
|
||||
|
||||
## Setting this to not fail the workflow while deleting cache keys.
|
||||
set +e
|
||||
echo "Deleting caches..."
|
||||
for cacheKey in $cacheKeysForPR
|
||||
do
|
||||
gh actions-cache delete $cacheKey -R $REPO -B $BRANCH --confirm
|
||||
done
|
||||
echo "Done"
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -0,0 +1,30 @@
|
||||
name: Close stale theme pull requests that have the 'invalid' label.
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 0 */7 * *"
|
||||
|
||||
jobs:
|
||||
closeOldThemePrs:
|
||||
name: Close stale 'invalid' theme PRs
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [16.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
|
||||
- uses: bahmutov/npm-install@v1
|
||||
with:
|
||||
useLockFile: false
|
||||
|
||||
- run: npm run close-stale-theme-prs
|
||||
env:
|
||||
STALE_DAYS: 15
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -1,57 +0,0 @@
|
||||
name: Close stale theme pull requests that have the 'invalid' label.
|
||||
on:
|
||||
# Temporary disabled due to paused themes addition.
|
||||
# See: https://github.com/anuraghazra/github-readme-stats/issues/3404
|
||||
# schedule:
|
||||
# # ┌───────────── minute (0 - 59)
|
||||
# # │ ┌───────────── hour (0 - 23)
|
||||
# # │ │ ┌───────────── day of the month (1 - 31)
|
||||
# # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
|
||||
# # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
|
||||
# # │ │ │ │ │
|
||||
# # │ │ │ │ │
|
||||
# # │ │ │ │ │
|
||||
# # * * * * *
|
||||
# - cron: "0 0 */7 * *"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
checks: read
|
||||
contents: read
|
||||
deployments: read
|
||||
issues: read
|
||||
discussions: read
|
||||
packages: read
|
||||
pages: read
|
||||
pull-requests: write
|
||||
repository-projects: read
|
||||
security-events: read
|
||||
statuses: read
|
||||
|
||||
jobs:
|
||||
closeOldThemePrs:
|
||||
if: github.repository == 'anuraghazra/github-readme-stats'
|
||||
name: Close stale 'invalid' theme PRs
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [22.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
|
||||
- uses: bahmutov/npm-install@3e063b974f0d209807684aa23e534b3dde517fd9 # v1.11.2
|
||||
with:
|
||||
useLockFile: false
|
||||
|
||||
- run: npm run close-stale-theme-prs
|
||||
env:
|
||||
STALE_DAYS: 20
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -2,26 +2,24 @@ name: Test
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- "*"
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Perform tests
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [22.x]
|
||||
node-version: [16.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
@@ -31,17 +29,9 @@ jobs:
|
||||
npm ci
|
||||
npm run test
|
||||
|
||||
- name: Run ESLint
|
||||
run: |
|
||||
npm run lint
|
||||
|
||||
- name: Run bench tests
|
||||
run: |
|
||||
npm run bench
|
||||
|
||||
- name: Run Prettier
|
||||
run: |
|
||||
npm run format:check
|
||||
|
||||
- name: Code Coverage
|
||||
uses: codecov/codecov-action@4fe8c5f003fae66aa5ebb77cfd3e7bfbbda0b6b0 # v3.1.5
|
||||
uses: codecov/codecov-action@v1
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
name: Theme Pull Requests Closer
|
||||
|
||||
on:
|
||||
- pull_request_target
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
checks: read
|
||||
contents: read
|
||||
deployments: read
|
||||
issues: read
|
||||
discussions: read
|
||||
packages: read
|
||||
pages: read
|
||||
pull-requests: write
|
||||
repository-projects: read
|
||||
security-events: read
|
||||
statuses: read
|
||||
|
||||
jobs:
|
||||
close-prs:
|
||||
if: github.repository == 'anuraghazra/github-readme-stats'
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out the code
|
||||
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
|
||||
- name: Set up Git
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
- name: Close Pull Requests
|
||||
run: |
|
||||
comment_message="We are currently pausing addition of new themes. If this theme is exclusively for your personal use, then instead of adding it to our theme collection, you can use card [customization options](https://github.com/anuraghazra/github-readme-stats?tab=readme-ov-file#customization)."
|
||||
|
||||
for pr_number in $(gh pr list -l "themes" -q is:open --json number -q ".[].number"); do
|
||||
gh pr close $pr_number -c "$comment_message"
|
||||
done
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
@@ -1,46 +1,20 @@
|
||||
name: Update top issues dashboard
|
||||
on:
|
||||
schedule:
|
||||
# ┌───────────── minute (0 - 59)
|
||||
# │ ┌───────────── hour (0 - 23)
|
||||
# │ │ ┌───────────── day of the month (1 - 31)
|
||||
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
|
||||
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
|
||||
# │ │ │ │ │
|
||||
# │ │ │ │ │
|
||||
# │ │ │ │ │
|
||||
# * * * * *
|
||||
- cron: "0 0 */3 * *"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
checks: read
|
||||
contents: read
|
||||
deployments: read
|
||||
issues: write
|
||||
discussions: read
|
||||
packages: read
|
||||
pages: read
|
||||
pull-requests: write
|
||||
repository-projects: read
|
||||
security-events: read
|
||||
statuses: read
|
||||
|
||||
jobs:
|
||||
showAndLabelTopIssues:
|
||||
if: github.repository == 'anuraghazra/github-readme-stats'
|
||||
name: Update top issues Dashboard.
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Run top issues action
|
||||
uses: rickstaa/top-issues-action@7e8dda5d5ae3087670f9094b9724a9a091fc3ba1 # v1.3.101
|
||||
uses: rickstaa/top-issues-action@v1
|
||||
env:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
top_list_size: 10
|
||||
filter: "1772"
|
||||
label: true
|
||||
label: false
|
||||
dashboard: true
|
||||
dashboard_show_total_reactions: true
|
||||
top_issues: true
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
name: Update supported languages
|
||||
on:
|
||||
schedule:
|
||||
# ┌───────────── minute (0 - 59)
|
||||
# │ ┌───────────── hour (0 - 23)
|
||||
# │ │ ┌───────────── day of the month (1 - 31)
|
||||
# │ │ │ ┌───────────── month (1 - 12 or JAN-DEC)
|
||||
# │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT)
|
||||
# │ │ │ │ │
|
||||
# │ │ │ │ │
|
||||
# │ │ │ │ │
|
||||
# * * * * *
|
||||
- cron: "0 0 */30 * *"
|
||||
|
||||
permissions:
|
||||
actions: read
|
||||
checks: read
|
||||
contents: write
|
||||
deployments: read
|
||||
issues: read
|
||||
discussions: read
|
||||
packages: read
|
||||
pages: read
|
||||
pull-requests: write
|
||||
repository-projects: read
|
||||
security-events: read
|
||||
statuses: read
|
||||
|
||||
jobs:
|
||||
updateLanguages:
|
||||
if: github.repository == 'anuraghazra/github-readme-stats'
|
||||
name: Update supported languages
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [22.x]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
|
||||
|
||||
- name: Setup Node
|
||||
uses: actions/setup-node@395ad3262231945c25e8478fd5baf05154b1d79f # v6.1.0
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
cache: npm
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
env:
|
||||
CI: true
|
||||
|
||||
- name: Run update-languages-json.js script
|
||||
run: npm run generate-langs-json
|
||||
|
||||
- name: Create Pull Request if upstream language file is changed
|
||||
uses: peter-evans/create-pull-request@98357b18bf14b5342f975ff684046ec3b2a07725 # v8.0.0
|
||||
with:
|
||||
commit-message: "refactor: update languages JSON"
|
||||
branch: "update_langs/patch"
|
||||
delete-branch: true
|
||||
title: Update languages JSON
|
||||
body:
|
||||
"The
|
||||
[update-langs](https://github.com/anuraghazra/github-readme-stats/actions/workflows/update-langs.yaml)
|
||||
action found new/updated languages in the [upstream languages JSON
|
||||
file](https://raw.githubusercontent.com/github/linguist/master/lib/linguist/languages.yml)."
|
||||
labels: "ci, lang-card"
|
||||
+2
-6
@@ -2,15 +2,11 @@
|
||||
.env
|
||||
node_modules
|
||||
*.lock
|
||||
.vscode/
|
||||
.idea/
|
||||
coverage
|
||||
benchmarks
|
||||
vercel_token
|
||||
|
||||
# IDE
|
||||
.vscode/*
|
||||
!.vscode/extensions.json
|
||||
!.vscode/settings.json
|
||||
.vscode
|
||||
*.code-workspace
|
||||
|
||||
.vercel
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
_
|
||||
@@ -1,3 +0,0 @@
|
||||
npm test
|
||||
npm run lint
|
||||
npx lint-staged
|
||||
+2
-14
@@ -1,15 +1,3 @@
|
||||
.devcontainer
|
||||
.github
|
||||
.husky
|
||||
.vscode
|
||||
benchmarks
|
||||
coverage
|
||||
scripts
|
||||
tests
|
||||
.env
|
||||
**/*.md
|
||||
**/*.svg
|
||||
.eslintrc.json
|
||||
.prettierignore
|
||||
.pretterrc.json
|
||||
codecov.yml
|
||||
package-lock.json
|
||||
coverage
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"yzhang.markdown-all-in-one",
|
||||
"esbenp.prettier-vscode",
|
||||
"dbaeumer.vscode-eslint",
|
||||
"ms-azuretools.vscode-containers",
|
||||
"github.vscode-github-actions"
|
||||
]
|
||||
}
|
||||
Vendored
-8
@@ -1,8 +0,0 @@
|
||||
{
|
||||
"markdown.extension.toc.levels": "1..3",
|
||||
"editor.formatOnSave": true,
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"[javascript]": {
|
||||
"editor.tabSize": 2
|
||||
}
|
||||
}
|
||||
+19
-20
@@ -2,11 +2,11 @@
|
||||
|
||||
We love your input! We want to make contributing to this project as easy and transparent as possible, whether it's:
|
||||
|
||||
- Reporting [an issue](https://github.com/anuraghazra/github-readme-stats/issues/new?assignees=&labels=bug&template=bug_report.yml).
|
||||
- [Discussing](https://github.com/anuraghazra/github-readme-stats/discussions) the current state of the code.
|
||||
- Submitting [a fix](https://github.com/anuraghazra/github-readme-stats/compare).
|
||||
- Proposing [new features](https://github.com/anuraghazra/github-readme-stats/issues/new?assignees=&labels=enhancement&template=feature_request.yml).
|
||||
- Becoming a maintainer.
|
||||
- Reporting an issue
|
||||
- Discussing the current state of the code
|
||||
- Submitting a fix
|
||||
- Proposing new features
|
||||
- Becoming a maintainer
|
||||
|
||||
## All Changes Happen Through Pull Requests
|
||||
|
||||
@@ -33,30 +33,25 @@ _(make sure you already have a [Vercel](https://vercel.com/) account)_
|
||||
1. Install [Vercel CLI](https://vercel.com/download).
|
||||
2. Fork the repository and clone the code to your local machine.
|
||||
3. Run `npm install` in the repository root.
|
||||
4. Run the command `vercel` in the root and follow the steps there.
|
||||
5. Run the command `vercel dev` to start a development server at <http://localhost:3000>.
|
||||
6. Create a `.env` file in the root and add the following line `NODE_ENV=development`, this will disable caching for local development.
|
||||
7. The cards will then be available from this local endpoint (i.e. `http://localhost:3000/api?username=anuraghazra`).
|
||||
|
||||
> [!NOTE]
|
||||
> You can debug the package code in [Vscode](https://code.visualstudio.com/) by using the [Node.js: Attach to process](https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_setting-up-an-attach-configuration) debug option. You can also debug any tests using the [VSCode Jest extension](https://marketplace.visualstudio.com/items?itemName=Orta.vscode-jest). For more information, see https://github.com/jest-community/vscode-jest/issues/912.
|
||||
4. Run the command "vercel" in the root and follow the steps there.
|
||||
5. Open `vercel.json` and set the maxDuration to 10.
|
||||
6. Create a `.env` file in the root of the directory.
|
||||
7. In the .env file add a new variable named "PAT_1" with your [GitHub Personal Access Token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token).
|
||||
8. Run the command "vercel dev" to start a development server at <https://localhost:3000>.
|
||||
|
||||
## Themes Contribution
|
||||
|
||||
We're currently paused addition of new themes to decrease maintenance efforts. All pull requests related to new themes will be closed.
|
||||
GitHub Readme Stats supports custom theming, and you can also contribute new themes!
|
||||
|
||||
> [!NOTE]
|
||||
> If you are considering contributing your theme just because you are using it personally, then instead of adding it to our theme collection, you can use card [customization options](./readme.md#customization).
|
||||
All you need to do is edit the [themes/index.js](./themes/index.js) file and add your theme at the end of the file.
|
||||
|
||||
## Translations Contribution
|
||||
While creating the Pull request to add a new theme **don't forget to add a screenshot of how your theme looks**, you can also test how it looks using custom URL parameters like `title_color`, `icon_color`, `bg_color`, `text_color`, `border_color`
|
||||
|
||||
GitHub Readme Stats supports multiple languages, if we are missing your language, you can contribute it! You can check the currently supported languages [here](./readme.md#available-locales).
|
||||
|
||||
To contribute your language you need to edit the [src/translations.js](./src/translations.js) file and add new property to each object where the key is the language code in [ISO 639-1 standard](https://www.andiamo.co.uk/resources/iso-language-codes/) and the value is the translated string.
|
||||
> NOTE: If you are contributing your theme just because you are using it personally, then you can [customize the looks](./readme.md#customization) of your card with URL params instead.
|
||||
|
||||
## Any contributions you make will be under the MIT Software License
|
||||
|
||||
In short, when you submit changes, your submissions are understood to be under the same [MIT License](https://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.
|
||||
In short, when you submit changes, your submissions are understood to be under the same [MIT License](http://choosealicense.com/licenses/mit/) that covers the project. Feel free to contact the maintainers if that's a concern.
|
||||
|
||||
## Report issues/bugs using GitHub's [issues](https://github.com/anuraghazra/github-readme-stats/issues)
|
||||
|
||||
@@ -109,3 +104,7 @@ People _love_ thorough bug reports. I'm not even kidding.
|
||||
- A quick idea summary
|
||||
- What & why do you want to add the specific feature
|
||||
- Additional context like images, links to resources to implement the feature, etc.
|
||||
|
||||
## License
|
||||
|
||||
By contributing, you agree that your contributions will be licensed under its [MIT License](./LICENSE).
|
||||
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
# GitHub Readme Stats Security Policies and Procedures <!-- omit in toc -->
|
||||
|
||||
This document outlines security procedures and general policies for the
|
||||
GitHub Readme Stats project.
|
||||
|
||||
- [Reporting a Vulnerability](#reporting-a-vulnerability)
|
||||
- [Disclosure Policy](#disclosure-policy)
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
The GitHub Readme Stats team and community take all security vulnerabilities
|
||||
seriously. Thank you for improving the security of our open source
|
||||
software. We appreciate your efforts and responsible disclosure and will
|
||||
make every effort to acknowledge your contributions.
|
||||
|
||||
Report security vulnerabilities by emailing the GitHub Readme Stats team at:
|
||||
|
||||
```
|
||||
hazru.anurag@gmail.com
|
||||
```
|
||||
|
||||
The lead maintainer will acknowledge your email within 24 hours, and will
|
||||
send a more detailed response within 48 hours indicating the next steps in
|
||||
handling your report. After the initial reply to your report, the security
|
||||
team will endeavor to keep you informed of the progress towards a fix and
|
||||
full announcement, and may ask for additional information or guidance.
|
||||
|
||||
Report security vulnerabilities in third-party modules to the person or
|
||||
team maintaining the module.
|
||||
|
||||
## Disclosure Policy
|
||||
|
||||
When the security team receives a security bug report, they will assign it
|
||||
to a primary handler. This person will coordinate the fix and release
|
||||
process, involving the following steps:
|
||||
|
||||
* Confirm the problem.
|
||||
* Audit code to find any potential similar problems.
|
||||
* Prepare fixes and release them as fast as possible.
|
||||
-127
@@ -1,127 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
import { renderError } from "../src/common/render.js";
|
||||
import { isLocaleAvailable } from "../src/translations.js";
|
||||
import { renderGistCard } from "../src/cards/gist.js";
|
||||
import { fetchGist } from "../src/fetchers/gist.js";
|
||||
import {
|
||||
CACHE_TTL,
|
||||
resolveCacheSeconds,
|
||||
setCacheHeaders,
|
||||
setErrorCacheHeaders,
|
||||
} from "../src/common/cache.js";
|
||||
import { guardAccess } from "../src/common/access.js";
|
||||
import {
|
||||
MissingParamError,
|
||||
retrieveSecondaryMessage,
|
||||
} from "../src/common/error.js";
|
||||
import { parseBoolean } from "../src/common/ops.js";
|
||||
|
||||
// @ts-ignore
|
||||
export default async (req, res) => {
|
||||
const {
|
||||
id,
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
theme,
|
||||
cache_seconds,
|
||||
locale,
|
||||
border_radius,
|
||||
border_color,
|
||||
show_owner,
|
||||
hide_border,
|
||||
} = req.query;
|
||||
|
||||
res.setHeader("Content-Type", "image/svg+xml");
|
||||
|
||||
const access = guardAccess({
|
||||
res,
|
||||
id,
|
||||
type: "gist",
|
||||
colors: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
},
|
||||
});
|
||||
if (!access.isPassed) {
|
||||
return access.result;
|
||||
}
|
||||
|
||||
if (locale && !isLocaleAvailable(locale)) {
|
||||
return res.send(
|
||||
renderError({
|
||||
message: "Something went wrong",
|
||||
secondaryMessage: "Language not found",
|
||||
renderOptions: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const gistData = await fetchGist(id);
|
||||
const cacheSeconds = resolveCacheSeconds({
|
||||
requested: parseInt(cache_seconds, 10),
|
||||
def: CACHE_TTL.GIST_CARD.DEFAULT,
|
||||
min: CACHE_TTL.GIST_CARD.MIN,
|
||||
max: CACHE_TTL.GIST_CARD.MAX,
|
||||
});
|
||||
|
||||
setCacheHeaders(res, cacheSeconds);
|
||||
|
||||
return res.send(
|
||||
renderGistCard(gistData, {
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
theme,
|
||||
border_radius,
|
||||
border_color,
|
||||
locale: locale ? locale.toLowerCase() : null,
|
||||
show_owner: parseBoolean(show_owner),
|
||||
hide_border: parseBoolean(hide_border),
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
setErrorCacheHeaders(res);
|
||||
if (err instanceof Error) {
|
||||
return res.send(
|
||||
renderError({
|
||||
message: err.message,
|
||||
secondaryMessage: retrieveSecondaryMessage(err),
|
||||
renderOptions: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
show_repo_link: !(err instanceof MissingParamError),
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
return res.send(
|
||||
renderError({
|
||||
message: "An unknown error occurred",
|
||||
renderOptions: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
-167
@@ -1,167 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
import { renderStatsCard } from "../src/cards/stats.js";
|
||||
import { guardAccess } from "../src/common/access.js";
|
||||
import {
|
||||
CACHE_TTL,
|
||||
resolveCacheSeconds,
|
||||
setCacheHeaders,
|
||||
setErrorCacheHeaders,
|
||||
} from "../src/common/cache.js";
|
||||
import {
|
||||
MissingParamError,
|
||||
retrieveSecondaryMessage,
|
||||
} from "../src/common/error.js";
|
||||
import { parseArray, parseBoolean } from "../src/common/ops.js";
|
||||
import { renderError } from "../src/common/render.js";
|
||||
import { fetchStats } from "../src/fetchers/stats.js";
|
||||
import { isLocaleAvailable } from "../src/translations.js";
|
||||
|
||||
// @ts-ignore
|
||||
export default async (req, res) => {
|
||||
const {
|
||||
username,
|
||||
hide,
|
||||
hide_title,
|
||||
hide_border,
|
||||
card_width,
|
||||
hide_rank,
|
||||
show_icons,
|
||||
include_all_commits,
|
||||
commits_year,
|
||||
line_height,
|
||||
title_color,
|
||||
ring_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
text_bold,
|
||||
bg_color,
|
||||
theme,
|
||||
cache_seconds,
|
||||
exclude_repo,
|
||||
custom_title,
|
||||
locale,
|
||||
disable_animations,
|
||||
border_radius,
|
||||
number_format,
|
||||
number_precision,
|
||||
border_color,
|
||||
rank_icon,
|
||||
show,
|
||||
} = req.query;
|
||||
res.setHeader("Content-Type", "image/svg+xml");
|
||||
|
||||
const access = guardAccess({
|
||||
res,
|
||||
id: username,
|
||||
type: "username",
|
||||
colors: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
},
|
||||
});
|
||||
if (!access.isPassed) {
|
||||
return access.result;
|
||||
}
|
||||
|
||||
if (locale && !isLocaleAvailable(locale)) {
|
||||
return res.send(
|
||||
renderError({
|
||||
message: "Something went wrong",
|
||||
secondaryMessage: "Language not found",
|
||||
renderOptions: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const showStats = parseArray(show);
|
||||
const stats = await fetchStats(
|
||||
username,
|
||||
parseBoolean(include_all_commits),
|
||||
parseArray(exclude_repo),
|
||||
showStats.includes("prs_merged") ||
|
||||
showStats.includes("prs_merged_percentage"),
|
||||
showStats.includes("discussions_started"),
|
||||
showStats.includes("discussions_answered"),
|
||||
parseInt(commits_year, 10),
|
||||
);
|
||||
const cacheSeconds = resolveCacheSeconds({
|
||||
requested: parseInt(cache_seconds, 10),
|
||||
def: CACHE_TTL.STATS_CARD.DEFAULT,
|
||||
min: CACHE_TTL.STATS_CARD.MIN,
|
||||
max: CACHE_TTL.STATS_CARD.MAX,
|
||||
});
|
||||
|
||||
setCacheHeaders(res, cacheSeconds);
|
||||
|
||||
return res.send(
|
||||
renderStatsCard(stats, {
|
||||
hide: parseArray(hide),
|
||||
show_icons: parseBoolean(show_icons),
|
||||
hide_title: parseBoolean(hide_title),
|
||||
hide_border: parseBoolean(hide_border),
|
||||
card_width: parseInt(card_width, 10),
|
||||
hide_rank: parseBoolean(hide_rank),
|
||||
include_all_commits: parseBoolean(include_all_commits),
|
||||
commits_year: parseInt(commits_year, 10),
|
||||
line_height,
|
||||
title_color,
|
||||
ring_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
text_bold: parseBoolean(text_bold),
|
||||
bg_color,
|
||||
theme,
|
||||
custom_title,
|
||||
border_radius,
|
||||
border_color,
|
||||
number_format,
|
||||
number_precision: parseInt(number_precision, 10),
|
||||
locale: locale ? locale.toLowerCase() : null,
|
||||
disable_animations: parseBoolean(disable_animations),
|
||||
rank_icon,
|
||||
show: showStats,
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
setErrorCacheHeaders(res);
|
||||
if (err instanceof Error) {
|
||||
return res.send(
|
||||
renderError({
|
||||
message: err.message,
|
||||
secondaryMessage: retrieveSecondaryMessage(err),
|
||||
renderOptions: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
show_repo_link: !(err instanceof MissingParamError),
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
return res.send(
|
||||
renderError({
|
||||
message: "An unknown error occurred",
|
||||
renderOptions: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,94 @@
|
||||
import * as dotenv from "dotenv";
|
||||
import { renderStatsCard } from "../src/cards/stats-card";
|
||||
import { blacklist } from "../src/common/blacklist";
|
||||
import {
|
||||
clampValue,
|
||||
CONSTANTS,
|
||||
parseArray,
|
||||
parseBoolean,
|
||||
renderError,
|
||||
} from "../src/common/utils";
|
||||
import { fetchStats } from "../src/fetchers/stats-fetcher";
|
||||
import { isLocaleAvailable } from "../src/translations";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
export default async (req, res) => {
|
||||
const {
|
||||
username,
|
||||
hide,
|
||||
hide_title,
|
||||
hide_border,
|
||||
card_width,
|
||||
hide_rank,
|
||||
show_icons,
|
||||
count_private,
|
||||
include_all_commits,
|
||||
line_height,
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
text_bold,
|
||||
bg_color,
|
||||
theme,
|
||||
cache_seconds,
|
||||
exclude_repo,
|
||||
custom_title,
|
||||
locale,
|
||||
disable_animations,
|
||||
border_radius,
|
||||
border_color,
|
||||
} = req.query;
|
||||
res.setHeader("Content-Type", "image/svg+xml");
|
||||
|
||||
if (blacklist.includes(username)) {
|
||||
return res.send(renderError("Something went wrong"));
|
||||
}
|
||||
|
||||
if (locale && !isLocaleAvailable(locale)) {
|
||||
return res.send(renderError("Something went wrong", "Language not found"));
|
||||
}
|
||||
|
||||
try {
|
||||
const stats = await fetchStats(
|
||||
username,
|
||||
parseBoolean(count_private),
|
||||
parseBoolean(include_all_commits),
|
||||
parseArray(exclude_repo),
|
||||
);
|
||||
|
||||
const cacheSeconds = clampValue(
|
||||
parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10),
|
||||
CONSTANTS.FOUR_HOURS,
|
||||
CONSTANTS.ONE_DAY,
|
||||
);
|
||||
|
||||
res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
|
||||
|
||||
return res.send(
|
||||
renderStatsCard(stats, {
|
||||
hide: parseArray(hide),
|
||||
show_icons: parseBoolean(show_icons),
|
||||
hide_title: parseBoolean(hide_title),
|
||||
hide_border: parseBoolean(hide_border),
|
||||
card_width: parseInt(card_width, 10),
|
||||
hide_rank: parseBoolean(hide_rank),
|
||||
include_all_commits: parseBoolean(include_all_commits),
|
||||
line_height,
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
text_bold: parseBoolean(text_bold),
|
||||
bg_color,
|
||||
theme,
|
||||
custom_title,
|
||||
border_radius,
|
||||
border_color,
|
||||
locale: locale ? locale.toLowerCase() : null,
|
||||
disable_animations: parseBoolean(disable_animations),
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
return res.send(renderError(err.message, err.secondaryMessage));
|
||||
}
|
||||
};
|
||||
-130
@@ -1,130 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
import { renderRepoCard } from "../src/cards/repo.js";
|
||||
import { guardAccess } from "../src/common/access.js";
|
||||
import {
|
||||
CACHE_TTL,
|
||||
resolveCacheSeconds,
|
||||
setCacheHeaders,
|
||||
setErrorCacheHeaders,
|
||||
} from "../src/common/cache.js";
|
||||
import {
|
||||
MissingParamError,
|
||||
retrieveSecondaryMessage,
|
||||
} from "../src/common/error.js";
|
||||
import { parseBoolean } from "../src/common/ops.js";
|
||||
import { renderError } from "../src/common/render.js";
|
||||
import { fetchRepo } from "../src/fetchers/repo.js";
|
||||
import { isLocaleAvailable } from "../src/translations.js";
|
||||
|
||||
// @ts-ignore
|
||||
export default async (req, res) => {
|
||||
const {
|
||||
username,
|
||||
repo,
|
||||
hide_border,
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
theme,
|
||||
show_owner,
|
||||
cache_seconds,
|
||||
locale,
|
||||
border_radius,
|
||||
border_color,
|
||||
description_lines_count,
|
||||
} = req.query;
|
||||
|
||||
res.setHeader("Content-Type", "image/svg+xml");
|
||||
|
||||
const access = guardAccess({
|
||||
res,
|
||||
id: username,
|
||||
type: "username",
|
||||
colors: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
},
|
||||
});
|
||||
if (!access.isPassed) {
|
||||
return access.result;
|
||||
}
|
||||
|
||||
if (locale && !isLocaleAvailable(locale)) {
|
||||
return res.send(
|
||||
renderError({
|
||||
message: "Something went wrong",
|
||||
secondaryMessage: "Language not found",
|
||||
renderOptions: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const repoData = await fetchRepo(username, repo);
|
||||
const cacheSeconds = resolveCacheSeconds({
|
||||
requested: parseInt(cache_seconds, 10),
|
||||
def: CACHE_TTL.PIN_CARD.DEFAULT,
|
||||
min: CACHE_TTL.PIN_CARD.MIN,
|
||||
max: CACHE_TTL.PIN_CARD.MAX,
|
||||
});
|
||||
|
||||
setCacheHeaders(res, cacheSeconds);
|
||||
|
||||
return res.send(
|
||||
renderRepoCard(repoData, {
|
||||
hide_border: parseBoolean(hide_border),
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
theme,
|
||||
border_radius,
|
||||
border_color,
|
||||
show_owner: parseBoolean(show_owner),
|
||||
locale: locale ? locale.toLowerCase() : null,
|
||||
description_lines_count,
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
setErrorCacheHeaders(res);
|
||||
if (err instanceof Error) {
|
||||
return res.send(
|
||||
renderError({
|
||||
message: err.message,
|
||||
secondaryMessage: retrieveSecondaryMessage(err),
|
||||
renderOptions: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
show_repo_link: !(err instanceof MissingParamError),
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
return res.send(
|
||||
renderError({
|
||||
message: "An unknown error occurred",
|
||||
renderOptions: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
import { renderRepoCard } from "../src/cards/repo-card";
|
||||
import { blacklist } from "../src/common/blacklist";
|
||||
import {
|
||||
clampValue,
|
||||
CONSTANTS,
|
||||
parseBoolean,
|
||||
renderError,
|
||||
} from "../src/common/utils";
|
||||
import { fetchRepo } from "../src/fetchers/repo-fetcher";
|
||||
import { isLocaleAvailable } from "../src/translations";
|
||||
|
||||
export default async (req, res) => {
|
||||
const {
|
||||
username,
|
||||
repo,
|
||||
hide_border,
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
theme,
|
||||
show_owner,
|
||||
cache_seconds,
|
||||
locale,
|
||||
border_radius,
|
||||
border_color,
|
||||
} = req.query;
|
||||
|
||||
res.setHeader("Content-Type", "image/svg+xml");
|
||||
|
||||
if (blacklist.includes(username)) {
|
||||
return res.send(renderError("Something went wrong"));
|
||||
}
|
||||
|
||||
if (locale && !isLocaleAvailable(locale)) {
|
||||
return res.send(renderError("Something went wrong", "Language not found"));
|
||||
}
|
||||
|
||||
try {
|
||||
const repoData = await fetchRepo(username, repo);
|
||||
|
||||
let cacheSeconds = clampValue(
|
||||
parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10),
|
||||
CONSTANTS.FOUR_HOURS,
|
||||
CONSTANTS.ONE_DAY,
|
||||
);
|
||||
|
||||
/*
|
||||
if star count & fork count is over 1k then we are kFormating the text
|
||||
and if both are zero we are not showing the stats
|
||||
so we can just make the cache longer, since there is no need to frequent updates
|
||||
*/
|
||||
const stars = repoData.starCount;
|
||||
const forks = repoData.forkCount;
|
||||
const isBothOver1K = stars > 1000 && forks > 1000;
|
||||
const isBothUnder1 = stars < 1 && forks < 1;
|
||||
if (!cache_seconds && (isBothOver1K || isBothUnder1)) {
|
||||
cacheSeconds = CONSTANTS.FOUR_HOURS;
|
||||
}
|
||||
|
||||
res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
|
||||
|
||||
return res.send(
|
||||
renderRepoCard(repoData, {
|
||||
hide_border: parseBoolean(hide_border),
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
theme,
|
||||
border_radius,
|
||||
border_color,
|
||||
show_owner: parseBoolean(show_owner),
|
||||
locale: locale ? locale.toLowerCase() : null,
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
return res.send(renderError(err.message, err.secondaryMessage));
|
||||
}
|
||||
};
|
||||
@@ -1,159 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
/**
|
||||
* @file Contains a simple cloud function that can be used to check which PATs are no
|
||||
* longer working. It returns a list of valid PATs, expired PATs and PATs with errors.
|
||||
*
|
||||
* @description This function is currently rate limited to 1 request per 5 minutes.
|
||||
*/
|
||||
|
||||
import { request } from "../../src/common/http.js";
|
||||
import { logger } from "../../src/common/log.js";
|
||||
import { dateDiff } from "../../src/common/ops.js";
|
||||
|
||||
export const RATE_LIMIT_SECONDS = 60 * 5; // 1 request per 5 minutes
|
||||
|
||||
/**
|
||||
* Simple uptime check fetcher for the PATs.
|
||||
*
|
||||
* @param {any} variables Fetcher variables.
|
||||
* @param {string} token GitHub token.
|
||||
* @returns {Promise<import('axios').AxiosResponse>} The response.
|
||||
*/
|
||||
const uptimeFetcher = (variables, token) => {
|
||||
return request(
|
||||
{
|
||||
query: `
|
||||
query {
|
||||
rateLimit {
|
||||
remaining
|
||||
resetAt
|
||||
},
|
||||
}`,
|
||||
variables,
|
||||
},
|
||||
{
|
||||
Authorization: `bearer ${token}`,
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
const getAllPATs = () => {
|
||||
return Object.keys(process.env).filter((key) => /PAT_\d*$/.exec(key));
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {(variables: any, token: string) => Promise<import('axios').AxiosResponse>} Fetcher The fetcher function.
|
||||
* @typedef {{validPATs: string[], expiredPATs: string[], exhaustedPATs: string[], suspendedPATs: string[], errorPATs: string[], details: any}} PATInfo The PAT info.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Check whether any of the PATs is expired.
|
||||
*
|
||||
* @param {Fetcher} fetcher The fetcher function.
|
||||
* @param {any} variables Fetcher variables.
|
||||
* @returns {Promise<PATInfo>} The response.
|
||||
*/
|
||||
const getPATInfo = async (fetcher, variables) => {
|
||||
/** @type {Record<string, any>} */
|
||||
const details = {};
|
||||
const PATs = getAllPATs();
|
||||
|
||||
for (const pat of PATs) {
|
||||
try {
|
||||
const response = await fetcher(variables, process.env[pat]);
|
||||
const errors = response.data.errors;
|
||||
const hasErrors = Boolean(errors);
|
||||
const errorType = errors?.[0]?.type;
|
||||
const isRateLimited =
|
||||
(hasErrors && errorType === "RATE_LIMITED") ||
|
||||
response.data.data?.rateLimit?.remaining === 0;
|
||||
|
||||
// Store PATs with errors.
|
||||
if (hasErrors && errorType !== "RATE_LIMITED") {
|
||||
details[pat] = {
|
||||
status: "error",
|
||||
error: {
|
||||
type: errors[0].type,
|
||||
message: errors[0].message,
|
||||
},
|
||||
};
|
||||
continue;
|
||||
} else if (isRateLimited) {
|
||||
const date1 = new Date();
|
||||
const date2 = new Date(response.data?.data?.rateLimit?.resetAt);
|
||||
details[pat] = {
|
||||
status: "exhausted",
|
||||
remaining: 0,
|
||||
resetIn: dateDiff(date2, date1) + " minutes",
|
||||
};
|
||||
} else {
|
||||
details[pat] = {
|
||||
status: "valid",
|
||||
remaining: response.data.data.rateLimit.remaining,
|
||||
};
|
||||
}
|
||||
} catch (err) {
|
||||
// Store the PAT if it is expired.
|
||||
const errorMessage = err.response?.data?.message?.toLowerCase();
|
||||
if (errorMessage === "bad credentials") {
|
||||
details[pat] = {
|
||||
status: "expired",
|
||||
};
|
||||
} else if (errorMessage === "sorry. your account was suspended.") {
|
||||
details[pat] = {
|
||||
status: "suspended",
|
||||
};
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const filterPATsByStatus = (status) => {
|
||||
return Object.keys(details).filter((pat) => details[pat].status === status);
|
||||
};
|
||||
|
||||
const sortedDetails = Object.keys(details)
|
||||
.sort()
|
||||
.reduce((obj, key) => {
|
||||
obj[key] = details[key];
|
||||
return obj;
|
||||
}, {});
|
||||
|
||||
return {
|
||||
validPATs: filterPATsByStatus("valid"),
|
||||
expiredPATs: filterPATsByStatus("expired"),
|
||||
exhaustedPATs: filterPATsByStatus("exhausted"),
|
||||
suspendedPATs: filterPATsByStatus("suspended"),
|
||||
errorPATs: filterPATsByStatus("error"),
|
||||
details: sortedDetails,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Cloud function that returns information about the used PATs.
|
||||
*
|
||||
* @param {any} _ The request.
|
||||
* @param {any} res The response.
|
||||
* @returns {Promise<void>} The response.
|
||||
*/
|
||||
export default async (_, res) => {
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
try {
|
||||
// Add header to prevent abuse.
|
||||
const PATsInfo = await getPATInfo(uptimeFetcher, {});
|
||||
if (PATsInfo) {
|
||||
res.setHeader(
|
||||
"Cache-Control",
|
||||
`max-age=0, s-maxage=${RATE_LIMIT_SECONDS}`,
|
||||
);
|
||||
}
|
||||
res.send(JSON.stringify(PATsInfo, null, 2));
|
||||
} catch (err) {
|
||||
// Throw error if something went wrong.
|
||||
logger.error(err);
|
||||
res.setHeader("Cache-Control", "no-store");
|
||||
res.send("Something went wrong: " + err.message);
|
||||
}
|
||||
};
|
||||
@@ -1,124 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
/**
|
||||
* @file Contains a simple cloud function that can be used to check if the PATs are still
|
||||
* functional.
|
||||
*
|
||||
* @description This function is currently rate limited to 1 request per 5 minutes.
|
||||
*/
|
||||
|
||||
import { request } from "../../src/common/http.js";
|
||||
import retryer from "../../src/common/retryer.js";
|
||||
import { logger } from "../../src/common/log.js";
|
||||
|
||||
export const RATE_LIMIT_SECONDS = 60 * 5; // 1 request per 5 minutes
|
||||
|
||||
/**
|
||||
* Simple uptime check fetcher for the PATs.
|
||||
*
|
||||
* @param {any} variables Fetcher variables.
|
||||
* @param {string} token GitHub token.
|
||||
* @returns {Promise<import('axios').AxiosResponse>} The response.
|
||||
*/
|
||||
const uptimeFetcher = (variables, token) => {
|
||||
return request(
|
||||
{
|
||||
query: `
|
||||
query {
|
||||
rateLimit {
|
||||
remaining
|
||||
}
|
||||
}
|
||||
`,
|
||||
variables,
|
||||
},
|
||||
{
|
||||
Authorization: `bearer ${token}`,
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* schemaVersion: number;
|
||||
* label: string;
|
||||
* message: "up" | "down";
|
||||
* color: "brightgreen" | "red";
|
||||
* isError: boolean
|
||||
* }} ShieldsResponse Shields.io response object.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates Json response that can be used for shields.io dynamic card generation.
|
||||
*
|
||||
* @param {boolean} up Whether the PATs are up or not.
|
||||
* @returns {ShieldsResponse} Dynamic shields.io JSON response object.
|
||||
*
|
||||
* @see https://shields.io/endpoint.
|
||||
*/
|
||||
const shieldsUptimeBadge = (up) => {
|
||||
const schemaVersion = 1;
|
||||
const isError = true;
|
||||
const label = "Public Instance";
|
||||
const message = up ? "up" : "down";
|
||||
const color = up ? "brightgreen" : "red";
|
||||
return {
|
||||
schemaVersion,
|
||||
label,
|
||||
message,
|
||||
color,
|
||||
isError,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Cloud function that returns whether the PATs are still functional.
|
||||
*
|
||||
* @param {any} req The request.
|
||||
* @param {any} res The response.
|
||||
* @returns {Promise<void>} Nothing.
|
||||
*/
|
||||
export default async (req, res) => {
|
||||
let { type } = req.query;
|
||||
type = type ? type.toLowerCase() : "boolean";
|
||||
|
||||
res.setHeader("Content-Type", "application/json");
|
||||
|
||||
try {
|
||||
let PATsValid = true;
|
||||
try {
|
||||
await retryer(uptimeFetcher, {});
|
||||
} catch (err) {
|
||||
// Resolve eslint no-unused-vars
|
||||
err;
|
||||
|
||||
PATsValid = false;
|
||||
}
|
||||
|
||||
if (PATsValid) {
|
||||
res.setHeader(
|
||||
"Cache-Control",
|
||||
`max-age=0, s-maxage=${RATE_LIMIT_SECONDS}`,
|
||||
);
|
||||
} else {
|
||||
res.setHeader("Cache-Control", "no-store");
|
||||
}
|
||||
|
||||
switch (type) {
|
||||
case "shields":
|
||||
res.send(shieldsUptimeBadge(PATsValid));
|
||||
break;
|
||||
case "json":
|
||||
res.send({ up: PATsValid });
|
||||
break;
|
||||
default:
|
||||
res.send(PATsValid);
|
||||
break;
|
||||
}
|
||||
} catch (err) {
|
||||
// Return fail boolean if something went wrong.
|
||||
logger.error(err);
|
||||
res.setHeader("Cache-Control", "no-store");
|
||||
res.send("Something went wrong: " + err.message);
|
||||
}
|
||||
};
|
||||
@@ -1,188 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
import { renderTopLanguages } from "../src/cards/top-languages.js";
|
||||
import { guardAccess } from "../src/common/access.js";
|
||||
import {
|
||||
CACHE_TTL,
|
||||
resolveCacheSeconds,
|
||||
setCacheHeaders,
|
||||
setErrorCacheHeaders,
|
||||
} from "../src/common/cache.js";
|
||||
import {
|
||||
MissingParamError,
|
||||
retrieveSecondaryMessage,
|
||||
} from "../src/common/error.js";
|
||||
import { parseArray, parseBoolean } from "../src/common/ops.js";
|
||||
import { renderError } from "../src/common/render.js";
|
||||
import { fetchTopLanguages } from "../src/fetchers/top-languages.js";
|
||||
import { isLocaleAvailable } from "../src/translations.js";
|
||||
|
||||
// @ts-ignore
|
||||
export default async (req, res) => {
|
||||
const {
|
||||
username,
|
||||
hide,
|
||||
hide_title,
|
||||
hide_border,
|
||||
card_width,
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
theme,
|
||||
cache_seconds,
|
||||
layout,
|
||||
langs_count,
|
||||
exclude_repo,
|
||||
size_weight,
|
||||
count_weight,
|
||||
custom_title,
|
||||
locale,
|
||||
border_radius,
|
||||
border_color,
|
||||
disable_animations,
|
||||
hide_progress,
|
||||
stats_format,
|
||||
} = req.query;
|
||||
res.setHeader("Content-Type", "image/svg+xml");
|
||||
|
||||
const access = guardAccess({
|
||||
res,
|
||||
id: username,
|
||||
type: "username",
|
||||
colors: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
},
|
||||
});
|
||||
if (!access.isPassed) {
|
||||
return access.result;
|
||||
}
|
||||
|
||||
if (locale && !isLocaleAvailable(locale)) {
|
||||
return res.send(
|
||||
renderError({
|
||||
message: "Something went wrong",
|
||||
secondaryMessage: "Locale not found",
|
||||
renderOptions: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
layout !== undefined &&
|
||||
(typeof layout !== "string" ||
|
||||
!["compact", "normal", "donut", "donut-vertical", "pie"].includes(layout))
|
||||
) {
|
||||
return res.send(
|
||||
renderError({
|
||||
message: "Something went wrong",
|
||||
secondaryMessage: "Incorrect layout input",
|
||||
renderOptions: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
stats_format !== undefined &&
|
||||
(typeof stats_format !== "string" ||
|
||||
!["bytes", "percentages"].includes(stats_format))
|
||||
) {
|
||||
return res.send(
|
||||
renderError({
|
||||
message: "Something went wrong",
|
||||
secondaryMessage: "Incorrect stats_format input",
|
||||
renderOptions: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const topLangs = await fetchTopLanguages(
|
||||
username,
|
||||
parseArray(exclude_repo),
|
||||
size_weight,
|
||||
count_weight,
|
||||
);
|
||||
const cacheSeconds = resolveCacheSeconds({
|
||||
requested: parseInt(cache_seconds, 10),
|
||||
def: CACHE_TTL.TOP_LANGS_CARD.DEFAULT,
|
||||
min: CACHE_TTL.TOP_LANGS_CARD.MIN,
|
||||
max: CACHE_TTL.TOP_LANGS_CARD.MAX,
|
||||
});
|
||||
|
||||
setCacheHeaders(res, cacheSeconds);
|
||||
|
||||
return res.send(
|
||||
renderTopLanguages(topLangs, {
|
||||
custom_title,
|
||||
hide_title: parseBoolean(hide_title),
|
||||
hide_border: parseBoolean(hide_border),
|
||||
card_width: parseInt(card_width, 10),
|
||||
hide: parseArray(hide),
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
theme,
|
||||
layout,
|
||||
langs_count,
|
||||
border_radius,
|
||||
border_color,
|
||||
locale: locale ? locale.toLowerCase() : null,
|
||||
disable_animations: parseBoolean(disable_animations),
|
||||
hide_progress: parseBoolean(hide_progress),
|
||||
stats_format,
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
setErrorCacheHeaders(res);
|
||||
if (err instanceof Error) {
|
||||
return res.send(
|
||||
renderError({
|
||||
message: err.message,
|
||||
secondaryMessage: retrieveSecondaryMessage(err),
|
||||
renderOptions: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
show_repo_link: !(err instanceof MissingParamError),
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
return res.send(
|
||||
renderError({
|
||||
message: "An unknown error occurred",
|
||||
renderOptions: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,81 @@
|
||||
import * as dotenv from "dotenv";
|
||||
import { renderTopLanguages } from "../src/cards/top-languages-card";
|
||||
import { blacklist } from "../src/common/blacklist";
|
||||
import {
|
||||
clampValue,
|
||||
CONSTANTS,
|
||||
parseArray,
|
||||
parseBoolean,
|
||||
renderError,
|
||||
} from "../src/common/utils";
|
||||
import { fetchTopLanguages } from "../src/fetchers/top-languages-fetcher";
|
||||
import { isLocaleAvailable } from "../src/translations";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
export default async (req, res) => {
|
||||
const {
|
||||
username,
|
||||
hide,
|
||||
hide_title,
|
||||
hide_border,
|
||||
card_width,
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
theme,
|
||||
cache_seconds,
|
||||
layout,
|
||||
langs_count,
|
||||
exclude_repo,
|
||||
custom_title,
|
||||
locale,
|
||||
border_radius,
|
||||
border_color,
|
||||
} = req.query;
|
||||
res.setHeader("Content-Type", "image/svg+xml");
|
||||
|
||||
if (blacklist.includes(username)) {
|
||||
return res.send(renderError("Something went wrong"));
|
||||
}
|
||||
|
||||
if (locale && !isLocaleAvailable(locale)) {
|
||||
return res.send(renderError("Something went wrong", "Locale not found"));
|
||||
}
|
||||
|
||||
try {
|
||||
const topLangs = await fetchTopLanguages(
|
||||
username,
|
||||
parseArray(exclude_repo),
|
||||
);
|
||||
|
||||
const cacheSeconds = clampValue(
|
||||
parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10),
|
||||
CONSTANTS.FOUR_HOURS,
|
||||
CONSTANTS.ONE_DAY,
|
||||
);
|
||||
|
||||
res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
|
||||
|
||||
return res.send(
|
||||
renderTopLanguages(topLangs, {
|
||||
custom_title,
|
||||
hide_title: parseBoolean(hide_title),
|
||||
hide_border: parseBoolean(hide_border),
|
||||
card_width: parseInt(card_width, 10),
|
||||
hide: parseArray(hide),
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
theme,
|
||||
layout,
|
||||
langs_count,
|
||||
border_radius,
|
||||
border_color,
|
||||
locale: locale ? locale.toLowerCase() : null,
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
return res.send(renderError(err.message, err.secondaryMessage));
|
||||
}
|
||||
};
|
||||
-146
@@ -1,146 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
import { renderWakatimeCard } from "../src/cards/wakatime.js";
|
||||
import { renderError } from "../src/common/render.js";
|
||||
import { fetchWakatimeStats } from "../src/fetchers/wakatime.js";
|
||||
import { isLocaleAvailable } from "../src/translations.js";
|
||||
import {
|
||||
CACHE_TTL,
|
||||
resolveCacheSeconds,
|
||||
setCacheHeaders,
|
||||
setErrorCacheHeaders,
|
||||
} from "../src/common/cache.js";
|
||||
import { guardAccess } from "../src/common/access.js";
|
||||
import {
|
||||
MissingParamError,
|
||||
retrieveSecondaryMessage,
|
||||
} from "../src/common/error.js";
|
||||
import { parseArray, parseBoolean } from "../src/common/ops.js";
|
||||
|
||||
// @ts-ignore
|
||||
export default async (req, res) => {
|
||||
const {
|
||||
username,
|
||||
title_color,
|
||||
icon_color,
|
||||
hide_border,
|
||||
card_width,
|
||||
line_height,
|
||||
text_color,
|
||||
bg_color,
|
||||
theme,
|
||||
cache_seconds,
|
||||
hide_title,
|
||||
hide_progress,
|
||||
custom_title,
|
||||
locale,
|
||||
layout,
|
||||
langs_count,
|
||||
hide,
|
||||
api_domain,
|
||||
border_radius,
|
||||
border_color,
|
||||
display_format,
|
||||
disable_animations,
|
||||
} = req.query;
|
||||
|
||||
res.setHeader("Content-Type", "image/svg+xml");
|
||||
|
||||
const access = guardAccess({
|
||||
res,
|
||||
id: username,
|
||||
type: "wakatime",
|
||||
colors: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
},
|
||||
});
|
||||
if (!access.isPassed) {
|
||||
return access.result;
|
||||
}
|
||||
|
||||
if (locale && !isLocaleAvailable(locale)) {
|
||||
return res.send(
|
||||
renderError({
|
||||
message: "Something went wrong",
|
||||
secondaryMessage: "Language not found",
|
||||
renderOptions: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
const stats = await fetchWakatimeStats({ username, api_domain });
|
||||
const cacheSeconds = resolveCacheSeconds({
|
||||
requested: parseInt(cache_seconds, 10),
|
||||
def: CACHE_TTL.WAKATIME_CARD.DEFAULT,
|
||||
min: CACHE_TTL.WAKATIME_CARD.MIN,
|
||||
max: CACHE_TTL.WAKATIME_CARD.MAX,
|
||||
});
|
||||
|
||||
setCacheHeaders(res, cacheSeconds);
|
||||
|
||||
return res.send(
|
||||
renderWakatimeCard(stats, {
|
||||
custom_title,
|
||||
hide_title: parseBoolean(hide_title),
|
||||
hide_border: parseBoolean(hide_border),
|
||||
card_width: parseInt(card_width, 10),
|
||||
hide: parseArray(hide),
|
||||
line_height,
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
theme,
|
||||
hide_progress,
|
||||
border_radius,
|
||||
border_color,
|
||||
locale: locale ? locale.toLowerCase() : null,
|
||||
layout,
|
||||
langs_count,
|
||||
display_format,
|
||||
disable_animations: parseBoolean(disable_animations),
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
setErrorCacheHeaders(res);
|
||||
if (err instanceof Error) {
|
||||
return res.send(
|
||||
renderError({
|
||||
message: err.message,
|
||||
secondaryMessage: retrieveSecondaryMessage(err),
|
||||
renderOptions: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
show_repo_link: !(err instanceof MissingParamError),
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
return res.send(
|
||||
renderError({
|
||||
message: "An unknown error occurred",
|
||||
renderOptions: {
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,83 @@
|
||||
import * as dotenv from "dotenv";
|
||||
import { renderWakatimeCard } from "../src/cards/wakatime-card";
|
||||
import {
|
||||
clampValue,
|
||||
CONSTANTS,
|
||||
parseArray,
|
||||
parseBoolean,
|
||||
renderError,
|
||||
} from "../src/common/utils";
|
||||
import { fetchWakatimeStats } from "../src/fetchers/wakatime-fetcher";
|
||||
import { isLocaleAvailable } from "../src/translations";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
export default async (req, res) => {
|
||||
const {
|
||||
username,
|
||||
title_color,
|
||||
icon_color,
|
||||
hide_border,
|
||||
line_height,
|
||||
text_color,
|
||||
bg_color,
|
||||
theme,
|
||||
cache_seconds,
|
||||
hide_title,
|
||||
hide_progress,
|
||||
custom_title,
|
||||
locale,
|
||||
layout,
|
||||
langs_count,
|
||||
hide,
|
||||
api_domain,
|
||||
range,
|
||||
border_radius,
|
||||
border_color,
|
||||
} = req.query;
|
||||
|
||||
res.setHeader("Content-Type", "image/svg+xml");
|
||||
|
||||
if (locale && !isLocaleAvailable(locale)) {
|
||||
return res.send(renderError("Something went wrong", "Language not found"));
|
||||
}
|
||||
|
||||
try {
|
||||
const stats = await fetchWakatimeStats({ username, api_domain, range });
|
||||
|
||||
let cacheSeconds = clampValue(
|
||||
parseInt(cache_seconds || CONSTANTS.FOUR_HOURS, 10),
|
||||
CONSTANTS.FOUR_HOURS,
|
||||
CONSTANTS.ONE_DAY,
|
||||
);
|
||||
|
||||
if (!cache_seconds) {
|
||||
cacheSeconds = CONSTANTS.FOUR_HOURS;
|
||||
}
|
||||
|
||||
res.setHeader("Cache-Control", `public, max-age=${cacheSeconds}`);
|
||||
|
||||
return res.send(
|
||||
renderWakatimeCard(stats, {
|
||||
custom_title,
|
||||
hide_title: parseBoolean(hide_title),
|
||||
hide_border: parseBoolean(hide_border),
|
||||
hide: parseArray(hide),
|
||||
line_height,
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
theme,
|
||||
hide_progress,
|
||||
border_radius,
|
||||
border_color,
|
||||
locale: locale ? locale.toLowerCase() : null,
|
||||
layout,
|
||||
langs_count,
|
||||
}),
|
||||
);
|
||||
} catch (err) {
|
||||
return res.send(renderError(err.message, err.secondaryMessage));
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
presets: [
|
||||
["@babel/preset-env", { targets: { node: "current" } }],
|
||||
"@babel/preset-typescript",
|
||||
],
|
||||
};
|
||||
@@ -1,3 +0,0 @@
|
||||
[Caddyfile]
|
||||
indent_style = tab
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
readme-stats.example.com {
|
||||
## optional, force all requests to return your github stats
|
||||
#uri query username ${github_username:anuraghazra}
|
||||
reverse_proxy readme_stats:${port:9000}
|
||||
}
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
FROM node:lts-alpine
|
||||
|
||||
# environment variables
|
||||
ENV port=9000
|
||||
ENV github_username=anuraghazra
|
||||
|
||||
# setup folder within the docker container with this app's files
|
||||
WORKDIR /app
|
||||
COPY ./api /app/api
|
||||
COPY ./scripts /app/scripts
|
||||
COPY ./src /app/src
|
||||
COPY ./themes /app/themes
|
||||
COPY ./express.js /app/express.js
|
||||
COPY ./package.json /app/package.json
|
||||
COPY ./package-lock.json /app/package-lock.json
|
||||
|
||||
# prepare script uses a dev-dependency, so remove it,
|
||||
# move express from dev-dependency to regular dependency
|
||||
# then finally install all non-dev dependencies
|
||||
RUN npm pkg delete scripts.prepare \
|
||||
&& npm pkg set dependencies.express="$(node -p "require('./package.json').devDependencies.express")" \
|
||||
&& npm pkg delete devDependencies.express \
|
||||
&& npm ci --omit=dev
|
||||
|
||||
# healthcheck
|
||||
HEALTHCHECK --interval=60m \
|
||||
--retries=3 \
|
||||
--start-interval=1s \
|
||||
--start-period=10s \
|
||||
--timeout=5s \
|
||||
CMD wget --no-verbose -O - --tries=1 "http://127.0.0.1:$port/api/?username=$github_username" | grep 'GitHub Stats' || exit 1
|
||||
|
||||
# start the app, on the supplied port
|
||||
EXPOSE $port
|
||||
CMD [ "node", "express.js" ]
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
services:
|
||||
readme_stats:
|
||||
container_name: readme_stats
|
||||
env_file:
|
||||
- .env
|
||||
expose:
|
||||
- $port
|
||||
init: true
|
||||
image: digitaladapt/github-readme-stats:latest
|
||||
restart: unless-stopped
|
||||
|
||||
caddy:
|
||||
## optional, make caddy wait until the service is ready
|
||||
#depends_on:
|
||||
# readme_stats:
|
||||
# condition: service_healthy
|
||||
## optional, make variables in .env file available to use in your Caddyfile
|
||||
#env_file:
|
||||
# - .env
|
||||
image: caddy:lates
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
- "443:443/udp"
|
||||
volumes:
|
||||
- ./Caddyfile:/etc/caddy/Caddyfile:ro
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
Get dynamically generated GitHub stats on your READMEs, with the ease of docker!
|
||||
|
||||
Fork of [https://github.com/anuraghazra/github-readme-stats](https://github.com/anuraghazra/github-readme-stats), gently wrapped in docker.
|
||||
|
||||
Now as an image on Docker Hub.
|
||||
|
||||
**Steps to setup:**
|
||||
* add the readme_stats service to your existing docker-compose.yml.
|
||||
* configure your .env to have `PAT_1=<YOUR_GITHUB_TOKEN>`.
|
||||
* optionally configure `port`, and `github_username`
|
||||
* update your existing Caddyfile.
|
||||
* and start with `docker compose up -d`.
|
||||
|
||||
docker-compose.yml.example, Caddyfile.example, and env.example have a very simple working example using Caddy reverse proxy.
|
||||
|
||||
Files have example in their name, so that when you update, your local settings won't be overridden.
|
||||
|
||||
```
|
||||
git clone https://code.digitaladapt.com/andrew/github-readme-stats.git
|
||||
cd github-readme-stats
|
||||
cp docker-compose.yml.example docker-compose.yml
|
||||
cp env.example .env
|
||||
vim .env
|
||||
# add your github token
|
||||
|
||||
cp Caddyfile.example Caddyfile
|
||||
vim Caddyfile
|
||||
# configure your domain
|
||||
|
||||
docker compose up -d
|
||||
```
|
||||
|
||||
@@ -0,0 +1,351 @@
|
||||
<p align="center">
|
||||
<img width="100px" src="https://res.cloudinary.com/anuraghazra/image/upload/v1594908242/logo_ccswme.svg" align="center" alt="GitHub Readme Stats" />
|
||||
<h2 align="center">GitHub Readme Stats</h2>
|
||||
<p align="center">在你的 README 中获取动态生成的 GitHub 统计信息!</p>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/actions">
|
||||
<img alt="Tests Passing" src="https://github.com/anuraghazra/github-readme-stats/workflows/Test/badge.svg" />
|
||||
</a>
|
||||
<a href="https://codecov.io/gh/anuraghazra/github-readme-stats">
|
||||
<img src="https://codecov.io/gh/anuraghazra/github-readme-stats/branch/master/graph/badge.svg" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues">
|
||||
<img alt="Issues" src="https://img.shields.io/github/issues/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/pulls">
|
||||
<img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="#demo">查看 Demo</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">报告 Bug</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">请求增加功能</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="/docs/readme_fr.md">Français</a>
|
||||
·
|
||||
<a href="/docs/readme_cn.md">简体中文</a>
|
||||
·
|
||||
<a href="/docs/readme_es.md">Español</a>
|
||||
·
|
||||
<a href="/docs/readme_de.md">Deutsch</a>
|
||||
·
|
||||
<a href="/docs/readme_ja.md">日本語</a>
|
||||
·
|
||||
<a href="/docs/readme_pt-BR.md">Português Brasileiro</a>
|
||||
·
|
||||
<a href="/docs/readme_it.md">Italiano</a>
|
||||
·
|
||||
<a href="/docs/readme_kr.md">한국어</a>
|
||||
.
|
||||
<a href="/docs/readme_nl.md">Nederlands</a>
|
||||
.
|
||||
<a href="/docs/readme_np.md">नेपाली</a>
|
||||
</p>
|
||||
</p>
|
||||
<p align="center">喜欢这个项目?请考虑<a href="https://www.paypal.me/anuraghazra">捐赠</a>来帮助它完善!
|
||||
|
||||
# 特性
|
||||
|
||||
- [GitHub 统计卡片](#GitHub-统计卡片)
|
||||
- [GitHub 更多置顶](#GitHub-更多置顶)
|
||||
- [热门语言卡片](#热门语言卡片)
|
||||
- [主题](#主题)
|
||||
- [自定义](#自定义)
|
||||
- [自己部署](#自己部署)
|
||||
|
||||
# GitHub 统计卡片
|
||||
|
||||
将这行代码复制到你的 markdown 文件中,就是如此简单!
|
||||
|
||||
更改 `?username=` 的值为你的 GitHub 用户名。
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
_注: 等级基于用户的统计信息计算得出,详见 [src/calculateRank.js](../src/calculateRank.js)_
|
||||
|
||||
### 隐藏指定统计
|
||||
|
||||
想要隐藏指定统计信息,你可以调用参数 `?hide=`,其值用 `,` 分隔。
|
||||
|
||||
> 选项:`&hide=stars,commits,prs,issues,contribs`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### 将私人项目贡献添加到总提交计数中
|
||||
|
||||
你可以使用参数 `?count_private=true` 把私人贡献计数添加到总提交计数中。
|
||||
|
||||
_注:如果你是自己部署本项目,私人贡献将会默认被计数,如果不是自己部署,你需要分享你的私人贡献计数。_
|
||||
|
||||
> 选项: `&count_private=true`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### 显示图标
|
||||
|
||||
如果想要显示图标,你可以调用 `show_icons=true` 参数,像这样:
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### 主题
|
||||
|
||||
你可以通过现有的主题进行卡片个性化,省去[手动自定义](#自定义)的麻烦。
|
||||
|
||||
通过调用 `?theme=THEME_NAME` 参数,像这样:
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
#### 所有现有主题
|
||||
|
||||
dark, radical, merko, gruvbox, tokyonight, onedark, cobalt, synthwave, highcontrast, dracula
|
||||
|
||||
<img src="https://res.cloudinary.com/anuraghazra/image/upload/v1595174536/grs-themes_l4ynja.png" alt="GitHub Readme Stat Themes" width="600px"/>
|
||||
|
||||
你可以预览[所有可用主题](../themes/README.md)或者签出[主题配置文件](../themes/index.js), 而且如果你喜欢, **你也可以贡献新的主题** :D
|
||||
|
||||
### 自定义
|
||||
|
||||
你可以通过使用 URL 参数的方式,为你的 `Stats Card` 或 `Repo Card` 自定义样式。
|
||||
|
||||
常用选项:
|
||||
|
||||
- `title_color` - 卡片标题颜色 _(十六进制色码)_
|
||||
- `text_color` - 内容文本颜色 _(十六进制色码)_
|
||||
- `icon_color` - 图标颜色(如果可用)_(十六进制色码)_
|
||||
- `bg_color` - 卡片背景颜色 _(十六进制色码)_ **或者** 以 _angle,start,end_ 的形式渐变
|
||||
- `hide_border` - 隐藏卡的边框 _(布尔值)_
|
||||
- `theme` - 主题名称,从[所有可用主题](../themes/README.md)中选择
|
||||
- `cache_seconds` - 手动设置缓存头 _(最小值: 1800,最大值: 86400)_
|
||||
- `locale` - 在卡片中设置语言 _(例如 cn, de, es, 等等)_
|
||||
|
||||
##### bg_color 渐变
|
||||
|
||||
你可以在 bg_color 选项中提供多个逗号分隔的值来呈现渐变,渐变的格式是 :-
|
||||
|
||||
```
|
||||
&bg_color=DEG,COLOR1,COLOR2,COLOR3...COLOR10
|
||||
```
|
||||
|
||||
> 缓存的注意事项: 如果 fork 数和 star 数 少于 1k , Repo 卡片默认缓存是 4 小时 (14400 秒) ,否则是 2 小时(7200)。另请注意缓存被限制为最短 2 小时,最长 24 小时。
|
||||
|
||||
#### 统计卡片专属选项:
|
||||
|
||||
- `hide` - 隐藏特定统计信息 _(以逗号分隔)_
|
||||
- `hide_title` - _(boolean)_
|
||||
- `hide_rank` - _(boolean)_
|
||||
- `show_icons` - _(boolean)_
|
||||
- `include_all_commits` - 统计总提交次数而不是仅统计今年的提交次数 _(boolean)_
|
||||
- `count_private` - 统计私人提交 _(boolean)_
|
||||
- `line_height` - 设置文本之间的行高 _(number)_
|
||||
|
||||
#### Repo 卡片专属选项:
|
||||
|
||||
- `show_owner` - 显示 Repo 的所有者名字 _(boolean)_
|
||||
|
||||
#### 语言卡片专属选项:
|
||||
|
||||
- `hide` - 从卡片中隐藏指定语言 _(Comma seperated values)_
|
||||
- `hide_title` - _(boolean)_
|
||||
- `layout` - 在两个可用布局 `default` & `compact` 间切换
|
||||
- `card_width` - 手动设置卡片的宽度 _(number)_
|
||||
|
||||
> :warning: **重要:**
|
||||
> 如 [Percent Encoding](https://en.wikipedia.org/wiki/Percent-encoding) 所指定,语言名称应使用 uri 转义。
|
||||
> (例: `c++` 应该是 `c%2B%2B`, `jupyter notebook` 应该是 `jupyter%20notebook`, 等.)
|
||||
|
||||
---
|
||||
|
||||
# GitHub 更多置顶
|
||||
|
||||
GitHub 更多置顶 允许你在使用 GitHub readme profile 时,在个人资料中置顶多于 6 个 repo 。
|
||||
|
||||
是的!你不再受限于置顶最多 6 个存储库了。
|
||||
|
||||
### 使用细则
|
||||
|
||||
复制粘贴这段代码到你的 README 文件中,并更改链接。
|
||||
|
||||
端点: `api/pin?username=anuraghazra&repo=github-readme-stats`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Demo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
使用 [show_owner](#自定义) 变量将 Repo 所有者的用户名包含在内。
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# 热门语言卡片
|
||||
|
||||
热门语言卡片显示了 GitHub 用户常用的编程语言。
|
||||
|
||||
_注意:热门语言并不表示我的技能水平或类似的水平,它是用来衡量用户在 github 上拥有最多代码的语言的一项指标,它是 github-readme-stats 的新特性_
|
||||
|
||||
### 使用细则
|
||||
|
||||
将此代码复制粘贴到您的 `README.md` 文件中,并修改链接。
|
||||
|
||||
端点: `api/top-langs?username=anuraghazra`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### 隐藏指定语言
|
||||
|
||||
可以使用 `?hide=language1,language2` 参数来隐藏指定的语言。
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### 紧凑的语言卡片布局
|
||||
|
||||
你可以使用 `&layout=compact` 参数来改变卡片的样式。
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Demo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- 紧凑布局
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### 全部 Demos
|
||||
|
||||
- 默认
|
||||
|
||||

|
||||
|
||||
- 隐藏指定统计
|
||||
|
||||

|
||||
|
||||
- 显示图标
|
||||
|
||||

|
||||
|
||||
- 包含全部提交
|
||||
|
||||

|
||||
|
||||
- 主题
|
||||
|
||||
从[默认主题](#主题)中进行选择
|
||||
|
||||

|
||||
|
||||
- 渐变
|
||||
|
||||

|
||||
|
||||
- 自定义统计卡片
|
||||
|
||||

|
||||
|
||||
- 自定义 repo 卡片
|
||||
|
||||

|
||||
|
||||
- 热门语言
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### 快速提示 (对齐 Repo 卡片)
|
||||
|
||||
你通常无法将图片靠边显示。为此,您可以使用以下方法:
|
||||
|
||||
```html
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/convoychat">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=convoychat" />
|
||||
</a>
|
||||
```
|
||||
|
||||
## 自己部署
|
||||
|
||||
#### [Check Out Step By Step Video Tutorial By @codeSTACKr](https://youtu.be/n6d4KHSKqGk?t=107)
|
||||
|
||||
因为 GitHub 的 API 每个小时只允许 5 千次请求,我的 `https://github-readme-stats.vercel.app/api` 很有可能会触发限制。如果你将其托管在自己的 Vercel 服务器上,那么你就不必为此担心。点击 deploy 按钮来开始你的部署!
|
||||
|
||||
注意: 从 [#58](https://github.com/anuraghazra/github-readme-stats/pull/58) 开始,我们应该能够处理超过 5 千次的请求,并且不会出现宕机问题 :D
|
||||
|
||||
[](https://vercel.com/import/project?template=https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
<details>
|
||||
<summary>设置 Vercel 的指导</summary>
|
||||
|
||||
1. 前往 [vercel.com](https://vercel.com/)
|
||||
1. 点击 `Log in`
|
||||

|
||||
1. 点击 `Continue with GitHub` 通过 GitHub 进行登录
|
||||

|
||||
1. 登录 GitHub 并允许访问所有存储库(如果系统这样提示)
|
||||
1. Fork 这个仓库
|
||||
1. 返回到你的 [Vercel dashboard](https://vercel.com/dashboard)
|
||||
1. 选择 `Import Project`
|
||||

|
||||
1. 选择 `Import Git Repository`
|
||||

|
||||
1. 选择 root 并将所有内容保持不变,并且只需添加名为 PAT_1 的环境变量(如图所示),其中将包含一个个人访问令牌(PAT),你可以在[这里](https://github.com/settings/tokens/new)轻松创建(保留默认,并且只需要命名下,名字随便)
|
||||

|
||||
1. 点击 deploy,这就完成了,查看你的域名就可使用 API 了!
|
||||
|
||||
</details>
|
||||
|
||||
## :sparkling_heart: 支持这个项目
|
||||
|
||||
我尽己所能地进行开源,并且我尽量回复每个在使用项目时需要帮助的人。很明显,这需要时间,但你可以免费享受这些。
|
||||
|
||||
然而, 如果你正在使用这个项目并感觉良好,或只是想要支持我继续开发,你可以通过如下方式:
|
||||
|
||||
- 在你的 readme 中使用 github-readme-stats 时,链接指向这里 :D
|
||||
- Star 并 分享这个项目 :rocket:
|
||||
- [](https://www.paypal.me/anuraghazra) - 你可以通过 PayPal 一次性捐款. 我多半会买一杯 ~~咖啡~~ 茶. :tea:
|
||||
|
||||
谢谢! :heart:
|
||||
|
||||
---
|
||||
|
||||
[](https://vercel.com?utm_source=github_readme_stats_team&utm_campaign=oss)
|
||||
|
||||
欢迎贡献! <3
|
||||
|
||||
用 :heart: 发电,用 JavaScript 制作。
|
||||
@@ -0,0 +1,374 @@
|
||||
<p align="center">
|
||||
<img width="100px" src="https://res.cloudinary.com/anuraghazra/image/upload/v1594908242/logo_ccswme.svg" align="center" alt="GitHub Readme Stats" />
|
||||
<h2 align="center">GitHub Readme Statistiken</h2>
|
||||
<p align="center">Zeige dynamisch generierte GitHub-Statistiken in deinen Readmes!</p>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/actions">
|
||||
<img alt="Tests Passing" src="https://github.com/anuraghazra/github-readme-stats/workflows/Test/badge.svg" />
|
||||
</a>
|
||||
<a href="https://codecov.io/gh/anuraghazra/github-readme-stats">
|
||||
<img src="https://codecov.io/gh/anuraghazra/github-readme-stats/branch/master/graph/badge.svg" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues">
|
||||
<img alt="Issues" src="https://img.shields.io/github/issues/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/pulls">
|
||||
<img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="#demo">Beispiele ansehen</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Fehler melden</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Funktion wünschen</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="/docs/readme_fr.md">Français</a>
|
||||
·
|
||||
<a href="/docs/readme_cn.md">简体中文</a>
|
||||
·
|
||||
<a href="/docs/readme_es.md">Español</a>
|
||||
·
|
||||
<a href="/docs/readme_de.md">Deutsch</a>
|
||||
·
|
||||
<a href="/docs/readme_ja.md">日本語</a>
|
||||
·
|
||||
<a href="/docs/readme_pt-BR.md">Português Brasileiro</a>
|
||||
·
|
||||
<a href="/docs/readme_it.md">Italiano</a>
|
||||
·
|
||||
<a href="/docs/readme_kr.md">한국어</a>
|
||||
.
|
||||
<a href="/docs/readme_nl.md">Nederlands</a>
|
||||
.
|
||||
<a href="/docs/readme_np.md">नेपाली</a>
|
||||
</p>
|
||||
</p>
|
||||
<p align="center">Du magst das Projekt? Wie wäre es mit einer kleinen <a href="https://www.paypal.me/anuraghazra">Spende</a> um es weiterhin am Leben zu erhalten?
|
||||
|
||||
# Funktionen
|
||||
|
||||
- [GitHub Statistiken-Karte](#github-statistiken-karte)
|
||||
- [GitHub Extra Pins](#github-extra-pins)
|
||||
- [Top Programmiersprachen-Karte](#top-programmiersprachen-karte)
|
||||
- [Wakatime Wochen-Statistik](#wakatime-wochen-statistik)
|
||||
- [Erscheinungsbild/Themes](#erscheinungsbildthemes)
|
||||
- [Anpassungen/Personalisierung](#anpassungenpersonalisierung)
|
||||
- [Selber betreiben](#betreibe-es-auf-deiner-eigenen-vercel-instanz)
|
||||
|
||||
# GitHub Statistiken-Karte
|
||||
|
||||
Kopiere folgendes in deine Readme um die Statistiken zu benutzen.
|
||||
Passe den Wert des URL-Parameters `?username=` so an, dass dort dein GitHub-Nutzername steht.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
_Hinweis: Die Berechnung des Ranges basiert auf den jeweiligen Benutzerstatistiken, siehe [src/calculateRank.js](../src/calculateRank.js)_
|
||||
|
||||
### Verbergen individueller Statistiken
|
||||
|
||||
Um eine spezifische Statistik auszublenden, kann dem Query-Parameter `?hide=` ein Array an Optionen, die nicht angezeigt werden sollen, übergeben werden.
|
||||
|
||||
> Optionen: `&hide=stars,commits,prs,issues,contribs`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Symbole anzeigen
|
||||
|
||||
Um Symbole anzuzeigen kann der URL-Parameter `show_icons=true` wie folgt verwendet werden:
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Erscheinungsbild/Themes
|
||||
|
||||
Mithilfe der eingebauten Themes kann das Aussehen der Karten verändern werden, ohne manuelle Anpassungen vornehmen zu müssen.
|
||||
|
||||
Benutze den `?theme=THEME_NAME`-Parameter wie folgt :-
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
#### Alle eingebauten Themes :-
|
||||
|
||||
dark, radical, merko, gruvbox, tokyonight, onedark, cobalt, synthwave, highcontrast, dracula
|
||||
|
||||
<img src="https://res.cloudinary.com/anuraghazra/image/upload/v1595174536/grs-themes_l4ynja.png" alt="GitHub Readme Stat Themes" width="600px"/>
|
||||
|
||||
Du kannst dir eine Vorschau [aller verfügbaren Themes](../themes/README.md) ansehen oder die [theme config Datei](../themes/index.js) ansehen.
|
||||
Außerdem **kannst du neue Themes erstellen**, Beiträge an diesem Projekt sind gerne gesehen! :D
|
||||
|
||||
### Anpassungen/Personalisierung
|
||||
|
||||
Du kannst das Erscheinungsbild deiner `Stats Card` oder `Repo Card`, mithilfe von URL-Parametern, nach deinen Vorlieben anpassen.
|
||||
|
||||
#### Verbreitete Optionen:
|
||||
|
||||
- `title_color` - Titelfarbe _(hex color)_
|
||||
- `text_color` - Textkörperfarbe _(hex color)_
|
||||
- `icon_color` - Symbolfarbe (falls verfügbar) _(hex color)_
|
||||
- `bg_color` - Hintergrundfarbe _(hex color)_ **oder** ein Farbverlauf in der Form von _winkel,start,ende_
|
||||
- `hide_border` - Blendet den Rand der Karte aus _(Boolean)_
|
||||
- `theme` - Name des Erscheinungsbildes/Themes [alle verfügbaren Themes](../themes/README.md)
|
||||
- `cache_seconds` - manuelles festlegen der Cachezeiten _(min: 1800, max: 86400)_
|
||||
- `locale` - Stellen Sie die Sprache auf der Karte ein _(z.B. cn, de, es, etc.)_
|
||||
|
||||
##### Farbverlauf in bg_color
|
||||
|
||||
Du kannst mehrere, mit Kommas separierte, Werte in der bg_color Option angeben, um einen Farbverlauf anzuzeigen. Das Format ist:-
|
||||
|
||||
```
|
||||
&bg_color=WINKEL,FARBE1,FARBE2,FARBE3...FARBE10
|
||||
```
|
||||
|
||||
> Hinweis bzgl. des Caches: Wenn die Anzahl der Forks und Stars geringer als 1 Tsd. ist, haben die Repo-Cards eine Standard-Cachezeit von 30 Minuten (1800 Sekunden), ansonsten beträgt diese 2 Stunden (7200 Sekunden). Außerdem ist der Cache auf ein Minimum von 30 Minuten und ein Maximum von 24 Stunden begrenzt.
|
||||
|
||||
#### Exklusive Optionen der Statistiken-Karte:
|
||||
|
||||
- `hide` - Verbirgt die [angegeben Elemente](#verbergen-individueller-statistiken) _(mit Komma abgegrenzte Werte)_
|
||||
- `hide_title` - _(Boolean)_
|
||||
- `hide_rank` - _(Boolean)_
|
||||
- `show_icons` - _(Boolean)_
|
||||
- `include_all_commits` - Zähle alle Beiträge anstatt nur das aktuelle Jahr _(Boolean)_
|
||||
- `count_private` - Zähle private Beiträge _(Boolean)_
|
||||
- `line_height` - Legt die Zeilenhöhe zwischen Text fest _(Zahl)_
|
||||
|
||||
#### Exklusive Optionen der Repo-Karte:
|
||||
|
||||
- `show_owner` - Zeigt den Besitzer des Repos _(Boolean)_
|
||||
|
||||
#### Exklusive Optionen der Sprachen-Karte:
|
||||
|
||||
- `hide` - Verbirgt die angegebenen Sprachen von der Karte _(Komma separierte Werte)_
|
||||
- `hide_title` - _(Boolean)_
|
||||
- `layout` - Wechsel zwischen den zwei verfügbaren Layouts `default` & `compact`
|
||||
- `card_width` - Lege die Breite der Karte manuell fest _(Zahl)_
|
||||
|
||||
> :warning: **Wichtig:**
|
||||
> Sprachennamen sollten uri-escaped sein, wie hier angegeben: [Percent Encoding](https://en.wikipedia.org/wiki/Percent-encoding)
|
||||
> (z.B.: `c++` sollte zu `c%2B%2B` werden, `jupyter notebook` sollte zu `jupyter%20notebook` werden, usw.)
|
||||
|
||||
#### Exklusive Optionen der WakaTime-Karte:
|
||||
|
||||
- `hide_title` - _(Boolean)_
|
||||
- `line_height` - Legt die Zeilenhöhe des Texts fest _(Zahl)_
|
||||
- `hide_progress` - Verbirgt die Fortschrittsanzeige und Prozentzahl _(Boolean)_
|
||||
- `custom_title` - Legt einen benutzerdefinierten Titel fest
|
||||
- `layout` - Wechselt zwischen zwei verschiedenen Layouts: `default` & `compact`
|
||||
- `langs_count` - Begrenzt die Anzahl der angezeigten Sprachen auf der Karte
|
||||
- `api_domain` - Legt eine benutzerdefinierte API Domain fest, z.B. für [Hakatime](https://github.com/mujx/hakatime) oder [Wakapi](https://github.com/muety/wakapi)
|
||||
- `range` – Fragt eine andere Zeitspanne an, als jene, welche standardmäßig in Wakatime hinterlegt ist. Zum Beispiel `last_7_days`. Siehe [WakaTime API Dokumentation](https://wakatime.com/developers#stats).
|
||||
|
||||
---
|
||||
|
||||
# GitHub Extra-Pins
|
||||
|
||||
GitHub Extra-Pins ermöglicht es mit Hilfe einer Readme auf deinem Profil mehr als 6 Repositories anzuzeigen.
|
||||
|
||||
Und Bääm! Du bist nicht mehr auf 6 angeheftete Repositories limitiert.
|
||||
|
||||
### Benutzung
|
||||
|
||||
Füge diesen Code in deine Readme-Datei ein und passe die Links an.
|
||||
Passe den Wert des URL-Parameters `?username=` so an, dass dort dein GitHub-Nutzername steht.
|
||||
Den Wert des URL-Parameters `?repo=` musst du so anpassen, dass dort der Namen deines Repositorys steht.
|
||||
|
||||
Endpunkt: `api/pin?username=anuraghazra&repo=github-readme-stats`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Beispiele
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
Benutze die [show_owner](#anpassungenpersonalisierung) Variable, um den Nutzernamen des Repository-Eigentümers anzuzeigen.
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# Top Programmiersprachen-Karte
|
||||
|
||||
Die Top Programmiersprachen-Karte visualisiert die am meisten benutzten Programmiersprachen eines GitHub-Nutzers.
|
||||
|
||||
_HINWEIS: Die Top Programmiersprachen treffen keine Aussage über persönliche Fähigkeiten oder dergleichen, es ist lediglich eine auf den GitHub-Statistiken des Nutzers basierende Kennzahl, welche Programmiersprache wie häufig verwendet wurde._
|
||||
|
||||
### Benutzung
|
||||
|
||||
Füge diesen Code in deine Readme-Datei ein und passe die Links an.
|
||||
Passe den Wert des URL-Parameters `?username=` so an, dass dort dein GitHub-Nutzername steht.
|
||||
|
||||
Endpunkt: `api/top-langs?username=anuraghazra`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Verbirg einzelne Sprachen
|
||||
|
||||
Du kannst den `?hide=language1,language2` URL-Parameter benutzen, um einzelne Sprachen auszublenden.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Kompaktes Sprachen-Karte Layout
|
||||
|
||||
Du kannst die `&layout=compact` Option nutzen, um das Kartendesign zu ändern.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Beispiel
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Kompaktes Layout
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# Wakatime Wochen-Statistik
|
||||
|
||||
Ändere `?username=` in den eigenen [Wakatime](https://wakatime.com)-Benutzernamen.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Beispiel
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Kompaktes Layout
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### Alle Beispiele
|
||||
|
||||
- Default
|
||||
|
||||

|
||||
|
||||
- Ausblenden bestimmter Statistiken
|
||||
|
||||

|
||||
|
||||
- Symbole anzeigen
|
||||
|
||||

|
||||
|
||||
- Alle Beiträge anzeigen
|
||||
|
||||

|
||||
|
||||
- Erscheinungsbild/Themes
|
||||
|
||||
Wähle Eines von den [Standard-Themes](#themes)
|
||||
|
||||

|
||||
|
||||
- Farbverlauf
|
||||
|
||||

|
||||
|
||||
- Statistiken-Karte anpassen
|
||||
|
||||

|
||||
|
||||
- Repo-Karte(Extra-Pin) anpassen
|
||||
|
||||

|
||||
|
||||
- Top Programmiersprachen
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### Kleiner Tipp (Ausrichten der Repo-Karte)
|
||||
|
||||
Üblicherweise ist es in `.md`-Dateien nicht möglich Bilder nebeneinander anzuzeigen. Um dies zu ermöglichen, kannst du folgendes tun:
|
||||
|
||||
```html
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/convoychat">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=convoychat" />
|
||||
</a>
|
||||
```
|
||||
|
||||
## Betreibe es auf deiner eigenen Vercel-Instanz
|
||||
|
||||
#### [Schritt für Schritt YouTube Tutorial by @codeSTACKr](https://youtu.be/n6d4KHSKqGk?t=107)
|
||||
|
||||
Da die GitHub API nur 5 Tsd. Aufrufe pro Stunde zulässt, kann es passieren, dass meine `https://github-readme-stats.vercel.app/api` dieses Limit erreicht.
|
||||
Wenn du es auf deinem eigenen Vercel-Server hostest, brauchst du dich darum nicht zu kümmern. Klicke auf den Deploy-Knopf um loszulegen!
|
||||
|
||||
Hinweis: Seit [#58](https://github.com/anuraghazra/github-readme-stats/pull/58) sollte es möglich sein, mehr als 5 Tsd Aufrufe pro Stunde ohne Downtimes zu verkraften :D
|
||||
|
||||
[](https://vercel.com/import/project?template=https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
<details>
|
||||
<summary><b>Anleitung zum Einrichten von Vercel 🔨 </b></summary>
|
||||
|
||||
1. Gehe zu [vercel.com](https://vercel.com/)
|
||||
1. Klicke auf `Log in`
|
||||

|
||||
1. Melde dich mit deinem GitHub-account an, indem du `Continue with GitHub` klickst
|
||||

|
||||
1. Verbinde dich mit GitHub und erlaube den Zugriff auf alle Repositories (falls gefordert)
|
||||
1. Forke dieses Repository
|
||||
1. Gehe zurück zu deinem [Vercel Dashboard](https://vercel.com/dashboard)
|
||||
1. Klick `Import Project`
|
||||

|
||||
1. Klick `Import Git Repository`
|
||||

|
||||
1. Wähle root und füge eine Umgebungsvariable namens PAT_1 (siehe Abbildung) die als Wert deinen persönlichen Access Token (PAT) hat hinzu, den du einfach [hier](https://github.com/settings/tokens/new) erzeugen kannst (lasse alles wie es ist, vergebe einen beliebigen Namen)
|
||||

|
||||
1. Klicke auf `Deploy`, und das wars. Besuche deine Domains um die API zu benutzen!
|
||||
</details>
|
||||
|
||||
## :sparkling_heart: Unterstütze das Projekt
|
||||
|
||||
Ich versuche alles was ich kann als Open-Source zur Verfügung zu stellen, als auch jedem der Hilfe bei der Benutzung dieses Projektes braucht zu antworten. Natürlich beansprucht sowas Zeit und du kannst diesen Dienst kostenlos benutzen.
|
||||
|
||||
Wenn du dieses Projekt nutzt und zufrieden bist, kannst du dennoch Dinge tun um mich weiterhin zu motivieren am Projekt zu arbeiten:
|
||||
|
||||
- Erwähne und verlinke das Projekt in deiner Readme wenn du es benutzt :D
|
||||
- Geb dem Projekt einen Stern hier auf GitHub und teile es :rocket:
|
||||
- [](https://www.paypal.me/anuraghazra) - Du kannst einmalige Spenden via PayPal tätigen. Ich kaufe mir wahrscheinlich einen ~~Kaffee~~ Tee davon. :tea:
|
||||
|
||||
Vielen Dank! :heart:
|
||||
|
||||
---
|
||||
|
||||
[](https://vercel.com?utm_source=github_readme_stats_team&utm_campaign=oss)
|
||||
|
||||
|
||||
Mitarbeit an dem Projekt ist immer Willkommen! <3
|
||||
|
||||
Gemacht mit viel :heart: und JavaScript.
|
||||
@@ -0,0 +1,412 @@
|
||||
<p align="center">
|
||||
<img width="100px" src="https://res.cloudinary.com/anuraghazra/image/upload/v1594908242/logo_ccswme.svg" align="center" alt="GitHub Readme Stats" />
|
||||
<h2 align="center">GitHub Readme Stats</h2>
|
||||
<p align="center">¡Obtén tus estadísticas de GitHub generadas dinámicamente en tu README!</p>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/actions">
|
||||
<img alt="Tests Passing" src="https://github.com/anuraghazra/github-readme-stats/workflows/Test/badge.svg" />
|
||||
</a>
|
||||
<a href="https://codecov.io/gh/anuraghazra/github-readme-stats">
|
||||
<img src="https://codecov.io/gh/anuraghazra/github-readme-stats/branch/master/graph/badge.svg" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues">
|
||||
<img alt="Issues" src="https://img.shields.io/github/issues/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/pulls">
|
||||
<img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Apoyado%20por-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Apoyado%20por-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="#ejemplo">Ver un ejemplo</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Reportar un bug</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Solicitar una mejora</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="/docs/readme_fr.md">Français</a>
|
||||
·
|
||||
<a href="/docs/readme_cn.md">简体中文</a>
|
||||
·
|
||||
<a href="/docs/readme_es.md">Español</a>
|
||||
·
|
||||
<a href="/docs/readme_de.md">Deutsch</a>
|
||||
·
|
||||
<a href="/docs/readme_ja.md">日本語</a>
|
||||
·
|
||||
<a href="/docs/readme_pt-BR.md">Português Brasileiro</a>
|
||||
·
|
||||
<a href="/docs/readme_it.md">Italiano</a>
|
||||
·
|
||||
<a href="/docs/readme_kr.md">한국어</a>
|
||||
.
|
||||
<a href="/docs/readme_nl.md">Nederlands</a>
|
||||
.
|
||||
<a href="/docs/readme_tr.md">Türkçe</a>
|
||||
.
|
||||
<a href="/docs/readme_np.md">नेपाली</a>
|
||||
</p>
|
||||
</p>
|
||||
<p align="center">¿Te gusta este proyecto? ¡Por favor, considera <a href="https://www.paypal.me/anuraghazra">donar</a> para ayudar a mejorarlo!
|
||||
|
||||
# Características
|
||||
|
||||
- [Tarjeta de estadísticas de GitHub](#tarjeta-de-estadísticas-de-github)
|
||||
- [Pins adicionales de GitHub](#pines-adicionales-de-github)
|
||||
- [Tarjeta de Lenguajes Principales](#tarjeta-de-lenguajes-principales)
|
||||
- [Wakatime Week Stats](#estadísticas-de-la-semana-de-wakatime)
|
||||
- [Temas](#temas)
|
||||
- [Personalización](#personalización)
|
||||
- [Despliega por tu cuenta](#despliega-tu-propia-instancia-de-vercel)
|
||||
|
||||
# Tarjeta de estadísticas de GitHub
|
||||
|
||||
Copia y pega esto en el contenido de tu README.md y listo. ¡Simple!
|
||||
|
||||
Cambia el valor de `?username=` al nombre de tu usuario de GitHub.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
_Nota: Los rangos disponibles son S+ (top 1%), S (top 25%), A++ (top 45%), A+ (top 60%) y B+ (todos). Los valores se calculan utilizando la [función de distribución acumulada](https://es.wikipedia.org/wiki/Funci%C3%B3n_de_distribuci%C3%B3n) utilizando commits, contribuciones, issues, estrellas, pull request, seguidores y repositorios propios. Puedes investigar más sobre la implementación en [src/calculateRank.js](../src/calculateRank.js)._
|
||||
|
||||
### Ocultar estadísticas individualmente
|
||||
|
||||
Para ocultar alguna estadística específica, puedes utilizar el parámetro `?hide=` con los elementos que quieras ocultar separados por comas.
|
||||
|
||||
> Opciones: `&hide=stars,commits,prs,issues,contribs`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Agregar contribuciones privadas al total de commits contados
|
||||
|
||||
Puedes agregar el recuento de todas sus contribuciones privadas al recuento total de commits utilizando el parámetro `?count_private=true`.
|
||||
|
||||
_Nota: Si estás desplegando este proyecto tú mismo, las contribuciones privadas se contarán de manera predeterminada; de lo contrario, deberás elegir compartir el recuento de sus contribuciones privadas._
|
||||
|
||||
> Opciones: `&count_private=true`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Mostrar íconos
|
||||
|
||||
Para habilitar los íconos, puedes utilizar `show_icons=true` como parámetro, de esta manera:
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Temas
|
||||
|
||||
Puedes personalizar el aspecto de la tarjeta sin realizar ninguna [personalización manual](#personalización) con los temas incorporados.
|
||||
|
||||
Utiliza el parámetro `?theme=THEME_NAME`, de esta manera:
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
#### Todos los temas incorporados
|
||||
|
||||
dark, radical, merko, gruvbox, tokyonight, onedark, cobalt, synthwave, highcontrast, dracula
|
||||
|
||||
<img src="https://res.cloudinary.com/anuraghazra/image/upload/v1595174536/grs-themes_l4ynja.png" alt="GitHub Readme Stat Themes" width="600px"/>
|
||||
|
||||
Puedes ver una vista previa de [todos los temas disponibles](../themes/README.md) o ver el [archivo de configuración](../themes/index.js) del tema y también **puedes contribuir con nuevos temas** si lo deseas :D
|
||||
|
||||
### Personalización
|
||||
|
||||
Puedes personalizar el aspecto de tu `Tarjeta de Estadísticas` o `Tarjeta de Repo` de la manera que desees con los parámetros URL.
|
||||
|
||||
#### Opciones Comunes:
|
||||
|
||||
- `title_color` - Color del título _(hex color)_
|
||||
- `text_color` - Color del contenido _(hex color)_
|
||||
- `icon_color` - Color de icono si esta disponible _(hex color)_
|
||||
- `bg_color` - Color de fondo _(hex color)_
|
||||
- `hide_border` - Oculta el borde de la tarjeta _(booleano)_
|
||||
- `theme` - Nombre del tema, elige uno de [todos los temas disponible ](../themes/README.md)
|
||||
- `cache_seconds` - Cache _(min: 1800, max: 86400)_
|
||||
- `locale` - configurar el idioma en la tarjeta _(p.ej. cn, de, es, etc.)_
|
||||
|
||||
##### Gradiente en `bg_color`
|
||||
|
||||
Puedes pasar mútliples valores separados por coma en la opción `bg_color` para dibujar un gradiente, el formato del gradiente es:
|
||||
|
||||
```
|
||||
&bg_color=DEG,COLOR1,COLOR2,COLOR3...COLOR10
|
||||
```
|
||||
|
||||
> Nota sobre la caché: las tarjetas de Repo tienen un caché predeterminado de 4 horas (14400 segundos) si el recuento forks y el recuento de estrellas es inferior a 1k; de lo contrario, son 2 horas (7200 segundos). También ten en cuenta que la caché está sujeta a un mínimo de 2 horas y un máximo de 24 horas
|
||||
|
||||
#### Opciones exclusivas de la Tarjeta de Estadísticas:
|
||||
|
||||
- `hide` - Oculta de las estadísticas [los elementos especificados](#ocultar-estadísticas-individualmente) _(valores separados por comas)_
|
||||
- `hide_title` - _(booleano)_
|
||||
- `hide_rank` - _(booleano)_
|
||||
- `show_icons` - _(booleano)_
|
||||
- `include_all_commits` - Cuenta el total de commits en lugar de solo los commits del año actual _(boolean)_
|
||||
- `count_private` - Cuenta los commits privadas _(boolean)_
|
||||
- `line_height` - Establece el alto de línea entre texto _(número)_
|
||||
- `custom_title` - Establece un título personalizado
|
||||
- [`disable_animations`] - Desactiva todas las animaciones _(booleano)_
|
||||
|
||||
#### Opciones exclusivas de la Tarjeta de Repo:
|
||||
|
||||
- `show_owner` - Mostrar el nombre del propietario del repositorio _(booleano)_
|
||||
|
||||
#### Opciones exclusivas de la Tarjeta de Lenguajes:
|
||||
|
||||
- `hide` - Oculta de la tarjeta los lenguajes especificados _(valores separados por comas)_
|
||||
- `hide_title` - _(booleano)_
|
||||
- `layout` - Cambia entre los dos diseños disponibles `default` & `compact`
|
||||
- `card_width` - Establece el ancho de la tarjeta manualmente _(número)_
|
||||
- `langs_count` - Muestra más lenguajes en la tarjeta, entre 1-10, por defecto 5 _(número)_
|
||||
- `exclude_repo` - Excluye los repositorios especificados _(valores separados por comas)_
|
||||
- `custom_title` - Establece un título personalizado
|
||||
|
||||
> :warning: **Importante:**
|
||||
> Los nombres de los lenguajes deben estar codificados para URLs, como se especifica en [Código porciento](https://es.wikipedia.org/wiki/C%C3%B3digo_porciento)
|
||||
> (es decir: `c++` debería convertirse en `c%2B%2B`,`jupyter notebook` debería convertirse en `jupyter%20notebook`, etc.)
|
||||
|
||||
#### Opciones exclusivas de la Tarjeta de Wakatime:
|
||||
|
||||
- `hide_title` - _(booleano)_
|
||||
- `line_height` - Establece el alto de línea entre texto _(número)_
|
||||
- `hide_progress` - Oculta la barra de progreso y el porcentaje _(booleano)_
|
||||
- `custom_title` - Establece un título personalizado
|
||||
- `layout` - Cambia entre los dos diseños disponibles `default` & `compact`
|
||||
- `langs_count` - Limita el número de idiomas que aparecen en el mapa
|
||||
- `api_domain` - Establece un dominio de API personalizado para la tarjeta
|
||||
|
||||
---
|
||||
|
||||
# Pines adicionales de GitHub
|
||||
|
||||
Los pines adicionales de GitHub le permiten fijar más de 6 repositorios en su perfil utilizando un perfil readme de GitHub.
|
||||
|
||||
¡Yey! Ya no está limitado a 6 repositorios pinneados.
|
||||
|
||||
### Utilización
|
||||
|
||||
Copia y pegua este código en tu Readme y cambia los enlaces.
|
||||
|
||||
Endpoint: `api/pin?username=anuraghazra&repo=github-readme-stats`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Ejemplo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
Utiliza la variable [show_owner](#customización) para incluir el nombre de usuario del propietario del repositorio.
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# Tarjeta de Lenguajes Principales
|
||||
|
||||
La tarjeta de lenguajes principales muestra los lenguajes principales del usuario de GitHub que se han utilizado principalmente.
|
||||
|
||||
_NOTA: los lenguajes principales no indican mi nivel de habilidad o algo así, es una métrica de GitHub de los lenguajes que tengo más código en GitHub. Es una nueva característica de github-readme-stats_
|
||||
|
||||
### Utilización
|
||||
|
||||
Copia y pegua este código en tu Readme y cambia los enlaces.
|
||||
|
||||
Endpoint: `api/top-langs?username=anuraghazra`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Excluir repositorios individualmente
|
||||
|
||||
Puedes usar el parámetro `?exclude_repo=repo1,repo2` para ocultar repositorios individualmente.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Ocultar lenguajes individualmente
|
||||
|
||||
Puedes usar el parámetro `?hide=language1,language2` para ocultar lenguajes individualmente.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Mostrar más lenguajes
|
||||
|
||||
Puedes usar el paramétro `&langs_count=` para incrementar o decrementar el número de lenguajes mostrados en la tarjeta. Los valores admitidos son los números enteros entre 1 y 10 (inclusive), y el valor por defecto es 5.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Diseño Compacto de Tarjeta de Lenguaje
|
||||
|
||||
Puedes usar la opción `& layout = compact` para cambiar el diseño de la tarjeta.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Ejemplo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Diseño compacto
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# Estadísticas de la semana de Wakatime
|
||||
|
||||
cambia el valor del parámetro `?username=` a tu username en [Wakatime](https://wakatime.com).
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Ejemplo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Diseño compacto
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### Todos los ejemplos
|
||||
|
||||
- Por defecto
|
||||
|
||||

|
||||
|
||||
- Ocultando ciertas estadísticas
|
||||
|
||||

|
||||
|
||||
- Mostrando íconos
|
||||
|
||||

|
||||
|
||||
- Incluyendo todos los commits
|
||||
|
||||

|
||||
|
||||
- Temas
|
||||
|
||||
Escoja cualquiera de los [temas por defecto](#themes)
|
||||
|
||||

|
||||
|
||||
- Gradiente
|
||||
|
||||

|
||||
|
||||
- Personalizando Tarjeta de Estadísticas
|
||||
|
||||

|
||||
|
||||
- Estableciendo Idioma de la tarjeta
|
||||
|
||||

|
||||
|
||||
- Personalizando Tarjeta de Repo
|
||||
|
||||

|
||||
|
||||
- Lenguajes Top
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Tarjeta de Wakatime
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### Consejo rápido (para alinear las tarjetas de repositorio)
|
||||
|
||||
Por lo general, no podrás acomodar las imágenes una al lado de la otra. Para hacerlo, puede usar este enfoque:
|
||||
|
||||
```html
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/convoychat">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=convoychat" />
|
||||
</a>
|
||||
```
|
||||
|
||||
## Despliega tu propia instancia de Vercel
|
||||
|
||||
#### [Échale un vistazo a este tutorial paso a paso de @codeSTACKr](https://youtu.be/n6d4KHSKqGk?t=107)
|
||||
|
||||
Desde que la API de GitHub permite solo 5k peticiones por hora, es posible que mi `https://github-readme-stats.vercel.app/api` pueda llegar al límite. Si lo alojas en tu propio servidor de Vercel, no tendrás que preocuparte de nada. ¡Clickea en el botón "Deploy" para comenzar!
|
||||
|
||||
NOTA: Debido a [#58](https://github.com/anuraghazra/github-readme-stats/pull/58) podríamos manejar más de 5k peticiones sin tener ningún problema con el downtime :D
|
||||
|
||||
[](https://vercel.com/import/project?template=https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
<details>
|
||||
<summary>Guía para comenzar en Vercel</summary>
|
||||
|
||||
1. Ve a [vercel.com](https://vercel.com/)
|
||||
2. Clickea en `Log in`
|
||||

|
||||
3. Inicia sesión con GitHub presionando `Continue with GitHub`
|
||||

|
||||
4. Permite el acceso a todos los repositorios (si se te pregunta)
|
||||
5. Haz un Fork de este repositorio
|
||||
6. Dirígete de nuevo a tu [Vercel dashboard](https://vercel.com/dashboard)
|
||||
7. Selecciona `Import Project`
|
||||

|
||||
8. Selecciona `Import Git Repository`
|
||||

|
||||
9. Selecciona "root" y matén todo como está, simplemente añade tu variable de entorno llamada PAT_1 (como se muestra), la cual contendrá un token de acceso personal (PAT), el cual puedes crear fácilmente [aquí](https://github.com/settings/tokens/new) (mantén todo como está, simplemente asígnale un nombre, puede ser cualquiera que desees)
|
||||

|
||||
10. Clickea "Deploy" y ya está listo. ¡Ve tus dominios para usar la API!
|
||||
|
||||
</details>
|
||||
|
||||
## :sparkling_heart: Apoya al proyecto
|
||||
|
||||
Casi todos mis proyectos son de código abierto e intento responder a todos los usuarios que necesiten ayuda con alguno de estos proyectos. Obviamente, esto toma tiempo. Puedes usar este servicio gratis.
|
||||
|
||||
No obstante, si estás utilizando este proyecto y estás feliz con él o simplemente quieres animarme a que siga creando cosas, aquí tienes algunas maneras de hacerlo:
|
||||
|
||||
- Darme créditos cuando estés utilizando github-readme-stats en tu README, añadiendo un link a este repositorio :D
|
||||
- Dándole una estrella y compartiendo el proyecto :rocket:
|
||||
- [](https://www.paypal.me/anuraghazra) - Puedes hacerme una única donación a través de PayPal. Probablemente me compraré un ~~café~~ té. :tea:
|
||||
|
||||
¡Gracias! :heart:
|
||||
|
||||
---
|
||||
|
||||
[](https://vercel.com?utm_source=github_readme_stats_team&utm_campaign=oss)
|
||||
|
||||
¡Las contribuciones son bienvenidas! <3
|
||||
|
||||
Hecho con :heart: y JavaScript.
|
||||
@@ -0,0 +1,352 @@
|
||||
<p align="center">
|
||||
<img width="100px" src="https://res.cloudinary.com/anuraghazra/image/upload/v1594908242/logo_ccswme.svg" align="center" alt="GitHub Readme Stats" />
|
||||
<h2 align="center">GitHub Readme Stats</h2>
|
||||
<p align="center">Obtenez des statistiques GitHub générées dynamiquement sur vos Readme !</p>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/actions">
|
||||
<img alt="Tests Passing" src="https://github.com/anuraghazra/github-readme-stats/workflows/Test/badge.svg" />
|
||||
</a>
|
||||
<a href="https://codecov.io/gh/anuraghazra/github-readme-stats">
|
||||
<img src="https://codecov.io/gh/anuraghazra/github-readme-stats/branch/master/graph/badge.svg" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues">
|
||||
<img alt="Issues" src="https://img.shields.io/github/issues/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/pulls">
|
||||
<img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supporté%20par-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supporté%20par-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="#démo">Voir la démo</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Soumettre un bug</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Demander une nouveauté</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="/docs/readme_fr.md">Français</a>
|
||||
·
|
||||
<a href="/docs/readme_cn.md">简体中文</a>
|
||||
·
|
||||
<a href="/docs/readme_es.md">Español</a>
|
||||
·
|
||||
<a href="/docs/readme_de.md">Deutsch</a>
|
||||
·
|
||||
<a href="/docs/readme_ja.md">日本語</a>
|
||||
·
|
||||
<a href="/docs/readme_pt-BR.md">Português Brasileiro</a>
|
||||
·
|
||||
<a href="/docs/readme_it.md">Italiano</a>
|
||||
·
|
||||
<a href="/docs/readme_kr.md">한국어</a>
|
||||
.
|
||||
<a href="/docs/readme_nl.md">Nederlands</a>
|
||||
.
|
||||
<a href="/docs/readme_np.md">नेपाली</a>
|
||||
</p>
|
||||
</p>
|
||||
<p align="center">Vous aimez ce projet? Pensez <a href="https://www.paypal.me/anuraghazra">à faire un don</a> pour l'améliorer!
|
||||
|
||||
# Features
|
||||
|
||||
- [Carte des stats GitHub](#carte-des-stats-github)
|
||||
- [GitHub Extra Pins](#github-extra-pins)
|
||||
- [Carte des meilleurs langages](#carte-des-langages-les--utilisés)
|
||||
- [Themes](#thèmes)
|
||||
- [Personnalisation](#personnalisation)
|
||||
- [Deployer toi-même](#déployer-sur-votre-propre-instance-vercel)
|
||||
|
||||
# Carte des Stats GitHub
|
||||
|
||||
Copiez-collez ceci dans votre Markdown, et c'est tout. C'est simple !
|
||||
|
||||
Remplacez la valeur `?username=` par le nom d'utilisateur de votre GitHub.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
_Note: Les rangs sont calculés sur la base des statistiques de l'utilisateur, voir [src/calculateRank.js](../src/calculateRank.js)_
|
||||
|
||||
### Cacher les statistiques individuelles
|
||||
|
||||
Pour masquer des statistiques spécifiques, vous pouvez passer un paramètre de requête `?hide=` avec des valeurs séparées par des virgules.
|
||||
|
||||
> Options: `&hide=stars,commits,prs,issues,contribs`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Ajouter le compte des contributions privées au compte des commits totaux
|
||||
|
||||
Vous pouvez ajouter le compte de toutes vos contributions privées au compte total des engagements en utilisant le paramètre de requête `?count_private=true`.
|
||||
|
||||
_Note: Si vous déployez vous-même ce projet, les contributions privées seront comptées par défaut ; sinon, vous devez choisir de partager les comptes de vos contributions privées._
|
||||
|
||||
> Options: `&count_private=true`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Afficher les icônes
|
||||
|
||||
Pour activer les icônes, vous pouvez passer `show_icons=true` dans le paramètre de requête, comme ceci :
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Thèmes
|
||||
|
||||
Avec les thèmes intégrés, vous pouvez personnaliser l'apparence de la carte sans faire de [personnalisation manuelle](#customization).
|
||||
|
||||
Use `?theme=THEME_NAME` parameter like so :-
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
#### Tous les thèmes intégrés :-
|
||||
|
||||
dark, radical, merko, gruvbox, tokyonight, onedark, cobalt, synthwave, highcontrast, dracula
|
||||
|
||||
<img src="https://res.cloudinary.com/anuraghazra/image/upload/v1595174536/grs-themes_l4ynja.png" alt="GitHub Readme Stat Themes" width="600px"/>
|
||||
|
||||
Vous pouvez consulter un aperçu de [tous les thèmes disponibles](../themes/README.md) ou consulter le [fichier de configuration des thèmes](../themes/index.js) & **vous pouvez également ajouter de nouveaux thèmes** si vous le souhaitez :D
|
||||
|
||||
### Personnalisation
|
||||
|
||||
Vous pouvez personnaliser l'apparence de votre `Carte des stats` ou `Carte de dépôt` comme vous le souhaitez avec les paramètres d'URL.
|
||||
|
||||
#### Options principales:
|
||||
|
||||
- `title_color` - Couleur du titre de la carte _(hex color)_
|
||||
- `text_color` - Couleur du texte _(hex color)_
|
||||
- `icon_color` - Couleur des icônes si disponibles _(hex color)_
|
||||
- `bg_color` - Couleur du fond de la carte _(hex color)_ **ou** un gradiant de la forme _angle,start,end_
|
||||
- `hide_border` - Cache la bordure de la carte _(booléen)_
|
||||
- `theme` - Nom du thème, parmis [tous les thèmes disponibles](../themes/README.md)
|
||||
- `cache_seconds` - Paramétrer le cache manuellement _(min: 1800, max: 86400)_
|
||||
- `locale` - définir la langue de la carte _(par exemple. cn, de, es, etc.)_
|
||||
|
||||
##### Gradient in bg_color
|
||||
|
||||
Vous pouvez fournir plusieurs valeurs (suivie d'une virgule) dans l'option bg_color pour rendre un degradé, le format du degradé est :-
|
||||
|
||||
```
|
||||
&bg_color=DEG,COLOR1,COLOR2,COLOR3...COLOR10
|
||||
```
|
||||
|
||||
> Note relative: Les cartes dépôt ont un cache par défaut de 30 minutes (1800 secondes) si le nombre de bifurcations et d'étoiles est inférieur à 1K, alors il est de 2 heures (7200). Notez également que la mémoire cache est limitée à 30 minutes au minimum et à 24 heures au maximum.
|
||||
|
||||
#### Stats Card Exclusive Options:
|
||||
|
||||
- `hide` - Masquer [les éléments spécifiés](#cacher-les-statistiques-individuelles) dans les statistiques _(Comma seperated values)_
|
||||
- `hide_title` - Masquer le titre _(boolean)_
|
||||
- `hide_rank` - Masquer le rang _(boolean)_
|
||||
- `show_icons` - Afficher les icônes _(boolean)_
|
||||
- `include_all_commits` - Compter le total de commits au lieu de ne compter que les commits de l'année en cours _(boolean)_
|
||||
- `count_private` - Compter les commits privés _(boolean)_
|
||||
- `line_height` - Fixer la hauteur de la ligne entre les textes _(number)_
|
||||
|
||||
#### Repo Card Exclusive Options:
|
||||
|
||||
- `show_owner` - Affiche le nom du propriétaire du dépôt _(boolean)_
|
||||
|
||||
#### Language Card Exclusive Options:
|
||||
|
||||
- `hide` - Masquer les langages spécifiés sur la carte _(Comma seperated values)_
|
||||
- `hide_title` - Masquer le titre _(boolean)_
|
||||
- `layout` - Alterner entre 2 mise en page `default` & `compact`
|
||||
- `card_width` - Fixer la largeur de la carte manuellement _(number)_
|
||||
|
||||
> :warning: **Important:**
|
||||
> Les noms des langages doivent être en format uri, comme spécifié dans [Percent Encoding](https://fr.wikipedia.org/wiki/Percent-encoding)
|
||||
> (c'est-à-dire que: `c++` devrait devenir `c%2B%2B`, `jupyter notebook` devrait devenir `jupyter%20notebook`, etc.)
|
||||
|
||||
---
|
||||
|
||||
# GitHub Extra Pins
|
||||
|
||||
Les épingles supplémentaires GitHub vous permettent d'épingler plus de 6 dépôts dans votre profil en utilisant un profil GitHub readme.
|
||||
|
||||
Et OUI ! Vous n'êtes plus limité à 6 dépôts épinglés.
|
||||
|
||||
### Usage
|
||||
|
||||
Copiez-collez ce code dans votre readme et modifiez les liens.
|
||||
|
||||
Extrémité: `api/pin?username=anuraghazra&repo=github-readme-stats`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Démo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
Utiliser la variable [show_owner](#customization) pour inclure le nom d'utilisateur du propriétaire du dépôt.
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# Carte des langages les + utilisés
|
||||
|
||||
La carte des langages principaux montre les langages les plus utilisés par les utilisateurs de GitHub.
|
||||
|
||||
_NOTE: Les langages affichés n'indiquent pas mon niveau de compétence ou quelque chose comme ça, c'est une métrique GitHub de quelles langages j'ai le plus de code sur GitHub, c'est une nouvelle fonctionnalité de github-readme-stats_
|
||||
|
||||
### Usage
|
||||
|
||||
Copiez-collez ce code dans votre readme et modifiez les liens.
|
||||
|
||||
Extrémité: `api/top-langs?username=anuraghazra`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Cacher certaines langages
|
||||
|
||||
Vous pouvez utiliser le paramètre `?hide=language1,language2` pour masquer les langages individuels.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Carte compacte des langages
|
||||
|
||||
Vous pouvez utiliser l'option `&layout=compact` pour changer le style de la carte.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Démo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Carte compacte
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### Toutes les démos
|
||||
|
||||
- Défaut
|
||||
|
||||

|
||||
|
||||
- Ne pas afficher des stats spécifiques
|
||||
|
||||

|
||||
|
||||
- Afficher les icônes
|
||||
|
||||

|
||||
|
||||
- Inclure tous les commits
|
||||
|
||||

|
||||
|
||||
- Thèmes
|
||||
|
||||
Choisissez parmi l'un des [thèmes par défaut](#themes)
|
||||
|
||||

|
||||
|
||||
- Dégradé
|
||||
|
||||

|
||||
|
||||
- Personnaliser la carte des stats
|
||||
|
||||

|
||||
|
||||
- Personnaliser la carte dépôt
|
||||
|
||||

|
||||
|
||||
- Top Langages
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### Conseil rapide (aligner les cartes des dépôts)
|
||||
|
||||
En général, vous ne pourrez pas mettre les images côte à côte. Pour ce faire, vous pouvez utiliser cette approche :
|
||||
|
||||
```html
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/convoychat">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=convoychat" />
|
||||
</a>
|
||||
```
|
||||
|
||||
## Déployer sur votre propre instance Vercel
|
||||
|
||||
#### [Check Out Step By Step Video Tutorial By @codeSTACKr](https://youtu.be/n6d4KHSKqGk?t=107)
|
||||
|
||||
Comme l'API GitHub ne permet que 5k requêtes par heure, il est possible que mon `https://github-readme-stats.vercel.app/api` puisse atteindre le limiteur de débit. Si vous l'hébergez sur votre propre serveur Vercel, alors vous n'avez pas à vous soucier de quoi que ce soit. Cliquez sur le bouton de déploiement pour commencer !
|
||||
|
||||
NOTE: Depuis [#58](https://github.com/anuraghazra/github-readme-stats/pull/58) nous devrions être en mesure de traiter plus de 5 000 demandes et ne pas avoir de problèmes de temps d'arrêt :D
|
||||
|
||||
[](https://vercel.com/import/project?template=https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
<details>
|
||||
<summary><b> Guide pour la mise en place de Vercel 🔨 </b></summary>
|
||||
|
||||
1. Allez sur [vercel.com](https://vercel.com/)
|
||||
1. Cliquez sur `Log in`
|
||||

|
||||
1. Connectez-vous avec GitHub en cliquant `Continue with GitHub`
|
||||

|
||||
1. Connectez-vous à GitHub et autorisez l'accès à tous les dépôts, si vous y êtes invité
|
||||
1. Forkez ce dépôt
|
||||
1. Retournez au [dashboard Vercel](https://vercel.com/dashboard)
|
||||
1. Sélectionnez `Import Project`
|
||||

|
||||
1. Sélectionnez `Import Git Repository`
|
||||

|
||||
1. Choisissez root et gardez tout tel quel, ajoutez simplement votre variable d'environnement nommée PAT_1 (comme indiqué), qui contiendra un jeton d'accès personnel (PAT), que vous pouvez facilement créer [ici](https://github.com/settings/tokens/new) (laissez tout tel quel, nommez le simplement quelque chose, cela peut être tout ce que vous voulez)
|
||||

|
||||
1. Cliquez sur "Deploy" et vous êtes prêt à partir. Regardez vos domaines pour utiliser l'API !
|
||||
|
||||
</details>
|
||||
|
||||
## :sparkling_heart: Supporter le project
|
||||
|
||||
Je mets open-source presque tout ce que je peux, et j'essaie de répondre à tous ceux qui ont besoin d'aide en utilisant ces projets. Évidemment, cela prend du temps. Vous pouvez utiliser ce service gratuitement.
|
||||
|
||||
Cependant, si vous utilisez ce projet et que vous en êtes satisfait ou si vous voulez simplement m'encourager à continuer à créer, il y a quelques façons de le faire :-
|
||||
|
||||
- Donner un crédit approprié lorsque vous utilisez github-readme-stats sur votre readme, avec un lien vers celui-ci :D
|
||||
- Mettre une étoile et partager le projet :rocket:
|
||||
- [](https://www.paypal.me/anuraghazra) - Vous pouvez faire des dons uniques via PayPal. Je vais probablement acheter un ~~café~~ thé. :tea:
|
||||
|
||||
Merci ! :heart:
|
||||
|
||||
---
|
||||
|
||||
[](https://vercel.com?utm_source=github_readme_stats_team&utm_campaign=oss)
|
||||
|
||||
|
||||
Les contributions sont les bienvenues ! <3
|
||||
|
||||
Fait avec :heart: et JavaScript.
|
||||
@@ -0,0 +1,350 @@
|
||||
<p align="center">
|
||||
<img width="100px" src="https://res.cloudinary.com/anuraghazra/image/upload/v1594908242/logo_ccswme.svg" align="center" alt="GitHub Readme Stats" />
|
||||
<h2 align="center">GitHub Readme Stats</h2>
|
||||
<p align="center">Mostra nei tuoi README file le statistiche GitHub generate dinamicamente!</p>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/actions">
|
||||
<img alt="Tests Passing" src="https://github.com/anuraghazra/github-readme-stats/workflows/Test/badge.svg" />
|
||||
</a>
|
||||
<a href="https://codecov.io/gh/anuraghazra/github-readme-stats">
|
||||
<img src="https://codecov.io/gh/anuraghazra/github-readme-stats/branch/master/graph/badge.svg" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues">
|
||||
<img alt="Issues" src="https://img.shields.io/github/issues/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/pulls">
|
||||
<img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supportato%20da-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supportato%20da-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="#demo">Anteprima</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Segnala un errore</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Richiedi una nuova funzionalità</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="/docs/readme_fr.md">Français </a>
|
||||
·
|
||||
<a href="/docs/readme_cn.md">简体中文</a>
|
||||
·
|
||||
<a href="/docs/readme_es.md">Español</a>
|
||||
·
|
||||
<a href="/docs/readme_de.md">Deutsch</a>
|
||||
·
|
||||
<a href="/docs/readme_ja.md">日本語</a>
|
||||
·
|
||||
<a href="/docs/readme_pt-BR.md">Português Brasileiro</a>
|
||||
·
|
||||
<a href="/docs/readme_it.md">Italiano</a>
|
||||
·
|
||||
<a href="/docs/readme_kr.md">한국어</a>
|
||||
.
|
||||
<a href="/docs/readme_nl.md">Nederlands</a>
|
||||
.
|
||||
<a href="/docs/readme_np.md">नेपाली</a>
|
||||
</p>
|
||||
</p>
|
||||
<p align="center">Se ti piace questo progetto, considera la possibilità di <a href="https://www.paypal.me/anuraghazra">donare</a> per aiutare a renderlo migliore!
|
||||
|
||||
# Caratteristiche
|
||||
|
||||
- [Statistiche GitHub (GitHub Stats Card)](#github-stats-card)
|
||||
- [GitHub Extra Pin](#github-extra-pins)
|
||||
- [Linguaggi più usati (Top Languages Card)](#top-languages-card)
|
||||
- [Temi](#temi)
|
||||
- [Personalizzazione](#personalizzazione)
|
||||
- [Effettua il Deploy](#deploy-su-vercel)
|
||||
|
||||
# GitHub Stats Card
|
||||
|
||||
Per creare una Card con le statistiche GitHub, copia e incolla nel tuo file markdown, tutto qua: è semplice!
|
||||
|
||||
Ricorda di cambiare il valore `?username=` con il tuo nome utente GitHub.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
_Nota: I punteggi sono calcolati sulla base delle tue statistiche, dai un'occhiata a [src/calculateRank.js](../src/calculateRank.js) per ulteriori informazioni_
|
||||
|
||||
### Nascondere statistiche individuali
|
||||
|
||||
Per nascondere qualche dato, puoi aggiungere i parametri `?hide=`, separando i valori con una virgola.
|
||||
|
||||
> Opzioni: `&hide=stars,commits,prs,issues,contribs`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Includere i contributi privati nel computo totale
|
||||
|
||||
Puoi aggiungere i tuoi contributi privati al totale dei commit, utilizzando il parametro `?count_private=true`.
|
||||
|
||||
_Nota: se hai deciso di fare il deploy del progetto, i contributi privati verranno inclusi in automatico._
|
||||
|
||||
> Opzioni: `&count_private=true`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Mostrare le icone
|
||||
|
||||
Per abilitare le icone, puoi specificare `show_icons=true`, ad esempio:
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Temi
|
||||
|
||||
Esistono alcuni temi predefiniti coi quali è possibile personalizzare l'aspetto delle card. In alternativa, è possibile effettuare una [personalizzazione manuale](#personalizzazione).
|
||||
|
||||
Usa il parametro `?theme=NOME_TEMA` in questo modo:-
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
#### Galleria dei temi:-
|
||||
|
||||
dark, radical, merko, gruvbox, tokyonight, onedark, cobalt, synthwave, highcontrast, dracula
|
||||
|
||||
<img src="https://res.cloudinary.com/anuraghazra/image/upload/v1595174536/grs-themes_l4ynja.png" alt="GitHub Readme Stat Themes" width="600px"/>
|
||||
|
||||
Puoi avere un'anteprima di [tutti i temi supportati](../themes/README.md) o controllare il [file di configurazione dei temi](../themes/index.js) e **puoi anche contribuire creando un nuovo tema** se vuoi :D
|
||||
|
||||
### Personalizzazione
|
||||
|
||||
Puoi personalizzare l'aspetto delle tue `Stats Card` o delle `Repo Card` in qualsiasi modo, semplicemente modificando i parametri dell'URL.
|
||||
|
||||
#### Opzioni comuni:
|
||||
|
||||
- `title_color` - Colore del titolo _(in esadecimale)_
|
||||
- `text_color` - Colore del testo _(in esadecimale)_
|
||||
- `icon_color` - Colore delle icone, se disponibili _(in esadecimale)_
|
||||
- `bg_color` - Colore dello sfondo _(in esadecimale)_ **oppure** un gradiente nella forma _angolo,inizio,fine_
|
||||
- `hide_border` - Nasconde il bordo della carta _(booleano)_
|
||||
- `theme` - Nome del tema, dai un'occhiata a [tutti i temi disponibili](../themes/README.md)
|
||||
- `cache_seconds` - Specifica manualmente il valore di cache, in secondi _(min: 1800, max: 86400)_
|
||||
- `locale` - Impostare la lingua nella scheda _(per esempio. cn, de, es, eccetera.)_
|
||||
|
||||
##### Gradiente nello sfondo
|
||||
|
||||
Puoi fornire valori separati da virgola nel parametro bg_color per creare un gradiente, il cui formato è:-
|
||||
|
||||
```
|
||||
&bg_color=DEG,COLOR1,COLOR2,COLOR3...COLOR10
|
||||
```
|
||||
|
||||
> Nota sulla cache: le card hanno un valore di cache di 4 ore (14400 seconds) di default se il numero di fork & il numero di stelle è inferiore a 1000; altrimenti è pari a 2 ore (7200).
|
||||
|
||||
#### Opzioni valide solo per le card delle statistiche:
|
||||
|
||||
- `hide` - Nasconde gli oggetti selezionati _(valori separati da virgola)_
|
||||
- `hide_title` - Nasconde il titolo _(booleano)_
|
||||
- `hide_rank` - Nasconde il punteggio _(booleano)_
|
||||
- `show_icons` - Mostra le icone _(booleano)_
|
||||
- `include_all_commits` - Mostra tutti i commit e non solo quelli dell'anno corrente _(booleano)_
|
||||
- `count_private` - Include i contributi privati _(booleano)_
|
||||
- `line_height` - Specifica il valore dell'altezza di riga _(numero)_
|
||||
|
||||
#### Opzioni valide solo per le Repo Card:
|
||||
|
||||
- `show_owner` - Mostra il nome utente del proprietario _(booleano)_
|
||||
|
||||
#### Opzioni valide solo per le card dei linguaggi:
|
||||
|
||||
- `hide` - Nasconde un linguaggio specifico _(valori separati da virgola)_
|
||||
- `hide_title` - Nasconde il titolo _(booleano)_
|
||||
- `layout` - Specifica il tipo di layout, `default` (esteso) o `compact` (compatto)
|
||||
- `card_width` - Specifica il valore della larghezza _(numero)_
|
||||
|
||||
> :warning: **Importante:**
|
||||
> Per i nomi dei linguaggi, assicurati di effettuare l'encoding giusto nell'uri, come specificato in [Percent Encoding](https://en.wikipedia.org/wiki/Percent-encoding)
|
||||
> (ad esempio: `c++` diventa `c%2B%2B`, `jupyter notebook` diventa `jupyter%20notebook`, ecc.)
|
||||
|
||||
---
|
||||
|
||||
# GitHub Extra Pins
|
||||
|
||||
GitHub Extra Pins ti permette di fissare in alto più di 6 repository nel tuo profilo, sfruttando il README del profilo.
|
||||
|
||||
### Utilizzo
|
||||
|
||||
Copia e incolla il seguente codice, premurandoti di cambiare il link.
|
||||
|
||||
Endpoint: `api/pin?username=anuraghazra&repo=github-readme-stats`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Demo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
Usa la variabile [show_owner](#personalizzazione) per includere il nome utente del proprietario
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# Top Languages Card
|
||||
|
||||
La Top Languages Card mostra i linguaggi che utilizzi di più su GitHub.
|
||||
|
||||
_NOTA: questa card non indica il livello di abilità, ma piuttosto quanto codice hai scritto in un determinato linguaggio_
|
||||
|
||||
### Utilizzo
|
||||
|
||||
Copia e incolla nel tuo file README, cambiando i link.
|
||||
|
||||
Endpoint: `api/top-langs?username=anuraghazra`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Nascondi linguaggi specifici
|
||||
|
||||
Puoi utilizzare il parametro `?hide=linguaggio1,linguaggio2` per nascondere alcuni linguaggi.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Layout compatto
|
||||
|
||||
Puoi utilizzare l'opzione `&layout=compact` per cambiare l'aspetto della card.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Demo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Layout Compatto
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### Galleria di esempi
|
||||
|
||||
- Default
|
||||
|
||||

|
||||
|
||||
- Nascondere dati specifici
|
||||
|
||||

|
||||
|
||||
- Mostrare le icone
|
||||
|
||||

|
||||
|
||||
- Includere tutti i commit
|
||||
|
||||

|
||||
|
||||
- Temi
|
||||
|
||||
Scegli uno dei [temi di default](#themes)
|
||||
|
||||

|
||||
|
||||
- Gradiente
|
||||
|
||||

|
||||
|
||||
- Personalizzare le Stats Card
|
||||
|
||||

|
||||
|
||||
- Personalizzare le Repo Card
|
||||
|
||||

|
||||
|
||||
- Linguaggi più usati
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### Consiglio veloce (Allineare le Card)
|
||||
|
||||
Per allineare le card una accanto all'altra, puoi adottare questo approccio:
|
||||
|
||||
```html
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/convoychat">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=convoychat" />
|
||||
</a>
|
||||
```
|
||||
|
||||
## Deploy su Vercel
|
||||
|
||||
#### [Guarda questo Video Tutorial, realizzato da @codeSTACKr](https://youtu.be/n6d4KHSKqGk?t=107)
|
||||
|
||||
Since the GitHub API only allows 5k requests per hour, it is possible that my `https://github-readme-stats.vercel.app/api` could hit the rate limiter. If you host it on your own Vercel server, then you don't have to worry about anything. Click on the deploy button to get started!
|
||||
|
||||
NOTE: Since [#58](https://github.com/anuraghazra/github-readme-stats/pull/58) we should be able to handle more than 5k requests and have no issues with downtime :D
|
||||
|
||||
[](https://vercel.com/import/project?template=https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
<details>
|
||||
<summary><b> Guide on setting up Vercel 🔨 </b></summary>
|
||||
|
||||
1. Go to [vercel.com](https://vercel.com/)
|
||||
1. Click on `Log in`
|
||||

|
||||
1. Sign in with GitHub by pressing `Continue with GitHub`
|
||||

|
||||
1. Sign into GitHub and allow access to all repositories, if prompted
|
||||
1. Fork this repo
|
||||
1. Go back to your [Vercel dashboard](https://vercel.com/dashboard)
|
||||
1. Select `Import Project`
|
||||

|
||||
1. Select `Import Git Repository`
|
||||

|
||||
1. Select root and keep everything as is, just add your environment variable named PAT_1 (as shown), which will contain a personal access token (PAT), which you can easily create [here](https://github.com/settings/tokens/new) (leave everything as is, just name it something, it can be anything you want)
|
||||

|
||||
1. Click deploy, and you're good to go. See your domains to use the API!
|
||||
|
||||
</details>
|
||||
|
||||
## :sparkling_heart: Supporta il progetto
|
||||
|
||||
Rendo open-source quasi tutto ciò che posso e provo a rispondere a chiunque sia in difficoltà nell'utilizzare questi progetti. Ovviamente, mi richiede del tempo.
|
||||
Puoi utilizzare questo servizio gratuitamente.
|
||||
|
||||
Tuttavia, se usi il progetto e ti piace e vuoi sostenermi, puoi:-
|
||||
|
||||
- Dare il giusto riconoscimento quando usi github-readme-stats nei tuoi readme, includendo un link :D
|
||||
- Mettere una stella e condividere il progetto :rocket:
|
||||
- [](https://www.paypal.me/anuraghazra) - Fare una donazione via PayPal. Probabilmente compreròun ~~caffè~~ tè. :tea:
|
||||
|
||||
Grazie! :heart:
|
||||
|
||||
---
|
||||
|
||||
[](https://vercel.com?utm_source=github_readme_stats_team&utm_campaign=oss)
|
||||
|
||||
I contributi sono benvenuti! <3
|
||||
|
||||
Realizzato col :heart: e in JavaScript.
|
||||
@@ -0,0 +1,358 @@
|
||||
<p align="center">
|
||||
<img width="100px" src="https://res.cloudinary.com/anuraghazra/image/upload/v1594908242/logo_ccswme.svg" align="center" alt="GitHub Readme Stats" />
|
||||
<h2 align="center">GitHub Readme Stats</h2>
|
||||
<p align="center">あなたの README に自動生成された GitHub の統計情報を載せましょう!</p>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/actions">
|
||||
<img alt="Tests Passing" src="https://github.com/anuraghazra/github-readme-stats/workflows/Test/badge.svg" />
|
||||
</a>
|
||||
<a href="https://codecov.io/gh/anuraghazra/github-readme-stats">
|
||||
<img src="https://codecov.io/gh/anuraghazra/github-readme-stats/branch/master/graph/badge.svg" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues">
|
||||
<img alt="Issues" src="https://img.shields.io/github/issues/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/pulls">
|
||||
<img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="#demo">View Demo</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Report Bug</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Request Feature</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="/docs/readme_fr.md">Français</a>
|
||||
·
|
||||
<a href="/docs/readme_cn.md">简体中文</a>
|
||||
·
|
||||
<a href="/docs/readme_es.md">Español</a>
|
||||
·
|
||||
<a href="/docs/readme_de.md">Deutsch</a>
|
||||
·
|
||||
<a href="/docs/readme_ja.md">日本語</a>
|
||||
·
|
||||
<a href="/docs/readme_pt-BR.md">Português Brasileiro</a>
|
||||
·
|
||||
<a href="/docs/readme_it.md">Italiano</a>
|
||||
·
|
||||
<a href="/docs/readme_kr.md">한국어</a>
|
||||
.
|
||||
<a href="/docs/readme_nl.md">Nederlands</a>
|
||||
.
|
||||
<a href="/docs/readme_np.md">नेपाली</a>
|
||||
</p>
|
||||
</p>
|
||||
<p align="center">このプロジェクトを気に入っていただけましたか?<br>もしよろしければ、プロジェクトのさらなる改善のために<a href="https://www.paypal.me/anuraghazra">寄付</a>を検討して頂けると嬉しいです!</p>
|
||||
|
||||
# 主な機能
|
||||
|
||||
- [GitHub Stats Card](#github-stats-card)
|
||||
- [GitHub Extra Pins](#github-extra-pins)
|
||||
- [Top Languages Card](#top-languages-card)
|
||||
- [Themes](#テーマの変更)
|
||||
- [Customization](#テーマを自分でカスタマイズする)
|
||||
- [Deploy Yourself](#自分の-Vercel-インスタンスにデプロイする)
|
||||
|
||||
# GitHub Stats Card
|
||||
|
||||
以下のコードをコピーして、あなたの Markdown ファイルに貼り付けるだけです。
|
||||
簡単ですね!
|
||||
|
||||
`?username=` の値は、あなたの GitHub アカウントのユーザー名に変更してください。
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
_Note: カードに表示されるランクはユーザの統計情報に基づいて計算されています。詳しくは、[src/calculateRank.js](../src/calculateRank.js)をご覧ください。_
|
||||
|
||||
### 特定の統計情報を隠す
|
||||
|
||||
クエリパラメータ `?hide=` に値をカンマ区切りで渡すことで、特定の統計情報を隠すことができます。
|
||||
|
||||
> Options: `&hide=stars,commits,prs,issues,contribs`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### プライベートリポジトリへのコミットをカウントする
|
||||
|
||||
クエリパラメータ `?count_private=true` を使用することで、プライベートリポジトリへのコミット数を総数に追加することができます。
|
||||
|
||||
_Note: このプロジェクトを自分でデプロイしている場合、デフォルトではプライベートリポジトリへのコミットがカウントされます。_
|
||||
|
||||
> Options: `&count_private=true`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### アイコンを表示する
|
||||
|
||||
クエリパラメータ `?show_icons=true` を使用することで、アイコンの表示が有効になります。
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### テーマの変更
|
||||
|
||||
内蔵されているテーマを使用すれば、[手動のカスタマイズ](#customization)を行うことなくカードの外観を変更することができます。
|
||||
|
||||
`?theme=THEME_NAME` は以下のように使います。
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
#### 内蔵テーマの一覧
|
||||
|
||||
dark, radical, merko, gruvbox, tokyonight, onedark, cobalt, synthwave, highcontrast, dracula
|
||||
|
||||
<img src="https://res.cloudinary.com/anuraghazra/image/upload/v1595174536/grs-themes_l4ynja.png" alt="GitHub Readme Stat Themes" width="600px"/>
|
||||
|
||||
その他の使用可能なテーマの[プレビュー](../themes/README.md)や[設定ファイル](../themes/index.js)もご覧ください。もしよろしければ、**新しいテーマを投稿してみてください** :smile:
|
||||
|
||||
### テーマを自分でカスタマイズする
|
||||
|
||||
`Stats Card` や `Repo Card` の外観を URL パラメータを使って好きなようにカスタマイズすることができます。
|
||||
|
||||
#### 共通のオプション
|
||||
|
||||
- `title_color` - タイトルの色 _(16 進数カラーコード)_
|
||||
- `text_color` - 中身のテキストの色 _(16 進数カラーコード)_
|
||||
- `icon_color` - アイコンの色(変更可能な場合のみ) _(16 進数カラーコード)_
|
||||
- `bg_color` - 背景の色 _(16 進数カラーコード)_ **または** _angle,start,end_ の形式でグラデーションを指定することも可
|
||||
- `hide_border` - カードの境界線を非表示にします _(ブール値)_
|
||||
- `theme` - [使用可能なテーマ一覧](../themes/README.md) から選んだテーマ名
|
||||
- `cache_seconds` - キャッシュ時間の秒数 _(最小値: 1800, 最大値: 86400)_
|
||||
- `locale` - カードに言語を設定する _(例えば cn, de, es, 等)_
|
||||
|
||||
##### bg_color の グラデーション指定
|
||||
|
||||
bg_color オプションで複数のカンマ区切りの値を指定してグラデーションをレンダリングすることができます。フォーマットは以下の通りになります。
|
||||
|
||||
```
|
||||
&bg_color=DEG,COLOR1,COLOR2,COLOR3...COLOR10
|
||||
```
|
||||
|
||||
> キャッシュに関する注意点: Repo cards のデフォルトのキャッシュは、フォーク数とスター数が 1k 未満の場合は 30 分(1800 秒) で、それ以外の場合は 2 時間(7200) です。また、キャッシュは最低でも 30 分、最大でも 24 時間に制限されていることに注意してください。
|
||||
|
||||
#### Stats Card だけに存在するオプション
|
||||
|
||||
- `hide` - 特定の統計情報を隠す _(カンマ区切りで指定)_
|
||||
- `hide_title` - _(boolean)_
|
||||
- `hide_rank` - _(boolean)_
|
||||
- `show_icons` - _(boolean)_
|
||||
- `include_all_commits` - 今年度のコミット数だけでなく、コミット数の総数をカウントする _(boolean)_
|
||||
- `count_private` - プライベートリポジトリへのコミットをカウントする _(boolean)_
|
||||
- `line_height` - テキストの行の高さ _(number)_
|
||||
- `custom_title` - タイトル文字列を変更する
|
||||
- `disable_animations` - カードのアニメーションを無効にする _(boolean)_
|
||||
|
||||
#### Repo Card だけに存在するオプション
|
||||
|
||||
- `show_owner` - リポジトリのオーナーを表示する _(boolean)_
|
||||
|
||||
#### Language Card だけに存在するオプション
|
||||
|
||||
- `hide` - 特定の言語を隠す _(カンマ区切りで指定)_
|
||||
- `hide_title` - _(boolean)_
|
||||
- `layout` - `default` か `compact` のいずれかのレイアウトに切り替える
|
||||
- `card_width` - カードの横幅 _(number)_
|
||||
- `langs_count` - 表示される言語の数 _(1 ~ 10, 初期値 5)_
|
||||
- `exclude_repo` - 指定されたリポジトリを除外する _(カンマ区切りで指定)_
|
||||
- `custom_title` - タイトル文字列を変更する
|
||||
|
||||
> :warning: **重要:**
|
||||
> [Percent Encoding](https://en.wikipedia.org/wiki/Percent-encoding) で指定されているように、プログラミング言語の名前は URL エンコードされている必要があります。
|
||||
> (例: `c++` は `c%2B%2B`, `jupyter notebook` は `jupyter%20notebook`, など)
|
||||
|
||||
---
|
||||
|
||||
# GitHub Extra Pins
|
||||
|
||||
GitHub extra pins を使うと、GitHub の readme プロフィールを使って、自分のプロフィールに 6 つ以上のリポジトリをピン留めすることができます。
|
||||
|
||||
やったー! もはや、リポジトリをピン留めできる数が 6 つに制限されることはありません。
|
||||
|
||||
### 使い方
|
||||
|
||||
以下のコードをあなたの readme にコピー & ペーストし、リンクを変更してください。
|
||||
|
||||
エンドポイント: `api/pin?username=anuraghazra&repo=github-readme-stats`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### デモ
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
リポジトリのオーナーのユーザー名を含める場合は、show_owner 変数を使用します。
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# Top Languages Card
|
||||
|
||||
Top languages card には、その GitHub ユーザーが最も利用している Top languages が表示されます。
|
||||
|
||||
_NOTE: Top languages は、ユーザのスキルレベルを示すものではなく、GitHub 上でどの言語で最も多くのコードを書いているかを示す GitHub の指標です。_
|
||||
|
||||
### 使い方
|
||||
|
||||
以下のコードをあなたの readme にコピー & ペーストし、リンクを変更してください。
|
||||
|
||||
エンドポイント: `api/top-langs?username=anuraghazra`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### 特定の言語を隠す
|
||||
|
||||
クエリパラメータ `?hide=language1,language2` 使用することで、特定の言語を非表示にすることができます。
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### レイアウトをコンパクトにする
|
||||
|
||||
クエリパラメータ `&layout=compact` を使用することで、カードのデザインを変更することができます。
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### デモ
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Compact layout の場合
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### 全てのデモ
|
||||
|
||||
- デフォルト
|
||||
|
||||

|
||||
|
||||
- 特定の統計情報を隠す
|
||||
|
||||

|
||||
|
||||
- アイコンを表示する
|
||||
|
||||

|
||||
|
||||
- コミット数の総数をカウントする
|
||||
|
||||

|
||||
|
||||
- テーマの変更
|
||||
|
||||
任意の[テーマ](#themes)を選択できます。
|
||||
|
||||

|
||||
|
||||
- グラデーション
|
||||
|
||||

|
||||
|
||||
- stats card のカスタマイズ
|
||||
|
||||

|
||||
|
||||
- repo card のカスタマイズ
|
||||
|
||||

|
||||
|
||||
- Top languages
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### クイックヒント (カードを並べる)
|
||||
|
||||
通常、画像を並べてレイアウトすることはできません。画像を並べるには、以下のような方法があります。
|
||||
|
||||
```html
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/convoychat">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=convoychat" />
|
||||
</a>
|
||||
```
|
||||
|
||||
## 自分の Vercel インスタンスにデプロイする
|
||||
|
||||
#### [@codeSTACKr によるチュートリアルはこちら](https://youtu.be/n6d4KHSKqGk?t=107)
|
||||
|
||||
GitHub API は 1 時間あたり 5k リクエストしか受け付けていないので、私の `https://github-readme-stats.vercel.app/api` がレートリミッターを超えてしまう可能性があります。自分の Vercel サーバーでホストしているのであれば、何も心配する必要はありません。デプロイボタンをクリックして始めましょう!
|
||||
|
||||
NOTE: [#58](https://github.com/anuraghazra/github-readme-stats/pull/58) 以降は 5k 以上のリクエストに対応できるようになり、ダウンタイムの問題もなくなりました :smile:
|
||||
|
||||
[](https://vercel.com/import/project?template=https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
<details>
|
||||
<summary>Vercelの設定ガイド</summary>
|
||||
|
||||
1. [vercel.com](https://vercel.com/)に行きます。
|
||||
1. `Log in`をクリックします。
|
||||

|
||||
1. `Continue with GitHub` を押して GitHub にサインインします。
|
||||

|
||||
1. GitHub にサインインし、すべてのリポジトリへのアクセスを許可します。
|
||||
1. このリポジトリをフォークします。
|
||||
1. [Vercel dashboard](https://vercel.com/dashboard)に戻ります。
|
||||
1. `Import Project` を選択します。
|
||||

|
||||
1. `Import Git Repository` を選択します。
|
||||

|
||||
1. root を選択して、すべてをそのままにしておき、PAT_1 という名前の環境変数を(下図のように)追加します。これには個人アクセストークン (PAT) が含まれており、[ここ](https://github.com/settings/tokens/new)で簡単に作成することができます (すべてをそのままにしておいて、何かに名前を付けてください。)
|
||||

|
||||
1. デプロイをクリックすれば完了です。API を使用するためにあなたのドメインを参照してください!
|
||||
|
||||
</details>
|
||||
|
||||
## :sparkling_heart: このプロジェクトを支援する
|
||||
|
||||
私はできる限りのことをオープンソースで行い、また、このプロジェクトを利用する上で困っている皆さん全員に返信するようにしています。もちろん返信には時間が掛かる場合がありますが。
|
||||
このプロジェクトは無料でご利用いただけます。
|
||||
|
||||
しかしながら、もしあなたがこのプロジェクトに満足しているのであれば、あるいはただ、私がソフトウェアを作り続けるよう励ましたいのであれば、いくつかの方法があります。
|
||||
|
||||
- あなたの readme で github-readme-stats を使用して適切なクレジットを付与し、それにリンクします :smile:
|
||||
- このプロジェクトにスターを贈り、他の人達にもシェアしてください :rocket:
|
||||
- [](https://www.paypal.me/anuraghazra) - PayPal を介して 1 回限りの寄付を行うことができます。私はおそらく ~~コーヒー~~ お茶を買うでしょう。 :tea:
|
||||
|
||||
Thanks! :heart:
|
||||
|
||||
---
|
||||
|
||||
[](https://vercel.com?utm_source=github_readme_stats_team&utm_campaign=oss)
|
||||
|
||||
コントリビュートは大歓迎です! :heart_eyes:
|
||||
|
||||
このプロジェクトは :heart: と JavaScript で作られています。
|
||||
@@ -0,0 +1,439 @@
|
||||
<p align="center">
|
||||
<img width="100px" src="https://res.cloudinary.com/anuraghazra/image/upload/v1594908242/logo_ccswme.svg" align="center" alt="GitHub Readme Stats" />
|
||||
<h2 align="center">GitHub Readme Stats</h2>
|
||||
<p align="center">동적으로 생성되는 Github 사용량 통계를 여러분의 README 에 추가해보세요!</p>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/actions">
|
||||
<img alt="Tests Passing" src="https://github.com/anuraghazra/github-readme-stats/workflows/Test/badge.svg" />
|
||||
</a>
|
||||
<a href="https://codecov.io/gh/anuraghazra/github-readme-stats">
|
||||
<img src="https://codecov.io/gh/anuraghazra/github-readme-stats/branch/master/graph/badge.svg" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues">
|
||||
<img alt="Issues" src="https://img.shields.io/github/issues/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/pulls">
|
||||
<img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="#미리보기">미리보기 확인</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">버그 제보하기</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">기능 추가 요청하기</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="/docs/readme_fr.md">Français </a>
|
||||
·
|
||||
<a href="/docs/readme_cn.md">简体中文</a>
|
||||
·
|
||||
<a href="/docs/readme_es.md">Español</a>
|
||||
·
|
||||
<a href="/docs/readme_de.md">Deutsch</a>
|
||||
·
|
||||
<a href="/docs/readme_ja.md">日本語</a>
|
||||
·
|
||||
<a href="/docs/readme_pt-BR.md">Português Brasileiro</a>
|
||||
·
|
||||
<a href="/docs/readme_it.md">Italiano</a>
|
||||
·
|
||||
<a href="/docs/readme_kr.md">한국어</a>
|
||||
.
|
||||
<a href="/docs/readme_nl.md">Nederlands</a>
|
||||
.
|
||||
<a href="/docs/readme_np.md">नेपाली</a>
|
||||
</p>
|
||||
</p>
|
||||
<p align="center">기능들이 마음에 드시나요? 괜찮으시다면, 서비스 개선을 위해 <a href="https://www.paypal.me/anuraghazra">기부</a>를 고려해주세요!
|
||||
|
||||
# 기능들
|
||||
|
||||
- [GitHub 통계](#github-통계)
|
||||
- [GitHub 저장소 핀](#github-저장소-핀)
|
||||
- [언어 사용량 통계](#언어-사용량-통계)
|
||||
- [Wakatime 주간 통계](#wakatime-주간-통계)
|
||||
- [테마](#테마)
|
||||
- [커스터마이징](#커스터마이징)
|
||||
- [직접 배포하기](#나만의-Vercel-인스턴스에-직접-배포하기)
|
||||
|
||||
|
||||
# GitHub 통계
|
||||
|
||||
아래 코드를 복사해서 마크다운 파일에 붙여넣으면 끝이에요, 아주 간단해요!
|
||||
|
||||
`?username=` 속성의 값을 Github 계정의 사용자 명(닉네임)으로 바꿔주세요.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
_참고:_
|
||||
|
||||
_랭크는 S+ (상위 1%), S (상위 25%), A++ (상위 45%), A+ (상위 60%), 그리고 B+ (전체) 로 구성되어 있습니다._
|
||||
|
||||
_커밋의 수(commits), 기여도(contribution), 이슈의 수(issues), 즐겨찾기(star), 작업내용 반영 요청(Pull Request),
|
||||
팔로워 수, 그리고 보유 중인 저장소 등의 항목들에 대해 [누적 분포 함수](https://ko.wikipedia.org/wiki/%EB%88%84%EC%A0%81_%EB%B6%84%ED%8F%AC_%ED%95%A8%EC%88%98) 를 이용해 계산됩니다._
|
||||
|
||||
_[src/calculateRank.js](../src/calculateRank.js) 에서 수행되는 계산 작업의 내용을 확인할 수 있습니다._
|
||||
|
||||
### 개별 통계 숨기기
|
||||
|
||||
특정 통계를 숨기려면 `콤마(,)`로 구분된 값들을 `?hide=` 속성의 값으로 넣어주세요.
|
||||
|
||||
> 사용 가능한 항목들: `&hide=stars,commits,prs,issues,contribs`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### 총 커밋 수에 비공개 기여도 (private contribs) 수 추가하기
|
||||
|
||||
`?count_private=true` 속성을 추가하시면, 여러분의 모든 비공개 기여도까지 반영됩니다.
|
||||
|
||||
_참고: 프로젝트를 직접 배포하신 경우, 비공개 기여도는 기본적으로 반영됩니다. 원하지 않는 경우엔 직접 설정해야 합니다._
|
||||
|
||||
> 예시: `&count_private=true`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### 아이콘 표시하기
|
||||
|
||||
아이콘 항목을 활성화 하기 위해선, 다음과 같이 `show_icons=true` 속성을 추가해주세요.
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### 테마 설정하기
|
||||
|
||||
내장 테마를 사용하시면, 별도의 [커스터마이징](#커스터마이징) 없이 GitHub 통계 카드를 꾸미실 수 있어요.
|
||||
|
||||
다음과 같이 `?theme=THEME_NAME` 속성을 이용해주세요.
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
#### 지원하는 내장 테마 목록
|
||||
|
||||
dark, radical, merko, gruvbox, tokyonight, onedark, cobalt, synthwave, highcontrast, dracula
|
||||
|
||||
<img src="https://res.cloudinary.com/anuraghazra/image/upload/v1595174536/grs-themes_l4ynja.png" alt="GitHub Readme Stat Themes" width="600px"/>
|
||||
|
||||
[사용 가능한 모든 테마](../themes/README.md) 에서 미리보기를 확인하실 수 있어요.
|
||||
|
||||
원하신다면 [테마 설정하기](../themes/index.js) 항목에서 **새로운 테마를 직접 만드실수 있어요.** :D
|
||||
|
||||
### 커스터마이징
|
||||
|
||||
여러가지 추가 속성을 통해, 원하는대로 `Stats Card` 또는 `Repo Card` 모양을 커스터마이징할 수 있어요.
|
||||
|
||||
#### 기본 옵션:
|
||||
|
||||
- `title_color` - 카드 타이틀 색상 _(hex color)_
|
||||
- `text_color` - 카드 본문 글씨 색상 _(hex color)_
|
||||
- `icon_color` - 아이콘 색상 (활성화된 경우) _(hex color)_
|
||||
- `bg_color` - 카드의 배경 색상 _(hex color)_ **혹은** 다음 양식으로 그라데이션 주기 _angle,start,end_
|
||||
- `hide_border` - 카드의 테두리 표시 여부 _(boolean)_
|
||||
- `theme` - 테마의 이름, [사용 가능한 모든 테마](../themes/README.md) 에서 선택
|
||||
- `cache_seconds` - 수동으로 캐시 헤더 설정 _(min: 1800, max: 86400)_
|
||||
- `locale` - 카드에 표시할 언어 _(e.g. kr, cn, de, es, etc.)_
|
||||
|
||||
##### 배경에 그라데이션 주기
|
||||
|
||||
그라데이션이 적용된 카드를 표시하고 싶으시다면, 여러가지 쉼표(,) 로 구분된 값을 추가할 수 있어요.
|
||||
|
||||
양식은 다음과 같습니다.
|
||||
|
||||
```
|
||||
&bg_color=DEG,COLOR1,COLOR2,COLOR3...COLOR10
|
||||
```
|
||||
|
||||
> 캐시에 대한 참고사항:
|
||||
> 포크와 스타 수가 1,000 개 미만인 저장소의 카드는 기본적으로 4시간 (14,400초) 으로 설정되어 있습니다.
|
||||
> 그 외에는, it's 2시간 (7,200초) 입니다. 또한, 캐시설정 시간의 범위는 최소 2시간, 최대 24시간입니다.
|
||||
|
||||
|
||||
#### 통계 카드의 표시 제한 옵션:
|
||||
|
||||
- `hide` - 통계에서 특정한 값 제외 _(Comma-separated values)_
|
||||
- `hide_title` - 타이틀 표시 여부 _(boolean)_
|
||||
- `hide_rank` - 랭크 표시 여부 _(boolean)_
|
||||
- `show_icons` - 아이콘 표시 여부 _(boolean)_
|
||||
- `include_all_commits` - 올해가 아닌 전체 연도에 대한 커밋 포함 여부 _(boolean)_
|
||||
- `count_private` - 비공개 기여도 포함 여부 _(boolean)_
|
||||
- `line_height` - 텍스트 간 줄 높이 설정(자간) _(number)_
|
||||
- `custom_title` - 카드의 타이틀 값 설정
|
||||
- `disable_animations` - 카드의 모든 에니메이션 활성 여부 _(boolean)_
|
||||
|
||||
#### 저장소 카드의 표시 제한 옵션:
|
||||
|
||||
- `show_owner` - 저장소 소유자 닉네임 표기 여부 _(boolean)_
|
||||
|
||||
#### 언어 사용량 통계 카드의 표시 제한 옵션:
|
||||
|
||||
- `hide` - 카드에서 특정 언어 제외 _(Comma-separated values)_
|
||||
- `hide_title` - 타이틀 제외 _(boolean)_
|
||||
- `layout` - 사용 가능한 두 가지 값, `default` & `compact` 중 표시 형태 선택
|
||||
- `card_width` - 카드 너비 직접 설정 _(number)_
|
||||
- `langs_count` - 카드에 표시할 언어의 수 (1-10 사이, 기본 값 : 5) _(number)_
|
||||
- `exclude_repo` - 통계에 제외할 저장소 지정 _(Comma-separated values)_
|
||||
- `custom_title` - 카드의 타이틀 값 설정
|
||||
|
||||
##### 경고! **매우 중요**
|
||||
>
|
||||
> 언어의 이름은 [퍼센트 인코딩](https://ko.wikipedia.org/wiki/%ED%8D%BC%EC%84%BC%ED%8A%B8_%EC%9D%B8%EC%BD%94%EB%94%A9) 에 지정된 URI 방식으로 표기되어야 합니다.
|
||||
> ( 예를 들면, `c++` 는 `c%2B%2B`, `jupyter notebook` 는 `jupyter%20notebook`, 등등. )
|
||||
> [urlencoder.org](https://www.urlencoder.org/) < 서비스를 이용하면 자동으로 생성할 수 있습니다.
|
||||
|
||||
#### Wakatime 카드의 표시 제한 옵션:
|
||||
|
||||
- `hide_title` - 타이틀 제외 _(boolean)_
|
||||
- `line_height` - 텍스트 간 줄 높이 설정(자간) _(number)_
|
||||
- `hide_progress` - 퍼센트와 표기바 표시 여부 _(boolean)_
|
||||
- `custom_title` - 카드의 타이틀 값 설정
|
||||
- `layout` - 사용 가능한 두 가지 값, `default` & `compact` 중 표시 형태 선택
|
||||
|
||||
---
|
||||
|
||||
# GitHub 저장소 핀
|
||||
|
||||
GitHub 저장소 여분 핀을 이용하면, 6개 이상의 저장소 핀을 여러분의 프로필에 추가할 수 있어요.
|
||||
|
||||
맞아요! 이제 6개 이상의 핀을 사용할 수 있어요! (핀이 부족할 일이 없답니다!)
|
||||
|
||||
### 사용법
|
||||
|
||||
이 코드를 복사해서 여러분의 README 에 넣고 링크를 변경해주세요.
|
||||
|
||||
엔드 포인트: `api/pin?username=anuraghazra&repo=github-readme-stats`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### 미리보기
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
[show_owner](#커스터마이징) 속성을 통해 저장소 소유자의 닉네임 표시 여부를 설정할 수 있어요.
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# 언어 사용량 통계
|
||||
|
||||
언어 사용량 통계 카드는 Github 사용자가 가장 많이 사용한 언어가 표시됩니다.
|
||||
|
||||
_참고:
|
||||
언어 사용량 통계는 GitHub 에서 가장 많이 사용된 언어의 표기일 뿐입니다.
|
||||
숙련도, 혹은 그와 비슷한 지표를 나타내진 않습니다. (새로 추가된 기능입니다!)_
|
||||
|
||||
### 사용법
|
||||
|
||||
이 코드를 복사해서 여러분의 README 에 넣고 링크를 변경해주세요.
|
||||
|
||||
엔드 포인트: `api/top-langs?username=anuraghazra`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### 통계에서 제외할 저장소 지정하기
|
||||
|
||||
`?exclude_repo=repo1,repo2` 속성을 통해 특정 저장소를 제외할 수 있어요.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### 통계에서 특정 언어 제외하기
|
||||
|
||||
`?hide=language1,language2` 속성을 통해 특정 언어를 제외할 수 있어요.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### 표시할 언어 수 지정하기
|
||||
|
||||
`&langs_count=` 속성을 통해 카드에 표시할 언어의 수를 지정할 수 있어요. (1-10 사이, 기본 값 : 5)
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### 컴택트한 카드 레이아웃 설정하기
|
||||
|
||||
`&layout=compact` 속성을 통해 카드의 디자인을 변경할 수 있어요.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### 미리보기
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- 컴팩트한 레이아웃
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# Wakatime 주간 통계
|
||||
|
||||
`?username=` 속성의 값을 [Wakatime](https://wakatime.com) 계정의 사용자 명(닉네임)으로 바꿔주세요.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### 미리보기
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- 컴팩트한 레이아웃
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### 전체 미리보기
|
||||
|
||||
- 기본
|
||||
|
||||

|
||||
|
||||
- 특정 통계 내용 숨김
|
||||
|
||||

|
||||
|
||||
- 아이콘 표시
|
||||
|
||||

|
||||
|
||||
- 전체 커밋 포함 시
|
||||
|
||||

|
||||
|
||||
- 테마들
|
||||
|
||||
[내장 테마](#themes) 에서 직접 선택해보세요
|
||||
|
||||

|
||||
|
||||
- 그라데이션 주기
|
||||
|
||||

|
||||
|
||||
- 통계 카드 커스터마이징하기
|
||||
|
||||

|
||||
|
||||
- 언어 사용 지역 설정하기
|
||||
|
||||

|
||||
|
||||
- 저장소 핀 커스터마이징하기
|
||||
|
||||

|
||||
|
||||
- 언어 사용량 통계
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Wakatime 카드
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### 꿀팁 (저장소 핀 정렬하기)
|
||||
|
||||
아마, 이미지들을 나란히 정렬할 수 없을거에요.
|
||||
|
||||
그럴땐, 이렇게 해보세요!
|
||||
|
||||
```html
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/convoychat">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=convoychat" />
|
||||
</a>
|
||||
```
|
||||
|
||||
## 나만의 Vercel 인스턴스에 직접 배포하기
|
||||
|
||||
#### [@codeSTACKr 님의 튜토리얼 영상 보기](https://youtu.be/n6d4KHSKqGk?t=107)
|
||||
|
||||
GitHub API 가 시간 당 요청 개수를 5,000회로 제한한 뒤로,
|
||||
저의 `https://github-readme-stats.vercel.app/api` 가 사용량 제한에 걸릴 위험이 생겼어요.
|
||||
|
||||
만약, 여러분이 Vercel server 에서 직접 호스트 하신다면, 걱정하실 일은 없을거에요.
|
||||
|
||||
아래의 버튼을 이용해 직접 배포해보세요!
|
||||
|
||||
참고: [#58](https://github.com/anuraghazra/github-readme-stats/pull/58) 풀 리퀘스트 이후로, 저희는 5,000 개 이상의 요청을 처리할 수 있게 됐어요. 더이상 서버 다운에 대한 걱정은 노놉! :D
|
||||
|
||||
[](https://vercel.com/import/project?template=https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
<details>
|
||||
<summary><b> 🔨 Vercel 세팅 가이드! </b></summary>
|
||||
|
||||
1. [vercel.com](https://vercel.com/) 으로 이동하기
|
||||
1. `Log in` 버튼 클릭!
|
||||

|
||||
1. `Continue with GitHub` 버튼을 이용해 GitHub 계정으로 가입하기
|
||||

|
||||
1. GitHub 에 로그인한 뒤, (권한을 요청한다면) 모든 저장소에 대한 권한을 허용해주세요!
|
||||
1. 이 저장소를 Fork!
|
||||
1. [Vercel 대시보드](https://vercel.com/dashboard) 로 돌아가세요!
|
||||
1. `Import Project` 항목 선택!
|
||||

|
||||
1. `Import Git Repository` 항목 선택!
|
||||

|
||||
1. 'root' 를 선택하고 넘어간 후, 아래와 같이 개인용 엑세스 토큰 (PAT) 을 저장할 환경변수를 PAT_1 의 값으로 추가해주세요. [이 곳](https://github.com/settings/tokens/new)에서 쉽게 생성할 수 있어요. (모든 항목을 그대로 두고, 이 부분만 원하는 이름으로 변경해주세요.)
|
||||

|
||||
1. 마지막으로 'Deploy' 버튼을 클릭하면, 끝! => API 를 사용하기 위한 도메인 주소를 확인하세요!
|
||||
|
||||
</details>
|
||||
|
||||
## :sparkling_heart: 프로젝트 지원하기!
|
||||
|
||||
저는 가능한 모든 요소들을 오픈소스로 공개하고,
|
||||
이 서비스를 이용하는데 도움이 필요한 모두에게 도움을 드리려 노력하고 있어요.
|
||||
|
||||
솔직히 말하자면, 시간이 좀 걸린답니다...
|
||||
물론, 여러분이 이 서비스를 사용하는건 무료에요 ㅎ
|
||||
|
||||
하지만, 만약 여러분이 이 서비스를 잘 이용하시고,
|
||||
만족하시거나, 제가 이런 요소들을 만드는 데에 도움을 주고 싶으시다면,
|
||||
여러분께서 도와주실 수 있는 것들이 있어요!
|
||||
|
||||
- github-readme-stats 를 README 에 표시하실 때 확실한 도움을 주세요! 이 저장소로 링크를 걸어주시면 돼요! :D
|
||||
- 이 프로젝트를 많이 공유해주시고, 즐겨찾기 해주세요! :rocket:
|
||||
- [](https://www.paypal.me/anuraghazra) - PayPal 을 이용해 1회성 도네이션을 해주실 수 있어요. 아마도 전 ~~커피, 아... 아니~~ 차를 사서 마시겠죠? ㅎ; :tea:
|
||||
|
||||
감사합니다! :heart:
|
||||
|
||||
---
|
||||
|
||||
[](https://vercel.com?utm_source=github_readme_stats_team&utm_campaign=oss)
|
||||
|
||||
프로젝트에 대한 기여는 언제나 환영이에요! <3
|
||||
|
||||
Made with :heart: and JavaScript.
|
||||
@@ -0,0 +1,407 @@
|
||||
<p align="center">
|
||||
<img width="100px" src="https://res.cloudinary.com/anuraghazra/image/upload/v1594908242/logo_ccswme.svg" align="center" alt="GitHub Readme Stats" />
|
||||
<h2 align="center">GitHub Readme Stats</h2>
|
||||
<p align="center">Krijg dynamisch gegenereerde GitHub statistieken op je readme's!</p>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/actions">
|
||||
<img alt="Tests Passing" src="https://github.com/anuraghazra/github-readme-stats/workflows/Test/badge.svg" />
|
||||
</a>
|
||||
<a href="https://codecov.io/gh/anuraghazra/github-readme-stats">
|
||||
<img src="https://codecov.io/gh/anuraghazra/github-readme-stats/branch/master/graph/badge.svg" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues">
|
||||
<img alt="Issues" src="https://img.shields.io/github/issues/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/pulls">
|
||||
<img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="#demo">Bekijk Demo</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Rapporteer een Bug</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Vraag een nieuwe toepassing aan</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="/docs/readme_fr.md">Français </a>
|
||||
·
|
||||
<a href="/docs/readme_cn.md">简体中文</a>
|
||||
·
|
||||
<a href="/docs/readme_es.md">Español</a>
|
||||
·
|
||||
<a href="/docs/readme_de.md">Deutsch</a>
|
||||
·
|
||||
<a href="/docs/readme_ja.md">日本語</a>
|
||||
·
|
||||
<a href="/docs/readme_pt-BR.md">Português Brasileiro</a>
|
||||
·
|
||||
<a href="/docs/readme_it.md">Italiano</a>
|
||||
·
|
||||
<a href="/docs/readme_kr.md">한국어</a>
|
||||
.
|
||||
<a href="/docs/readme_nl.md">Nederlands</a>
|
||||
.
|
||||
<a href="/docs/readme_np.md">नेपाली</a>
|
||||
</p>
|
||||
</p>
|
||||
<p align="center">Bevalt het project? <a href="https://www.paypal.me/anuraghazra">Doneer</a> om het te verbeteren!
|
||||
|
||||
# Functionaliteiten
|
||||
|
||||
- [GitHub Statistieken Kaart](#github-statistieken-kaart)
|
||||
- [GitHub Extra Pins](#github-extra-pins)
|
||||
- [Top Programmeertalen Kaart](#top-Programmeertalen-kaart)
|
||||
- [Wekelijkse Wakatime Statistieken](#wekelijkse-wakatime-statistieken)
|
||||
- [Thema\'s](#themas)
|
||||
- [Opmaak](#opmaak)
|
||||
- [Zelf deployen](#deploy-je-eigen-vercel-instatie)
|
||||
|
||||
# GitHub Statistieken Kaart
|
||||
|
||||
Kopieer en plak dit in je markdown content, zo simpel is het!
|
||||
|
||||
Verander de waarde `?username=` naar jou gebruikersnaam.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
_Notitie: Beschikbare rangen zijn S+ (top 1%), S (top 25%), A++ (top 45%), A+ (top 60%), and B+ (iedereen).
|
||||
De waarden worden berekend met behulp van de zogeheten [cumulative distribution function](https://en.wikipedia.org/wiki/Cumulative_distribution_function) met de waardes van de commits, bijdragens, issues, sterren, PR's, volgers en eigen repositories.
|
||||
De implementatie hiervan kan bekijken op [src/calculateRank.js](../src/calculateRank.js)_
|
||||
|
||||
### Verberg individueele statistieken
|
||||
|
||||
Om specifieke statistieken te verbergen, kan je een `?hide=` query parameter toevogen, verdeeld met komma\'s.
|
||||
|
||||
|
||||
> Opties: `&hide=stars,commits,prs,issues,contribs`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Voeg privé contributies toe aan totale commits.
|
||||
|
||||
Je kan de hoeveelheid privé commits toevoegen aan je totale hoeveelheid commits door de query parameter `?count_private=true` te gebruiken.
|
||||
|
||||
_Notitie: Als je dit project zelf deployt, zullen de privé contributies standaard toegevoegt worden aan je totaal, omdat anders je hoeveelheid privé contributies moet delen._
|
||||
|
||||
> Opties: `&count_private=true`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Laat icoontjes zien
|
||||
|
||||
Om icoontjes te gebruiken kan je `show_icons=true` gebruiken in de query parameter, zoals hier:
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Thema\'s
|
||||
|
||||
Met ingebouwde thema\'s kan je het uiterlijk van de kaart aanpassen zonder enige [handmatige opmaak](#customization).
|
||||
|
||||
Gebruik `?theme=THEME_NAME` parameters zo :-
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
#### Alle ingeboude thema\'s :-
|
||||
|
||||
dark, radical, merko, gruvbox, tokyonight, onedark, cobalt, synthwave, highcontrast, dracula
|
||||
|
||||
<img src="https://res.cloudinary.com/anuraghazra/image/upload/v1595174536/grs-themes_l4ynja.png" alt="GitHub Readme Statestieken Thema's" width="600px"/>
|
||||
|
||||
Je kan een preview van alle [beschikbare thema\'s](../themes/README.md) bekijken, of zie het [thema configuratie bestand](../themes/index.js) en **je kan aan nieuwe thema\'s bijdragen** als je dat leuk lijkt :D
|
||||
|
||||
### Opmaak
|
||||
|
||||
Je kan het uiterlijk van je `Statistieken kaart` of `Repo kaart` aanpassen hoe je ook maar wilt met URL parameters.
|
||||
|
||||
#### Veel gebruikte opties:
|
||||
|
||||
- `title_color` - De kleur van de titel van de kaart _(hex kleur)_
|
||||
- `text_color` - Tekst kleur _(hex kleur)_
|
||||
- `icon_color` - Icoon kleuren, wanneer beschikbaar _(hex kleur)_
|
||||
- `bg_color` - Achtergrond kleur van de kaart _(hex kleur)_ **of** een verloop van kleuren in het formaat van _graden,start,einde_
|
||||
- `hide_border` - Verbergt de rand van de kaart _(boolean)_
|
||||
- `theme` - Naam van het thema, kies uit [alle beschikbare thema\'s](../themes/README.md)
|
||||
- `cache_seconds` - Stel de cache header handmatig in _(min: 1800, max: 86400)_
|
||||
- `locale` - Stel taal van de kaart in _(e.g. cn, de, es, etc.)_
|
||||
|
||||
##### Kleurenverloop in bg_color (achtergrond kleur):
|
||||
|
||||
Je kan meerdere komma verdeelde waarden in de bg_color optie geven om een kleurenverloop te creeëren, het formaat van het kleurenverloop is:-
|
||||
|
||||
```
|
||||
&bg_color=GRADEN,KLEUR1,KLEUR2,KLEUR3...KLEUR10
|
||||
```
|
||||
|
||||
> Notities i.v.b.m. cache: Repo kaarten hebben een standaard cache van 4 uur (14400 seconden) als de fork hoeveelheid en de star hoeveelheid minder is dan 1k, anders is het 2 uur (7200 seconden). Daarnaast ligt de cache vast aan een minimum van 2 uur en een maximum van 24 uur.
|
||||
|
||||
#### Exclusieve opties voor Statistieken Kaart:
|
||||
|
||||
- `hide` - Verbergt gespecificeerde items van de statistieken. _(komma gescheiden waardes)_
|
||||
- `hide_title` - _(boolean)_
|
||||
- `hide_rank` - _(boolean)_
|
||||
- `show_icons` - _(boolean)_
|
||||
- `include_all_commits` - Tel alle commits inplaats van alleen de commits van het huidige jaar _(boolean)_
|
||||
- `count_private` - Tel privé commits mee _(boolean)_
|
||||
- `line_height` - Stel de lijn-hoogte tussen text in _(nummer)_
|
||||
- `custom_title` - Stel een aangepaste titel voor je kaart in
|
||||
|
||||
#### Exclusieve opties voor Repo Kaart:
|
||||
|
||||
- `show_owner` - Laat de eigenaar van de repo zien _(boolean)_
|
||||
|
||||
#### Exclusieve opties voor Programmeertaal Kaart:
|
||||
|
||||
- `hide` - Verbergt specifieke talen van de kaart _(komma gescheiden waardes)_
|
||||
- `hide_title` - _(boolean)_
|
||||
- `layout` - Keuze voor de twee beschikbare layouts `default` & `compact`
|
||||
- `card_width` - Stelt de breedte van de kaart handmatig in. _(nummer)_
|
||||
- `langs_count` - Laat meer talen op de kaart zien, waarde tussen 1-10, staat standaard op to 5 _(nummer)_
|
||||
- `exclude_repo` - Verbergt specifieke repositories _(komma gescheiden waardes)_
|
||||
- `custom_title` - Stelt een eigen titel voor de kaart in
|
||||
|
||||
> :Waarschuwing: **Belangrijk:**
|
||||
> Namen van programmeertalen moeten worden geuri-escaped, zoals gespecificeerd in [Percent Encoding](https://en.wikipedia.org/wiki/Percent-encoding)
|
||||
> (Oftewel: `c++` moet `c%2B%2B` worden, `jupyter notebook` moet `jupyter%20notebook` worden, enzovoort...)
|
||||
> Zie [urlencoder.org](https://www.urlencoder.org/) om dit automatisch te doen.
|
||||
|
||||
#### Exclusieve opties voor Wakatime Kaart:
|
||||
|
||||
- `hide_title` - _(boolean)_
|
||||
- `line_height` - Verandert de lijn hoogte tussen tekst _(nummer)_
|
||||
- `hide_progress` - Verbergt de progressiebalk en het percentage _(boolean)_
|
||||
- `custom_title` - Stelt een eigen titel voor de kaart in
|
||||
- `layout` - Schakel tussen de twee beschikbare lay-outs `default` en `compact`
|
||||
|
||||
---
|
||||
|
||||
# GitHub Extra Pins
|
||||
|
||||
GitHub extra pins geven je de mogelijkheid om meer dan 6 repositories op je profiel te pinnen, doormiddel van een GitHub readme profile.
|
||||
|
||||
Joepie! Je bent niet langer aan 6 pins gelimiteerd!
|
||||
|
||||
### Gebruik
|
||||
|
||||
Kopieer en plak deze code in je readme en verander de links.
|
||||
|
||||
Eindpunt: `api/pin?username=anuraghazra&repo=github-readme-stats`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Demo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
Gebruikt [show_owner](#customization) variabele om de repo\'s eigenaar toe te voegen
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# Top Programmeertalen Kaart
|
||||
|
||||
De top programmeertalen kaart laat zien welke talen een GitHub gebruiker het meest gebruikt.
|
||||
|
||||
_Notitie: Top programmeertalen wijzen niet op een vaardigheids niveau, het is puur een GitHub metriek over welke talen de meeste code op GitHub hebben. Het is een nieuwe funktie van github-readme-stats._
|
||||
|
||||
### Gebruik
|
||||
|
||||
Kopieer en plak deze code in je readme en verander de links.
|
||||
|
||||
|
||||
Eindpunt: `api/top-langs?username=anuraghazra`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Verberg individueele repositories
|
||||
|
||||
Je kan de parameter `?exclude_repo=repo1,repo2` gebruiken om individueele repositories te verbergen.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Verberg individueele talen
|
||||
|
||||
Je kan de `?hide=taal1,taal2` parameter gebruiken om individuele programmeer talen te verbergen.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Laat meer programmeertalen zien
|
||||
|
||||
Je kan de `&langs_count=` optie gebruiken om de hoeveelheid talen op je kaart groter en kleiner te maken. Geldige waardes zijn tussen de 1 en 10 (inclusief), en de standaard waarde is 5.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Compacte Talen Kaart opmaak
|
||||
|
||||
Je kan de `&layout=compact` optie gebruiken om het kaart ontwerp aan te passen.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Demo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Compacte opmaak
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# Wekelijkse Wakatime Statistieken
|
||||
|
||||
Verander de `?username=` waarde naar je [Wakatime](https://wakatime.com) gebruikersnaam.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Demo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### Alle demos
|
||||
|
||||
- Standaard
|
||||
|
||||

|
||||
|
||||
- Verberg specifieke statestieken
|
||||
|
||||

|
||||
|
||||
- Weergeef icoontjes
|
||||
|
||||

|
||||
|
||||
- Voeg alle commits toe
|
||||
|
||||

|
||||
|
||||
- Thema\'s
|
||||
|
||||
Kies uit de [standaard thema\'s](#themes)
|
||||
|
||||

|
||||
|
||||
- Kleurenverloop
|
||||
|
||||

|
||||
|
||||
- Pas statistieken kaart aan
|
||||
|
||||

|
||||
|
||||
- Stel je kaart locale (taal) in
|
||||
|
||||

|
||||
|
||||
- Pas repo kaart aan.
|
||||
|
||||

|
||||
|
||||
- Top programmeertalen
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Wakatime kaart
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### Kleine tip (Verstel de repo kaart z\'n positie)
|
||||
|
||||
Meestal kan je de afbeeldingen niet naast elkaar zetten, op deze manier wel:
|
||||
|
||||
```html
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/convoychat">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=convoychat" />
|
||||
</a>
|
||||
```
|
||||
|
||||
## Deploy je eigen Vercel instatie
|
||||
|
||||
#### [Check de stapsgewijze video tutorial door @codeSTACKr (In het Engels)](https://youtu.be/n6d4KHSKqGk?t=107)
|
||||
|
||||
Sinds de GitHub API alleen maar 5k verzoeken per uur toestaat, zou mijn `https://github-readme-stats.vercel.app/api` mogelijk de rate limiet behalen. Als je het op je eigen Vercel server host, dan hoef je je nergens zorgen om te maken. Klik op de deploy knop om te beginnen!
|
||||
|
||||
NOTITIE: Sinds [#58](https://github.com/anuraghazra/github-readme-stats/pull/58) zouden we geen problemen meer moeten hebben de 5k verzoeken per uur, en verdere downtime :D
|
||||
|
||||
[](https://vercel.com/import/project?template=https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
<details>
|
||||
<summary><b>Versel deploy gids: 🔨 </b></summary>
|
||||
|
||||
1. Ga naar [vercel.com](https://vercel.com/)
|
||||
2. Klik op `Log in`
|
||||

|
||||
3. Meld je aan met GitHub door op `Continue with GitHub` te klikken.
|
||||

|
||||
4. Log in op GitHub en sta toegang tot alle repositories toe, wanneer dat gevraagt wordt.
|
||||
5. Fork deze repo
|
||||
6. Ga terug naar je [Vercel dashboard](https://vercel.com/dashboard)
|
||||
7. Selecteer `Import Project`
|
||||

|
||||
8. Selecteer `Import Git Repository`
|
||||

|
||||
9. Selecteer root en hou alles zoals het is, voeg alleen je environment variable genaamd PAT_1 toe (Zoals hier late zien word), die beheert over een persoonlijke toegangs token (PAT), die je gemakklijk [hier](https://github.com/settings/tokens/new) gemakkelijk kan creeëren. (Laat alles zoals het is, noem het maar iets, mag alles zijn.)
|
||||

|
||||
10. Klik deploy, en alles zou moeten werken. Zie je domein om de api te gebruiken!
|
||||
|
||||
</details>
|
||||
|
||||
## :sparkling_heart: Ondersteun het project
|
||||
|
||||
Ik maak bijna alles open-source wat ik kan, en ik probeer iedereen te helpen die deze projecten gebruiken. Natuurlijk kost dit tijd, je mag deze services gratis gebruiken.
|
||||
|
||||
Hoe dan ook, als je dit project gebruikt en er blij mee bent, of mij wilt aanmoedigen om dingen te blijven maken, zijn er een paar manieren om dit te doen; -
|
||||
|
||||
- Credits geven aan github-readme-stats op je readme, die terug naar het project linkt :D
|
||||
- Sterren en delen van het project :rocket:
|
||||
- [](https://www.paypal.me/anuraghazra) - Je kan eenmalig giften via PayPal, ik koop er waarschijnlijk ~~koffie~~ thee van. :tea:
|
||||
|
||||
Bedankt! :heart:
|
||||
|
||||
---
|
||||
|
||||
[](https://vercel.com?utm_source=github_readme_stats_team&utm_campaign=oss)
|
||||
|
||||
Contributies zijn welkom! <3
|
||||
|
||||
Gemaakt met :heart: en JavaScript.
|
||||
@@ -0,0 +1,403 @@
|
||||
<p align="center">
|
||||
<img width="100px" src="https://res.cloudinary.com/anuraghazra/image/upload/v1594908242/logo_ccswme.svg" align="center" alt="GitHub Readme Stats" />
|
||||
<h2 align="center">GitHub Readme Stats</h2>
|
||||
<p align="center">पहुनु होस् द्य्नामिचल्ली गेनेरटे गितहब रेअडमी सतत </p>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/actions">
|
||||
<img alt="Tests Passing" src="https://github.com/anuraghazra/github-readme-stats/workflows/Test/badge.svg" />
|
||||
</a>
|
||||
<a href="https://codecov.io/gh/anuraghazra/github-readme-stats">
|
||||
<img src="https://codecov.io/gh/anuraghazra/github-readme-stats/branch/master/graph/badge.svg" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues">
|
||||
<img alt="Issues" src="https://img.shields.io/github/issues/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/pulls">
|
||||
<img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="#demo">डेमो हेर्नुहोस्</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">रिपोर्ट बग</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">अनुरोध सुविधा</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="/docs/readme_fr.md">Français </a>
|
||||
·
|
||||
<a href="/docs/readme_cn.md">简体中文</a>
|
||||
·
|
||||
<a href="/docs/readme_es.md">Español</a>
|
||||
·
|
||||
<a href="/docs/readme_de.md">Deutsch</a>
|
||||
·
|
||||
<a href="/docs/readme_ja.md">日本語</a>
|
||||
·
|
||||
<a href="/docs/readme_pt-BR.md">Português Brasileiro</a>
|
||||
·
|
||||
<a href="/docs/readme_it.md">Italiano</a>
|
||||
·
|
||||
<a href="/docs/readme_kr.md">한국어</a>
|
||||
·
|
||||
<a href="/docs/readme_np.md">नेपाली</a>
|
||||
</p>
|
||||
</p>
|
||||
<p align="center">परियोजना मनपर्यो? तपाईं मद्दत गर्न सक्नुहुन्छ <a href="https://www.paypal.me/anuraghazra">यो परियोजना</a> बढ्न
|
||||
|
||||
# विशेषताहरु
|
||||
|
||||
- [गितहब स्टेट कार्ड](#गितहब-स्टेट-कार्ड)
|
||||
- [गितहब अतिरिक्त पिन्स](#गितहब-अतिरिक्त-पिन्स)
|
||||
- [टोप भाषा कार्ड](#टोप-भाषा-कार्ड)
|
||||
- [वाका समय वीक स्तट्स ](#वाका-समय-वीक-स्तट्स )
|
||||
- [विषयवस्तुहरू](#विषयवस्तुहरू)
|
||||
- [अनुकूलन](#अनुकूलन)
|
||||
- [आफैलाई तैनाथ गर्नुहोस्](#देप्लोय-आफ्नै-वेर्चेल-इन्स्तंस )
|
||||
|
||||
# गितहब स्टेट कार्ड
|
||||
|
||||
Copy-paste this into your markdown content, and that's it. Simple!
|
||||
|
||||
Change the `?username=` value to your GitHub's username.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
_Note: Ranks are calculated based on user's stats, see [src/calculateRank.js](./src/calculateRank.js)_
|
||||
|
||||
### लुकाउनु होस् व्यक्तिगत स्टेट
|
||||
|
||||
To hide any specific stats, you can pass a query parameter `?hide=` with comma-separated values.
|
||||
|
||||
> Options: `&hide=stars,commits,prs,issues,contribs`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### जोड्नु होस् निजी टोटल योगदान
|
||||
|
||||
You can add the count of all your private contributions to the total commits count by using the query parameter `?count_private=true`.
|
||||
|
||||
_Note: If you are deploying this project yourself, the private contributions will be counted by default otherwise you need to chose to share your private contribution counts._
|
||||
|
||||
> Options: `&count_private=true`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### देखाउनु होस् इकोन
|
||||
|
||||
To enable icons, you can pass `show_icons=true` in the query param, like so:
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### विषयवस्तुहरू
|
||||
|
||||
With inbuilt themes, you can customize the look of the card without doing any [manual customization](#customization).
|
||||
|
||||
Use `?theme=THEME_NAME` parameter like so :-
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
#### सबै इनबिल्ट विषयवस्तु :-
|
||||
|
||||
dark, radical, merko, gruvbox, tokyonight, onedark, cobalt, synthwave, highcontrast, dracula
|
||||
|
||||
<img src="https://res.cloudinary.com/anuraghazra/image/upload/v1595174536/grs-themes_l4ynja.png" alt="GitHub Readme Stat Themes" width="600px"/>
|
||||
|
||||
|
||||
तपैले सबै थेम्सहरु प्रेविउ गर्न सक्नु हुनेछ । [all available themes](./themes/README.md) नत्र थेम्सहरुको config [theme config file](./themes/index.js) पनि हेर्न सक्नु हुनेछ र **थेम्सहरुमा योगदान पनि गर्नु सक्नु हुनेछ** :D ।
|
||||
|
||||
### अनुकूलन
|
||||
|
||||
तपैले `Stats Card` or `Repo Card` को अपपेअरंस कस्टमेज गर्न सक्नु हुनेछ जसमा तपैले URL params पनि प्रयोग गर्नु सक्नु हुनेछ ।
|
||||
|
||||
#### साधारण विकल्पहरू:
|
||||
|
||||
- `title_color` - Card's title color _(hex color)_
|
||||
- `text_color` - Body text color _(hex color)_
|
||||
- `icon_color` - Icons color if available _(hex color)_
|
||||
- `bg_color` - Card's background color _(hex color)_ **or** a gradient in the form of _angle,start,end_
|
||||
- `hide_border` - Hides the card's border _(boolean)_
|
||||
- `theme` - name of the theme, choose from [all available themes](./themes/README.md)
|
||||
- `cache_seconds` - set the cache header manually _(min: 1800, max: 86400)_
|
||||
- `locale` - set the language in the card _(e.g. cn, de, es, etc.)_
|
||||
|
||||
##### Gradient in bg_color
|
||||
|
||||
You can provide multiple comma-separated values in bg_color option to render a gradient, the format of the gradient is :-
|
||||
|
||||
```
|
||||
&bg_color=DEG,COLOR1,COLOR2,COLOR3...COLOR10
|
||||
```
|
||||
|
||||
> Note on cache: Repo cards have a default cache of 4 hours (14400 seconds) if the fork count & star count is less than 1k, otherwise, it's 2 hours (7200 seconds). Also, note that the cache is clamped to a minimum of 2 hours and a maximum of 24 hours
|
||||
|
||||
#### Stats कार्ड विशेष विकल्पहरू:
|
||||
|
||||
- `hide` - Hides the specified items from stats _(Comma-separated values)_
|
||||
- `hide_title` - _(boolean)_
|
||||
- `hide_rank` - _(boolean)_
|
||||
- `show_icons` - _(boolean)_
|
||||
- `include_all_commits` - Count total commits instead of just the current year commits _(boolean)_
|
||||
- `count_private` - Count private commits _(boolean)_
|
||||
- `line_height` - Sets the line-height between text _(number)_
|
||||
- `custom_title` - Sets a custom title for the card
|
||||
|
||||
#### Repo कार्ड विशेष विकल्पहरू:
|
||||
|
||||
- `show_owner` - Show the owner name of the repo _(boolean)_
|
||||
|
||||
#### भाषा कार्ड अनन्य विकल्पहरू :
|
||||
|
||||
- `hide` - Hide the languages specified from the card _(Comma-separated values)_
|
||||
- `hide_title` - _(boolean)_
|
||||
- `layout` - Switch between two available layouts `default` & `compact`
|
||||
- `card_width` - Set the card's width manually _(number)_
|
||||
- `langs_count` - Show more languages on the card, between 1-10, defaults to 5 _(number)_
|
||||
- `exclude_repo` - Exclude specified repositories _(Comma-separated values)_
|
||||
- `custom_title` - Sets a custom title for the card
|
||||
|
||||
> :warning: **Important:**
|
||||
> Language names should be uri-escaped, as specified in [Percent Encoding](https://en.wikipedia.org/wiki/Percent-encoding)
|
||||
> (i.e: `c++` should become `c%2B%2B`, `jupyter notebook` should become `jupyter%20notebook`, etc.)
|
||||
|
||||
#### वकासमय कार्ड विशेष विकल्प:
|
||||
|
||||
- `hide_title` - _(boolean)_
|
||||
- `line_height` - Sets the line-height between text _(number)_
|
||||
- `hide_progress` - Hides the progress bar and percentage _(boolean)_
|
||||
- `custom_title` - Sets a custom title for the card
|
||||
|
||||
---
|
||||
|
||||
# गितहब अतिरिक्त पिन्स
|
||||
|
||||
GitHub extra pins allow you to pin more than 6 repositories in your profile using a GitHub readme profile.
|
||||
|
||||
GitHub फाल्तु पिनले तपाइँलाए GitHub रीडमी प्रोफाइल प्रयोग गरी तपाइँको प्रोफाइलमा छ ओटा भन्दा बढि प्रोजेक्टहरु पिन गर्न अनुमति दिन्छ ।
|
||||
|
||||
हो! तपाईं अब pin पिन गरीएको छ ओटा प्रोजेक्ट सीमित हुनुहुन्छ ।
|
||||
|
||||
### प्रयोग
|
||||
|
||||
कोदलाए कपी- पेसेत readme मा गर्नु होला र लिंक परिवतन गर्नु होला |
|
||||
|
||||
Endpoint: `api/pin?username=anuraghazra&repo=github-readme-stats`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### डेमो
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
Use [show_owner](#customization) variable to include the repo's owner username
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# टोप भाषा कार्ड
|
||||
|
||||
टोप भाषाकार्डले github परयोग गर्नेहरुको प्रोग्रम्मिंग भाषाहरु देखाऊने गर्दछ |.
|
||||
|
||||
_NOTE: टोप भाषाहरुले आफ्नो सिपलाए संकेत गरेको होईन | योचै Github Metricबाट धेरै कुन भाषा परयोग भाकोलाए संकेत गरेको हो |
|
||||
### प्रयोग
|
||||
|
||||
कोदलाए कपी- पेसेत readme मा गर्नु होला र लिंक परिवतन गर्नु होला |
|
||||
|
||||
Endpoint: `api/top-langs?username=anuraghazra`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Exclude individual repositories
|
||||
|
||||
You can use `?exclude_repo=repo1,repo2` parameter to exclude individual repositories.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### कुनै भाषा चुपौनॆ तरिका
|
||||
|
||||
You can use `?hide=language1,language2` parameter to hide individual languages.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### धेरॆ भाषाहरु हेर्नको लागि
|
||||
|
||||
You can use the `&langs_count=` option to increase or decrease the number of languages shown on the card. Valid values are integers between 1 and 10 (inclusive), and the default is 5.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### कम्प्याक्ट भाषा कार्ड ळयोउत
|
||||
|
||||
तपाइले `&layout=compact` ओप्तिओनपनि कार्ड देसिग्न को लागि परहयोग गर्न सक्नु हुन्क्ष
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### डेमो
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Compact layout
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# वाका समय वीक स्तट्स
|
||||
|
||||
Change the `?username=` value to your [Wakatime](https://wakatime.com) username.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### डेमो
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### सबै डेमोहरु
|
||||
|
||||
- देफौल्ट
|
||||
|
||||

|
||||
|
||||
- हिदिंग स्पेचific स्तट्स
|
||||
|
||||

|
||||
|
||||
- इकोनहरु शो गर्ने
|
||||
|
||||

|
||||
|
||||
- सबै कमितहरु
|
||||
|
||||

|
||||
|
||||
- थेम्स
|
||||
|
||||
कुनै एउटा चोज गर्नुस [default themes](#themes)
|
||||
|
||||

|
||||
|
||||
- घ्रदिएन्त
|
||||
|
||||

|
||||
|
||||
- स्तत्स कार्ड लाए कस्तोमेज गर्ने
|
||||
|
||||

|
||||
|
||||
- सेत्तिंग कार्ड लोचले
|
||||
|
||||

|
||||
|
||||
- रेपो कार्डलाई एडित गर्नु
|
||||
|
||||

|
||||
|
||||
- टोप भाषा
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- वक समय कार्ड
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### टिप् (रेपो कार्डलाए अलिग्न गर्ने )
|
||||
|
||||
तपाइले इमेजलाई सइद बय सइद अलीग्न गर्न सक्नु हुदैन तेसैले येसरी गर्नु होस् :
|
||||
|
||||
```html
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/convoychat">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=convoychat" />
|
||||
</a>
|
||||
```
|
||||
|
||||
## देप्लोय आफ्नै वेर्चेल इन्स्तंस
|
||||
|
||||
#### [Check Out Step By Step Video Tutorial By @codeSTACKr](https://youtu.be/n6d4KHSKqGk?t=107)
|
||||
|
||||
गितहब को अपिएले पाच हजार रेक़ुएस्त प्रति घण्टा मात्र मिल्क्ष । मेरो
|
||||
`https://github-readme-stats.vercel.app/api` प्रोजेक्ट मा रेत् लिमिट हुन सक्क्ष । तर तपाइले आफ्नै वेर्चेल सेर्वेर मा होस्ट गर्नु बाको छ बने यो प्रोब्लेम हुदैन।
|
||||
होस्ट गर्ने तरिका यस पकारका षन ।
|
||||
|
||||
NOTE: Since [#58](https://github.com/anuraghazra/github-readme-stats/pull/58) we should be able to handle more than 5k requests and have no issues with downtime :D
|
||||
|
||||
[](https://vercel.com/import/project?template=https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
<details>
|
||||
<summary><b> Guide on setting up Vercel 🔨 </b></summary>
|
||||
|
||||
1. Go to [vercel.com](https://vercel.com/)
|
||||
1. Click on `Log in`
|
||||

|
||||
1. Sign in with GitHub by pressing `Continue with GitHub`
|
||||

|
||||
1. Sign into GitHub and allow access to all repositories, if prompted
|
||||
1. Fork this repo
|
||||
1. Go back to your [Vercel dashboard](https://vercel.com/dashboard)
|
||||
1. Select `Import Project`
|
||||

|
||||
1. Select `Import Git Repository`
|
||||

|
||||
1. Select root and keep everything as is, just add your environment variable named PAT_1 (as shown), which will contain a personal access token (PAT), which you can easily create [here](https://github.com/settings/tokens/new) (leave everything as is, just name it something, it can be anything you want)
|
||||

|
||||
1. Click deploy, and you're good to go. See your domains to use the API!
|
||||
|
||||
</details>
|
||||
|
||||
## :sparkling_heart: सहपोर्ट द प्रोजेक्ट
|
||||
|
||||
म सके सम्म आफ्नो प्रोजेक्ट हरु ओपेन्सोउर्चे गर्छु र अरु ले पनि सहयोग गर्क्षु । मेले सहयोग गर्दा आफ्नो समय पनि देरै ने दिन्क्षु । तपाइहरु ले यो सेर्विचेस फ्री मा चलाउनु सक्नु हुनेक्ष ।
|
||||
|
||||
येदि तपाइले यो प्रोजेक्ट चलाउनु बाकोक्ष बने र मलाई अझै प्रसंसा गर्ने हो बने तपाइले थुप्रै तरिका ले गर्नु सक्नु हुने छ :-
|
||||
|
||||
- यो प्रोजेक्टमा तपाइले प्रहयोग गर्दा मलाई क्रेडिट दिन सक्नु हुनेक्ष ।
|
||||
- तपाइले Github ReadMe Stats स्तार्रेड गर्न सक्नु हुनेक्ष :rocket:
|
||||
- [](https://www.paypal.me/anuraghazra) - तपाइले पेपाल बाट पनि सहयोग (डक्क्षिन) गर्न सक्नु हुनेक्ष | म ~~कोफी ~~ चिया . :tea: किन्न सक्क्षु ।
|
||||
|
||||
धन्याबाद! :heart:
|
||||
|
||||
---
|
||||
|
||||

|
||||
|
||||
योगधन को लागी स्वगत छ! <3
|
||||
|
||||
जाभास्क्रिप्ट बाटा बनको :heart:
|
||||
@@ -0,0 +1,357 @@
|
||||
<p align="center">
|
||||
<img width="100px" src="https://res.cloudinary.com/anuraghazra/image/upload/v1594908242/logo_ccswme.svg" align="center" alt="GitHub Readme Stats" />
|
||||
<h2 align="center">GitHub Readme Stats</h2>
|
||||
<p align="center">Adicione suas estatísticas no GitHub geradas dinamicamente em seus readmes!</p>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/actions">
|
||||
<img alt="Testes aprovados" src="https://github.com/anuraghazra/github-readme-stats/workflows/Test/badge.svg" />
|
||||
</a>
|
||||
<a href="https://codecov.io/gh/anuraghazra/github-readme-stats">
|
||||
<img src="https://codecov.io/gh/anuraghazra/github-readme-stats/branch/master/graph/badge.svg" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues">
|
||||
<img alt="Issues" src="https://img.shields.io/github/issues/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/pulls">
|
||||
<img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Apoiado%20por-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Apoiado%20por-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="#demonstração">Ver demonstração</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Reportar erros</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Solicitar recursos</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="/docs/readme_fr.md">Français</a>
|
||||
·
|
||||
<a href="/docs/readme_cn.md">简体中文</a>
|
||||
·
|
||||
<a href="/docs/readme_es.md">Español</a>
|
||||
·
|
||||
<a href="/docs/readme_de.md">Deutsch</a>
|
||||
·
|
||||
<a href="/docs/readme_ja.md">日本語</a>
|
||||
·
|
||||
<a href="/docs/readme_pt-BR.md">Português Brasileiro</a>
|
||||
·
|
||||
<a href="/docs/readme_it.md">Italiano</a>
|
||||
·
|
||||
<a href="/docs/readme_kr.md">한국어</a>
|
||||
.
|
||||
<a href="/docs/readme_nl.md">Nederlands</a>
|
||||
.
|
||||
<a href="/docs/readme_np.md">नेपाली</a>
|
||||
</p>
|
||||
</p>
|
||||
<p align="center">Gostou do projeto? Por favor considere <a href="https://www.paypal.me/anuraghazra">fazer uma doação</a> para ajudar a melhorá-lo!
|
||||
|
||||
# Características
|
||||
|
||||
- [Cartão de estatísticas do GitHub](#cartão-de-estatísticas-do-github)
|
||||
- [Pins extras do GitHub](#pins-extras-do-github)
|
||||
- [Cartão de principais linguagens de programação](#cartão-de-principais-linguagens-de-programação)
|
||||
- [Estatística semanal Wakatime](#estatística-semanal-wakatime)
|
||||
- [Temas](#temas)
|
||||
- [Personalização](#personalização)
|
||||
- [Faça suas próprias implantações](#implante-em-sua-própria-instância-do-vercel)
|
||||
|
||||
# Cartão de estatísticas do GitHub
|
||||
|
||||
Copie e cole isso no seu conteúdo de remarcação e é isso. Simples!
|
||||
|
||||
Mude o valor de `?username=` para o seu nome de usuário no GitHub.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
_Nota: As classificações são baseadas nas estatísticas do usuário, veja [src/calculateRank.js](../src/calculateRank.js)_
|
||||
|
||||
### Ocultando estatísticas específicas
|
||||
|
||||
Para ocultar estatísticas individualmente, você pode passar um parâmetro de consulta `?hide=` com valores separados por vírgula.
|
||||
|
||||
> Opções: `&hide=stars,commits,prs,issues,contribs`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Adicionando contagem de contribuições privadas à contagem total de commits
|
||||
|
||||
Adicione a contagem de todas as suas contribuições privadas à contagem total de confirmações usando o parâmetro de consulta `?count_private=true`.
|
||||
|
||||
_Nota: Se você estiver implantando este projeto, as contribuições privadas serão contadas por padrão; caso contrário, você precisará compartilhar suas contagens de contribuições privadas._
|
||||
|
||||
> Opções: `&count_private=true`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Exibindo ícones
|
||||
|
||||
Para habilitar ícones, basta utilizar o parâmetro `show_icons=true` na sua requisição, da seguinte forma:
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Temas
|
||||
|
||||
Com temas predefinidos, pode personalizar a aparência dos cartões sem precisar fazer nenhuma [configuração manual](#personalização).
|
||||
|
||||
Utilize o parâmetro `?theme=THEME_NAME`, da seguinte forma:
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
#### Todos os temas predefinidos :
|
||||
|
||||
dark, radical, merko, gruvbox, tokyonight, onedark, cobalt, synthwave, highcontrast, dracula
|
||||
|
||||
<img src="https://res.cloudinary.com/anuraghazra/image/upload/v1595174536/grs-themes_l4ynja.png" alt="GitHub Readme Stat Themes" width="600px"/>
|
||||
|
||||
Visualize [todos o temas disponíveis](../themes/README.md) ou o [arquivo de configuração de tema](../themes/index.js), além de **também poder contribuir com novos temas**, se desejar :D
|
||||
|
||||
### Personalização
|
||||
|
||||
Personalize a aparência do seu `Stats Card` ou `Repo Card` da maneira que desejar com os parâmetros de URL.
|
||||
|
||||
#### Opções comuns
|
||||
|
||||
- `title_color` - Cor do título do cartão _(hex color)_
|
||||
- `text_color` - Cor de texto do conteúdo _(hex color)_
|
||||
- `icon_color` - Cor dos ícones (se disponível) _(hex color)_
|
||||
- `bg_color` - Cor de fundo do cartão _(hex color)_
|
||||
- `hide_border` - Esconde a borda do cartão _(boleano)_
|
||||
- `theme` - Nome do tema, escolha em [todos os temas disponíveis](../themes/README.md)
|
||||
- `cache_seconds` - Defina o cabeçalho do cache manualmente _(min: 1800, max: 86400)_
|
||||
- `locale` - defina o idioma no cartão _(por exemplo. cn, de, es, etc.)_
|
||||
|
||||
> Nota sobre o cache: Cartões de repositório tem um cache padrão de 30 minutos (1800 segundos), se o número a contagem de forks e contagem de estrelas é menor que 1 mil o padrão é 2 horas (7200). Note também que o cache é limitado a um mínimo de 30 minutos e um máximo de 24 horas.
|
||||
|
||||
#### Opções exclusivas do cartão de estatísticas:
|
||||
|
||||
- `hide` - Oculta itens específicos das estatísticas _(Valores separados por vírgulas)_
|
||||
- `hide_title` - Ocultar o título _(boolean)_
|
||||
- `hide_rank` - Ocultar a classificação _(boolean)_
|
||||
- `show_icons` - Mostrar ícones _(boolean)_
|
||||
- `include_all_commits` - Contabiliza todos os commits ao invés de apenas os atual ano _(boolean)_
|
||||
- `count_private` - Contabiliza commits privados _(boolean)_
|
||||
- `line_height` - Define a altura do espaçamento entre o texto _(number)_
|
||||
|
||||
#### Opções exclusivas do cartão de repositórios:
|
||||
|
||||
- `show_owner` - Exibir o nome da pessoa a quem o repositório pertence _(boolean)_
|
||||
|
||||
#### Opções exclusivas do cartão de linguagens:
|
||||
|
||||
- `hide` - Oculta linguagens específicas _(Valores separados por vírgulas)_
|
||||
- `hide_title` - Oculta o título _(boolean)_
|
||||
- `layout` - Alterna entre os dois layouts disponíveis `default` & `compact`
|
||||
- `card_width` - Define a largura do cartão manualmente _(number)_
|
||||
|
||||
> :warning: **Importante:**
|
||||
> Nomes de linguagens devem ser uma sequência escapada de URI, como específicado em [Codificação por cento](https://pt.wikipedia.org/wiki/Codificação_por_cento)
|
||||
> (Isso é: `c++` deve se tornar `c%2B%2B`, `jupyter notebook` deve se tornar `jupyter%20notebook`, etc.)
|
||||
|
||||
---
|
||||
|
||||
# Pins extras do GitHub
|
||||
|
||||
Os Pins extras do GitHub permitem fixar mais de 6 repositórios no seu perfil usando um perfil README.me do GitHub.
|
||||
|
||||
Uhu! Você não está mais limitado a 6 repositórios fixados.
|
||||
|
||||
### Utilização
|
||||
|
||||
Copie e cole esse código no seu README.md e altere os atributos.
|
||||
|
||||
Endpoint: `api/pin?username=anuraghazra&repo=github-readme-stats`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Demonstração
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
Utilize a variável [show_owner](#personalização) para incluir o nome de usuário do proprietária do repositório
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# Cartão de principais linguagens de programação
|
||||
|
||||
Exibe uma métrica de linguagens de programação mais usadas pelo usuário do GitHub.
|
||||
|
||||
_Nota: As principais linguagens de programação não fazem declarações sobre habilidades pessoais ou similares, é apenas uma figura-chave com base nas estatísticas do GitHub do usuário indicando a frequência com que cada uma foi utilizada._
|
||||
|
||||
### Utilização
|
||||
|
||||
Copie e cole esse código no seu README.md e altere os atributos.
|
||||
|
||||
Endpoint: `api/top-langs?username=anuraghazra`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Ocultar linguagens individualmente
|
||||
|
||||
Utilize o parâmetro `?hide=language1,language2` para ocultar linguagens específicas.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Layout de cartão de linguagens compacto
|
||||
|
||||
Utilize a opção `&layout=compact` para mudar o layout do cartão.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Demonstração
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Layout compacto
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# Estatística semanal Wakatime
|
||||
|
||||
Altere o valor de `?username=` para o seu username do Wakatime.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Demonstração
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
|
||||
|
||||
### Todas as demonstrações
|
||||
|
||||
- Padronizado
|
||||
|
||||

|
||||
|
||||
- Ocultando estatísticas específicas
|
||||
|
||||

|
||||
|
||||
- Mostrando ícones
|
||||
|
||||

|
||||
|
||||
- Incluir todos os commits
|
||||
|
||||

|
||||
|
||||
- Temas
|
||||
|
||||
Escolha entre um dos [temas predefinidos](#temas)
|
||||
|
||||

|
||||
|
||||
- Personalizando o cartão de estatísticas
|
||||
|
||||

|
||||
|
||||
- Customizando o cartão de repositório
|
||||
|
||||

|
||||
|
||||
- Principais linguagens
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### Dica (Alinhandos os cartões de repositório)
|
||||
|
||||
Por padrão, você não poderá organizar as imagens lado a lado. Para fazer isso, você pode usar a seguinte abordagem:
|
||||
|
||||
```html
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/convoychat">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=convoychat" />
|
||||
</a>
|
||||
```
|
||||
|
||||
## Implante em sua própria instância do Vercel
|
||||
|
||||
#### [Check Out Step By Step Video Tutorial By @codeSTACKr](https://youtu.be/n6d4KHSKqGk?t=107)
|
||||
|
||||
Como a API do GitHub permite apenas 5 mil solicitações por hora, é possível que minha `https://github-readme-stats.vercel.app/api` atinja a cota limite. Se hospedar em seu próprio servidor Vercel, não precisará se preocupar com nada. Clique no botão de implantação para começar!
|
||||
|
||||
Nota: Desde [#58](https://github.com/anuraghazra/github-readme-stats/pull/58) há possibilidade de lidar com mais de 5 mil chamadas por hora, sem interrupções :D
|
||||
|
||||
[](https://vercel.com/import/project?template=https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
<details>
|
||||
<summary>Guia de configuração do Vercel</summary>
|
||||
|
||||
1. Acesse [vercel.com](https://vercel.com/)
|
||||
1. Clique em `Login`
|
||||

|
||||
1. Acesse com o GitHub clicando em `Continue with GitHub`
|
||||

|
||||
1. Entre no GitHub e permita acesso a todos os repositórios, se solicitado
|
||||
1. Faça Fork neste repositório
|
||||
1. Volte ao seu [painel principal do Vercel](https://vercel.com/dashboard)
|
||||
1. Selecione `Import Project`
|
||||

|
||||
1. Selecione `Import Git Repository`
|
||||

|
||||
1. Selecione a raiz e mantenha tudo como está, basta adicionar sua variável de ambiente chamada PAT_1 (que será exibida), que conterá um token de acesso pessoal (PAT), que você pode criar facilmente [aqui](https://github.com/settings/tokens/new) (deixe tudo como está, apenas dê um nome, que pode ser o que você quiser)
|
||||

|
||||
1. Clique em `deploy` e já estará tudo pronto. Veja seus domínios para usar a API!
|
||||
|
||||
</details>
|
||||
|
||||
## :sparkling_heart: Apoie o projeto
|
||||
|
||||
Disponibilizo como código aberto quase tudo o que posso e tento responder a todos que precisam de ajuda para utilizar esses projetos. Claro,
|
||||
isso demanda tempo. Utilize este serviço gratuitamente.
|
||||
|
||||
No entanto, se você utilizar este projeto e estiver satisfeito com ele, ou apenas quiser me encorajar a continuar criando coisas, existem algumas formas fazê-lo:
|
||||
|
||||
- Dando os devidos créditos ao usar github-readme-stats no seu README.me, adicionando uma referência ao projeto :D
|
||||
- Dando uma estrela (Starring) e compartilhando o projeto 🚀
|
||||
- [](https://www.paypal.me/anuraghazra) - Você pode fazer doações únicas via PayPal. Provavelmente vou comprar um ~~café~~ chá. :tea:
|
||||
|
||||
Obrigado! :heart:
|
||||
|
||||
---
|
||||
|
||||
[](https://vercel.com?utm_source=github_readme_stats_team&utm_campaign=oss)
|
||||
|
||||
Contribuições são bem-vindas! <3
|
||||
|
||||
Feito com :heart: e JavaScript.
|
||||
@@ -0,0 +1,417 @@
|
||||
<p align="center">
|
||||
<img width="100px" src="https://res.cloudinary.com/anuraghazra/image/upload/v1594908242/logo_ccswme.svg" align="center" alt="GitHub Readme Stats" />
|
||||
<h2 align="center">GitHub Readme Stats</h2>
|
||||
<p align="center">Readme'lerinizde dinamik olarak oluşturulmuş GitHub istatistikleri alın!</p>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/actions">
|
||||
<img alt="Tests Passing" src="https://github.com/anuraghazra/github-readme-stats/workflows/Test/badge.svg" />
|
||||
</a>
|
||||
<a href="https://codecov.io/gh/anuraghazra/github-readme-stats">
|
||||
<img src="https://codecov.io/gh/anuraghazra/github-readme-stats/branch/master/graph/badge.svg" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues">
|
||||
<img alt="Issues" src="https://img.shields.io/github/issues/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/pulls">
|
||||
<img alt="GitHub pull requests" src="https://img.shields.io/github/issues-pr/anuraghazra/github-readme-stats?color=0088ff" />
|
||||
</a>
|
||||
<br />
|
||||
<br />
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=1227">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-VSCode%20Power%20User%20%E2%86%92-gray.svg?colorA=655BE1&colorB=4F44D6&style=for-the-badge"/>
|
||||
</a>
|
||||
<a href="https://a.paddle.com/v2/click/16413/119403?link=2345">
|
||||
<img src="https://img.shields.io/badge/Supported%20by-Node%20Cli.com%20%E2%86%92-gray.svg?colorA=61c265&colorB=4CAF50&style=for-the-badge"/>
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="#demo">Demo</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Hata İlet</a>
|
||||
·
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats/issues/new/choose">Özellik Talep Et</a>
|
||||
</p>
|
||||
<p align="center">
|
||||
<a href="/docs/readme_fr.md">Français </a>
|
||||
·
|
||||
<a href="/docs/readme_cn.md">简体中文</a>
|
||||
·
|
||||
<a href="/docs/readme_es.md">Español</a>
|
||||
·
|
||||
<a href="/docs/readme_de.md">Deutsch</a>
|
||||
·
|
||||
<a href="/docs/readme_ja.md">日本語</a>
|
||||
·
|
||||
<a href="/docs/readme_pt-BR.md">Português Brasileiro</a>
|
||||
·
|
||||
<a href="/docs/readme_it.md">Italiano</a>
|
||||
·
|
||||
<a href="/docs/readme_kr.md">한국어</a>
|
||||
.
|
||||
<a href="/docs/readme_nl.md">Nederlands</a>
|
||||
.
|
||||
<a href="/docs/readme_np.md">नेपाली</a>
|
||||
.
|
||||
<a href="/docs/readme_tr.md">Türkçe</a>
|
||||
</p>
|
||||
</p>
|
||||
<p align="center">Projeyi sevdiniz mi? Daha da gelişmesi için lütfen <a href="https://www.paypal.me/anuraghazra">bağış</a> yapın!
|
||||
|
||||
# Features
|
||||
|
||||
- [GitHub İstatistikler Kartı](#github-istatistikler-kartı)
|
||||
- [GitHub Ekstra Pinler](#github-ekstra-pinler)
|
||||
- [En Çok Kullanılan Diller](#en-çok-kullanılan-diller)
|
||||
- [Wakatime Haftalık İstatistikler](#wakatime-haftalık-istatistikler)
|
||||
- [Temalar](#temalar)
|
||||
- [Özelleştirmeler](#özelleştirmeler)
|
||||
- [Yayınlayın](#yayınlayın)
|
||||
|
||||
# GitHub İstatistikler Kartı
|
||||
|
||||
Alt kısımdaki kodu Kopyalayın ve yapıştırın. İşte bu kadar. Çok basit!
|
||||
|
||||
`?username=` değerini kendi Github kullanıcı adınız ile değiştirin.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
_Not: Şu sıralamalar mevcut: S+ (en üst 1%), S (en üst 25%), A++ (en üst 45%), A+ (en üst 60%), and B+ (herkes).
|
||||
Buradaki değerler [cumulative distribution function](https://en.wikipedia.org/wiki/Cumulative_distribution_function) ile hesaplanırken; commitler, katkılar, hatalar, yıldızlar, çekme istekleri, takipçiler ve sahip olunan depolar (repository) göz önünde bulundurulamaktadır.
|
||||
Uygulamanın yapısı [src/calculateRank.js](./src/calculateRank.js)'te daha detaylı incelenebilir._
|
||||
|
||||
### Bazı İstatitistikleri Gizleme
|
||||
|
||||
Bazı belirli istatistikleri gizlemek için `?hide=` paremetresi içerisinde virgülle ayırarak gönderebilirsiniz.
|
||||
|
||||
> Örnek: `&hide=stars,commits,prs,issues,contribs`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Özel Katkı Sayısını Toplam Commit Sayısına Ekleme
|
||||
|
||||
Özel (private) olarak geliştirdiğiniz depolardaki commit sayınızı toplam commit sayınız içerisinde göstermek istiyorsanız `?count_private=true` parametresini gönderebilirsiniz.
|
||||
|
||||
_Not: Eğer projeyi kendiniz yayınlayıp kullanacaksanız, özel depolardaki geliştirmelerinizin sayısını varsayılan olarak toplam commit sayınız içerisinde gösterilecektir. Aksi taktirde özel depolardaki katkı sayınızı paylaşmayı ayrıca seçmeniz gerekecektir.
|
||||
|
||||
> Örnek: `&count_private=true`
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### İkonları Göstermek
|
||||
|
||||
Eğer ikonları göstermek istiyorsanız, `show_icons=true` parametresini göndermeniz gerekmektedir. Örnek olarak:
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Temalar
|
||||
|
||||
Dahili olarak gelen temalarla, herhangi bir [manuel özelleştirme](#özelleştirmeler) yapmadan kartın görünümünü özelleştirebilirsiniz.
|
||||
|
||||
`?theme=THEME_NAME` parametresini kullanabilirsiniz:
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
#### Tüm Dahili Temalar :-
|
||||
|
||||
dark, radical, merko, gruvbox, tokyonight, onedark, cobalt, synthwave, highcontrast, dracula
|
||||
|
||||
<img src="https://res.cloudinary.com/anuraghazra/image/upload/v1595174536/grs-themes_l4ynja.png" alt="GitHub Readme Stat Temaları" width="600px"/>
|
||||
|
||||
Önizleme yapmak için şuralara göz atabilirsiniz: [tüm dahili temalar](./themes/README.md) veya [tema ayar dosyası](./themes/index.js) & **ayrıca siz de yeni bir tema oluşturarak katkı sağlayabilirsiniz** elbette isterseniz :D
|
||||
|
||||
### Özelleştirmeler
|
||||
|
||||
|
||||
`Stats Card` ya da `Repo Card` görüntünüzü istediğiniz gibi şu parametreler ile değiştirebilirsiniz:
|
||||
|
||||
#### Yaygın Seçenekler:
|
||||
|
||||
- `title_color` - Kart başlığı rengi _(hex color / hex rengi)_
|
||||
- `text_color` - İçerik rengi _(hex color / hex rengi)_
|
||||
- `icon_color` - Mümkünse ikon rengi _(hex color / hex rengi)_
|
||||
- `bg_color` - Kartın arkaplan rengi _(hex color / hex rengi)_ **ya da** gradient şeklinde _açı,başlangıç,bitiş_
|
||||
- `hide_border` - Kartın çerçevelerini gizler _(boolean)_
|
||||
- `theme` - Temanın rengi [tüm temalar](./themes/README.md)
|
||||
- `cache_seconds` - Manuel olarak cache'i belirleyebilirsiniz _(en az: 1800, en fazla: 86400)_
|
||||
- `locale` - Karttaki dili seçebilirsiniz _(örneğin; tr, cn, de, es, vb.)_
|
||||
|
||||
##### bg_color'da Gradient
|
||||
|
||||
bg_color içerisinde birden fazla rengi gradient olarak göstermek için virgülle ayırarak kullanabilirsiniz. Gradient kullanımı için örnek format:
|
||||
|
||||
```
|
||||
&bg_color=DEG,COLOR1,COLOR2,COLOR3...COLOR10
|
||||
```
|
||||
|
||||
> Cache Hakkında: Repo kartında fork ve yıldız sayısı 1.000'den küçükse varsayılan cache süresi 4 saat yani 14400 saniyedir. 1.000'den büyükse 2 saat yani 7200 saniyedir. Ayrıca, önbelleğin minimum 2 ve maksimum 24 saate sabitlendiğini unutmayın.
|
||||
|
||||
#### İstatistik Karları Exclusive Özellikler:
|
||||
|
||||
- `hide` - Spesifik özellikleri istatistiklerden gizleyebilirsiniz. _(Virgül ile ayırılmış değerlerle)_
|
||||
- `hide_title` - _(boolean)_
|
||||
- `hide_rank` - _(boolean)_ Sıralamayı gizler ve kartın genişliğini otomatik olarak tekrar düzenler
|
||||
- `show_icons` - _(boolean)_
|
||||
- `include_all_commits` - _(boolean)_ Sadece bu yılın değil tüm zamanlarda yaptığınız commit sayısını gösterir
|
||||
- `count_private` - _(boolean)_ Özel depolarda yaptığınız commitleri gösterir
|
||||
- `line_height` - _(number)_ Satır arası yüksekliği belirler
|
||||
- `custom_title` - Kart için istediğiniz bir başlığı belirler
|
||||
- `disable_animations` - _(boolean)_ Kart içerisindeki tüm animasyonları kapatır
|
||||
|
||||
#### Repo Kartları Exclusive Özellikler:
|
||||
|
||||
- `show_owner` - _(boolean)_ Reponun sahibinin ismini gösterir
|
||||
|
||||
#### Dil Kartları Exclusive Özellikler:
|
||||
|
||||
- `hide` - Belirli bir dili listede gizler _(Virgül ile ayırılmış değerlerle)_
|
||||
- `hide_title` - _(boolean)_
|
||||
- `layout` - Uygun olan iki tasarım / layout arasında değişiklik yapar `default` & `compact`
|
||||
- `card_width` - Kartın genişliğini manuel olarak belirler _(number)_
|
||||
- `langs_count` - 1-10 arasında istediğiniz kadar dil gösterebilirsiniz. Varsayılan: 5 _(number)_
|
||||
- `exclude_repo` - Belirli repoları listeden çıkartır _(Virgül ile ayırılmış değerlerle)_
|
||||
- `custom_title` - Kart için istediğiniz bir başlığı belirler
|
||||
|
||||
> :warning: **Önemli:**
|
||||
> Dİl isimleri [Percent Encoding](https://en.wikipedia.org/wiki/Percent-encoding)'te belirtildiği üzere uri-escaped olarak belirtilmelidir.
|
||||
> (ör: `c++` yerine `c%2B%2B`, `jupyter notebook` yerine `jupyter%20notebook`, vb.)
|
||||
> [urlencoder.org](https://www.urlencoder.org/) adresini kullanarak otomatik olarak değerleri bu şekle çevirebilirsiniz.
|
||||
|
||||
#### Wakatime Kart Exclusive Özellikler:
|
||||
|
||||
- `hide_title` - _(boolean)_
|
||||
- `line_height` - Satır aralığı yüksekliği _(number)_
|
||||
- `hide_progress` - Progresbarı ve yüzdeyi gizler _(boolean)_
|
||||
- `custom_title` - Kart için istediğiniz bir başlığı belirler
|
||||
- `layout` - Uygun olan iki tasarım / layout arasında değişiklik yapar `default` & `compact`
|
||||
|
||||
---
|
||||
|
||||
# GitHub Ekstra Pinler
|
||||
|
||||
Github ekstra pinler profilinize 6'dan fazla repoyu / depoyu profilinizde pinleyebilirsiniz.
|
||||
|
||||
Hey! Artık 6 pin ile kısıtlı kalmayacaksınız!
|
||||
|
||||
### Kullanım
|
||||
|
||||
Alttaki kodu kopyalayıp readme dosyanıza urlleri değiştirerek yapıştırın.
|
||||
|
||||
Endpoint: `api/pin?username=mustafacagri&repo=github-readme-stats`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Demo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
[show_owner](#özelleştirmeler) ile reponun sahibini gösterebilirsiniz.
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# En Çok Kullanılan Diller
|
||||
|
||||
En çok kullanılan diller kartı kullanıcının en çok kullandığı dilleri gösterir.
|
||||
|
||||
_NOTE: En çok kullanılan dillerde yer alan bilgiler sizin yeteneğinizi ve benzeri şeyleri göstermek. Bu, kodlarınızda en çok kullandığınız dilleri gösteren bir Github metriğidir. Ayrıca, github-readme-stats'ın yeni özelliğidir.
|
||||
|
||||
### Kullanım
|
||||
|
||||
Alttaki kodu kopyalayıp readme dosyanıza urlleri değiştirerek yapıştırın.
|
||||
|
||||
Endpoint: `api/top-langs?username=mustafacagri`
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Belirli Repoları Çıkartın
|
||||
|
||||
`?exclude_repo=repo1,repo2` parametresini kullanarak istediğiniz repoları çıkartabilirsiniz.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Belirli Dilleri Çıkartın
|
||||
|
||||
`?hide=language1,language2` parametresini kullanarak istediğiniz dilleri çıkartabilirsiniz.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Daha Fazla Dil Gösterin
|
||||
|
||||
`&langs_count=` parametresini kullanarak kartınızda gösterilen dil sayısını azaltabilir ya da artırabilirsiniz. Varsayılan değeri 5, kullanılabilir sayı aralığı ise 1-10'dur.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Kompakt Dil Kartı Düzeni
|
||||
|
||||
`&layout=compact` parametresiyle kart tasarımınızı değiştirebilirsiniz.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Demo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Kompakt Düzen / Layout
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
# Wakatime Haftalık İstatistikler
|
||||
|
||||
`?username=` değerini [Wakatime](https://wakatime.com)'daki kullanıcı adınızla değiştirin.
|
||||
|
||||
```md
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
```
|
||||
|
||||
### Demo
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Kompakt Düzen
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### Tüm Demolar
|
||||
|
||||
- Varsayılan
|
||||
|
||||

|
||||
|
||||
- Belirli istatistikler gizli
|
||||
|
||||

|
||||
|
||||
- İkonlar gösteriliyor
|
||||
|
||||

|
||||
|
||||
- Tüm commitler dahil
|
||||
|
||||

|
||||
|
||||
- Temalar
|
||||
|
||||
[default themes](#themes) adresinden istediğiniz temayı seçin.
|
||||
|
||||

|
||||
|
||||
- Gradient
|
||||
|
||||

|
||||
|
||||
- İstatistik Kartını Düzenleyin
|
||||
|
||||

|
||||
|
||||
- Kartın dilini seçin
|
||||
|
||||

|
||||
|
||||
- Repo kartı düzenleyin
|
||||
|
||||

|
||||
|
||||
- En çok kullanılan diller
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
- Wakatime kart
|
||||
|
||||
[](https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
---
|
||||
|
||||
### Hızlı İpucu (Repo Kartları Hizlayın)
|
||||
|
||||
Genellikle resimleri yan yana düzenleyemezsiniz. Bunu yapmak için şu yaklaşımı kullanabilirsiniz:
|
||||
|
||||
```html
|
||||
<a href="https://github.com/anuraghazra/github-readme-stats">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=github-readme-stats" />
|
||||
</a>
|
||||
<a href="https://github.com/anuraghazra/convoychat">
|
||||
<img align="center" src="https://github-readme-stats.vercel.app/api/pin/?username=anuraghazra&repo=convoychat" />
|
||||
</a>
|
||||
```
|
||||
|
||||
## Kendi Vercel Örneğinizde Yayınlayın
|
||||
|
||||
|
||||
#### [@codeSTACKr'ın Yayınladığı Video Eğitimine Göz Atın](https://youtu.be/n6d4KHSKqGk?t=107)
|
||||
|
||||
Github API saatte sadece 5.000 isteğe izin verdiği için `https://github-readme-stats.vercel.app/api` adresindeki API'm bu limite muhtemelen takılmış olabilir. Eğer projeyi kendi Vercel sunucunuzda yayınlarsanız, böyle bir sorun yaşamayabilirsiniz. Deploy butonuna tıkla ve deploy başlasın!
|
||||
|
||||
|
||||
NOT: [#58](https://github.com/anuraghazra/github-readme-stats/pull/58) geliştirmesi sonrasında anlamadığımız bir şekilde 5.000 istek limitine takılmıyoruz :)
|
||||
|
||||
[](https://vercel.com/import/project?template=https://github.com/anuraghazra/github-readme-stats)
|
||||
|
||||
<details>
|
||||
<summary><strong> Vercel Kurulum Rehberi 🔨 </strong></summary>
|
||||
|
||||
1. [vercel.com](https://vercel.com/) adresine gidin
|
||||
1. `Log in`'e tıklayın
|
||||

|
||||
1. `Continue with GitHub`'e basarak Github ile giriş yapın
|
||||

|
||||
1. Github'a giriş yapın ve eğer çıkarsa tüm repolara izin verin.
|
||||
1. Bu repoyu fork'layın
|
||||
1. [Vercel dashboard](https://vercel.com/dashboard)'unuza geri dönün.
|
||||
1. `Import Project`'i seçin.
|
||||

|
||||
1. `Import Git Repository`'yi seçin.
|
||||

|
||||
1. Root'u seçin ve her şeyi olduğu gibi bırakın, [burada](https://github.com/settings/tokens/new) kolayca oluşturabileceğiniz kişisel bir erişim belirteci (personal access token) (PAT) içerecek olan PAT_1 adlı ortam değişkeninizi (gösterildiği gibi) ekleyin. (istediğiniz bir isim verin, çok da mühim değil açıkçası)
|
||||

|
||||
1. Deploy'u tıklayın ve hazırsınız.
|
||||
Click deploy, and you're good to go. API'ı kullanmak için alanlarınızı (domainlerinizi) görün!
|
||||
|
||||
</details>
|
||||
|
||||
## :sparkling_heart: Projeyi Destekleyin
|
||||
|
||||
Neredeyse yapabildiğim her şeyi açık kaynak yapıyorum ve bu projeleri kullanırken yardıma ihtiyacı olan herkese cevap vermeye çalışıyorum. Açıkçası,
|
||||
bu zaman alıyor. Destekleriniz sayesinde bu hizmeti ücretsiz olarak kullanabilirsiniz.
|
||||
|
||||
Ayrıca, bu projeyi kullanıyor ve memnunsanız veya sadece bir şeyler yaratmaya devam etmem için beni teşvik etmek istiyorsanız, bunu yapmanın birkaç yolu var: -
|
||||
|
||||
- Readme'nizde github-readme-stats'ı kullanırken bu projeye uygun bir link verebilirsiniz.
|
||||
- Projeye yıldız verebilir ve paylaşabilirsiniz :rocket:
|
||||
- [](https://www.paypal.me/anuraghazra) - PayPal ile tek seferlik bağış yapabilirsiniz. Muhtemelen bir ~~kahve~~ ya da çay :tea: alacağım.
|
||||
|
||||
Teşekkürler! :heart:
|
||||
|
||||
---
|
||||
|
||||
[](https://vercel.com?utm_source=github_readme_stats_team&utm_campaign=oss)
|
||||
|
||||
|
||||
Katkılara açığız! <3
|
||||
|
||||
:heart: ve JavaScript ile hazırlandı.
|
||||
@@ -1,83 +0,0 @@
|
||||
import globals from "globals";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import js from "@eslint/js";
|
||||
import { FlatCompat } from "@eslint/eslintrc";
|
||||
import jsdoc from "eslint-plugin-jsdoc";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = path.dirname(__filename);
|
||||
const compat = new FlatCompat({
|
||||
baseDirectory: __dirname,
|
||||
recommendedConfig: js.configs.recommended,
|
||||
allConfig: js.configs.all,
|
||||
});
|
||||
|
||||
export default [
|
||||
...compat.extends("prettier"),
|
||||
{
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.node,
|
||||
...globals.browser,
|
||||
},
|
||||
|
||||
ecmaVersion: 2022,
|
||||
sourceType: "module",
|
||||
},
|
||||
plugins: {
|
||||
jsdoc,
|
||||
},
|
||||
rules: {
|
||||
"no-unexpected-multiline": "error",
|
||||
"accessor-pairs": [
|
||||
"error",
|
||||
{
|
||||
getWithoutSet: false,
|
||||
setWithoutGet: true,
|
||||
},
|
||||
],
|
||||
"block-scoped-var": "warn",
|
||||
"consistent-return": "error",
|
||||
curly: "error",
|
||||
"no-alert": "error",
|
||||
"no-caller": "error",
|
||||
"no-warning-comments": [
|
||||
"warn",
|
||||
{
|
||||
terms: ["TODO", "FIXME"],
|
||||
location: "start",
|
||||
},
|
||||
],
|
||||
"no-with": "warn",
|
||||
radix: "warn",
|
||||
"no-delete-var": "error",
|
||||
"no-undef-init": "off",
|
||||
"no-undef": "error",
|
||||
"no-undefined": "off",
|
||||
"no-unused-vars": "warn",
|
||||
"no-use-before-define": "error",
|
||||
"constructor-super": "error",
|
||||
"no-class-assign": "error",
|
||||
"no-const-assign": "error",
|
||||
"no-dupe-class-members": "error",
|
||||
"no-this-before-super": "error",
|
||||
"object-shorthand": ["warn"],
|
||||
"no-mixed-spaces-and-tabs": "warn",
|
||||
"no-multiple-empty-lines": "warn",
|
||||
"no-negated-condition": "warn",
|
||||
"no-unneeded-ternary": "warn",
|
||||
"keyword-spacing": [
|
||||
"error",
|
||||
{
|
||||
before: true,
|
||||
after: true,
|
||||
},
|
||||
],
|
||||
"jsdoc/require-returns": "warn",
|
||||
"jsdoc/require-returns-description": "warn",
|
||||
"jsdoc/require-param-description": "warn",
|
||||
"jsdoc/require-jsdoc": "warn",
|
||||
},
|
||||
},
|
||||
];
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
import "dotenv/config";
|
||||
import statsCard from "./api/index.js";
|
||||
import repoCard from "./api/pin.js";
|
||||
import langCard from "./api/top-langs.js";
|
||||
import wakatimeCard from "./api/wakatime.js";
|
||||
import gistCard from "./api/gist.js";
|
||||
import express from "express";
|
||||
|
||||
const app = express();
|
||||
const router = express.Router();
|
||||
|
||||
router.get("/", statsCard);
|
||||
router.get("/pin", repoCard);
|
||||
router.get("/top-langs", langCard);
|
||||
router.get("/wakatime", wakatimeCard);
|
||||
router.get("/gist", gistCard);
|
||||
|
||||
app.use("/api", router);
|
||||
|
||||
const port = process.env.PORT || process.env.port || 9000;
|
||||
const server = app.listen(port, "0.0.0.0", () => {
|
||||
console.log(`Server running on port ${port}`);
|
||||
});
|
||||
|
||||
/* stop gracefully when requested */
|
||||
process.on("SIGTERM", () => {
|
||||
console.log("stopping, received SIGTERM signal");
|
||||
server.close(() => {
|
||||
process.exit();
|
||||
});
|
||||
});
|
||||
@@ -1,13 +0,0 @@
|
||||
export default {
|
||||
clearMocks: true,
|
||||
transform: {},
|
||||
testEnvironment: "jsdom",
|
||||
coverageProvider: "v8",
|
||||
testPathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/tests/e2e/"],
|
||||
modulePathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/tests/e2e/"],
|
||||
coveragePathIgnorePatterns: [
|
||||
"<rootDir>/node_modules/",
|
||||
"<rootDir>/tests/e2e/",
|
||||
],
|
||||
testRegex: "(\\.bench)\\.(ts|tsx|js)$",
|
||||
};
|
||||
@@ -1,8 +1,8 @@
|
||||
export default {
|
||||
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
clearMocks: true,
|
||||
transform: {},
|
||||
testEnvironment: "jsdom",
|
||||
coverageProvider: "v8",
|
||||
testPathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/tests/e2e/"],
|
||||
modulePathIgnorePatterns: ["<rootDir>/node_modules/", "<rootDir>/tests/e2e/"],
|
||||
coveragePathIgnorePatterns: [
|
||||
@@ -0,0 +1,7 @@
|
||||
/** @type {import('ts-jest').JestConfigWithTsJest} */
|
||||
module.exports = {
|
||||
preset: 'ts-jest',
|
||||
testEnvironment: 'node',
|
||||
clearMocks: true,
|
||||
testMatch: ["<rootDir>/tests/e2e/**/*.test.ts"],
|
||||
};
|
||||
@@ -1,7 +0,0 @@
|
||||
export default {
|
||||
clearMocks: true,
|
||||
transform: {},
|
||||
testEnvironment: "node",
|
||||
coverageProvider: "v8",
|
||||
testMatch: ["<rootDir>/tests/e2e/**/*.test.js"],
|
||||
};
|
||||
Generated
+7760
-7599
File diff suppressed because it is too large
Load Diff
+37
-53
@@ -1,76 +1,60 @@
|
||||
{
|
||||
"name": "github-readme-stats",
|
||||
"version": "1.0.0",
|
||||
"description": "Dynamically generate stats for your GitHub readme",
|
||||
"keywords": [
|
||||
"github-readme-stats",
|
||||
"readme-stats",
|
||||
"cards",
|
||||
"card-generator"
|
||||
],
|
||||
"main": "src/index.js",
|
||||
"description": "Dynamically generate stats for your github readmes",
|
||||
"main": "index.js",
|
||||
"type": "module",
|
||||
"homepage": "https://github.com/anuraghazra/github-readme-stats",
|
||||
"bugs": {
|
||||
"url": "https://github.com/anuraghazra/github-readme-stats/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/anuraghazra/github-readme-stats.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node --experimental-vm-modules node_modules/jest/bin/jest.js --coverage",
|
||||
"test:watch": "node --experimental-vm-modules node_modules/jest/bin/jest.js --watch",
|
||||
"test:update:snapshot": "node --experimental-vm-modules node_modules/jest/bin/jest.js -u",
|
||||
"test:e2e": "node --experimental-vm-modules node_modules/jest/bin/jest.js --config jest.e2e.config.js",
|
||||
"test": "jest --coverage",
|
||||
"test:watch": "jest --watch",
|
||||
"test:update:snapshot": "jest -u",
|
||||
"test:e2e": "jest --config jest.e2e.config.cjs",
|
||||
"theme-readme-gen": "node scripts/generate-theme-doc",
|
||||
"preview-theme": "node scripts/preview-theme",
|
||||
"close-stale-theme-prs": "node scripts/close-stale-theme-prs",
|
||||
"generate-langs-json": "node scripts/generate-langs-json",
|
||||
"format": "prettier --write .",
|
||||
"format:check": "prettier --check .",
|
||||
"prepare": "husky",
|
||||
"lint": "npx eslint --max-warnings 0 \"./src/**/*.js\" \"./scripts/**/*.js\" \"./tests/**/*.js\" \"./api/**/*.js\" \"./themes/**/*.js\"",
|
||||
"bench": "node --experimental-vm-modules node_modules/jest/bin/jest.js --config jest.bench.config.js"
|
||||
"format": "./node_modules/.bin/prettier --write .",
|
||||
"format:check": "./node_modules/.bin/prettier --check .",
|
||||
"start": "vercel dev"
|
||||
},
|
||||
"author": "Anurag Hazra",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@actions/core": "^2.0.1",
|
||||
"@actions/github": "^6.0.1",
|
||||
"@eslint/eslintrc": "^3.3.3",
|
||||
"@eslint/js": "^9.39.2",
|
||||
"@testing-library/dom": "^10.4.1",
|
||||
"@testing-library/jest-dom": "^6.9.1",
|
||||
"@actions/core": "^1.9.1",
|
||||
"@actions/github": "^4.0.0",
|
||||
"@babel/core": "^7.19.3",
|
||||
"@babel/preset-env": "^7.19.3",
|
||||
"@babel/preset-typescript": "^7.18.6",
|
||||
"@testing-library/dom": "^8.17.1",
|
||||
"@testing-library/jest-dom": "^5.16.5",
|
||||
"@types/jest": "^29.1.1",
|
||||
"@uppercod/css-to-object": "^1.1.1",
|
||||
"axios-mock-adapter": "^2.1.0",
|
||||
"@vercel/node": "^2.5.21",
|
||||
"axios-mock-adapter": "^1.18.1",
|
||||
"babel-jest": "^29.1.2",
|
||||
"color-contrast-checker": "^2.1.0",
|
||||
"eslint": "^9.39.2",
|
||||
"eslint-config-prettier": "^10.1.8",
|
||||
"eslint-plugin-jsdoc": "^61.5.0",
|
||||
"express": "^5.2.1",
|
||||
"globals": "^16.5.0",
|
||||
"hjson": "^3.2.2",
|
||||
"husky": "^9.1.7",
|
||||
"jest": "^30.2.0",
|
||||
"jest-environment-jsdom": "^30.2.0",
|
||||
"js-yaml": "^4.1.1",
|
||||
"lint-staged": "^16.2.7",
|
||||
"husky": "^4.2.5",
|
||||
"jest": "^29.1.2",
|
||||
"jest-environment-jsdom": "^29.0.3",
|
||||
"js-yaml": "^4.1.0",
|
||||
"lodash.snakecase": "^4.1.1",
|
||||
"parse-diff": "^0.11.1",
|
||||
"prettier": "^3.7.3"
|
||||
"parse-diff": "^0.7.0",
|
||||
"prettier": "^2.1.2",
|
||||
"ts-jest": "^29.0.3",
|
||||
"typescript": "^4.8.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^1.13.1",
|
||||
"dotenv": "^17.2.3",
|
||||
"emoji-name-map": "^2.0.3",
|
||||
"axios": "^0.24.0",
|
||||
"dotenv": "^8.2.0",
|
||||
"emoji-name-map": "^1.2.8",
|
||||
"github-username-regex": "^1.0.0",
|
||||
"word-wrap": "^1.2.5"
|
||||
"upgrade": "^1.1.0",
|
||||
"word-wrap": "^1.2.3"
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{js,css,md}": "prettier --write"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22"
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "npm test"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,30 +9,19 @@ import github from "@actions/github";
|
||||
import { RequestError } from "@octokit/request-error";
|
||||
import { getGithubToken, getRepoInfo } from "./helpers.js";
|
||||
|
||||
// Script parameters
|
||||
const CLOSING_COMMENT = `
|
||||
\rThis theme PR has been automatically closed due to inactivity. Please reopen it if you want to continue working on it.\
|
||||
\rThis PR has been automatically closed due to inactivity. Please feel free to reopen it if you need to continue working on it.\
|
||||
\rThank you for your contributions.
|
||||
`;
|
||||
const REVIEWER = "github-actions[bot]";
|
||||
|
||||
/**
|
||||
* Retrieve the review user.
|
||||
* @returns {string} review user.
|
||||
*/
|
||||
const getReviewer = () => {
|
||||
return process.env.REVIEWER ? process.env.REVIEWER : REVIEWER;
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetch open PRs from a given repository.
|
||||
*
|
||||
* @param {module:@actions/github.Octokit} octokit The octokit client.
|
||||
* @param {string} user The user name of the repository owner.
|
||||
* @param {string} repo The name of the repository.
|
||||
* @param {string} reviewer The reviewer to filter by.
|
||||
* @returns {Promise<Object[]>} The open PRs.
|
||||
* @param user The user name of the repository owner.
|
||||
* @param repo The name of the repository.
|
||||
* @returns The open PRs.
|
||||
*/
|
||||
export const fetchOpenPRs = async (octokit, user, repo, reviewer) => {
|
||||
export const fetchOpenPRs = async (octokit, user, repo) => {
|
||||
const openPRs = [];
|
||||
let hasNextPage = true;
|
||||
let endCursor;
|
||||
@@ -60,9 +49,9 @@ export const fetchOpenPRs = async (octokit, user, repo, reviewer) => {
|
||||
name
|
||||
}
|
||||
}
|
||||
reviews(first: 100, states: CHANGES_REQUESTED, author: "${reviewer}") {
|
||||
reviews(first: 1, states: CHANGES_REQUESTED, author: "github-actions[bot]") {
|
||||
nodes {
|
||||
submittedAt
|
||||
updatedAt
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,10 +79,8 @@ export const fetchOpenPRs = async (octokit, user, repo, reviewer) => {
|
||||
|
||||
/**
|
||||
* Retrieve pull requests that have a given label.
|
||||
*
|
||||
* @param {Object[]} pulls The pull requests to check.
|
||||
* @param {string} label The label to check for.
|
||||
* @returns {Object[]} The pull requests that have the given label.
|
||||
* @param pull The pull requests to check.
|
||||
* @param label The label to check for.
|
||||
*/
|
||||
export const pullsWithLabel = (pulls, label) => {
|
||||
return pulls.filter((pr) => {
|
||||
@@ -103,23 +90,20 @@ export const pullsWithLabel = (pulls, label) => {
|
||||
|
||||
/**
|
||||
* Check if PR is stale. Meaning that it hasn't been updated in a given time.
|
||||
*
|
||||
* @param {Object} pullRequest request object.
|
||||
* @param {number} staleDays number of days.
|
||||
* @returns {boolean} indicating if PR is stale.
|
||||
* @param {number} days number of days.
|
||||
* @returns Boolean indicating if PR is stale.
|
||||
*/
|
||||
const isStale = (pullRequest, staleDays) => {
|
||||
const lastCommitDate = new Date(
|
||||
pullRequest.commits.nodes[0].commit.pushedDate,
|
||||
);
|
||||
if (pullRequest.reviews.nodes[0]) {
|
||||
const lastReviewDate = new Date(
|
||||
pullRequest.reviews.nodes.sort((a, b) => (a < b ? 1 : -1))[0].submittedAt,
|
||||
);
|
||||
const lastReviewDate = new Date(pullRequest.reviews.nodes[0].updatedAt);
|
||||
const lastUpdateDate =
|
||||
lastCommitDate >= lastReviewDate ? lastCommitDate : lastReviewDate;
|
||||
const now = new Date();
|
||||
return (now - lastUpdateDate) / (1000 * 60 * 60 * 24) >= staleDays;
|
||||
return now - lastUpdateDate > 1000 * 60 * 60 * 24 * staleDays;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
@@ -127,22 +111,19 @@ const isStale = (pullRequest, staleDays) => {
|
||||
|
||||
/**
|
||||
* Main function.
|
||||
*
|
||||
* @returns {Promise<void>} A promise.
|
||||
*/
|
||||
const run = async () => {
|
||||
try {
|
||||
// Create octokit client.
|
||||
const dryRun = process.env.DRY_RUN === "true" || false;
|
||||
const staleDays = process.env.STALE_DAYS || 20;
|
||||
const staleDays = process.env.STALE_DAYS || 15;
|
||||
debug("Creating octokit client...");
|
||||
const octokit = github.getOctokit(getGithubToken());
|
||||
const { owner, repo } = getRepoInfo(github.context);
|
||||
const reviewer = getReviewer();
|
||||
|
||||
// Retrieve all theme pull requests.
|
||||
debug("Retrieving all theme pull requests...");
|
||||
const prs = await fetchOpenPRs(octokit, owner, repo, reviewer);
|
||||
const prs = await fetchOpenPRs(octokit, owner, repo);
|
||||
const themePRs = pullsWithLabel(prs, "themes");
|
||||
const invalidThemePRs = pullsWithLabel(themePRs, "invalid");
|
||||
debug("Retrieving stale theme PRs...");
|
||||
@@ -155,21 +136,21 @@ const run = async () => {
|
||||
// Loop through all stale invalid theme pull requests and close them.
|
||||
for (const prNumber of staleThemePRsNumbers) {
|
||||
debug(`Closing #${prNumber} because it is stale...`);
|
||||
if (dryRun) {
|
||||
debug("Dry run enabled, skipping...");
|
||||
} else {
|
||||
await octokit.rest.issues.createComment({
|
||||
if (!dryRun) {
|
||||
await octokit.issues.createComment({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: prNumber,
|
||||
body: CLOSING_COMMENT,
|
||||
});
|
||||
await octokit.rest.pulls.update({
|
||||
await octokit.pulls.update({
|
||||
owner,
|
||||
repo,
|
||||
pull_number: prNumber,
|
||||
state: "closed",
|
||||
});
|
||||
} else {
|
||||
debug("Dry run enabled, skipping...");
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
@@ -14,7 +14,7 @@ const THEME_TEMPLATE = `## Available Themes
|
||||
|
||||
With inbuilt themes, you can customize the look of the card without doing any manual customization.
|
||||
|
||||
Use \`?theme=THEME_NAME\` parameter like so:
|
||||
Use \`?theme=THEME_NAME\` parameter like so :-
|
||||
|
||||
\`\`\`md
|
||||

|
||||
@@ -22,7 +22,7 @@ Use \`?theme=THEME_NAME\` parameter like so:
|
||||
|
||||
## Stats
|
||||
|
||||
> These themes work with all five of our cards: Stats Card, Repo Card, Gist Card, Top Languages Card, and WakaTime Card.
|
||||
> These themes work both for the Stats Card and Repo Card.
|
||||
|
||||
| | | |
|
||||
| :--: | :--: | :--: |
|
||||
@@ -30,7 +30,7 @@ ${STAT_CARD_TABLE_FLAG}
|
||||
|
||||
## Repo Card
|
||||
|
||||
> These themes work with all five of our cards: Stats Card, Repo Card, Gist Card, Top Languages Card, and WakaTime Card.
|
||||
> These themes work both for the Stats Card and Repo Card.
|
||||
|
||||
| | | |
|
||||
| :--: | :--: | :--: |
|
||||
@@ -39,6 +39,11 @@ ${REPO_CARD_TABLE_FLAG}
|
||||
${STAT_CARD_LINKS_FLAG}
|
||||
|
||||
${REPO_CARD_LINKS_FLAG}
|
||||
|
||||
|
||||
[add-theme]: https://github.com/anuraghazra/github-readme-stats/edit/master/themes/index.js
|
||||
|
||||
Want to add a new theme? Consider reading the [contribution guidelines](../CONTRIBUTING.md#themes-contribution) :D
|
||||
`;
|
||||
|
||||
const createRepoMdLink = (theme) => {
|
||||
@@ -55,16 +60,13 @@ const generateLinks = (fn) => {
|
||||
};
|
||||
|
||||
const createTableItem = ({ link, label, isRepoCard }) => {
|
||||
if (!link || !label) {
|
||||
return "";
|
||||
}
|
||||
if (!link || !label) return "";
|
||||
return `\`${label}\` ![${link}][${link}${isRepoCard ? "_repo" : ""}]`;
|
||||
};
|
||||
|
||||
const generateTable = ({ isRepoCard }) => {
|
||||
const rows = [];
|
||||
const themesFiltered = Object.keys(themes).filter(
|
||||
(name) => name !== (isRepoCard ? "default" : "default_repocard"),
|
||||
(name) => name !== (!isRepoCard ? "default_repocard" : "default"),
|
||||
);
|
||||
|
||||
for (let i = 0; i < themesFiltered.length; i += 3) {
|
||||
@@ -76,7 +78,15 @@ const generateTable = ({ isRepoCard }) => {
|
||||
let tableItem2 = createTableItem({ link: two, label: two, isRepoCard });
|
||||
let tableItem3 = createTableItem({ link: three, label: three, isRepoCard });
|
||||
|
||||
if (three === undefined) {
|
||||
tableItem3 = `[Add your theme][add-theme]`;
|
||||
}
|
||||
rows.push(`| ${tableItem1} | ${tableItem2} | ${tableItem3} |`);
|
||||
|
||||
// if it's the last row & the row has no empty space push a new row
|
||||
if (three && i + 3 === themesFiltered.length) {
|
||||
rows.push(`| [Add your theme][add-theme] | | |`);
|
||||
}
|
||||
}
|
||||
|
||||
return rows.join("\n");
|
||||
|
||||
+3
-5
@@ -4,13 +4,14 @@
|
||||
|
||||
import { getInput } from "@actions/core";
|
||||
|
||||
// Script variables.
|
||||
const OWNER = "anuraghazra";
|
||||
const REPO = "github-readme-stats";
|
||||
|
||||
/**
|
||||
* Retrieve information about the repository that ran the action.
|
||||
*
|
||||
* @param {Object} ctx Action context.
|
||||
* @param {Object} context Action context.
|
||||
* @returns {Object} Repository information.
|
||||
*/
|
||||
export const getRepoInfo = (ctx) => {
|
||||
@@ -20,9 +21,6 @@ export const getRepoInfo = (ctx) => {
|
||||
repo: ctx.repo.repo,
|
||||
};
|
||||
} catch (error) {
|
||||
// Resolve eslint no-unused-vars
|
||||
error;
|
||||
|
||||
return {
|
||||
owner: OWNER,
|
||||
repo: REPO,
|
||||
@@ -33,7 +31,7 @@ export const getRepoInfo = (ctx) => {
|
||||
/**
|
||||
* Retrieve github token and throw error if it is not found.
|
||||
*
|
||||
* @returns {string} GitHub token.
|
||||
* @returns {string} Github token.
|
||||
*/
|
||||
export const getGithubToken = () => {
|
||||
const token = getInput("github_token") || process.env.GITHUB_TOKEN;
|
||||
|
||||
+78
-200
@@ -12,10 +12,11 @@ import Hjson from "hjson";
|
||||
import snakeCase from "lodash.snakecase";
|
||||
import parse from "parse-diff";
|
||||
import { inspect } from "util";
|
||||
import { isValidHexColor, isValidGradient } from "../src/common/color.js";
|
||||
import { isValidHexColor } from "../src/common/utils.js";
|
||||
import { themes } from "../themes/index.js";
|
||||
import { getGithubToken, getRepoInfo } from "./helpers.js";
|
||||
|
||||
// Script variables.
|
||||
const COMMENTER = "github-actions[bot]";
|
||||
|
||||
const COMMENT_TITLE = "Automated Theme Preview";
|
||||
@@ -23,54 +24,26 @@ const THEME_PR_FAIL_TEXT = ":x: Theme PR does not adhere to our guidelines.";
|
||||
const THEME_PR_SUCCESS_TEXT =
|
||||
":heavy_check_mark: Theme PR does adhere to our guidelines.";
|
||||
const FAIL_TEXT = `
|
||||
\rUnfortunately, your theme PR contains an error or does not adhere to our [theme guidelines](https://github.com/anuraghazra/github-readme-stats/blob/master/CONTRIBUTING.md#themes-contribution). Please fix the issues below, and we will review your\
|
||||
\r PR again. This pull request will **automatically close in 20 days** if no changes are made. After this time, you must re-open the PR for it to be reviewed.
|
||||
\rUnfortunately, your theme PR does not adhere to our [theme guidelines](https://github.com/anuraghazra/github-readme-stats/blob/master/CONTRIBUTING.md#themes-contribution). Please fix the issues below, and we will review your\
|
||||
\r PR again. This pull request will **automatically close in 15 days** if no changes are made. After this time, you must re-open the PR for it to be reviewed.
|
||||
`;
|
||||
const THEME_CONTRIB_GUIDELINES = `
|
||||
const THEME_CONTRIB_GUIDELINESS = `
|
||||
\rHi, thanks for the theme contribution. Please read our theme [contribution guidelines](https://github.com/anuraghazra/github-readme-stats/blob/master/CONTRIBUTING.md#themes-contribution).
|
||||
\rWe are currently only accepting color combinations from any VSCode theme or themes with good colour combinations to minimize bloating the themes collection.
|
||||
|
||||
\r> [!WARNING]\
|
||||
\r> Keep in mind that we already have a vast collection of different themes. To keep their number manageable, we began to add only themes supported by the community. Your pull request with theme addition will be merged once we get enough positive feedback from the community in the form of thumbs up :+1: emojis (see [#1935](https://github.com/anuraghazra/github-readme-stats/issues/1935#top-themes-prs)). We expect to see at least 10-15 thumbs up before making a decision to merge your pull request into the master branch. Remember that you can also support themes of other contributors that you liked to speed up their merge.
|
||||
|
||||
\r> [!WARNING]\
|
||||
\r> Please do not submit a pull request with a batch of themes, since it will be hard to judge how the community will react to each of them. We will only merge one theme per pull request. If you have several themes, please submit a separate pull request for each of them. Situations when you have several versions of the same theme (e.g. light and dark) are an exception to this rule.
|
||||
|
||||
\r> [!NOTE]\
|
||||
\r> Also, note that if this theme is exclusively for your personal use, then instead of adding it to our theme collection, you can use card [customization options](https://github.com/anuraghazra/github-readme-stats#customization).
|
||||
`;
|
||||
const COLOR_PROPS = {
|
||||
title_color: 6,
|
||||
icon_color: 6,
|
||||
text_color: 6,
|
||||
bg_color: 23,
|
||||
bg_color: 8,
|
||||
border_color: 6,
|
||||
};
|
||||
const ACCEPTED_COLOR_PROPS = Object.keys(COLOR_PROPS);
|
||||
const REQUIRED_COLOR_PROPS = ACCEPTED_COLOR_PROPS.slice(0, 4);
|
||||
const INVALID_REVIEW_COMMENT = (commentUrl) =>
|
||||
`Some themes are invalid. See the [Automated Theme Preview](${commentUrl}) comment above for more information.`;
|
||||
var OCTOKIT;
|
||||
var OWNER;
|
||||
var REPO;
|
||||
var PULL_REQUEST_ID;
|
||||
|
||||
/**
|
||||
* Incorrect JSON format error.
|
||||
* @extends Error
|
||||
* @param {string} message Error message.
|
||||
* @returns {Error} IncorrectJsonFormatError.
|
||||
*/
|
||||
class IncorrectJsonFormatError extends Error {
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param {string} message Error message.
|
||||
*/
|
||||
constructor(message) {
|
||||
super(message);
|
||||
this.name = "IncorrectJsonFormatError";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve PR number from the event payload.
|
||||
@@ -78,9 +51,7 @@ class IncorrectJsonFormatError extends Error {
|
||||
* @returns {number} PR number.
|
||||
*/
|
||||
const getPrNumber = () => {
|
||||
if (process.env.MOCK_PR_NUMBER) {
|
||||
return process.env.MOCK_PR_NUMBER; // For testing purposes.
|
||||
}
|
||||
if (process.env.MOCK_PR_NUMBER) return process.env.MOCK_PR_NUMBER; // For testing purposes.
|
||||
|
||||
const pullRequest = github.context.payload.pull_request;
|
||||
if (!pullRequest) {
|
||||
@@ -120,10 +91,9 @@ const isPreviewComment = (inputs, comment) => {
|
||||
*
|
||||
* @param {Object} octokit Octokit instance.
|
||||
* @param {number} issueNumber Issue number.
|
||||
* @param {string} owner Owner of the repository.
|
||||
* @param {string} repo Repository name.
|
||||
* @param {string} commenter Comment author.
|
||||
* @returns {Object | undefined} The GitHub comment object.
|
||||
* @param {string} owner Owner of the repository.
|
||||
* @returns {Object} The Github comment object.
|
||||
*/
|
||||
const findComment = async (octokit, issueNumber, owner, repo, commenter) => {
|
||||
const parameters = {
|
||||
@@ -151,44 +121,21 @@ const findComment = async (octokit, issueNumber, owner, repo, commenter) => {
|
||||
debug(`No theme preview comment found.`);
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create or update the preview comment.
|
||||
*
|
||||
* @param {Object} octokit Octokit instance.
|
||||
* @param {number} issueNumber Issue number.
|
||||
* @param {Object} repo Repository name.
|
||||
* @param {Object} owner Owner of the repository.
|
||||
* @param {number} commentId Comment ID.
|
||||
* @param {string} body Comment body.
|
||||
* @returns {string} The comment URL.
|
||||
* @param {Object} props Comment properties.
|
||||
* @return {string} The comment URL.
|
||||
*/
|
||||
const upsertComment = async (
|
||||
octokit,
|
||||
issueNumber,
|
||||
repo,
|
||||
owner,
|
||||
commentId,
|
||||
body,
|
||||
) => {
|
||||
const upsertComment = async (octokit, props) => {
|
||||
let resp;
|
||||
if (commentId === undefined) {
|
||||
resp = await octokit.rest.issues.createComment({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: issueNumber,
|
||||
body,
|
||||
});
|
||||
if (props.comment_id !== undefined) {
|
||||
resp = await octokit.issues.updateComment(props);
|
||||
} else {
|
||||
resp = await octokit.rest.issues.updateComment({
|
||||
owner,
|
||||
repo,
|
||||
comment_id: commentId,
|
||||
body,
|
||||
});
|
||||
resp = await octokit.issues.createComment(props);
|
||||
}
|
||||
return resp.data.html_url;
|
||||
};
|
||||
@@ -202,7 +149,6 @@ const upsertComment = async (
|
||||
* @param {string} repo Repository name.
|
||||
* @param {string} reviewState The review state. Options are (APPROVE, REQUEST_CHANGES, COMMENT, PENDING).
|
||||
* @param {string} reason The reason for the review.
|
||||
* @returns {Promise<void>} Promise.
|
||||
*/
|
||||
const addReview = async (
|
||||
octokit,
|
||||
@@ -212,7 +158,7 @@ const addReview = async (
|
||||
reviewState,
|
||||
reason,
|
||||
) => {
|
||||
await octokit.rest.pulls.createReview({
|
||||
await octokit.pulls.createReview({
|
||||
owner,
|
||||
repo,
|
||||
pull_number: prNumber,
|
||||
@@ -229,10 +175,9 @@ const addReview = async (
|
||||
* @param {string} owner Repository owner.
|
||||
* @param {string} repo Repository name.
|
||||
* @param {string[]} labels Labels to add.
|
||||
* @returns {Promise<void>} Promise.
|
||||
*/
|
||||
const addLabel = async (octokit, prNumber, owner, repo, labels) => {
|
||||
await octokit.rest.issues.addLabels({
|
||||
await octokit.issues.addLabels({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: prNumber,
|
||||
@@ -248,10 +193,9 @@ const addLabel = async (octokit, prNumber, owner, repo, labels) => {
|
||||
* @param {string} owner Repository owner.
|
||||
* @param {string} repo Repository name.
|
||||
* @param {string} label Label to add or remove.
|
||||
* @returns {Promise<void>} Promise.
|
||||
*/
|
||||
const removeLabel = async (octokit, prNumber, owner, repo, label) => {
|
||||
await octokit.rest.issues.removeLabel({
|
||||
await octokit.issues.removeLabel({
|
||||
owner,
|
||||
repo,
|
||||
issue_number: prNumber,
|
||||
@@ -268,10 +212,9 @@ const removeLabel = async (octokit, prNumber, owner, repo, label) => {
|
||||
* @param {string} repo Repository name.
|
||||
* @param {string} label Label to add or remove.
|
||||
* @param {boolean} add Whether to add or remove the label.
|
||||
* @returns {Promise<void>} Promise.
|
||||
*/
|
||||
const addRemoveLabel = async (octokit, prNumber, owner, repo, label, add) => {
|
||||
const res = await octokit.rest.pulls.get({
|
||||
const res = await octokit.pulls.get({
|
||||
owner,
|
||||
repo,
|
||||
pull_number: prNumber,
|
||||
@@ -327,41 +270,22 @@ const parseJSON = (json) => {
|
||||
if (typeof parsedJson === "object") {
|
||||
return parsedJson;
|
||||
} else {
|
||||
throw new IncorrectJsonFormatError(
|
||||
"PR diff is not a valid theme JSON object.",
|
||||
);
|
||||
throw new Error("PR diff is not a valid theme JSON object.");
|
||||
}
|
||||
} catch (error) {
|
||||
// Resolve eslint no-unused-vars
|
||||
error;
|
||||
|
||||
// Remove trailing commas (if any).
|
||||
let parsedJson = json.replace(/(,\s*})/g, "}");
|
||||
|
||||
// Remove JS comments (if any).
|
||||
parsedJson = parsedJson.replace(/\/\/[A-z\s]*\s/g, "");
|
||||
|
||||
// Fix incorrect open bracket (if any).
|
||||
const splitJson = parsedJson
|
||||
let parsedJson = json
|
||||
.split(/([\s\r\s]*}[\s\r\s]*,[\s\r\s]*)(?=[\w"-]+:)/)
|
||||
.filter((x) => typeof x !== "string" || !!x.trim()); // Split json into array of strings and objects.
|
||||
if (splitJson[0].replace(/\s+/g, "") === "},") {
|
||||
splitJson[0] = "},";
|
||||
if (/\s*}\s*,?\s*$/.test(splitJson[1])) {
|
||||
splitJson.shift();
|
||||
.filter((x) => typeof x !== "string" || !!x.trim());
|
||||
if (parsedJson[0].replace(/\s+/g, "") === "},") {
|
||||
parsedJson[0] = "},";
|
||||
if (!/\s*}\s*,?\s*$/.test(parsedJson[1])) {
|
||||
parsedJson.push(parsedJson.shift());
|
||||
} else {
|
||||
splitJson.push(splitJson.shift());
|
||||
parsedJson.shift();
|
||||
}
|
||||
parsedJson = splitJson.join("");
|
||||
}
|
||||
|
||||
// Try to parse the fixed json.
|
||||
try {
|
||||
return Hjson.parse(parsedJson);
|
||||
} catch (error) {
|
||||
throw new IncorrectJsonFormatError(
|
||||
`Theme JSON file could not be parsed: ${error.message}`,
|
||||
);
|
||||
return Hjson.parse(parsedJson.join(""));
|
||||
} else {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -375,66 +299,53 @@ const themeNameAlreadyExists = (name) => {
|
||||
return themes[name] !== undefined;
|
||||
};
|
||||
|
||||
const DRY_RUN = process.env.DRY_RUN === "true" || false;
|
||||
|
||||
/**
|
||||
* Main function.
|
||||
*
|
||||
* @returns {Promise<void>} Promise.
|
||||
*/
|
||||
export const run = async () => {
|
||||
export const run = async (prNumber) => {
|
||||
try {
|
||||
const dryRun = process.env.DRY_RUN === "true" || false;
|
||||
debug("Retrieve action information from context...");
|
||||
debug(`Context: ${inspect(github.context)}`);
|
||||
let commentBody = `
|
||||
\r# ${COMMENT_TITLE}
|
||||
\r${THEME_CONTRIB_GUIDELINES}
|
||||
\r${THEME_CONTRIB_GUIDELINESS}
|
||||
`;
|
||||
const ccc = new ColorContrastChecker();
|
||||
OCTOKIT = github.getOctokit(getGithubToken());
|
||||
PULL_REQUEST_ID = getPrNumber();
|
||||
const { owner, repo } = getRepoInfo(github.context);
|
||||
OWNER = owner;
|
||||
REPO = repo;
|
||||
const octokit = github.getOctokit(getGithubToken());
|
||||
const pullRequestId = prNumber ? prNumber : getPrNumber();
|
||||
const commenter = getCommenter();
|
||||
PULL_REQUEST_ID = getPrNumber();
|
||||
debug(`Owner: ${OWNER}`);
|
||||
debug(`Repo: ${REPO}`);
|
||||
const { owner, repo } = getRepoInfo(github.context);
|
||||
debug(`Owner: ${owner}`);
|
||||
debug(`Repo: ${repo}`);
|
||||
debug(`Commenter: ${commenter}`);
|
||||
|
||||
// Retrieve the PR diff and preview-theme comment.
|
||||
debug("Retrieve PR diff...");
|
||||
const res = await OCTOKIT.rest.pulls.get({
|
||||
owner: OWNER,
|
||||
repo: REPO,
|
||||
pull_number: PULL_REQUEST_ID,
|
||||
const res = await octokit.pulls.get({
|
||||
owner,
|
||||
repo,
|
||||
pull_number: pullRequestId,
|
||||
mediaType: {
|
||||
format: "diff",
|
||||
},
|
||||
});
|
||||
debug("Retrieve preview-theme comment...");
|
||||
const comment = await findComment(
|
||||
OCTOKIT,
|
||||
PULL_REQUEST_ID,
|
||||
OWNER,
|
||||
REPO,
|
||||
octokit,
|
||||
pullRequestId,
|
||||
owner,
|
||||
repo,
|
||||
commenter,
|
||||
);
|
||||
|
||||
// Retrieve theme changes from the PR diff.
|
||||
debug("Retrieve themes...");
|
||||
const diff = parse(res.data);
|
||||
|
||||
// Retrieve all theme changes from the PR diff and convert to JSON.
|
||||
debug("Retrieve theme changes...");
|
||||
const content = diff
|
||||
.find((file) => file.to === "themes/index.js")
|
||||
.chunks.map((chunk) =>
|
||||
chunk.changes
|
||||
.filter((c) => c.type === "add")
|
||||
.map((c) => c.content.replace("+", ""))
|
||||
.join(""),
|
||||
)
|
||||
.chunks[0].changes.filter((c) => c.type === "add")
|
||||
.map((c) => c.content.replace("+", ""))
|
||||
.join("");
|
||||
const themeObject = parseJSON(content);
|
||||
if (
|
||||
@@ -472,7 +383,10 @@ export const run = async () => {
|
||||
// Check if the theme colors are valid.
|
||||
debug("Theme preview body: Check if the theme colors are valid...");
|
||||
let invalidColors = false;
|
||||
if (colors) {
|
||||
if (!colors) {
|
||||
warning.push("Theme colors are missing");
|
||||
invalidColors = true;
|
||||
} else {
|
||||
const missingKeys = REQUIRED_COLOR_PROPS.filter(
|
||||
(x) => !Object.keys(colors).includes(x),
|
||||
);
|
||||
@@ -502,21 +416,14 @@ export const run = async () => {
|
||||
`Theme color property \`${colorKey}\` can not be longer than \`${COLOR_PROPS[colorKey]}\` characters`,
|
||||
);
|
||||
invalidColors = true;
|
||||
} else if (
|
||||
!(colorKey === "bg_color" && colorValue.split(",").length > 1
|
||||
? isValidGradient(colorValue.split(","))
|
||||
: isValidHexColor(colorValue))
|
||||
) {
|
||||
} else if (!isValidHexColor(colorValue)) {
|
||||
errors.push(
|
||||
`Theme color property \`${colorKey}\` is not a valid hex color: <code>${colorValue}</code>`,
|
||||
`Theme color property \`${colorKey}\` is not a valid hex color: <code>#${colorValue}</code>`,
|
||||
);
|
||||
invalidColors = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
warnings.push("Theme colors are missing");
|
||||
invalidColors = true;
|
||||
}
|
||||
if (invalidColors) {
|
||||
themeValid[theme] = false;
|
||||
@@ -549,10 +456,6 @@ export const run = async () => {
|
||||
Object.keys(colorPairs).forEach((item) => {
|
||||
let color1 = colorPairs[item][0];
|
||||
let color2 = colorPairs[item][1];
|
||||
const isGradientColor = color2.split(",").length > 1;
|
||||
if (isGradientColor) {
|
||||
return;
|
||||
}
|
||||
color1 = color1.length === 4 ? color1.slice(0, 3) : color1.slice(0, 6);
|
||||
color2 = color2.length === 4 ? color2.slice(0, 3) : color2.slice(0, 6);
|
||||
if (!ccc.isLevelAA(`#${color1}`, `#${color2}`)) {
|
||||
@@ -574,8 +477,8 @@ export const run = async () => {
|
||||
\r${warnings.map((warning) => `- :warning: ${warning}.\n`).join("")}
|
||||
|
||||
\ntitle_color: <code>#${titleColor}</code> | icon_color: <code>#${iconColor}</code> | text_color: <code>#${textColor}</code> | bg_color: <code>#${bgColor}</code>${
|
||||
borderColor ? ` | border_color: <code>#${borderColor}</code>` : ""
|
||||
}
|
||||
borderColor ? ` | border_color: <code>#${borderColor}</code>` : ""
|
||||
}
|
||||
|
||||
\r[Preview Link](${url})
|
||||
|
||||
@@ -611,18 +514,17 @@ export const run = async () => {
|
||||
// Create or update theme-preview comment.
|
||||
debug("Create or update theme-preview comment...");
|
||||
let comment_url;
|
||||
if (DRY_RUN) {
|
||||
if (!dryRun) {
|
||||
comment_url = await upsertComment(octokit, {
|
||||
comment_id: comment?.id,
|
||||
issue_number: pullRequestId,
|
||||
owner,
|
||||
repo,
|
||||
body: commentBody,
|
||||
});
|
||||
} else {
|
||||
info(`DRY_RUN: Comment body: ${commentBody}`);
|
||||
comment_url = "";
|
||||
} else {
|
||||
comment_url = await upsertComment(
|
||||
OCTOKIT,
|
||||
PULL_REQUEST_ID,
|
||||
REPO,
|
||||
OWNER,
|
||||
comment?.id,
|
||||
commentBody,
|
||||
);
|
||||
}
|
||||
|
||||
// Change review state and add/remove `invalid` label based on theme PR validity.
|
||||
@@ -634,52 +536,28 @@ export const run = async () => {
|
||||
const reviewReason = themesValid
|
||||
? undefined
|
||||
: INVALID_REVIEW_COMMENT(comment_url);
|
||||
if (DRY_RUN) {
|
||||
info(`DRY_RUN: Review state: ${reviewState}`);
|
||||
info(`DRY_RUN: Review reason: ${reviewReason}`);
|
||||
} else {
|
||||
if (!dryRun) {
|
||||
await addReview(
|
||||
OCTOKIT,
|
||||
PULL_REQUEST_ID,
|
||||
OWNER,
|
||||
REPO,
|
||||
octokit,
|
||||
pullRequestId,
|
||||
owner,
|
||||
repo,
|
||||
reviewState,
|
||||
reviewReason,
|
||||
);
|
||||
await addRemoveLabel(
|
||||
OCTOKIT,
|
||||
PULL_REQUEST_ID,
|
||||
OWNER,
|
||||
REPO,
|
||||
octokit,
|
||||
pullRequestId,
|
||||
owner,
|
||||
repo,
|
||||
"invalid",
|
||||
!themesValid,
|
||||
);
|
||||
} else {
|
||||
info(`DRY_RUN: Review state: ${reviewState}`);
|
||||
info(`DRY_RUN: Review reason: ${reviewReason}`);
|
||||
}
|
||||
} catch (error) {
|
||||
debug("Set review state to `REQUEST_CHANGES` and add `invalid` label...");
|
||||
if (DRY_RUN) {
|
||||
info(`DRY_RUN: Review state: REQUEST_CHANGES`);
|
||||
info(`DRY_RUN: Review reason: ${error.message}`);
|
||||
} else {
|
||||
await addReview(
|
||||
OCTOKIT,
|
||||
PULL_REQUEST_ID,
|
||||
OWNER,
|
||||
REPO,
|
||||
"REQUEST_CHANGES",
|
||||
"**Something went wrong in the theme preview action:** `" +
|
||||
error.message +
|
||||
"`",
|
||||
);
|
||||
await addRemoveLabel(
|
||||
OCTOKIT,
|
||||
PULL_REQUEST_ID,
|
||||
OWNER,
|
||||
REPO,
|
||||
"invalid",
|
||||
true,
|
||||
);
|
||||
}
|
||||
setFailed(error.message);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -5,11 +5,10 @@ set -e
|
||||
export BRANCH_NAME=updated-theme-readme
|
||||
git --version
|
||||
git config --global user.email "no-reply@githubreadmestats.com"
|
||||
git config --global user.name "GitHub Readme Stats Bot"
|
||||
git config --global --add safe.directory ${GITHUB_WORKSPACE}
|
||||
git config --global user.name "Github Readme Stats Bot"
|
||||
git branch -d $BRANCH_NAME || true
|
||||
git checkout -b $BRANCH_NAME
|
||||
git add --all
|
||||
git commit --no-verify --message "docs(theme): auto update theme readme"
|
||||
git commit --message "docs(theme): Auto update theme readme" || exit 0
|
||||
git remote add origin-$BRANCH_NAME https://${PERSONAL_TOKEN}@github.com/${GH_REPO}.git
|
||||
git push --force --quiet --set-upstream origin-$BRANCH_NAME $BRANCH_NAME
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
/**
|
||||
* Calculates the exponential cdf.
|
||||
*
|
||||
* @param {number} x The value.
|
||||
* @returns {number} The exponential cdf.
|
||||
*/
|
||||
function exponential_cdf(x) {
|
||||
return 1 - 2 ** -x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the log normal cdf.
|
||||
*
|
||||
* @param {number} x The value.
|
||||
* @returns {number} The log normal cdf.
|
||||
*/
|
||||
function log_normal_cdf(x) {
|
||||
// approximation
|
||||
return x / (1 + x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the users rank.
|
||||
*
|
||||
* @param {object} params Parameters on which the user's rank depends.
|
||||
* @param {boolean} params.all_commits Whether `include_all_commits` was used.
|
||||
* @param {number} params.commits Number of commits.
|
||||
* @param {number} params.prs The number of pull requests.
|
||||
* @param {number} params.issues The number of issues.
|
||||
* @param {number} params.reviews The number of reviews.
|
||||
* @param {number} params.repos Total number of repos.
|
||||
* @param {number} params.stars The number of stars.
|
||||
* @param {number} params.followers The number of followers.
|
||||
* @returns {{ level: string, percentile: number }} The users rank.
|
||||
*/
|
||||
function calculateRank({
|
||||
all_commits,
|
||||
commits,
|
||||
prs,
|
||||
issues,
|
||||
reviews,
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
repos, // unused
|
||||
stars,
|
||||
followers,
|
||||
}) {
|
||||
const COMMITS_MEDIAN = all_commits ? 1000 : 250,
|
||||
COMMITS_WEIGHT = 2;
|
||||
const PRS_MEDIAN = 50,
|
||||
PRS_WEIGHT = 3;
|
||||
const ISSUES_MEDIAN = 25,
|
||||
ISSUES_WEIGHT = 1;
|
||||
const REVIEWS_MEDIAN = 2,
|
||||
REVIEWS_WEIGHT = 1;
|
||||
const STARS_MEDIAN = 50,
|
||||
STARS_WEIGHT = 4;
|
||||
const FOLLOWERS_MEDIAN = 10,
|
||||
FOLLOWERS_WEIGHT = 1;
|
||||
|
||||
const TOTAL_WEIGHT =
|
||||
COMMITS_WEIGHT +
|
||||
PRS_WEIGHT +
|
||||
ISSUES_WEIGHT +
|
||||
REVIEWS_WEIGHT +
|
||||
STARS_WEIGHT +
|
||||
FOLLOWERS_WEIGHT;
|
||||
|
||||
const THRESHOLDS = [1, 12.5, 25, 37.5, 50, 62.5, 75, 87.5, 100];
|
||||
const LEVELS = ["S", "A+", "A", "A-", "B+", "B", "B-", "C+", "C"];
|
||||
|
||||
const rank =
|
||||
1 -
|
||||
(COMMITS_WEIGHT * exponential_cdf(commits / COMMITS_MEDIAN) +
|
||||
PRS_WEIGHT * exponential_cdf(prs / PRS_MEDIAN) +
|
||||
ISSUES_WEIGHT * exponential_cdf(issues / ISSUES_MEDIAN) +
|
||||
REVIEWS_WEIGHT * exponential_cdf(reviews / REVIEWS_MEDIAN) +
|
||||
STARS_WEIGHT * log_normal_cdf(stars / STARS_MEDIAN) +
|
||||
FOLLOWERS_WEIGHT * log_normal_cdf(followers / FOLLOWERS_MEDIAN)) /
|
||||
TOTAL_WEIGHT;
|
||||
|
||||
const level = LEVELS[THRESHOLDS.findIndex((t) => rank * 100 <= t)];
|
||||
|
||||
return { level, percentile: rank * 100 };
|
||||
}
|
||||
|
||||
export { calculateRank };
|
||||
export default calculateRank;
|
||||
@@ -0,0 +1,100 @@
|
||||
/**
|
||||
* Calculates the probability of x taking on x or a value less than x in a normal distribution
|
||||
* with mean and standard deviation.
|
||||
*
|
||||
* @see https://stackoverflow.com/a/5263759/10629172
|
||||
*
|
||||
* @param {string} mean
|
||||
* @param {number} sigma
|
||||
* @param {number} to
|
||||
* @returns {number} Probability.
|
||||
*/
|
||||
function normalcdf(mean, sigma, to) {
|
||||
var z = (to - mean) / Math.sqrt(2 * sigma * sigma);
|
||||
var t = 1 / (1 + 0.3275911 * Math.abs(z));
|
||||
var a1 = 0.254829592;
|
||||
var a2 = -0.284496736;
|
||||
var a3 = 1.421413741;
|
||||
var a4 = -1.453152027;
|
||||
var a5 = 1.061405429;
|
||||
var erf =
|
||||
1 - ((((a5 * t + a4) * t + a3) * t + a2) * t + a1) * t * Math.exp(-z * z);
|
||||
var sign = 1;
|
||||
if (z < 0) {
|
||||
sign = -1;
|
||||
}
|
||||
return (1 / 2) * (1 + sign * erf);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the users rank.
|
||||
*
|
||||
* @param {number} totalRepos
|
||||
* @param {number} totalCommits
|
||||
* @param {number} contributions
|
||||
* @param {number} followers
|
||||
* @param {number} prs
|
||||
* @param {number} issues
|
||||
* @param {number} stargazers
|
||||
* @returns {{level: string, score: number}}} The users rank.
|
||||
*/
|
||||
function calculateRank({
|
||||
totalRepos,
|
||||
totalCommits,
|
||||
contributions,
|
||||
followers,
|
||||
prs,
|
||||
issues,
|
||||
stargazers,
|
||||
}) {
|
||||
const COMMITS_OFFSET = 1.65;
|
||||
const CONTRIBS_OFFSET = 1.65;
|
||||
const ISSUES_OFFSET = 1;
|
||||
const STARS_OFFSET = 0.75;
|
||||
const PRS_OFFSET = 0.5;
|
||||
const FOLLOWERS_OFFSET = 0.45;
|
||||
const REPO_OFFSET = 1;
|
||||
|
||||
const ALL_OFFSETS =
|
||||
CONTRIBS_OFFSET +
|
||||
ISSUES_OFFSET +
|
||||
STARS_OFFSET +
|
||||
PRS_OFFSET +
|
||||
FOLLOWERS_OFFSET +
|
||||
REPO_OFFSET;
|
||||
|
||||
const RANK_S_VALUE = 1;
|
||||
const RANK_DOUBLE_A_VALUE = 25;
|
||||
const RANK_A2_VALUE = 45;
|
||||
const RANK_A3_VALUE = 60;
|
||||
const RANK_B_VALUE = 100;
|
||||
|
||||
const TOTAL_VALUES =
|
||||
RANK_S_VALUE + RANK_A2_VALUE + RANK_A3_VALUE + RANK_B_VALUE;
|
||||
|
||||
// prettier-ignore
|
||||
const score = (
|
||||
totalCommits * COMMITS_OFFSET +
|
||||
contributions * CONTRIBS_OFFSET +
|
||||
issues * ISSUES_OFFSET +
|
||||
stargazers * STARS_OFFSET +
|
||||
prs * PRS_OFFSET +
|
||||
followers * FOLLOWERS_OFFSET +
|
||||
totalRepos * REPO_OFFSET
|
||||
) / 100;
|
||||
|
||||
const normalizedScore = normalcdf(score, TOTAL_VALUES, ALL_OFFSETS) * 100;
|
||||
|
||||
const level = (() => {
|
||||
if (normalizedScore < RANK_S_VALUE) return "S+";
|
||||
if (normalizedScore < RANK_DOUBLE_A_VALUE) return "S";
|
||||
if (normalizedScore < RANK_A2_VALUE) return "A++";
|
||||
if (normalizedScore < RANK_A3_VALUE) return "A+";
|
||||
return "B+";
|
||||
})();
|
||||
|
||||
return { level, score: normalizedScore };
|
||||
}
|
||||
|
||||
export { calculateRank };
|
||||
export default calculateRank;
|
||||
@@ -1,152 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
import {
|
||||
measureText,
|
||||
flexLayout,
|
||||
iconWithLabel,
|
||||
createLanguageNode,
|
||||
} from "../common/render.js";
|
||||
import Card from "../common/Card.js";
|
||||
import { getCardColors } from "../common/color.js";
|
||||
import { kFormatter, wrapTextMultiline } from "../common/fmt.js";
|
||||
import { encodeHTML } from "../common/html.js";
|
||||
import { icons } from "../common/icons.js";
|
||||
import { parseEmojis } from "../common/ops.js";
|
||||
|
||||
/** Import language colors.
|
||||
*
|
||||
* @description Here we use the workaround found in
|
||||
* https://stackoverflow.com/questions/66726365/how-should-i-import-json-in-node
|
||||
* since vercel is using v16.14.0 which does not yet support json imports without the
|
||||
* --experimental-json-modules flag.
|
||||
*/
|
||||
import { createRequire } from "module";
|
||||
const require = createRequire(import.meta.url);
|
||||
const languageColors = require("../common/languageColors.json"); // now works
|
||||
|
||||
const ICON_SIZE = 16;
|
||||
const CARD_DEFAULT_WIDTH = 400;
|
||||
const HEADER_MAX_LENGTH = 35;
|
||||
|
||||
/**
|
||||
* @typedef {import('./types').GistCardOptions} GistCardOptions Gist card options.
|
||||
* @typedef {import('../fetchers/types').GistData} GistData Gist data.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Render gist card.
|
||||
*
|
||||
* @param {GistData} gistData Gist data.
|
||||
* @param {Partial<GistCardOptions>} options Gist card options.
|
||||
* @returns {string} Gist card.
|
||||
*/
|
||||
const renderGistCard = (gistData, options = {}) => {
|
||||
const { name, nameWithOwner, description, language, starsCount, forksCount } =
|
||||
gistData;
|
||||
const {
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
theme,
|
||||
border_radius,
|
||||
border_color,
|
||||
show_owner = false,
|
||||
hide_border = false,
|
||||
} = options;
|
||||
|
||||
// returns theme based colors with proper overrides and defaults
|
||||
const { titleColor, textColor, iconColor, bgColor, borderColor } =
|
||||
getCardColors({
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
});
|
||||
|
||||
const lineWidth = 59;
|
||||
const linesLimit = 10;
|
||||
const desc = parseEmojis(description || "No description provided");
|
||||
const multiLineDescription = wrapTextMultiline(desc, lineWidth, linesLimit);
|
||||
const descriptionLines = multiLineDescription.length;
|
||||
const descriptionSvg = multiLineDescription
|
||||
.map((line) => `<tspan dy="1.2em" x="25">${encodeHTML(line)}</tspan>`)
|
||||
.join("");
|
||||
|
||||
const lineHeight = descriptionLines > 3 ? 12 : 10;
|
||||
const height =
|
||||
(descriptionLines > 1 ? 120 : 110) + descriptionLines * lineHeight;
|
||||
|
||||
const totalStars = kFormatter(starsCount);
|
||||
const totalForks = kFormatter(forksCount);
|
||||
const svgStars = iconWithLabel(
|
||||
icons.star,
|
||||
totalStars,
|
||||
"starsCount",
|
||||
ICON_SIZE,
|
||||
);
|
||||
const svgForks = iconWithLabel(
|
||||
icons.fork,
|
||||
totalForks,
|
||||
"forksCount",
|
||||
ICON_SIZE,
|
||||
);
|
||||
|
||||
const languageName = language || "Unspecified";
|
||||
// @ts-ignore
|
||||
const languageColor = languageColors[languageName] || "#858585";
|
||||
|
||||
const svgLanguage = createLanguageNode(languageName, languageColor);
|
||||
|
||||
const starAndForkCount = flexLayout({
|
||||
items: [svgLanguage, svgStars, svgForks],
|
||||
sizes: [
|
||||
measureText(languageName, 12),
|
||||
ICON_SIZE + measureText(`${totalStars}`, 12),
|
||||
ICON_SIZE + measureText(`${totalForks}`, 12),
|
||||
],
|
||||
gap: 25,
|
||||
}).join("");
|
||||
|
||||
const header = show_owner ? nameWithOwner : name;
|
||||
|
||||
const card = new Card({
|
||||
defaultTitle:
|
||||
header.length > HEADER_MAX_LENGTH
|
||||
? `${header.slice(0, HEADER_MAX_LENGTH)}...`
|
||||
: header,
|
||||
titlePrefixIcon: icons.gist,
|
||||
width: CARD_DEFAULT_WIDTH,
|
||||
height,
|
||||
border_radius,
|
||||
colors: {
|
||||
titleColor,
|
||||
textColor,
|
||||
iconColor,
|
||||
bgColor,
|
||||
borderColor,
|
||||
},
|
||||
});
|
||||
|
||||
card.setCSS(`
|
||||
.description { font: 400 13px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor} }
|
||||
.gray { font: 400 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor} }
|
||||
.icon { fill: ${iconColor} }
|
||||
`);
|
||||
card.setHideBorder(hide_border);
|
||||
|
||||
return card.render(`
|
||||
<text class="description" x="25" y="-5">
|
||||
${descriptionSvg}
|
||||
</text>
|
||||
|
||||
<g transform="translate(30, ${height - 75})">
|
||||
${starAndForkCount}
|
||||
</g>
|
||||
`);
|
||||
};
|
||||
|
||||
export { renderGistCard, HEADER_MAX_LENGTH };
|
||||
export default renderGistCard;
|
||||
@@ -1,4 +0,0 @@
|
||||
export { renderRepoCard } from "./repo.js";
|
||||
export { renderStatsCard } from "./stats.js";
|
||||
export { renderTopLanguages } from "./top-languages.js";
|
||||
export { renderWakatimeCard } from "./wakatime.js";
|
||||
@@ -1,30 +1,22 @@
|
||||
// @ts-check
|
||||
|
||||
import { Card } from "../common/Card.js";
|
||||
import { getCardColors } from "../common/color.js";
|
||||
import { kFormatter, wrapTextMultiline } from "../common/fmt.js";
|
||||
import { encodeHTML } from "../common/html.js";
|
||||
import { I18n } from "../common/I18n.js";
|
||||
import { icons } from "../common/icons.js";
|
||||
import { clampValue, parseEmojis } from "../common/ops.js";
|
||||
import { Card } from "../common/Card";
|
||||
import { I18n } from "../common/I18n";
|
||||
import { icons } from "../common/icons";
|
||||
import {
|
||||
encodeHTML,
|
||||
flexLayout,
|
||||
getCardColors,
|
||||
kFormatter,
|
||||
measureText,
|
||||
iconWithLabel,
|
||||
createLanguageNode,
|
||||
} from "../common/render.js";
|
||||
import { repoCardLocales } from "../translations.js";
|
||||
|
||||
const ICON_SIZE = 16;
|
||||
const DESCRIPTION_LINE_WIDTH = 59;
|
||||
const DESCRIPTION_MAX_LINES = 3;
|
||||
parseEmojis,
|
||||
wrapTextMultiline,
|
||||
} from "../common/utils";
|
||||
import { repoCardLocales } from "../translations";
|
||||
|
||||
/**
|
||||
* Retrieves the repository description and wraps it to fit the card width.
|
||||
*
|
||||
* @param {string} label The repository description.
|
||||
* @param {string} textColor The color of the text.
|
||||
* @returns {string} Wrapped repo description SVG object.
|
||||
* @param {string} label
|
||||
* @param {string} textColor
|
||||
* @returns {string}
|
||||
*/
|
||||
const getBadgeSVG = (label, textColor) => `
|
||||
<g data-testid="badge" class="badge" transform="translate(320, -18)">
|
||||
@@ -42,16 +34,42 @@ const getBadgeSVG = (label, textColor) => `
|
||||
`;
|
||||
|
||||
/**
|
||||
* @typedef {import("../fetchers/types").RepositoryData} RepositoryData Repository data.
|
||||
* @typedef {import("./types").RepoCardOptions} RepoCardOptions Repo card options.
|
||||
* @param {string} langName
|
||||
* @param {string} langColor
|
||||
* @returns {string}
|
||||
*/
|
||||
const createLanguageNode = (langName, langColor) => {
|
||||
return `
|
||||
<g data-testid="primary-lang">
|
||||
<circle data-testid="lang-color" cx="0" cy="-5" r="6" fill="${langColor}" />
|
||||
<text data-testid="lang-name" class="gray" x="15">${langName}</text>
|
||||
</g>
|
||||
`;
|
||||
};
|
||||
|
||||
const ICON_SIZE = 16;
|
||||
const iconWithLabel = (icon, label, testid) => {
|
||||
if (label <= 0) return "";
|
||||
const iconSvg = `
|
||||
<svg
|
||||
class="icon"
|
||||
y="-12"
|
||||
viewBox="0 0 16 16"
|
||||
version="1.1"
|
||||
width="${ICON_SIZE}"
|
||||
height="${ICON_SIZE}"
|
||||
>
|
||||
${icon}
|
||||
</svg>
|
||||
`;
|
||||
const text = `<text data-testid="${testid}" class="gray">${label}</text>`;
|
||||
return flexLayout({ items: [iconSvg, text], gap: 20 }).join("");
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders repository card details.
|
||||
*
|
||||
* @param {RepositoryData} repo Repository data.
|
||||
* @param {Partial<RepoCardOptions>} options Card options.
|
||||
* @returns {string} Repository card SVG object.
|
||||
* @param {import('../fetchers/types').RepositoryData} repo
|
||||
* @param {Partial<import("./types").RepoCardOptions>} options
|
||||
* @returns {string}
|
||||
*/
|
||||
const renderRepoCard = (repo, options = {}) => {
|
||||
const {
|
||||
@@ -75,34 +93,22 @@ const renderRepoCard = (repo, options = {}) => {
|
||||
border_radius,
|
||||
border_color,
|
||||
locale,
|
||||
description_lines_count,
|
||||
} = options;
|
||||
|
||||
const lineHeight = 10;
|
||||
const header = show_owner ? nameWithOwner : name;
|
||||
const langName = (primaryLanguage && primaryLanguage.name) || "Unspecified";
|
||||
const langColor = (primaryLanguage && primaryLanguage.color) || "#333";
|
||||
const descriptionMaxLines = description_lines_count
|
||||
? clampValue(description_lines_count, 1, DESCRIPTION_MAX_LINES)
|
||||
: DESCRIPTION_MAX_LINES;
|
||||
|
||||
const desc = parseEmojis(description || "No description provided");
|
||||
const multiLineDescription = wrapTextMultiline(
|
||||
desc,
|
||||
DESCRIPTION_LINE_WIDTH,
|
||||
descriptionMaxLines,
|
||||
);
|
||||
const descriptionLinesCount = description_lines_count
|
||||
? clampValue(description_lines_count, 1, DESCRIPTION_MAX_LINES)
|
||||
: multiLineDescription.length;
|
||||
|
||||
const multiLineDescription = wrapTextMultiline(desc);
|
||||
const descriptionLines = multiLineDescription.length;
|
||||
const descriptionSvg = multiLineDescription
|
||||
.map((line) => `<tspan dy="1.2em" x="25">${encodeHTML(line)}</tspan>`)
|
||||
.join("");
|
||||
|
||||
const height =
|
||||
(descriptionLinesCount > 1 ? 120 : 110) +
|
||||
descriptionLinesCount * lineHeight;
|
||||
(descriptionLines > 1 ? 120 : 110) + descriptionLines * lineHeight;
|
||||
|
||||
const i18n = new I18n({
|
||||
locale,
|
||||
@@ -125,18 +131,8 @@ const renderRepoCard = (repo, options = {}) => {
|
||||
|
||||
const totalStars = kFormatter(starCount);
|
||||
const totalForks = kFormatter(forkCount);
|
||||
const svgStars = iconWithLabel(
|
||||
icons.star,
|
||||
totalStars,
|
||||
"stargazers",
|
||||
ICON_SIZE,
|
||||
);
|
||||
const svgForks = iconWithLabel(
|
||||
icons.fork,
|
||||
totalForks,
|
||||
"forkcount",
|
||||
ICON_SIZE,
|
||||
);
|
||||
const svgStars = iconWithLabel(icons.star, totalStars, "stargazers");
|
||||
const svgForks = iconWithLabel(icons.fork, totalForks, "forkcount");
|
||||
|
||||
const starAndForkCount = flexLayout({
|
||||
items: [svgLanguage, svgStars, svgForks],
|
||||
@@ -174,9 +170,9 @@ const renderRepoCard = (repo, options = {}) => {
|
||||
? // @ts-ignore
|
||||
getBadgeSVG(i18n.t("repocard.template"), colors.textColor)
|
||||
: isArchived
|
||||
? // @ts-ignore
|
||||
getBadgeSVG(i18n.t("repocard.archived"), colors.textColor)
|
||||
: ""
|
||||
? // @ts-ignore
|
||||
getBadgeSVG(i18n.t("repocard.archived"), colors.textColor)
|
||||
: ""
|
||||
}
|
||||
|
||||
<text class="description" x="25" y="-5">
|
||||
@@ -0,0 +1,317 @@
|
||||
// @ts-check
|
||||
import { Card } from "../common/Card";
|
||||
import { I18n } from "../common/I18n";
|
||||
import { icons } from "../common/icons";
|
||||
import {
|
||||
clampValue,
|
||||
flexLayout,
|
||||
getCardColors,
|
||||
kFormatter,
|
||||
measureText,
|
||||
} from "../common/utils";
|
||||
import { getStyles } from "../getStyles";
|
||||
import { statCardLocales } from "../translations";
|
||||
|
||||
/**
|
||||
* Create a stats card text item.
|
||||
*
|
||||
* @param {object[]} createTextNodeParams Object that contains the createTextNode parameters.
|
||||
* @param {string} createTextNodeParams.label The label to display.
|
||||
* @param {string} createTextNodeParams.value The value to display.
|
||||
* @param {string} createTextNodeParams.id The id of the stat.
|
||||
* @param {number} createTextNodeParams.index The index of the stat.
|
||||
* @param {boolean} createTextNodeParams.showIcons Whether to show icons.
|
||||
* @param {number} createTextNodeParams.shiftValuePos Number of pixels the value has to be shifted to the right.
|
||||
* @param {boolean} createTextNodeParams.bold Whether to bold the label.
|
||||
* @returns
|
||||
*/
|
||||
const createTextNode = ({
|
||||
icon,
|
||||
label,
|
||||
value,
|
||||
id,
|
||||
index,
|
||||
showIcons,
|
||||
shiftValuePos,
|
||||
bold,
|
||||
}) => {
|
||||
const kValue = kFormatter(value);
|
||||
const staggerDelay = (index + 3) * 150;
|
||||
|
||||
const labelOffset = showIcons ? `x="25"` : "";
|
||||
const iconSvg = showIcons
|
||||
? `
|
||||
<svg data-testid="icon" class="icon" viewBox="0 0 16 16" version="1.1" width="16" height="16">
|
||||
${icon}
|
||||
</svg>
|
||||
`
|
||||
: "";
|
||||
return `
|
||||
<g class="stagger" style="animation-delay: ${staggerDelay}ms" transform="translate(25, 0)">
|
||||
${iconSvg}
|
||||
<text class="stat ${
|
||||
bold ? " bold" : "not_bold"
|
||||
}" ${labelOffset} y="12.5">${label}:</text>
|
||||
<text
|
||||
class="stat ${bold ? " bold" : "not_bold"}"
|
||||
x="${(showIcons ? 140 : 120) + shiftValuePos}"
|
||||
y="12.5"
|
||||
data-testid="${id}"
|
||||
>${kValue}</text>
|
||||
</g>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Partial<import('../fetchers/types').StatsData>} stats
|
||||
* @param {Partial<import("./types").StatCardOptions>} options
|
||||
* @returns {string}
|
||||
*/
|
||||
const renderStatsCard = (stats = {}, options = { hide: [] }) => {
|
||||
const {
|
||||
name,
|
||||
totalStars,
|
||||
totalCommits,
|
||||
totalIssues,
|
||||
totalPRs,
|
||||
contributedTo,
|
||||
rank,
|
||||
} = stats;
|
||||
const {
|
||||
hide = [],
|
||||
show_icons = false,
|
||||
hide_title = false,
|
||||
hide_border = false,
|
||||
card_width,
|
||||
hide_rank = false,
|
||||
include_all_commits = false,
|
||||
line_height = 25,
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
text_bold = true,
|
||||
bg_color,
|
||||
theme = "default",
|
||||
custom_title,
|
||||
border_radius,
|
||||
border_color,
|
||||
locale,
|
||||
disable_animations = false,
|
||||
} = options;
|
||||
|
||||
const lheight = parseInt(String(line_height), 10);
|
||||
|
||||
// returns theme based colors with proper overrides and defaults
|
||||
const { titleColor, textColor, iconColor, bgColor, borderColor } =
|
||||
getCardColors({
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
});
|
||||
|
||||
const apostrophe = ["x", "s"].includes(name.slice(-1).toLocaleLowerCase())
|
||||
? ""
|
||||
: "s";
|
||||
const i18n = new I18n({
|
||||
locale,
|
||||
translations: statCardLocales({ name, apostrophe }),
|
||||
});
|
||||
|
||||
// Meta data for creating text nodes with createTextNode function
|
||||
const STATS = {
|
||||
stars: {
|
||||
icon: icons.star,
|
||||
label: i18n.t("statcard.totalstars"),
|
||||
value: totalStars,
|
||||
id: "stars",
|
||||
},
|
||||
commits: {
|
||||
icon: icons.commits,
|
||||
label: `${i18n.t("statcard.commits")}${
|
||||
include_all_commits ? "" : ` (${new Date().getFullYear()})`
|
||||
}`,
|
||||
value: totalCommits,
|
||||
id: "commits",
|
||||
},
|
||||
prs: {
|
||||
icon: icons.prs,
|
||||
label: i18n.t("statcard.prs"),
|
||||
value: totalPRs,
|
||||
id: "prs",
|
||||
},
|
||||
issues: {
|
||||
icon: icons.issues,
|
||||
label: i18n.t("statcard.issues"),
|
||||
value: totalIssues,
|
||||
id: "issues",
|
||||
},
|
||||
contribs: {
|
||||
icon: icons.contribs,
|
||||
label: i18n.t("statcard.contribs"),
|
||||
value: contributedTo,
|
||||
id: "contribs",
|
||||
},
|
||||
};
|
||||
|
||||
const longLocales = [
|
||||
"cn",
|
||||
"es",
|
||||
"fr",
|
||||
"pt-br",
|
||||
"ru",
|
||||
"uk-ua",
|
||||
"id",
|
||||
"my",
|
||||
"pl",
|
||||
"de",
|
||||
"nl",
|
||||
];
|
||||
const isLongLocale = longLocales.includes(locale) === true;
|
||||
|
||||
// filter out hidden stats defined by user & create the text nodes
|
||||
const statItems = Object.keys(STATS)
|
||||
.filter((key) => !hide.includes(key))
|
||||
.map((key, index) =>
|
||||
// create the text nodes, and pass index so that we can calculate the line spacing
|
||||
createTextNode({
|
||||
...STATS[key],
|
||||
index,
|
||||
showIcons: show_icons,
|
||||
shiftValuePos:
|
||||
(!include_all_commits ? 50 : 35) + (isLongLocale ? 50 : 0),
|
||||
bold: text_bold,
|
||||
}),
|
||||
);
|
||||
|
||||
// Calculate the card height depending on how many items there are
|
||||
// but if rank circle is visible clamp the minimum height to `150`
|
||||
let height = Math.max(
|
||||
45 + (statItems.length + 1) * lheight,
|
||||
hide_rank ? 0 : 150,
|
||||
);
|
||||
|
||||
// the better user's score the the rank will be closer to zero so
|
||||
// subtracting 100 to get the progress in 100%
|
||||
const progress = 100 - rank.score;
|
||||
const cssStyles = getStyles({
|
||||
titleColor,
|
||||
textColor,
|
||||
iconColor,
|
||||
show_icons,
|
||||
progress,
|
||||
});
|
||||
|
||||
const calculateTextWidth = () => {
|
||||
return measureText(custom_title ? custom_title : i18n.t("statcard.title"));
|
||||
};
|
||||
|
||||
/*
|
||||
When hide_rank=true, the minimum card width is 270 px + the title length and padding.
|
||||
When hide_rank=false, the minimum card_width is 340 px + the icon width (if show_icons=true).
|
||||
Numbers are picked by looking at existing dimensions on production.
|
||||
*/
|
||||
const iconWidth = show_icons ? 16 : 0;
|
||||
const minCardWidth = hide_rank
|
||||
? clampValue(50 /* padding */ + calculateTextWidth() * 2, 270, Infinity)
|
||||
: 340 + iconWidth;
|
||||
const defaultCardWidth = hide_rank ? 270 : 495;
|
||||
let width = isNaN(card_width) ? defaultCardWidth : card_width;
|
||||
if (width < minCardWidth) {
|
||||
width = minCardWidth;
|
||||
}
|
||||
|
||||
const card = new Card({
|
||||
customTitle: custom_title,
|
||||
defaultTitle: i18n.t("statcard.title"),
|
||||
width,
|
||||
height,
|
||||
border_radius,
|
||||
colors: {
|
||||
titleColor,
|
||||
textColor,
|
||||
iconColor,
|
||||
bgColor,
|
||||
borderColor,
|
||||
},
|
||||
});
|
||||
|
||||
card.setHideBorder(hide_border);
|
||||
card.setHideTitle(hide_title);
|
||||
card.setCSS(cssStyles);
|
||||
|
||||
if (disable_animations) card.disableAnimations();
|
||||
|
||||
/**
|
||||
* Calculates the right rank circle translation values such that the rank circle
|
||||
* keeps respecting the padding.
|
||||
*
|
||||
* width > 450: The default left padding of 50 px will be used.
|
||||
* width < 450: The left and right padding will shrink equally.
|
||||
*
|
||||
* @returns {number} - Rank circle translation value.
|
||||
*/
|
||||
const calculateRankXTranslation = () => {
|
||||
if (width < 450) {
|
||||
return width - 95 + (45 * (450 - 340)) / 110;
|
||||
} else {
|
||||
return width - 95;
|
||||
}
|
||||
};
|
||||
|
||||
// Conditionally rendered elements
|
||||
const rankCircle = hide_rank
|
||||
? ""
|
||||
: `<g data-testid="rank-circle"
|
||||
transform="translate(${calculateRankXTranslation()}, ${
|
||||
height / 2 - 50
|
||||
})">
|
||||
<circle class="rank-circle-rim" cx="-10" cy="8" r="40" />
|
||||
<circle class="rank-circle" cx="-10" cy="8" r="40" />
|
||||
<g class="rank-text">
|
||||
<text
|
||||
x="-5"
|
||||
y="3"
|
||||
alignment-baseline="central"
|
||||
dominant-baseline="central"
|
||||
text-anchor="middle"
|
||||
>
|
||||
${rank.level}
|
||||
</text>
|
||||
</g>
|
||||
</g>`;
|
||||
|
||||
// Accessibility Labels
|
||||
const labels = Object.keys(STATS)
|
||||
.filter((key) => !hide.includes(key))
|
||||
.map((key) => {
|
||||
if (key === "commits") {
|
||||
return `${i18n.t("statcard.commits")} ${
|
||||
include_all_commits ? "" : `in ${new Date().getFullYear()}`
|
||||
} : ${totalStars}`;
|
||||
}
|
||||
return `${STATS[key].label}: ${STATS[key].value}`;
|
||||
})
|
||||
.join(", ");
|
||||
|
||||
card.setAccessibilityLabel({
|
||||
title: `${card.title}, Rank: ${rank.level}`,
|
||||
desc: labels,
|
||||
});
|
||||
|
||||
return card.render(`
|
||||
${rankCircle}
|
||||
<svg x="0" y="0">
|
||||
${flexLayout({
|
||||
items: statItems,
|
||||
gap: lheight,
|
||||
direction: "column",
|
||||
}).join("")}
|
||||
</svg>
|
||||
`);
|
||||
};
|
||||
|
||||
export { renderStatsCard };
|
||||
export default renderStatsCard;
|
||||
@@ -1,602 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
import { Card } from "../common/Card.js";
|
||||
import { getCardColors } from "../common/color.js";
|
||||
import { CustomError } from "../common/error.js";
|
||||
import { kFormatter } from "../common/fmt.js";
|
||||
import { I18n } from "../common/I18n.js";
|
||||
import { icons, rankIcon } from "../common/icons.js";
|
||||
import { clampValue } from "../common/ops.js";
|
||||
import { flexLayout, measureText } from "../common/render.js";
|
||||
import { statCardLocales, wakatimeCardLocales } from "../translations.js";
|
||||
|
||||
const CARD_MIN_WIDTH = 287;
|
||||
const CARD_DEFAULT_WIDTH = 287;
|
||||
const RANK_CARD_MIN_WIDTH = 420;
|
||||
const RANK_CARD_DEFAULT_WIDTH = 450;
|
||||
const RANK_ONLY_CARD_MIN_WIDTH = 290;
|
||||
const RANK_ONLY_CARD_DEFAULT_WIDTH = 290;
|
||||
|
||||
/**
|
||||
* Long locales that need more space for text. Keep sorted alphabetically.
|
||||
*
|
||||
* @type {(keyof typeof wakatimeCardLocales["wakatimecard.title"])[]}
|
||||
*/
|
||||
const LONG_LOCALES = [
|
||||
"az",
|
||||
"bg",
|
||||
"cs",
|
||||
"de",
|
||||
"el",
|
||||
"es",
|
||||
"fil",
|
||||
"fi",
|
||||
"fr",
|
||||
"hu",
|
||||
"id",
|
||||
"ja",
|
||||
"ml",
|
||||
"my",
|
||||
"nl",
|
||||
"pl",
|
||||
"pt-br",
|
||||
"pt-pt",
|
||||
"ru",
|
||||
"sr",
|
||||
"sr-latn",
|
||||
"sw",
|
||||
"ta",
|
||||
"uk-ua",
|
||||
"uz",
|
||||
"zh-tw",
|
||||
];
|
||||
|
||||
/**
|
||||
* Create a stats card text item.
|
||||
*
|
||||
* @param {object} params Object that contains the createTextNode parameters.
|
||||
* @param {string} params.icon The icon to display.
|
||||
* @param {string} params.label The label to display.
|
||||
* @param {number} params.value The value to display.
|
||||
* @param {string} params.id The id of the stat.
|
||||
* @param {string=} params.unitSymbol The unit symbol of the stat.
|
||||
* @param {number} params.index The index of the stat.
|
||||
* @param {boolean} params.showIcons Whether to show icons.
|
||||
* @param {number} params.shiftValuePos Number of pixels the value has to be shifted to the right.
|
||||
* @param {boolean} params.bold Whether to bold the label.
|
||||
* @param {string} params.numberFormat The format of numbers on card.
|
||||
* @param {number=} params.numberPrecision The precision of numbers on card.
|
||||
* @returns {string} The stats card text item SVG object.
|
||||
*/
|
||||
const createTextNode = ({
|
||||
icon,
|
||||
label,
|
||||
value,
|
||||
id,
|
||||
unitSymbol,
|
||||
index,
|
||||
showIcons,
|
||||
shiftValuePos,
|
||||
bold,
|
||||
numberFormat,
|
||||
numberPrecision,
|
||||
}) => {
|
||||
const precision =
|
||||
typeof numberPrecision === "number" && !isNaN(numberPrecision)
|
||||
? clampValue(numberPrecision, 0, 2)
|
||||
: undefined;
|
||||
const kValue =
|
||||
numberFormat.toLowerCase() === "long" || id === "prs_merged_percentage"
|
||||
? value
|
||||
: kFormatter(value, precision);
|
||||
const staggerDelay = (index + 3) * 150;
|
||||
|
||||
const labelOffset = showIcons ? `x="25"` : "";
|
||||
const iconSvg = showIcons
|
||||
? `
|
||||
<svg data-testid="icon" class="icon" viewBox="0 0 16 16" version="1.1" width="16" height="16">
|
||||
${icon}
|
||||
</svg>
|
||||
`
|
||||
: "";
|
||||
return `
|
||||
<g class="stagger" style="animation-delay: ${staggerDelay}ms" transform="translate(25, 0)">
|
||||
${iconSvg}
|
||||
<text class="stat ${
|
||||
bold ? " bold" : "not_bold"
|
||||
}" ${labelOffset} y="12.5">${label}:</text>
|
||||
<text
|
||||
class="stat ${bold ? " bold" : "not_bold"}"
|
||||
x="${(showIcons ? 140 : 120) + shiftValuePos}"
|
||||
y="12.5"
|
||||
data-testid="${id}"
|
||||
>${kValue}${unitSymbol ? ` ${unitSymbol}` : ""}</text>
|
||||
</g>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates progress along the boundary of the circle, i.e. its circumference.
|
||||
*
|
||||
* @param {number} value The rank value to calculate progress for.
|
||||
* @returns {number} Progress value.
|
||||
*/
|
||||
const calculateCircleProgress = (value) => {
|
||||
const radius = 40;
|
||||
const c = Math.PI * (radius * 2);
|
||||
|
||||
if (value < 0) {
|
||||
value = 0;
|
||||
}
|
||||
if (value > 100) {
|
||||
value = 100;
|
||||
}
|
||||
|
||||
return ((100 - value) / 100) * c;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves the animation to display progress along the circumference of circle
|
||||
* from the beginning to the given value in a clockwise direction.
|
||||
*
|
||||
* @param {{progress: number}} progress The progress value to animate to.
|
||||
* @returns {string} Progress animation css.
|
||||
*/
|
||||
const getProgressAnimation = ({ progress }) => {
|
||||
return `
|
||||
@keyframes rankAnimation {
|
||||
from {
|
||||
stroke-dashoffset: ${calculateCircleProgress(0)};
|
||||
}
|
||||
to {
|
||||
stroke-dashoffset: ${calculateCircleProgress(progress)};
|
||||
}
|
||||
}
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves CSS styles for a card.
|
||||
*
|
||||
* @param {Object} colors The colors to use for the card.
|
||||
* @param {string} colors.titleColor The title color.
|
||||
* @param {string} colors.textColor The text color.
|
||||
* @param {string} colors.iconColor The icon color.
|
||||
* @param {string} colors.ringColor The ring color.
|
||||
* @param {boolean} colors.show_icons Whether to show icons.
|
||||
* @param {number} colors.progress The progress value to animate to.
|
||||
* @returns {string} Card CSS styles.
|
||||
*/
|
||||
const getStyles = ({
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
titleColor,
|
||||
textColor,
|
||||
iconColor,
|
||||
ringColor,
|
||||
show_icons,
|
||||
progress,
|
||||
}) => {
|
||||
return `
|
||||
.stat {
|
||||
font: 600 14px 'Segoe UI', Ubuntu, "Helvetica Neue", Sans-Serif; fill: ${textColor};
|
||||
}
|
||||
@supports(-moz-appearance: auto) {
|
||||
/* Selector detects Firefox */
|
||||
.stat { font-size:12px; }
|
||||
}
|
||||
.stagger {
|
||||
opacity: 0;
|
||||
animation: fadeInAnimation 0.3s ease-in-out forwards;
|
||||
}
|
||||
.rank-text {
|
||||
font: 800 24px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor};
|
||||
animation: scaleInAnimation 0.3s ease-in-out forwards;
|
||||
}
|
||||
.rank-percentile-header {
|
||||
font-size: 14px;
|
||||
}
|
||||
.rank-percentile-text {
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.not_bold { font-weight: 400 }
|
||||
.bold { font-weight: 700 }
|
||||
.icon {
|
||||
fill: ${iconColor};
|
||||
display: ${show_icons ? "block" : "none"};
|
||||
}
|
||||
|
||||
.rank-circle-rim {
|
||||
stroke: ${ringColor};
|
||||
fill: none;
|
||||
stroke-width: 6;
|
||||
opacity: 0.2;
|
||||
}
|
||||
.rank-circle {
|
||||
stroke: ${ringColor};
|
||||
stroke-dasharray: 250;
|
||||
fill: none;
|
||||
stroke-width: 6;
|
||||
stroke-linecap: round;
|
||||
opacity: 0.8;
|
||||
transform-origin: -10px 8px;
|
||||
transform: rotate(-90deg);
|
||||
animation: rankAnimation 1s forwards ease-in-out;
|
||||
}
|
||||
${process.env.NODE_ENV === "test" ? "" : getProgressAnimation({ progress })}
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Return the label for commits according to the selected options
|
||||
*
|
||||
* @param {boolean} include_all_commits Option to include all years
|
||||
* @param {number|undefined} commits_year Option to include only selected year
|
||||
* @param {I18n} i18n The I18n instance.
|
||||
* @returns {string} The label corresponding to the options.
|
||||
*/
|
||||
const getTotalCommitsYearLabel = (include_all_commits, commits_year, i18n) =>
|
||||
include_all_commits
|
||||
? ""
|
||||
: commits_year
|
||||
? ` (${commits_year})`
|
||||
: ` (${i18n.t("wakatimecard.lastyear")})`;
|
||||
|
||||
/**
|
||||
* @typedef {import('../fetchers/types').StatsData} StatsData
|
||||
* @typedef {import('./types').StatCardOptions} StatCardOptions
|
||||
*/
|
||||
|
||||
/**
|
||||
* Renders the stats card.
|
||||
*
|
||||
* @param {StatsData} stats The stats data.
|
||||
* @param {Partial<StatCardOptions>} options The card options.
|
||||
* @returns {string} The stats card SVG object.
|
||||
*/
|
||||
const renderStatsCard = (stats, options = {}) => {
|
||||
const {
|
||||
name,
|
||||
totalStars,
|
||||
totalCommits,
|
||||
totalIssues,
|
||||
totalPRs,
|
||||
totalPRsMerged,
|
||||
mergedPRsPercentage,
|
||||
totalReviews,
|
||||
totalDiscussionsStarted,
|
||||
totalDiscussionsAnswered,
|
||||
contributedTo,
|
||||
rank,
|
||||
} = stats;
|
||||
const {
|
||||
hide = [],
|
||||
show_icons = false,
|
||||
hide_title = false,
|
||||
hide_border = false,
|
||||
card_width,
|
||||
hide_rank = false,
|
||||
include_all_commits = false,
|
||||
commits_year,
|
||||
line_height = 25,
|
||||
title_color,
|
||||
ring_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
text_bold = true,
|
||||
bg_color,
|
||||
theme = "default",
|
||||
custom_title,
|
||||
border_radius,
|
||||
border_color,
|
||||
number_format = "short",
|
||||
number_precision,
|
||||
locale,
|
||||
disable_animations = false,
|
||||
rank_icon = "default",
|
||||
show = [],
|
||||
} = options;
|
||||
|
||||
const lheight = parseInt(String(line_height), 10);
|
||||
|
||||
// returns theme based colors with proper overrides and defaults
|
||||
const { titleColor, iconColor, textColor, bgColor, borderColor, ringColor } =
|
||||
getCardColors({
|
||||
title_color,
|
||||
text_color,
|
||||
icon_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
ring_color,
|
||||
theme,
|
||||
});
|
||||
|
||||
const apostrophe = /s$/i.test(name.trim()) ? "" : "s";
|
||||
const i18n = new I18n({
|
||||
locale,
|
||||
translations: {
|
||||
...statCardLocales({ name, apostrophe }),
|
||||
...wakatimeCardLocales,
|
||||
},
|
||||
});
|
||||
|
||||
// Meta data for creating text nodes with createTextNode function
|
||||
const STATS = {};
|
||||
|
||||
STATS.stars = {
|
||||
icon: icons.star,
|
||||
label: i18n.t("statcard.totalstars"),
|
||||
value: totalStars,
|
||||
id: "stars",
|
||||
};
|
||||
STATS.commits = {
|
||||
icon: icons.commits,
|
||||
label: `${i18n.t("statcard.commits")}${getTotalCommitsYearLabel(
|
||||
include_all_commits,
|
||||
commits_year,
|
||||
i18n,
|
||||
)}`,
|
||||
value: totalCommits,
|
||||
id: "commits",
|
||||
};
|
||||
STATS.prs = {
|
||||
icon: icons.prs,
|
||||
label: i18n.t("statcard.prs"),
|
||||
value: totalPRs,
|
||||
id: "prs",
|
||||
};
|
||||
|
||||
if (show.includes("prs_merged")) {
|
||||
STATS.prs_merged = {
|
||||
icon: icons.prs_merged,
|
||||
label: i18n.t("statcard.prs-merged"),
|
||||
value: totalPRsMerged,
|
||||
id: "prs_merged",
|
||||
};
|
||||
}
|
||||
|
||||
if (show.includes("prs_merged_percentage")) {
|
||||
STATS.prs_merged_percentage = {
|
||||
icon: icons.prs_merged_percentage,
|
||||
label: i18n.t("statcard.prs-merged-percentage"),
|
||||
value: mergedPRsPercentage.toFixed(
|
||||
typeof number_precision === "number" && !isNaN(number_precision)
|
||||
? clampValue(number_precision, 0, 2)
|
||||
: 2,
|
||||
),
|
||||
id: "prs_merged_percentage",
|
||||
unitSymbol: "%",
|
||||
};
|
||||
}
|
||||
|
||||
if (show.includes("reviews")) {
|
||||
STATS.reviews = {
|
||||
icon: icons.reviews,
|
||||
label: i18n.t("statcard.reviews"),
|
||||
value: totalReviews,
|
||||
id: "reviews",
|
||||
};
|
||||
}
|
||||
|
||||
STATS.issues = {
|
||||
icon: icons.issues,
|
||||
label: i18n.t("statcard.issues"),
|
||||
value: totalIssues,
|
||||
id: "issues",
|
||||
};
|
||||
|
||||
if (show.includes("discussions_started")) {
|
||||
STATS.discussions_started = {
|
||||
icon: icons.discussions_started,
|
||||
label: i18n.t("statcard.discussions-started"),
|
||||
value: totalDiscussionsStarted,
|
||||
id: "discussions_started",
|
||||
};
|
||||
}
|
||||
if (show.includes("discussions_answered")) {
|
||||
STATS.discussions_answered = {
|
||||
icon: icons.discussions_answered,
|
||||
label: i18n.t("statcard.discussions-answered"),
|
||||
value: totalDiscussionsAnswered,
|
||||
id: "discussions_answered",
|
||||
};
|
||||
}
|
||||
|
||||
STATS.contribs = {
|
||||
icon: icons.contribs,
|
||||
label: i18n.t("statcard.contribs"),
|
||||
value: contributedTo,
|
||||
id: "contribs",
|
||||
};
|
||||
|
||||
// @ts-ignore
|
||||
const isLongLocale = locale ? LONG_LOCALES.includes(locale) : false;
|
||||
|
||||
// filter out hidden stats defined by user & create the text nodes
|
||||
const statItems = Object.keys(STATS)
|
||||
.filter((key) => !hide.includes(key))
|
||||
.map((key, index) => {
|
||||
// @ts-ignore
|
||||
const stats = STATS[key];
|
||||
|
||||
// create the text nodes, and pass index so that we can calculate the line spacing
|
||||
return createTextNode({
|
||||
icon: stats.icon,
|
||||
label: stats.label,
|
||||
value: stats.value,
|
||||
id: stats.id,
|
||||
unitSymbol: stats.unitSymbol,
|
||||
index,
|
||||
showIcons: show_icons,
|
||||
shiftValuePos: 79.01 + (isLongLocale ? 50 : 0),
|
||||
bold: text_bold,
|
||||
numberFormat: number_format,
|
||||
numberPrecision: number_precision,
|
||||
});
|
||||
});
|
||||
|
||||
if (statItems.length === 0 && hide_rank) {
|
||||
throw new CustomError(
|
||||
"Could not render stats card.",
|
||||
"Either stats or rank are required.",
|
||||
);
|
||||
}
|
||||
|
||||
// Calculate the card height depending on how many items there are
|
||||
// but if rank circle is visible clamp the minimum height to `150`
|
||||
let height = Math.max(
|
||||
45 + (statItems.length + 1) * lheight,
|
||||
hide_rank ? 0 : statItems.length ? 150 : 180,
|
||||
);
|
||||
|
||||
// the lower the user's percentile the better
|
||||
const progress = 100 - rank.percentile;
|
||||
const cssStyles = getStyles({
|
||||
titleColor,
|
||||
ringColor,
|
||||
textColor,
|
||||
iconColor,
|
||||
show_icons,
|
||||
progress,
|
||||
});
|
||||
|
||||
const calculateTextWidth = () => {
|
||||
return measureText(
|
||||
custom_title
|
||||
? custom_title
|
||||
: statItems.length
|
||||
? i18n.t("statcard.title")
|
||||
: i18n.t("statcard.ranktitle"),
|
||||
);
|
||||
};
|
||||
|
||||
/*
|
||||
When hide_rank=true, the minimum card width is 270 px + the title length and padding.
|
||||
When hide_rank=false, the minimum card_width is 340 px + the icon width (if show_icons=true).
|
||||
Numbers are picked by looking at existing dimensions on production.
|
||||
*/
|
||||
const iconWidth = show_icons && statItems.length ? 16 + /* padding */ 1 : 0;
|
||||
const minCardWidth =
|
||||
(hide_rank
|
||||
? clampValue(
|
||||
50 /* padding */ + calculateTextWidth() * 2,
|
||||
CARD_MIN_WIDTH,
|
||||
Infinity,
|
||||
)
|
||||
: statItems.length
|
||||
? RANK_CARD_MIN_WIDTH
|
||||
: RANK_ONLY_CARD_MIN_WIDTH) + iconWidth;
|
||||
const defaultCardWidth =
|
||||
(hide_rank
|
||||
? CARD_DEFAULT_WIDTH
|
||||
: statItems.length
|
||||
? RANK_CARD_DEFAULT_WIDTH
|
||||
: RANK_ONLY_CARD_DEFAULT_WIDTH) + iconWidth;
|
||||
let width = card_width
|
||||
? isNaN(card_width)
|
||||
? defaultCardWidth
|
||||
: card_width
|
||||
: defaultCardWidth;
|
||||
if (width < minCardWidth) {
|
||||
width = minCardWidth;
|
||||
}
|
||||
|
||||
const card = new Card({
|
||||
customTitle: custom_title,
|
||||
defaultTitle: statItems.length
|
||||
? i18n.t("statcard.title")
|
||||
: i18n.t("statcard.ranktitle"),
|
||||
width,
|
||||
height,
|
||||
border_radius,
|
||||
colors: {
|
||||
titleColor,
|
||||
textColor,
|
||||
iconColor,
|
||||
bgColor,
|
||||
borderColor,
|
||||
},
|
||||
});
|
||||
|
||||
card.setHideBorder(hide_border);
|
||||
card.setHideTitle(hide_title);
|
||||
card.setCSS(cssStyles);
|
||||
|
||||
if (disable_animations) {
|
||||
card.disableAnimations();
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the right rank circle translation values such that the rank circle
|
||||
* keeps respecting the following padding:
|
||||
*
|
||||
* width > RANK_CARD_DEFAULT_WIDTH: The default right padding of 70 px will be used.
|
||||
* width < RANK_CARD_DEFAULT_WIDTH: The left and right padding will be enlarged
|
||||
* equally from a certain minimum at RANK_CARD_MIN_WIDTH.
|
||||
*
|
||||
* @returns {number} - Rank circle translation value.
|
||||
*/
|
||||
const calculateRankXTranslation = () => {
|
||||
if (statItems.length) {
|
||||
const minXTranslation = RANK_CARD_MIN_WIDTH + iconWidth - 70;
|
||||
if (width > RANK_CARD_DEFAULT_WIDTH) {
|
||||
const xMaxExpansion = minXTranslation + (450 - minCardWidth) / 2;
|
||||
return xMaxExpansion + width - RANK_CARD_DEFAULT_WIDTH;
|
||||
} else {
|
||||
return minXTranslation + (width - minCardWidth) / 2;
|
||||
}
|
||||
} else {
|
||||
return width / 2 + 20 - 10;
|
||||
}
|
||||
};
|
||||
|
||||
// Conditionally rendered elements
|
||||
const rankCircle = hide_rank
|
||||
? ""
|
||||
: `<g data-testid="rank-circle"
|
||||
transform="translate(${calculateRankXTranslation()}, ${
|
||||
height / 2 - 50
|
||||
})">
|
||||
<circle class="rank-circle-rim" cx="-10" cy="8" r="40" />
|
||||
<circle class="rank-circle" cx="-10" cy="8" r="40" />
|
||||
<g class="rank-text">
|
||||
${rankIcon(rank_icon, rank?.level, rank?.percentile)}
|
||||
</g>
|
||||
</g>`;
|
||||
|
||||
// Accessibility Labels
|
||||
const labels = Object.keys(STATS)
|
||||
.filter((key) => !hide.includes(key))
|
||||
.map((key) => {
|
||||
// @ts-ignore
|
||||
const stats = STATS[key];
|
||||
if (key === "commits") {
|
||||
return `${i18n.t("statcard.commits")} ${getTotalCommitsYearLabel(
|
||||
include_all_commits,
|
||||
commits_year,
|
||||
i18n,
|
||||
)} : ${stats.value}`;
|
||||
}
|
||||
return `${stats.label}: ${stats.value}`;
|
||||
})
|
||||
.join(", ");
|
||||
|
||||
card.setAccessibilityLabel({
|
||||
title: `${card.title}, Rank: ${rank.level}`,
|
||||
desc: labels,
|
||||
});
|
||||
|
||||
return card.render(`
|
||||
${rankCircle}
|
||||
<svg x="0" y="0">
|
||||
${flexLayout({
|
||||
items: statItems,
|
||||
gap: lheight,
|
||||
direction: "column",
|
||||
}).join("")}
|
||||
</svg>
|
||||
`);
|
||||
};
|
||||
|
||||
export { renderStatsCard };
|
||||
export default renderStatsCard;
|
||||
@@ -0,0 +1,314 @@
|
||||
// @ts-check
|
||||
import { Card } from "../common/Card";
|
||||
import { createProgressNode } from "../common/createProgressNode";
|
||||
import { I18n } from "../common/I18n";
|
||||
import {
|
||||
chunkArray,
|
||||
clampValue,
|
||||
flexLayout,
|
||||
getCardColors,
|
||||
lowercaseTrim,
|
||||
measureText,
|
||||
} from "../common/utils";
|
||||
import { langCardLocales } from "../translations";
|
||||
|
||||
const DEFAULT_CARD_WIDTH = 300;
|
||||
const MIN_CARD_WIDTH = 230;
|
||||
const DEFAULT_LANGS_COUNT = 5;
|
||||
const DEFAULT_LANG_COLOR = "#858585";
|
||||
const CARD_PADDING = 25;
|
||||
|
||||
/**
|
||||
* @typedef {import("../fetchers/types").Lang} Lang
|
||||
*/
|
||||
|
||||
/**
|
||||
* @param {Lang[]} arr
|
||||
*/
|
||||
const getLongestLang = (arr) =>
|
||||
arr.reduce(
|
||||
(savedLang, lang) =>
|
||||
lang.name.length > savedLang.name.length ? lang : savedLang,
|
||||
{ name: "", size: null, color: "" },
|
||||
);
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* width: number,
|
||||
* color: string,
|
||||
* name: string,
|
||||
* progress: string
|
||||
* }} props
|
||||
*/
|
||||
const createProgressTextNode = ({ width, color, name, progress }) => {
|
||||
const paddingRight = 95;
|
||||
const progressTextX = width - paddingRight + 10;
|
||||
const progressWidth = width - paddingRight;
|
||||
|
||||
return `
|
||||
<text data-testid="lang-name" x="2" y="15" class="lang-name">${name}</text>
|
||||
<text x="${progressTextX}" y="34" class="lang-name">${progress}%</text>
|
||||
${createProgressNode({
|
||||
x: 0,
|
||||
y: 25,
|
||||
color,
|
||||
width: progressWidth,
|
||||
progress,
|
||||
progressBarBackgroundColor: "#ddd",
|
||||
})}
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {{ lang: Lang, totalSize: number }} props
|
||||
*/
|
||||
const createCompactLangNode = ({ lang, totalSize }) => {
|
||||
const percentage = ((lang.size / totalSize) * 100).toFixed(2);
|
||||
const color = lang.color || "#858585";
|
||||
|
||||
return `
|
||||
<g>
|
||||
<circle cx="5" cy="6" r="5" fill="${color}" />
|
||||
<text data-testid="lang-name" x="15" y="10" class='lang-name'>
|
||||
${lang.name} ${percentage}%
|
||||
</text>
|
||||
</g>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {{ langs: Lang[], totalSize: number }} props
|
||||
*/
|
||||
const createLanguageTextNode = ({ langs, totalSize }) => {
|
||||
const longestLang = getLongestLang(langs);
|
||||
const chunked = chunkArray(langs, langs.length / 2);
|
||||
const layouts = chunked.map((array) => {
|
||||
// @ts-ignore
|
||||
const items = array.map((lang, index) =>
|
||||
createCompactLangNode({
|
||||
lang,
|
||||
totalSize,
|
||||
// @ts-ignore
|
||||
index,
|
||||
}),
|
||||
);
|
||||
return flexLayout({
|
||||
items,
|
||||
gap: 25,
|
||||
direction: "column",
|
||||
}).join("");
|
||||
});
|
||||
|
||||
const percent = ((longestLang.size / totalSize) * 100).toFixed(2);
|
||||
const minGap = 150;
|
||||
const maxGap = 20 + measureText(`${longestLang.name} ${percent}%`, 11);
|
||||
return flexLayout({
|
||||
items: layouts,
|
||||
gap: maxGap < minGap ? minGap : maxGap,
|
||||
}).join("");
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Lang[]} langs
|
||||
* @param {number} width
|
||||
* @param {number} totalLanguageSize
|
||||
* @returns {string}
|
||||
*/
|
||||
const renderNormalLayout = (langs, width, totalLanguageSize) => {
|
||||
return flexLayout({
|
||||
items: langs.map((lang) => {
|
||||
return createProgressTextNode({
|
||||
width: width,
|
||||
name: lang.name,
|
||||
color: lang.color || DEFAULT_LANG_COLOR,
|
||||
progress: ((lang.size / totalLanguageSize) * 100).toFixed(2),
|
||||
});
|
||||
}),
|
||||
gap: 40,
|
||||
direction: "column",
|
||||
}).join("");
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Lang[]} langs
|
||||
* @param {number} width
|
||||
* @param {number} totalLanguageSize
|
||||
* @returns {string}
|
||||
*/
|
||||
const renderCompactLayout = (langs, width, totalLanguageSize) => {
|
||||
const paddingRight = 50;
|
||||
const offsetWidth = width - paddingRight;
|
||||
// progressOffset holds the previous language's width and used to offset the next language
|
||||
// so that we can stack them one after another, like this: [--][----][---]
|
||||
let progressOffset = 0;
|
||||
const compactProgressBar = langs
|
||||
.map((lang) => {
|
||||
const percentage = parseFloat(
|
||||
((lang.size / totalLanguageSize) * offsetWidth).toFixed(2),
|
||||
);
|
||||
|
||||
const progress = percentage < 10 ? percentage + 10 : percentage;
|
||||
|
||||
const output = `
|
||||
<rect
|
||||
mask="url(#rect-mask)"
|
||||
data-testid="lang-progress"
|
||||
x="${progressOffset}"
|
||||
y="0"
|
||||
width="${progress}"
|
||||
height="8"
|
||||
fill="${lang.color || "#858585"}"
|
||||
/>
|
||||
`;
|
||||
progressOffset += percentage;
|
||||
return output;
|
||||
})
|
||||
.join("");
|
||||
|
||||
return `
|
||||
<mask id="rect-mask">
|
||||
<rect x="0" y="0" width="${offsetWidth}" height="8" fill="white" rx="5" />
|
||||
</mask>
|
||||
${compactProgressBar}
|
||||
|
||||
<g transform="translate(0, 25)">
|
||||
${createLanguageTextNode({
|
||||
langs,
|
||||
totalSize: totalLanguageSize,
|
||||
})}
|
||||
</g>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} totalLangs
|
||||
* @returns {number}
|
||||
*/
|
||||
const calculateCompactLayoutHeight = (totalLangs) => {
|
||||
return 90 + Math.round(totalLangs / 2) * 25;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {number} totalLangs
|
||||
* @returns {number}
|
||||
*/
|
||||
const calculateNormalLayoutHeight = (totalLangs) => {
|
||||
return 45 + (totalLangs + 1) * 40;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Record<string, Lang>} topLangs
|
||||
* @param {string[]} hide
|
||||
* @param {string} langs_count
|
||||
*/
|
||||
const useLanguages = (topLangs, hide, langs_count) => {
|
||||
let langs = Object.values(topLangs);
|
||||
let langsToHide = {};
|
||||
let langsCount = clampValue(parseInt(langs_count), 1, 10);
|
||||
|
||||
// populate langsToHide map for quick lookup
|
||||
// while filtering out
|
||||
if (hide) {
|
||||
hide.forEach((langName) => {
|
||||
langsToHide[lowercaseTrim(langName)] = true;
|
||||
});
|
||||
}
|
||||
|
||||
// filter out languages to be hidden
|
||||
langs = langs
|
||||
.sort((a, b) => b.size - a.size)
|
||||
.filter((lang) => {
|
||||
return !langsToHide[lowercaseTrim(lang.name)];
|
||||
})
|
||||
.slice(0, langsCount);
|
||||
|
||||
const totalLanguageSize = langs.reduce((acc, curr) => acc + curr.size, 0);
|
||||
|
||||
return { langs, totalLanguageSize };
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {import('../fetchers/types').TopLangData} topLangs
|
||||
* @param {Partial<import("./types").TopLangOptions>} options
|
||||
* @returns {string}
|
||||
*/
|
||||
const renderTopLanguages = (topLangs, options = {}) => {
|
||||
const {
|
||||
hide_title = false,
|
||||
hide_border,
|
||||
card_width,
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
hide,
|
||||
theme,
|
||||
layout,
|
||||
custom_title,
|
||||
locale,
|
||||
langs_count = DEFAULT_LANGS_COUNT,
|
||||
border_radius,
|
||||
border_color,
|
||||
} = options;
|
||||
|
||||
const i18n = new I18n({
|
||||
locale,
|
||||
translations: langCardLocales,
|
||||
});
|
||||
|
||||
const { langs, totalLanguageSize } = useLanguages(
|
||||
topLangs,
|
||||
hide,
|
||||
String(langs_count),
|
||||
);
|
||||
|
||||
let width = isNaN(card_width)
|
||||
? DEFAULT_CARD_WIDTH
|
||||
: card_width < MIN_CARD_WIDTH
|
||||
? MIN_CARD_WIDTH
|
||||
: card_width;
|
||||
let height = calculateNormalLayoutHeight(langs.length);
|
||||
|
||||
let finalLayout = "";
|
||||
if (layout === "compact") {
|
||||
width = width + 50; // padding
|
||||
height = calculateCompactLayoutHeight(langs.length);
|
||||
|
||||
finalLayout = renderCompactLayout(langs, width, totalLanguageSize);
|
||||
} else {
|
||||
finalLayout = renderNormalLayout(langs, width, totalLanguageSize);
|
||||
}
|
||||
|
||||
// returns theme based colors with proper overrides and defaults
|
||||
const colors = getCardColors({
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
});
|
||||
|
||||
const card = new Card({
|
||||
customTitle: custom_title,
|
||||
defaultTitle: i18n.t("langcard.title"),
|
||||
width,
|
||||
height,
|
||||
border_radius,
|
||||
colors,
|
||||
});
|
||||
|
||||
card.disableAnimations();
|
||||
card.setHideBorder(hide_border);
|
||||
card.setHideTitle(hide_title);
|
||||
card.setCSS(
|
||||
`.lang-name { font: 400 11px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${colors.textColor} }`,
|
||||
);
|
||||
|
||||
return card.render(`
|
||||
<svg data-testid="lang-items" x="${CARD_PADDING}">
|
||||
${finalLayout}
|
||||
</svg>
|
||||
`);
|
||||
};
|
||||
|
||||
export { renderTopLanguages, MIN_CARD_WIDTH };
|
||||
@@ -1,965 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
import { Card } from "../common/Card.js";
|
||||
import { getCardColors } from "../common/color.js";
|
||||
import { formatBytes } from "../common/fmt.js";
|
||||
import { I18n } from "../common/I18n.js";
|
||||
import { chunkArray, clampValue, lowercaseTrim } from "../common/ops.js";
|
||||
import {
|
||||
createProgressNode,
|
||||
flexLayout,
|
||||
measureText,
|
||||
} from "../common/render.js";
|
||||
import { langCardLocales } from "../translations.js";
|
||||
|
||||
const DEFAULT_CARD_WIDTH = 300;
|
||||
const MIN_CARD_WIDTH = 280;
|
||||
const DEFAULT_LANG_COLOR = "#858585";
|
||||
const CARD_PADDING = 25;
|
||||
const COMPACT_LAYOUT_BASE_HEIGHT = 90;
|
||||
const MAXIMUM_LANGS_COUNT = 20;
|
||||
|
||||
const NORMAL_LAYOUT_DEFAULT_LANGS_COUNT = 5;
|
||||
const COMPACT_LAYOUT_DEFAULT_LANGS_COUNT = 6;
|
||||
const DONUT_LAYOUT_DEFAULT_LANGS_COUNT = 5;
|
||||
const PIE_LAYOUT_DEFAULT_LANGS_COUNT = 6;
|
||||
const DONUT_VERTICAL_LAYOUT_DEFAULT_LANGS_COUNT = 6;
|
||||
|
||||
/**
|
||||
* @typedef {import("../fetchers/types").Lang} Lang
|
||||
*/
|
||||
|
||||
/**
|
||||
* Retrieves the programming language whose name is the longest.
|
||||
*
|
||||
* @param {Lang[]} arr Array of programming languages.
|
||||
* @returns {{ name: string, size: number, color: string }} Longest programming language object.
|
||||
*/
|
||||
const getLongestLang = (arr) =>
|
||||
arr.reduce(
|
||||
(savedLang, lang) =>
|
||||
lang.name.length > savedLang.name.length ? lang : savedLang,
|
||||
{ name: "", size: 0, color: "" },
|
||||
);
|
||||
|
||||
/**
|
||||
* Convert degrees to radians.
|
||||
*
|
||||
* @param {number} angleInDegrees Angle in degrees.
|
||||
* @returns {number} Angle in radians.
|
||||
*/
|
||||
const degreesToRadians = (angleInDegrees) => angleInDegrees * (Math.PI / 180.0);
|
||||
|
||||
/**
|
||||
* Convert radians to degrees.
|
||||
*
|
||||
* @param {number} angleInRadians Angle in radians.
|
||||
* @returns {number} Angle in degrees.
|
||||
*/
|
||||
const radiansToDegrees = (angleInRadians) => angleInRadians / (Math.PI / 180.0);
|
||||
|
||||
/**
|
||||
* Convert polar coordinates to cartesian coordinates.
|
||||
*
|
||||
* @param {number} centerX Center x coordinate.
|
||||
* @param {number} centerY Center y coordinate.
|
||||
* @param {number} radius Radius of the circle.
|
||||
* @param {number} angleInDegrees Angle in degrees.
|
||||
* @returns {{x: number, y: number}} Cartesian coordinates.
|
||||
*/
|
||||
const polarToCartesian = (centerX, centerY, radius, angleInDegrees) => {
|
||||
const rads = degreesToRadians(angleInDegrees);
|
||||
return {
|
||||
x: centerX + radius * Math.cos(rads),
|
||||
y: centerY + radius * Math.sin(rads),
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Convert cartesian coordinates to polar coordinates.
|
||||
*
|
||||
* @param {number} centerX Center x coordinate.
|
||||
* @param {number} centerY Center y coordinate.
|
||||
* @param {number} x Point x coordinate.
|
||||
* @param {number} y Point y coordinate.
|
||||
* @returns {{radius: number, angleInDegrees: number}} Polar coordinates.
|
||||
*/
|
||||
const cartesianToPolar = (centerX, centerY, x, y) => {
|
||||
const radius = Math.sqrt(Math.pow(x - centerX, 2) + Math.pow(y - centerY, 2));
|
||||
let angleInDegrees = radiansToDegrees(Math.atan2(y - centerY, x - centerX));
|
||||
if (angleInDegrees < 0) {
|
||||
angleInDegrees += 360;
|
||||
}
|
||||
return { radius, angleInDegrees };
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates length of circle.
|
||||
*
|
||||
* @param {number} radius Radius of the circle.
|
||||
* @returns {number} The length of the circle.
|
||||
*/
|
||||
const getCircleLength = (radius) => {
|
||||
return 2 * Math.PI * radius;
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates height for the compact layout.
|
||||
*
|
||||
* @param {number} totalLangs Total number of languages.
|
||||
* @returns {number} Card height.
|
||||
*/
|
||||
const calculateCompactLayoutHeight = (totalLangs) => {
|
||||
return COMPACT_LAYOUT_BASE_HEIGHT + Math.round(totalLangs / 2) * 25;
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates height for the normal layout.
|
||||
*
|
||||
* @param {number} totalLangs Total number of languages.
|
||||
* @returns {number} Card height.
|
||||
*/
|
||||
const calculateNormalLayoutHeight = (totalLangs) => {
|
||||
return 45 + (totalLangs + 1) * 40;
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates height for the donut layout.
|
||||
*
|
||||
* @param {number} totalLangs Total number of languages.
|
||||
* @returns {number} Card height.
|
||||
*/
|
||||
const calculateDonutLayoutHeight = (totalLangs) => {
|
||||
return 215 + Math.max(totalLangs - 5, 0) * 32;
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates height for the donut vertical layout.
|
||||
*
|
||||
* @param {number} totalLangs Total number of languages.
|
||||
* @returns {number} Card height.
|
||||
*/
|
||||
const calculateDonutVerticalLayoutHeight = (totalLangs) => {
|
||||
return 300 + Math.round(totalLangs / 2) * 25;
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates height for the pie layout.
|
||||
*
|
||||
* @param {number} totalLangs Total number of languages.
|
||||
* @returns {number} Card height.
|
||||
*/
|
||||
const calculatePieLayoutHeight = (totalLangs) => {
|
||||
return 300 + Math.round(totalLangs / 2) * 25;
|
||||
};
|
||||
|
||||
/**
|
||||
* Calculates the center translation needed to keep the donut chart centred.
|
||||
* @param {number} totalLangs Total number of languages.
|
||||
* @returns {number} Donut center translation.
|
||||
*/
|
||||
const donutCenterTranslation = (totalLangs) => {
|
||||
return -45 + Math.max(totalLangs - 5, 0) * 16;
|
||||
};
|
||||
|
||||
/**
|
||||
* Trim top languages to lang_count while also hiding certain languages.
|
||||
*
|
||||
* @param {Record<string, Lang>} topLangs Top languages.
|
||||
* @param {number} langs_count Number of languages to show.
|
||||
* @param {string[]=} hide Languages to hide.
|
||||
* @returns {{ langs: Lang[], totalLanguageSize: number }} Trimmed top languages and total size.
|
||||
*/
|
||||
const trimTopLanguages = (topLangs, langs_count, hide) => {
|
||||
let langs = Object.values(topLangs);
|
||||
let langsToHide = {};
|
||||
let langsCount = clampValue(langs_count, 1, MAXIMUM_LANGS_COUNT);
|
||||
|
||||
// populate langsToHide map for quick lookup
|
||||
// while filtering out
|
||||
if (hide) {
|
||||
hide.forEach((langName) => {
|
||||
// @ts-ignore
|
||||
langsToHide[lowercaseTrim(langName)] = true;
|
||||
});
|
||||
}
|
||||
|
||||
// filter out languages to be hidden
|
||||
langs = langs
|
||||
.sort((a, b) => b.size - a.size)
|
||||
.filter((lang) => {
|
||||
// @ts-ignore
|
||||
return !langsToHide[lowercaseTrim(lang.name)];
|
||||
})
|
||||
.slice(0, langsCount);
|
||||
|
||||
const totalLanguageSize = langs.reduce((acc, curr) => acc + curr.size, 0);
|
||||
|
||||
return { langs, totalLanguageSize };
|
||||
};
|
||||
|
||||
/**
|
||||
* Get display value corresponding to the format.
|
||||
*
|
||||
* @param {number} size Bytes size.
|
||||
* @param {number} percentages Percentage value.
|
||||
* @param {string} format Format of the stats.
|
||||
* @returns {string} Display value.
|
||||
*/
|
||||
const getDisplayValue = (size, percentages, format) => {
|
||||
return format === "bytes" ? formatBytes(size) : `${percentages.toFixed(2)}%`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create progress bar text item for a programming language.
|
||||
*
|
||||
* @param {object} props Function properties.
|
||||
* @param {number} props.width The card width
|
||||
* @param {string} props.color Color of the programming language.
|
||||
* @param {string} props.name Name of the programming language.
|
||||
* @param {number} props.size Size of the programming language.
|
||||
* @param {number} props.totalSize Total size of all languages.
|
||||
* @param {string} props.statsFormat Stats format.
|
||||
* @param {number} props.index Index of the programming language.
|
||||
* @returns {string} Programming language SVG node.
|
||||
*/
|
||||
const createProgressTextNode = ({
|
||||
width,
|
||||
color,
|
||||
name,
|
||||
size,
|
||||
totalSize,
|
||||
statsFormat,
|
||||
index,
|
||||
}) => {
|
||||
const staggerDelay = (index + 3) * 150;
|
||||
const paddingRight = 95;
|
||||
const progressTextX = width - paddingRight + 10;
|
||||
const progressWidth = width - paddingRight;
|
||||
|
||||
const progress = (size / totalSize) * 100;
|
||||
const displayValue = getDisplayValue(size, progress, statsFormat);
|
||||
|
||||
return `
|
||||
<g class="stagger" style="animation-delay: ${staggerDelay}ms">
|
||||
<text data-testid="lang-name" x="2" y="15" class="lang-name">${name}</text>
|
||||
<text x="${progressTextX}" y="34" class="lang-name">${displayValue}</text>
|
||||
${createProgressNode({
|
||||
x: 0,
|
||||
y: 25,
|
||||
color,
|
||||
width: progressWidth,
|
||||
progress,
|
||||
progressBarBackgroundColor: "#ddd",
|
||||
delay: staggerDelay + 300,
|
||||
})}
|
||||
</g>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates compact text item for a programming language.
|
||||
*
|
||||
* @param {object} props Function properties.
|
||||
* @param {Lang} props.lang Programming language object.
|
||||
* @param {number} props.totalSize Total size of all languages.
|
||||
* @param {boolean=} props.hideProgress Whether to hide percentage.
|
||||
* @param {string=} props.statsFormat Stats format
|
||||
* @param {number} props.index Index of the programming language.
|
||||
* @returns {string} Compact layout programming language SVG node.
|
||||
*/
|
||||
const createCompactLangNode = ({
|
||||
lang,
|
||||
totalSize,
|
||||
hideProgress,
|
||||
statsFormat = "percentages",
|
||||
index,
|
||||
}) => {
|
||||
const percentages = (lang.size / totalSize) * 100;
|
||||
const displayValue = getDisplayValue(lang.size, percentages, statsFormat);
|
||||
|
||||
const staggerDelay = (index + 3) * 150;
|
||||
const color = lang.color || "#858585";
|
||||
|
||||
return `
|
||||
<g class="stagger" style="animation-delay: ${staggerDelay}ms">
|
||||
<circle cx="5" cy="6" r="5" fill="${color}" />
|
||||
<text data-testid="lang-name" x="15" y="10" class='lang-name'>
|
||||
${lang.name} ${hideProgress ? "" : displayValue}
|
||||
</text>
|
||||
</g>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create compact languages text items for all programming languages.
|
||||
*
|
||||
* @param {object} props Function properties.
|
||||
* @param {Lang[]} props.langs Array of programming languages.
|
||||
* @param {number} props.totalSize Total size of all languages.
|
||||
* @param {boolean=} props.hideProgress Whether to hide percentage.
|
||||
* @param {string=} props.statsFormat Stats format
|
||||
* @returns {string} Programming languages SVG node.
|
||||
*/
|
||||
const createLanguageTextNode = ({
|
||||
langs,
|
||||
totalSize,
|
||||
hideProgress,
|
||||
statsFormat,
|
||||
}) => {
|
||||
const longestLang = getLongestLang(langs);
|
||||
const chunked = chunkArray(langs, langs.length / 2);
|
||||
const layouts = chunked.map((array) => {
|
||||
// @ts-ignore
|
||||
const items = array.map((lang, index) =>
|
||||
createCompactLangNode({
|
||||
lang,
|
||||
totalSize,
|
||||
hideProgress,
|
||||
statsFormat,
|
||||
index,
|
||||
}),
|
||||
);
|
||||
return flexLayout({
|
||||
items,
|
||||
gap: 25,
|
||||
direction: "column",
|
||||
}).join("");
|
||||
});
|
||||
|
||||
const percent = ((longestLang.size / totalSize) * 100).toFixed(2);
|
||||
const minGap = 150;
|
||||
const maxGap = 20 + measureText(`${longestLang.name} ${percent}%`, 11);
|
||||
return flexLayout({
|
||||
items: layouts,
|
||||
gap: maxGap < minGap ? minGap : maxGap,
|
||||
}).join("");
|
||||
};
|
||||
|
||||
/**
|
||||
* Create donut languages text items for all programming languages.
|
||||
*
|
||||
* @param {object} props Function properties.
|
||||
* @param {Lang[]} props.langs Array of programming languages.
|
||||
* @param {number} props.totalSize Total size of all languages.
|
||||
* @param {string} props.statsFormat Stats format
|
||||
* @returns {string} Donut layout programming language SVG node.
|
||||
*/
|
||||
const createDonutLanguagesNode = ({ langs, totalSize, statsFormat }) => {
|
||||
return flexLayout({
|
||||
items: langs.map((lang, index) => {
|
||||
return createCompactLangNode({
|
||||
lang,
|
||||
totalSize,
|
||||
hideProgress: false,
|
||||
statsFormat,
|
||||
index,
|
||||
});
|
||||
}),
|
||||
gap: 32,
|
||||
direction: "column",
|
||||
}).join("");
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders the default language card layout.
|
||||
*
|
||||
* @param {Lang[]} langs Array of programming languages.
|
||||
* @param {number} width Card width.
|
||||
* @param {number} totalLanguageSize Total size of all languages.
|
||||
* @param {string} statsFormat Stats format.
|
||||
* @returns {string} Normal layout card SVG object.
|
||||
*/
|
||||
const renderNormalLayout = (langs, width, totalLanguageSize, statsFormat) => {
|
||||
return flexLayout({
|
||||
items: langs.map((lang, index) => {
|
||||
return createProgressTextNode({
|
||||
width,
|
||||
name: lang.name,
|
||||
color: lang.color || DEFAULT_LANG_COLOR,
|
||||
size: lang.size,
|
||||
totalSize: totalLanguageSize,
|
||||
statsFormat,
|
||||
index,
|
||||
});
|
||||
}),
|
||||
gap: 40,
|
||||
direction: "column",
|
||||
}).join("");
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders the compact language card layout.
|
||||
*
|
||||
* @param {Lang[]} langs Array of programming languages.
|
||||
* @param {number} width Card width.
|
||||
* @param {number} totalLanguageSize Total size of all languages.
|
||||
* @param {boolean=} hideProgress Whether to hide progress bar.
|
||||
* @param {string} statsFormat Stats format.
|
||||
* @returns {string} Compact layout card SVG object.
|
||||
*/
|
||||
const renderCompactLayout = (
|
||||
langs,
|
||||
width,
|
||||
totalLanguageSize,
|
||||
hideProgress,
|
||||
statsFormat = "percentages",
|
||||
) => {
|
||||
const paddingRight = 50;
|
||||
const offsetWidth = width - paddingRight;
|
||||
// progressOffset holds the previous language's width and used to offset the next language
|
||||
// so that we can stack them one after another, like this: [--][----][---]
|
||||
let progressOffset = 0;
|
||||
const compactProgressBar = langs
|
||||
.map((lang) => {
|
||||
const percentage = parseFloat(
|
||||
((lang.size / totalLanguageSize) * offsetWidth).toFixed(2),
|
||||
);
|
||||
|
||||
const progress = percentage < 10 ? percentage + 10 : percentage;
|
||||
|
||||
const output = `
|
||||
<rect
|
||||
mask="url(#rect-mask)"
|
||||
data-testid="lang-progress"
|
||||
x="${progressOffset}"
|
||||
y="0"
|
||||
width="${progress}"
|
||||
height="8"
|
||||
fill="${lang.color || "#858585"}"
|
||||
/>
|
||||
`;
|
||||
progressOffset += percentage;
|
||||
return output;
|
||||
})
|
||||
.join("");
|
||||
|
||||
return `
|
||||
${
|
||||
hideProgress
|
||||
? ""
|
||||
: `
|
||||
<mask id="rect-mask">
|
||||
<rect x="0" y="0" width="${offsetWidth}" height="8" fill="white" rx="5"/>
|
||||
</mask>
|
||||
${compactProgressBar}
|
||||
`
|
||||
}
|
||||
<g transform="translate(0, ${hideProgress ? "0" : "25"})">
|
||||
${createLanguageTextNode({
|
||||
langs,
|
||||
totalSize: totalLanguageSize,
|
||||
hideProgress,
|
||||
statsFormat,
|
||||
})}
|
||||
</g>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders donut vertical layout to display user's most frequently used programming languages.
|
||||
*
|
||||
* @param {Lang[]} langs Array of programming languages.
|
||||
* @param {number} totalLanguageSize Total size of all languages.
|
||||
* @param {string} statsFormat Stats format.
|
||||
* @returns {string} Compact layout card SVG object.
|
||||
*/
|
||||
const renderDonutVerticalLayout = (langs, totalLanguageSize, statsFormat) => {
|
||||
// Donut vertical chart radius and total length
|
||||
const radius = 80;
|
||||
const totalCircleLength = getCircleLength(radius);
|
||||
|
||||
// SVG circles
|
||||
let circles = [];
|
||||
|
||||
// Start indent for donut vertical chart parts
|
||||
let indent = 0;
|
||||
|
||||
// Start delay coefficient for donut vertical chart parts
|
||||
let startDelayCoefficient = 1;
|
||||
|
||||
// Generate each donut vertical chart part
|
||||
for (const lang of langs) {
|
||||
const percentage = (lang.size / totalLanguageSize) * 100;
|
||||
const circleLength = totalCircleLength * (percentage / 100);
|
||||
const delay = startDelayCoefficient * 100;
|
||||
|
||||
circles.push(`
|
||||
<g class="stagger" style="animation-delay: ${delay}ms">
|
||||
<circle
|
||||
cx="150"
|
||||
cy="100"
|
||||
r="${radius}"
|
||||
fill="transparent"
|
||||
stroke="${lang.color}"
|
||||
stroke-width="25"
|
||||
stroke-dasharray="${totalCircleLength}"
|
||||
stroke-dashoffset="${indent}"
|
||||
size="${percentage}"
|
||||
data-testid="lang-donut"
|
||||
/>
|
||||
</g>
|
||||
`);
|
||||
|
||||
// Update the indent for the next part
|
||||
indent += circleLength;
|
||||
// Update the start delay coefficient for the next part
|
||||
startDelayCoefficient += 1;
|
||||
}
|
||||
|
||||
return `
|
||||
<svg data-testid="lang-items">
|
||||
<g transform="translate(0, 0)">
|
||||
<svg data-testid="donut">
|
||||
${circles.join("")}
|
||||
</svg>
|
||||
</g>
|
||||
<g transform="translate(0, 220)">
|
||||
<svg data-testid="lang-names" x="${CARD_PADDING}">
|
||||
${createLanguageTextNode({
|
||||
langs,
|
||||
totalSize: totalLanguageSize,
|
||||
hideProgress: false,
|
||||
statsFormat,
|
||||
})}
|
||||
</svg>
|
||||
</g>
|
||||
</svg>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders pie layout to display user's most frequently used programming languages.
|
||||
*
|
||||
* @param {Lang[]} langs Array of programming languages.
|
||||
* @param {number} totalLanguageSize Total size of all languages.
|
||||
* @param {string} statsFormat Stats format.
|
||||
* @returns {string} Compact layout card SVG object.
|
||||
*/
|
||||
const renderPieLayout = (langs, totalLanguageSize, statsFormat) => {
|
||||
// Pie chart radius and center coordinates
|
||||
const radius = 90;
|
||||
const centerX = 150;
|
||||
const centerY = 100;
|
||||
|
||||
// Start angle for the pie chart parts
|
||||
let startAngle = 0;
|
||||
|
||||
// Start delay coefficient for the pie chart parts
|
||||
let startDelayCoefficient = 1;
|
||||
|
||||
// SVG paths
|
||||
const paths = [];
|
||||
|
||||
// Generate each pie chart part
|
||||
for (const lang of langs) {
|
||||
if (langs.length === 1) {
|
||||
paths.push(`
|
||||
<circle
|
||||
cx="${centerX}"
|
||||
cy="${centerY}"
|
||||
r="${radius}"
|
||||
stroke="none"
|
||||
fill="${lang.color}"
|
||||
data-testid="lang-pie"
|
||||
size="100"
|
||||
/>
|
||||
`);
|
||||
break;
|
||||
}
|
||||
|
||||
const langSizePart = lang.size / totalLanguageSize;
|
||||
const percentage = langSizePart * 100;
|
||||
// Calculate the angle for the current part
|
||||
const angle = langSizePart * 360;
|
||||
|
||||
// Calculate the end angle
|
||||
const endAngle = startAngle + angle;
|
||||
|
||||
// Calculate the coordinates of the start and end points of the arc
|
||||
const startPoint = polarToCartesian(centerX, centerY, radius, startAngle);
|
||||
const endPoint = polarToCartesian(centerX, centerY, radius, endAngle);
|
||||
|
||||
// Determine the large arc flag based on the angle
|
||||
const largeArcFlag = angle > 180 ? 1 : 0;
|
||||
|
||||
// Calculate delay
|
||||
const delay = startDelayCoefficient * 100;
|
||||
|
||||
// SVG arc markup
|
||||
paths.push(`
|
||||
<g class="stagger" style="animation-delay: ${delay}ms">
|
||||
<path
|
||||
data-testid="lang-pie"
|
||||
size="${percentage}"
|
||||
d="M ${centerX} ${centerY} L ${startPoint.x} ${startPoint.y} A ${radius} ${radius} 0 ${largeArcFlag} 1 ${endPoint.x} ${endPoint.y} Z"
|
||||
fill="${lang.color}"
|
||||
/>
|
||||
</g>
|
||||
`);
|
||||
|
||||
// Update the start angle for the next part
|
||||
startAngle = endAngle;
|
||||
// Update the start delay coefficient for the next part
|
||||
startDelayCoefficient += 1;
|
||||
}
|
||||
|
||||
return `
|
||||
<svg data-testid="lang-items">
|
||||
<g transform="translate(0, 0)">
|
||||
<svg data-testid="pie">
|
||||
${paths.join("")}
|
||||
</svg>
|
||||
</g>
|
||||
<g transform="translate(0, 220)">
|
||||
<svg data-testid="lang-names" x="${CARD_PADDING}">
|
||||
${createLanguageTextNode({
|
||||
langs,
|
||||
totalSize: totalLanguageSize,
|
||||
hideProgress: false,
|
||||
statsFormat,
|
||||
})}
|
||||
</svg>
|
||||
</g>
|
||||
</svg>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates the SVG paths for the language donut chart.
|
||||
*
|
||||
* @param {number} cx Donut center x-position.
|
||||
* @param {number} cy Donut center y-position.
|
||||
* @param {number} radius Donut arc Radius.
|
||||
* @param {number[]} percentages Array with donut section percentages.
|
||||
* @returns {{d: string, percent: number}[]} Array of svg path elements
|
||||
*/
|
||||
const createDonutPaths = (cx, cy, radius, percentages) => {
|
||||
const paths = [];
|
||||
let startAngle = 0;
|
||||
let endAngle = 0;
|
||||
|
||||
const totalPercent = percentages.reduce((acc, curr) => acc + curr, 0);
|
||||
for (let i = 0; i < percentages.length; i++) {
|
||||
const tmpPath = {};
|
||||
|
||||
let percent = parseFloat(
|
||||
((percentages[i] / totalPercent) * 100).toFixed(2),
|
||||
);
|
||||
|
||||
endAngle = 3.6 * percent + startAngle;
|
||||
const startPoint = polarToCartesian(cx, cy, radius, endAngle - 90); // rotate donut 90 degrees counter-clockwise.
|
||||
const endPoint = polarToCartesian(cx, cy, radius, startAngle - 90); // rotate donut 90 degrees counter-clockwise.
|
||||
const largeArc = endAngle - startAngle <= 180 ? 0 : 1;
|
||||
|
||||
tmpPath.percent = percent;
|
||||
tmpPath.d = `M ${startPoint.x} ${startPoint.y} A ${radius} ${radius} 0 ${largeArc} 0 ${endPoint.x} ${endPoint.y}`;
|
||||
|
||||
paths.push(tmpPath);
|
||||
startAngle = endAngle;
|
||||
}
|
||||
|
||||
return paths;
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders the donut language card layout.
|
||||
*
|
||||
* @param {Lang[]} langs Array of programming languages.
|
||||
* @param {number} width Card width.
|
||||
* @param {number} totalLanguageSize Total size of all languages.
|
||||
* @param {string} statsFormat Stats format.
|
||||
* @returns {string} Donut layout card SVG object.
|
||||
*/
|
||||
const renderDonutLayout = (langs, width, totalLanguageSize, statsFormat) => {
|
||||
const centerX = width / 3;
|
||||
const centerY = width / 3;
|
||||
const radius = centerX - 60;
|
||||
const strokeWidth = 12;
|
||||
|
||||
const colors = langs.map((lang) => lang.color);
|
||||
const langsPercents = langs.map((lang) =>
|
||||
parseFloat(((lang.size / totalLanguageSize) * 100).toFixed(2)),
|
||||
);
|
||||
|
||||
const langPaths = createDonutPaths(centerX, centerY, radius, langsPercents);
|
||||
|
||||
const donutPaths =
|
||||
langs.length === 1
|
||||
? `<circle cx="${centerX}" cy="${centerY}" r="${radius}" stroke="${colors[0]}" fill="none" stroke-width="${strokeWidth}" data-testid="lang-donut" size="100"/>`
|
||||
: langPaths
|
||||
.map((section, index) => {
|
||||
const staggerDelay = (index + 3) * 100;
|
||||
const delay = staggerDelay + 300;
|
||||
|
||||
const output = `
|
||||
<g class="stagger" style="animation-delay: ${delay}ms">
|
||||
<path
|
||||
data-testid="lang-donut"
|
||||
size="${section.percent}"
|
||||
d="${section.d}"
|
||||
stroke="${colors[index]}"
|
||||
fill="none"
|
||||
stroke-width="${strokeWidth}">
|
||||
</path>
|
||||
</g>
|
||||
`;
|
||||
|
||||
return output;
|
||||
})
|
||||
.join("");
|
||||
|
||||
const donut = `<svg width="${width}" height="${width}">${donutPaths}</svg>`;
|
||||
|
||||
return `
|
||||
<g transform="translate(0, 0)">
|
||||
<g transform="translate(0, 0)">
|
||||
${createDonutLanguagesNode({ langs, totalSize: totalLanguageSize, statsFormat })}
|
||||
</g>
|
||||
|
||||
<g transform="translate(125, ${donutCenterTranslation(langs.length)})">
|
||||
${donut}
|
||||
</g>
|
||||
</g>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {import("./types").TopLangOptions} TopLangOptions
|
||||
* @typedef {TopLangOptions["layout"]} Layout
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates the no languages data SVG node.
|
||||
*
|
||||
* @param {object} props Object with function properties.
|
||||
* @param {string} props.color No languages data text color.
|
||||
* @param {string} props.text No languages data translated text.
|
||||
* @param {Layout | undefined} props.layout Card layout.
|
||||
* @returns {string} No languages data SVG node string.
|
||||
*/
|
||||
const noLanguagesDataNode = ({ color, text, layout }) => {
|
||||
return `
|
||||
<text x="${
|
||||
layout === "pie" || layout === "donut-vertical" ? CARD_PADDING : 0
|
||||
}" y="11" class="stat bold" fill="${color}">${text}</text>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get default languages count for provided card layout.
|
||||
*
|
||||
* @param {object} props Function properties.
|
||||
* @param {Layout=} props.layout Input layout string.
|
||||
* @param {boolean=} props.hide_progress Input hide_progress parameter value.
|
||||
* @returns {number} Default languages count for input layout.
|
||||
*/
|
||||
const getDefaultLanguagesCountByLayout = ({ layout, hide_progress }) => {
|
||||
if (layout === "compact" || hide_progress === true) {
|
||||
return COMPACT_LAYOUT_DEFAULT_LANGS_COUNT;
|
||||
} else if (layout === "donut") {
|
||||
return DONUT_LAYOUT_DEFAULT_LANGS_COUNT;
|
||||
} else if (layout === "donut-vertical") {
|
||||
return DONUT_VERTICAL_LAYOUT_DEFAULT_LANGS_COUNT;
|
||||
} else if (layout === "pie") {
|
||||
return PIE_LAYOUT_DEFAULT_LANGS_COUNT;
|
||||
} else {
|
||||
return NORMAL_LAYOUT_DEFAULT_LANGS_COUNT;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {import('../fetchers/types').TopLangData} TopLangData
|
||||
*/
|
||||
|
||||
/**
|
||||
* Renders card that display user's most frequently used programming languages.
|
||||
*
|
||||
* @param {TopLangData} topLangs User's most frequently used programming languages.
|
||||
* @param {Partial<TopLangOptions>} options Card options.
|
||||
* @returns {string} Language card SVG object.
|
||||
*/
|
||||
const renderTopLanguages = (topLangs, options = {}) => {
|
||||
const {
|
||||
hide_title = false,
|
||||
hide_border = false,
|
||||
card_width,
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
hide,
|
||||
hide_progress,
|
||||
theme,
|
||||
layout,
|
||||
custom_title,
|
||||
locale,
|
||||
langs_count = getDefaultLanguagesCountByLayout({ layout, hide_progress }),
|
||||
border_radius,
|
||||
border_color,
|
||||
disable_animations,
|
||||
stats_format = "percentages",
|
||||
} = options;
|
||||
|
||||
const i18n = new I18n({
|
||||
locale,
|
||||
translations: langCardLocales,
|
||||
});
|
||||
|
||||
const { langs, totalLanguageSize } = trimTopLanguages(
|
||||
topLangs,
|
||||
langs_count,
|
||||
hide,
|
||||
);
|
||||
|
||||
let width = card_width
|
||||
? isNaN(card_width)
|
||||
? DEFAULT_CARD_WIDTH
|
||||
: card_width < MIN_CARD_WIDTH
|
||||
? MIN_CARD_WIDTH
|
||||
: card_width
|
||||
: DEFAULT_CARD_WIDTH;
|
||||
let height = calculateNormalLayoutHeight(langs.length);
|
||||
|
||||
// returns theme based colors with proper overrides and defaults
|
||||
const colors = getCardColors({
|
||||
title_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
});
|
||||
|
||||
let finalLayout = "";
|
||||
if (langs.length === 0) {
|
||||
height = COMPACT_LAYOUT_BASE_HEIGHT;
|
||||
finalLayout = noLanguagesDataNode({
|
||||
color: colors.textColor,
|
||||
text: i18n.t("langcard.nodata"),
|
||||
layout,
|
||||
});
|
||||
} else if (layout === "pie") {
|
||||
height = calculatePieLayoutHeight(langs.length);
|
||||
finalLayout = renderPieLayout(langs, totalLanguageSize, stats_format);
|
||||
} else if (layout === "donut-vertical") {
|
||||
height = calculateDonutVerticalLayoutHeight(langs.length);
|
||||
finalLayout = renderDonutVerticalLayout(
|
||||
langs,
|
||||
totalLanguageSize,
|
||||
stats_format,
|
||||
);
|
||||
} else if (layout === "compact" || hide_progress == true) {
|
||||
height =
|
||||
calculateCompactLayoutHeight(langs.length) + (hide_progress ? -25 : 0);
|
||||
|
||||
finalLayout = renderCompactLayout(
|
||||
langs,
|
||||
width,
|
||||
totalLanguageSize,
|
||||
hide_progress,
|
||||
stats_format,
|
||||
);
|
||||
} else if (layout === "donut") {
|
||||
height = calculateDonutLayoutHeight(langs.length);
|
||||
width = width + 50; // padding
|
||||
finalLayout = renderDonutLayout(
|
||||
langs,
|
||||
width,
|
||||
totalLanguageSize,
|
||||
stats_format,
|
||||
);
|
||||
} else {
|
||||
finalLayout = renderNormalLayout(
|
||||
langs,
|
||||
width,
|
||||
totalLanguageSize,
|
||||
stats_format,
|
||||
);
|
||||
}
|
||||
|
||||
const card = new Card({
|
||||
customTitle: custom_title,
|
||||
defaultTitle: i18n.t("langcard.title"),
|
||||
width,
|
||||
height,
|
||||
border_radius,
|
||||
colors,
|
||||
});
|
||||
|
||||
if (disable_animations) {
|
||||
card.disableAnimations();
|
||||
}
|
||||
|
||||
card.setHideBorder(hide_border);
|
||||
card.setHideTitle(hide_title);
|
||||
card.setCSS(
|
||||
`
|
||||
@keyframes slideInAnimation {
|
||||
from {
|
||||
width: 0;
|
||||
}
|
||||
to {
|
||||
width: calc(100%-100px);
|
||||
}
|
||||
}
|
||||
@keyframes growWidthAnimation {
|
||||
from {
|
||||
width: 0;
|
||||
}
|
||||
to {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.stat {
|
||||
font: 600 14px 'Segoe UI', Ubuntu, "Helvetica Neue", Sans-Serif; fill: ${colors.textColor};
|
||||
}
|
||||
@supports(-moz-appearance: auto) {
|
||||
/* Selector detects Firefox */
|
||||
.stat { font-size:12px; }
|
||||
}
|
||||
.bold { font-weight: 700 }
|
||||
.lang-name {
|
||||
font: 400 11px "Segoe UI", Ubuntu, Sans-Serif;
|
||||
fill: ${colors.textColor};
|
||||
}
|
||||
.stagger {
|
||||
opacity: 0;
|
||||
animation: fadeInAnimation 0.3s ease-in-out forwards;
|
||||
}
|
||||
#rect-mask rect{
|
||||
animation: slideInAnimation 1s ease-in-out forwards;
|
||||
}
|
||||
.lang-progress{
|
||||
animation: growWidthAnimation 0.6s ease-in-out forwards;
|
||||
}
|
||||
`,
|
||||
);
|
||||
|
||||
if (layout === "pie" || layout === "donut-vertical") {
|
||||
return card.render(finalLayout);
|
||||
}
|
||||
|
||||
return card.render(`
|
||||
<svg data-testid="lang-items" x="${CARD_PADDING}">
|
||||
${finalLayout}
|
||||
</svg>
|
||||
`);
|
||||
};
|
||||
|
||||
export {
|
||||
getLongestLang,
|
||||
degreesToRadians,
|
||||
radiansToDegrees,
|
||||
polarToCartesian,
|
||||
cartesianToPolar,
|
||||
getCircleLength,
|
||||
calculateCompactLayoutHeight,
|
||||
calculateNormalLayoutHeight,
|
||||
calculateDonutLayoutHeight,
|
||||
calculateDonutVerticalLayoutHeight,
|
||||
calculatePieLayoutHeight,
|
||||
donutCenterTranslation,
|
||||
trimTopLanguages,
|
||||
renderTopLanguages,
|
||||
MIN_CARD_WIDTH,
|
||||
getDefaultLanguagesCountByLayout,
|
||||
};
|
||||
Vendored
+7
-23
@@ -1,5 +1,4 @@
|
||||
type ThemeNames = keyof typeof import("../../themes/index.js");
|
||||
type RankIcon = "default" | "github" | "percentile";
|
||||
type ThemeNames = keyof typeof import("../../themes/index");
|
||||
|
||||
export type CommonOptions = {
|
||||
title_color: string;
|
||||
@@ -10,58 +9,43 @@ export type CommonOptions = {
|
||||
border_radius: number;
|
||||
border_color: string;
|
||||
locale: string;
|
||||
hide_border: boolean;
|
||||
};
|
||||
|
||||
export type StatCardOptions = CommonOptions & {
|
||||
hide: string[];
|
||||
show_icons: boolean;
|
||||
hide_title: boolean;
|
||||
hide_border: boolean;
|
||||
card_width: number;
|
||||
hide_rank: boolean;
|
||||
include_all_commits: boolean;
|
||||
commits_year: number;
|
||||
line_height: number | string;
|
||||
custom_title: string;
|
||||
disable_animations: boolean;
|
||||
number_format: string;
|
||||
number_precision: number;
|
||||
ring_color: string;
|
||||
text_bold: boolean;
|
||||
rank_icon: RankIcon;
|
||||
show: string[];
|
||||
};
|
||||
|
||||
export type RepoCardOptions = CommonOptions & {
|
||||
hide_border: boolean;
|
||||
show_owner: boolean;
|
||||
description_lines_count: number;
|
||||
};
|
||||
|
||||
export type TopLangOptions = CommonOptions & {
|
||||
hide_title: boolean;
|
||||
hide_border: boolean;
|
||||
card_width: number;
|
||||
hide: string[];
|
||||
layout: "compact" | "normal" | "donut" | "donut-vertical" | "pie";
|
||||
layout: "compact" | "normal";
|
||||
custom_title: string;
|
||||
langs_count: number;
|
||||
disable_animations: boolean;
|
||||
hide_progress: boolean;
|
||||
stats_format: "percentages" | "bytes";
|
||||
};
|
||||
|
||||
export type WakaTimeOptions = CommonOptions & {
|
||||
type WakaTimeOptions = CommonOptions & {
|
||||
hide_title: boolean;
|
||||
hide_border: boolean;
|
||||
hide: string[];
|
||||
card_width: number;
|
||||
line_height: string;
|
||||
hide_progress: boolean;
|
||||
custom_title: string;
|
||||
layout: "compact" | "normal";
|
||||
langs_count: number;
|
||||
display_format: "time" | "percent";
|
||||
disable_animations: boolean;
|
||||
};
|
||||
|
||||
export type GistCardOptions = CommonOptions & {
|
||||
show_owner: boolean;
|
||||
};
|
||||
|
||||
@@ -0,0 +1,319 @@
|
||||
// @ts-check
|
||||
import { Card } from "../common/Card";
|
||||
import { createProgressNode } from "../common/createProgressNode";
|
||||
import { I18n } from "../common/I18n";
|
||||
import {
|
||||
clampValue,
|
||||
flexLayout,
|
||||
getCardColors,
|
||||
lowercaseTrim,
|
||||
} from "../common/utils";
|
||||
import { getStyles } from "../getStyles";
|
||||
import { wakatimeCardLocales } from "../translations";
|
||||
|
||||
import languageColors from "../common/languageColors.json";
|
||||
|
||||
/**
|
||||
* @param {{color: string, text: string}} param0
|
||||
*/
|
||||
const noCodingActivityNode = ({ color, text }) => {
|
||||
return `
|
||||
<text x="25" y="11" class="stat bold" fill="${color}">${text}</text>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {{
|
||||
* lang: import("../fetchers/types").WakaTimeLang,
|
||||
* totalSize: number,
|
||||
* x: number,
|
||||
* y: number
|
||||
* }} props
|
||||
*/
|
||||
const createCompactLangNode = ({ lang, totalSize, x, y }) => {
|
||||
const color = languageColors[lang.name] || "#858585";
|
||||
|
||||
return `
|
||||
<g transform="translate(${x}, ${y})">
|
||||
<circle cx="5" cy="6" r="5" fill="${color}" />
|
||||
<text data-testid="lang-name" x="15" y="10" class='lang-name'>
|
||||
${lang.name} - ${lang.text}
|
||||
</text>
|
||||
</g>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {{
|
||||
* langs: import("../fetchers/types").WakaTimeLang[],
|
||||
* totalSize: number,
|
||||
* x: number,
|
||||
* y: number
|
||||
* }} props
|
||||
*/
|
||||
const createLanguageTextNode = ({ langs, totalSize, x, y }) => {
|
||||
return langs.map((lang, index) => {
|
||||
if (index % 2 === 0) {
|
||||
return createCompactLangNode({
|
||||
lang,
|
||||
x: 25,
|
||||
y: 12.5 * index + y,
|
||||
totalSize,
|
||||
});
|
||||
}
|
||||
return createCompactLangNode({
|
||||
lang,
|
||||
x: 230,
|
||||
y: 12.5 + 12.5 * index,
|
||||
totalSize,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {{
|
||||
* id: string;
|
||||
* label: string;
|
||||
* value: string;
|
||||
* index: number;
|
||||
* percent: number;
|
||||
* hideProgress: boolean;
|
||||
* progressBarColor: string;
|
||||
* progressBarBackgroundColor: string
|
||||
* }} props
|
||||
*/
|
||||
const createTextNode = ({
|
||||
id,
|
||||
label,
|
||||
value,
|
||||
index,
|
||||
percent,
|
||||
hideProgress,
|
||||
progressBarColor,
|
||||
progressBarBackgroundColor,
|
||||
}) => {
|
||||
const staggerDelay = (index + 3) * 150;
|
||||
|
||||
const cardProgress = hideProgress
|
||||
? null
|
||||
: createProgressNode({
|
||||
x: 110,
|
||||
y: 4,
|
||||
progress: percent,
|
||||
color: progressBarColor,
|
||||
width: 220,
|
||||
// @ts-ignore
|
||||
name: label,
|
||||
progressBarBackgroundColor,
|
||||
});
|
||||
|
||||
return `
|
||||
<g class="stagger" style="animation-delay: ${staggerDelay}ms" transform="translate(25, 0)">
|
||||
<text class="stat bold" y="12.5" data-testid="${id}">${label}:</text>
|
||||
<text
|
||||
class="stat"
|
||||
x="${hideProgress ? 170 : 350}"
|
||||
y="12.5"
|
||||
>${value}</text>
|
||||
${cardProgress}
|
||||
</g>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {import("../fetchers/types").WakaTimeLang[]} languages
|
||||
*/
|
||||
const recalculatePercentages = (languages) => {
|
||||
// recalculating percentages so that,
|
||||
// compact layout's progress bar does not break when hiding languages
|
||||
const totalSum = languages.reduce(
|
||||
(totalSum, language) => totalSum + language.percent,
|
||||
0,
|
||||
);
|
||||
const weight = +(100 / totalSum).toFixed(2);
|
||||
languages.forEach((language) => {
|
||||
language.percent = +(language.percent * weight).toFixed(2);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {Partial<import('../fetchers/types').WakaTimeData>} stats
|
||||
* @param {Partial<import('./types').WakaTimeOptions>} options
|
||||
* @returns {string}
|
||||
*/
|
||||
const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
||||
let { languages } = stats;
|
||||
const {
|
||||
hide_title = false,
|
||||
hide_border = false,
|
||||
hide,
|
||||
line_height = 25,
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
theme = "default",
|
||||
hide_progress,
|
||||
custom_title,
|
||||
locale,
|
||||
layout,
|
||||
langs_count = languages ? languages.length : 0,
|
||||
border_radius,
|
||||
border_color,
|
||||
} = options;
|
||||
|
||||
const shouldHideLangs = Array.isArray(hide) && hide.length > 0;
|
||||
if (shouldHideLangs && languages !== undefined) {
|
||||
const languagesToHide = new Set(hide.map((lang) => lowercaseTrim(lang)));
|
||||
languages = languages.filter(
|
||||
(lang) => !languagesToHide.has(lowercaseTrim(lang.name)),
|
||||
);
|
||||
recalculatePercentages(languages);
|
||||
}
|
||||
|
||||
const i18n = new I18n({
|
||||
locale,
|
||||
translations: wakatimeCardLocales,
|
||||
});
|
||||
|
||||
const lheight = parseInt(String(line_height), 10);
|
||||
|
||||
const langsCount = clampValue(parseInt(String(langs_count)), 1, langs_count);
|
||||
|
||||
// returns theme based colors with proper overrides and defaults
|
||||
const { titleColor, textColor, iconColor, bgColor, borderColor } =
|
||||
getCardColors({
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
});
|
||||
|
||||
const filteredLanguages = languages
|
||||
? languages
|
||||
.filter((language) => language.hours || language.minutes)
|
||||
.slice(0, langsCount)
|
||||
: [];
|
||||
|
||||
// Calculate the card height depending on how many items there are
|
||||
// but if rank circle is visible clamp the minimum height to `150`
|
||||
let height = Math.max(45 + (filteredLanguages.length + 1) * lheight, 150);
|
||||
|
||||
const cssStyles = getStyles({
|
||||
titleColor,
|
||||
textColor,
|
||||
iconColor,
|
||||
});
|
||||
|
||||
let finalLayout = "";
|
||||
|
||||
let width = 440;
|
||||
|
||||
// RENDER COMPACT LAYOUT
|
||||
if (layout === "compact") {
|
||||
width = width + 50;
|
||||
height = 90 + Math.round(filteredLanguages.length / 2) * 25;
|
||||
|
||||
// progressOffset holds the previous language's width and used to offset the next language
|
||||
// so that we can stack them one after another, like this: [--][----][---]
|
||||
let progressOffset = 0;
|
||||
const compactProgressBar = filteredLanguages
|
||||
.map((language) => {
|
||||
// const progress = (width * lang.percent) / 100;
|
||||
const progress = ((width - 25) * language.percent) / 100;
|
||||
|
||||
const languageColor = languageColors[language.name] || "#858585";
|
||||
|
||||
const output = `
|
||||
<rect
|
||||
mask="url(#rect-mask)"
|
||||
data-testid="lang-progress"
|
||||
x="${progressOffset}"
|
||||
y="0"
|
||||
width="${progress}"
|
||||
height="8"
|
||||
fill="${languageColor}"
|
||||
/>
|
||||
`;
|
||||
progressOffset += progress;
|
||||
return output;
|
||||
})
|
||||
.join("");
|
||||
|
||||
finalLayout = `
|
||||
<mask id="rect-mask">
|
||||
<rect x="25" y="0" width="${width - 50}" height="8" fill="white" rx="5" />
|
||||
</mask>
|
||||
${compactProgressBar}
|
||||
${createLanguageTextNode({
|
||||
x: 0,
|
||||
y: 25,
|
||||
langs: filteredLanguages,
|
||||
totalSize: 100,
|
||||
}).join("")}
|
||||
`;
|
||||
} else {
|
||||
finalLayout = flexLayout({
|
||||
items: filteredLanguages.length
|
||||
? filteredLanguages.map((language) => {
|
||||
return createTextNode({
|
||||
id: language.name,
|
||||
label: language.name,
|
||||
value: language.text,
|
||||
percent: language.percent,
|
||||
// @ts-ignore
|
||||
progressBarColor: titleColor,
|
||||
// @ts-ignore
|
||||
progressBarBackgroundColor: textColor,
|
||||
hideProgress: hide_progress,
|
||||
});
|
||||
})
|
||||
: [
|
||||
noCodingActivityNode({
|
||||
// @ts-ignore
|
||||
color: textColor,
|
||||
text: i18n.t("wakatimecard.nocodingactivity"),
|
||||
}),
|
||||
],
|
||||
gap: lheight,
|
||||
direction: "column",
|
||||
}).join("");
|
||||
}
|
||||
|
||||
const card = new Card({
|
||||
customTitle: custom_title,
|
||||
defaultTitle: i18n.t("wakatimecard.title"),
|
||||
width: 495,
|
||||
height,
|
||||
border_radius,
|
||||
colors: {
|
||||
titleColor,
|
||||
textColor,
|
||||
iconColor,
|
||||
bgColor,
|
||||
borderColor,
|
||||
},
|
||||
});
|
||||
|
||||
card.setHideBorder(hide_border);
|
||||
card.setHideTitle(hide_title);
|
||||
card.setCSS(
|
||||
`
|
||||
${cssStyles}
|
||||
.lang-name { font: 400 11px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor} }
|
||||
`,
|
||||
);
|
||||
|
||||
return card.render(`
|
||||
<svg x="0" y="0" width="100%">
|
||||
${finalLayout}
|
||||
</svg>
|
||||
`);
|
||||
};
|
||||
|
||||
export { renderWakatimeCard };
|
||||
export default renderWakatimeCard;
|
||||
@@ -1,481 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
import { Card } from "../common/Card.js";
|
||||
import { getCardColors } from "../common/color.js";
|
||||
import { I18n } from "../common/I18n.js";
|
||||
import { clampValue, lowercaseTrim } from "../common/ops.js";
|
||||
import { createProgressNode, flexLayout } from "../common/render.js";
|
||||
import { wakatimeCardLocales } from "../translations.js";
|
||||
|
||||
/** Import language colors.
|
||||
*
|
||||
* @description Here we use the workaround found in
|
||||
* https://stackoverflow.com/questions/66726365/how-should-i-import-json-in-node
|
||||
* since vercel is using v16.14.0 which does not yet support json imports without the
|
||||
* --experimental-json-modules flag.
|
||||
*/
|
||||
import { createRequire } from "module";
|
||||
const require = createRequire(import.meta.url);
|
||||
const languageColors = require("../common/languageColors.json"); // now works
|
||||
|
||||
const DEFAULT_CARD_WIDTH = 495;
|
||||
const MIN_CARD_WIDTH = 250;
|
||||
const COMPACT_LAYOUT_MIN_WIDTH = 400;
|
||||
const DEFAULT_LINE_HEIGHT = 25;
|
||||
const PROGRESSBAR_PADDING = 130;
|
||||
const HIDDEN_PROGRESSBAR_PADDING = 170;
|
||||
const COMPACT_LAYOUT_PROGRESSBAR_PADDING = 25;
|
||||
const TOTAL_TEXT_WIDTH = 275;
|
||||
|
||||
/**
|
||||
* Creates the no coding activity SVG node.
|
||||
*
|
||||
* @param {object} props The function properties.
|
||||
* @param {string} props.color No coding activity text color.
|
||||
* @param {string} props.text No coding activity translated text.
|
||||
* @returns {string} No coding activity SVG node string.
|
||||
*/
|
||||
const noCodingActivityNode = ({ color, text }) => {
|
||||
return `
|
||||
<text x="25" y="11" class="stat bold" fill="${color}">${text}</text>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {import('../fetchers/types').WakaTimeLang} WakaTimeLang
|
||||
*/
|
||||
|
||||
/**
|
||||
* Format language value.
|
||||
*
|
||||
* @param {Object} args The function arguments.
|
||||
* @param {WakaTimeLang} args.lang The language object.
|
||||
* @param {"time" | "percent"} args.display_format The display format of the language node.
|
||||
* @returns {string} The formatted language value.
|
||||
*/
|
||||
const formatLanguageValue = ({ display_format, lang }) => {
|
||||
return display_format === "percent"
|
||||
? `${lang.percent.toFixed(2).toString()} %`
|
||||
: lang.text;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create compact WakaTime layout.
|
||||
*
|
||||
* @param {Object} args The function arguments.
|
||||
* @param {WakaTimeLang} args.lang The languages array.
|
||||
* @param {number} args.x The x position of the language node.
|
||||
* @param {number} args.y The y position of the language node.
|
||||
* @param {"time" | "percent"} args.display_format The display format of the language node.
|
||||
* @returns {string} The compact layout language SVG node.
|
||||
*/
|
||||
const createCompactLangNode = ({ lang, x, y, display_format }) => {
|
||||
// @ts-ignore
|
||||
const color = languageColors[lang.name] || "#858585";
|
||||
const value = formatLanguageValue({ display_format, lang });
|
||||
|
||||
return `
|
||||
<g transform="translate(${x}, ${y})">
|
||||
<circle cx="5" cy="6" r="5" fill="${color}" />
|
||||
<text data-testid="lang-name" x="15" y="10" class='lang-name'>
|
||||
${lang.name} - ${value}
|
||||
</text>
|
||||
</g>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create WakaTime language text node item.
|
||||
*
|
||||
* @param {Object} args The function arguments.
|
||||
* @param {WakaTimeLang[]} args.langs The language objects.
|
||||
* @param {number} args.y The y position of the language node.
|
||||
* @param {"time" | "percent"} args.display_format The display format of the language node.
|
||||
* @param {number} args.card_width Width in px of the card.
|
||||
* @returns {string[]} The language text node items.
|
||||
*/
|
||||
const createLanguageTextNode = ({ langs, y, display_format, card_width }) => {
|
||||
const LEFT_X = 25;
|
||||
const RIGHT_X_BASE = 230;
|
||||
const rightOffset = (card_width - DEFAULT_CARD_WIDTH) / 2;
|
||||
const RIGHT_X = RIGHT_X_BASE + rightOffset;
|
||||
|
||||
return langs.map((lang, index) => {
|
||||
const isLeft = index % 2 === 0;
|
||||
return createCompactLangNode({
|
||||
lang,
|
||||
x: isLeft ? LEFT_X : RIGHT_X,
|
||||
y: y + DEFAULT_LINE_HEIGHT * Math.floor(index / 2),
|
||||
display_format,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Create WakaTime text item.
|
||||
*
|
||||
* @param {Object} args The function arguments.
|
||||
* @param {string} args.id The id of the text node item.
|
||||
* @param {string} args.label The label of the text node item.
|
||||
* @param {string} args.value The value of the text node item.
|
||||
* @param {number} args.index The index of the text node item.
|
||||
* @param {number} args.percent Percentage of the text node item.
|
||||
* @param {boolean=} args.hideProgress Whether to hide the progress bar.
|
||||
* @param {string} args.progressBarColor The color of the progress bar.
|
||||
* @param {string} args.progressBarBackgroundColor The color of the progress bar background.
|
||||
* @param {number} args.progressBarWidth The width of the progress bar.
|
||||
* @returns {string} The text SVG node.
|
||||
*/
|
||||
const createTextNode = ({
|
||||
id,
|
||||
label,
|
||||
value,
|
||||
index,
|
||||
percent,
|
||||
hideProgress,
|
||||
progressBarColor,
|
||||
progressBarBackgroundColor,
|
||||
progressBarWidth,
|
||||
}) => {
|
||||
const staggerDelay = (index + 3) * 150;
|
||||
const cardProgress = hideProgress
|
||||
? null
|
||||
: createProgressNode({
|
||||
x: 110,
|
||||
y: 4,
|
||||
progress: percent,
|
||||
color: progressBarColor,
|
||||
width: progressBarWidth,
|
||||
// @ts-ignore
|
||||
name: label,
|
||||
progressBarBackgroundColor,
|
||||
delay: staggerDelay + 300,
|
||||
});
|
||||
|
||||
return `
|
||||
<g class="stagger" style="animation-delay: ${staggerDelay}ms" transform="translate(25, 0)">
|
||||
<text class="stat bold" y="12.5" data-testid="${id}">${label}:</text>
|
||||
<text
|
||||
class="stat"
|
||||
x="${hideProgress ? HIDDEN_PROGRESSBAR_PADDING : PROGRESSBAR_PADDING + progressBarWidth}"
|
||||
y="12.5"
|
||||
>${value}</text>
|
||||
${cardProgress}
|
||||
</g>
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Recalculating percentages so that, compact layout's progress bar does not break when
|
||||
* hiding languages.
|
||||
*
|
||||
* @param {WakaTimeLang[]} languages The languages array.
|
||||
* @returns {void} The recalculated languages array.
|
||||
*/
|
||||
const recalculatePercentages = (languages) => {
|
||||
const totalSum = languages.reduce(
|
||||
(totalSum, language) => totalSum + language.percent,
|
||||
0,
|
||||
);
|
||||
const weight = +(100 / totalSum).toFixed(2);
|
||||
languages.forEach((language) => {
|
||||
language.percent = +(language.percent * weight).toFixed(2);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Retrieves CSS styles for a card.
|
||||
*
|
||||
* @param {Object} colors The colors to use for the card.
|
||||
* @param {string} colors.titleColor The title color.
|
||||
* @param {string} colors.textColor The text color.
|
||||
* @returns {string} Card CSS styles.
|
||||
*/
|
||||
const getStyles = ({
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
titleColor,
|
||||
textColor,
|
||||
}) => {
|
||||
return `
|
||||
.stat {
|
||||
font: 600 14px 'Segoe UI', Ubuntu, "Helvetica Neue", Sans-Serif; fill: ${textColor};
|
||||
}
|
||||
@supports(-moz-appearance: auto) {
|
||||
/* Selector detects Firefox */
|
||||
.stat { font-size:12px; }
|
||||
}
|
||||
.stagger {
|
||||
opacity: 0;
|
||||
animation: fadeInAnimation 0.3s ease-in-out forwards;
|
||||
}
|
||||
.not_bold { font-weight: 400 }
|
||||
.bold { font-weight: 700 }
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* Normalize incoming width (string or number) and clamp to minimum.
|
||||
*
|
||||
* @param {Object} args The function arguments.
|
||||
* @param {WakaTimeOptions["layout"] | undefined} args.layout The incoming layout value.
|
||||
* @param {number|undefined} args.value The incoming width value.
|
||||
* @returns {number} The normalized width value.
|
||||
*/
|
||||
const normalizeCardWidth = ({ value, layout }) => {
|
||||
if (value === undefined || value === null || isNaN(value)) {
|
||||
return DEFAULT_CARD_WIDTH;
|
||||
}
|
||||
return Math.max(
|
||||
layout === "compact" ? COMPACT_LAYOUT_MIN_WIDTH : MIN_CARD_WIDTH,
|
||||
value,
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {import('../fetchers/types').WakaTimeData} WakaTimeData
|
||||
* @typedef {import('./types').WakaTimeOptions} WakaTimeOptions
|
||||
*/
|
||||
|
||||
/**
|
||||
* Renders WakaTime card.
|
||||
*
|
||||
* @param {Partial<WakaTimeData>} stats WakaTime stats.
|
||||
* @param {Partial<WakaTimeOptions>} options Card options.
|
||||
* @returns {string} WakaTime card SVG.
|
||||
*/
|
||||
const renderWakatimeCard = (stats = {}, options = { hide: [] }) => {
|
||||
let { languages = [] } = stats;
|
||||
const {
|
||||
hide_title = false,
|
||||
hide_border = false,
|
||||
card_width,
|
||||
hide,
|
||||
line_height = DEFAULT_LINE_HEIGHT,
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
theme = "default",
|
||||
hide_progress,
|
||||
custom_title,
|
||||
locale,
|
||||
layout,
|
||||
langs_count = languages.length,
|
||||
border_radius,
|
||||
border_color,
|
||||
display_format = "time",
|
||||
disable_animations,
|
||||
} = options;
|
||||
|
||||
const normalizedWidth = normalizeCardWidth({ value: card_width, layout });
|
||||
|
||||
const shouldHideLangs = Array.isArray(hide) && hide.length > 0;
|
||||
if (shouldHideLangs) {
|
||||
const languagesToHide = new Set(hide.map((lang) => lowercaseTrim(lang)));
|
||||
languages = languages.filter(
|
||||
(lang) => !languagesToHide.has(lowercaseTrim(lang.name)),
|
||||
);
|
||||
}
|
||||
|
||||
// Since the percentages are sorted in descending order, we can just
|
||||
// slice from the beginning without sorting.
|
||||
languages = languages.slice(0, langs_count);
|
||||
recalculatePercentages(languages);
|
||||
|
||||
const i18n = new I18n({
|
||||
locale,
|
||||
translations: wakatimeCardLocales,
|
||||
});
|
||||
|
||||
const lheight = parseInt(String(line_height), 10);
|
||||
|
||||
const langsCount = clampValue(langs_count, 1, langs_count);
|
||||
|
||||
// returns theme based colors with proper overrides and defaults
|
||||
const { titleColor, textColor, iconColor, bgColor, borderColor } =
|
||||
getCardColors({
|
||||
title_color,
|
||||
icon_color,
|
||||
text_color,
|
||||
bg_color,
|
||||
border_color,
|
||||
theme,
|
||||
});
|
||||
|
||||
const filteredLanguages = languages
|
||||
.filter((language) => language.hours || language.minutes)
|
||||
.slice(0, langsCount);
|
||||
|
||||
// Calculate the card height depending on how many items there are
|
||||
// but if rank circle is visible clamp the minimum height to `150`
|
||||
let height = Math.max(45 + (filteredLanguages.length + 1) * lheight, 150);
|
||||
|
||||
const cssStyles = getStyles({
|
||||
titleColor,
|
||||
textColor,
|
||||
});
|
||||
|
||||
let finalLayout = "";
|
||||
|
||||
// RENDER COMPACT LAYOUT
|
||||
if (layout === "compact") {
|
||||
const width = normalizedWidth - 5;
|
||||
height =
|
||||
90 + Math.round(filteredLanguages.length / 2) * DEFAULT_LINE_HEIGHT;
|
||||
|
||||
// progressOffset holds the previous language's width and used to offset the next language
|
||||
// so that we can stack them one after another, like this: [--][----][---]
|
||||
let progressOffset = 0;
|
||||
const compactProgressBar = filteredLanguages
|
||||
.map((language) => {
|
||||
const progress =
|
||||
((width - COMPACT_LAYOUT_PROGRESSBAR_PADDING) * language.percent) /
|
||||
100;
|
||||
|
||||
// @ts-ignore
|
||||
const languageColor = languageColors[language.name] || "#858585";
|
||||
|
||||
const output = `
|
||||
<rect
|
||||
mask="url(#rect-mask)"
|
||||
data-testid="lang-progress"
|
||||
x="${progressOffset}"
|
||||
y="0"
|
||||
width="${progress}"
|
||||
height="8"
|
||||
fill="${languageColor}"
|
||||
/>
|
||||
`;
|
||||
progressOffset += progress;
|
||||
return output;
|
||||
})
|
||||
.join("");
|
||||
|
||||
finalLayout = `
|
||||
<mask id="rect-mask">
|
||||
<rect x="${COMPACT_LAYOUT_PROGRESSBAR_PADDING}" y="0" width="${width - 2 * COMPACT_LAYOUT_PROGRESSBAR_PADDING}" height="8" fill="white" rx="5" />
|
||||
</mask>
|
||||
${compactProgressBar}
|
||||
${
|
||||
filteredLanguages.length
|
||||
? createLanguageTextNode({
|
||||
y: 25,
|
||||
langs: filteredLanguages,
|
||||
display_format,
|
||||
card_width: normalizedWidth,
|
||||
}).join("")
|
||||
: noCodingActivityNode({
|
||||
// @ts-ignore
|
||||
color: textColor,
|
||||
text: stats.is_coding_activity_visible
|
||||
? stats.is_other_usage_visible
|
||||
? i18n.t("wakatimecard.nocodingactivity")
|
||||
: i18n.t("wakatimecard.nocodedetails")
|
||||
: i18n.t("wakatimecard.notpublic"),
|
||||
})
|
||||
}
|
||||
`;
|
||||
} else {
|
||||
finalLayout = flexLayout({
|
||||
items: filteredLanguages.length
|
||||
? filteredLanguages.map((language, index) => {
|
||||
return createTextNode({
|
||||
id: language.name,
|
||||
label: language.name,
|
||||
value: formatLanguageValue({ display_format, lang: language }),
|
||||
index,
|
||||
percent: language.percent,
|
||||
// @ts-ignore
|
||||
progressBarColor: titleColor,
|
||||
// @ts-ignore
|
||||
progressBarBackgroundColor: textColor,
|
||||
hideProgress: hide_progress,
|
||||
progressBarWidth: normalizedWidth - TOTAL_TEXT_WIDTH,
|
||||
});
|
||||
})
|
||||
: [
|
||||
noCodingActivityNode({
|
||||
// @ts-ignore
|
||||
color: textColor,
|
||||
text: stats.is_coding_activity_visible
|
||||
? stats.is_other_usage_visible
|
||||
? i18n.t("wakatimecard.nocodingactivity")
|
||||
: i18n.t("wakatimecard.nocodedetails")
|
||||
: i18n.t("wakatimecard.notpublic"),
|
||||
}),
|
||||
],
|
||||
gap: lheight,
|
||||
direction: "column",
|
||||
}).join("");
|
||||
}
|
||||
|
||||
// Get title range text
|
||||
let titleText = i18n.t("wakatimecard.title");
|
||||
switch (stats.range) {
|
||||
case "last_7_days":
|
||||
titleText += ` (${i18n.t("wakatimecard.last7days")})`;
|
||||
break;
|
||||
case "last_year":
|
||||
titleText += ` (${i18n.t("wakatimecard.lastyear")})`;
|
||||
break;
|
||||
}
|
||||
|
||||
const card = new Card({
|
||||
customTitle: custom_title,
|
||||
defaultTitle: titleText,
|
||||
width: normalizedWidth,
|
||||
height,
|
||||
border_radius,
|
||||
colors: {
|
||||
titleColor,
|
||||
textColor,
|
||||
iconColor,
|
||||
bgColor,
|
||||
borderColor,
|
||||
},
|
||||
});
|
||||
|
||||
if (disable_animations) {
|
||||
card.disableAnimations();
|
||||
}
|
||||
|
||||
card.setHideBorder(hide_border);
|
||||
card.setHideTitle(hide_title);
|
||||
card.setCSS(
|
||||
`
|
||||
${cssStyles}
|
||||
@keyframes slideInAnimation {
|
||||
from {
|
||||
width: 0;
|
||||
}
|
||||
to {
|
||||
width: calc(100%-100px);
|
||||
}
|
||||
}
|
||||
@keyframes growWidthAnimation {
|
||||
from {
|
||||
width: 0;
|
||||
}
|
||||
to {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.lang-name { font: 400 11px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor} }
|
||||
#rect-mask rect{
|
||||
animation: slideInAnimation 1s ease-in-out forwards;
|
||||
}
|
||||
.lang-progress{
|
||||
animation: growWidthAnimation 0.6s ease-in-out forwards;
|
||||
}
|
||||
`,
|
||||
);
|
||||
|
||||
return card.render(`
|
||||
<svg x="0" y="0" width="100%">
|
||||
${finalLayout}
|
||||
</svg>
|
||||
`);
|
||||
};
|
||||
|
||||
export { renderWakatimeCard };
|
||||
export default renderWakatimeCard;
|
||||
@@ -1,25 +1,87 @@
|
||||
// @ts-check
|
||||
import { getAnimations } from "../getStyles";
|
||||
import { encodeHTML, flexLayout } from "./utils";
|
||||
|
||||
import { encodeHTML } from "./html.js";
|
||||
import { flexLayout } from "./render.js";
|
||||
/** Card colors. */
|
||||
export interface CardColors {
|
||||
/** Title color. */
|
||||
titleColor: string;
|
||||
/** Text color. */
|
||||
textColor: string;
|
||||
/** Icon color. */
|
||||
iconColor: string;
|
||||
/** Background color. */
|
||||
bgColor: string;
|
||||
/** Border color. */
|
||||
borderColor: string;
|
||||
}
|
||||
|
||||
class Card {
|
||||
/** Accessibility label. */
|
||||
interface AccessibilityLabel {
|
||||
/** The label to display. */
|
||||
title: string;
|
||||
/** The value to display. */
|
||||
desc: string;
|
||||
}
|
||||
|
||||
/** Card properties. */
|
||||
interface CardProps {
|
||||
/** Card width. */
|
||||
width: number;
|
||||
/** Card height. */
|
||||
height: number;
|
||||
/** Card border radius. */
|
||||
border_radius: number;
|
||||
/** Card colors. */
|
||||
colors: CardColors | {};
|
||||
/** Card title. */
|
||||
customTitle?: string;
|
||||
/** Card default title. */
|
||||
defaultTitle?: string;
|
||||
/** Card title prefix icon. */
|
||||
titlePrefixIcon?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Card class.
|
||||
*/
|
||||
export class Card {
|
||||
/** Card width. */
|
||||
width: number;
|
||||
/** Card height. */
|
||||
height: number;
|
||||
/** Whether the card border is hidden. */
|
||||
hideBorder: boolean;
|
||||
/** Whether the card title is hidden. */
|
||||
hideTitle: boolean;
|
||||
/** Border radius. */
|
||||
border_radius: number;
|
||||
/** Card colors. */
|
||||
colors: CardColors | {};
|
||||
/** Card title. */
|
||||
title: string;
|
||||
/** Card css. */
|
||||
css: string;
|
||||
/** Card x padding. */
|
||||
paddingX: number;
|
||||
/** Card y padding. */
|
||||
paddingY: number;
|
||||
/** Card title prefix icon. */
|
||||
titlePrefixIcon?: string;
|
||||
/** Whether the card is animated. */
|
||||
animations: boolean;
|
||||
/** Accessibility label title. */
|
||||
a11yTitle: string;
|
||||
/** Accessibility label description. */
|
||||
a11yDesc: string;
|
||||
/**
|
||||
* Creates a new card instance.
|
||||
*
|
||||
* @param {object} args Card arguments.
|
||||
* @param {number=} args.width Card width.
|
||||
* @param {number=} args.height Card height.
|
||||
* @param {number=} args.border_radius Card border radius.
|
||||
* @param {string=} args.customTitle Card custom title.
|
||||
* @param {string=} args.defaultTitle Card default title.
|
||||
* @param {string=} args.titlePrefixIcon Card title prefix icon.
|
||||
* @param {object} [args.colors={}] Card colors arguments.
|
||||
* @param {string=} args.colors.titleColor Card title color.
|
||||
* @param {string=} args.colors.textColor Card text color.
|
||||
* @param {string=} args.colors.iconColor Card icon color.
|
||||
* @param {string|string[]=} args.colors.bgColor Card background color.
|
||||
* @param {string=} args.colors.borderColor Card border color.
|
||||
* @param {object} args
|
||||
* @param {number?=} args.width
|
||||
* @param {number?=} args.height
|
||||
* @param {number?=} args.border_radius
|
||||
* @param {string?=} args.customTitle
|
||||
* @param {string?=} args.defaultTitle
|
||||
* @param {string?=} args.titlePrefixIcon
|
||||
* @param {ReturnType<import('./utils').getCardColors>?=} args.colors
|
||||
*/
|
||||
constructor({
|
||||
width = 100,
|
||||
@@ -29,7 +91,7 @@ class Card {
|
||||
customTitle,
|
||||
defaultTitle = "",
|
||||
titlePrefixIcon,
|
||||
}) {
|
||||
}: CardProps) {
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
|
||||
@@ -41,9 +103,9 @@ class Card {
|
||||
// returns theme based colors with proper overrides and defaults
|
||||
this.colors = colors;
|
||||
this.title =
|
||||
customTitle === undefined
|
||||
? encodeHTML(defaultTitle)
|
||||
: encodeHTML(customTitle);
|
||||
customTitle !== undefined
|
||||
? encodeHTML(customTitle)
|
||||
: encodeHTML(defaultTitle);
|
||||
|
||||
this.css = "";
|
||||
|
||||
@@ -55,45 +117,36 @@ class Card {
|
||||
this.a11yDesc = "";
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {void}
|
||||
*/
|
||||
disableAnimations() {
|
||||
this.animations = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Object} props The props object.
|
||||
* @param {string} props.title Accessibility title.
|
||||
* @param {string} props.desc Accessibility description.
|
||||
* @returns {void}
|
||||
* @param {{title: string, desc: string}} prop
|
||||
*/
|
||||
setAccessibilityLabel({ title, desc }) {
|
||||
setAccessibilityLabel({ title, desc }: AccessibilityLabel) {
|
||||
this.a11yTitle = title;
|
||||
this.a11yDesc = desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} value The CSS to add to the card.
|
||||
* @returns {void}
|
||||
* @param {string} value
|
||||
*/
|
||||
setCSS(value) {
|
||||
setCSS(value: string) {
|
||||
this.css = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} value Whether to hide the border or not.
|
||||
* @returns {void}
|
||||
* @param {boolean} value
|
||||
*/
|
||||
setHideBorder(value) {
|
||||
setHideBorder(value: boolean) {
|
||||
this.hideBorder = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {boolean} value Whether to hide the title or not.
|
||||
* @returns {void}
|
||||
* @param {boolean} value
|
||||
*/
|
||||
setHideTitle(value) {
|
||||
setHideTitle(value: boolean) {
|
||||
this.hideTitle = value;
|
||||
if (value) {
|
||||
this.height -= 30;
|
||||
@@ -101,16 +154,12 @@ class Card {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {string} text The title to set.
|
||||
* @returns {void}
|
||||
* @param {string} text
|
||||
*/
|
||||
setTitle(text) {
|
||||
setTitle(text: string) {
|
||||
this.title = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string} The rendered card title.
|
||||
*/
|
||||
renderTitle() {
|
||||
const titleText = `
|
||||
<text
|
||||
@@ -140,20 +189,15 @@ class Card {
|
||||
transform="translate(${this.paddingX}, ${this.paddingY})"
|
||||
>
|
||||
${flexLayout({
|
||||
items: [this.titlePrefixIcon ? prefixIcon : "", titleText],
|
||||
items: [this.titlePrefixIcon && prefixIcon, titleText],
|
||||
gap: 25,
|
||||
}).join("")}
|
||||
</g>
|
||||
`;
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns {string} The rendered card gradient.
|
||||
*/
|
||||
renderGradient() {
|
||||
if (typeof this.colors.bgColor !== "object") {
|
||||
return "";
|
||||
}
|
||||
if (typeof this.colors.bgColor !== "object") return "";
|
||||
|
||||
const gradients = this.colors.bgColor.slice(1);
|
||||
return typeof this.colors.bgColor === "object"
|
||||
@@ -164,7 +208,7 @@ class Card {
|
||||
gradientTransform="rotate(${this.colors.bgColor[0]})"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
>
|
||||
${gradients.map((grad, index) => {
|
||||
${gradients.map((grad: string, index: number) => {
|
||||
let offset = (index * 100) / (gradients.length - 1);
|
||||
return `<stop offset="${offset}%" stop-color="#${grad}" />`;
|
||||
})}
|
||||
@@ -175,37 +219,9 @@ class Card {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves css animations for a card.
|
||||
*
|
||||
* @returns {string} Animation css.
|
||||
* @param {string} body
|
||||
*/
|
||||
getAnimations = () => {
|
||||
return `
|
||||
/* Animations */
|
||||
@keyframes scaleInAnimation {
|
||||
from {
|
||||
transform: translate(-5px, 5px) scale(0);
|
||||
}
|
||||
to {
|
||||
transform: translate(-5px, 5px) scale(1);
|
||||
}
|
||||
}
|
||||
@keyframes fadeInAnimation {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
`;
|
||||
};
|
||||
|
||||
/**
|
||||
* @param {string} body The inner body of the card.
|
||||
* @returns {string} The rendered card.
|
||||
*/
|
||||
render(body) {
|
||||
render(body: string) {
|
||||
return `
|
||||
<svg
|
||||
width="${this.width}"
|
||||
@@ -230,7 +246,7 @@ class Card {
|
||||
}
|
||||
${this.css}
|
||||
|
||||
${process.env.NODE_ENV === "test" ? "" : this.getAnimations()}
|
||||
${process.env.NODE_ENV === "test" ? "" : getAnimations()}
|
||||
${
|
||||
this.animations === false
|
||||
? `* { animation-duration: 0s !important; animation-delay: 0s !important; }`
|
||||
@@ -270,6 +286,3 @@ class Card {
|
||||
`;
|
||||
}
|
||||
}
|
||||
|
||||
export { Card };
|
||||
export default Card;
|
||||
@@ -1,43 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
const FALLBACK_LOCALE = "en";
|
||||
|
||||
/**
|
||||
* I18n translation class.
|
||||
*/
|
||||
class I18n {
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param {Object} options Options.
|
||||
* @param {string=} options.locale Locale.
|
||||
* @param {any} options.translations Translations.
|
||||
*/
|
||||
constructor({ locale, translations }) {
|
||||
this.locale = locale || FALLBACK_LOCALE;
|
||||
this.translations = translations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get translation.
|
||||
*
|
||||
* @param {string} str String to translate.
|
||||
* @returns {string} Translated string.
|
||||
*/
|
||||
t(str) {
|
||||
if (!this.translations[str]) {
|
||||
throw new Error(`${str} Translation string not found`);
|
||||
}
|
||||
|
||||
if (!this.translations[str][this.locale]) {
|
||||
throw new Error(
|
||||
`'${str}' translation not found for locale '${this.locale}'`,
|
||||
);
|
||||
}
|
||||
|
||||
return this.translations[str][this.locale];
|
||||
}
|
||||
}
|
||||
|
||||
export { I18n };
|
||||
export default I18n;
|
||||
@@ -0,0 +1,37 @@
|
||||
type Translations = Record<string, Record<string, string>>;
|
||||
|
||||
/**
|
||||
* I18n translation class.
|
||||
*/
|
||||
export class I18n {
|
||||
/** The language locale. */
|
||||
locale?: string;
|
||||
/** The translations object. */
|
||||
translations: Translations;
|
||||
/** The fallback language locale. */
|
||||
fallbackLocale: string;
|
||||
|
||||
constructor({
|
||||
locale,
|
||||
translations,
|
||||
}: {
|
||||
locale?: string;
|
||||
translations: Translations;
|
||||
}) {
|
||||
this.locale = locale;
|
||||
this.translations = translations;
|
||||
this.fallbackLocale = "en";
|
||||
}
|
||||
|
||||
t(str: string) {
|
||||
if (!this.translations[str]) {
|
||||
throw new Error(`${str} Translation string not found`);
|
||||
}
|
||||
|
||||
if (!this.translations[str][this.locale || this.fallbackLocale]) {
|
||||
throw new Error(`${str} Translation locale not found`);
|
||||
}
|
||||
|
||||
return this.translations[str][this.locale || this.fallbackLocale];
|
||||
}
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
import { renderError } from "./render.js";
|
||||
import { blacklist } from "./blacklist.js";
|
||||
import { whitelist, gistWhitelist } from "./envs.js";
|
||||
|
||||
const NOT_WHITELISTED_USERNAME_MESSAGE = "This username is not whitelisted";
|
||||
const NOT_WHITELISTED_GIST_MESSAGE = "This gist ID is not whitelisted";
|
||||
const BLACKLISTED_MESSAGE = "This username is blacklisted";
|
||||
|
||||
/**
|
||||
* Guards access using whitelist/blacklist.
|
||||
*
|
||||
* @param {Object} args The parameters object.
|
||||
* @param {any} args.res The response object.
|
||||
* @param {string} args.id Resource identifier (username or gist id).
|
||||
* @param {"username"|"gist"|"wakatime"} args.type The type of identifier.
|
||||
* @param {{ title_color?: string, text_color?: string, bg_color?: string, border_color?: string, theme?: string }} args.colors Color options for the error card.
|
||||
* @returns {{ isPassed: boolean, result?: any }} The result object indicating success or failure.
|
||||
*/
|
||||
const guardAccess = ({ res, id, type, colors }) => {
|
||||
if (!["username", "gist", "wakatime"].includes(type)) {
|
||||
throw new Error(
|
||||
'Invalid type. Expected "username", "gist", or "wakatime".',
|
||||
);
|
||||
}
|
||||
|
||||
const currentWhitelist = type === "gist" ? gistWhitelist : whitelist;
|
||||
const notWhitelistedMsg =
|
||||
type === "gist"
|
||||
? NOT_WHITELISTED_GIST_MESSAGE
|
||||
: NOT_WHITELISTED_USERNAME_MESSAGE;
|
||||
|
||||
if (Array.isArray(currentWhitelist) && !currentWhitelist.includes(id)) {
|
||||
const result = res.send(
|
||||
renderError({
|
||||
message: notWhitelistedMsg,
|
||||
secondaryMessage: "Please deploy your own instance",
|
||||
renderOptions: {
|
||||
...colors,
|
||||
show_repo_link: false,
|
||||
},
|
||||
}),
|
||||
);
|
||||
return { isPassed: false, result };
|
||||
}
|
||||
|
||||
if (
|
||||
type === "username" &&
|
||||
currentWhitelist === undefined &&
|
||||
blacklist.includes(id)
|
||||
) {
|
||||
const result = res.send(
|
||||
renderError({
|
||||
message: BLACKLISTED_MESSAGE,
|
||||
secondaryMessage: "Please deploy your own instance",
|
||||
renderOptions: {
|
||||
...colors,
|
||||
show_repo_link: false,
|
||||
},
|
||||
}),
|
||||
);
|
||||
return { isPassed: false, result };
|
||||
}
|
||||
|
||||
return { isPassed: true };
|
||||
};
|
||||
|
||||
export { guardAccess };
|
||||
@@ -1,10 +0,0 @@
|
||||
const blacklist = [
|
||||
"renovate-bot",
|
||||
"technote-space",
|
||||
"sw-yx",
|
||||
"YourUsername",
|
||||
"[YourUsername]",
|
||||
];
|
||||
|
||||
export { blacklist };
|
||||
export default blacklist;
|
||||
@@ -0,0 +1,2 @@
|
||||
/** User blacklist. */
|
||||
export const blacklist = ["renovate-bot", "technote-space", "sw-yx"];
|
||||
@@ -1,153 +0,0 @@
|
||||
// @ts-check
|
||||
|
||||
import { clampValue } from "./ops.js";
|
||||
|
||||
const MIN = 60;
|
||||
const HOUR = 60 * MIN;
|
||||
const DAY = 24 * HOUR;
|
||||
|
||||
/**
|
||||
* Common durations in seconds.
|
||||
*/
|
||||
const DURATIONS = {
|
||||
ONE_MINUTE: MIN,
|
||||
FIVE_MINUTES: 5 * MIN,
|
||||
TEN_MINUTES: 10 * MIN,
|
||||
FIFTEEN_MINUTES: 15 * MIN,
|
||||
THIRTY_MINUTES: 30 * MIN,
|
||||
|
||||
TWO_HOURS: 2 * HOUR,
|
||||
FOUR_HOURS: 4 * HOUR,
|
||||
SIX_HOURS: 6 * HOUR,
|
||||
EIGHT_HOURS: 8 * HOUR,
|
||||
TWELVE_HOURS: 12 * HOUR,
|
||||
|
||||
ONE_DAY: DAY,
|
||||
TWO_DAY: 2 * DAY,
|
||||
SIX_DAY: 6 * DAY,
|
||||
TEN_DAY: 10 * DAY,
|
||||
};
|
||||
|
||||
/**
|
||||
* Common cache TTL values in seconds.
|
||||
*/
|
||||
const CACHE_TTL = {
|
||||
STATS_CARD: {
|
||||
DEFAULT: DURATIONS.ONE_DAY,
|
||||
MIN: DURATIONS.TWELVE_HOURS,
|
||||
MAX: DURATIONS.TWO_DAY,
|
||||
},
|
||||
TOP_LANGS_CARD: {
|
||||
DEFAULT: DURATIONS.SIX_DAY,
|
||||
MIN: DURATIONS.TWO_DAY,
|
||||
MAX: DURATIONS.TEN_DAY,
|
||||
},
|
||||
PIN_CARD: {
|
||||
DEFAULT: DURATIONS.TEN_DAY,
|
||||
MIN: DURATIONS.ONE_DAY,
|
||||
MAX: DURATIONS.TEN_DAY,
|
||||
},
|
||||
GIST_CARD: {
|
||||
DEFAULT: DURATIONS.TWO_DAY,
|
||||
MIN: DURATIONS.ONE_DAY,
|
||||
MAX: DURATIONS.TEN_DAY,
|
||||
},
|
||||
WAKATIME_CARD: {
|
||||
DEFAULT: DURATIONS.ONE_DAY,
|
||||
MIN: DURATIONS.TWELVE_HOURS,
|
||||
MAX: DURATIONS.TWO_DAY,
|
||||
},
|
||||
ERROR: DURATIONS.TEN_MINUTES,
|
||||
};
|
||||
|
||||
/**
|
||||
* Resolves the cache seconds based on the requested, default, min, and max values.
|
||||
*
|
||||
* @param {Object} args The parameters object.
|
||||
* @param {number} args.requested The requested cache seconds.
|
||||
* @param {number} args.def The default cache seconds.
|
||||
* @param {number} args.min The minimum cache seconds.
|
||||
* @param {number} args.max The maximum cache seconds.
|
||||
* @returns {number} The resolved cache seconds.
|
||||
*/
|
||||
const resolveCacheSeconds = ({ requested, def, min, max }) => {
|
||||
let cacheSeconds = clampValue(isNaN(requested) ? def : requested, min, max);
|
||||
|
||||
if (process.env.CACHE_SECONDS) {
|
||||
const envCacheSeconds = parseInt(process.env.CACHE_SECONDS, 10);
|
||||
if (!isNaN(envCacheSeconds)) {
|
||||
cacheSeconds = envCacheSeconds;
|
||||
}
|
||||
}
|
||||
|
||||
return cacheSeconds;
|
||||
};
|
||||
|
||||
/**
|
||||
* Disables caching by setting appropriate headers on the response object.
|
||||
*
|
||||
* @param {any} res The response object.
|
||||
*/
|
||||
const disableCaching = (res) => {
|
||||
// Disable caching for browsers, shared caches/CDNs, and GitHub Camo.
|
||||
res.setHeader(
|
||||
"Cache-Control",
|
||||
"no-cache, no-store, must-revalidate, max-age=0, s-maxage=0",
|
||||
);
|
||||
res.setHeader("Pragma", "no-cache");
|
||||
res.setHeader("Expires", "0");
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the Cache-Control headers on the response object.
|
||||
*
|
||||
* @param {any} res The response object.
|
||||
* @param {number} cacheSeconds The cache seconds to set in the headers.
|
||||
*/
|
||||
const setCacheHeaders = (res, cacheSeconds) => {
|
||||
if (cacheSeconds < 1 || process.env.NODE_ENV === "development") {
|
||||
disableCaching(res);
|
||||
return;
|
||||
}
|
||||
|
||||
res.setHeader(
|
||||
"Cache-Control",
|
||||
`max-age=${cacheSeconds}, ` +
|
||||
`s-maxage=${cacheSeconds}, ` +
|
||||
`stale-while-revalidate=${DURATIONS.ONE_DAY}`,
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Sets the Cache-Control headers for error responses on the response object.
|
||||
*
|
||||
* @param {any} res The response object.
|
||||
*/
|
||||
const setErrorCacheHeaders = (res) => {
|
||||
const envCacheSeconds = process.env.CACHE_SECONDS
|
||||
? parseInt(process.env.CACHE_SECONDS, 10)
|
||||
: NaN;
|
||||
if (
|
||||
(!isNaN(envCacheSeconds) && envCacheSeconds < 1) ||
|
||||
process.env.NODE_ENV === "development"
|
||||
) {
|
||||
disableCaching(res);
|
||||
return;
|
||||
}
|
||||
|
||||
// Use lower cache period for errors.
|
||||
res.setHeader(
|
||||
"Cache-Control",
|
||||
`max-age=${CACHE_TTL.ERROR}, ` +
|
||||
`s-maxage=${CACHE_TTL.ERROR}, ` +
|
||||
`stale-while-revalidate=${DURATIONS.ONE_DAY}`,
|
||||
);
|
||||
};
|
||||
|
||||
export {
|
||||
resolveCacheSeconds,
|
||||
setCacheHeaders,
|
||||
setErrorCacheHeaders,
|
||||
DURATIONS,
|
||||
CACHE_TTL,
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user