Render token balances to Github comment image
This commit is contained in:
parent
5b639e1f20
commit
d6aae3fb5e
|
@ -11,7 +11,7 @@
|
|||
margin: 0px;
|
||||
padding: 1em;
|
||||
width: 1336px;
|
||||
height: 300px;
|
||||
height: {{ image-height }}px;
|
||||
}
|
||||
|
||||
.commiteth-logo {
|
||||
|
@ -34,11 +34,28 @@
|
|||
top: 196px;
|
||||
left: 32px;
|
||||
}
|
||||
.comment-balance {
|
||||
.comment-eth-balance {
|
||||
color: #343434;
|
||||
position: fixed;
|
||||
top: 196px;
|
||||
left: 135px;
|
||||
}
|
||||
|
||||
.token-list {
|
||||
position: fixed;
|
||||
top: 253px;
|
||||
left: 32px;
|
||||
}
|
||||
.comment-token {
|
||||
color: #a8aab1;
|
||||
display: inline;
|
||||
font-size: 48px;
|
||||
}
|
||||
.comment-token-balance {
|
||||
color: #343434;
|
||||
display:inline;
|
||||
font-size: 48px;
|
||||
left: 135px;
|
||||
}
|
||||
|
||||
.qr-image {
|
||||
|
@ -64,7 +81,12 @@
|
|||
<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAAXNSR0IArs4c6QAABT1JREFUaAXdWmtMHFUUPmcWZEVRYrDSyqNYozb+sSkxgsvysLawJfpDa1ob44/+Mjb+MDH6h/hKjMbExBKNMekPTdQmjYkvFpXIcxtNRekfY0RSnr4oMUDpspSdOZ47eLcg9+7OsrvDyE3g7px7znfPN3PuuY8ZgC1SMFs89g4OFl6YWawlojK0YLsFVMrgpYB0Vbb6EDhEjA4wDL78k1PNtSMSOyMiu77qK79sYisBtSJQExH4JXDua4z6DNo33tLwregrbyMdlofP7EKIv7gUhyMAliEwaCNAGdlQoUnwBkPUCJi0iJR/HdkBcbMNIH7MIsrPyI8sGHM47ZEwjolUdvaFrLj5EY+B66TxZtccyqPSBzss5IWurgj3PWta8LmXSKz4ii9Ln5MO9p09o35zceIkE3hUGjiuETkHwAIiLLBN1oYQg3LWwmEEbJ8MBT+R/i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xevdmsMcrH5AvIM6p9Kf9p1nWymWvdEpYb/n31ZuCJyebgp9ImKRGpJF6G8knLK4zvsWyFR6cO1n8o/HTk2ESo/jWfDx8Qp46SnDdqapN+OCIilMebgx2Q59vNZN5JltEksBs17z6rZD+OiQiDyf2B3ydD9U/wBxO7DcQP+D3R2tiXqC7VPJCGZFeOxohU/m/tpY9qMiKymljiMycTyvlLIf68ydrOK/+b3PrMabUv/+vf/wB8Edrv6oR/RwAAAABJRU5ErkJggg=="/>
|
||||
</div>
|
||||
<div class="comment-issue-url">{{issue-url}}</div>
|
||||
<div class="comment-eth">ETH<div class="comment-balance">{{balance}}</div></div>
|
||||
<div class="comment-eth">ETH<div class="comment-eth-balance">{{eth-balance}}</div></div>
|
||||
<div class="token-list">
|
||||
{% for token in tokens %}
|
||||
<div class="token-list-item"><div class="comment-token">{{ token.tla }}<div class="comment-token-balance"> {{ token.balance }}</div></div></div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<div class="qr-image">
|
||||
<img src="data:image/png;base64,{{qr-image}}"/>
|
||||
</div>
|
||||
|
|
|
@ -59,15 +59,16 @@
|
|||
(map (partial add-bounty-for-issue repo repo-id) bounty-issues))))
|
||||
|
||||
|
||||
(defn update-bounty-comment-image [issue-id owner repo issue-number contract-address balance balance-str]
|
||||
(let [hash (github/github-comment-hash owner repo issue-number balance)
|
||||
(defn update-bounty-comment-image [issue-id owner repo issue-number contract-address eth-balance eth-balance-str tokens]
|
||||
(let [hash (github/github-comment-hash owner repo issue-number eth-balance)
|
||||
issue-url (str owner "/" repo "/issues/" (str issue-number))
|
||||
png-data (png-rendering/gen-comment-image
|
||||
contract-address
|
||||
balance-str
|
||||
eth-balance-str
|
||||
tokens
|
||||
issue-url)]
|
||||
(log/debug "update-bounty-comment-image" issue-id owner repo issue-number)
|
||||
(log/debug contract-address balance-str)
|
||||
(log/debug contract-address eth-balance-str)
|
||||
(log/debug "hash" hash)
|
||||
|
||||
(if png-data
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
issue-number
|
||||
contract-address
|
||||
balance
|
||||
balance-str)
|
||||
balance-str
|
||||
{})
|
||||
(github/update-comment owner
|
||||
repo
|
||||
comment-id
|
||||
|
@ -227,7 +228,8 @@
|
|||
issue-number
|
||||
contract-address
|
||||
balance-eth
|
||||
balance-eth-str)
|
||||
balance-eth-str
|
||||
token-balances)
|
||||
(github/update-comment owner
|
||||
repo
|
||||
comment-id
|
||||
|
|
|
@ -25,13 +25,23 @@
|
|||
:size [255 255])))
|
||||
|
||||
|
||||
(defn gen-comment-image [address balance issue-url]
|
||||
(defn token-map->list [tokens]
|
||||
(mapv (fn [[tla balance]] {:tla (subs (str tla) 1)
|
||||
:balance balance})
|
||||
tokens))
|
||||
|
||||
(defn image-height [tokens]
|
||||
(+ 300 (* 32 (count (keys tokens)))))
|
||||
|
||||
(defn gen-comment-image [address balance-eth tokens issue-url]
|
||||
(let [qr-image (String. (image->base64 (generate-qr-image address))
|
||||
"ISO-8859-1")
|
||||
html (:body (render "bounty.html"
|
||||
{:qr-image qr-image
|
||||
:balance balance
|
||||
:address address
|
||||
{:qr-image qr-image
|
||||
:eth-balance balance-eth
|
||||
:tokens (token-map->list tokens)
|
||||
:image-height (image-height tokens)
|
||||
:address address
|
||||
:issue-url issue-url}))
|
||||
command (env :html2png-command "wkhtmltoimage")
|
||||
{out :out err :err exit :exit}
|
||||
|
|
Loading…
Reference in New Issue