Check-in [cb3512ec8a]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Add GitHub trees query |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
cb3512ec8ae05e5c981461e5e6802eaf |
User & Date: | mario 2021-10-19 17:52:10 |
Context
2021-10-19
| ||
18:30 | Add references to builtin JSON api check-in: 318e9394db user: mario tags: trunk | |
17:52 | Add GitHub trees query check-in: cb3512ec8a user: mario tags: trunk | |
16:46 | Remove :memory: binding, fx_meta was acting up check-in: aeec556468 user: mario tags: trunk | |
Changes
Added extroot/trees.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | #!/usr/bin/php-cgi -dcgi.force_redirect=0 <?php # encoding: utf-8 # api: cgi # type: output # category: api # title: trees API # description: Simulate GitHub directory listing response # version: 0.1 # state: beta # depends: php:sqlite # config: - # # Always outputs complete file list, trunk only. # #-- init include("./fossil_common.php"); #$fn = ltrim($_SERVER["PATH_INFO"], "/"); #print_r($_SERVER); #-- search function file_list() { return db(" SELECT uuid, name, mperm, size, MAX(rid) FROM blob LEFT JOIN mlink ON blob.rid=mlink.fid LEFT JOIN filename ON mlink.fnid=filename.fnid GROUP BY name ORDER BY name --ORDER BY rid DESC "); } function trees() { $r = []; foreach(file_list() as $f) { if (empty($f["name"])) { continue; } $r[] = [ "path" => $f["name"], "mode" => decoct($f["mperm"]), "type" => "blob", "sha" => $f["uuid"], "size" => $f["size"], "url" => "$_SERVER[FOSSIL_SELF]raw/$f[uuid]?at=$f[name]" ]; } return $r; } function last_uuid() { return db("SELECT uuid FROM blob ORDER BY rid DESC LIMIT 1")[0]["uuid"]; } #-- output header("Content-Type: application/json"); print(json_encode([ "sha" => last_uuid(), "url" => "$_SERVER[FOSSIL_SELF]ext/trees", "tree" => trees(), "truncated" => false ], JSON_PRETTY_PRINT|JSON_UNESCAPED_SLASHES)); |