Merge pull request #1067 from Beanow/feature/noscrape
Added noscrape feature.
This commit is contained in:
commit
016b6428a0
|
@ -361,6 +361,7 @@ function admin_page_site_post(&$a){
|
|||
$temppath = ((x($_POST,'temppath')) ? notags(trim($_POST['temppath'])) : '');
|
||||
$basepath = ((x($_POST,'basepath')) ? notags(trim($_POST['basepath'])) : '');
|
||||
$singleuser = ((x($_POST,'singleuser')) ? notags(trim($_POST['singleuser'])) : '');
|
||||
$enable_noscrape = ((x($_POST,'enable_noscrape')) ? true : false);
|
||||
if($ssl_policy != intval(get_config('system','ssl_policy'))) {
|
||||
if($ssl_policy == SSL_POLICY_FULL) {
|
||||
q("update `contact` set
|
||||
|
@ -484,6 +485,7 @@ function admin_page_site_post(&$a){
|
|||
set_config('system','lockpath', $lockpath);
|
||||
set_config('system','temppath', $temppath);
|
||||
set_config('system','basepath', $basepath);
|
||||
set_config('system','enable_noscrape', $enable_noscrape);
|
||||
|
||||
info( t('Site settings updated.') . EOL);
|
||||
goaway($a->get_baseurl(true) . '/admin/site' );
|
||||
|
@ -644,8 +646,9 @@ function admin_page_site(&$a) {
|
|||
'$basepath' => array('basepath', t("Base path to installation"), get_config('system','basepath'), "If the system cannot detect the correct path to your installation, enter the correct path here. This setting should only be set if you are using a restricted system and symbolic links to your webroot."),
|
||||
|
||||
'$relocate_url' => array('relocate_url', t("New base url"), $a->get_baseurl(), "Change base url for this server. Sends relocate message to all DFRN contacts of all users."),
|
||||
|
||||
'$form_security_token' => get_form_security_token("admin_site"),
|
||||
|
||||
'$enable_noscrape'=> array('enable_noscrape', t("Enable noscrape"), get_config('system','enable_noscrape'), t("The noscrape feature speeds up directory submissions by using JSON data instead of HTML scraping.")),
|
||||
'$form_security_token' => get_form_security_token("admin_site")
|
||||
|
||||
));
|
||||
|
||||
|
|
|
@ -37,8 +37,12 @@ function friendica_init(&$a) {
|
|||
'admin' => $admin,
|
||||
'site_name' => $a->config['sitename'],
|
||||
'platform' => FRIENDICA_PLATFORM,
|
||||
'info' => ((x($a->config,'info')) ? $a->config['info'] : '')
|
||||
'info' => ((x($a->config,'info')) ? $a->config['info'] : ''),
|
||||
);
|
||||
|
||||
//Enable noscrape?
|
||||
if(!!get_config('system','enable_noscrape'))
|
||||
$data['no_scrape_url'] = $a->get_baseurl().'/noscrape';
|
||||
|
||||
echo json_encode($data);
|
||||
killme();
|
||||
|
|
51
mod/noscrape.php
Normal file
51
mod/noscrape.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
function noscrape_init(&$a) {
|
||||
|
||||
if(!get_config('system','enable_noscrape'))
|
||||
killme();
|
||||
|
||||
if($a->argc > 1)
|
||||
$which = $a->argv[1];
|
||||
else
|
||||
killme();
|
||||
|
||||
$profile = 0;
|
||||
if((local_user()) && ($a->argc > 2) && ($a->argv[2] === 'view')) {
|
||||
$which = $a->user['nickname'];
|
||||
$profile = $a->argv[1];
|
||||
}
|
||||
|
||||
profile_load($a,$which,$profile);
|
||||
|
||||
if(!$a->profile['net-publish'])
|
||||
killme();
|
||||
|
||||
$keywords = ((x($a->profile,'pub_keywords')) ? $a->profile['pub_keywords'] : '');
|
||||
$keywords = str_replace(array('#',',',' ',',,'),array('',' ',',',','),$keywords);
|
||||
$keywords = explode(',', $keywords);
|
||||
|
||||
$json_info = array(
|
||||
'fn' => $a->profile['name'],
|
||||
'key' => $a->profile['pubkey'],
|
||||
'homepage' => $a->get_baseurl()."/profile/{$which}",
|
||||
'comm' => (x($a->profile,'page-flags')) && ($a->profile['page-flags'] == PAGE_COMMUNITY),
|
||||
'photo' => $a->profile['photo'],
|
||||
'tags' => $keywords
|
||||
);
|
||||
|
||||
//These are optional fields.
|
||||
$profile_fields = array('pdesc', 'locality', 'region', 'postal-code', 'country-name', 'gender', 'marital');
|
||||
foreach($profile_fields as $field)
|
||||
if(!empty($a->profile[$field])) $json_info["$field"] = $a->profile[$field];
|
||||
|
||||
$dfrn_pages = array('request', 'confirm', 'notify', 'poll');
|
||||
foreach($dfrn_pages as $dfrn)
|
||||
$json_info["dfrn-{$dfrn}"] = $a->get_baseurl()."/dfrn_{$dfrn}/{$which}";
|
||||
|
||||
//Output all the JSON!
|
||||
header('Content-type: application/json; charset=utf-8');
|
||||
echo json_encode($json_info);
|
||||
exit;
|
||||
|
||||
}
|
|
@ -108,6 +108,7 @@
|
|||
{{include file="field_checkbox.tpl" field=$suppress_language}}
|
||||
|
||||
<h3>{{$performance}}</h3>
|
||||
{{include file="field_checkbox.tpl" field=$enable_noscrape}}
|
||||
{{include file="field_checkbox.tpl" field=$use_fulltext_engine}}
|
||||
{{include file="field_input.tpl" field=$itemcache}}
|
||||
{{include file="field_input.tpl" field=$itemcache_duration}}
|
||||
|
|
Loading…
Reference in a new issue