From fd7c85d7e574074392d2db0b0342bcdd1e723920 Mon Sep 17 00:00:00 2001 From: marcdeb1 Date: Sat, 6 Apr 2019 12:26:30 +0200 Subject: [PATCH 1/6] Removed author from claim page --- src/Template/Main/claims.ctp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Template/Main/claims.ctp b/src/Template/Main/claims.ctp index 4458105..58e67d6 100644 --- a/src/Template/Main/claims.ctp +++ b/src/Template/Main/claims.ctp @@ -113,17 +113,17 @@ if (strlen(trim($desc)) == 0) {
', $desc) ?>
-
Author
Content Type
+
Language
- -
author)) > 0 ? $claim->author : 'Unspecified' ?>
content_type)) > 0 ? $claim->content_type : 'Unspecified' ?>
+
language)) > 0 ? ($claim->language == 'en' ? 'English' : '') : 'Unspecified' ?>
+
Language
+ -->
language)) > 0 ? ($claim->language == 'en' ? 'English' : '') : 'Unspecified' ?>
+ -->
Open in LBRY From 428c9d88964cbaf5e42e3ba369adec1912e1df06 Mon Sep 17 00:00:00 2001 From: marcdeb1 Date: Sat, 6 Apr 2019 12:37:55 +0200 Subject: [PATCH 2/6] Block time & Created time matching --- src/Template/Main/tx.ctp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Template/Main/tx.ctp b/src/Template/Main/tx.ctp index 0a7e8aa..1f6a391 100644 --- a/src/Template/Main/tx.ctp +++ b/src/Template/Main/tx.ctp @@ -18,9 +18,12 @@
+ transaction_time - strtotime($tx->created_at)) > 3600) ? $tx->transaction_time : $tx->created_at; + ?>

Time Created

-
created_at->format('j M Y H:i:s') . ' UTC '; ?>
+
format('j M Y H:i:s') . ' UTC '; ?>
From 7899669c4b9b1480b58cff12d9bdf6df82335760 Mon Sep 17 00:00:00 2001 From: marcdeb1 Date: Sat, 6 Apr 2019 16:07:30 +0200 Subject: [PATCH 3/6] Added information to claim page --- src/Controller/MainController.php | 2 +- src/Template/Main/claims.ctp | 17 ++++++++++++++++- src/Template/Main/tx.ctp | 9 +++++++-- webroot/css/main.css | 11 ++++++----- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 0e9a4b6..59c8188 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -169,7 +169,7 @@ public function claims($id = null) { $this->set('currentPage', $page); $this->set('claims', $claims); } else { - $claim = $this->Claims->find()->select($this->Claims)->select(['publisher' => 'C.name'])->leftJoin(['C' => 'claim'], ['C.claim_id = Claims.publisher_id'])->where(['Claims.claim_id' => $id])->order(['Claims.created_at' => 'DESC'])->first(); + $claim = $this->Claims->find()->select($this->Claims)->select(['publisher' => 'C.name'])->leftJoin(['C' => 'claim'], ['C.claim_id = Claims.publisher_id'])->select(['claim_bid' => 'O.value'])->leftJoin(['O' => 'output'], ['Claims.transaction_hash_id = O.transaction_hash AND Claims.vout = O.vout'])->where(['Claims.claim_id' => $id])->order(['Claims.created_at' => 'DESC'])->first(); if (!$claim) { return $this->redirect('/'); } diff --git a/src/Template/Main/claims.ctp b/src/Template/Main/claims.ctp index 58e67d6..6d06df1 100644 --- a/src/Template/Main/claims.ctp +++ b/src/Template/Main/claims.ctp @@ -44,7 +44,7 @@ $cost = 'Free'; if (isset($claim->price) && $claim->price > 0) { $cost = $this->Amount->formatCurrency($claim->price) . ' LBC'; } else if (isset($claim->fee) && strtolower($claim->fee_currency) === 'lbc') { - $cost = $this->Amount->formatCurrency($claim->fee) . ' LBC'; + $cost = (float) ($claim->fee) . ' LBC'; } $desc = $claim->description; @@ -66,6 +66,10 @@ if (strlen(trim($desc)) == 0) {
+
+
bid_state; ?>
+
+
is_nsfw && strlen(trim($claim->thumbnail_url)) > 0): ?> @@ -101,6 +105,17 @@ if (strlen(trim($desc)) == 0) {
+ +
Claim bid
+
Effective amount
+ +
claim_bid) . ' LBC'; ?>
+
effective_amount / 100000000) . ' LBC'; ?>
+ +
+ +
Stream hash
+
sd_hash ?>
diff --git a/src/Template/Main/tx.ctp b/src/Template/Main/tx.ctp index 1f6a391..42da9e6 100644 --- a/src/Template/Main/tx.ctp +++ b/src/Template/Main/tx.ctp @@ -19,7 +19,12 @@
transaction_time - strtotime($tx->created_at)) > 3600) ? $tx->transaction_time : $tx->created_at; + $transaction_time = \DateTime::createFromFormat('U', $tx->transaction_time); + if($tx->transaction_time == null || strlen(trim($tx->transaction_time)) == 0) { + $created_time = $tx->created_at; + } else { + $created_time = (abs($tx->transaction_time - strtotime($tx->created_at)) > 3600) ? $transaction_time : $tx->created_at; + } ?>

