Permalink
Browse files

dev-tools: txp-index

  • Loading branch information...
makss committed Nov 14, 2017
1 parent 8623e0b commit e87687acb6de6b4b61f8f36a43837ec8950f6faa
Showing with 65 additions and 0 deletions.
  1. +62 −0 .github/txp-index.php
  2. +1 −0 .gitignore
  3. +1 −0 README.md
  4. +1 −0 package.json
View
@@ -0,0 +1,62 @@
<?php
$gitview = 'https://github.com/textpattern/textpattern/blob';
$outdir = '.github/index';
@mkdir($outdir);
$branch = index_get_branch();
index_code('callback_event');
index_code('callback_event_ref');
exit;
function index_code($search)
{
global $gitview, $branch, $outdir;
$out = array();
$out2 = array();
$txt = shell_exec('grep --exclude-dir=.github --include=\*.php -rn . -e "'.escapeshellcmd($search).'("');
if (preg_match_all('%^\./(.*?):(.*?):(?:\s+)?(.*?'.preg_quote($search).'\((.*))$%ium', $txt, $mm)) {
foreach ($mm[3] as $key=>$d) {
if (! preg_match('%^(\*|function)%', trim($d))) {
$d = trim(preg_replace('%(<\?php|\?\>)%', '', $d));
$k = preg_replace('%[\,\)].*$%', '', $mm[4][$key]);
$out["{$k}_{$key}"] = "<tr><td>{$k}</td><td>{$d}</td><td><a href='{$gitview}/{$branch}/{$mm[1][$key]}#L{$mm[2][$key]}'>{$mm[1][$key]}</a></td></tr>";
}
}
ksort($out);
index_file_save($search, '<table class="idx">'.join("\n", $out)."\n".'</table>');
}
}
function index_get_branch()
{
$txt = @file_get_contents('.git/HEAD');
if (preg_match('%refs/heads/(.*)$%m', $txt, $mm)) {
return $mm[1];
}
return '';
}
function index_file_save($name, $data)
{
global $branch, $outdir;
$head =<<<EOF
<!DOCTYPE html><html lang="en-gb" dir="ltr">
<head>
<meta charset="utf-8">
<title>{$branch} :: {$name}</title>
<style>
body { background-color: #fafafa; }
.idx tr:nth-child(odd) { background-color: #eee; }
.idx tr:hover { background-color: #ccc; }
</style>
</head>
<body>
EOF;
file_put_contents("{$outdir}/{$branch}__{$name}.html", $head.$data.'</body></html>');
}
View
@@ -24,3 +24,4 @@ Thumbs.db
/npm-debug.log
/yarn.lock
/yarn-error.log
.github/index
View
@@ -125,6 +125,7 @@ Usage: `npm run txp-gitdist <version> [dest-dir]` (`dest-dir` defaults to a
temporary location).
```ShellSession
npm run txp-index
npm run txp-checksums
npm run txp-gitdist 1.2.3 ../my-dest-dir
```
View
@@ -36,6 +36,7 @@
"get-classic-admin-theme": "sh .github/get-classic-admin-theme.sh",
"get-hive-admin-theme": "sh .github/get-hive-admin-theme.sh",
"get-default-theme": "sh .github/get-default-theme.sh",
"txp-index": "php .github/txp-index.php
"txp-checksums": "php .github/txp-checksums.php",
"txp-gitdist": "npm run txp-checksums && sh .github/txp-gitdist.sh"
},

2 comments on commit e87687a

@philwareham

This comment has been minimized.

Show comment
Hide comment
@philwareham

philwareham Nov 14, 2017

Member

What's this, then?! 🙂

Member

philwareham replied Nov 14, 2017

What's this, then?! 🙂

@makss

This comment has been minimized.

Show comment
Hide comment
@makss

makss Nov 14, 2017

Member

This is an attempt to automatically generate the actual callback list. I always forget what kind of callbacks we have. ;-)
Related issue #964

Member

makss replied Nov 14, 2017

This is an attempt to automatically generate the actual callback list. I always forget what kind of callbacks we have. ;-)
Related issue #964

Please sign in to comment.