xaizek / rocketgit (License: AGPLv3+) (since 2018-12-09)
Light and fast Git hosting solution suitable to serve both as a hub or as a personal code storage with its tickets, pull requests, API and much more.
Commit 2cb32e0b4f38ea098e7e0f02744d743faa26a319

Mostly templates stuff (nested).
Author: Catalin(ux) M. BOIE
Author date (UTC): 2012-10-15 19:23
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2012-10-16 03:02
Parent(s): b97257f8544be4197bb76c358ee409fd92810b0b
Signing key:
Tree: f18749ad4f23236e628e3199c725bbd25b541c5e
File Lines added Lines deleted
TODO 6 7
inc/bug.inc.php 16 6
inc/init.inc.php 4 1
inc/login/login.form.php 0 41
inc/login/login.php 10 3
inc/struct.inc.php 1 0
inc/user/create.php 1 0
inc/user/repo/bug/search/search.php 1 1
inc/util.inc.php 103 17
root/themes/default/hints/repo/clone_ssh.html 1 1
root/themes/default/repo/bug/search/search.html 7 2
root/themes/default/user/login.html 34 0
root/themes/try3/main.css 14 17
tests/root/themes/util/t3/c1 1 1
tests/root/themes/util/t3/c2 7 0
tests/root/themes/util/t3/c3 1 0
tests/root/themes/util/t3/c4 15 0
tests/root/themes/util/t3/c5 5 0
tests/util.php 94 5
File TODO changed (mode: 100644) (index 7356512..53d1017)
1 1 == BEFORE FIRST RELEASE! == == BEFORE FIRST RELEASE! ==
2 [ ] rg_bug_search should be rg_bug_get/load and rg_bug_search to search using
3 labels/start/end/etc.
2 [ ] Fix @@if problems by parsing template line-by-line with a stack.
4 3 [ ] bug_update does not update labels! [ ] bug_update does not update labels!
5 4 [ ] Integrate remote_add.html. [ ] Integrate remote_add.html.
6 [ ] If you are not logged in, do not show the save option!
7 [ ] ml.php in /root/PHP
8 [ ] Should we expire the reset password token? Why? Somebody can request another
9 one!
5 [ ] Should we expire the reset password token? Why?
6 Somebody can request another one!
10 7 [ ] All internal error should show a special page? [ ] All internal error should show a special page?
8 [ ] Deleting a SSH key should be done with token.
9 [ ] All operations must be verified with tokens.
11 10 [ ] [ ]
12 11
13 12
14 13 == Medium == == Medium ==
15 [ ] Bug rights: add note, anonymous add note, add label.
14 [ ] Bug rights: add note, anonymous add note, add label, add global search.
16 15 [ ] Allow user to specify if is on windows/linux/etc. to be able to give [ ] Allow user to specify if is on windows/linux/etc. to be able to give
17 16 specific hints. Hm. THe user may have multiple OSs. specific hints. Hm. THe user may have multiple OSs.
18 17 [ ] The selected menu is not colored different. [ ] The selected menu is not colored different.
File inc/bug.inc.php changed (mode: 100644) (index 8ea95d3..1d2c24f)
... ... function rg_bug_search_load($db, $repo_id, $uid, $name)
470 470 "body_string" => "", "body_string" => "",
471 471 "bugs_per_page" => 25, "bugs_per_page" => 25,
472 472 "global" => 0, "global" => 0,
473 "for_all_users" => 1,
473 474 "standard" => 1 "standard" => 1
474 475 ); );
475 476
 