Time Created

@@ -29,7 +34,7 @@

Block Time

transaction_time == null || strlen(trim($tx->transaction_time)) == 0) ? 'Not yet confirmed' : - \DateTime::createFromFormat('U', $tx->transaction_time)->format('j M Y H:i:s') . ' UTC' ?> + $transaction_time->format('j M Y H:i:s') . ' UTC' ?> transaction_time > $tx->created_at->getTimestamp()): $diffSeconds = $tx->transaction_time - $tx->created_at->getTimestamp(); diff --git a/webroot/css/main.css b/webroot/css/main.css index 2f1a828..ae5e40f 100644 --- a/webroot/css/main.css +++ b/webroot/css/main.css @@ -69,7 +69,7 @@ border-radius: 0 8px 8px 0 } .claims-grid .claim-grid-item.last-item { margin-right: 0 } .claims-grid .claim-grid-item.last-row { margin-bottom: 0 } .claims-grid .claim-grid-item .price-tag { font-size: 65%; position: absolute; left: 0; top: 0; z-index: 505; background: #155b4a; color: #fff; text-align: center; padding: 4px 12px } -.claims-grid .claim-grid-item .tags { font-size: 65%; position: absolute; right: 0; top: 0; z-index: 505 } +.claims-grid .claim-grid-item .tags, .claim-info .tags { font-size: 65%; position: absolute; right: 0; top: 0; z-index: 505 } .claims-grid .claim-grid-item .thumbnail { width: 100%; height: 200px; background: #f0f0f0; display: block; position: relative; overflow: hidden;} .claims-grid .claim-grid-item .thumbnail img { width: 100%; position: absolute; left: 0; top: 0; border-bottom: 1px solid #eee } .claims-grid .claim-grid-item .thumbnail.purple { background: #ab47bc } @@ -79,9 +79,9 @@ border-radius: 0 8px 8px 0 } .claims-grid .claim-grid-item .thumbnail.green { background: #66bb6a } .claims-grid .claim-grid-item .thumbnail.yellow { background: #fdd835 } .claims-grid .claim-grid-item .thumbnail .autothumb { display: block; margin: 73px auto 0 auto; text-align: center; font-size: 240%; color: #fff; line-height: 54px } -.claims-grid .claim-grid-item .tags > div { display: inline-block; padding: 4px 12px; margin-left: 2px } +.claims-grid .claim-grid-item .tags > div, .claim-info .tags > div { display: inline-block; padding: 4px 12px; margin-left: 2px } .claims-grid .claim-grid-item .tags .nsfw { background: #e53935; text-align: center; color: #fff; position: relative; left: 1px } -.claims-grid .claim-grid-item .tags .bid-state { background: #551CA1; text-align: center; color: #fff; } +.claims-grid .claim-grid-item .tags .bid-state, .claim-info .bid-state { background: #551CA1; text-align: center; color: #fff; } .claims-grid .claim-grid-item .tags .content-type { background: #880e4f; text-align: center; color: #fff; } .claims-grid .claim-grid-item .metadata { padding: 24px; font-size: 90% } .claims-grid .claim-grid-item .title { font-size: 120%; height: 25px; line-height: 25px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap } @@ -95,11 +95,12 @@ border-radius: 0 8px 8px 0 } .claims-grid .claim-grid-item .spacer { height: 16px } .claims-body { width: 1200px; margin: 0 auto 0 auto; cursor: default } -.claims-body .claim-info { width: 400px; float: left; /*box-shadow: 0 2px 4px rgba(0,0,0,.175);*/ border: 1px solid rgba(0,0,0,.15); cursor: default } +.claims-body .claim-info { position: relative; width: 400px; float: left; /*box-shadow: 0 2px 4px rgba(0,0,0,.175);*/ border: 1px solid rgba(0,0,0,.15); cursor: default } .claims-body .claim-info .thumbnail { width: 100%; height: 220px; background: #f0f0f0; display: block; position: relative; overflow: hidden } .claims-body .claim-info .thumbnail img { width: 100% } .claims-body .claim-info .content { padding: 24px } -.claims-body .claim-info .content .label { font-size: inherit; text-decoration: underline; color: #666666 } +.claims-body .claim-info .content .label { display: inline; font-size: inherit; text-decoration: underline; color: #666666 } +.claims-body .claim-info .content .help-text { text-decoration: underline dotted grey; cursor: help; } .claims-body .claim-info .content .value { font-weight: 300; margin-bottom: 24px; word-break: break-word; word-wrap: break-word } .claims-body .claim-info .content .value:last-child { margin-bottom: 0 } .claims-body .claim-info .content .half-width { width: 50%; float: left } From 28071a4a923f0053c28118039ada088bffcff84a Mon Sep 17 00:00:00 2001 From: marcdeb1 Date: Sat, 6 Apr 2019 16:14:43 +0200 Subject: [PATCH 4/6] Minor fix --- src/Template/Main/claims.ctp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Template/Main/claims.ctp b/src/Template/Main/claims.ctp index 6d06df1..7e21cd5 100644 --- a/src/Template/Main/claims.ctp +++ b/src/Template/Main/claims.ctp @@ -46,6 +46,7 @@ if (isset($claim->price) && $claim->price > 0) { } else if (isset($claim->fee) && strtolower($claim->fee_currency) === 'lbc') { $cost = (float) ($claim->fee) . ' LBC'; } +$effective_amount = $claim->effective_amount / 100000000; $desc = $claim->description; if (strlen(trim($desc)) == 0) { @@ -110,7 +111,7 @@ if (strlen(trim($desc)) == 0) {
Effective amount
claim_bid) . ' LBC'; ?>
-
effective_amount / 100000000) . ' LBC'; ?>
+
claim_bid) ? 'Synchronizing' : ((float) ($claim->effective_amount / 100000000) . ' LBC'); ?>
From ecaefa6950622d59eb503abc66b2b8742bd511eb Mon Sep 17 00:00:00 2001 From: marcdeb1 Date: Thu, 7 Nov 2019 23:59:32 +0100 Subject: [PATCH 5/6] Format currency refactoring --- src/Template/Element/claimbox.ctp | 2 +- src/Template/Main/claims.ctp | 6 +++--- src/View/Helper/AmountHelper.php | 6 ++++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Template/Element/claimbox.ctp b/src/Template/Element/claimbox.ctp index 76bc25e..f8a1dc3 100644 --- a/src/Template/Element/claimbox.ctp +++ b/src/Template/Element/claimbox.ctp @@ -4,7 +4,7 @@ $cost = ''; if (isset($claim->price) && $claim->price > 0) { $cost = $this->Amount->formatCurrency($claim->price) . ' LBC'; } else if (isset($claim->fee) && strtolower($claim->fee_currency) === 'lbc') { - $cost = $this->Amount->formatCurrency($claim->fee) . ' LBC'; + $cost = $this->Amount->formatLbryCurrency($claim->fee) . ' LBC'; } $a = ['purple', 'orange', 'blue', 'teal', 'green', 'yellow']; // content type diff --git a/src/Template/Main/claims.ctp b/src/Template/Main/claims.ctp index 7e21cd5..9de70d2 100644 --- a/src/Template/Main/claims.ctp +++ b/src/Template/Main/claims.ctp @@ -44,9 +44,9 @@ $cost = 'Free'; if (isset($claim->price) && $claim->price > 0) { $cost = $this->Amount->formatCurrency($claim->price) . ' LBC'; } else if (isset($claim->fee) && strtolower($claim->fee_currency) === 'lbc') { - $cost = (float) ($claim->fee) . ' LBC'; + $cost = $this->Amount->formatLbryCurrency($claim->fee) . ' LBC'; } -$effective_amount = $claim->effective_amount / 100000000; +$effective_amount = $this->Amount->formatLbryCurrency($claim->effective_amount); $desc = $claim->description; if (strlen(trim($desc)) == 0) { @@ -111,7 +111,7 @@ if (strlen(trim($desc)) == 0) {
Effective amount
claim_bid) . ' LBC'; ?>
-
claim_bid) ? 'Synchronizing' : ((float) ($claim->effective_amount / 100000000) . ' LBC'); ?>
+
effective_amount < $claim->claim_bid) ? 'Synchronizing' : ($effective_amount . ' LBC'); ?>
diff --git a/src/View/Helper/AmountHelper.php b/src/View/Helper/AmountHelper.php index e830421..75505b3 100644 --- a/src/View/Helper/AmountHelper.php +++ b/src/View/Helper/AmountHelper.php @@ -5,6 +5,8 @@ use Cake\View\Helper; class AmountHelper extends Helper { + const DEWIES_DIVIDER = 100000000; + public function format($value, $thousandsSeparator = ',') { $value = number_format($value, 8, '.', $thousandsSeparator); $dotIdx = strpos($value, '.'); @@ -20,6 +22,10 @@ public function format($value, $thousandsSeparator = ',') { return $value; } + + public function formatLbryCurrency($value, $thousandsSeparator = ",") { + return formatCurrency($value / DEWIES_DIVIDER); + } public function formatCurrency($value, $thousandsSeparator = ',') { $dotIdx = strpos($value, '.'); From 976436285524da67b54d8c631852b0e3c7f9e77c Mon Sep 17 00:00:00 2001 From: marcdeb1 Date: Sun, 10 Nov 2019 15:13:08 +0100 Subject: [PATCH 6/6] Added constants and new function for LBRY price display --- src/Controller/MainController.php | 4 ++-- src/View/Helper/AmountHelper.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Controller/MainController.php b/src/Controller/MainController.php index 59c8188..0df6abe 100644 --- a/src/Controller/MainController.php +++ b/src/Controller/MainController.php @@ -175,7 +175,7 @@ public function claims($id = null) { } if ($canConvert && $claim->fee > 0 && $claim->fee_currency == 'USD') { - $claim->price = $claim->fee / $priceInfo->price; + $claim->price = ($claim->fee / 100) / $priceInfo->price; } if (isset($claim->Stream)) { @@ -194,7 +194,7 @@ public function claims($id = null) { $moreClaims = $this->Claims->find()->select($this->Claims)->select(['publisher' => 'C.name'])->leftJoin(['C' => 'claim'], ['C.claim_id = Claims.publisher_id'])->where(['Claims.claim_type' => 1, 'Claims.id <>' => $claim->id, 'Claims.publisher_id' => isset($claim->publisher) ? $claim->publisher_id : $claim->claim_id])->limit(9)->order(['Claims.fee' => 'DESC', 'RAND()' => 'DESC'])->toArray(); for ($i = 0; $i < count($moreClaims); $i++) { if ($canConvert && $moreClaims[$i]->fee > 0 && $moreClaims[$i]->fee_currency == 'USD') { - $moreClaims[$i]->price = $moreClaims[$i]->fee / $priceInfo->price; + $moreClaims[$i]->price = ($moreClaims[$i]->fee / 100) / $priceInfo->price; } if (isset($moreClaims[$i]->Stream)) { diff --git a/src/View/Helper/AmountHelper.php b/src/View/Helper/AmountHelper.php index 75505b3..55df850 100644 --- a/src/View/Helper/AmountHelper.php +++ b/src/View/Helper/AmountHelper.php @@ -5,7 +5,7 @@ use Cake\View\Helper; class AmountHelper extends Helper { - const DEWIES_DIVIDER = 100000000; + const DECIMAL_DIVIDER = 100000000; public function format($value, $thousandsSeparator = ',') { $value = number_format($value, 8, '.', $thousandsSeparator); @@ -24,7 +24,7 @@ public function format($value, $thousandsSeparator = ',') { } public function formatLbryCurrency($value, $thousandsSeparator = ",") { - return formatCurrency($value / DEWIES_DIVIDER); + return $this->formatCurrency($value / AmountHelper::DECIMAL_DIVIDER); } public function formatCurrency($value, $thousandsSeparator = ',') {