Collection of themes/skins for the Fossil SCM

βŒˆβŒ‹ βŽ‡ branch:  Fossil Skins Extra


Check-in [fe53bd85f9]

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

Overview
Comment:tag wiki pages (on initial artifactt)
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: fe53bd85f9046890b46d23c9e52fddac1344fb80
User & Date: mario 2021-10-24 06:19:56
Context
2021-10-24
06:20
standardize PMD type: further check-in: 7573908dd3 user: mario tags: trunk
06:19
tag wiki pages (on initial artifactt) check-in: fe53bd85f9 user: mario tags: trunk
06:19
add has_cap() and fossil_exec() check-in: f0a1108c8d user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added extroot/wikitag.



































































































































































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/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.)
#
#


#-- init
include("./fossil_common.php");   # db() etc.
if (!is_admin()) {
    die("Admin-only");
}
error_reporting(E_ALL);

#-- fossil HTML output
function page_md($text) {
    header("Content-Type: text/html; charset=utf-8");
    print <<<EOF
<div class='fossil-doc' data-title='Tag wiki pages'>
<style>
 .save-button {
    padding: 2pt 30pt;
 }
</style>
$text
EOF;
}


#-- query page names and tags
function wiki_pages($TYPEFILTER = "AND tagtype != 0") {
    $r = db("
        SELECT
           SUBSTR(tagname,6) AS pagename,
           MIN(tagxref.rid) AS rid,
           (SELECT GROUP_CONCAT(tagname, ', ')
              FROM (SELECT tagname
                      FROM tagxref tx2
                      JOIN tag tg2 ON tx2.tagid=tg2.tagid
                     WHERE tx2.rid=tagxref.rid
                       AND tx2.tagid != tagxref.tagid
                       $TYPEFILTER
                    )
            ) AS pagetag
        FROM
           tagxref
        LEFT JOIN
           tag ON tagxref.tagid=tag.tagid
        WHERE
           tagname LIKE 'wiki-%' AND
           NOT tagxref.tagid IN (SELECT tagid FROM (SELECT tagid,value,MAX(rid) FROM tagxref GROUP BY tagid) WHERE NOT value)
        GROUP BY
           tagxref.tagid
        ORDER BY
           LOWER(pagename)
    ");
    return array_column($r, $val="pagetag", $key="pagename");
}
function first_uuid($page) {
    return db("
        SELECT uuid, MIN(blob.rid)
          FROM blob
          LEFT JOIN tagxref ON blob.rid=tagxref.rid
          LEFT JOIN tag ON tagxref.tagid=tag.tagid
         WHERE tagname=?
         GROUP BY tagxref.tagid
    ", ["wiki-$page"])[0]["uuid"];
}


#-- saving
function save($pt, $q="escapeshellarg") {
    $orig = wiki_pages();
    foreach ($pt as $page=>$tags) {
        if ($tags == $orig[$page]) {
            continue;
        }
        $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"]);
    }
}

#-- get page→tags list
$pages = wiki_pages();

#-- print hook row
function pt_row($page, $tags, $h="h") {
    print <<<END
    <tr>
        <td>{$h($page)}</td>
        <td><input name="tags[{$h($page)}]" value="{$h($tags)}"></td>
    </tr>
END;
}


#-- build form table
page_md("
  <div class=config-list>
  <form method=POST enctype='multipart/form-data'>
  <table>
  <tr> <th>Page</th> <th>Tags</th> </tr>
");

# fields
foreach ($pages as $page=>$tags) {
    pt_row($page, $tags);
}

?>
<tr><td colspan=2 align=center><input type=submit value="Add / Save" class=save-button></td></tr>
<tr><td colspan=2 align=center><label><input type=checkbox name=propagate value=1 checked> <b>--propagate</b> added tags</label></td></tr>
</table>
</form>
<?php
 has_cap("ailsv") or print("<div class=warning>You don't have permission to change tags.</div>");
?>