@@ -26,17 +26,136 @@ <h2>Welcome to the Machine Learning Repositories</h2>
26
26
< p > This website provides an overview of various machine learning repositories available on GitHub, brought to you by the RecodeHive organization.</ p >
27
27
< a href ="https://github.com/recodehive/machine-learning-repos " class ="cta-button "> Visit the Repository</ a >
28
28
</ section > .
29
+
30
+ <!-- Repository Information -->
31
+ < section id ="repository-info ">
32
+ < h2 > Repository Information</ h2 >
33
+ < div >
34
+ < h3 id ="repo-name "> </ h3 >
35
+ < p > Owner: < a id ="repo-owner-link "> < span id ="repo-owner-name "> </ span > </ a > </ p >
36
+ < img id ="repo-owner-avatar " src ="" alt ="Owner Avatar " width ="100 " />
37
+ < p > < a id ="repo-link "> View on GitHub</ a > </ p >
38
+ </ div >
39
+ </ section >
40
+
41
+ <!-- Statistics Cards -->
42
+ < section id ="statistics-cards ">
43
+ < h2 > Repository Statistics</ h2 >
44
+ < div class ="stats-grid ">
45
+ < div class ="stat-card ">
46
+ < h3 > Total Stars</ h3 >
47
+ < div id ="total-stars "> 0</ div >
48
+ </ div >
49
+ < div class ="stat-card ">
50
+ < h3 > Total Forks</ h3 >
51
+ < div id ="total-forks "> 0</ div >
52
+ </ div >
53
+ < div class ="stat-card ">
54
+ < h3 > Open Issues</ h3 >
55
+ < div id ="open-issues "> 0</ div >
56
+ </ div >
57
+ < div class ="stat-card ">
58
+ < h3 > License</ h3 >
59
+ < div id ="license "> No License</ div >
60
+ </ div >
61
+ < div class ="stat-card ">
62
+ < h3 > Repository Size</ h3 >
63
+ < div id ="repo-size "> 0 MB</ div >
64
+ </ div >
65
+ < div class ="stat-card ">
66
+ < h3 > Total Contributors</ h3 >
67
+ < div id ="contributors-count "> 0</ div >
68
+ </ div >
69
+ < div class ="stat-card ">
70
+ < h3 > Total Projects</ h3 >
71
+ < div id ="total-projects "> 10</ div >
72
+ </ div >
73
+ < div class ="stat-card ">
74
+ < h3 > Most Used Language</ h3 >
75
+ < div id ="most-used-language "> N/A</ div >
76
+ </ div >
77
+ </ div >
78
+ </ section >
79
+
80
+ <!-- Languages -->
81
+ < section id ="languages ">
82
+ < h2 > Languages Used</ h2 >
83
+ < ul id ="language-list "> </ ul >
84
+ </ section >
85
+
29
86
< section id ="repo-list ">
30
87
< h2 > Repositories</ h2 >
31
88
< ul id ="directories ">
32
89
</ ul >
33
90
</ section >
91
+
34
92
</ main >
35
93
36
94
< footer >
37
95
< p > © 2024 Machine Learning Repos - < a href ="https://github.com/recodehive "> RecodeHive</ a > . All rights reserved.</ p >
38
96
</ footer >
39
97
40
- < script src ="js/script.js "> </ script >
98
+ < script >
99
+
100
+ document . addEventListener ( 'DOMContentLoaded' , async function ( ) {
101
+ const repoOwner = 'recodehive' ; // Your GitHub username
102
+ const repoName = 'machine-learning-repos' ; // The repository name
103
+ const apiUrl = `https://api.github.com/repos/${ repoOwner } /${ repoName } ` ;
104
+
105
+ try {
106
+ // Fetch repository data
107
+ const repoResponse = await fetch ( apiUrl ) ;
108
+ const repoData = await repoResponse . json ( ) ;
109
+
110
+ // Populate repository info
111
+ document . getElementById ( 'repo-name' ) . innerText = repoData . name ;
112
+ document . getElementById ( 'repo-owner-name' ) . innerText = repoData . owner . login ;
113
+ document . getElementById ( 'repo-owner-avatar' ) . src = repoData . owner . avatar_url ;
114
+ document . getElementById ( 'repo-owner-link' ) . href = repoData . owner . html_url ;
115
+ document . getElementById ( 'repo-link' ) . href = repoData . html_url ;
116
+
117
+ // Populate statistics cards
118
+ document . getElementById ( 'total-stars' ) . innerText = repoData . stargazers_count ;
119
+ document . getElementById ( 'total-forks' ) . innerText = repoData . forks_count ;
120
+ document . getElementById ( 'open-issues' ) . innerText = repoData . open_issues_count ;
121
+ document . getElementById ( 'license' ) . innerText = repoData . license ? repoData . license . spdx_id : 'No License' ;
122
+ document . getElementById ( 'repo-size' ) . innerText = ( repoData . size / 1024 ) . toFixed ( 2 ) + ' MB' ;
123
+
124
+
125
+ // Fetch languages
126
+ const languagesResponse = await fetch ( `${ apiUrl } /languages` ) ;
127
+ const languagesData = await languagesResponse . json ( ) ;
128
+ const languageList = document . getElementById ( 'language-list' ) ;
129
+ const totalBytes = Object . values ( languagesData ) . reduce ( ( acc , val ) => acc + val , 0 ) ;
130
+ let mostUsedLanguage = { name : '' , bytes : 0 } ;
131
+
132
+ for ( const [ language , bytes ] of Object . entries ( languagesData ) ) {
133
+ const percentage = ( ( bytes / totalBytes ) * 100 ) . toFixed ( 2 ) ;
134
+ const listItem = document . createElement ( 'li' ) ;
135
+ listItem . innerHTML = `
136
+ <span>${ language } </span>
137
+ <div class="progress-bar" style="width: ${ percentage } %;"></div>
138
+ ` ;
139
+ languageList . appendChild ( listItem ) ;
140
+
141
+ if ( bytes > mostUsedLanguage . bytes ) {
142
+ mostUsedLanguage = { name : language , bytes : bytes } ;
143
+ }
144
+ }
145
+
146
+ document . getElementById ( 'most-used-language' ) . innerText = mostUsedLanguage . name ;
147
+
148
+ // Populate total projects (assuming this is a static value)
149
+ // Replace this with a dynamic calculation if you have a method to determine the total number of projects
150
+ document . getElementById ( 'total-projects' ) . innerText = "10" ;
151
+
152
+
153
+
154
+ } catch ( error ) {
155
+ console . error ( 'Error fetching data from GitHub API:' , error ) ;
156
+ }
157
+ } ) ;
158
+
159
+ </ script >
41
160
</ body >
42
161
</ html >
0 commit comments