2018-07-16 23:06:37 +02:00
"use strict" ;
// P A C K A G E
const fs = require ( "graceful-fs" ) ;
const html = require ( "choo-async/html" ) ;
const raw = require ( "nanohtml/raw" ) ;
// E X P O R T
module . exports = exports = ( ) => async ( ) => html `
< div class = "hook" id = "hook" >
< nav class = "hook__navigation" id = "hook-navigation" >
< div class = "inner-wrap" > <!-- / TODO: Save tutorial position to localStorage / -- >
2018-07-25 00:29:25 +02:00
< button class = "hook__navigation__step" data - action = "tour, step 1" type = "button" >
2018-07-16 23:06:37 +02:00
< span class = "number" > 1 < / s p a n >
Resolve a claim
2018-07-25 00:29:25 +02:00
< / b u t t o n >
2018-07-16 23:06:37 +02:00
2018-07-25 00:29:25 +02:00
< button class = "hook__navigation__step" data - action = "tour, step 2" type = "button" >
2018-07-16 23:06:37 +02:00
< span class = "number" > 2 < / s p a n >
Publish content
2018-07-25 00:29:25 +02:00
< / b u t t o n >
2018-07-16 23:06:37 +02:00
2018-07-25 00:29:25 +02:00
< button class = "hook__navigation__step" data - action = "tour, step 3" type = "button" >
2018-07-16 23:06:37 +02:00
< span class = "number" > 3 < / s p a n >
Support with LBC
2018-07-25 00:29:25 +02:00
< / b u t t o n >
2018-07-16 23:06:37 +02:00
< / d i v >
< / n a v >
$ { step1 ( ) }
$ { step2 ( ) }
$ { step3 ( ) }
< / d i v >
< script > $ { raw ( fs . readFileSync ( "./views/partials/tour-scripts.js" , "utf-8" ) ) } < / s c r i p t >
` ;
function step1 ( ) {
/ * *
Step 1 loading steps :
- exampleCode !== ""
< pre > < code class = "bash" > < span v - html = "highlight('bash', exampleCode)" > < / s p a n > < / c o d e > < / p r e >
- isLoading
< div class = "loader" > < / d i v >
- jsonData
< p style = "text-align: center;" > Success ! Here is the response for < strong > lbry : //{{ address }}</strong>:</p>
< pre > < code class = "json" > < span v - html = "highlight('json', jsonData)" > < / s p a n > < / c o d e > < / p r e >
< a href = "#" class = "__button-black" data - action = "go to step 2" title = "Proceed to step two" > Go to next step < / a >
- TODO :
2018-07-18 22:31:05 +02:00
[ ✓ ] Create message for error
[ ] Scroll to top of page when selecting a claim
2018-07-16 23:06:37 +02:00
* /
return html `
< section class = "hook__page" id = "step1-page" >
< header class = "hook__page__hero" >
< div class = "inner-wrap" >
< h1 > Learn the LBRY protocol by examples < / h 1 >
< p > Let ' s start by getting the associated metadata for a claim . < / p >
< div class = "hook__page__hero__claim" >
2018-07-25 00:29:25 +02:00
< span > lbry : //</span><input id="fetch-claim-uri" placeholder=" Claim URI goes here" type="text"/>
< button class = "button" data - action = "execute claim" type = "button" > Execute < / b u t t o n >
2018-07-16 23:06:37 +02:00
< / d i v >
< / d i v >
< / h e a d e r >
< div class = "hook__page__content inner-wrap" id = "step1-placeholder" > < / d i v >
2018-07-18 22:31:05 +02:00
< div class = "hook__page__content inner-wrap" id = "step1-selections" >
2018-07-16 23:06:37 +02:00
< p style = "text-align: center;" > & hellip ; or select a live example from below < / p >
< div class = "hook__page__content__card" >
2018-07-25 00:29:25 +02:00
< img data - action = "choose claim" data - claim - id = "itsadisaster" src = "https://spee.ch/0654f2e2322ccfefa02a956d252df9ac7611d8b0/placeholder-itsadisaster.jpeg" >
2018-07-16 23:06:37 +02:00
< div data - action = "choose claim" data - claim - id = "itsadisaster" >
< h4 > It ' s a Disaster < / h 4 >
< p class = "account" > Anonymous < / p >
< / d i v >
< / d i v >
< div class = "hook__page__content__card" >
2018-07-25 00:29:25 +02:00
< img data - action = "choose claim" data - claim - id = "unbubbled1-1" src = "https://spee.ch/b1bd330e048fc22dc7bf941c33dd8245eef492c1/unbubbled.png" >
2018-07-16 23:06:37 +02:00
< div data - action = "choose claim" data - claim - id = "unbubbled1-1" >
< h4 > Unbubbled with Jamie King , Ep1 . 1 & mdash ; Bitcoin , Boom or Bust < / h 4 >
< p class = "account" > @ Unbubbled < / p >
< / d i v >
< / d i v >
< div class = "hook__page__content__card" >
2018-07-25 00:29:25 +02:00
< img data - action = "choose claim" data - claim - id = "fortnite-top-stream-moments-nickatnyte" src = "https://spee.ch/9880947df41af880bc19724ceddd1cce957a07e2/placeholder-fortninte.jpeg" >
2018-07-16 23:06:37 +02:00
< div data - action = "choose claim" data - claim - id = "fortnite-top-stream-moments-nickatnyte" >
< h4 > FORTNITE TOP STREAM MOMENTS & mdash ; Nickatnyte & amp ; GamingwithMolt < / h 4 >
< p class = "account" > @ nickatnyte < / p >
< / d i v >
< / d i v >
< div class = "hook__page__content__card" >
2018-07-25 00:29:25 +02:00
< img data - action = "choose claim" data - claim - id = "six" src = "https://spee.ch/a3b8258478ad88954f42f6ac3427eab380720f60/placeholder-lbrymine.png" >
2018-07-16 23:06:37 +02:00
< div data - action = "choose claim" data - claim - id = "six" >
< h4 > LBRY Coin ( LBC ) GPU Miner for AMD and NVIDIA < / h 4 >
< p class = "account" > Anonymous < / p >
< / d i v >
< / d i v >
< / d i v >
< / s e c t i o n >
` ;
}
function step2 ( ) {
/ * *
Step 2 loading steps :
2018-07-23 23:46:58 +02:00
- exampleCode !== ''
< pre style = "clear: both;" > < code class = "bash" > < span v - html = "highlight('bash', exampleCode)" > < / s p a n > < / c o d e > < / p r e >
- isLoading
< div class = "loader" > < / d i v >
- jsonData
< p style = "text-align: center;" > Success ! < br / >
< a class = "__button-black" v - bind : href = "'http://explorer.lbry.io/tx/'+txid" > See the transaction on explorer . lbry . io < / a >
< / p >
< p style = "text-align: center;" > Here is the raw response : < / p >
< pre > < code class = "json" > < span v - html = "highlight('json', jsonData)" > < / s p a n > < / c o d e > < / p r e >
2018-07-25 00:29:25 +02:00
Meme submission process :
- ` PUT ` request to ` http://daemon.lbry.tech/images.php ` :
- headers : "Content-Type" : "text/plain"
- qs : access _token : process . env . LBRY _DAEMON _ACCESS _TOKEN
- body : document . getElementById ( "meme-canvas" ) . toDataURL ( "image/jpeg" , 0.6 )
- response should be parsed as JSON
- //
- socket emit "fetch metadata" :
- bid : 0.001 , // hard-coded on the back-end
- description : component . description ,
- file _path : uploadResponse . body . filename ,
- language : component . language ,
- license : component . license ,
- method : "publish" ,
- name : component . title ,
- nsfw : component . nsfw ,
- title : component . title
- socket emit error from back - end if any field is missing
2018-07-23 23:46:58 +02:00
Process after submitting meme :
- isLoading appears
- exampleCode and jsonData replace ` #step2-placeholder ` contents
- next button should exist
Issues :
- image isn ' t uploaded to spee . ch
- response is blank
- response should have link to upload on Blockchain Explorer
- NSFW flag should work
2018-07-16 23:06:37 +02:00
* /
const images = [
{
2018-07-25 00:29:25 +02:00
alt : "Carl Sagan" ,
src : "/assets/media/images/carlsagan2.jpg"
2018-07-16 23:06:37 +02:00
} ,
{
2018-07-25 00:29:25 +02:00
alt : "Doge" ,
src : "/assets/media/images/doge-meme.jpg"
2018-07-16 23:06:37 +02:00
} ,
{
2018-07-25 00:29:25 +02:00
alt : "LBRY Logo With Green Background" ,
src : "/assets/media/images/lbry-green.png"
2018-07-16 23:06:37 +02:00
}
] ;
2018-07-23 23:46:58 +02:00
const memePlaceholderData = {
bottomLine : {
placeholder : "Top line" ,
value : "that I made"
} ,
description : {
placeholder : "Description" ,
value : "Check out this image I published to LBRY via lbry.tech"
} ,
topLine : {
placeholder : "Top line" ,
value : "This is an example meme"
} ,
title : {
placeholder : "Title" ,
value : "Dank Meme Supreme da Cheese"
}
} ;
2018-07-16 23:06:37 +02:00
const renderedImages = [ ] ;
for ( const image of images ) {
2018-07-25 00:29:25 +02:00
renderedImages . push ( ` <img alt=" ${ image . alt } " class="hook__page__content__meme__thumbnail" src=" ${ image . src } "/> ` ) ;
2018-07-16 23:06:37 +02:00
}
return html `
2018-07-25 00:29:25 +02:00
< section class = "hook__page" id = "step2-page" style = "display: none;" >
2018-07-16 23:06:37 +02:00
< header class = "hook__page__hero" >
< div class = "inner-wrap" >
< h1 > Publish your content on the blockchain < / h 1 >
2018-07-25 00:29:25 +02:00
< p > Upload an image to the blockchain and you are able to view it on the < a href = "http://explorer.lbry.io" rel = "noopener noreferrer" target = "_blank" title = "LBRY Blockchain Explorer" > LBRY Blockchain Explorer < / a > . < / p >
2018-07-16 23:06:37 +02:00
< / d i v >
< / h e a d e r >
< div class = "hook__page__content inner-wrap" >
2018-07-23 23:46:58 +02:00
< div class = "hook__page__content__meme left" >
2018-07-25 00:29:25 +02:00
< img alt = "Base image for LBRY meme creator" id = "base-image" style = "height: 0; visibility: hidden;" / >
< canvas id = "meme-canvas" height = "300" width = "400" > Unfortunately , it looks like canvas is < strong > not supported < / s t r o n g > i n y o u r b r o w s e r < / c a n v a s >
2018-07-16 23:06:37 +02:00
2018-07-23 23:46:58 +02:00
$ { renderedImages }
2018-07-16 23:06:37 +02:00
< / d i v >
2018-07-23 23:46:58 +02:00
2018-07-25 00:29:25 +02:00
< form class = "hook__page__content__meme right" >
2018-07-23 23:46:58 +02:00
< h2 > Image Text < / h 2 >
< fieldset >
< label for = "meme-top-line" > Top line < / l a b e l >
2018-07-25 00:29:25 +02:00
< input id = "meme-top-line" name = "meme-top-line" placeholder = "${memePlaceholderData.topLine.placeholder}" spellcheck = "false" type = "text" value = "${memePlaceholderData.topLine.value}" required / >
2018-07-23 23:46:58 +02:00
< / f i e l d s e t >
< fieldset >
< label for = "meme-bottom-line" > Bottom line < / l a b e l >
2018-07-25 00:29:25 +02:00
< input id = "meme-bottom-line" name = "meme-bottom-line" placeholder = "${memePlaceholderData.bottomLine.placeholder}" spellcheck = "false" type = "text" value = "${memePlaceholderData.bottomLine.value}" required / >
2018-07-23 23:46:58 +02:00
< / f i e l d s e t >
< h2 class = "__metadata" > Metadata < / h 2 >
< fieldset >
< label for = "meme-title" > Title < / l a b e l >
2018-07-25 00:29:25 +02:00
< input id = "meme-title" name = "meme-title" placeholder = "${memePlaceholderData.title.placeholder}" spellcheck = "false" type = "text" value = "${memePlaceholderData.title.value}" required / >
2018-07-23 23:46:58 +02:00
< / f i e l d s e t >
< fieldset >
< label for = "meme-description" > Description < / l a b e l >
2018-07-25 00:29:25 +02:00
< textarea id = "meme-description" name = "meme-description" placeholder = "${memePlaceholderData.description.placeholder}" spellcheck = "false" type = "text" required > $ { memePlaceholderData . description . value } < / t e x t a r e a >
2018-07-23 23:46:58 +02:00
< / f i e l d s e t >
< fieldset >
< label for = "meme-language" > Language < / l a b e l >
2018-07-25 00:29:25 +02:00
< select id = "meme-language" name = "meme-language" >
2018-07-23 23:46:58 +02:00
< option value = "ar" > Arabic < / o p t i o n >
< option value = "zh" > Chinese ( Mandarin ) < / o p t i o n >
< option value = "en" > English < / o p t i o n >
< option value = "fr" > French < / o p t i o n >
< option value = "de" > German < / o p t i o n >
< option value = "it" > Italian < / o p t i o n >
< option value = "jp" > Japanese < / o p t i o n >
< option value = "ru" > Russian < / o p t i o n >
< option value = "es" > Spanish < / o p t i o n >
< option value = "" > Not specified < / o p t i o n >
< / s e l e c t >
< / f i e l d s e t >
< fieldset >
< label for = "meme-license" > License < / l a b e l >
2018-07-25 00:29:25 +02:00
< select id = "meme-license" name = "meme-license" required >
2018-07-23 23:46:58 +02:00
< option value = "Public Domain" > Public Domain < / o p t i o n >
< option value = "Creative Commons Attribution 4.0 International" > Creative Commons Attribution 4.0 International < / o p t i o n >
< option value = "Creative Commons Attribution-ShareAlike 4.0 International" > Creative Commons Attribution - ShareAlike 4.0 International < / o p t i o n >
< option value = "Creative Commons Attribution-NoDerivatives 4.0 International" > Creative Commons Attribution - NoDerivatives 4.0 International < / o p t i o n >
< option value = "Creative Commons Attribution-NonCommercial 4.0 International" > Creative Commons Attribution - NonCommercial 4.0 International < / o p t i o n >
< option value = "Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International" > Creative Commons Attribution - NonCommercial - ShareAlike 4.0 International < / o p t i o n >
< option value = "Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International" > Creative Commons Attribution - NonCommercial - NoDerivatives 4.0 International < / o p t i o n >
< option value = "None" > None < / o p t i o n >
< / s e l e c t >
< / f i e l d s e t >
< fieldset >
2018-07-25 00:29:25 +02:00
< label > < input id = "meme-nsfw-flag" name = "nsfw" type = "checkbox" / > NSFW < / l a b e l >
2018-07-23 23:46:58 +02:00
< / f i e l d s e t >
< fieldset >
2018-07-25 00:29:25 +02:00
< button data - action = "upload image" class = "__button-black" type = "button" > Submit < / b u t t o n >
2018-07-23 23:46:58 +02:00
< / f i e l d s e t >
< / f o r m >
2018-07-16 23:06:37 +02:00
< / d i v >
2018-07-23 23:46:58 +02:00
< div class = "hook__page__content inner-wrap" id = "step2-placeholder" > < / d i v >
2018-07-16 23:06:37 +02:00
< / s e c t i o n >
` ;
}
function step3 ( ) {
2018-07-25 21:44:02 +02:00
/ * *
2018-07-25 22:42:29 +02:00
Step 3 loading steps :
2018-07-25 21:44:02 +02:00
- exampleCode !== ''
< pre > < code class = "bash" > < span v - html = "highlight('bash', exampleCode)" > < / s p a n > < / c o d e > < / p r e >
- isLoading
< div class = "loader" > < / d i v >
- jsonData
< p style = "text-align: center;" > Success ! Here is the response : < / p >
< pre > < code class = "json" > < span v - html = "highlight('json', jsonData)" > < / s p a n > < / c o d e > < / p r e >
* /
return html `
< section class = "hook__page" id = "step3-page" style = "display: none;" >
< header class = "hook__page__hero" >
< div class = "inner-wrap" >
< h1 > Support your favorite content creators with LBRY < / h 1 >
< p > Send LBRY coins to claim addresses and the owner will receive it in their wallet . < / p >
< p > To send LBC to someone , you need either their wallet address or claim ID . You can get claim IDs by using the resolve method in < a href = "#" v - on : click . prevent . stop = "goTo(1)" title = "Go back to step one" > the first step < / a > , o r y o u c a n u s e t h e e x a m p l e s b e l o w . < / p >
< div class = "hook__page__hero__support" >
< input type = "text" v - model = "claimId" placeholder = "Claim ID goes here" / >
< input type = "number" v - model = "amount" disabled title = "You can set this value to any amount of LBC in your wallet, but for demonstration purposes we have hardcoded it to 0.01" / > < span > LBC < / s p a n >
< a href = "#" v - on : click . prevent = "send" class = "button" title = "Execute claim" > Execute < / a >
< / d i v >
< / d i v >
< / h e a d e r >
< div class = "hook__page__content inner-wrap" id = "step3-placeholder" > < / d i v >
< div class = "hook__page__content inner-wrap" id = "step3-selections" >
< p style = "text-align: center;" > Click on any of the claims below to support them ! < / p >
< div class = "hook__page__content__card" > <!-- / fbdcd44a97810522d23d5f1335b8ca04be9d776c / -- >
< img data - action = "choose claim" data - claim - id = "itsadisaster" src = "https://spee.ch/0654f2e2322ccfefa02a956d252df9ac7611d8b0/placeholder-itsadisaster.jpeg" >
< div data - action = "choose claim" data - claim - id = "itsadisaster" >
< h4 > It ' s a Disaster < / h 4 >
< p class = "account" > Anonymous < / p >
< / d i v >
< / d i v >
< div class = "hook__page__content__card" > <!-- / de7f7fa33e8d879b2bae7238d2bdf827a39f9301 / -- >
< img data - action = "choose claim" data - claim - id = "unbubbled1-1" src = "https://spee.ch/b1bd330e048fc22dc7bf941c33dd8245eef492c1/unbubbled.png" >
< div data - action = "choose claim" data - claim - id = "unbubbled1-1" >
< h4 > Unbubbled with Jamie King , Ep1 . 1 & mdash ; Bitcoin , Boom or Bust < / h 4 >
< p class = "account" > @ Unbubbled < / p >
< / d i v >
< / d i v >
< div class = "hook__page__content__card" > <!-- / 5b7c7a202201033d99e1be2930d290c127c0f4fe / -- >
< img data - action = "choose claim" data - claim - id = "fortnite-top-stream-moments-nickatnyte" src = "https://spee.ch/9880947df41af880bc19724ceddd1cce957a07e2/placeholder-fortninte.jpeg" >
< div data - action = "choose claim" data - claim - id = "fortnite-top-stream-moments-nickatnyte" >
< h4 > FORTNITE TOP STREAM MOMENTS & mdash ; Nickatnyte & amp ; GamingwithMolt < / h 4 >
< p class = "account" > @ nickatnyte < / p >
< / d i v >
< / d i v >
< div class = "hook__page__content__card" > <!-- / a1372cf5523885f5923237bfe522f02f5f054362 / -- >
< img data - action = "choose claim" data - claim - id = "six" src = "https://spee.ch/a3b8258478ad88954f42f6ac3427eab380720f60/placeholder-lbrymine.png" >
< div data - action = "choose claim" data - claim - id = "six" >
< h4 > LBRY Coin ( LBC ) GPU Miner for AMD and NVIDIA < / h 4 >
< p class = "account" > Anonymous < / p >
< / d i v >
< / d i v >
< / d i v >
< / s e c t i o n >
` ;
2018-07-16 23:06:37 +02:00
}