Collection of themes/skins for the Fossil SCM

⌈⌋ ⎇ branch:  Fossil Skins Extra


Check-in [c09979b7a9]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Enable wikitag saving (via new `fossil_exec()`)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c09979b7a95cda1e17159fdfb41f9aa512087da0
User & Date: mario 2021-10-28 01:21:10
Context
2022-01-21
21:30
Support technotes check-in: 18aea61ba2 user: mario tags: trunk
2021-10-28
01:21
Enable wikitag saving (via new `fossil_exec()`) check-in: c09979b7a9 user: mario tags: trunk
2021-10-25
18:54
trim wiki page name, remove more github remnants check-in: 01dcd6c9b8 user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to extroot/fossil_common.php.

113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
 */
function fossil_exec($args, $input=NULL) {
    $args = array_map(
        function ($s) {
            return escapeshellarg(preg_replace("/[^\\r\\n\\t\\x20-\\xFF]/", "", $s));
        },
        array_merge(
            ["--nocgi"], $args, ["-R", $_SERVER["FOSSIL_REPOSITORY"]]
        )
    );    
    $cmd = FOSSIL_BIN . " " . implode(" ", $args) . " 2>&1";
    if ($input) {
        #$tmpfn = tempnam();
        #$cmd .= " < $tmpfn";
    }







|







113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
 */
function fossil_exec($args, $input=NULL) {
    $args = array_map(
        function ($s) {
            return escapeshellarg(preg_replace("/[^\\r\\n\\t\\x20-\\xFF]/", "", $s));
        },
        array_merge(
            ["--nocgi"], array_filter($args, "strlen"), ["-R", $_SERVER["FOSSIL_REPOSITORY"]]
        )
    );    
    $cmd = FOSSIL_BIN . " " . implode(" ", $args) . " 2>&1";
    if ($input) {
        #$tmpfn = tempnam();
        #$cmd .= " < $tmpfn";
    }

Changes to extroot/wikitag.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/php-cgi -dcgi.force_redirect=0
<?php
# encoding: utf-8
# api: cgi
# type: config
# category: wiki
# title: WikiTag
# description: tag wiki pages
# version: 0.1
# state: beta
# config: -
# access: ailsv
#
# Simplifies adding tags to wiki pages.
# Basically a wrapper around `fossil tag add` which looks up the first artifact id.
# (On the assumption that the very first page artifict should declare any tags.)








|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/usr/bin/php-cgi -dcgi.force_redirect=0
<?php
# encoding: utf-8
# api: cgi
# type: config
# category: wiki
# title: WikiTag
# description: tag wiki pages
# version: 0.2
# state: beta
# config: -
# access: ailsv
#
# Simplifies adding tags to wiki pages.
# Basically a wrapper around `fossil tag add` which looks up the first artifact id.
# (On the assumption that the very first page artifict should declare any tags.)
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
        }
        $uuid = first_uuid($page);
        $new = array_filter(str_getcsv($tags));
        $old = array_filter(str_getcsv($orig[$page]));
        #-- add
        foreach (array_diff($new, $old) as $add) {
            $propagate = empty($_POST["propagate"]) ? "" : "--propagate";
            print "fossil tag add $propagate {$q($add)} {$q($uuid)} -R {$_SERVER['FOSSIL_REPOSITORY']}<br>";
        }
        #-- rm
        foreach (array_diff($old, $new) as $rm) {
            print "fossil tag cancel {$q($rm)} {$q($uuid)} -R {$_SERVER['FOSSIL_REPOSITORY']}<br>";
        }
    }
}
if (!empty($_POST["tags"])) {
    if (has_cap("ailsv")) {  #admin,checkin,modwiki,superuser,developer
        save($_POST["tags"]);
    }







|



|







90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
        }
        $uuid = first_uuid($page);
        $new = array_filter(str_getcsv($tags));
        $old = array_filter(str_getcsv($orig[$page]));
        #-- add
        foreach (array_diff($new, $old) as $add) {
            $propagate = empty($_POST["propagate"]) ? "" : "--propagate";
            fossil_exec(["tag", "add", $propagate, $add, $uuid]);
        }
        #-- rm
        foreach (array_diff($old, $new) as $rm) {
            fossil_exec(["tag", "cancel", $rm, $uuid]);
        }
    }
}
if (!empty($_POST["tags"])) {
    if (has_cap("ailsv")) {  #admin,checkin,modwiki,superuser,developer
        save($_POST["tags"]);
    }

Changes to tools/fossil-webhook.

462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479






480
481
482
483
484
485
486
    }
    // could alternatively try sync-with:*, but that might leak sensitive peers
    else {
        return $urls[0];
    }
}

