Skip to content

Commit

Permalink
Images archiving fixes (#1147)
Browse files Browse the repository at this point in the history
* List of archived server

* Images src replace to archive

* Replace images in all code

* Fix srcNew
  • Loading branch information
zanhesl authored Nov 27, 2023
1 parent a54e949 commit 3207bed
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions components/imagegallery/templates/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

var src = image.csrc || image.src;

if (src && src.indexOf('peertube') == -1)
src = src.replace('bastyon.com:8092', 'pocketnet.app:8092').replace('test.', '')
if (src && src.indexOf('peertube') == -1)
src = replaceArchiveInImage(src)

%>

Expand Down
2 changes: 1 addition & 1 deletion components/wallet/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var wallet = (function(){
defaultValueTemplate : function(d, f, g, firstdef){
if(_.isObject(d)){

var img = d.image ? d.image.replace('bastyon.com:8092', 'pocketnet.app:8092').replace('test.pocketnet', 'pocketnet') : null
var img = d.image ? replaceArchiveInImage(d.image) : null

var h = ''

Expand Down
15 changes: 13 additions & 2 deletions js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1788,7 +1788,8 @@ bgImagesClApply = function (el, src) {

bgImagesClApplyTemplate = function (src) {

src = (src || "").replace('bastyon.com:8092', 'pocketnet.app:8092').replace('test.pocketnet', 'pocketnet')
src = (src || "");
src = replaceArchiveInImage(src);

app.platform.archivedServers.map(server => {
if (src.includes(server)) src = src.replace(server, 'peertube.archive.pocketnet.app');
Expand Down Expand Up @@ -9577,7 +9578,7 @@ edjsHTML = function () {
if (t.withBorder) cl.push('withBorder')
if (t.stretched) cl.push('stretched')

var src = (t.file && t.file.url ? t.file.url : t.file).replace('bastyon.com:8092', 'pocketnet.app:8092').replace('test.pocketnet', 'pocketnet')
var src = replaceArchiveInImage(t.file && t.file.url ? t.file.url : t.file)

return '<div class="article_image ' + cl.join(' ') + '"><img src="' + checkIfAllowedImageApply(_.escape(src)) + '" alt="' + (r) + '" />' +

Expand Down Expand Up @@ -10556,6 +10557,16 @@ var connectionSpeed = function()
return defaultSpeed;
};

function replaceArchiveInImage(src) {
var srcNew = src;

app.platform.archivedServers.map(server => {
if (srcNew.includes(server)) srcNew = srcNew.replace(server, 'peertube.archive.pocketnet.app');
});

return srcNew.replace('bastyon.com:8092', 'pocketnet.app:8092').replace('test.pocketnet', 'pocketnet');
};

/*test*/
/*
if(typeof Window != 'undefined'){
Expand Down
2 changes: 1 addition & 1 deletion js/vendor/imagesloaded.pkgd.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@
}
}

url = url.replace('bastyon.com:8092', 'pocketnet.app:8092').replace('test.pocketnet', 'pocketnet')
url = replaceArchiveInImage(url)

if (app){

Expand Down

0 comments on commit 3207bed

Please sign in to comment.