Newsletter: Add custom link to media/post

This commit is contained in:
2020-05-13 19:23:39 +02:00
parent aa9ceb151f
commit 6b023d2546
10 changed files with 80 additions and 41 deletions

View File

@@ -14,7 +14,7 @@
<tr>
<td colspan="2">
<div style="background-color:#6dff58;color:#326526;border-radius:3px;padding:1rem;margin-top:1rem;display:inline-block;box-shadow: 2px 2px 3px 0px rgba(0,0,0,.5);">
<a href="[#]local_server[#]" target="_blank"><img style="border-radius:3px;" src="[#]geo_server[#]?a=tile&amp;id=static.marker&amp;z=13&amp;x=[#]longitude[#]&amp;y=[#]latitude[#]&amp;marker=[#]live_server[#]/images/footprint_mapbox.png&amp;token=[#]token[#]" alt="position" /></a>
<a href="[#]local_server[#]" target="_blank"><img style="border-radius:3px;" src="[#]geo_server[#]?a=tile&amp;id=static.marker&amp;z=13&amp;x=[#]longitude[#]&amp;y=[#]latitude[#]&amp;marker=[#]local_server[#]images/footprint_mapbox.png&amp;token=[#]token[#]" alt="position" /></a>
<br />[#]lat_dms[#] [#]lon_dms[#]
<br />[#]date_time[#] ([#]timezone[#])
</div>
@@ -27,7 +27,7 @@
<!-- [PART] news [START] -->
<tr>
<td>
<a href="[#]local_server[#]" target="_blank" style="text-decoration:none;background-color:#EEE;color:#333;margin-bottom:1rem;border-radius:3px;padding:5%;display:inline-block;width:90%;box-shadow: 2px 2px 3px 0px rgba(0,0,0,.5);">
<a href="[#]local_server[#]#project-[#]project[#]-[#]type[#]-[#]id[#]" target="_blank" style="text-decoration:none;background-color:#EEE;color:#333;margin-bottom:1rem;border-radius:3px;padding:5%;display:inline-block;width:90%;box-shadow: 2px 2px 3px 0px rgba(0,0,0,.5);">
<!-- [PART] media [START] --><img src="[#]local_server[#][#]thumb_path[#]" style="max-height:200px;image-orientation:from-image;" /><br /><span>[#]comment[#]</span><!-- [PART] media [END] -->
<!-- [PART] post [START] --><span>[#]content[#]</span><br /><span style="margin-top:0.5em;float:right;">--[#]formatted_name[#]</span><!-- [PART] post [END] -->
</a>

View File

@@ -48,7 +48,7 @@
<script type="text/javascript">
oSpot.onSamePageMove = function(asHash) {
if(self.tmp('first_exec')) initPage(asHash);
else {
else if(asHash.items[0] != self.vars(['project', 'codename'])) {
self.tmp('map').remove();
self.tmp('$Map').empty();
self.tmp('map', null);
@@ -181,11 +181,12 @@ function initPage(asHash) {
initSettings();
//project Bootstrap
initProject(asHash.items[0]);
var oFocusPost = asHash.items[1]?{type: asHash.items[1], id: asHash.items[2]}:null;
initProject(asHash.items[0], oFocusPost);
}
}
function initProject(sProjectCodeName){
function initProject(sProjectCodeName, oFocusPost){
self.tmp('first_exec', false);
self.vars('project', self.vars(['projects', sProjectCodeName]));
@@ -220,9 +221,9 @@ function initProject(sProjectCodeName){
$('#poster').toggle(!bHistoMode);
//Feed auto-update
updateFeed(true, false, function(){focusOnPost(oFocusPost);});
self.tmp('simple-bar').getScrollElement().scrollTop = 0;
if(!bHistoMode) onAutoUpdate(true);
else updateFeed(true);
}
function initPosts() {
@@ -320,10 +321,8 @@ function setUserInterface() {
}
}
function onAutoUpdate(bFirstExec) {
bFirstExec = bFirstExec || false;
if(bFirstExec) updateFeed(true);
else if(self.tmp('simple-bar').getScrollElement().scrollTop == 0) updateFeed(true, true);
function onAutoUpdate(bStart) {
if(!bStart && self.tmp('simple-bar').getScrollElement().scrollTop == 0) updateFeed(true, true);
setFeedUpdateTimer(60, onAutoUpdate);
}
@@ -381,7 +380,7 @@ function initSpotMessages(aoMessages, aoTracks, bNoFeed) {
$.each(self.vars('projects'), function(sCodeName, asProject){
var asRadioAttrs = {'type': 'radio', 'class': 'leaflet-control-layers-selector', 'name':'project', 'value': sCodeName};
if(asProject.id == self.vars(['project', 'id'])) asRadioAttrs.checked = 'checked';
var $Radio =$('<input>', asRadioAttrs).change(function(){
var $Radio = $('<input>', asRadioAttrs).change(function(){
toggleSettingsPanel(false);
self.setHash(self.vars('page'), [$(this).val()]);
});
@@ -620,9 +619,10 @@ function onFeedScroll() {
if(($Box.scrollTop() + $(window).height()) / $BoxContent.height() >= 0.8) updateFeed();
}
function updateFeed(bFirstChunk, bDiscrete) {
function updateFeed(bFirstChunk, bDiscrete, fCallback) {
bFirstChunk = bFirstChunk || false;
bDiscrete = bDiscrete || false;
fCallback = fCallback || function(){};
if(self.tmp('updatable')) {
if(!self.tmp('out-of-data') || bFirstChunk) {
@@ -635,29 +635,52 @@ function updateFeed(bFirstChunk, bDiscrete) {
self.tmp('news_chunk', 0);
}
self.get('feed', function(asData) {
$('#loading').hide();
$.each(asData, function(iKey, asPost){
$Posts.append(getPost(asPost));
});
self.tmp('news_chunk', self.tmp('news_chunk') + 1);
self.tmp('out-of-data', Object.keys(asData).length != self.vars('chunk_size'));
if(bFirstChunk===true) self.tmp('$PostList').empty();
self.tmp('$PostList').append($Posts.children());
self.tmp('updatable', true);
}, {
'project_id': self.vars(['project', 'id']),
'chunk': self.tmp('news_chunk')
});
self.get(
'feed',
function(asData) {
$('#loading').hide();
$.each(asData, function(iKey, asPost){
$Posts.append(getPost(asPost));
});
self.tmp('news_chunk', self.tmp('news_chunk') + 1);
self.tmp('out-of-data', Object.keys(asData).length != self.vars('chunk_size'));
if(bFirstChunk===true) self.tmp('$PostList').empty();
self.tmp('$PostList').append($Posts.children());
self.tmp('$PostList').find('img').waitForImages(true).done(fCallback);
self.tmp('updatable', true);
}, {
'project_id': self.vars(['project', 'id']),
'chunk': self.tmp('news_chunk')
}
);
}
}
else if(bFirstChunk) setFeedUpdateTimer(0.2);
}
function focusOnPost(oFocusPost) {
if(oFocusPost) {
var sElemId = '#'+oFocusPost.type+'-'+oFocusPost.id;
var $Post = oSpot.tmp('$PostList').find(sElemId);
var bGetToTop = (oSpot.tmp('$PostList').height() - (($Post.length > 0)?$Post.position().top:0) >= $(window).height());
if($Post.length > 0 && (bGetToTop || self.tmp('out-of-data'))) {
self.tmp('simple-bar').getScrollElement().scrollTop = $Post.position().top;
if(oFocusPost.type=='media' || oFocusPost.type=='message') $Post.find('a.drill').click();
}
else if(!self.tmp('out-of-data')) updateFeed(false, false, function() {focusOnPost(oFocusPost);});
else console.log('Missing element ID '+sElemId);
//Reset Hash
var asHash = self.getHash();
self.setHash(asHash.page, [asHash.items[0]]);
}
}
function setFeedUpdateTimer(iSeconds, fCallback) {
fCallback = fCallback || function(){updateFeed(true);};
if(typeof self.tmp('update_timer') != 'undefined') clearTimeout(self.tmp('update_timer'));
@@ -666,7 +689,10 @@ function setFeedUpdateTimer(iSeconds, fCallback) {
function getPost(asPost) {
asPost.headerless = asPost.headerless || false;
var $Post = $('<div>', {'class':'post '+asPost.type+(asPost.headerless?' headerless':'')});
if(asPost.id) $Post.prop('id', asPost.type+'-'+asPost.id);
var sRelTime = (asPost.relative_time!='')?((self.vars('project') && self.vars(['project', 'mode'])==self.consts.modes.histo)?asPost.formatted_time.substr(0, 10):asPost.relative_time):'';
var sAbsTime = asPost.formatted_time;
var sType = asPost.subtype || asPost.type;