This commit is contained in:
zotlabs 2019-05-27 20:50:05 -07:00
parent d382f68161
commit b7e7b997e7
6 changed files with 40 additions and 55 deletions

View file

@ -52,7 +52,8 @@ class Cron_weekly {
Master::Summon(array('Checksites'));
// update searchable doc indexes
Master::Summon(array('Importdoc'));
// disabled until help system regenerated
// Master::Summon(array('Importdoc'));
/**
* End Cron Weekly

View file

@ -1,59 +1,41 @@
<?php
namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
use Zotlabs\Web\HTTPSig;
use Zotlabs\Lib\ActivityStreams;
use Zotlabs\Lib\Activity;
require_once('library/jsonld/jsonld.php');
class Ap_probe extends \Zotlabs\Web\Controller {
class Ap_probe extends Controller {
function get() {
$o .= '<h3>ActivityPub Probe Diagnostic</h3>';
$o .= '<form action="ap_probe" method="post">';
$o .= 'Lookup URI: <input type="text" style="width: 250px;" name="addr" value="' . $_REQUEST['addr'] .'" /><br>';
$o .= 'or paste text: <textarea style="width: 250px;" name="text">' . htmlspecialchars($_REQUEST['text']) . '</textarea><br>';
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
$o .= '<br /><br />';
if(x($_REQUEST,'addr')) {
$addr = $_REQUEST['addr'];
$headers = 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams", application/activity+json, application/ld+json';
$channel = null;
$o = replace_macros(get_markup_template('ap_probe.tpl'), [
'$page_title' => t('ActivityPub Probe Diagnostic'),
'$resource' => [ 'resource', t('Object URL') , $_REQUEST['resource'], EMPTY_STR ],
'$authf' => [ 'authf', t('Authenticated fetch'), $_REQUEST['authf'], EMPTY_STR, [ t('No'), t('Yes') ] ],
'$submit' => t('Submit')
]);
$redirects = 0;
$x = z_fetch_url($addr,true,$redirects, [ 'headers' => [ $headers ]]);
if($x['success'])
$o .= '<pre>' . htmlspecialchars($x['header']) . '</pre>' . EOL;
$o .= '<pre>' . htmlspecialchars($x['body']) . '</pre>' . EOL;
$o .= 'verify returns: ' . str_replace("\n",EOL,print_r(HTTPSig::verify($x),true)) . EOL;
$text = $x['body'];
}
else {
$text = $_REQUEST['text'];
if (x($_REQUEST,'resource')) {
$resource = $_REQUEST['resource'];
if ($_REQUEST['authf']) {
$channel = App::get_channel();
if (! $channel) {
$channel = get_sys_channel();
}
}
if($text) {
$x = Activity::fetch($resource,$channel);
// if($text && json_decode($text)) {
// $normalized1 = jsonld_normalize(json_decode($text),[ 'algorithm' => 'URDNA2015', 'format' => 'application/nquads' ]);
// $o .= str_replace("\n",EOL,htmlentities(var_export($normalized1,true)));
if ($x) {
$o .= '<pre>' . str_replace('\\n',"\n",htmlspecialchars(json_encode($x,JSON_UNESCAPED_SLASHES|JSON_PRETTY_PRINT))) . '</pre>';
}
// $o .= '<pre>' . json_encode($normalized1, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . '</pre>';
// }
$o .= '<pre>' . str_replace(['\\n','\\'],["\n",''],htmlspecialchars(jindent($text))) . '</pre>';
$AP = new ActivityStreams($text);
$o .= '<pre>' . htmlspecialchars($AP->debug()) . '</pre>';
}
return $o;

View file

@ -468,7 +468,8 @@ define ( 'ZOT_APSCHEMA_REV', '/apschema/v1.7' );
* activity stream defines
*/
define ( 'ACTIVITY_PUBLIC_INBOX', 'https://www.w3.org/ns/activitystreams#Public' );
define ( 'ACTIVITY_PUBLIC_INBOX', 'https://www.w3.org/ns/activitystreams#Public' );
define ( 'ACTIVITY_AUTHENTICATED', 'https://www.w3.org/ns/activitystreams#Authenticated' );
define ( 'ACTIVITY_POST', 'Create' );
define ( 'ACTIVITY_CREATE', 'Create' );

View file

@ -62,10 +62,10 @@ function get_help_content($tocpath = false) {
$path = argv(1);
$fullpath = get_help_fullpath($path,'.md');
logger('fullpath: ' . $fullpath);
$text = load_doc_file($fullpath . '.md');
logger('text = ' . $text);
App::$page['title'] = t('Help');
@ -147,7 +147,7 @@ function find_doc_file($s) {
function search_doc_files($s) {
\App::set_pager_itemspage(60);
App::set_pager_itemspage(60);
$pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(\App::$pager['itemspage']), intval(\App::$pager['start']));
$regexop = db_getfunc('REGEXP');
@ -182,7 +182,7 @@ function search_doc_files($s) {
$r[$x]['rank'] ++;
$r[$x]['rank'] += substr_count(strtolower($r[$x]['text']), strtolower($s));
// bias the results to the observer's native language
if($r[$x]['lang'] === \App::$language)
if($r[$x]['lang'] === App::$language)
$r[$x]['rank'] = $r[$x]['rank'] + 10;
}

View file

@ -135,15 +135,6 @@ web server platforms.
cd mywebsite
util/update_addon_repo zaddons
- Once the software is configured and the database installed, create searchable
representations of the online documentation. You may do this any time
that the documentation is updated.
cd mywebsite
util/importdoc
3. Create an empty database and note the access details (hostname, username,
password, database name). The PDO database libraries will fallback to socket

10
view/tpl/ap_probe.tpl Normal file
View file

@ -0,0 +1,10 @@
<h3>{{$page_title}}</h3>
<form action="ap_probe" method="get">
{{include file="field_input.tpl" field=$resource}}
{{include file="field_checkbox.tpl" field=$authf}}
<input type="submit" name="submit" value="{{$submit}}" >
</form>
<br>
<br>