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 4 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
2 changes: 1 addition & 1 deletion src/Controller/MainController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('/');
}
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 = (float) ($claim->fee) . ' LBC';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we treating currency as a float? What was wrong with formatCurrency?

}
$effective_amount = $claim->effective_amount / 100000000;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we create a const instead so the number makes sense?


$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 ($effective_amount < $claim->claim_bid) ? '<em>Synchronizing</em>' : ((float) ($claim->effective_amount / 100000000) . ' LBC'); ?></div>
tiger5226 marked this conversation as resolved.
Show resolved Hide resolved

<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
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