... ... function rg_bug_search_load($db, $repo_id, $uid, $name)
491 492
492 493 $e_name = rg_sql_escape($db, $name); $e_name = rg_sql_escape($db, $name);
493 494
494 $sql = "SELECT name, data FROM bug_search"
495 $sql = "SELECT name, data, for_all_users FROM bug_search"
495 496 . " WHERE (repo_id = $repo_id OR repo_id = 0)" . " WHERE (repo_id = $repo_id OR repo_id = 0)"
496 . " AND uid = $uid"
497 . " AND name = '$e_name'";
497 . " AND (uid = $uid OR for_all_users = 1)"
498 . " AND name = '$e_name'"
499 . " ORDER BY name";
498 500 $res = rg_sql_query($db, $sql); $res = rg_sql_query($db, $sql);
499 501 if ($res === FALSE) { if ($res === FALSE) {
500 502 rg_bug_set_error("cannot search load (" . rg_sql_error() . ")"); rg_bug_set_error("cannot search load (" . rg_sql_error() . ")");
 
... ... function rg_bug_search_load($db, $repo_id, $uid, $name)
511 513 } }
512 514 $ret = $_data; $ret = $_data;
513 515 $ret['name'] = $row['name']; //TODO: escape?! $ret['name'] = $row['name']; //TODO: escape?!
516 $ret['for_all_users'] = $row['for_all_users'];
514 517 $ret['standard'] = 0; $ret['standard'] = 0;
515 518 } else { } else {
516 519 $ret = array(); $ret = array();
 
... ... function rg_bug_search_save($db, $repo_id, $uid, $q)
552 555 else else
553 556 $e_repo_id = 0; $e_repo_id = 0;
554 557
555 if (empty($old)) {
558 if (isset($q['for_all_users']) && ($q['for_all_users'] == 1))
559 $e_for_all_users = 1;
560 else
561 $e_for_all_users = 0;
562
563 // We will not overwrite somebody else's search
564 if (empty($old) || ($old['uid'] != $uid)) {
556 565 $sql = "INSERT INTO bug_search (repo_id, uid, name" $sql = "INSERT INTO bug_search (repo_id, uid, name"
557 . ", data)"
566 . ", data, for_all_users)"
558 567 . " VALUES ($e_repo_id, $uid, '$e_name'" . " VALUES ($e_repo_id, $uid, '$e_name'"
559 . ", '$e_data')";
568 . ", '$e_data', $e_for_all_users)";
560 569 } else { } else {
561 570 $sql = "UPDATE bug_search" $sql = "UPDATE bug_search"
562 571 . " SET data = '$e_data'" . " SET data = '$e_data'"
572 . ", for_all_users = $e_for_all_users"
563 573 . " WHERE repo_id = $e_repo_id" . " WHERE repo_id = $e_repo_id"
564 574 . " AND uid = $uid" . " AND uid = $uid"
565 575 . " AND name = '$e_name'"; . " AND name = '$e_name'";
File inc/init.inc.php changed (mode: 100644) (index 3c8d5bd..b31a15d)
... ... $more = array();
6 6 // For escapeshellarg to work with UTF-8, we are forced to set a locale // For escapeshellarg to work with UTF-8, we are forced to set a locale
7 7 setlocale(LC_CTYPE, "en_US.UTF-8"); setlocale(LC_CTYPE, "en_US.UTF-8");
8 8
9 if (empty($rg_ssh_host))
9 if (empty($rg_ssh_host)) {
10 10 $rg_ssh_host = php_uname("n"); $rg_ssh_host = php_uname("n");
11 $rg_ssh_port = 22;
12 }
13
11 14 $more['rg_ssh_host'] = $rg_ssh_host; $more['rg_ssh_host'] = $rg_ssh_host;
12 15 $more['rg_ssh_port'] = $rg_ssh_port; $more['rg_ssh_port'] = $rg_ssh_port;
13 16
File inc/login/login.form.php deleted (index 017d446..0000000)
1 <?php
2 $_form = '<div class="formarea">' . "\n";
3
4 $_form .= '<div class="formarea_title">Login</div><br />' . "\n";
5
6 $_form .= rg_template_errmsg($errmsg);
7
8 $_form .= '
9 <form method="post" action="' . rg_re_post($cop) . '">
10 <input type="hidden" name="subop" value="1" />
11 <input type="hidden" name="doit" value="1" />
12
13 <label for="username" class="form_item_title">Username</label><br />
14 <input type="text" name="user" value="' . $user . '" />
15 <br />
16 <br />
17
18 <label for="password" class="form_item_title">Password</label><br />
19 <input type="password" name="pass" value="' . $pass . '" />
20 <br />
21 <br />
22
23 <input type="submit" name="button" value="Login" />
24 </form>
25 <br />
26
27 <a href="' . rg_re_url("/op/forgot_send") . '">Forgot your password?</a>
28 ';
29
30 if ($rg_account_allow_creation == 1) {
31 $_form .= '
32 <br />
33 <a href="' . rg_re_url("/op/create_account") . '">Create a new account</a>
34 ';
35 }
36
37 $_form .= '
38 </div>
39 ';
40
41 ?>
File inc/login/login.php changed (mode: 100644) (index 60f3266..9011af9)
1 1 <?php <?php
2 2 rg_log("/inc/login/login"); rg_log("/inc/login/login");
3 3
4 $my_more = $more;
5
4 6 $user = rg_var_str("user"); $user = rg_var_str("user");
5 7 $pass = rg_var_str("pass"); $pass = rg_var_str("pass");
6 8
 
... ... if ($doit == 1) {
19 21 } }
20 22 } }
21 23
22 include($INC . "/login/login.form.php");
23 $_login .= $_form;
24
24 $my_more['user'] = $user;
25 $my_more['pass'] = $pass;
26 $my_more['rg_action'] = rg_re_post($cop); // TODO: do I use r66_re_post everywhere?
27 $my_more['HTML:errmsg'] = rg_template_errmsg($errmsg);
28 $my_more['forgot_send'] = rg_re_url("/op/forgot_send");
29 $my_more['create_account'] = rg_re_url("/op/create_account");
30 $my_more['allow_creation'] = $rg_account_allow_creation;
31 $_login .= rg_template("user/login.html", $my_more);
25 32 ?> ?>
File inc/struct.inc.php changed (mode: 100644) (index 30775b4..bb670b8)
... ... $rg_sql_struct[7]['tables'] = array(
171 171 . ", uid INT NOT NULL" . ", uid INT NOT NULL"
172 172 . ", name TEXT NOT NULL" . ", name TEXT NOT NULL"
173 173 . ", data TEXT NOT NULL" . ", data TEXT NOT NULL"
174 . ", for_all_users SMALLINT NOT NULL"
174 175 . ")" . ")"
175 176 ); );
176 177 $rg_sql_struct[7]['other'] = array( $rg_sql_struct[7]['other'] = array(
File inc/user/create.php changed (mode: 100644) (index 263c7c1..9fb133f)
... ... rg_log("/inc/user/create");
4 4 $_create = ""; $_create = "";
5 5
6 6 if ($rg_account_allow_creation != 1) { if ($rg_account_allow_creation != 1) {
7 // TODO: move this in a template
7 8 $_create .= "This site does not allow account creation. Ask the Admin."; $_create .= "This site does not allow account creation. Ask the Admin.";
8 9 return; return;
9 10 } }
File inc/user/repo/bug/search/search.php changed (mode: 100644) (index 484e520..8655c62)
... ... $_my_more = array_merge($_my_more, $_x);
60 60 $_my_more['HTML:bug_errmsg'] = rg_template_errmsg($bug_errmsg); $_my_more['HTML:bug_errmsg'] = rg_template_errmsg($bug_errmsg);
61 61 $_my_more['rg_action'] = rg_re_post($cop); $_my_more['rg_action'] = rg_re_post($cop);
62 62 $_my_more['HTML:state_select'] = rg_bug_state_select($_x['state']); $_my_more['HTML:state_select'] = rg_bug_state_select($_x['state']);
63 $_bug_search .= rg_template("repo/bug/bug_search.html", $_my_more);
63 $_bug_search .= rg_template("repo/bug/search/search.html", $_my_more);
64 64 ?> ?>
File inc/util.inc.php changed (mode: 100644) (index 94791fa..5bd5931)
... ... function rg_prepare_image($line)
370 370 return preg_replace_callback('/@@IMG:(.*)@@/uU', "rg_image_callback", $line); return preg_replace_callback('/@@IMG:(.*)@@/uU', "rg_image_callback", $line);
371 371 } }
372 372
373 /*
374 * Helper for rg_replace_conditionals.
375 * It works at line level.
376 * @master_block (TRUE / FALSE) is the condition for parent block.
377 */
378 function rg_replace_conditionals_block($block, &$stack)
379 {
380 rg_log("rg_replace_conditionals_block: block=[$block]"
381 . " stack=" . rg_array2string($stack));
382
383 if (!is_string($block)) {
384 rg_internal_error("Block is not a string!");
385 return FALSE;
386 }
387
388 // Nesting error
389 // TODO: rg_internal_error?
390 if (empty($stack))
391 return FALSE;
392
393 $cond = array_pop($stack);
394 $stack[] = $cond;
395 rg_log("cond is " . ($cond ? "TRUE" : "FALSE"));
396
397 // First, try to match a start of 'if'
398 $match1 = "@@if\s*\((.*?)\s*==\s*(.*?)\)\s*?{{";
399 $match2 = "{{";
400 $match3 = "}}";
401 $search = $match1 . '|' . $match2 . '|' . $match3;
402 $r = preg_match('/^(.*?)(' . $search . ')(.*)/su',
403 $block, $matches);
404 if ($r === FALSE)
405 return FALSE;
406 if ($r === 1) {
407 rg_log("matches: " . rg_array2string($matches));
408
409 $ret = "";
410 if ($cond)
411 $ret = $matches[1];
412
413 $rest = $matches[5];
414 if (strcmp($matches[2], "}}") == 0) {
415 // We pop from stack only at }} and not at {{
416 rg_log("}}: Pop the stack!");
417 array_pop($stack);
418 } else if (strcmp($matches[2], "{{") == 0) {
419 rg_log("{{");
420 } else {
421 $left = trim($matches[3]);
422 $right = trim($matches[4]);
423 rg_log("if left=[$left] right=[$right]");
424 $new_cond = strcmp($left, $right) == 0 ? TRUE : FALSE;
425 $not_new_cond = $new_cond ? FALSE : TRUE;
426
427 // We have to respect the outer block condition
428 // We have to push in reverse order. Remeber, first in, last out
429 $stack[] = $not_new_cond && $cond;
430 $stack[] = $new_cond && $cond;
431 }
432
433 $tmp = rg_replace_conditionals_block($rest, $stack);
434 if ($tmp === FALSE)
435 return FALSE;
436
437 rg_log("returning [" . $ret . $tmp . "]");
438 return $ret . $tmp;
439 }
440
441 if ($cond === FALSE)
442 $block = "";
443
444 rg_log("returning [$block]");
445 return $block;
446 }
447
373 448 /* /*
374 449 * Replace conditionals * Replace conditionals
375 * @@if(X){{@@A@@}}{{@@B@@}} - if X is 0 will return @@B@@, else @@A@@
450 * @@if(X == Y){{A}}{{B}} - if X == Y it will return A, else B.
451 * Do note that there is no ending @@.
452 * Because of complexity, I choosed to have a restriction: the 'if' is on
453 * a single line or '@@if(...){{', '}}{{' and '}}' are on separate lines.
454 * TODO: Also, we must have both branches (both true and false), for now.
455 * We support nested ifs.
376 456 */ */
377 function rg_prepare_conditionals(&$data, &$what, &$values)
457 function rg_replace_conditionals($block)
378 458 { {
379 // we need greedy (!U) here to take care of cascading ifs
380 // TODO: probably we need to repeat the replace?
381 $what['false'] = "/@@if\(0\){{(.*)}}{{(.*)}}/su";
382 $values['false'] = '$2';
459 rg_log("rg_replace_conditionals");
460
461 $ret = array();
462
463 $stack = array();
464 $stack[] = TRUE;
465 $ret = rg_replace_conditionals_block($block, $stack);
383 466
384 // For condition, we must be non greedy!
385 $what['true'] = "/@@if\(.*?\){{(.*)}}{{(.*)}}/su";
386 $values['true'] = '$1';
467 if (empty($stack) || ($stack[0] !== TRUE)) {
468 rg_internal_error("Template nesting error!");
469 return FALSE;
470 }
471
472 return $ret;
387 473 } }
388 474
389 475 function rg_prepare_replace(&$data, &$what, &$values) function rg_prepare_replace(&$data, &$what, &$values)
 
