wiki mimetype selection. We can add text/plain as soon as we add code to purify and render it specifically.

This commit is contained in:
zotlabs 2017-09-12 23:15:30 -07:00
parent 7489a4442e
commit 796228b7ad
5 changed files with 32 additions and 12 deletions

View File

@ -175,6 +175,7 @@ class NativeWikiPage {
return [ return [
'content' => $content, 'content' => $content,
'mimeType' => $w['mimeType'], 'mimeType' => $w['mimeType'],
'pageMimeType' => $item['mimetype'],
'message' => '', 'message' => '',
'success' => true 'success' => true
]; ];
@ -339,7 +340,6 @@ class NativeWikiPage {
return array('message' => t('Error reading wiki'), 'success' => false); return array('message' => t('Error reading wiki'), 'success' => false);
} }
$mimetype = $w['mimeType'];
// fetch the most recently saved revision. // fetch the most recently saved revision.
@ -348,6 +348,8 @@ class NativeWikiPage {
return array('message' => t('Page not found'), 'success' => false); return array('message' => t('Page not found'), 'success' => false);
} }
$mimetype = $item['mimetype'];
// change just the fields we need to change to create a revision; // change just the fields we need to change to create a revision;
unset($item['id']); unset($item['id']);

View File

@ -259,7 +259,7 @@ class Wiki extends \Zotlabs\Web\Controller {
goaway(z_root() . '/' . argv(0) . '/' . argv(1) ); 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')); $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'), '$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 head_add_js('/library/ace/ace.js'); // Ace Code Editor
return $o; return $o;
@ -347,11 +347,12 @@ class Wiki extends \Zotlabs\Web\Controller {
if((argc() > 2) && (argv(2) === 'preview')) { if((argc() > 2) && (argv(2) === 'preview')) {
$content = $_POST['content']; $content = $_POST['content'];
$resource_id = $_POST['resource_id']; $resource_id = $_POST['resource_id'];
$w = Zlib\NativeWiki::get_wiki($owner['channel_id'],$observer_hash,$resource_id); $w = Zlib\NativeWiki::get_wiki($owner['channel_id'],$observer_hash,$resource_id);
$wikiURL = argv(0) . '/' . argv(1) . '/' . $w['urlName']; $wikiURL = argv(0) . '/' . argv(1) . '/' . $w['urlName'];
$mimeType = $w['mimeType']; $mimeType = $_POST['mimetype'];
if($mimeType == 'text/bbcode') { if($mimeType == 'text/bbcode') {
$html = Zlib\NativeWikiPage::convert_links(zidify_links(smilies(bbcode($content))),$wikiURL); $html = Zlib\NativeWikiPage::convert_links(zidify_links(smilies(bbcode($content))),$wikiURL);

View File

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

View File

@ -1,6 +1,6 @@
<?php <?php
define( 'UPDATE_VERSION' , 1194 ); define( 'UPDATE_VERSION' , 1195 );
/** /**
* *
@ -2992,3 +2992,19 @@ function update_r1193() {
return UPDATE_SUCCESS; return UPDATE_SUCCESS;
return UPDATE_FAILED; 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}} {{else}}
content: editor.val(), content: editor.val(),
{{/if}} {{/if}}
resource_id: window.wiki_resource_id resource_id: window.wiki_resource_id,
mimetype: '{{$mimeType}}'
}, },
function (data) { function (data) {
if (data.success) { if (data.success) {