Commit a491c25e authored by Malcolm Blaney's avatar Malcolm Blaney

Initial commit which adds channels to Reader module. Channels can

currently be set per feed, although most of the work is done to
also set channels based on the author as well. Control module
updates for channel UI as page-select is switched to display
channels on reader pages.
parent 001ce457
Pipeline #39733145 passed with stage
in 1 minute and 26 seconds
This diff is collapsed.
......@@ -186,7 +186,9 @@ class Settings extends Base {
$mysqli->close();
$this->AppendScript($path, 'dobrado.settings.js', false);
$this->AddTemplate(['"settings-display","","control"']);
// Add all modules that call AddSettingTypes here as a default.
$this->AddTemplate(['"settings-display","","account,control,purchase,' .
'reader"']);
$site_style = ['"",".settings-section","background-color","#eeeeee"',
'"",".settings-section","border","1px solid #aaaaaa"',
'"",".settings-section","margin","5px"',
......
......@@ -241,7 +241,9 @@ class Start extends Base {
}
if ($profile === 'unicyclic') {
return ['control' => ['displayMessageButton' => 'hidden',
'displayToolsButton' => 'display']];
'displayToolsButton' => 'display'],
'reader' => ['defaultChannel' => 'all',
'showChannels' => 'yes']];
}
return [];
}
......
......@@ -1609,7 +1609,7 @@ class Stock extends Base {
}
$mysqli->close();
if (count($us_sort_options) > 0) {
if (is_array($us_sort_options) && count($us_sort_options) > 0) {
$args = [];
foreach ($us_sort_options as $sort) {
$id = $sort['columnId'];
......
......@@ -283,6 +283,7 @@ class Writer extends Base {
'"",".writer .designate","padding","5px"',
'"",".writer .designate","margin-bottom","10px"',
'"",".writer .designate label","width","15em"',
'"",".writer .submit-designate","margin-left","5px"',
'"","#writer-feed-title-input","width","324px"',
'"","#writer-designate-input","width","250px"',
'"","#writer-webaction-info","padding-bottom","2px"',
......
This diff is collapsed.
......@@ -69,6 +69,15 @@ if (!this.dobrado.reader) {
title: 'Discovered Feeds',
close: function() { importList = []; importCount = 0; },
create: dobrado.fixedDialog });
$('.reader-channel-button').button().click(channelSettings);
$('.reader-channel-settings').dialog({
show: true,
autoOpen: false,
width: 600,
height: 300,
position: { my: 'top', at: 'top+50', of: window },
title: 'Channel List',
create: dobrado.fixedDialog });
feedSettings();
// Retrieve existing feed content from localStorage if available.
......@@ -93,10 +102,8 @@ if (!this.dobrado.reader) {
}
else {
// If the user hasn't subscribed to any feeds yet, automatically open
// the reader settings. The writer module also toggles designate, so
// show that too so they don't get out of sync.
// the reader settings.
if ($('.reader-settings .feed-item').length <= 5) {
$('.writer .designate').show();
$('.reader-settings').show();
}
newFeedEvents();
......@@ -104,7 +111,140 @@ if (!this.dobrado.reader) {
}
});
function channelSettings() {
function addChannel() {
var option = $('#reader-channel-add').val();
if (option === '') {
return;
}
$('#reader-channel-add').val('');
setChannel(option, true);
}
function setChannel(option, add) {
var feed = $('#reader-channel-url').html();
$.post('/php/request.php',
{ id: '#' + $('.reader').attr('id'), request : 'reader',
action: 'setChannel', channel: option, feed: feed,
url: location.href, token: dobrado.token },
function(response) {
if (dobrado.checkResponseError(response, 'reader setChannel')) {
return;
}
var channel = JSON.parse(response);
var text = channel.name === 'not set' ?
'The channel for this feed is no longer set.' :
'The channel for this feed has been updated to <b>' +
channel.name + '</b>';
$('#reader-channel-status').html(text);
// Also update the channel button in the feed setting list.
$('.reader-feed-list .feed-url').each(function() {
if ($(this).html() === feed) {
let channelButton =
$(this).parents('.feed-item').find('.reader-channel-button');
channelButton.button('option', 'label', channel.name);
}
});
// If called from addChannel add option to reader-channel-select.
if (add) {
$('#reader-channel-select').append('<option selected="selected">' +
channel.name + '</option>');
$('#reader-channel-select').selectmenu('refresh');
// The select is initially hidden if there are no channel options.
$('#reader-channel-select').parent().show();
}
});
}
var title = $(this).parent().find('.feed-title');
var link = $(this).parent().find('.feed-url');
var channel = $(this).html();
var text = '';
if (title && link) {
text = '<span id="reader-channel-title">' + title.html() +
'</span> [<a href="' + link.html() + '" ' +
'id="reader-channel-url">' + link.html() + '</a>]';
}
else if (link) {
text += '<a href="' + link.html() + '" id="reader-channel-url">' +
link.html() + '</a>';
}
$('#reader-channel-select').selectmenu({ change: function(event, ui) {
setChannel(ui.item.value, false); }});
$('#reader-channel-submit').button().click(addChannel);
if (channel === 'not set') {
text += '<p id="reader-channel-status">' +
'This feed does not have a channel set. ';
if ($('#reader-channel-select').children().length === 0) {
text += 'You can add one below to set the channel for this feed.</p>';
}
else {
let firstOption = $('#reader-channel-select').children().first().html();
if (firstOption !== 'not set') {
$('#reader-channel-select').prepend('<option selected="selected">' +
'not set</option>');
}
text += 'You can select an existing channel from the list or add a ' +
'new channel below.</p>';
}
}
else {
text += '<p id="reader-channel-status">' +
'The channel for this feed is <b>' + channel + '</b></p>';
}
$('#reader-channel-select').val(channel);
$('#reader-channel-select').selectmenu('refresh');
$('#reader-channel-info').html(text);
$('.reader-channel-settings').dialog('open');
}
function feedSettings() {
function readerOption(event, ui) {
if (ui.item.value === 'add') {
// This option is labelled 'All Feeds' so also reset the list.
$('#reader-channel-show').val('').selectmenu('refresh');
$('.reader-feed-list .feed-item').show();
$('#reader-feed-input-wrapper').show();
$('#reader-channel-wrapper').hide();
$('#reader-file-import-wrapper').hide();
$('.writer .designate').hide();
}
else if (ui.item.value === 'channels') {
$('#reader-channel-wrapper').show();
$('#reader-feed-input-wrapper').hide();
$('#reader-file-import-wrapper').hide();
$('.writer .designate').hide();
}
else if (ui.item.value === 'import') {
$('#reader-file-import-wrapper').show();
$('#reader-feed-input-wrapper').hide();
$('#reader-channel-wrapper').hide();
$('.writer .designate').hide();
}
else if (ui.item.value === 'writer') {
$('.writer .designate').show();
$('#reader-feed-input-wrapper').hide();
$('#reader-channel-wrapper').hide();
$('#reader-file-import-wrapper').hide();
}
}
function channelFeeds(event, ui) {
// First reset the feed list so that the new channel selection is shown.
$('.reader-feed-list .feed-item').show();
if (ui.item.value !== '') {
$('.reader-feed-list .reader-channel-button').each(function() {
if ($(this).html() !== ui.item.value) {
$(this).parents('.feed-item').hide();
}
});
}
}
$('#reader-feed-input').keypress(function(event) {
if (event.keyCode !== 13) {
return;
......@@ -117,10 +257,13 @@ if (!this.dobrado.reader) {
icon: 'ui-icon-closethick',
showLabel: false
}).click(removeFeed);
$('#reader-toggle-import').checkboxradio({ icon: false }).click(function() {
$('#reader-file-import').parent().toggle();
});
if ($('.writer .designate').length !== 0) {
$('#reader-options').
append('<option value="writer">Writer Settings</option>');
}
$('#reader-options').selectmenu({ change: readerOption });
$('#reader-file-import').change(importFile);
$('#reader-channel-show').selectmenu({ change: channelFeeds });
// Any newly added entry will be highlighted, remove the extra
// class after a few seconds.
if ($('.feed-text.added').length !== 0) {
......@@ -318,7 +461,7 @@ if (!this.dobrado.reader) {
$.post('/php/request.php',
{ id: '#' + $('.reader').attr('id'),
request : 'reader', action: 'remove',
xmlUrl: $(this).siblings().find('a').prop('href'),
xmlUrl: $(this).siblings().find('a.feed-url').prop('href'),
url: location.href, token: dobrado.token },
function(response) {
if (dobrado.checkResponseError(response, 'reader remove')) {
......@@ -441,7 +584,6 @@ if (!this.dobrado.reader) {
feedSettings();
}
if ($('.reader-settings .feed-item').length <= 5) {
$('.writer .designate').show();
$('.reader-settings').show();
}
newFeedEvents();
......@@ -527,6 +669,25 @@ if (!this.dobrado.reader) {
});
};
dobrado.reader.channelSelect = function(channel) {
$.post('php/request.php',
{ id: '#' + $('.reader').attr('id'), request: 'reader',
action: 'changeChannel', channel: channel,
url: location.href, token: dobrado.token },
function(response) {
if (dobrado.checkResponseError(response, 'reader change channel')) {
return;
}
var change = JSON.parse(response);
if (change.channel) {
reset(false);
}
else {
dobrado.changePage(channel);
}
});
};
dobrado.reader.update = function(action) {
request('newer', action);
};
......@@ -538,7 +699,7 @@ if (!this.dobrado.reader) {
// Set checked to false on the indie-action's for this item so
// that indieConfig will add a highlight to the actioned link and
// also update the href to point to the new permalink.
var item = $('.reader-item a[href="'+url+'"]').parents('.reader-item');
let item = $('.reader-item a[href="'+url+'"]').parents('.reader-item');
item.find('indie-action').data('checked', false);
dobrado.indieConfig();
}
......
......@@ -26,7 +26,8 @@
if(!this.dobrado.writer){dobrado.writer={};}
(function(){'use strict';var sendToTwitter=0;var webactionType='';var webactionUrl='';var defaultText='Write a new post...';$(function(){if($('#writer-content').length===0){return;}
$('#writer-content').click(function(){if(!$('.extended').dialog('isOpen')){dobrado.writer.showEditor();}});$('.writer-post').button({disabled:true}).click(function(){dobrado.log('Creating post...','info');dobrado.createModule('writer','post','post');});$('#writer-author').val(dobrado.readCookie('user'));$('#writer-title').val('');$('#writer-tag-input').val('');$('#writer-tags').checkboxradio({icon:false}).click(toggleTags);$('.writer .menu').menu();$('#writer-photo-browse').button().click(function(){dobrado.createModule('browser','browser','writer');});$('.writer-edit-settings').button({icon:'ui-icon-signal-diag',showLabel:false}).click(function(){$('.writer .designate').toggle();$('.reader-settings').toggle();});$('#writer-designate-action').val('post').change(showDesignate);$('.writer .submit-designate').button().click(designate);$('.writer .submit-feed-title').button().click(feedTitle);$('.writer-remove-title').button({icon:'ui-icon-closethick',showLabel:false}).click(removeTitle);$('.writer-remove-author').button({icon:'ui-icon-closethick',showLabel:false}).click(removeAuthor);$('.writer-remove-twitter').button({icon:'ui-icon-closethick',showLabel:false}).click(removeTwitter);$('.writer-remove-photo').button({icon:'ui-icon-closethick',showLabel:false}).click(removePhoto);$('#writer-remove-action').button({icon:'ui-icon-closethick',showLabel:false}).click(removeActionExplicit);if(dobrado.reader){$('#writer-follow').button().click(dobrado.reader.addFeed);}
$('#writer-content').click(function(){if(!$('.extended').dialog('isOpen')){dobrado.writer.showEditor();}});$('.writer-post').button({disabled:true}).click(function(){dobrado.log('Creating post...','info');dobrado.createModule('writer','post','post');});$('#writer-author').val(dobrado.readCookie('user'));$('#writer-title').val('');$('#writer-tag-input').val('');$('#writer-tags').checkboxradio({icon:false}).click(toggleTags);$('.writer .menu').menu();$('#writer-photo-browse').button().click(function(){dobrado.createModule('browser','browser','writer');});$('.writer-edit-settings').button({icon:'ui-icon-signal-diag',showLabel:false}).click(function(){if($('.reader-settings').length===0){$('.writer .designate').toggle();}
else{$('.reader-settings').toggle();}});$('#writer-designate-action').val('post').change(showDesignate);$('.writer .submit-designate').button().click(designate);$('.writer .submit-feed-title').button().click(feedTitle);$('.writer-remove-title').button({icon:'ui-icon-closethick',showLabel:false}).click(removeTitle);$('.writer-remove-author').button({icon:'ui-icon-closethick',showLabel:false}).click(removeAuthor);$('.writer-remove-twitter').button({icon:'ui-icon-closethick',showLabel:false}).click(removeTwitter);$('.writer-remove-photo').button({icon:'ui-icon-closethick',showLabel:false}).click(removePhoto);$('#writer-remove-action').button({icon:'ui-icon-closethick',showLabel:false}).click(removeActionExplicit);if(dobrado.reader){$('#writer-follow').button().click(dobrado.reader.addFeed);}
if($('.post-comment').length===0){$('<div></div>').addClass('post-comment').appendTo('.writer');}
webactionType=$('#writer-action-type').html();if(webactionType==='like'||webactionType==='reply'){$('#writer-content').val('');}
webactionUrl=$('#writer-action-url').attr('href');if(webactionType==='share'){shareFullText();}
......@@ -63,8 +64,8 @@ if(sendTo==='twitter'){sendToTwitter=1;}
dobrado.log('Loading action...','info');$.post('/php/request.php',{request:'writer',mode:'showWebaction',action:action,actionUrl:url,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'writer action')){return;}
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();}
$('#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='.photo-hidden img { display: none; } .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: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;}
$('#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','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','opacity','outline','outline-color','outline-style','outline-width','size','text-align','text-decoration','text-indent','text-transform','white-space','word-spacing'];var css='.photo-hidden img { display: none; } .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+='padding: 5px; }';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();}
if(dobrado.editMode){var element=$(id+' .dobrado-editable').get(0);if(element){dobrado.inlineEditor(element);}}
if(dobrado.editor){dobrado.editor.setData(defaultText);}
......
......@@ -61,12 +61,17 @@ if (!this.dobrado.writer) {
$('#writer-photo-browse').button().click(function() {
dobrado.createModule('browser', 'browser', 'writer');
});
// Writer module has a button to toggle reader module's settings.
// Writer module has a button to toggle reader module's settings, so show
// that when on the page as it can toggle writer designate actions too.
$('.writer-edit-settings').button({
icon: 'ui-icon-signal-diag', showLabel: false
}).click(function() {
if ($('.reader-settings').length === 0) {
$('.writer .designate').toggle();
}
else {
$('.reader-settings').toggle();
}
});
$('#writer-designate-action').val('post').change(showDesignate);
$('.writer .submit-designate').button().click(designate);
......@@ -346,15 +351,13 @@ if (!this.dobrado.writer) {
var editorCssProperties =
['background', 'background-attachment', 'background-color',
'background-image', 'background-position', 'background-repeat',
'background-size', 'clear', 'color', 'direction', 'empty-cells', 'font',
'background-size', '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'];
'list-style-position', 'list-style-type', 'opacity', 'outline',
'outline-color', 'outline-style', 'outline-width', 'size', 'text-align',
'text-decoration', 'text-indent', 'text-transform', 'white-space',
'word-spacing'];
var css = '.photo-hidden img { display: none; } .cke_editable { ';
var current = $(dobrado.current);
......@@ -362,10 +365,10 @@ if (!this.dobrado.writer) {
var property = editorCssProperties[i];
var value = current.css(property);
if (value) {
css += property + ': ' + value + ';';
css += property + ': ' + value + '; ';
}
}
css += '}';
css += 'padding: 5px; }';
CKEDITOR.addCss(css);
// Force the textarea to refresh (the browser leaves old content displayed)
var content = $('#writer-content').text();
......
......@@ -25,7 +25,7 @@
// for the JavaScript code in this page.
if(!this.dobrado.control){dobrado.control={};}
(function(){'use strict';var notificationsRequested=false;$(function(){function indieauthHome(){$.post('/php/request.php',{request:'control',url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'indieauthHome')){return;}
(function(){'use strict';var notificationsRequested=false;var currentPage='';$(function(){function indieauthHome(){$.post('/php/request.php',{request:'control',url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'indieauthHome')){return;}
var indieauth=JSON.parse(response);if(indieauth.location){location.href=indieauth.location;}});return false;}
function add(){dobrado.hideOtherMenu('add-menu-wrapper');dobrado.toggleMenu('add-menu-wrapper');$('body').one('click',hideMenu);return false;}
function message(){dobrado.hideOtherMenu('message-menu-wrapper');dobrado.toggleMenu('message-menu-wrapper');$('body').one('click',hideMenu);return false;}
......@@ -36,7 +36,7 @@ function checkboxradio(id,name,display,fn){if($('#'+id).length===0){return;}
var label=$('#'+id).labels().html();if(display){label+=' '+name;}
else{$('label[for='+id+']').addClass('ui-button-icon-only');}
$('#'+id).checkboxradio({icon:false,label:label}).click(fn);}
var display=$('.dobrado-mobile').is(':hidden');$('.control-button.home').button({icon:'ui-icon-home',showLabel:display}).click(dobrado.home);$('.control-button.indieauth-home').button({icon:'ui-icon-home',showLabel:display}).click(indieauthHome);$('.control-button.account-button').button({icon:'ui-icon-person',showLabel:display}).click(showAccount);$('.account-menu-wrapper .menu li').each(function(){$(this).click(dobrado.account.option);});$('.control-button.message-button').button({icon:'ui-icon-comment',showLabel:display}).click(message);$('.control-button.notification-button').button({icon:'ui-icon-star',showLabel:display}).click(notification);$('#control-tools').prop('checked',false);checkboxradio('control-tools','tools',display,tools);$('.control-button.site').button({icon:'ui-icon-gear',showLabel:display}).click(site);$('.control-button.page').button({icon:'ui-icon-document',showLabel:display}).click(page);$('#page-select').selectmenu({change:pageSelect});$('#page-input').keypress(pageSubmit).click(dobrado.clear);$('.control-button.add').button({icon:'ui-icon-plus',showLabel:display}).click(add);$('.add-menu-wrapper .menu li').each(function(){$(this).click(dobrado.addModule);});$('#control-edit').prop('checked',false);checkboxradio('control-edit','edit',display,edit);$('#control-layout').prop('checked',false);checkboxradio('control-layout','layout',display,layout);$('.control-button.copy').button({icon:'ui-icon-copy',showLabel:display}).click(copy);$('#copy-input').keypress(copySubmit).click(dobrado.clear);$('.control .menu').menu();$('.arrow-border').css('border-color','transparent transparent '+
currentPage=$('#page-select').val();let display=$('.dobrado-mobile').is(':hidden');$('.control-button.home').button({icon:'ui-icon-home',showLabel:display}).click(dobrado.home);$('.control-button.indieauth-home').button({icon:'ui-icon-home',showLabel:display}).click(indieauthHome);$('.control-button.account-button').button({icon:'ui-icon-person',showLabel:display}).click(showAccount);$('.account-menu-wrapper .menu li').each(function(){$(this).click(dobrado.account.option);});$('.control-button.message-button').button({icon:'ui-icon-comment',showLabel:display}).click(message);$('.control-button.notification-button').button({icon:'ui-icon-star',showLabel:display}).click(notification);$('#control-tools').prop('checked',false);checkboxradio('control-tools','tools',display,tools);$('.control-button.site').button({icon:'ui-icon-gear',showLabel:display}).click(site);$('.control-button.page').button({icon:'ui-icon-document',showLabel:display}).click(page);$('#page-select').selectmenu({change:pageSelect});$('#reset-page-select').button({icon:'ui-icon-closethick',showLabel:false}).click(resetPageSelect);$('#page-input').keypress(pageSubmit).click(dobrado.clear);$('.control-button.add').button({icon:'ui-icon-plus',showLabel:display}).click(add);$('.add-menu-wrapper .menu li').each(function(){$(this).click(dobrado.addModule);});$('#control-edit').prop('checked',false);checkboxradio('control-edit','edit',display,edit);$('#control-layout').prop('checked',false);checkboxradio('control-layout','layout',display,layout);$('.control-button.copy').button({icon:'ui-icon-copy',showLabel:display}).click(copy);$('#copy-input').keypress(copySubmit).click(dobrado.clear);$('.control .menu').menu();$('.arrow-border').css('border-color','transparent transparent '+
dobrado.arrowBorderColor+' transparent');$('.arrow').css('border-color','transparent transparent '+
dobrado.arrowBackgroundColor+' transparent');$('.notification-dialog').dialog({show:true,autoOpen:false,width:450,height:500,position:{my:'top',at:'top+50',of:window},title:'Notifications',create:dobrado.fixedDialog});setTimeout(function(){$('.control').show('fade');},500);$('#notification-tabs').tabs();showNotifications();dobrado.notify('system',dobrado.control.notifications);dobrado.notify('feed',dobrado.control.notifications);dobrado.notify('comment',dobrado.control.notifications);dobrado.notify('tag',dobrado.control.notifications);dobrado.notify('star',dobrado.control.notifications);dobrado.notify('share',dobrado.control.notifications);dobrado.notify('invite',dobrado.control.notifications);});function showNotifications(){function addToGroup(){dobrado.log('Adding notification.','info');$.post('/php/request.php',{request:'notification',action:'addToGroup',url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'add notification')){return false;}
var notification=JSON.parse(response);var group='.notifications-'+notification.type+'-group';$(group).append(notification.group).show();$('.remove-notification-group').button({icon:'ui-icon-closethick',showLabel:false}).click(removeFromGroup);$('#add-notification').remove();});return false;}
......@@ -144,16 +144,18 @@ $('.extended').dialog('open');$('.extended').data('mode','site');$('#site-templa
function hideMenu(){$('.control .menu-wrapper').hide();}
function showAccount(){dobrado.hideOtherMenu('account-menu-wrapper');dobrado.toggleMenu('account-menu-wrapper');$('body').one('click',hideMenu);return false;}
function copySubmit(event){if(event.keyCode!==13){return;}
event.preventDefault();$('#control-copy-form > input').each(function(){if($(this).attr('name')==='page'){if(/^[a-z0-9\/_-]+$/i.test($(this).val())){var owner='';var page='';var fields=$(this).val().match(/^([^/]+)\/?(.*)$/);if(fields&&fields.length===3){if(fields[2]===''){page=fields[1];}
event.preventDefault();$('#control-copy-form > input').each(function(){if($(this).attr('name')==='page'){if(/^[a-z0-9\/_-]+$/i.test($(this).val())){let owner='';let page='';let fields=$(this).val().match(/^([^\/]+)\/?(.*)$/);if(fields&&fields.length===3){if(fields[2]===''){page=fields[1];}
else{owner=fields[1];page=fields[2];}
dobrado.log('Copying page...','info');$.post('/php/copy.php',{owner:owner,page:page,url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'copy')){return;}
var page=JSON.parse(response);location.href=page.name;});}}
let copy=JSON.parse(response);location.href=copy.name;});}}
else{dobrado.log('Invalid page name.','error');}
return false;}});}
function pageSelect(){if($(this).val()===''){$('#page-select').selectmenu('destroy');$('#page-select').hide();$('#page-input').show();}
else{dobrado.changePage($(this).val());}}
function pageSelect(event,ui){if(ui.item.value===''){$('#page-select-button').hide();$('#page-input').show();$('#reset-page-select').show();}
else if($('.reader').length!==0){currentPage=ui.item.value;dobrado.reader.channelSelect(currentPage);}
else{dobrado.changePage(ui.item.value);}}
function pageSubmit(event){if(event.keyCode!==13){return;}
event.preventDefault();dobrado.changePage($(this).val());return false;}
function resetPageSelect(){$('#page-select').val(currentPage).selectmenu('refresh');$('#page-select-button').show();$('#page-input').hide();$('#reset-page-select').hide();return false;}
dobrado.control.notifications=function(action){if(notificationsRequested){return;}
notificationsRequested=true;$.post('/php/request.php',{request:'notification',action:'new',url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,'notifications callback')){return;}
var notification=JSON.parse(response);if(notification.content!==''){if($('.notifications').length===0){$('<div></div>').addClass('notifications').appendTo('body');}
......
......@@ -69,8 +69,8 @@ notify=false;if(extended.content.notify){notify=extended.content.notify;}
var label=$(dobrado.current).data('label');if(label==='commenteditor'){label='Comment Manager';}
else if(label==='simple'){label='Text Area';}
else{label=label.charAt(0).toUpperCase()+label.slice(1);}
$('#extended-tabs li a').first().html(label);$('#extended-custom').html('<div class="custom">'+custom+'</div>');$('#extended-content').html('<div class="edit">'+source+'</div>');dobrado.oldPermalink=extended.content.permalink;$('#extended-custom-settings').find(":input").change(function(){customChange=true;});$('#extended-custom-settings :submit').button().click(function(){$('.extended').dialog('close');return false;});$('.post-remove-photo').button({icon:'ui-icon-closethick',showLabel:false}).click(function(){$(this).parent().remove();return false;});$('#post-add-photo').button().click(function(){dobrado.createModule('browser','browser','extended');return false;});if(extended.content.editor===true){var edit=$('#extended-content > div.edit');var editorCssProperties=['background','background-attachment','background-color','background-image','background-position','background-repeat','background-size','clear','clip','color','content','cursor','direction','empty-cells','filter','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','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);dobrado.editor=CKEDITOR.replace(edit.get(0),{allowedContent:true,disableNativeSpellChecker:false,enterMode:CKEDITOR.ENTER_BR,filebrowserBrowseUrl:'/php/browse.php',height:240,removePlugins:'elementspath,tableselection,tabletools,contextmenu,liststyle',resize_enabled:false,toolbar:[['Source','-','NewPage'],['Undo','Redo','-','SelectAll','RemoveFormat'],['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],['Bold','Italic','Underline','Strike'],['Subscript','Superscript'],['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],['Link','Unlink','Anchor'],['Image','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],['Format','Font','FontSize'],['TextColor','BGColor'],['Maximize','ShowBlocks','-','About']]});}
$('#extended-tabs li a').first().html(label);$('#extended-custom').html('<div class="custom">'+custom+'</div>');$('#extended-content').html('<div class="edit">'+source+'</div>');dobrado.oldPermalink=extended.content.permalink;$('#extended-custom-settings').find(":input").change(function(){customChange=true;});$('#extended-custom-settings :submit').button().click(function(){$('.extended').dialog('close');return false;});$('.post-remove-photo').button({icon:'ui-icon-closethick',showLabel:false}).click(function(){$(this).parent().remove();return false;});$('#post-add-photo').button().click(function(){dobrado.createModule('browser','browser','extended');return false;});if(extended.content.editor===true){var edit=$('#extended-content > div.edit');var editorCssProperties=['background','background-attachment','background-color','background-image','background-position','background-repeat','background-size','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','opacity','outline','outline-color','outline-style','outline-width','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+='padding: 5px; }';CKEDITOR.addCss(css);dobrado.editor=CKEDITOR.replace(edit.get(0),{allowedContent:true,disableNativeSpellChecker:false,enterMode:CKEDITOR.ENTER_BR,filebrowserBrowseUrl:'/php/browse.php',height:240,removePlugins:'elementspath,tableselection,tabletools,contextmenu,liststyle',resize_enabled:false,toolbar:[['Source','-','NewPage'],['Undo','Redo','-','SelectAll','RemoveFormat'],['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],['Bold','Italic','Underline','Strike'],['Subscript','Superscript'],['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],['Link','Unlink','Anchor'],['Image','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],['Format','Font','FontSize'],['TextColor','BGColor'],['Maximize','ShowBlocks','-','About']]});}
dobrado.extended.styleEditor(extended.style,extended.media);$('#extended-history').html(extended.history);$('.extended').dialog('open');$('.extended').data('mode','box');};}());jQuery.fn.farbtastic=function(callback){$.farbtastic(this,callback);return this;};jQuery.farbtastic=function(container,callback){container=$(container).get(0);return container.farbtastic||(container.farbtastic=new jQuery._farbtastic(container,callback));}
jQuery._farbtastic=function(container,callback){var fb=this;$(container).html('<div class="farbtastic"><div class="color"></div><div class="wheel"></div><div class="overlay"></div><div class="h-marker marker"></div><div class="sl-marker marker"></div></div>');var e=$('.farbtastic',container);fb.wheel=$('.wheel',container).get(0);fb.radius=84;fb.square=100;fb.width=194;fb.linkTo=function(callback){if(typeof fb.callback=='object'){$(fb.callback).unbind('keyup',fb.updateValue);}
fb.color=null;if(typeof callback=='function'){fb.callback=callback;}
......
......@@ -31,6 +31,7 @@ if (!this.dobrado.control) {
'use strict';
var notificationsRequested = false;
var currentPage = '';
$(function() {
......@@ -99,8 +100,9 @@ if (!this.dobrado.control) {
$('#' + id).checkboxradio({ icon: false, label: label }).click(fn);
}
currentPage = $('#page-select').val();
// Display labels on control bar buttons when not mobile mode.
var display = $('.dobrado-mobile').is(':hidden');
let display = $('.dobrado-mobile').is(':hidden');
// Hook up default events.
$('.control-button.home').button({ icon: 'ui-icon-home',
showLabel: display
......@@ -127,6 +129,8 @@ if (!this.dobrado.control) {
$('.control-button.page').button({ icon: 'ui-icon-document',
showLabel: display }).click(page);
$('#page-select').selectmenu({ change: pageSelect });
$('#reset-page-select').button({ icon: 'ui-icon-closethick',
showLabel: false }).click(resetPageSelect);
$('#page-input').keypress(pageSubmit).click(dobrado.clear);
$('.control-button.add').button({ icon: 'ui-icon-plus',
showLabel: display }).click(add);
......@@ -1095,10 +1099,10 @@ if (!this.dobrado.control) {
$('#control-copy-form > input').each(function() {
if ($(this).attr('name') === 'page') {
if (/^[a-z0-9\/_-]+$/i.test($(this).val())) {
var owner = '';
var page = '';
let owner = '';
let page = '';
// Look for an optional username before the page name.
var fields = $(this).val().match(/^([^/]+)\/?(.*)$/);
let fields = $(this).val().match(/^([^\/]+)\/?(.*)$/);
if (fields && fields.length === 3) {
if (fields[2] === '') {
page = fields[1];
......@@ -1115,8 +1119,8 @@ if (!this.dobrado.control) {
if (dobrado.checkResponseError(response, 'copy')) {
return;
}
var page = JSON.parse(response);
location.href = page.name;
let copy = JSON.parse(response);
location.href = copy.name;
});
}
}
......@@ -1128,14 +1132,19 @@ if (!this.dobrado.control) {
});
}
function pageSelect() {
if ($(this).val() === '') {
$('#page-select').selectmenu('destroy');
$('#page-select').hide();
function pageSelect(event, ui) {
if (ui.item.value === '') {
$('#page-select-button').hide();
$('#page-input').show();
$('#reset-page-select').show();
}
else if ($('.reader').length !== 0) {
// Store the new channel in case resetPageSelect is called.
currentPage = ui.item.value;
dobrado.reader.channelSelect(currentPage);
}
else {
dobrado.changePage($(this).val());
dobrado.changePage(ui.item.value);
}
}
......@@ -1148,6 +1157,14 @@ if (!this.dobrado.control) {
return false;
}
function resetPageSelect() {
$('#page-select').val(currentPage).selectmenu('refresh');
$('#page-select-button').show();
$('#page-input').hide();
$('#reset-page-select').hide();
return false;
}
dobrado.control.notifications = function(action) {
// Since multiple notifications are subscribed to, ignore subsequent
// notifications when a request has already been made as all new
......
......@@ -584,15 +584,13 @@ if (!this.dobrado.extended) {
var editorCssProperties =
['background', 'background-attachment', 'background-color',
'background-image', 'background-position', 'background-repeat',
'background-size', 'clear', 'clip', 'color', 'content', 'cursor',
'direction', 'empty-cells', 'filter', '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', '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'];
'background-size', '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',
'opacity', 'outline', 'outline-color', 'outline-style',
'outline-width', 'size', 'text-align', 'text-decoration',
'text-indent', 'text-transform', 'white-space', 'word-spacing'];
var css = '.cke_editable { ';
var current = $(dobrado.current);
......@@ -600,10 +598,10 @@ if (!this.dobrado.extended) {
var property = editorCssProperties[i];
var value = current.css(property);
if (value) {
css += property + ': ' + value + ';';
css += property + ': ' + value + '; ';
}
}
css += '}';
css += 'padding: 5px; }';
CKEDITOR.addCss(css);
dobrado.editor = CKEDITOR.replace(edit.get(0),
......
......@@ -349,6 +349,7 @@ function create_site_style() {
'"","body","padding","0"',
'"","body","color","#222222"',
'"","body","font-family","Arial, sans-serif"',
'"","audio","max-width","100%"',
'"","iframe","max-width","100%"',
'"","video","max-width","100%"',
'"","img","max-width","100%"',
......
......@@ -18,7 +18,6 @@
session_start();
function session_expired() {
// All javascript xhr should be able to log errors.
if (isset($_SESSION['token']) &&
isset($_POST['token']) && $_SESSION['token'] === $_POST['token']) {
return false;
......@@ -27,6 +26,7 @@ function session_expired() {
// May have an expired session because page.php does 'not modified' checks
// on feed pages. When this happens reload is used to skip the check.
$_SESSION['reload'] = true;
// Scripts that include this function should be returning JSON to client.
echo json_encode(['error' => 'Session expired: reloading page.']);
return true;
}
......@@ -260,6 +260,7 @@ class Control extends Base {
'"","#page-input","width","200px"',
'"' . $media . '","#page-input","width","100px"',
'"","#page-select","width","150px"',
'"","#reset-page-select","margin-left","2px"',
'"' . $media . '","#page-select","width","100px"',
'"","#control-page-form .ui-selectmenu-button","width",' .
'"150px"',
......@@ -445,11 +446,31 @@ class Control extends Base {
}
private function PageForm() {
// Check if there's a reader module on the page and that the user has
// selected to show channels, otherwise page options are shown.
$show_channels = isset($this->user->settings['reader']['showChannels']) ?
$this->user->settings['reader']['showChannels'] === 'yes' : false;
if ($show_channels && $this->AlreadyOnPage('reader')) {
$reader = new Module($this->user, $this->owner, 'reader');
$options = $reader->Factory('Channels');
if ($options !== '') {
return '<form id="control-page-form">' .
'<select id="page-select">' . $options . '</select>' .
'<span id="page-input-wrapper">' .
'<input id="page-input" class="control-input hidden" ' .
'type="text" name="page" value="change page..." ' .
'maxlength="200">' .
'<button id="reset-page-select" class="hidden">reset</button>' .
'</span>' .
'</form>';
}
}
$options = '';
$selected = false;
// Use a session array to avoid checking permissions on every page load.
if (isset($_SESSION['control-page-options'])) {
foreach($_SESSION['control-page-options'] as $page) {
foreach ($_SESSION['control-page-options'] as $page