|
|
|
@ -392,149 +392,151 @@ $server->setHandler(
@@ -392,149 +392,151 @@ $server->setHandler(
|
|
|
|
|
) { |
|
|
|
|
if ($record['transaction'] == $attribute[1]) |
|
|
|
|
{ |
|
|
|
|
// Raw mode |
|
|
|
|
if ('raw' == $request->getQuery()) |
|
|
|
|
// View mode |
|
|
|
|
switch ($request->getQuery()) |
|
|
|
|
{ |
|
|
|
|
// Transaction ID |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'# %s', |
|
|
|
|
$record['transaction'] |
|
|
|
|
); |
|
|
|
|
case 'raw': |
|
|
|
|
|
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'## %s', |
|
|
|
|
$config->geminiapp->string->data |
|
|
|
|
); |
|
|
|
|
// Transaction ID |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'# %s', |
|
|
|
|
$record['transaction'] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// Key |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'### %s', |
|
|
|
|
$config->geminiapp->string->key |
|
|
|
|
); |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'## %s', |
|
|
|
|
$config->geminiapp->string->data |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// Key |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'### %s', |
|
|
|
|
$config->geminiapp->string->key |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$result[] = '```'; |
|
|
|
|
$result[] = '```'; |
|
|
|
|
|
|
|
|
|
$lines = []; |
|
|
|
|
$lines = []; |
|
|
|
|
|
|
|
|
|
foreach ((array) explode(PHP_EOL, (string) $record['key']) as $line) |
|
|
|
|
{ |
|
|
|
|
$lines[] = preg_replace( |
|
|
|
|
'/^```/', |
|
|
|
|
' ```', |
|
|
|
|
$line |
|
|
|
|
foreach ((array) explode(PHP_EOL, (string) $record['key']) as $line) |
|
|
|
|
{ |
|
|
|
|
$lines[] = preg_replace( |
|
|
|
|
'/^```/', |
|
|
|
|
' ```', |
|
|
|
|
$line |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$result[] = implode( |
|
|
|
|
PHP_EOL, |
|
|
|
|
$lines |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$result[] = implode( |
|
|
|
|
PHP_EOL, |
|
|
|
|
$lines |
|
|
|
|
); |
|
|
|
|
$result[] = '```'; |
|
|
|
|
|
|
|
|
|
$result[] = '```'; |
|
|
|
|
// Value |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'### %s', |
|
|
|
|
$config->geminiapp->string->value |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// Value |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'### %s', |
|
|
|
|
$config->geminiapp->string->value |
|
|
|
|
); |
|
|
|
|
$result[] = '```'; |
|
|
|
|
|
|
|
|
|
$result[] = '```'; |
|
|
|
|
$lines = []; |
|
|
|
|
|
|
|
|
|
$lines = []; |
|
|
|
|
foreach ((array) explode(PHP_EOL, (string) $record['value']) as $line) |
|
|
|
|
{ |
|
|
|
|
$lines[] = preg_replace( |
|
|
|
|
'/^```/', |
|
|
|
|
' ```', |
|
|
|
|
$line |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach ((array) explode(PHP_EOL, (string) $record['value']) as $line) |
|
|
|
|
{ |
|
|
|
|
$lines[] = preg_replace( |
|
|
|
|
'/^```/', |
|
|
|
|
' ```', |
|
|
|
|
$line |
|
|
|
|
$result[] = implode( |
|
|
|
|
PHP_EOL, |
|
|
|
|
$lines |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$result[] = implode( |
|
|
|
|
PHP_EOL, |
|
|
|
|
$lines |
|
|
|
|
); |
|
|
|
|
$result[] = '```'; |
|
|
|
|
|
|
|
|
|
$result[] = '```'; |
|
|
|
|
// Meta |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'## %s', |
|
|
|
|
$config->geminiapp->string->meta |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// Meta |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'## %s', |
|
|
|
|
$config->geminiapp->string->meta |
|
|
|
|
); |
|
|
|
|
// Time |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'### %s', |
|
|
|
|
$config->geminiapp->string->time |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// Time |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'### %s', |
|
|
|
|
$config->geminiapp->string->time |
|
|
|
|
); |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = date( |
|
|
|
|
'Y-m-d', |
|
|
|
|
$record['time'] |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = date( |
|
|
|
|
'Y-m-d', |
|
|
|
|
$record['time'] |
|
|
|
|
); |
|
|
|
|
// Block |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'### %s', |
|
|
|
|
$config->geminiapp->string->block |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// Block |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'### %s', |
|
|
|
|
$config->geminiapp->string->block |
|
|
|
|
); |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = $record['block']; |
|
|
|
|
|
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = $record['block']; |
|
|
|
|
} |
|
|
|
|
break; |
|
|
|
|
|
|
|
|
|
// Reader mode |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// Key |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'# %s', |
|
|
|
|
trim( |
|
|
|
|
preg_replace( // single-line |
|
|
|
|
'/[\s]+/', |
|
|
|
|
' ', |
|
|
|
|
$record['key'] |
|
|
|
|
default: |
|
|
|
|
|
|
|
|
|
// Key |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'# %s', |
|
|
|
|
trim( |
|
|
|
|
preg_replace( // single-line |
|
|
|
|
'/[\s]+/', |
|
|
|
|
' ', |
|
|
|
|
$record['key'] |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// Value |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = trim( |
|
|
|
|
preg_replace( |
|
|
|
|
[ |
|
|
|
|
'/(^|\s+)(#|\*|```|=>)/', // escape gemini text |
|
|
|
|
'/[\n\r]{3,}/', // remove extra breaks |
|
|
|
|
], |
|
|
|
|
[ |
|
|
|
|
'$1 $2', |
|
|
|
|
PHP_EOL . PHP_EOL, |
|
|
|
|
], |
|
|
|
|
$record['value'] |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
// Value |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = trim( |
|
|
|
|
preg_replace( |
|
|
|
|
[ |
|
|
|
|
'/(^|\s+)(#|\*|```|=>)/', // escape gemini text |
|
|
|
|
'/[\n\r]{3,}/', // remove extra breaks |
|
|
|
|
], |
|
|
|
|
[ |
|
|
|
|
'$1 $2', |
|
|
|
|
PHP_EOL . PHP_EOL, |
|
|
|
|
], |
|
|
|
|
$record['value'] |
|
|
|
|
) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
// Time |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'%s in %d', |
|
|
|
|
date( |
|
|
|
|
'Y-m-d', |
|
|
|
|
$record['time'] |
|
|
|
|
), |
|
|
|
|
$record['block'] |
|
|
|
|
); |
|
|
|
|
// Time |
|
|
|
|
$result[] = null; |
|
|
|
|
$result[] = sprintf( |
|
|
|
|
'%s in %d', |
|
|
|
|
date( |
|
|
|
|
'Y-m-d', |
|
|
|
|
$record['time'] |
|
|
|
|
), |
|
|
|
|
$record['block'] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Footer |
|
|
|
|