Merge branch 'dev' of https://github.com/redmatrix/hubzilla into dev_merge

This commit is contained in:
zotlabs 2017-09-13 19:26:07 -07:00
commit e8e61c83d5
16 changed files with 113 additions and 65 deletions

View File

@ -13,7 +13,9 @@ class ActivityStreams {
public $tgt = null;
public $origin = null;
public $owner = null;
public $signer = null;
public $ldsig = null;
public $sigok = false;
public $recips = null;
function __construct($string) {
@ -32,6 +34,14 @@ class ActivityStreams {
$this->origin = $this->get_compound_property('origin');
$this->recips = $this->collect_recips();
$this->ldsig = $this->get_compound_property('signature');
if($this->ldsig) {
$this->signer = $this->get_compound_property('creator',$this->ldsig);
if($this->signer && $this->signer['publicKey'] && $this->signer['publicKey']['publicKeyPem']) {
$this->sigok = \Zotlabs\Lib\LDSignatures::verify($this->data,$this->signer['publicKey']['publicKeyPem']);
}
}
if(($this->type === 'Note') && (! $this->obj)) {
$this->obj = $this->data;
$this->type = 'Create';

View File

@ -16,11 +16,13 @@ class LDSignatures {
}
static function dopplesign(&$data,$channel) {
$data['magicEnv'] = self::salmon_sign($data,$channel);
// remove for the time being - performance issues
// $data['magicEnv'] = self::salmon_sign($data,$channel);
return self::sign($data,$channel);
}
static function sign($data,$channel) {
$options = [
'type' => 'RsaSignature2017',
'nonce' => random_string(64),
@ -46,7 +48,7 @@ class LDSignatures {
if($data) {
foreach($data as $k => $v) {
if(! in_array($k,[ 'signature' ])) {
$newopts[$k] = $v;
$newdata[$k] = $v;
}
}
}
@ -68,6 +70,7 @@ class LDSignatures {
}
static function hash($obj) {
return hash('sha256',self::normalise($obj));
}

View File

@ -55,7 +55,12 @@ class NativeWikiPage {
}
static public function create_page($channel_id, $observer_hash, $name, $resource_id) {
static public function create_page($channel_id, $observer_hash, $name, $resource_id, $mimetype = 'text/bbcode') {
logger('mimetype: ' . $mimetype);
if(! in_array($mimetype,[ 'text/markdown','text/bbcode','text/plain','text/html' ]))
$mimetype = 'text/markdown';
$w = Zlib\NativeWiki::get_wiki($channel_id, $observer_hash, $resource_id);
@ -68,6 +73,7 @@ class NativeWikiPage {
$arr = [];
$arr['uid'] = $channel_id;
$arr['author_xchan'] = $observer_hash;
$arr['mimetype'] = $mimetype;
$arr['resource_type'] = 'nwikipage';
$arr['resource_id'] = $resource_id;
$arr['allow_cid'] = $w['wiki']['allow_cid'];
@ -169,6 +175,7 @@ class NativeWikiPage {
return [
'content' => $content,
'mimeType' => $w['mimeType'],
'pageMimeType' => $item['mimetype'],
'message' => '',
'success' => true
];
@ -333,7 +340,6 @@ class NativeWikiPage {
return array('message' => t('Error reading wiki'), 'success' => false);
}
$mimetype = $w['mimeType'];
// fetch the most recently saved revision.
@ -342,6 +348,8 @@ class NativeWikiPage {
return array('message' => t('Page not found'), 'success' => false);
}
$mimetype = $item['mimetype'];
// change just the fields we need to change to create a revision;
unset($item['id']);

View File

@ -194,7 +194,7 @@ class Channel extends \Zotlabs\Web\Controller {
$simple_update = '';
if($static && $simple_update)
$simple_update .= " and item_thread_top = 1 and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' ";
$simple_update .= " and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' ";
if(($update) && (! $load)) {

View File

@ -478,6 +478,7 @@ class Network extends \Zotlabs\Web\Controller {
}
else {
// this is an update
$r = q("SELECT item.parent AS item_id FROM item
left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids )

View File

@ -160,6 +160,10 @@ class Display {
$theme_selected = ((array_key_exists('theme',$_SESSION) && $_SESSION['theme']) ? $_SESSION['theme'] : $theme);
if (strpos($theme_selected, ':')) {
$theme_selected = explode(':', $theme_selected)[0];
}
$mobile_theme_selected = (!x($_SESSION,'mobile_theme')? $default_mobile_theme : $_SESSION['mobile_theme']);
$preload_images = get_pconfig(local_channel(),'system','preload_images');

View File

@ -259,7 +259,7 @@ class Wiki extends \Zotlabs\Web\Controller {
goaway(z_root() . '/' . argv(0) . '/' . argv(1) );
}
$mimeType = $p['mimeType'];
$mimeType = $p['pageMimeType'];
$sampleContent = (($mimeType == 'text/bbcode') ? '[h3]' . t('New page') . '[/h3]' : '### ' . t('New page'));
@ -323,7 +323,7 @@ class Wiki extends \Zotlabs\Web\Controller {
'$modalerroralbum' => t('Error getting album'),
));
if($p['mimeType'] != 'text/bbcode')
if($p['pageMimeType'] != 'text/bbcode')
head_add_js('/library/ace/ace.js'); // Ace Code Editor
return $o;
@ -347,11 +347,12 @@ class Wiki extends \Zotlabs\Web\Controller {
if((argc() > 2) && (argv(2) === 'preview')) {
$content = $_POST['content'];
$resource_id = $_POST['resource_id'];
$w = Zlib\NativeWiki::get_wiki($owner['channel_id'],$observer_hash,$resource_id);
$wikiURL = argv(0) . '/' . argv(1) . '/' . $w['urlName'];
$mimeType = $w['mimeType'];
$mimeType = $_POST['mimetype'];
if($mimeType == 'text/bbcode') {
$html = Zlib\NativeWikiPage::convert_links(zidify_links(smilies(bbcode($content))),$wikiURL);
@ -406,7 +407,7 @@ class Wiki extends \Zotlabs\Web\Controller {
$r = Zlib\NativeWiki::create_wiki($owner, $observer_hash, $wiki, $acl);
if($r['success']) {
Zlib\NativeWiki::sync_a_wiki_item($owner['channel_id'],$r['item_id'],$r['item']['resource_id']);
$homePage = Zlib\NativeWikiPage::create_page($owner['channel_id'],$observer_hash,'Home', $r['item']['resource_id']);
$homePage = Zlib\NativeWikiPage::create_page($owner['channel_id'],$observer_hash,'Home', $r['item']['resource_id'], $wiki['mimeType']);
if(! $homePage['success']) {
notice( t('Wiki created, but error creating Home page.'));
goaway(z_root() . '/wiki/' . $nick . '/' . $wiki['urlName']);
@ -445,11 +446,13 @@ class Wiki extends \Zotlabs\Web\Controller {
// Create a page
if ((argc() === 4) && (argv(2) === 'create') && (argv(3) === 'page')) {
$mimetype = $_POST['mimetype'];
$resource_id = $_POST['resource_id'];
// Determine if observer has permission to create a page
$perms = Zlib\NativeWiki::get_permissions($resource_id, intval($owner['channel_id']), $observer_hash);
$perms = Zlib\NativeWiki::get_permissions($resource_id, intval($owner['channel_id']), $observer_hash, $mimetype);
if(! $perms['write']) {
logger('Wiki write permission denied. ' . EOL);
json_return_and_die(array('success' => false));
@ -459,7 +462,7 @@ class Wiki extends \Zotlabs\Web\Controller {
if(urlencode(escape_tags($_POST['pageName'])) === '') {
json_return_and_die(array('message' => 'Error creating page. Invalid name.', 'success' => false));
}
$page = Zlib\NativeWikiPage::create_page($owner['channel_id'],$observer_hash, $name, $resource_id);
$page = Zlib\NativeWikiPage::create_page($owner['channel_id'],$observer_hash, $name, $resource_id, $mimetype);
if($page['item_id']) {
$commit = Zlib\NativeWikiPage::commit(array(

View File

@ -50,6 +50,7 @@ class Wiki_pages {
'$canadd' => $can_create,
'$candel' => $can_delete,
'$addnew' => t('Add new page'),
'$mimetype' => mimetype_select(0,$p['mimeType'], [ 'text/markdown','text/bbcode' ]),
'$pageName' => array('pageName', t('Page name')),
'$refresh' => $arr['refresh']
));

View File

@ -52,7 +52,7 @@ define ( 'PLATFORM_NAME', 'hubzilla' );
define ( 'STD_VERSION', '2.7.2' );
define ( 'ZOT_REVISION', '1.3' );
define ( 'DB_UPDATE_VERSION', 1194 );
define ( 'DB_UPDATE_VERSION', 1195 );
define ( 'PROJECT_BASE', __DIR__ );

View File

@ -170,9 +170,9 @@ EOT;
if(local_channel()) {
$nav['network'] = array('network', t('Grid'), "", t('Your grid'),'network_nav_btn');
$nav['network']['all'] = [ 'network', t('View your network/grid'), '','' ];
$nav['network']['mark'] = array('', t('Mark all grid notifications seen'), '','');
$nav['network'] = array('network', t('Activity'), "", t('Network Activity'),'network_nav_btn');
$nav['network']['all'] = [ 'network', t('View your network activity'), '','' ];
$nav['network']['mark'] = array('', t('Mark all activity notifications seen'), '','');
$nav['home'] = array('channel/' . $channel['channel_address'], t('Channel Home'), "", t('Channel home'),'home_nav_btn');
$nav['home']['all'] = [ 'channel/' . $channel['channel_address'], t('View your channel home'), '' , '' ];

View File

@ -411,7 +411,7 @@ function http_status($val, $msg = '') {
if ($val >= 200 && $val < 300)
$msg = (($msg) ? $msg : 'OK');
logger('' . $val . ' ' . $msg);
logger(\App::$query_string . ':' . $val . ' ' . $msg);
header($_SERVER['SERVER_PROTOCOL'] . ' ' . $val . ' ' . $msg);
}

View File

@ -231,7 +231,7 @@ function oembed_fetch_url($embedurl){
// So if we see this, grab the frame src url and use that
// as the embed content - which will still need to be purified.
if(preg_match('#<iframe(.*?)src=[\'\"](.?*)[\'\"]#',$matches,$j['html'])) {
if(preg_match('#\<iframe(.*?)src\=[\'\"](.*?)[\'\"]#',$j['html'],$matches)) {
$x = z_fetch_url($matches[2]);
$j['html'] = $x['body'];
}

View File

@ -1786,15 +1786,15 @@ function layout_select($channel_id, $current = '') {
}
function mimetype_select($channel_id, $current = 'text/bbcode') {
function mimetype_select($channel_id, $current = 'text/bbcode', $choices = null, $element = 'mimetype') {
$x = array(
$x = (($choices) ? $choices : [
'text/bbcode',
'text/html',
'text/markdown',
'text/plain',
'application/x-pdl'
);
]);
if((App::$is_sys) || (channel_codeallowed($channel_id) && $channel_id == local_channel())){
@ -1807,7 +1807,7 @@ function mimetype_select($channel_id, $current = 'text/bbcode') {
}
$o = replace_macros(get_markup_template('field_select_raw.tpl'), array(
'$field' => array('mimetype', t('Page content type'), $selected, '', $options)
'$field' => array( $element, t('Page content type'), $selected, '', $options)
));
return $o;

View File

@ -1,6 +1,6 @@
<?php
define( 'UPDATE_VERSION' , 1194 );
define( 'UPDATE_VERSION' , 1195 );
/**
*
@ -2992,3 +2992,19 @@ function update_r1193() {
return UPDATE_SUCCESS;
return UPDATE_FAILED;
}
function update_r1194() {
$r = q("select id, resource_id from item where resource_type = 'nwiki'");
if($r) {
foreach($r as $rv) {
$mimetype = get_iconfig($rv['id'],'wiki','mimeType');
q("update item set mimetype = '%s' where resource_type = 'nwikipage' and resource_id = '%s'",
dbesc($mimetype),
dbesc($rv['resource_id'])
);
}
}
return UPDATE_SUCCESS;
}

View File

@ -183,7 +183,8 @@
{{else}}
content: editor.val(),
{{/if}}
resource_id: window.wiki_resource_id
resource_id: window.wiki_resource_id,
mimetype: '{{$mimeType}}'
},
function (data) {
if (data.success) {

View File

@ -21,6 +21,7 @@
<div id="new-page-form-wrapper" class="sub-menu" style="display:none;">
<form id="new-page-form" action="wiki/{{$channel_address}}/create/page" method="post" >
<input type="hidden" name="resource_id" value="{{$resource_id}}">
{{$mimetype}}
{{include file="field_input.tpl" field=$pageName}}
<button id="new-page-submit" class="btn btn-primary" type="submit" name="submit" >Submit</button>
</form>
@ -33,7 +34,7 @@
{{if $canadd}}
<script>
$('#new-page-submit').click(function (ev) {
$.post("wiki/{{$channel_address}}/create/page", {pageName: $('#id_pageName').val(), resource_id: window.wiki_resource_id},
$.post("wiki/{{$channel_address}}/create/page", {pageName: $('#id_pageName').val(), resource_id: window.wiki_resource_id, mimetype: $('#id_mimetype').val() },
function(data) {
if(data.success) {
window.location = data.url;