This commit is contained in:
zotlabs 2019-04-14 22:31:07 -07:00
parent 339b724c35
commit dffdac0757
5 changed files with 68 additions and 46 deletions

View file

@ -1,32 +1,22 @@
<?php
namespace Zotlabs\Module;
use App;
use Zotlabs\Daemon\Master;
use Zotlabs\Lib\Libsync;
/*
* Embed
* Given a post_id returns a share tag for inclusion in a post
*
*/
use Zotlabs\Web\Controller;
require_once('include/security.php');
require_once('include/bbcode.php');
class Embed extends Controller {
function init() {
$post_id = ((argc() > 1) ? intval(argv(1)) : 0);
if(! $post_id)
killme();
if(! local_channel()) {
killme();
if ($post_id && local_channel()) {
echo '[share=' . $post_id . '][/share]';
}
echo '[share=' . $post_id . '][/share]';
killme();
}
}

View file

@ -1,31 +1,34 @@
<?php
namespace Zotlabs\Module;
/*
* Finger diagnostic tool.
* Input a webfinger resource via an input form and
* view the results as an array.
*
*/
use Zotlabs\Web\Controller;
use Zotlabs\Lib\Webfinger;
class Finger extends \Zotlabs\Web\Controller {
class Finger extends Controller {
function get() {
$o .= '<h3>Webfinger Diagnostic</h3>';
$o .= '<form action="finger" method="get">';
$o .= 'Lookup address: <input type="text" style="width: 250px;" name="addr" value="' . $_GET['addr'] .'" />';
$o .= '<input type="submit" name="submit" value="Submit" /></form>';
$o .= '<br /><br />';
if(x($_GET,'addr')) {
$addr = trim($_GET['addr']);
$res = \Zotlabs\Lib\Webfinger::exec($addr);
$o = replace_macros(get_markup_template('finger.tpl'), [
'$page_title' => t('Webfinger Diagnostic'),
'$resource' => [ 'resource', t('Lookup address or URL') , $_GET['resource'], EMPTY_STR ],
'$submit' => t('Submit')
]);
$o .= '<pre>';
$o .= str_replace("\n",'<br />',print_r($res,true));
$o .= '</pre>';
if($_GET['resource']) {
$resource = trim(escape_tags($_GET['resource']));
$result = Webfinger::exec($resource);
$o .= '<pre>' . str_replace("\n",'<br>',print_array($result)) . '</pre>';
}
return $o;
}

View file

@ -2,8 +2,14 @@
namespace Zotlabs\Module;
/*
* Hashtag autocomplete controller
*
*/
class Hashtags extends \Zotlabs\Web\Controller {
use Zotlabs\Web\Controller;
class Hashtags extends Controller {
function init() {
$result = [];

View file

@ -1,27 +1,39 @@
<?php
namespace Zotlabs\Module;
/*
* Update
* Performs AJAX liveUpdate of conversational content by calling the appropriate
* controller (passed as argv(1)) and passing the profile_uid (passed as $_GET['p'])
* and load flag (argv(2) === 'load') to the get() function of the controller.
* Conversational controllers have been written to expect this input. Other controllers
* have not.
*/
use Zotlabs\Web\Controller;
class Update extends \Zotlabs\Web\Controller {
class Update extends Controller {
function get() {
$profile_uid = intval($_GET['p']);
// it's probably safe to do this for all modules and not just a limited subset,
// but it needs to be verified.
if((! $profile_uid) && in_array(argv(1),['display','search','pubstream','home']))
// Change a profile_uid of 0 (not logged in) to (-1) for selected controllers
// as they only respond to liveUpdate with non-zero values
if ((! $profile_uid) && in_array(argv(1),[ 'display', 'search', 'pubstream', 'home' ])) {
$profile_uid = (-1);
}
if(argc() < 2) {
if (argc() < 2) {
killme();
}
// These modules don't have a completely working liveUpdate implementation currently
if(in_array(strtolower(argv(1)),['articles','cards']))
if (in_array(strtolower(argv(1)),[ 'articles', 'cards' ])) {
killme();
}
$module = "\\Zotlabs\\Module\\" . ucfirst(argv(1));
$load = (((argc() > 2) && (argv(2) == 'load')) ? 1 : 0);
@ -30,6 +42,9 @@ class Update extends \Zotlabs\Web\Controller {
header("Content-type: text/html");
// Modify the argument parameters to match what the new controller
// expects. They are currently set to what this controller expects.
\App::$argv = [ argv(1) ];
\App::$argc = 1;
@ -38,6 +53,5 @@ class Update extends \Zotlabs\Web\Controller {
echo "</section></body></html>\r\n";
killme();
}
}

9
view/tpl/finger.tpl Normal file
View file

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