⌈⌋ branch:  freshcode


Check-in [2f4cf1ea0f]

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

Overview
SHA1:2f4cf1ea0f16b21335bd652600a8374b2e903efa
Date: 2014-11-16 16:19:36
User: mario
Comment:Xfer cron.job for freshcode.clb JSON feed importing.
Tags And Properties
  • bgcolor=#ffeedd inherited from [ed2e13d670]
  • branch=mirror inherited from [df89a65d10]
  • sym-mirror inherited from [df89a65d10]
Context
2014-11-16
16:24
[45e1f25efb] Leaf: Switch to manual dependency loading (user: mario, tags: mirror)
16:19
[2f4cf1ea0f] Xfer cron.job for freshcode.clb JSON feed importing. (user: mario, tags: mirror)
16:16
[79e42f8f28] empty default files (user: mario, tags: mirror)
Changes

Added cron.daily/xfer.php.



























































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
<?php
/**
 * api: cli
 * title: XFER import
 * description: fetches central feed (freshcode.club), and imports new entries
 * version: 0.0
 * type: cron
 * x-cron: 0,6,12,18 * * * *
 * category: import
 * 
 * 
 * Fetches `http://freshcode.club/feed/xfer.json` for importing new entries.
 * Will forgo minor edits / t_changed entries, but import all new projects and
 * releases.
 *
 */


chdir(dirname(__DIR__));
include("./config.php");

// retrieve
$API = "http://freshcode.club/feed/xfer.json?num=100";
$json = curl($API)->exec();
$json = json_decode($json, TRUE);

// import
foreach ($json["releases"] as $r) {

    // if name+version combo unknown
    if (!release::exists($r["name"], $r["version"])) {

        // fetch any previous data
        $push = new release($r["name"]);

        // most fields come in reusable,
        // some need updating:
        array_walk($r["urls"], function(&$v, $k) { $v = "$k = $v"; });
        $r["urls"] = join("\n", $r["urls"]);

        // update DB fields
        $push->update(
            // newdata
            $r,
            // prefill
            [],
            // override flags
            [
               "hidden" => intval($r["hidden"]),
               "t_published" => strtotime($r["published"]),
               "t_changed" => strtotime($r["changed"]),
            ],
            //
            $_partial = FALSE
        );

        $push->store();
print_r($push);
    }
}