Check-in [a7d9dca977]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Initial exchange format /feed/xfer and per-project /feed/linux JSON release lists. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
a7d9dca977bb1a0b349fb9db10090e6f |
User & Date: | mario 2014-06-30 00:25:25 |
Context
2014-06-30
| ||
00:44 | Link list is now a board of buttons. check-in: f9f2c3ea7b user: mario tags: trunk | |
00:25 | Initial exchange format /feed/xfer and per-project /feed/linux JSON release lists. check-in: a7d9dca977 user: mario tags: trunk | |
2014-06-27
| ||
00:41 | New indexes and views. check-in: 8e84cd0fc1 user: mario tags: trunk | |
Changes
Added page_feed.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 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 | <?php /** * api: freshcode * title: json feeds * description: exchange protocol and per-project feeds * version: 1.0 * license: CC-BY-SA * depends: json, db * * Generates /xfer stream and per-/project release feeds. * Both only JSON for now. * (No content-negotiation, as for RSS/ATOM a different * content summary probably made more sense.) * * This is still susceptible to changes. Currently freshcode.club * seems the only FM-reimplementation. But obviously the data * format should converge to facilitate proper synchronization. * */ /** * group and rename internal columns into feed structure * */ #-- general project description function feed_project($row) { return array( "name" => $row["name"], "title" => $row["title"], "description" => $row["description"], "homepage" => $row["homepage"], "license" => $row["license"], "tags" => $row["tags"], "image" => $row["image"], "submitter" => $row["submitter"], "urls" => p_key_value($row["urls"]), ); } #-- version/release blocks function feed_release($row) { return array( "version" => $row["version"], "state" => $row["state"], "scope" => $row["scope"], "changes" => $row["changes"], "download" => versioned_url($row["download"], $row["version"]), "published" => date(DateTime::ISO8601, $row["t_published"]), ); } #-- exchange data function feed_xfer($row) { return array( "hidden" => $row["hidden"], "changed" => date(DateTime::ISO8601, $row["t_published"]), "autoupdate_module" => $row["autoupdate_module"], "autoupdate_url" => $row["autoupdate_url"], "autoupdate_regex" => $row["autoupdate_regex"], // following fields will not be transferred for privacy reasons # "submitter_openid" => $row["submitter_openid"], # "lock" => $row["submitter_lock"], ); } #-- something was requested if ($name = $_GET->id["name"]) { $feed = array( "\$feed-origin" => "http://freshcode.club/", "\$feed-license" => "CC-BY-SA 3.0", ); #-- exchange data if ($name == "xfer") { $feed["releases"] = array(); $r = db("SELECT * FROM release_versions LIMIT 100"); while ( $row = $r->fetch() ) { $feed["releases"][] = feed_project($row) + feed_release($row) + feed_xfer($row); } } #-- per project else { $r = db("SELECT * FROM release_versions WHERE name=? LIMIT 10", $name); while ( $row = $r->fetch() ) { // project description isset($feed["releases"]) or $feed += feed_project($row) + array("releases" => array()); // versions $feed["releases"][] = feed_release($row); } } header("Content-Type: json/vnd.freshcode.club; charset=UTF-8"); exit(json_encode($feed, JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES)); } #-- else print an info page else { include("layout_header.php"); ?> <section id=main> <h4>Feeds</h4> <p> You can get any projects <b>releases.json</b> feed using<br><tt>http://freshcode.org/feed/<i>projectname</i></tt>. </p> <p> Whereas using <i>xfer</i> will return the whole recent changes list. </p> <?php include("layout_bottom.php"); } |