... ... function rg_prepare_replace(&$data, &$what, &$values)
397 483 } else { } else {
398 484 $v = htmlspecialchars($v); $v = htmlspecialchars($v);
399 485 } }
400 $what[$k] = "/@@" . $k . "@@/U";
486 $what[$k] = "/@@" . $k . "@@/uU";
401 487 $values[$k] = $v; $values[$k] = $v;
402 488 } }
403 489 } }
404 490
405 $what['DUMP'] = "/@@DUMP@@/U";
491 $what['DUMP'] = "/@@DUMP@@/uU";
406 492 $values['DUMP'] = htmlspecialchars(print_r($data, TRUE)); $values['DUMP'] = htmlspecialchars(print_r($data, TRUE));
407 493
408 494 // we replace @@unknown@@ with empty // we replace @@unknown@@ with empty
 
... ... function rg_template_table($dir, $data, $more)
438 524
439 525 $m_what = array(); $m_values = array(); $m_what = array(); $m_values = array();
440 526 rg_prepare_replace($more, $m_what, $m_values); rg_prepare_replace($more, $m_what, $m_values);
441 rg_prepare_conditionals($more, $m_what, $m_values);
442 527
443 528 if (!is_array($data) || (count($data) == 0)) { if (!is_array($data) || (count($data) == 0)) {
444 529 $no_data = rg_file_get_contents($xdir . "/nodata.html"); $no_data = rg_file_get_contents($xdir . "/nodata.html");
445 return preg_replace($m_what, $m_values, $no_data);
530 $_tmp = preg_replace($m_what, $m_values, $no_data);
531 return rg_replace_conditionals($_tmp);
446 532 } }
447 533
448 534 $head = rg_file_get_contents($xdir . "/header.html"); $head = rg_file_get_contents($xdir . "/header.html");
 
