List of commits:
Subject Hash Author Date (UTC)
Render readme files on the project page a8c09adb1bceed31f8070386158561b06470a98f Catalin(ux) M. BOIE 2023-06-14 17:09:17
Added rg_sid global variable to simplify the function calling 0047908fcd2ed0302a826487ddd15ca2579a9a83 Catalin(ux) M. BOIE 2023-06-14 17:06:39
Removed delta support for rpms because Fedora will remove it 2c26be90f4bc08a06ab03ab016e9ccaa843780e5 Catalin(ux) M. BOIE 2023-05-03 05:04:40
Added first payments option; fixes all around 7102aed9f239d529723799171553e8c4bd018440 Catalin(ux) M. BOIE 2023-05-02 22:36:28
Fixed a nasty typo in the build system; doc update; cosmetic 1934732b297d6476be7954fabdcaf9eb87678f5e Catalin(ux) M. BOIE 2022-12-21 12:51:53
Send client features to the builder dcf648353662409b9e39a422228ddb6a7c43358c Catalin(ux) M. BOIE 2022-12-21 11:10:00
Add support for SHA-256 git repos 8b88927d353c7b588909d0b1220c8922b32129c0 Catalin(ux) M. BOIE 2022-12-21 11:03:19
Look-up pkg_repo using pkg_repo uid f2b188b8cb151c376d8ee8c81f8e82c02ed93cd1 Catalin(ux) M. BOIE 2022-12-12 05:29:13
Cosmetic 04ae5ac6b9805198966a21755d1d430ef5b6a6dd Catalin(ux) M. BOIE 2022-12-11 17:17:39
Keep-alive mechanism for builder/worker 7e3add2ab41feefe37a858439934b8599fb30933 Catalin(ux) M. BOIE 2022-12-10 19:36:53
Bumped version to 0.76 09bb0cc92a9dfce513ce1289a22e71faf4ad1fe1 Catalin(ux) M. BOIE 2022-10-22 06:27:35
Cosmetic 45c59081c97489ccccd35efffa522607fee25a63 Catalin(ux) M. BOIE 2022-10-22 05:52:56
Mostly worker stuff ccf3a8d8da2ad1b0d97418fabb5028b40721835f Catalin(ux) M. BOIE 2022-10-22 05:50:04
wh: lambda: seems we cannot pass x-Amz-Client-Context header empty anymore 7f065b0fb6ceed5d2339afd7590f5a795ed3582e Catalin(ux) M. BOIE 2022-10-21 19:33:58
workers: wrong URL for delete a2b2ff5925b1ee9b4a033da93084c008b7af8c64 Catalin(ux) M. BOIE 2022-10-21 16:03:56
Typo 4557595fb985fb2a0a482a387ef0a61293b511ed Catalin(ux) M. BOIE 2022-03-29 17:06:57
Builder improvements 2c27620922c4990454dc3039b2f1c4a86388501f Catalin(ux) M. BOIE 2022-03-29 06:28:16
Extra space in debian/conffiles preventing Debian build 416ed9995151c29bffb4ca3f0f6901aab7cbaa8e Catalin(ux) M. BOIE 2022-03-28 19:36:06
Show global pkg sub repos; cosmetic 43f60158b760b2789261e703ff2fa0781f590e04 Catalin(ux) M. BOIE 2022-03-28 18:21:07
Cosmetic a60d33914b8a1754c84ddc5440533df9b89337ad Catalin(ux) M. BOIE 2022-03-16 07:40:37
Commit a8c09adb1bceed31f8070386158561b06470a98f - Render readme files on the project page
Author: Catalin(ux) M. BOIE
Author date (UTC): 2023-06-14 17:09
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2023-06-14 17:09
Parent(s): 0047908fcd2ed0302a826487ddd15ca2579a9a83
Signer:
Signing key:
Signing status: N
Tree: eac888cd3f06b097e6df6045a9d260b654760c08
File Lines added Lines deleted
inc/format.inc.php 60 0
inc/repo.inc.php 46 0
inc/user/repo-page.php 2 0
root/themes/default/repo/readme/err.html 1 0
root/themes/default/repo/readme/err_file.html 1 0
root/themes/default/repo/readme/one.html 8 0
tests/_run_tests.sh 2 1
tests/markdown1-a.md 11 0
tests/markdown1-b.md 9 0
tests/markdown1-c.html 7 0
tests/markdown1-d.txt 5 0
tests/markdown1.php 104 0
File inc/format.inc.php changed (mode: 100644) (index 7eb899e..11eff58)
... ... function rg_format_markdown($a)
154 154 return preg_replace($k, $v, $a); return preg_replace($k, $v, $a);
155 155 } }
156 156
157 function rg_format_unk_to_html_string(string $file_name, string $content)
158 {
159 $ret = array('ok' => 0);
160 do {
161 if (stristr($file_name, '.txt')) {
162 $ret['doc'] = nl2br(htmlspecialchars($content));
163 $ret['ok'] = 1;
164 break;
165 }
166
167 if (stristr($file_name, '.md')) {
168 $content = htmlspecialchars($content); // For now, we do not support inline HTML
169 $format = 'markdown';
170 } else {
171 $ret['doc'] = '';
172 $ret['ok'] = 1;
173 break;
174 }
175
176 $a = array(
177 'cmds' => array(
178 'cmd1' => array(
179 'cmd' => 'pandoc --toc'
180 . ' --from ' . escapeshellarg($format)
181 . ' --to html',
182 'out_buf' => $content
183 )
184 )
185 );
186 $r = rg_exec2($a);
187 //rg_debug('exec: ' . print_r($r, TRUE));
188 if (($r['ok'] != 1) || ($r['cmds']['cmd1']['exitcode'] != 0)) {
189 $ret['errmsg'] = 'cannot generate: '
190 . $r['cmds']['cmd1']['last_errmsg']
191 . ' [' . $r['cmds']['cmd1']['err_buf'] . ']';
192 break;
193 }
194
195 $ret['doc'] = $r['cmds']['cmd1']['in_buf'];
196 $ret['ok'] = 1;
197 } while (0);
198
199 return $ret;
200 }
201
202 function rg_format_unk_to_html_file(string $file, string $file_name)
203 {
204 $ret = array('ok' => 0);
205 do {
206 $c = @file_get_contents($file);
207 if ($c === FALSE) {
208 $ret['errmsg'] = 'cannot load file ' . $file;
209 break;
210 }
211
212 $ret = rg_format_unk_to_html_string($file_name, $c);
213 } while (0);
214
215 return $ret;
216 }
File inc/repo.inc.php changed (mode: 100644) (index 72de84d..c6a38a6)
... ... require_once(__DIR__ . '/prof.inc.php');
9 9 require_once(__DIR__ . '/mail.inc.php'); require_once(__DIR__ . '/mail.inc.php');
10 10 require_once(__DIR__ . '/events.inc.php'); require_once(__DIR__ . '/events.inc.php');
11 11 require_once(__DIR__ . '/webhooks.inc.php'); require_once(__DIR__ . '/webhooks.inc.php');
12 require_once(__DIR__ . '/format.inc.php');
12 13
13 14 $rg_repo_refs_rights = array( $rg_repo_refs_rights = array(
14 15 "F" => "Fetch", "F" => "Fetch",
 
... ... function rg_repo_fetch_push_helper($db, $host, $prefix, $repo_user,
2515 2516 return $ret; return $ret;
2516 2517 } }
2517 2518
2519 // Renders readme files
2520 function rg_repo_show_readme(array $rg, string $ref, string $path)
2521 {
2522 rg_prof_start('repo_show_readme');
2523 rg_log_enter('repo_show_readme: ref=' . $ref);
2524
2525 $ret = '';
2526 do {
2527 $list = rg_git_ls_tree($rg['repo_path'], $ref, $path);
2528 if ($list === FALSE) {
2529 $ret .= rg_template('repo/readme/err.html', $rg, TRUE /*xss*/);
2530 break;
2531 }
2532
2533 rg_log_debug('git_ls_tree: ' . print_r($list, TRUE));
2534 foreach ($list as $i) {
2535 if (!stristr($i['file'], 'readme')
2536 && !stristr($i['file'], 'read-me')
2537 && !stristr($i['file'], 'howto'))
2538 continue;
2539
2540 $r = rg_git_content($i['ref']);
2541 rg_log_debug('git_content returned: ' . print_r($r, TRUE));
2542
2543 $rg['readme_file'] = $i['file'];
2544
2545 $r = rg_format_unk_to_html_string($i['file'], $r);
2546 if ($r['ok'] != 1) {
2547 rg_log('error: ' . $r['errmsg']);
2548 $ret .= rg_template('repo/readme/err_file.html', $rg, TRUE /*xss*/);
2549 continue;
2550 }
2551
2552 if (empty($r['doc']))
2553 continue;
2554
2555 $rg['HTML:readme_doc'] = $r['doc'];
2556 $ret .= rg_template('repo/readme/one.html', $rg, TRUE /*xss*/);
2557 }
2558 } while (0);
2559
2560 rg_log_exit();
2561 rg_prof_end('repo_show_readme');
2562 return $ret;
2563 }
File inc/user/repo-page.php changed (mode: 100644) (index dc66fe8..a4d2de8)
... ... if (strcmp($_subop, "history") == 0) {
367 367 $_repo_body .= rg_warning("Cannot load history. Try again later."); $_repo_body .= rg_warning("Cannot load history. Try again later.");
368 368 else else
369 369 $_repo_body .= rg_template_table("repo/history", $hist, $rg); $_repo_body .= rg_template_table("repo/history", $hist, $rg);
370
371 $_repo_body .= rg_repo_show_readme($rg, 'HEAD', '.' /*path*/);
370 372 } else if (strcmp($_subop, "admin") == 0) { } else if (strcmp($_subop, "admin") == 0) {
371 373 $_repo_body .= rg_repo_admin($db, $rg, $paras); $_repo_body .= rg_repo_admin($db, $rg, $paras);
372 374 } else if (strcmp($_subop, "source") == 0) { } else if (strcmp($_subop, "source") == 0) {
File root/themes/default/repo/readme/err.html added (mode: 100644) (index 0000000..f90e708)
1 <span class="warning_text">Internal error rendering readme file(s).</span>
File root/themes/default/repo/readme/err_file.html added (mode: 100644) (index 0000000..b863fc6)
1 <span class="warning_text">Internal error rendering file <b>@@readme_file@@</b>.</span>
File root/themes/default/repo/readme/one.html added (mode: 100644) (index 0000000..547e828)
1 <div>
2 <br />
3 <b>@@readme_file@@:</b>
4 </div>
5
6 <div class="source">
7 @@readme_doc@@
8 </div>
File tests/_run_tests.sh changed (mode: 100755) (index a3aad47..18ab942)
3 3 . ./env.txt . ./env.txt
4 4
5 5 # wh_build must be at the end because takes a lot of time # wh_build must be at the end because takes a lot of time
6 tests="git-sha256 pkg_subrepo pkg_rpm gpg http_api http_304 ldap_core ldap \
6 tests="migrate1 \
7 git-sha256 pkg_subrepo pkg_rpm gpg http_api http_304 ldap_core ldap \
7 8 admin_set_web git_big_push admin_set_git by_http wh_lambda http_keys \ admin_set_web git_big_push admin_set_git by_http wh_lambda http_keys \
8 9 http_forgot \ http_forgot \
9 10 api wh_cloud pr_anon wh_http ssh http_totp totp git_log1 \ api wh_cloud pr_anon wh_http ssh http_totp totp git_log1 \
File tests/markdown1-a.md added (mode: 100644) (index 0000000..4fa229c)
1 ## Test 2#
2 some text
3
4 ### Test 3#
5 bla bla
6
7 <xss>
8
9 <b>this is bold generated by embedding html inside markdown</b>
10
11 This is markdown1-a.md file.
File tests/markdown1-b.md added (mode: 100644) (index 0000000..e6424a0)
1 ## other file Test 2#
2 some text
3
4 ### other file Test 3#
5 bla bla
6
7 <xss>
8
9 This is markdown1-b.md file.
File tests/markdown1-c.html added (mode: 100644) (index 0000000..318c6cf)
1 starting html
2 <div>
3 script: <script> alert('.html'); </script>
4 </div>
5
6 <xss>
7 ending html
File tests/markdown1-d.txt added (mode: 100644) (index 0000000..05e5d48)
1 This is rendered as markdown
2
3 <script> alert('.txt'); </script>
4
5 <xss>
File tests/markdown1.php added (mode: 100644) (index 0000000..0533d9c)
1 <?php
2 error_reporting(E_ALL | E_STRICT);
3 ini_set("track_errors", "On");
4
5 $test_normal = TRUE;
6
7 $INC = dirname(__FILE__) . "/../inc";
8 require_once(dirname(__FILE__) . "/config.php");
9 require_once($INC . "/init.inc.php");
10 require_once($INC . "/git.inc.php");
11 require_once($INC . '/format.inc.php');
12 require_once("helpers.inc.php");
13 require_once("http.inc.php");
14
15 rg_log_set_file("markdown1.log");
16
17 require_once("common.php");
18
19 $_testns = 'markdown1';
20
21
22 rg_test_create_user($db, $rg_ui);
23 $info = array('id' => $rg_ui['username']);
24 prepare_http($info);
25
26 rg_test_create_repo($db, $rg_ui, $repo);
27 $r = test_login($test_url, $rg_ui);
28 if ($r === FALSE) {
29 rg_log("Cannot login!");
30 exit(1);
31 }
32
33 rg_test_upload_ssh_key($db, $rg_ui, 'markdown1', $kn);
34
35
36
37 rg_log('');
38 rg_log_enter('Testing rg_markdown_to_html...');
39 $r = rg_format_unk_to_html_file('markdown1-a.md', 'markdown1-a.md');
40 if ($r['ok'] != 1) {
41 rg_log('error: ' . $r['errmsg']);
42 exit(1);
43 }
44
45 $e = '<h2 id="test-2">Test 2</h2>' . "\n"
46 . '<p>some text</p>' . "\n"
47 . '<h3 id="test-3">Test 3</h3>' . "\n"
48 . '<p>bla bla</p>' . "\n"
49 . '<p>&lt;xss&gt;</p>' . "\n"
50 . '<p>&lt;b&gt;this is bold generated by embedding html inside' . "\n"
51 . 'markdown&lt;/b&gt;</p>' . "\n"
52 . '<p>This is markdown1-a.md file.</p>' . "\n";
53 if (strcmp($r['doc'], $e) != 0) {
54 rg_log_ml('error: mismatch: doc r/e:' . "\n" . $r['doc'] . "\n" . $e);
55 exit(1);
56 }
57 rg_log_exit();
58
59
60
61 rg_log('');
62 rg_log_enter('Trying to push main...');
63 $remote = 'ssh://rocketgit@' . $rg_ssh_host . ':' .$rg_ssh_port
64 . '/user/' . escapeshellarg($rg_ui['username'])
65 . '/' . escapeshellarg($repo['name']);
66 $r = rg_exec('rm -rf temp_repos/markdown1'
67 . ' && mkdir -p temp_repos/markdown1'
68 . ' && cp markdown1-a.md temp_repos/markdown1/ReadMe.mD'
69 . ' && cp markdown1-b.md temp_repos/markdown1/readMe.mD'
70 . ' && cp markdown1-c.html temp_repos/markdown1/readMe.html'
71 . ' && cp markdown1-d.txt temp_repos/markdown1/readme.txt'
72 . ' && cd temp_repos/markdown1'
73 . ' && git init --initial-branch=main'
74 . ' && git add .'
75 . ' && git commit -m "bla"'
76 . ' && git remote add origin ' . $remote
77 . ' && git push origin main:main',
78 '', FALSE, FALSE, FALSE);
79 if ($r['ok'] != 1) {
80 rg_log_ml('out: ' . print_r($r, TRUE));
81 rg_log('Seems I cannot push main!');
82 exit(1);
83 }
84 rg_log_exit();
85
86
87
88 rg_log('');
89 rg_log_enter('Checking on web the readme.md file...');
90 $data = array();
91 $headers = array();
92 $r = do_req($info, $test_url . '/user/' . rawurlencode($rg_ui['username'])
93 . '/' . rawurlencode($repo['name']), $data, $headers);
94 if (!strstr($r['body'], 'This is markdown1-a.md file.')
95 || !strstr($r['body'], 'This is markdown1-b.md file')) {
96 rg_log('body: ' . $r['body']);
97 rg_log_ml('Markdown not rendered correctly!');
98 exit(1);
99 }
100 rg_log_exit();
101
102
103
104 rg_log('OK!');
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/rocketgit

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/rocketgit

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main