Skip to content

Commit

Permalink
chore: add some logs
Browse files Browse the repository at this point in the history
  • Loading branch information
veaba committed Jul 16, 2022
1 parent 9a13364 commit 4e0c6b6
Show file tree
Hide file tree
Showing 8 changed files with 163 additions and 55 deletions.
10 changes: 6 additions & 4 deletions config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,26 @@ import { ConfigItem } from "./src/core/types"
* height: svg height
* width: svg width
* fontSize: svg login name width
* isRadius: need radius for avatar, default:true // TODO
*/
const config: ConfigItem =
{
// https://github.com/veaba/contributors
'veaba/contributors': {
ignore: [], //
size:100,
height: 420,
size: 64,
height: 200,
width: 800,
fontSize: 20
},
// https://github.com/vuejs-translations/docs-zh-cn
'vuejs-translations/docs-zh-cn': {
ignore: [], // if you need ignore some users
size:64,
height: 300,
size: 80,
height: 200,
width: 800,
fontSize: 10,
isRadius: false,
}
}

Expand Down
70 changes: 35 additions & 35 deletions repos/veaba/contributors.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
89 changes: 89 additions & 0 deletions repos/vuejs-translations/docs-zh-cn.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script setup lang="ts">
import Home from './pages/Home.vue'
import DisplaySVG from './pages/DisplaySVG.vue'
</script>

<template>
<Home></Home>
<DisplaySVG></DisplaySVG>
<footer>
<p>Copyright @ 2022 <a href="https://github.com/veaba/" target="_blank" rel="noopener noreferrer">Veaba</a></p>
</footer>
Expand Down
22 changes: 18 additions & 4 deletions src/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { UserConfig, UserItem } from './types';
import { getOwnerRepo } from './utils';

import config from '../../config'
import console from 'node:console';

interface TypesContributors {
repo: string;
Expand Down Expand Up @@ -49,6 +50,7 @@ const generateUserListSVG = async (userList: UserItem[], config: UserConfig) =>
const baseSize = config.size || BASE_SIZE
const fontSize = config.fontSize || FONT_SIZE

const isRadius = config.isRadius !== false // default need radius => 50%;
const outSize = fontSize + baseSize
const oneRowMax = Math.floor(svgWidth / outSize)

Expand All @@ -63,7 +65,8 @@ const generateUserListSVG = async (userList: UserItem[], config: UserConfig) =>
oneRowMax,
outSize,
svgWidth,
svgHeight
svgHeight,
isRadius,
})

return `${svgStart(svgWidth, svgHeight)}
Expand All @@ -82,6 +85,18 @@ const saveSVG = async (ownerRepo: string) => {

const options: UserConfig = config[ownerRepo]

// TODO add test log
let name = ownerRepo === 'veaba/contributors' ? ownerRepo.padEnd(29, ' ') : ownerRepo
name += ' =>'
if (options.isRadius !== false) {

console.log(name, 'need radius=>')
} else {
console.log(name, 'not need radius=>')
}



try {
const controller = new AbortController();
const svgStr = await generateUserListSVG(listTen, options)
Expand All @@ -96,7 +111,6 @@ const saveSVG = async (ownerRepo: string) => {
}


const ownerRepo = 'veaba/contributors';
saveSVG(ownerRepo)

saveSVG('veaba/contributors')
saveSVG('vuejs-translations/docs-zh-cn')

12 changes: 6 additions & 6 deletions src/core/svg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,13 @@ export const svgBlock = async (userItem: UserItem, xIndex: number, yIndex: numbe
const textX = getTextX(yIndex, svgConfig) + autoCenter(childrenLen, svgConfig);
const textY = getTextY(xIndex, svgConfig)

console.log(
` (xIndex,yIndex) => ( ${xIndex}, ${yIndex} )
(getImageX,getImageY) => ( ${imageX}, ${imageY} )
(getTextX,getTextY) => ( ${textX}, ${textY} )`
)
// console.log(
// ` (xIndex,yIndex) => ( ${xIndex}, ${yIndex} )
// (getImageX,getImageY) => ( ${imageX}, ${imageY} )
// (getTextX,getTextY) => ( ${textX}, ${textY} )`
// )

console.log('\n')
// console.log('\n')

const localImagePath = 'public/avatars/' + userItem.id + '.jpg'
const base64Image = await imagePathToBase64(localImagePath)
Expand Down
2 changes: 2 additions & 0 deletions src/core/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface UserConfig {
width: number
fontSize: number
size: number
isRadius?: boolean
}
export interface ConfigItem {
[key: string]: UserConfig
Expand All @@ -28,4 +29,5 @@ export interface SvgConfig {
svgWidth: number
svgHeight: number
outSize: number
isRadius: boolean
}
9 changes: 5 additions & 4 deletions src/pages/Home.vue → src/pages/DisplaySVG.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script setup lang="ts">
import veabaSvg from '../../repos/veaba/contributors.svg'
// import docsZhCN from '../../repos/vuejs-translations/docs-zh-cn.svg'
import docsZhCN from '../../repos/vuejs-translations/docs-zh-cn.svg'
import circleSVG from '../assets/circle.svg'
const veabaSvgData = veabaSvg
// const docsZhCNData = docsZhCN
const docsZhCNData = docsZhCN
const circleSVGData = circleSVG
</script>

Expand All @@ -13,8 +14,8 @@ const circleSVGData = circleSVG
<h1> SVG veaba/contributor demo</h1>
<div v-html="veabaSvgData" class="divSVG"></div>

<!-- <h1> SVG vuejs-translations/docs-zh-cn demo</h1>
<div v-html="docsZhCNData" class="divSVG"></div> -->
<h1> SVG vuejs-translations/docs-zh-cn demo</h1>
<div v-html="docsZhCNData" class="divSVG"></div>

<h1> SVG border-radius </h1>
<div v-html="circleSVGData" class="divSVG"></div>
Expand Down

0 comments on commit 4e0c6b6

Please sign in to comment.