Collection of themes/skins for the Fossil SCM

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


Check-in [53aa554cb8]

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

Overview
Comment:Move fields declaration atop.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 53aa554cb8e7c1a81c87e8d30ab3883dc429462e
User & Date: mario 2021-04-04 14:39:32
Context
2021-04-04
16:54
Add scope support, confirm page, and code_challenge fields (not verified yet) check-in: 20e5c47f73 user: mario tags: trunk
14:39
Move fields declaration atop. check-in: 53aa554cb8 user: mario tags: trunk
14:39
Extensions index script check-in: 005d5c7bf8 user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to extroot/user_config.

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
#!/usr/bin/php-cgi -dcgi.force_redirect=0
<?php
# encoding: utf-8
# api: cgi
# type: edit
# title: User editing
# description: Provides an editing interface to user fields (info)
# version: 0.1
# state: alpha
# depends: php:sqlite
# config: -
#
# Fairly simple editing UI for user.info table, and possibly some
# new fields. This is basically an addition to the IndieAuth plugin,
# so users can actually update their contact information etc.
#
# New fields must be added in:
#   ยท field_input() $fields  โ†’ defaults
#   ยท save_fields() $allowed  โ†’ limits which columns may be updated
#

if ($_REQUEST["dbg"]) {
    error_reporting(E_ALL); ini_set("display_errors", 1);
}














#-- database (== fossil repo)
function db($sql="", $params=[]) {
    static $db;
    if (empty($db)) {
        $db = new PDO("sqlite:$_SERVER[FOSSIL_REPOSITORY]");
    }







|








|
<
<





>
>
>
>
>
>
>
>
>
>
>
>
>







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
#!/usr/bin/php-cgi -dcgi.force_redirect=0
<?php
# encoding: utf-8
# api: cgi
# type: edit
# title: User editing
# description: Provides an editing interface to user fields (info)
# version: 0.2
# state: alpha
# depends: php:sqlite
# config: -
#
# Fairly simple editing UI for user.info table, and possibly some
# new fields. This is basically an addition to the IndieAuth plugin,
# so users can actually update their contact information etc.
#
# New fields must be added in $fields[] atop.


#

if ($_REQUEST["dbg"]) {
    error_reporting(E_ALL); ini_set("display_errors", 1);
}

#-- allowed/new fields
$fields = [
    "info" => [
        "title" => "Contact info",
        "desc" => "This is usually just an email address. For using git-fast-export this must be a single line.",
    ],
    "homepage" => [
        "title" => "Homepage URLs",
        "desc" => "This will create a new column for listing user urls. Which is used by the IndieAuth plugin to verify authorization requests.",
    ],
];


#-- database (== fossil repo)
function db($sql="", $params=[]) {
    static $db;
    if (empty($db)) {
        $db = new PDO("sqlite:$_SERVER[FOSSIL_REPOSITORY]");
    }
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
}
function h($s) {
    return htmlspecialchars($s, ENT_QUOTES|ENT_HTML5, "UTF-8");
}


#-- show available fields
function field_inputs($user, $names="info") {
    // get existing columns
    $fields = array_merge(
        [
            "info" => "",
            "homepage" => "",
        ],
        db("SELECT $names FROM user WHERE login=?", [$user])[0]
    );
    
    // desc
    $titles = [
        "info" => "Contact info",
        "homepage" => "Homepage URLs",
    ];
    $desc = [
        "info" => "This is usually just an email address. For using git-fast-export this must be a single line.",
        "homepage" => "This will create a new column for listing user urls. Which is used by the IndieAuth plugin to verify authorization requests.",
    ];
    
    // output form
    $html = ""; $h = "h";
    foreach ($fields as $name=>$value) {

        $html .= <<<HTML
          <p>
             <h4>{$h($titles[$name] ?: $name)}</h4>
             <textarea name='{$h($name)}' rows=4 cols=80>{$h($value)}</textarea>
             <br>\n<small>{$desc[$name]}</small>
          </p>\n
HTML;
    }
    return $html;
}

#-- store them back.
function save_fields($user, $fields) {

    $allowed = [
        "info", "homepage"
    ];
    $existing_columns = array_keys(
        db("SELECT * FROM user WHERE login=?", [$user])[0]
    );
    
    foreach ($fields as $name=>$value) {
        if (!in_array($name, $allowed)) {
            continue;







|
<
|
|
|
<
<
|
<
<
<
<
<
<
<
<
<
<
<



|
>


|
|
|







|
>
|
<
<







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
}
function h($s) {
    return htmlspecialchars($s, ENT_QUOTES|ENT_HTML5, "UTF-8");
}


#-- show available fields
function field_inputs($user, $names="info,homepage") {

    global $fields;

    // get existing columns


    $values = db("SELECT $names FROM user WHERE login=?", [$user])[0];











    
    // output form
    $html = ""; $h = "h";
    foreach ($fields as $name=>$props) {
        extract($props);
        $html .= <<<HTML
          <p>
             <h4>{$h($title ?: $name)}</h4>
             <textarea name='{$h($name)}' rows=3 cols=80>{$h($values[$name])}</textarea>
             <br>\n<small>{$desc}</small>
          </p>\n
HTML;
    }
    return $html;
}

#-- store them back.
function save_fields($user) {
    global $fields;
    $allowed = array_keys($fields);


    $existing_columns = array_keys(
        db("SELECT * FROM user WHERE login=?", [$user])[0]
    );
    
    foreach ($fields as $name=>$value) {
        if (!in_array($name, $allowed)) {
            continue;