⌈⌋ ⎇ branch:  freshcode


Check-in [e56e768074]

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

Overview
Comment:Add background image for IndieAuth logon button, remove some debug messages.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: e56e768074859909286613831169624495e65bc5
User & Date: mario 2021-04-05 06:20:51
Context
2021-04-05
06:22
Add cash* spamwords. check-in: 75bba41295 user: mario tags: trunk
06:20
Add background image for IndieAuth logon button, remove some debug messages. check-in: e56e768074 user: mario tags: trunk
06:20
Use some short tags check-in: 13d1df713c user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to freshcode.css.

1
2
3
4
5
6
7
8
9
10
11
12
13
/**
 * api: css
 * type: stylesheet
 * title: freshcode.club layout+style
 * description: Simulates the late freecode.com layout and looks; well mostly.
 * version: 0.8.0
 *
 * Centered two-pane layout. The #main section is usually 33% of the screen width,
 * while the #sidebar floats at the right. They're repositioned only using padding:
 * to the outer html,body{}.
 *
 */






|







1
2
3
4
5
6
7
8
9
10
11
12
13
/**
 * api: css
 * type: stylesheet
 * title: freshcode.club layout+style
 * description: Simulates the late freecode.com layout and looks; well mostly.
 * version: 0.8.2
 *
 * Centered two-pane layout. The #main section is usually 33% of the screen width,
 * while the #sidebar floats at the right. They're repositioned only using padding:
 * to the outer html,body{}.
 *
 */

236
237
238
239
240
241
242

243
244
245
246
247
248
249
 *
 */
#sidebar {
    width: 15%;
    min-width: 175pt;
    min-height: 400pt;
    background: #fefdfd;

}
#sidebar.absolute-float {
    position: absolute;
    margin: 25pt 150pt 25pt 68%;
}
#sidebar section {
    border: 1.5pt solid #ccc;







>







236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
 *
 */
#sidebar {
    width: 15%;
    min-width: 175pt;
    min-height: 400pt;
    background: #fefdfd;
    max-width: 190pt;
}
#sidebar.absolute-float {
    position: absolute;
    margin: 25pt 150pt 25pt 68%;
}
#sidebar section {
    border: 1.5pt solid #ccc;
381
382
383
384
385
386
387









388
389
390
391
392
393
394
    color: #dde;
}
#main .login.box #login_url {
    background: #f7faff;
    background: linear-gradient(99deg, #888 0%, #a0a0a0 1%, #fc7 3%, #bbb 5%, #fff 8%);
    padding-left: 33px;
}











/**
 * Project listing on frontpage and /projects/xyz
 *
 */
#main .project {







>
>
>
>
>
>
>
>
>







382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
    color: #dde;
}
#main .login.box #login_url {
    background: #f7faff;
    background: linear-gradient(99deg, #888 0%, #a0a0a0 1%, #fc7 3%, #bbb 5%, #fff 8%);
    padding-left: 33px;
}
#main .box input.indieauth {
    padding: 5pt 20pt 5pt 35pt;
    background: #f7faff url("img/indieauth.png") no-repeat 10px 3px;
    font-weight: bold;
    text-shadow: 1px 1px #999;
}
#main .box input.indieauth:hover {
    background-color: #7b7 !important;
}


/**
 * Project listing on frontpage and /projects/xyz
 *
 */
#main .project {
842
843
844
845
846
847
848
849

    padding-top: 15pt;
    padding-bottom: 15pt;
    color: #fff;
    height: 50pt;
}
#bottom a { color: #fc9; }

[5~








<
>
852
853
854
855
856
857
858

859
    padding-top: 15pt;
    padding-bottom: 15pt;
    color: #fff;
    height: 50pt;
}
#bottom a { color: #fc9; }


}

Added img/indieauth.png.

cannot compute difference between binary files

Changes to lib/deferred_openid_session.php.

87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
function verify_indieauth() {
    # "https://freshcode.club/login?code=...&me=http://userurl..."
    $fields = [
        "code" => $_REQUEST->raw["code"],
        "client_id"  => INDIEAUTH_CLIENT_ID,
        "redirect_uri" => INDIEAUTH_REDIRECT,
    ];
    $json = curl(INDIEAUTH_API)->post(1)->postfields(
        http_build_query($fields)#->httpheader(array("Accept: application/json"))
    )->exec();
    print($json);
    if ($json) {
        $d = json_decode($json, True) or parse_str($json, $d);
        if (!empty($d["me"])) {
            session_fresh();
            return $_SESSION["openid"] = $d["me"];
        }
    }







|
|

<







87
88
89
90
91
92
93
94
95
96

97
98
99
100
101
102
103
function verify_indieauth() {
    # "https://freshcode.club/login?code=...&me=http://userurl..."
    $fields = [
        "code" => $_REQUEST->raw["code"],
        "client_id"  => INDIEAUTH_CLIENT_ID,
        "redirect_uri" => INDIEAUTH_REDIRECT,
    ];
    $json = curl(INDIEAUTH_API)->httpheader(array("Accept: application/json"))->post(1)->postfields(
        http_build_query($fields)
    )->exec();

    if ($json) {
        $d = json_decode($json, True) or parse_str($json, $d);
        if (!empty($d["me"])) {
            session_fresh();
            return $_SESSION["openid"] = $d["me"];
        }
    }

Changes to page_login.php.

14
15
16
17
18
19
20




21
22
23
24
25
26
27
28
 * kept plain in the session, but hashed in per-project
 * `lock` entries later.
 *
 */


// initiate verification




if ($_POST->has("login_url")) {

    try {
        $openid = new LightOpenID(HTTP_HOST);
        $openid->verify_peer = false;
        $openid->identity = $_POST->uri["login_url"];
        $openid->optional = array("namePerson/friendly");
        exit(header("Location: " . $openid->authUrl()));







>
>
>
>
|







14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 * kept plain in the session, but hashed in per-project
 * `lock` entries later.
 *
 */


// initiate verification
if ($_POST->has("initiate_indieauth")) {
    # should be done at this point
    initiate_indieauth($_POST->url["login_url"]);
}
elseif ($_POST->has("login_url")) {

    try {
        $openid = new LightOpenID(HTTP_HOST);
        $openid->verify_peer = false;
        $openid->identity = $_POST->uri["login_url"];
        $openid->optional = array("namePerson/friendly");
        exit(header("Location: " . $openid->authUrl()));
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

    print<<<HTML
    <h3>Login</h3>

    <table>
    <tr>
    <td>
    <p>Please provide an <a href="http://en.wikipedia.org/wiki/OpenID">OpenID</a> handle.</p>

    <p>
     <form action="" method=POST class="login box">
       <input type=url id=login_url name=login_url size=50 value="" placeholder="http://name.openid.xy/">
       <br>
       <input type=password style=display:none value=dummy>

       <input type=submit value=Login>
       <span class="service-logins">
          Or use your <a onclick="$('#login_url').val('http://facebook-openid.appspot.com/YourFaceBookLogin').focus().prop({selectionStart:35, selectionEnd:52});">Facebook</a>
                | <a onclick="$('#login_url').val('http://me.yahoo.com/#yourname').focus().prop({selectionStart:21, selectionEnd:29});">Yahoo</a> | <br>
                <a onclick="$('#login_url').val('http://launchpad.net/~yourname').focus().prop({selectionStart:22, selectionEnd:30});">Launchpad</a>
                | <a onclick="$('#login_url').val('https://openid.stackexchange.com/#yourname').focus().prop({selectionStart:34, selectionEnd:42});">StackOverflow</a> login
       </span> 
     </form>
    </p>
    <p>There are intentionally no user accounts on freshcode.club,
    but this prerequisite also helps eschew spam submissions.</p>
    </td>
    <td>







|



|


>
|

<
|
|
<







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

    print<<<HTML
    <h3>Login</h3>

    <table>
    <tr>
    <td>
    <p>Use your <a href="https://indielogin.com/">IndieAuth</a> (or OpenID) address.</p>

    <p>
     <form action="" method=POST class="login box">
       <input type=url id=login_url name=login_url size=50 value="" placeholder="https://name.example.net/">
       <br>
       <input type=password style=display:none value=dummy>
       <input type=submit name=initiate_indieauth value=IndieAuth>
       <input type=submit name=initiate_openid value=OpenID>
       <span class="service-logins">

          Or use your <a onclick="$('#login_url').val('http://me.yahoo.com/#yourname').focus().prop({selectionStart:21, selectionEnd:29});">Yahoo</a> | <br>
                <a onclick="$('#login_url').val('http://launchpad.net/~yourname').focus().prop({selectionStart:22, selectionEnd:30});">Launchpad</a> login

       </span> 
     </form>
    </p>
    <p>There are intentionally no user accounts on freshcode.club,
    but this prerequisite also helps eschew spam submissions.</p>
    </td>
    <td>
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
// a previous login was already successful
else {

    print "<h3>Already logged in</h3>";
    
    print isset($login_hint)
        ? "<p>$login_hint</p>"
        : "<p>You have associated an OpenID handle (<var>$_SESSION[openid]</var>).
           <form action='/login/logout' method=POST><button>Logout</button></form></p>";
    
}

?></div></section><?php
include("template/bottom.php");

?>







|








111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// a previous login was already successful
else {

    print "<h3>Already logged in</h3>";
    
    print isset($login_hint)
        ? "<p>$login_hint</p>"
        : "<p>You have associated an IndieAuth/OpenID handle (<var>$_SESSION[openid]</var>).
           <form action='/login/logout' method=POST><button>Logout</button></form></p>";
    
}

?></div></section><?php
include("template/bottom.php");

?>