6
6
< meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
7
7
< title > TheBaconSpace's Profile</ title >
8
8
<!-- Include Bootstrap 5.3.0 CSS -->
9
- < link href ="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css /bootstrap.min.css " rel ="stylesheet ">
9
+ < link href ="https://bootswatch.com/5/quartz /bootstrap.min.css " rel ="stylesheet ">
10
10
<!-- Include Font Awesome 6.4.2 CSS -->
11
11
< link rel ="stylesheet " href ="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.2/css/all.min.css ">
12
12
<!-- Custom CSS for styling -->
16
16
background-color : # f5f5f5 ;
17
17
margin : 0 ;
18
18
padding : 0 ;
19
- text-align : center;
19
+ text-align : -webkit- center;
20
20
}
21
21
22
22
header {
50
50
text-align : center;
51
51
padding : 10px 0 ;
52
52
}
53
-
54
- /* Adjusted styling for the repository cards */
55
- .card {
56
- width : 18rem ;
57
- height : 25rem ;
58
- margin : 15px ;
59
- display : inline-block;
60
- vertical-align : top;
61
- }
62
-
63
- .card-header {
64
- background-color : # 007bff ;
65
- color : # fff ;
66
- font-weight : bold;
67
- }
68
-
69
- .card-footer {
70
- background-color : # f8f9fa ;
71
- color : # 6c757d ;
72
- }
73
53
</ style >
74
54
</ head >
75
55
@@ -87,7 +67,7 @@ <h1>TheBaconSpace</h1>
87
67
< h1 > TheBaconSpace's Repositories</ h1 >
88
68
89
69
<!-- Placeholder for the list of repositories -->
90
- < div id ="repo-cards ">
70
+ < div id ="repo-cards " class =" row " >
91
71
<!-- Repository cards will be dynamically added here using JavaScript -->
92
72
</ div >
93
73
</ div >
@@ -100,6 +80,31 @@ <h1>TheBaconSpace's Repositories</h1>
100
80
< script src ="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js "> </ script >
101
81
<!-- JavaScript to fetch and display GitHub repositories -->
102
82
< script >
83
+ // Function to generate a random color excluding unreadable colors and white
84
+ function getRandomColor ( ) {
85
+ const letters = '0123456789ABCDEF' ;
86
+ let color = '#' ;
87
+ do {
88
+ color = '#' ;
89
+ for ( let i = 0 ; i < 6 ; i ++ ) {
90
+ color += letters [ Math . floor ( Math . random ( ) * 16 ) ] ;
91
+ }
92
+ } while ( isUnreadableColor ( color ) || color === '#FFFFFF' ) ; // Exclude unreadable and white colors
93
+ return color ;
94
+ }
95
+
96
+ // Function to check if a color is unreadable
97
+ function isUnreadableColor ( hexColor ) {
98
+ // Check if the color is too bright (light text on light background) or too dark (dark text on dark background)
99
+ const rgb = parseInt ( hexColor . substring ( 1 ) , 16 ) ;
100
+ const r = ( rgb >> 16 ) & 0xff ;
101
+ const g = ( rgb >> 8 ) & 0xff ;
102
+ const b = ( rgb >> 0 ) & 0xff ;
103
+
104
+ const brightness = ( r * 299 + g * 587 + b * 114 ) / 1000 ;
105
+ return brightness > 200 || brightness < 50 ; // Modify these thresholds as needed
106
+ }
107
+
103
108
// Function to fetch social links from the specified JSON file
104
109
function fetchAndRenderSocialLinks ( ) {
105
110
fetch ( "https://thebaconspace.github.io/links.json" )
@@ -129,14 +134,88 @@ <h1>TheBaconSpace's Repositories</h1>
129
134
} ) ;
130
135
}
131
136
132
- // Your existing JavaScript code here
137
+ // Function to fetch repositories from GitHub API and render cards
138
+ function fetchAndRenderRepositories ( ) {
139
+ fetch ( 'https://api.github.com/users/TheBaconSpace/repos' )
140
+ . then ( response => response . json ( ) )
141
+ . then ( repos => {
142
+ // Select the container for repository cards
143
+ const repoCards = document . getElementById ( 'repo-cards' ) ;
144
+
145
+ // Clear existing repository cards
146
+ repoCards . innerHTML = '' ;
147
+
148
+ // Iterate through the repositories and create cards
149
+ repos . forEach ( repo => {
150
+ // Create card element
151
+ const card = document . createElement ( 'div' ) ;
152
+ card . classList . add ( 'card' , 'mb-3' , 'col-md-6' ) ;
153
+
154
+ // Include card header template
155
+ card . innerHTML = `
156
+ <h3 class="card-header">${ repo . name } </h3>
157
+ <div class="card-body">
158
+ <h5 class="card-title">${ repo . description || `Plugin For Fivem Server Called TheBaconSpace` } </h5>
159
+ <h6 class="card-subtitle text-muted"></h6>
160
+ <ul class="list-group">
161
+ <li class="list-group-item d-flex justify-content-between align-items-center">
162
+ Stars
163
+ <span class="badge bg-primary rounded-pill">${ repo . stargazers_count } </span>
164
+ </li>
165
+ <li class="list-group-item d-flex justify-content-between align-items-center">
166
+ Watchers
167
+ <span class="badge bg-primary rounded-pill">${ repo . watchers_count } </span>
168
+ </li>
169
+ <li class="list-group-item d-flex justify-content-between align-items-center">
170
+ Forks
171
+ <span class="badge bg-primary rounded-pill">${ repo . forks_count } </span>
172
+ </li>
173
+ </ul>
174
+ </div>
175
+ <svg xmlns="http://www.w3.org/2000/svg" class="d-block user-select-none" width="100%" height="200"
176
+ aria-label="${ repo . name } " focusable="false" role="img" preserveAspectRatio="xMidYMid slice"
177
+ viewBox="0 0 318 180" style="font-size:1.125rem;text-anchor:middle">
178
+ <rect width="100%" height="100%" fill="${ getRandomColor ( ) } "></rect>
179
+ <text x="50%" y="50%" fill="#dee2e6" dy=".3em">${ repo . name } </text>
180
+ </svg>
181
+ <ul class="list-group list-group-flush">
182
+ <li class="list-group-item">${ repo . description || `Plugin For Fivem Server Called TheBaconSpace` } </li>
183
+ </ul>
184
+ <div class="card-body">
185
+ <a href="${ repo . html_url } " class="card-link">Link</a>
186
+ </div>
187
+ <div class="card-footer text-muted" id="repo-created-at-${ repo . id } "></div>
188
+ ` ;
189
+
190
+ // Format and set the created_at timestamp using Moment.js
191
+ const createdTimestamp = moment ( repo . created_at ) . fromNow ( ) ;
192
+ const createdAtElement = card . querySelector ( `#repo-created-at-${ repo . id } ` ) ;
193
+ createdAtElement . textContent = `Created ${ createdTimestamp } ` ;
194
+
195
+ // Append the card to the container
196
+ repoCards . appendChild ( card ) ;
197
+ } ) ;
198
+ } )
199
+ . catch ( error => console . error ( 'Error fetching repositories:' , error ) ) ;
200
+ }
133
201
134
- // Fetch and render repositories initially
135
- fetchAndRenderRepositories ( ) ;
202
+ // Function to update the current year in the specified timezone
203
+ function updateCurrentYear ( ) {
204
+ const currentYearElement = document . getElementById ( 'current-year' ) ;
205
+ const timezone = 'America/Toronto' ; // Specify your desired timezone here
206
+ const currentYear = new Date ( ) . toLocaleString ( 'en-US' , { timeZone : timezone , year : 'numeric' } ) ;
207
+ currentYearElement . textContent = `${ currentYear } ` ;
208
+ }
136
209
137
210
// Fetch and render social links initially
138
211
fetchAndRenderSocialLinks ( ) ;
139
212
213
+ // Fetch and render repositories initially
214
+ fetchAndRenderRepositories ( ) ;
215
+
216
+ // Automatically refresh social links every 3 minutes (180,000 milliseconds)
217
+ setInterval ( fetchAndRenderSocialLinks , 3 * 60 * 1000 ) ; // 3 minutes in milliseconds
218
+
140
219
// Update the current year
141
220
updateCurrentYear ( ) ;
142
221
</ script >
0 commit comments