#-- artifact owner
function get_user($uuid) {
    $r = db("
        SELECT login, size
          FROM blob
          LEFT JOIN rcvfrom ON blob.rcvid=rcvfrom.rcvid
          LEFT JOIN user ON user.uid=rcvfrom.uid
         WHERE uuid = ?",
        [$uuid]
    );
    return $r ? $r[0]["login"] : null;






}

#-- primary user
function get_main_user() {
    return db("
        SELECT user, COUNT(type) AS cnt
          FROM event







|
|








|
>
>
>
>
>
>







462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
    }
    // could alternatively try sync-with:*, but that might leak sensitive peers
    else {
        return $urls[0];
    }
}

#-- artifact user + size
function get_blob_info($uuid) {
    $r = db("
        SELECT login, size
          FROM blob
          LEFT JOIN rcvfrom ON blob.rcvid=rcvfrom.rcvid
          LEFT JOIN user ON user.uid=rcvfrom.uid
         WHERE uuid = ?",
        [$uuid]
    );
    return $r ? $r[0] : [];
}

#-- artifact owner
function get_user($uuid) {
    $r = get_blob_info($uuid);
    return $r ? $r["login"] : null;
}

#-- primary user
function get_main_user() {
    return db("
        SELECT user, COUNT(type) AS cnt
          FROM event
508
509
510
511
512
513
514

515






516
517
518
519
520
521
522
            ];
        },
        $rows
    );
    return $rows;
}


#-- turn uuid into appropriate url






function expand_artifact($row, $url, $q="urlencode") {
    global $cfg;
    switch ($row["type"]) {
        case "attachment":
        case "file":
            $row["name"] = $row["comment"];
            $row["url_raw"] = "$url/raw/$row[uuid]?at={$q($row['name'])}";







>
|
>
>
>
>
>
>







514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
            ];
        },
        $rows
    );
    return $rows;
}

/**
 * Expand artifact uuids.
 *
 * Adds access urls (raw/ and json/ API) to simplify webhook consumption.
 * And fill in some basic attributes depending on type. (No need to turn
 * into a full push. Though perhaps `wiki` artifacts could be sent along.)
 *
 */
function expand_artifact($row, $url, $q="urlencode") {
    global $cfg;
    switch ($row["type"]) {
        case "attachment":
        case "file":
            $row["name"] = $row["comment"];
            $row["url_raw"] = "$url/raw/$row[uuid]?at={$q($row['name'])}";
531
532
533
534
535
536
537
538
539



540
541
542
543

544


545
546
547
548
549
550
551
            $row["url_raw"] = "$url/raw/{$q($row['uuid'])}?at={$q($row['uuid'])}";  # ERR: this still contains the artifact header
            $row["url_json"] = "$url/json/wiki/get/{$q($row['name'])}";
            $row["url_web"] = "$url/wiki/{$q($row['name'])}";
            break;
        case "check-in":
            $row["url_json"] = "$url/json/artifact/{$q($row['uuid'])}";
            break;
        case "attachment-control":
        case "tag":



        case "referenced":
        default:
            break;
    }

    $cfg["user"] = $row["user"] = get_user($row["uuid"]);


    return $row;
}

#-- check-in or file, or other artifact types
function main_action($stdin) {
    foreach (["check-in", "file", "attachment", "wiki", "referenced", "tag"] as $t) {
        if (preg_match("/^\w+\s$t\\b/m", $stdin)) {







<

>
>
>




>
|
>
>







544
545
546
547
548
549
550

551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
            $row["url_raw"] = "$url/raw/{$q($row['uuid'])}?at={$q($row['uuid'])}";  # ERR: this still contains the artifact header
            $row["url_json"] = "$url/json/wiki/get/{$q($row['name'])}";
            $row["url_web"] = "$url/wiki/{$q($row['name'])}";
            break;
        case "check-in":
            $row["url_json"] = "$url/json/artifact/{$q($row['uuid'])}";
            break;

        case "tag":
            # `tag 123a31091fff0`
            # would need artifact lookup for `T +sym-1.0.0 xxxxxxxxxxxxxxx`
        case "attachment-control":
        case "referenced":
        default:
            break;
    }
    if ($blob = get_blob_info($row["uuid"])) {
        $cfg["user"] = $blob["user"];
        $row += $blob;
    }
    return $row;
}

#-- check-in or file, or other artifact types
function main_action($stdin) {
    foreach (["check-in", "file", "attachment", "wiki", "referenced", "tag"] as $t) {
        if (preg_match("/^\w+\s$t\\b/m", $stdin)) {