handle conversation links, fixes #269

This commit is contained in:
Hannes Mannerheim 2015-11-16 18:13:48 +01:00
parent 2ffe165d41
commit 8a76a28a66
3 changed files with 27 additions and 6 deletions

View File

@ -282,6 +282,10 @@ class QvitterPlugin extends Plugin {
array('action' => 'shownotice'), array('action' => 'shownotice'),
array('notice' => '[0-9]+'), array('notice' => '[0-9]+'),
'qvitter'); 'qvitter');
URLMapperOverwrite::overwrite_variable($m, 'conversation/:id',
array('action' => 'conversation'),
array('id' => '[0-9]+'),
'qvitter');
} }
// if qvitter is opt-out, disable the default register page (if we don't have a valid invitation code) // if qvitter is opt-out, disable the default register page (if we don't have a valid invitation code)

View File

@ -567,6 +567,7 @@ function setNewCurrentStream(streamObject,setLocation,fallbackId,actionOnSuccess
$('#feed').show(); $('#feed').show();
$('#feed-body').removeAttr('data-end-reached'); $('#feed-body').removeAttr('data-end-reached');
$('#feed-header-inner h2').css('opacity','0.2'); $('#feed-header-inner h2').css('opacity','0.2');
$('#feed-header-inner h2').html(h2FeedHeader); // update header (could be wrong in cache)
$('#feed-header-inner h2').animate({opacity:'1'},1000); $('#feed-header-inner h2').animate({opacity:'1'},1000);
// set location bar from stream // set location bar from stream
@ -723,7 +724,6 @@ function setNewCurrentStream(streamObject,setLocation,fallbackId,actionOnSuccess
remove_spinner(); remove_spinner();
$('#feed-body').html(''); // empty feed body $('#feed-body').html(''); // empty feed body
$('#feed-header-inner h2').html(h2FeedHeader); // update header (could be wrong in cache)
$('#new-queets-bar').parent().addClass('hidden'); document.title = window.siteTitle; // hide new queets bar if it's visible there $('#new-queets-bar').parent().addClass('hidden'); document.title = window.siteTitle; // hide new queets bar if it's visible there
addToFeed(queet_data, false,'visible'); // add stream items to feed element addToFeed(queet_data, false,'visible'); // add stream items to feed element
$('#feed').animate({opacity:'1'},150); // fade in $('#feed').animate({opacity:'1'},150); // fade in

View File

@ -74,11 +74,6 @@ function URLtoStreamRouter(url) {
// we don't expect protocol to matter // we don't expect protocol to matter
url = removeProtocolFromUrl(url); url = removeProtocolFromUrl(url);
// remove anchor tags
if(url.indexOf('#')>-1) {
url = url.substring(0,url.indexOf('#'));
}
// not a local URL // not a local URL
if(url != window.siteRootDomain && url.indexOf(window.siteRootDomain + '/') != 0) { if(url != window.siteRootDomain && url.indexOf(window.siteRootDomain + '/') != 0) {
// console.log('not a local url: ' + url); // console.log('not a local url: ' + url);
@ -102,6 +97,13 @@ function URLtoStreamRouter(url) {
function pathToStreamRouter(path) { function pathToStreamRouter(path) {
// remove and remember anchor tags
var anchor = false;
if(path.indexOf('#')>-1) {
anchor = path.substring(path.indexOf('#'));
path = path.substring(0,path.indexOf('#'));
}
// remove starting slash // remove starting slash
if(path.indexOf('/') == 0) { if(path.indexOf('/') == 0) {
path = path.substring(1); path = path.substring(1);
@ -201,6 +203,21 @@ function pathToStreamRouter(path) {
return streamObject; return streamObject;
} }
// conversation/{id}
if(pathSplit.length == 2 && pathSplit[0] == 'conversation' && /^[0-9]+$/.test(pathSplit[1])) {
streamObject.name = 'notice';
streamObject.id = pathSplit[1];
// conversation links are redirected to notice page, if the link is to a
// non root notice, then the notice we want to link to and expand is in the hash
if(anchor && anchor.indexOf('#notice-') == 0) {
streamObject.id = anchor.substring(8);
}
streamObject.path = 'notice/' + streamObject.id;
streamObject.streamHeader = replaceHtmlSpecialChars(streamObject.path);
streamObject.stream = 'statuses/show/' + streamObject.id + '.json';
return streamObject;
}
// user/{id} // user/{id}
if(pathSplit.length == 2 && pathSplit[0] == 'user' && /^[0-9]+$/.test(pathSplit[1])) { if(pathSplit.length == 2 && pathSplit[0] == 'user' && /^[0-9]+$/.test(pathSplit[1])) {
streamObject.name = 'profile by id'; streamObject.name = 'profile by id';