Commit 8ede2d78 authored by Malcolm Blaney's avatar Malcolm Blaney

Move code from Post->Callback to it's own function, CustomSettings,

which now also provides custom settings for enclosures. Bug fix in
Writer module js, enclosure was being stringify'd twice. Extended
module js also needed some changes to handle new Post custom
settings options. Support .mov files in SimplePie microformats
parser as browsers support them. A few other small bug fixes and
missing file includes for microformats.php which is now used more.
parent 35cc1c9d
Pipeline #36118102 passed with stage
in 1 minute and 9 seconds
This diff is collapsed.
...@@ -64,7 +64,7 @@ dobrado.log('Loading action...','info');$.post('/php/request.php',{request:'writ ...@@ -64,7 +64,7 @@ dobrado.log('Loading action...','info');$.post('/php/request.php',{request:'writ
var webactionInfo=JSON.parse(response);$('#writer-webaction-info').html(webactionInfo.content);$('#writer-remove-action').button({icon:'ui-icon-closethick',showLabel:false}).click(removeActionExplicit);if(dobrado.reader){$('#writer-follow').button().click(dobrado.reader.addFeed);}});};dobrado.writer.select=function(filename){$('#writer-photo-selected').append('<img src="'+filename+'">');};dobrado.writer.showEditor=function(){function clearContent(){if(dobrado.editor.getData()===defaultText){dobrado.editor.setData('');}} var webactionInfo=JSON.parse(response);$('#writer-webaction-info').html(webactionInfo.content);$('#writer-remove-action').button({icon:'ui-icon-closethick',showLabel:false}).click(removeActionExplicit);if(dobrado.reader){$('#writer-follow').button().click(dobrado.reader.addFeed);}});};dobrado.writer.select=function(filename){$('#writer-photo-selected').append('<img src="'+filename+'">');};dobrado.writer.showEditor=function(){function clearContent(){if(dobrado.editor.getData()===defaultText){dobrado.editor.setData('');}}
if(dobrado.editMode){dobrado.closeEditor();} if(dobrado.editMode){dobrado.closeEditor();}
$('#writer-content').parents('div').each(function(){if(/^dobrado-/.test($(this).attr('id'))){dobrado.current='#'+$(this).attr('id');return false;}});$(dobrado.current).data('label','writer');var editorCssProperties=['background','background-attachment','background-color','background-image','background-position','background-repeat','background-size','clear','color','direction','empty-cells','font','font-family','font-size','font-style','font-variant','font-weight','letter-spacing','line-height','list-style','list-style-image','list-style-position','list-style-type','margin','margin-left','margin-right','margin-top','margin-bottom','opacity','outline','outline-color','outline-style','outline-width','padding','padding-bottom','padding-left','padding-right','padding-top','size','text-align','text-decoration','text-indent','text-transform','white-space','word-spacing'];var css='.cke_editable { ';var current=$(dobrado.current);for(var i=0;i<editorCssProperties.length;i++){var property=editorCssProperties[i];var value=current.css(property);if(value){css+=property+': '+value+';';}} $('#writer-content').parents('div').each(function(){if(/^dobrado-/.test($(this).attr('id'))){dobrado.current='#'+$(this).attr('id');return false;}});$(dobrado.current).data('label','writer');var editorCssProperties=['background','background-attachment','background-color','background-image','background-position','background-repeat','background-size','clear','color','direction','empty-cells','font','font-family','font-size','font-style','font-variant','font-weight','letter-spacing','line-height','list-style','list-style-image','list-style-position','list-style-type','margin','margin-left','margin-right','margin-top','margin-bottom','opacity','outline','outline-color','outline-style','outline-width','padding','padding-bottom','padding-left','padding-right','padding-top','size','text-align','text-decoration','text-indent','text-transform','white-space','word-spacing'];var css='.cke_editable { ';var current=$(dobrado.current);for(var i=0;i<editorCssProperties.length;i++){var property=editorCssProperties[i];var value=current.css(property);if(value){css+=property+': '+value+';';}}
css+='}';CKEDITOR.addCss(css);var content=$('#writer-content').text();$('#writer-content').val(content);dobrado.editor=CKEDITOR.replace('writer-content',{allowedContent:true,autoGrow_minHeight:$('#writer-content').height(),autoGrow_onStartup:true,disableNativeSpellChecker:false,enterMode:CKEDITOR.ENTER_BR,extraPlugins:'autogrow,extended',filebrowserBrowseUrl:'/php/browse.php',removePlugins:'elementspath,tableselection,tabletools,contextmenu,liststyle',resize_enabled:false,on:{focus:clearContent},toolbar:[['Undo','Redo','-','Bold','Italic','-','Link','Unlink','-','Image','Extended']]});$('.writer-post').button('option','disabled',false);};dobrado.writer.newModuleCallback=function(id,context){var data=dobrado.editor?dobrado.editor.getData():$('#writer-content').val();var enclosure=[];$('#writer-photo-selected > img').each(function(){enclosure.push($(this).attr('src'));});var content={data:data,dataOnly:false,title:$('#writer-title').val(),author:$('#writer-author').val(),category:$('#writer-tag-input').val(),enclosure:JSON.stringify(enclosure),twitter:sendToTwitter,webactionType:webactionType,webactionUrl:webactionUrl};if(context==='post'){$.post('/php/content.php',{id:id,label:'post',content:JSON.stringify(content),url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'writer callback')){return;} css+='}';CKEDITOR.addCss(css);var content=$('#writer-content').text();$('#writer-content').val(content);dobrado.editor=CKEDITOR.replace('writer-content',{allowedContent:true,autoGrow_minHeight:$('#writer-content').height(),autoGrow_onStartup:true,disableNativeSpellChecker:false,enterMode:CKEDITOR.ENTER_BR,extraPlugins:'autogrow,extended',filebrowserBrowseUrl:'/php/browse.php',removePlugins:'elementspath,tableselection,tabletools,contextmenu,liststyle',resize_enabled:false,on:{focus:clearContent},toolbar:[['Undo','Redo','-','Bold','Italic','-','Link','Unlink','-','Image','Extended']]});$('.writer-post').button('option','disabled',false);};dobrado.writer.newModuleCallback=function(id,context){var data=dobrado.editor?dobrado.editor.getData():$('#writer-content').val();var enclosure=[];$('#writer-photo-selected > img').each(function(){enclosure.push($(this).attr('src'));});var content={data:data,dataOnly:false,title:$('#writer-title').val(),author:$('#writer-author').val(),category:$('#writer-tag-input').val(),enclosure:enclosure,twitter:sendToTwitter,webactionType:webactionType,webactionUrl:webactionUrl};if(context==='post'){$.post('/php/content.php',{id:id,label:'post',content:JSON.stringify(content),url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'writer callback')){return;}
var formatted=JSON.parse(response);if(formatted.html){$(id).html(formatted.html);$(id).show();} var formatted=JSON.parse(response);if(formatted.html){$(id).html(formatted.html);$(id).show();}
if(dobrado.editMode){var element=$(id+' .dobrado-editable').get(0);if(element){dobrado.inlineEditor(element);}} if(dobrado.editMode){var element=$(id+' .dobrado-editable').get(0);if(element){dobrado.inlineEditor(element);}}
if(dobrado.editor){dobrado.editor.setData(defaultText);} if(dobrado.editor){dobrado.editor.setData(defaultText);}
......
...@@ -395,15 +395,12 @@ if (!this.dobrado.writer) { ...@@ -395,15 +395,12 @@ if (!this.dobrado.writer) {
$('#writer-photo-selected > img').each(function() { $('#writer-photo-selected > img').each(function() {
enclosure.push($(this).attr('src')); enclosure.push($(this).attr('src'));
}); });
var content = { data: data, var content = { data: data, dataOnly: false,
dataOnly: false,
title: $('#writer-title').val(), title: $('#writer-title').val(),
author: $('#writer-author').val(), author: $('#writer-author').val(),
category: $('#writer-tag-input').val(), category: $('#writer-tag-input').val(),
enclosure: JSON.stringify(enclosure), enclosure: enclosure, twitter: sendToTwitter,
twitter: sendToTwitter, webactionType: webactionType, webactionUrl: webactionUrl };
webactionType: webactionType,
webactionUrl: webactionUrl };
if (context === 'post') { if (context === 'post') {
$.post('/php/content.php', $.post('/php/content.php',
{ id: id, label: 'post', content: JSON.stringify(content), { id: id, label: 'post', content: JSON.stringify(content),
......
This diff is collapsed.
This diff is collapsed.
...@@ -28,6 +28,7 @@ foreach (['id', 'label', 'url'] as $name) { ...@@ -28,6 +28,7 @@ foreach (['id', 'label', 'url'] as $name) {
include 'functions/copy_page.php'; include 'functions/copy_page.php';
include 'functions/db.php'; include 'functions/db.php';
include 'functions/microformats.php';
include 'functions/new_module.php'; include 'functions/new_module.php';
include 'functions/page_owner.php'; include 'functions/page_owner.php';
include 'functions/permission.php'; include 'functions/permission.php';
......
...@@ -665,6 +665,9 @@ class SimplePie_Parser ...@@ -665,6 +665,9 @@ class SimplePie_Parser
if (in_array($match[1], array('mp4', 'webm'))) { if (in_array($match[1], array('mp4', 'webm'))) {
$type = 'video/' . $match[1]; $type = 'video/' . $match[1];
} }
else if ($match[1] === 'mov') {
$type = 'video/quicktime';
}
else if ($match[1] === 'ogv') { else if ($match[1] === 'ogv') {
$type = 'video/ogg'; $type = 'video/ogg';
} }
......
...@@ -23,9 +23,11 @@ function header_value($headers, $name) { ...@@ -23,9 +23,11 @@ function header_value($headers, $name) {
} }
function photo_html($photo_list) { function photo_html($photo_list) {
// When there's more than one photo show the first and use a lightbox. if (!is_array($photo_list)) return '';
$count = count($photo_list); $count = count($photo_list);
if ($count === 0) return ''; if ($count === 0) return '';
if ($count === 1) { if ($count === 1) {
$value = ''; $value = '';
$alt = ''; $alt = '';
...@@ -41,6 +43,7 @@ function photo_html($photo_list) { ...@@ -41,6 +43,7 @@ function photo_html($photo_list) {
} }
return '<p><img class="u-photo" src="' . $value . '"' . $alt . '></p>'; return '<p><img class="u-photo" src="' . $value . '"' . $alt . '></p>';
} }
// Make sure image-set is unique incase there's more than one shown on // Make sure image-set is unique incase there's more than one shown on
// the feed page. // the feed page.
$image_set_id = preg_replace('/[[:^alnum:]]/', '', $photo_list[0]); $image_set_id = preg_replace('/[[:^alnum:]]/', '', $photo_list[0]);
...@@ -244,11 +247,12 @@ else { ...@@ -244,11 +247,12 @@ else {
} }
if (isset($_POST['photo'])) { if (isset($_POST['photo'])) {
$photo_list = $_POST['photo']; $photo_list = $_POST['photo'];
if (is_array($photo_list)) { if (is_string($photo_list)) {
$content['data'] .= photo_html($photo_list); $content['data'] .=
'<p><img class="u-photo" src="' . $_POST['photo'] . '"></p>';
} }
else { else {
$content['data'] .= '<p><img src="' . $_POST['photo'] . '"></p>'; $content['data'] .= photo_html($photo_list);
} }
} }
if (isset($_POST['in-reply-to'])) { if (isset($_POST['in-reply-to'])) {
......
...@@ -27,6 +27,7 @@ foreach (['id', 'label', 'url'] as $name) { ...@@ -27,6 +27,7 @@ foreach (['id', 'label', 'url'] as $name) {
} }
include 'functions/db.php'; include 'functions/db.php';
include 'functions/microformats.php';
include 'functions/new_module.php'; include 'functions/new_module.php';
include 'functions/page_owner.php'; include 'functions/page_owner.php';
include 'functions/permission.php'; include 'functions/permission.php';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment