Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Claim metadata #62

Closed
wants to merge 6 commits into from
Closed
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
6 changes: 3 additions & 3 deletions src/Controller/MainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ 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('/');
}

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)) {
Expand All @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Template/Element/claimbox.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 22 additions & 6 deletions src/Template/Main/claims.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +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 = $this->Amount->formatCurrency($claim->fee) . ' LBC';
$cost = $this->Amount->formatLbryCurrency($claim->fee) . ' LBC';
}
$effective_amount = $this->Amount->formatLbryCurrency($claim->effective_amount);

$desc = $claim->description;
if (strlen(trim($desc)) == 0) {
Expand All @@ -66,6 +67,10 @@ if (strlen(trim($desc)) == 0) {

<div class="claims-body">
<div class="claim-info">
<div class="tags">
<div class="bid-state"><?php echo $claim->bid_state; ?></div>
</div>

<div data-autothumb="<?php echo $autoThumbText ?>" class="thumbnail <?php echo $a[mt_rand(0, count($a) - 1)] ?>">
<?php if (!$claim->is_nsfw && strlen(trim($claim->thumbnail_url)) > 0): ?>
<img src="<?php echo htmlspecialchars($claim->thumbnail_url) ?>" alt="" />
Expand Down Expand Up @@ -101,6 +106,17 @@ if (strlen(trim($desc)) == 0) {

<div class="clear"></div>
<?php endif; ?>

<div class="half-width"><div class="label help-text" title="The quantity of tokens used to back the stake.">Claim bid</div></div>
<div class="half-width"><div class="label help-text" title="The sum of the claim bid and all of its active supports.">Effective amount</div></div>

<div class="value half-width"><?php echo (float) ($claim->claim_bid) . ' LBC'; ?></div>
<div class="value half-width"><?php echo ($claim->effective_amount < $claim->claim_bid) ? '<em>Synchronizing</em>' : ($effective_amount . ' LBC'); ?></div>

<div class="clear"></div>

<div class="label help-text" title="A unique identifier that is used to locate and fetch the content from the data network.">Stream hash</div>
<div class="value"><?php echo $claim->sd_hash ?></div>
</div>
</div>

Expand All @@ -113,26 +129,26 @@ if (strlen(trim($desc)) == 0) {
<div class="desc"><?php echo str_replace("\n", '<br />', $desc) ?></div>

<div class="details">
<div class="label half-width">Author</div>
<div class="label half-width">Content Type</div>
<div class="label half-width">Language</div>


<div class="value half-width"><?php echo strlen(trim($claim->author)) > 0 ? $claim->author : '<em>Unspecified</em>' ?></div>
<div class="value half-width"><?php echo strlen(trim($claim->content_type)) > 0 ? $claim->content_type : '<em>Unspecified</em>' ?></div>
<div class="value half-width"><?php echo strlen(trim($claim->language)) > 0 ? ($claim->language == 'en' ? 'English' : '') : '<em>Unspecified</em>' ?></div>

<!--
<div class="label half-width">License</div>
-->

<div class="label">Language</div>
-->

<!--
<div class="value half-width"<?php if(strlen(trim($claim->license)) > 0): ?> title="<?php echo $claim->license ?>"<?php endif; ?>>
<?php if (strlen(trim($claim->license_url)) > 0): ?><a href="<?php echo $claim->LicenseUrl ?>" rel="nofollow" target="_blank"><?php endif; ?>
<?php echo strlen(trim($claim->License)) > 0 ? $claim->License : '<em>Unspecified</em>' ?>
<?php if (strlen(trim($claim->LicenseUrl))): ?></a><?php endif; ?>
</div>
-->
<div class="value half-width"><?php echo strlen(trim($claim->language)) > 0 ? ($claim->language == 'en' ? 'English' : '') : '<em>Unspecified</em>' ?></div>
-->
</div>
<?php endif; ?>
<a href="<?php echo $claim->getLbryLink() ?>" class="open-lbry-link">Open in LBRY</a>
Expand Down
12 changes: 10 additions & 2 deletions src/Template/Main/tx.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,23 @@
</div>

<div class="tx-time">
<?php
$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;
}
?>
<div class="created-time">
<h3 title="Represents the time this transaction was created on the explorer">Time Created</h3>
<div><?php echo $tx->created_at->format('j M Y H:i:s') . ' UTC '; ?></div>
<div><?php echo $created_time->format('j M Y H:i:s') . ' UTC '; ?></div>
</div>

<div class="conf-time">
<h3 title="The time the first confirmation of this transaction happened on the blockchain">Block Time</h3>
<div><?php echo ($tx->transaction_time == null || strlen(trim($tx->transaction_time)) == 0) ? '<em>Not yet confirmed</em>' :
\DateTime::createFromFormat('U', $tx->transaction_time)->format('j M Y H:i:s') . ' UTC' ?>
$transaction_time->format('j M Y H:i:s') . ' UTC' ?>

<?php if ($tx->transaction_time > $tx->created_at->getTimestamp()):
$diffSeconds = $tx->transaction_time - $tx->created_at->getTimestamp();
Expand Down
6 changes: 6 additions & 0 deletions src/View/Helper/AmountHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
use Cake\View\Helper;

class AmountHelper extends Helper {
const DECIMAL_DIVIDER = 100000000;

public function format($value, $thousandsSeparator = ',') {
$value = number_format($value, 8, '.', $thousandsSeparator);
$dotIdx = strpos($value, '.');
Expand All @@ -20,6 +22,10 @@ public function format($value, $thousandsSeparator = ',') {

return $value;
}

public function formatLbryCurrency($value, $thousandsSeparator = ",") {
return $this->formatCurrency($value / AmountHelper::DECIMAL_DIVIDER);
}

public function formatCurrency($value, $thousandsSeparator = ',') {
$dotIdx = strpos($value, '.');
Expand Down
11 changes: 6 additions & 5 deletions webroot/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand All @@ -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 }
Expand All @@ -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 }
Expand Down