... ... function rg_template_table($dir, $data, $more)
460 546 $what = $m_what; $values = $m_values; $what = $m_what; $values = $m_values;
461 547
462 548 rg_prepare_replace($info, $what, $values); rg_prepare_replace($info, $what, $values);
463 rg_prepare_conditionals($info, $what, $values);
464 549
465 550 $line = rg_prepare_image($line); $line = rg_prepare_image($line);
466 551
 
... ... function rg_template_table($dir, $data, $more)
473 558 $body .= preg_replace($what, $values, $line); $body .= preg_replace($what, $values, $line);
474 559 } }
475 560
476 return $head . $body . $foot;
561 return rg_replace_conditionals($head . $body . $foot);
477 562 } }
478 563
479 564 function rg_template($file, $data) function rg_template($file, $data)
 
... ... function rg_template($file, $data)
493 578 $values = array(); $values = array();
494 579
495 580 rg_prepare_replace($data, $what, $values); rg_prepare_replace($data, $what, $values);
496 rg_prepare_conditionals($data, $what, $values);
497 581
498 582 $body = rg_prepare_image($body); $body = rg_prepare_image($body);
499 583
500 return preg_replace($what, $values, $body);
584 $ret = preg_replace($what, $values, $body);
585
586 return rg_replace_conditionals($ret);
501 587 } }
502 588
503 589 /* /*
File root/themes/default/hints/repo/clone_ssh.html changed (mode: 100644) (index fd24385..f0ed3ee)
1 Clone this repository using ssh (do not forget to upload a key):<br />
1 Clone this repository using ssh (do not forget to upload a key first):<br />
2 2 <code> <code>
3 3 git clone @@ssh@@ local_dir<br /> git clone @@ssh@@ local_dir<br />
4 4 cd local_dir<br /> cd local_dir<br />
File root/themes/default/repo/bug/search/search.html renamed from root/themes/default/repo/bug/bug_search.html (similarity 85%) (mode: 100644) (index 0c67033..5402ede)
48 48 <br /> <br />
49 49
50 50 <label for="bugs_per_page" class="form_item_title">Bugs per page</label><br /> <label for="bugs_per_page" class="form_item_title">Bugs per page</label><br />
51 <input type="text" name="bugs_per_page" value="@@bugs_per_page@@" size="40" />
51 <input type="text" name="bugs_per_page" value="@@bugs_per_page@@" size="10" />
52 52 <br /> <br />
53 53 <br /> <br />
54 54
55 55 @@if(@@can_save@@){{ @@if(@@can_save@@){{
56 <label for="global" class="form_item_title">Make this search global?</label><br />
56 <label for="for_all_users" class="form_item_title">Make this search available also for other users?</label><br />
57 <input type="checkbox" name="for_all_users" @@if(global){{checked="checked"}}{{}} />
58 <br />
59 <br />
60
61 <label for="global" class="form_item_title">Make this search available also for other repos?</label><br />
57 62 <input type="checkbox" name="global" @@if(global){{checked="checked"}}{{}} /> <input type="checkbox" name="global" @@if(global){{checked="checked"}}{{}} />
58 63 <br /> <br />
59 64 <br /> <br />
File root/themes/default/user/login.html added (mode: 100644) (index 0000000..4ca4818)
1 <div class="formarea">
2
3 <div class="formarea_title">Login</div><br />
4
5 @@errmsg@@
6
7 <form method="post" action="@@rg_action@@">
8 <input type="hidden" name="subop" value="1" />
9 <input type="hidden" name="doit" value="1" />
10
11 <label for="username" class="form_item_title">Username</label><br />
12 <input type="text" name="user" value="@@user@@" />
13 <br />
14 <br />
15
16 <label for="password" class="form_item_title">Password</label><br />
17 <input type="password" name="pass" value="@@pass@@" />
18 <br />
19 <br />
20
21 <input type="submit" name="button" value="Login" />
22 </form>
23 <br />
24
25 <a href="@@forgot_send@@">Forgot your password?</a>
26
27 @@if(@@allow_creation@@){{
28 <br />
29 <a href="@@create_account@@">Create a new account</a>
30 }}
31 {{
32 }}
33
34 </div>
File root/themes/try3/main.css changed (mode: 100644) (index 1d15b50..02bdbb6)
... ... body {
7 7 font-family: helvetica, sans-serif; font-family: helvetica, sans-serif;
8 8 font-size: 10pt; font-size: 10pt;
9 9 line-height: 105%; line-height: 105%;
10 background-color: #FFFFBB;
11 10 } }
12 11
13 12 table { table {
 
... ... form input, form textarea, form select, form option {
38 37 padding: 2px; padding: 2px;
39 38 margin: 2px; margin: 2px;
40 39 } }
41 form input[type="submit"] { font-weight: bold; }
40 form input[type="submit"] {
41 box-shadow: 0 2px 2px #FFFFFF inset;
42 background: #DDDDDD;
43 border-radius: 4px 4px 4px 4px;
44 color: #FF0000;
45 display: inline-block;
46 font-weight: bold;
47 text-decoration: none;
48 text-shadow: 0 1px 1px #555555;
49 font-size: 13pt;
50 padding: 6px;
51 cursor: pointer; cursor: hand;
52 }
42 53
43 54 #container { } #container { }
44 55
 
... ... label {
288 299
289 300 .warning { .warning {
290 301 margin-top: 10px; margin-top: 10px;
291 background-color: #FFAAAA;
302 background-color: #FF0000;
292 303 padding: 5px; padding: 5px;
293 304 border: 1px solid #CCCCCC; border: 1px solid #CCCCCC;
294 305 display: table; display: table;
295 306 } }
296 307
297 .button {
298 background: -moz-linear-gradient(center top , #A0FFA0 0px, #A0FFA0 100%) repeat scroll 0 0 padding-box transparent;
299 border: 1px solid #CCCCCC;
300 border-radius: 4px 4px 4px 4px;
301 box-shadow: 0 2px 2px #90FF90 inset;
302 color: #90DD90;
303 display: inline-block;
304 font-weight: bold;
305 text-decoration: none;
306 text-shadow: 0 1px 1px #000000;
307
308 font-size: 24px;
309 padding: 8px;
310 }
File tests/root/themes/util/t3/c1 changed (mode: 100644) (index ef1fe7b..4b13aea)
1 @@if(@@X@@){{@@A@@}}{{@@B@@}}
1 XX@@if(@@X@@ == 1){{@@A@@}}{{@@B@@}}YY
File tests/root/themes/util/t3/c2 added (mode: 100644) (index 0000000..f921aa6)
1 XX
2 @@if(@@X@@ == 1){{
3 @@A@@
4 }}{{
5 @@B@@
6 }}
7 YY
File tests/root/themes/util/t3/c3 added (mode: 100644) (index 0000000..f0bb284)
1 XX@@if(@@X@@ == 1){{@@if(@@Y@@ == 1){{@@R@@}}{{@@T@@}}ZZ}}{{@@B@@}}YY
File tests/root/themes/util/t3/c4 added (mode: 100644) (index 0000000..4012a71)
1 XX
2 @@if(@@X@@ == 1){{
3 @@if(@@Y@@ == 1){{
4 @@if(@@Z@@ == 1){{
5 TRUE_LEVEL_2
6 }}{{
7 FALSE_LEVEL_2
8 }}
9 }}{{
10 FALSE_LEVEL_1
11 }}
12 }}{{
13 FALSE_LEVEL_0
14 }}
15 YY
File tests/root/themes/util/t3/c5 added (mode: 100644) (index 0000000..dd398d7)
1 XX-
2 @@if(@@X@@ == 1){{X1}}{{X0}}
3 @@if(@@Y@@ == 1){{Y1}}{{Y0}}
4 @@if(@@Z@@ == 1){{Z1}}{{Z0}}
5 -YY
File tests/util.php changed (mode: 100644) (index e3b7ff7..e78f681)
... ... if (strcmp($r, $e) != 0) {
65 65 exit(1); exit(1);
66 66 } }
67 67
68 // test rg_template with conditional formating
68 // test rg_template with conditional formating (false)
69 69 $data = array("X" => "0", "A" => "Avalue", "B" => "Bvalue"); $data = array("X" => "0", "A" => "Avalue", "B" => "Bvalue");
70 70 $r = rg_template("t3/c1", $data); $r = rg_template("t3/c1", $data);
71 $e = "Bvalue";
71 $e = "XXBvalueYY";
72 72 if (strcmp($r, $e) != 0) { if (strcmp($r, $e) != 0) {
73 73 echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n"; echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n";
74 74 exit(1); exit(1);
75 75 } }
76 76
77 // test rg_template with conditional formating
78 $data = array("X" => "34", "A" => "Avalue", "B" => "Bvalue");
77 // test rg_template with conditional formating (true)
78 $data = array("X" => "1", "A" => "Avalue", "B" => "Bvalue");
79 79 $r = rg_template("t3/c1", $data); $r = rg_template("t3/c1", $data);
80 $e = "Avalue";
80 $e = "XXAvalueYY";
81 if (strcmp($r, $e) != 0) {
82 echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n";
83 exit(1);
84 }
85
86 // test rg_template with conditional formating (multiline)
87 $data = array("X" => "1", "A" => "Avalue", "B" => "Bvalue");
88 $r = rg_template("t3/c1", $data);
89 $e = "XXAvalueYY";
90 if (strcmp($r, $e) != 0) {
91 echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n";
92 exit(1);
93 }
94
95 // test rg_template with conditional formating (nested 1)
96 $data = array("X" => "1", "Y" => "1", "A" => "Avalue", "B" => "Bvalue",
97 "R" => "Rvalue", "T" => "Tvalue");
98 $r = rg_template("t3/c3", $data);
99 $e = "XXRvalueZZYY";
100 if (strcmp($r, $e) != 0) {
101 echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n";
102 exit(1);
103 }
104
105 // test rg_template with conditional formating (nested 2)
106 $data = array("X" => "1", "Y" => "0", "A" => "Avalue", "B" => "Bvalue",
107 "R" => "Rvalue", "T" => "Tvalue");
108 $r = rg_template("t3/c3", $data);
109 $e = "XXTvalueZZYY";
110 if (strcmp($r, $e) != 0) {
111 echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n";
112 exit(1);
113 }
114
115 rg_log("test rg_template with conditional formating (nested 3)");
116 $data = array("X" => "0", "Y" => "1", "A" => "Avalue", "B" => "Bvalue",
117 "R" => "Rvalue", "T" => "Tvalue");
118 $r = rg_template("t3/c3", $data);
119 $e = "XXBvalueYY";
120 if (strcmp($r, $e) != 0) {
121 echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n";
122 exit(1);
123 }
124
125 rg_log("test rg_template with conditional formating (nested nested 1)");
126 $data = array("X" => "1", "Y" => "1", "Z" => "1");
127 $r = rg_template("t3/c4", $data);
128 $r = preg_replace('/\s/', '', $r);
129 $e = "XXTRUE_LEVEL_2YY";
130 if (strcmp($r, $e) != 0) {
131 echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n";
132 exit(1);
133 }
134
135 rg_log("test rg_template with conditional formating (nested nested 2)");
136 $data = array("X" => "1", "Y" => "0", "Z" => "1");
137 $r = rg_template("t3/c4", $data);
138 $r = preg_replace('/\s/', '', $r);
139 $e = "XXFALSE_LEVEL_1YY";
140 if (strcmp($r, $e) != 0) {
141 echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n";
142 exit(1);
143 }
144
145 rg_log("test rg_template with conditional formating (nested nested 2)");
146 $data = array("X" => "0", "Y" => "1", "Z" => "1");
147 $r = rg_template("t3/c4", $data);
148 $r = preg_replace('/\s/', '', $r);
149 $e = "XXFALSE_LEVEL_0YY";
150 if (strcmp($r, $e) != 0) {
151 echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n";
152 exit(1);
153 }
154
155 rg_log("test rg_template with conditional formating (nested nested 3)");
156 $data = array("X" => "0", "Y" => "0", "Z" => "0");
157 $r = rg_template("t3/c5", $data);
158 $r = preg_replace('/\s/', '', $r);
159 $e = "XX-X0Y0Z0-YY";
160 if (strcmp($r, $e) != 0) {
161 echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n";
162 exit(1);
163 }
164
165 rg_log("test rg_template with conditional formating (nested nested 4)");
166 $data = array("X" => "0", "Y" => "1", "Z" => "0");
167 $r = rg_template("t3/c5", $data);
168 $r = preg_replace('/\s/', '', $r);
169 $e = "XX-X0Y1Z0-YY";
81 170 if (strcmp($r, $e) != 0) { if (strcmp($r, $e) != 0) {
82 171 echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n"; echo "util.php: rg_template with conditionals is not working (r=$r e=$e)!\n";
83 172 exit(1); exit(1);
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://code.reversed.top/user/xaizek/rocketgit

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/rocketgit

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