Check-in [02929b0711]
Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Twitter feed of recent releases. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
02929b0711c97d753847a549b6daf536 |
User & Date: | mario 2014-11-10 19:13:36 |
Context
2014-11-10
| ||
19:14 | Reduce extracted ::scope_tags() per unique() check-in: 4691c17354 user: mario tags: trunk | |
19:13 | Twitter feed of recent releases. check-in: 02929b0711 user: mario tags: trunk | |
2014-11-08
| ||
15:29 | CSS for audio tag, .editor_note (submit form), more narrow frontpage listings, styles for "GitHub releases" entries. check-in: 4a0624612c user: mario tags: trunk | |
Changes
Added cron.daily/twitter.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 | <?php /** * api: cli * title: Twitter bridge * description: Posts recent releases on twitter * version: 0.1 * category: rpc * type: cron * x-cron: 50 * * * * * * Summarize new releases for Twitter feed. * Currently using `twidge` (pre-configured in $HOME), * which doesn't support //t.co/ inline images yet. * */ chdir(dirname(__DIR__)); include("config.php"); /** * Releases within the last hour * */ $rel = db(" SELECT * FROM release_versions WHERE t_published >= ? ", time()-7300 )->fetchAll(); // query recent/previous status messages $prev = twit("lsarchive"); // condense individual tweets foreach ($rel as $row) { // skip existing if (is_int(strpos($prev, $row["title"]))) { print "skip($row[name]) "; continue; } // homepage if (empty($row["homepage"]) or strlen($row["homepage"] > 80)) { $row["homepage"] = "http://freshcode.club/projects/$row[name]"; } // prepare post $msg = "$row[title] $row[version] released. $row[homepage]"; $msg = preg_replace("/\s+/", " ", $msg); // add tags $tags = p_csv($row["tags"]); shuffle($tags); foreach ($tags as $tag) { $tag = preg_replace("/^(\w)\+\+/", "\\1pp", $tag); $tag = preg_replace("/-/", "_", $tag); $msg .= " #$tag"; } // cut to limit while (strlen($msg) > 140) { $msg = preg_replace("/\s\S+$/s", "", $msg); } // send print_r("$msg\n"); twit("update", $msg); } /** * Invoke cmdline twitter client * */ function twit() { $cmd = "twidge"; foreach (func_get_args() as $param) { $cmd .= " " . escapeshellarg($param); } return ` $cmd `; } ?> |