Skip to content

Commit 8926e29

Browse files
committed
Remove stats and studio pages along with their associated scripts and header partial
1 parent 743c858 commit 8926e29

15 files changed

Lines changed: 27 additions & 1432 deletions

File tree

src/components/card-renderer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { GitHubStats, CardOptions } from '../types.js';
1+
import { GitHubStats, StatsCardOptions } from '../types.js';
22
import { getTheme } from '../utils/themes.js';
33

44
export class CardRenderer {
@@ -51,7 +51,7 @@ export class CardRenderer {
5151
return `<g stroke="${iconColor}" stroke-width="2" fill="none" opacity="0.7"><path d="M ${x1} ${y1 + corner} V ${y1} H ${x1 + corner}"/><path d="M ${x2 - corner} ${y1} H ${x2} V ${y1 + corner}"/><path d="M ${x1} ${y2 - corner} V ${y2} H ${x1 + corner}"/><path d="M ${x2 - corner} ${y2} H ${x2} V ${y2 - corner}"/></g>`;
5252
}
5353

54-
static generateStatsCard(stats: GitHubStats, options: CardOptions): string {
54+
static generateStatsCard(stats: GitHubStats, options: StatsCardOptions): string {
5555
const theme = getTheme(options.theme, {
5656
bgColor: options.bgColor,
5757
borderColor: options.borderColor,

src/components/language-card.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { CardOptions, LanguageCount } from '../types.js';
1+
import { LanguagesCardOptions, LanguageCount } from '../types.js';
22
import { getTheme } from '../utils/themes.js';
33

44
export class LanguageCardRenderer {
5-
static generateLanguagesCard(languages: LanguageCount[], options: CardOptions): string {
5+
static generateLanguagesCard(languages: LanguageCount[], options: LanguagesCardOptions): string {
66
const theme = getTheme(options.theme, {
77
bgColor: options.bgColor,
88
borderColor: options.borderColor,

src/components/language-pie-chart.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import { CardOptions, LanguageCount } from '../types.js';
1+
import { LanguagesPieChartOptions, LanguageCount } from '../types.js';
22
import { getTheme } from '../utils/themes.js';
33

44
export class LanguagePieChartRenderer {
5-
static generatePieChart(languages: LanguageCount[], options: CardOptions): string {
5+
static generatePieChart(languages: LanguageCount[], options: LanguagesPieChartOptions): string {
66
const theme = getTheme(options.theme, {
77
bgColor: options.bgColor,
88
borderColor: options.borderColor,
@@ -15,7 +15,7 @@ export class LanguagePieChartRenderer {
1515
const fontFace = fontUrl
1616
? `@font-face { font-family: '${fontName}'; font-style: normal; font-weight: 400 900; font-display: swap; src: url(${fontUrl}) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }`
1717
: '';
18-
18+
1919
// Extract RGB values from theme colors for gradients
2020
const extractHSL = (hslString: string): { h: number; s: number; l: number } => {
2121
const match = hslString.match(/\d+/g);

src/controllers/home.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/controllers/languages.ts

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { Request, Response } from 'express';
22
import { GitHubClient } from '../utils/github-client.js';
33
import { LanguageCardRenderer } from '../components/language-card.js';
44
import { LanguagePieChartRenderer } from '../components/language-pie-chart.js';
5-
import { themes } from '../utils/themes.js';
6-
import { Controller } from './controller.js';
7-
8-
export class LanguageController extends Controller {
5+
export class LanguageController {
96
private static githubClient: GitHubClient;
107
private static cache: Map<string, { data: string; timestamp: number }>;
118
private static CACHE_DURATION: number;
@@ -16,56 +13,6 @@ export class LanguageController extends Controller {
1613
this.CACHE_DURATION = cacheDuration;
1714
}
1815

19-
static async get(req: Request, res: Response) {
20-
try {
21-
const {
22-
username,
23-
theme = 'default',
24-
show_info = 'true',
25-
top = '5',
26-
variant = 'bubbles'
27-
} = req.query;
28-
29-
if (!username || typeof username !== 'string') {
30-
return res.status(400).send('Username is required');
31-
}
32-
33-
const params = new URLSearchParams();
34-
params.set('username', username);
35-
params.set('format', 'webp');
36-
if (theme !== 'default') params.set('theme', theme as string);
37-
if (show_info === 'false') params.set('show_info', 'false');
38-
if (top) params.set('top', top as string);
39-
if (variant !== 'bubbles') params.set('variant', variant as string);
40-
41-
const protocol = req.protocol;
42-
const host = req.get('host');
43-
const svgUrl = `/languages?${params.toString()}`;
44-
const fullUrl = `${protocol}://${host}/languages?${params.toString()}`;
45-
46-
const payloads = {
47-
...Controller.defaultConfig,
48-
title: `${username}'s GitHub Languages - StackDev`,
49-
description: `View ${username}'s GitHub language breakdown with customizable themes, top language list, and visualization styles.`,
50-
keywords: `github languages, github readme, github card, language stats, top languages, svg card, github profile, ${username} languages`,
51-
page: 'languages',
52-
username,
53-
theme,
54-
showInfo: show_info !== 'false',
55-
top: Number.parseInt(top as string, 10) || 5,
56-
variant,
57-
svgUrl,
58-
fullUrl,
59-
themes: Object.keys(themes)
60-
};
61-
62-
res.render('layouts/main', payloads);
63-
} catch (error) {
64-
console.error('Error rendering languages view:', error);
65-
res.status(500).send(`Error: ${error instanceof Error ? error.message : 'Unknown error'}`);
66-
}
67-
}
68-
6916
static async getSvg(req: Request, res: Response) {
7017
try {
7118
const { username, theme = 'default', show_info, top, variant, type = 'card', bgColor, borderColor, textColor, titleColor, format } = req.query;
@@ -87,7 +34,6 @@ export class LanguageController extends Controller {
8734
let svg: string;
8835
if (type === 'pie') {
8936
svg = LanguagePieChartRenderer.generatePieChart(languages, {
90-
username,
9137
theme: theme as string,
9238
listLength: typeof top === 'string' ? Math.max(0, Number.parseInt(top, 10) || 8) : 8,
9339
bgColor: bgColor as string | undefined,
@@ -97,7 +43,6 @@ export class LanguageController extends Controller {
9743
});
9844
} else {
9945
svg = LanguageCardRenderer.generateLanguagesCard(languages, {
100-
username,
10146
theme: theme as string,
10247
showInfo: show_info !== 'false',
10348
listLength: typeof top === 'string' ? Math.max(0, Number.parseInt(top, 10) || 5) : 5,

src/controllers/stats.ts

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,7 @@ import { Request, Response } from 'express';
22
import { GitHubClient } from '../utils/github-client.js';
33
import { CardRenderer } from '../components/card-renderer.js';
44
import sharp from 'sharp';
5-
import { themes } from '../utils/themes.js';
6-
import { Controller } from './controller.js';
7-
8-
export class StatsController extends Controller {
5+
export class StatsController {
96
private static githubClient: GitHubClient;
107
private static cache: Map<string, { data: string; timestamp: number }>;
118
private static CACHE_DURATION: number;
@@ -18,62 +15,6 @@ export class StatsController extends Controller {
1815
this.CACHE_DURATION = cacheDuration;
1916
}
2017

21-
static async get(req: Request, res: Response) {
22-
try {
23-
const { username, theme = 'default', hide_title = 'false', hide_border = 'false', hide_rank = 'false', show_icons = 'true', avatar_mode = 'none', custom_title, data_border_style = 'solid', data_border_frame = 'out', format = 'svg' } = req.query;
24-
25-
if (!username || typeof username !== 'string') {
26-
return res.status(400).send('Username is required');
27-
}
28-
29-
// Build the SVG URL
30-
const params = new URLSearchParams();
31-
params.set('username', username);
32-
if (theme !== 'default') params.set('theme', theme as string);
33-
if (hide_title === 'true') params.set('hide_title', 'true');
34-
if (hide_border === 'true') params.set('hide_border', 'true');
35-
if (hide_rank === 'true') params.set('hide_rank', 'true');
36-
if (show_icons !== 'true') params.set('show_icons', 'false');
37-
if (avatar_mode !== 'none') params.set('avatar_mode', avatar_mode as string);
38-
if (data_border_style !== 'solid') params.set('data_border_style', data_border_style as string);
39-
if (data_border_frame !== 'out') params.set('data_border_frame', data_border_frame as string);
40-
if (custom_title) params.set('custom_title', custom_title as string);
41-
42-
const host = req.get('host');
43-
const svgUrl = `/stats?${params.toString()}&format=svg`;
44-
const APP_ENV = process.env.APP_ENV || 'development';
45-
const PROTOCOL = APP_ENV === 'production' ? 'https' : 'http';
46-
47-
const fullUrl = `${PROTOCOL}://${host}/stats?${params.toString()}`;
48-
49-
const payloads = {
50-
...Controller.defaultConfig,
51-
title: `${username}'s GitHub Stats - StackDev`,
52-
description: `View ${username}'s GitHub statistics with customizable themes and options. Generate dynamic SVG cards for your README or profile.`,
53-
keywords: `github stats, github readme, github card, github statistics, readme stats, github api, svg card, github profile, developer stats, contribution tracker, ${username} stats`,
54-
page: 'stats',
55-
username,
56-
theme,
57-
hideTitle: hide_title === 'true',
58-
hideBorder: hide_border === 'true',
59-
hideRank: hide_rank === 'true',
60-
showIcons: show_icons === 'true',
61-
avatarMode: avatar_mode,
62-
dataBorderStyle: data_border_style,
63-
dataBorderFramePosition: data_border_frame,
64-
customTitle: custom_title || '',
65-
svgUrl,
66-
fullUrl,
67-
themes: Object.keys(themes)
68-
}
69-
70-
res.render('layouts/main', payloads);
71-
} catch (error) {
72-
console.error('Error rendering stats view:', error);
73-
res.status(500).send(`Error: ${error instanceof Error ? error.message : 'Unknown error'}`);
74-
}
75-
}
76-
7718
static async getSvg(req: Request, res: Response) {
7819
try {
7920
const {
@@ -144,7 +85,6 @@ export class StatsController extends Controller {
14485
});
14586

14687
const card = CardRenderer.generateStatsCard(stats, {
147-
username,
14888
theme: theme as string,
14989
hideTitle: hide_title === 'true',
15090
hideBorder: hide_border === 'true',

src/controllers/studio.ts

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/index.ts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@ import 'dotenv/config';
22
import express from 'express';
33
import cors from 'cors';
44
import { GitHubClient } from './utils/github-client.js';
5-
import { HomeController } from './controllers/home.js';
65
import { StatsController } from './controllers/stats.js';
76
import { LanguageController } from './controllers/languages.js';
8-
import { StudioController } from './controllers/studio.js';
97
import path from 'path';
108
import { fileURLToPath } from 'url';
119

@@ -16,13 +14,8 @@ const publicDir = path.join(__dirname, '..', 'public');
1614
const app = express();
1715
app.use(cors());
1816

19-
// Set up EJS as the view engine
20-
app.set('view engine', 'ejs');
21-
app.set('views', path.join(__dirname, 'views'));
22-
app.use(express.static('dist'));
2317
app.use(express.static(publicDir));
2418
app.use('/public', express.static(publicDir));
25-
app.use('/js', express.static("dist/views/pages"));
2619

2720
const PORT = process.env.PORT || 3000;
2821
const APP_ENV = process.env.APP_ENV || 'development';
@@ -36,10 +29,6 @@ if (!GITHUB_TOKEN) {
3629
console.warn('⚠️ Get a token at: https://github.com/settings/tokens');
3730
}
3831

39-
app.use(express.static('dist'));
40-
app.use(express.static(publicDir));
41-
app.use('/public', express.static(publicDir));
42-
4332
const githubClient = new GitHubClient(GITHUB_TOKEN);
4433

4534
// Cache to reduce API calls
@@ -54,14 +43,6 @@ LanguageController.initialize(githubClient, cache, CACHE_DURATION);
5443
app.get('/stats', StatsController.getSvg);
5544
app.get('/languages', LanguageController.getSvg);
5645

57-
58-
// app.get('/view/stats', StatsController.get);
59-
// app.get('/preview/languages', LanguageController.get);
60-
61-
// UI
62-
app.get('/', HomeController.get);
63-
app.get('/studio', StudioController.get);
64-
6546
app.listen(PORT, () => {
6647
console.log(`🚀 GitHub Stats server running on ${PROTOCOL}://localhost:${PORT}`);
6748
console.log(`📊 Example: ${PROTOCOL}://localhost:${PORT}/stats?username=pphatdev&theme=dark`);

src/types.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,33 @@ export interface Theme {
2828
fontUrl?: string;
2929
}
3030

31-
export interface CardOptions {
32-
username: string;
31+
export interface ThemeOverrides {
3332
theme?: string;
33+
bgColor?: string;
34+
borderColor?: string;
35+
textColor?: string;
36+
titleColor?: string;
37+
}
38+
39+
export interface StatsCardOptions extends ThemeOverrides {
3440
hideTitle?: boolean;
3541
hideBorder?: boolean;
3642
hideRank?: boolean;
3743
showIcons?: boolean;
3844
customTitle?: string;
45+
avatarMode?: 'none' | 'avatar' | 'radar';
46+
dataBorderStyle?: 'solid' | 'frame';
47+
dataBorderFramePosition?: 'in' | 'out';
48+
}
49+
50+
export interface LanguagesCardOptions extends ThemeOverrides {
3951
showInfo?: boolean;
4052
listLength?: number;
4153
variant?: 'bubbles' | 'pie';
42-
type?: 'card' | 'pie';
43-
avatarMode?: 'none' | 'avatar' | 'radar';
4454
dataBorderStyle?: 'solid' | 'frame';
4555
dataBorderFramePosition?: 'in' | 'out';
46-
bgColor?: string;
47-
borderColor?: string;
48-
textColor?: string;
49-
titleColor?: string;
56+
}
57+
58+
export interface LanguagesPieChartOptions extends ThemeOverrides {
59+
listLength?: number;
5060
}

0 commit comments

Comments
 (0)