Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions home/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,16 @@ Accept: application/json</pre>
function esc(s){ return s?String(s).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&#34;'):''; }

function timeAgo(iso) {
if (!iso) return '';
var d=new Date(iso), secs=Math.floor((Date.now()-d)/1000);
if (!iso || iso.indexOf('0001-')===0) return '';
var d=new Date(iso);
if(isNaN(d.getTime())) return '';
var secs=Math.floor((Date.now()-d)/1000);
if(secs<0) return '';
if(secs<60) return 'just now';
if(secs<3600) return Math.floor(secs/60)+'m ago';
if(secs<86400) return Math.floor(secs/3600)+'h ago';
return Math.floor(secs/86400)+'d ago';
if(secs<2592000) return Math.floor(secs/86400)+'d ago';
return d.toLocaleDateString();
}

function formatPrice(price) {
Expand Down Expand Up @@ -570,7 +574,8 @@ Accept: application/json</pre>
// Strip markdown formatting for preview
content=content.replace(/#{1,6}\s/g,'').replace(/\*\*/g,'').replace(/\[([^\]]+)\]\([^)]+\)/g,'$1').replace(/\n/g,' ');
if(content.length>280) content=content.substring(0,280)+'…';
var age=opinion.updated_at||opinion.created_at?'<span style="font-size:11px;color:#888;">'+timeAgo(opinion.updated_at||opinion.created_at)+'</span>':'';
var ts=opinion.updated_at&&opinion.updated_at.indexOf('0001-')!==0?opinion.updated_at:opinion.created_at;
var age=ts?'<span style="font-size:11px;color:#888;">'+timeAgo(ts)+'</span>':'';
var tag=(opinion.tags||'').indexOf('opinion')!==-1?'<span style="font-size:11px;background:#f0f0f0;padding:2px 8px;border-radius:10px;margin-right:6px;">opinion</span>':'';
el.innerHTML='<div style="padding:8px 0;">'+tag+age+
'<a href="/post/'+esc(opinion.id)+'" style="font-size:15px;font-weight:700;display:block;line-height:1.4;margin-top:4px;color:#111;">'+esc(title)+'</a>'+
Expand Down
2 changes: 1 addition & 1 deletion markets/markets.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ func generateMarketsCardHTML(prices map[string]float64) string {
}

var sb strings.Builder
sb.WriteString(`<table style="width:100%;border-collapse:collapse;font-size:14px;">`)
sb.WriteString(`<table style="width:100%;border-collapse:collapse;">`)
for i := 0; i < len(show); i += 2 {
sb.WriteString(`<tr>`)
for col := 0; col < 2; col++ {
Expand Down
Loading