mirror of
https://codeberg.org/teddit/teddit.git
synced 2026-04-18 21:45:06 -04:00
mv url localization away from pug templates
This commit is contained in:
@@ -69,26 +69,6 @@ meta(name="viewport", content="width=device-width, initial-scale=1.0")
|
||||
}
|
||||
}
|
||||
|
||||
function localize(url) {
|
||||
try {
|
||||
let u = new URL(url)
|
||||
if(u.host === 'www.reddit.com' || u.host === 'reddit.com') {
|
||||
url = url.replace(u.host, 'teddit.net')
|
||||
}
|
||||
if(u.host === 'i.redd.it' || u.host === 'v.redd.it') {
|
||||
let image_exts = ['png', 'jpg', 'jpeg']
|
||||
let video_exts = ['mp4', 'gif', 'gifv']
|
||||
let file_ext = getFileExtension(url)
|
||||
if(image_exts.includes(file_ext))
|
||||
url = url.replace(`${u.host}/`, 'teddit.net/pics/w:null_')
|
||||
if(video_exts.includes(file_ext) || !image_exts.includes(file_ext))
|
||||
url = url.replace(u.host, 'teddit.net/vids') + '.mp4'
|
||||
}
|
||||
|
||||
} catch(e) { }
|
||||
return url
|
||||
}
|
||||
|
||||
function toDateString(time) {
|
||||
let d = new Date();
|
||||
d.setTime(time*1000);
|
||||
|
||||
@@ -21,7 +21,7 @@ html
|
||||
span #{kFormatter(post.ups)}
|
||||
div.arrow.down
|
||||
.title
|
||||
a(href="" + localize(post.url) + "")
|
||||
a(href="" + post.url + "")
|
||||
h2 #{cleanTitle(post.title)}
|
||||
span(class="domain") (#{post.domain})
|
||||
p.submitted
|
||||
@@ -31,7 +31,7 @@ html
|
||||
if post.crosspost.is_crosspost === true
|
||||
.crosspost
|
||||
.title
|
||||
a(href="" + localize(post.crosspost.permalink) + "")
|
||||
a(href="" + post.crosspost.permalink + "")
|
||||
h2 #{cleanTitle(post.crosspost.title)}
|
||||
span(class="domain") (#{post.domain})
|
||||
.num_comments
|
||||
|
||||
Reference in New Issue
Block a user