Skip to content
This repository was archived by the owner on Oct 6, 2024. It is now read-only.

Commit b62970d

Browse files
authored
Generate HTML files with information about issues (#14)
1 parent 0b6f297 commit b62970d

File tree

3 files changed

+61
-6
lines changed

3 files changed

+61
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77

88
# Generated files
99
index.html
10+
lang

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
1-
# good-first-issue
1+
# good-first-issue.com
2+
23
Make your first open-source contribution.
34

45

6+
TODO Make with V by gomzyakov
7+
8+
https://gomzyakov.github.io/good-first-issue/
9+
10+
11+
# Как добавить свой репозиторий?
12+
13+
todo [repositories.json](https://github.com/gomzyakov/good-first-issue/blob/main/repositories.json)
14+
515

616
# Как это работает?
717

@@ -10,4 +20,6 @@ Make your first open-source contribution.
1020
chmod u+x xxx.sh
1121

1222

23+
https://api.github.com/repos/gomzyakov/good-first-issue/issues?state=open&sort=updated&labels=good%20first%20issue
24+
1325
Ежедневно запускается [cron.yml](#TODO) который _TODO_

generate.php

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
// TODO To class + ->run()
77

88

9-
// Удаляем все файлы (кроме .gitignore) из директории `./data`
9+
if (!is_dir('lang')) {
10+
mkdir('lang');
11+
}
1012

1113

1214
// Read the JSON file
@@ -20,7 +22,9 @@
2022

2123
// TODO Рандомизируем массив с репозиториями
2224

23-
$indexContent= "<h1>Hello!</h1>";
25+
$indexContent = "<h1>Hello!</h1>";
26+
27+
$repositoriesByLanguage = [];
2428

2529
// Проходимся по всем репозиториям
2630
foreach ($json_data as $line) {
@@ -54,15 +58,53 @@
5458

5559
print_r($repositoryData);
5660

57-
$indexContent .= '<h2>'.$repositoryData['full_name'].'</h2>';
58-
$indexContent .= '<p>'.$repositoryData['description'].'</p>';
61+
// Конетент для главной страницы
62+
$indexContent .= '<h2>' . $repositoryData['full_name'] . '</h2>';
63+
$indexContent .= '<p>' . $repositoryData['description'] . '</p>';
5964

65+
$repositoriesByLanguage[$repositoryData['language']][] = $repositoryData['full_name'];
6066

6167
// Записываем ищуйки в общий файл
6268
}
6369

6470

71+
file_put_contents('index.html', $indexContent);
6572

6673

67-
file_put_contents('index.html', $indexContent);
74+
foreach ($repositoriesByLanguage as $lang => $repositories) {
75+
if (strlen($lang) < 1) {
76+
$lang = 'other';
77+
}
78+
79+
print_r('Language: ' . $lang);
80+
81+
$langFile = 'lang/' . $lang . '.html';
82+
if (file_exists($langFile)) {
83+
$status = unlink($langFile) ? 'The file ' . $langFile . ' has been deleted' . "\n" : 'Error deleting ' . $langFile . "\n";
84+
echo $status;
85+
}
86+
87+
88+
// TODO Пишем шапку файла
89+
file_put_contents($langFile, '<h1>Lang: ' . $lang . '</h1>' . "\n");
90+
91+
foreach ($repositories as $repository) {
92+
print_r('Repository: ' . $repository."\n");
93+
94+
$issuesJson = file_get_contents('https://api.github.com/repos/' . $repository . '/issues?state=open&sort=updated&labels=good%20first%20issue', false, $context);
95+
$issues = json_decode($issuesJson, true);
96+
97+
foreach ($issues as $issue) {
98+
print_r('Issue #' . $issue['number'] . ' ' . $issue['title'] . "\n");
99+
100+
$str = '<p>' . $issue['title'] . '</p>';
101+
$str .= '<p>' . $issue['html_url'] . '</p>';
102+
103+
file_put_contents($langFile, $str, FILE_APPEND);
104+
}
105+
106+
}
107+
108+
109+
}
68110

0 commit comments

Comments
 (0)