mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
Update youtube onboarding with new changes
This commit is contained in:
parent
4ce772d680
commit
75700e0b76
9 changed files with 114 additions and 80 deletions
|
@ -122,6 +122,7 @@ class Controller
|
|||
$router->any('/youtube/thanks', 'AcquisitionActions::executeThanks');
|
||||
$router->any('/youtube/sub', 'AcquisitionActions::executeYouTubeSub');
|
||||
$router->any('/youtube', 'AcquisitionActions::executeYT2');
|
||||
$router->post('/youtube/edit', 'AcquisitionActions::executeYoutubeEdit');
|
||||
$router->post('/youtube/token', 'AcquisitionActions::executeYoutubeToken');
|
||||
$router->any('/youtube/status/{token}', 'AcquisitionActions::executeYoutubeStatus');
|
||||
$router->get('/verify/{token}', 'AcquisitionActions::executeVerify');
|
||||
|
|
|
@ -57,28 +57,21 @@ class AcquisitionActions extends Actions
|
|||
return ['acquisition/youtube_status', ['token' => $token]];
|
||||
}
|
||||
|
||||
public static function actionYoutubeToken(string $email, string $desired_lbry_channel_name, string $youtube_channel_id)
|
||||
public static function actionYoutubeToken(string $desired_lbry_channel_name)
|
||||
{
|
||||
|
||||
$email_is_valid = static::email_verification($email);
|
||||
$desired_lbry_channel_name_is_valid = static::lbry_channel_verification($desired_lbry_channel_name);
|
||||
$youtube_channel_id_is_valid = static::youtube_channel_verification($youtube_channel_id);
|
||||
var_dump($desired_lbry_channel_name);
|
||||
var_dump($desired_lbry_channel_name_is_valid);
|
||||
|
||||
//if ($desired_lbry_channel_name_is_valid) {
|
||||
$token = LBRY::connectYoutube($desired_lbry_channel_name);
|
||||
var_dump($token);
|
||||
//}
|
||||
}
|
||||
|
||||
if ($email_is_valid && $desired_lbry_channel_name_is_valid && $youtube_channel_id_is_valid) {
|
||||
$token = LBRY::newYoutube($email, $youtube_channel_id, $desired_lbry_channel_name);
|
||||
|
||||
if ($token['error'] === null) {
|
||||
$url = "/youtube/status/" . $token['data']['status_token'];
|
||||
Controller::redirect($url);
|
||||
} else {
|
||||
$url = "/yt2?error=true&error_message=" . $token['error'];
|
||||
Controller::redirect($url);
|
||||
}
|
||||
} else {
|
||||
$url = "/yt2?error=true";
|
||||
Controller::redirect($url);
|
||||
}
|
||||
public static function executeYoutubeEdit(){
|
||||
return ['acquisition/youtube_edit'];
|
||||
}
|
||||
|
||||
protected static function email_verification($email)
|
||||
|
|
9
lib/thirdparty/LBRY.class.php
vendored
9
lib/thirdparty/LBRY.class.php
vendored
|
@ -36,6 +36,11 @@ class LBRY
|
|||
return Curl::post(static::getApiUrl('/yt/new'), ['email' => $email, 'youtube_channel_id' => $channel_id,'desired_lbry_channel_name' => $channel_name], ['json_response' => true]);
|
||||
}
|
||||
|
||||
public static function connectYoutube($channel_name)
|
||||
{
|
||||
$type = 'sync';
|
||||
return Curl::post(static::getApiUrl('/yt/connect'), ['desired_lbry_channel_name' => $channel_name, 'type' => $type], ['json_response' => true]);
|
||||
}
|
||||
// Check the sync status
|
||||
public static function statusYoutube($status_token)
|
||||
{
|
||||
|
@ -45,4 +50,8 @@ class LBRY
|
|||
public static function youtubeReward(){
|
||||
return CurlWithCache::post(static::getApiUrl('/yt/rewards'),[], ['cache' => 3600, 'json_response' => true ]);
|
||||
}
|
||||
|
||||
public static function editYouTube($status_token, $channel_name, $email, $sync_consent){
|
||||
return Curl::post(static::getApiUrl("/yt/update"),['status_token' => $status_token, 'new_email' => $email, 'new_preferred_channel' => $channel_name, 'sync_consent' => $sync_consent], ['json_response' => true]);
|
||||
}
|
||||
}
|
||||
|
|
10
view/template/acquisition/youtube_edit.php
Normal file
10
view/template/acquisition/youtube_edit.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
$status_token = $_POST['status_token'];
|
||||
$channel_name = $_POST['new_preferred_channel'];
|
||||
$email = $_POST['new_email'];
|
||||
$sync_consent = isset($_POST['sync_consent']);
|
||||
|
||||
LBRY::editYouTube($status_token, $channel_name, $email, $sync_consent);
|
||||
|
||||
|
||||
Controller::redirect("/youtube/status/" . $status_token);
|
|
@ -1,10 +1,16 @@
|
|||
<?php Response::setMetaDescription('YouTuber? Take back control! LBRY allows publication on your terms. It\'s open-source, decentralized, and gives you 100% of the profit.') ?>
|
||||
<?php Response::setMetaTitle(__('YouTubers! Take back control.')) ?>
|
||||
<?php echo View::render('nav/_header', ['isDark' => false]) ?>
|
||||
|
||||
<?php Response::addJsAsset('/js/yt2/FormValidation.js')?>
|
||||
<main>
|
||||
<?php $status= LBRY::statusYoutube($token);?>
|
||||
<form action="yt/update?status_token=<?php echo $token?>" method="post">
|
||||
<form id="youtube_settings" action="/youtube/edit" method="post">
|
||||
<div>
|
||||
<input type="hidden" name="status_token" id="status_token" value="<?php echo $token?>"/>
|
||||
</div>
|
||||
<div hidden id="channel-name-error" style="text-align: center;">
|
||||
Channel is invalid or blank
|
||||
</div>
|
||||
<div style="text-align: center;">
|
||||
<label for="channel-name">LBRY channel name:</label>
|
||||
<input type="text" id="channel-name" style="display: block; margin : 0 auto;"
|
||||
|
@ -12,38 +18,37 @@
|
|||
value="<?php echo $status['data']['lbry_channel_name'];?>"
|
||||
>
|
||||
</div>
|
||||
<div hidden id="email-error" style="text-align: center;">
|
||||
Email is invalid or blank
|
||||
</div>
|
||||
<div style="text-align: center;">
|
||||
LBRY channel name:
|
||||
Email:
|
||||
<input type="text" id="email" style="display: block; margin : 0 auto;"
|
||||
name="new_email" placeholder="bill@gmail.com"
|
||||
value="<?php echo $status['data']['email'];?>"
|
||||
>
|
||||
</div>
|
||||
<div style="text-align: center;">
|
||||
<label for="sync-consent">Youtube Sync status:</label>
|
||||
<select name="sync_consent" id="sync-consent" style="display: block; margin : 0 auto;">
|
||||
<option value="false" <?php echo $status['data']['status']=='pending'?'selected="selected"':'';?>>
|
||||
Don't sync yet
|
||||
</option>
|
||||
<option value="true" <?php echo $status['data']['status']=='queued'?'selected="selected"':'';?>>
|
||||
Sync my channel
|
||||
</option>
|
||||
<option value="syncing" <?php echo $status['data']['status']=='syncing'?'selected="selected"':'';?>
|
||||
disabled="disabled">
|
||||
Being synced
|
||||
</option>
|
||||
<option value="synced" <?php echo $status['data']['status']=='synced'?'selected="selected"':'';?>
|
||||
disabled="disabled">
|
||||
Syncing completed
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div style="text-align: center;">
|
||||
Expected Reward:
|
||||
<?php echo $status['data']['expected_reward'];?> LBC
|
||||
</div>
|
||||
<div style="text-align: center;">
|
||||
<button type="submit" class="btn btn-default">Edit my preferences</button>
|
||||
Number Of Subscriber:
|
||||
<?php echo $status['data']['subscribers']?>
|
||||
</div>
|
||||
<div style="text-align: center;">
|
||||
Number Of Video:
|
||||
<?php echo $status['data']['videos']?>
|
||||
</div>
|
||||
<div hidden id="sync-consent-error" style="text-align: center;" >
|
||||
You must agreed to sync to continue
|
||||
</div>
|
||||
<div style="text-align: center;">
|
||||
<input name="sync_consent" id="sync-consent" type="checkbox"> I want to sync my content to the LBRY network and agree to the "terms"
|
||||
</div>
|
||||
<div style="text-align: center;">
|
||||
<button type="submit" class="btn btn-default" onClick="return submitEditForm()">Edit my preferences</button>
|
||||
</div>
|
||||
</form>
|
||||
</main>
|
|
@ -1,3 +1,8 @@
|
|||
<?php
|
||||
AcquisitionActions::actionYoutubeToken($_POST['email_address'], $_POST['desired_lbry_channel_name'], $_POST['youtube_channel_url']);
|
||||
$desired_lbry_channel_name = $_POST['desired_lbry_channel_name'];
|
||||
|
||||
if(!preg_match("/([@][1-z]+)/", $desired_lbry_channel_name)){
|
||||
$desired_lbry_channel_name = "@" . $desired_lbry_channel_name;
|
||||
}
|
||||
AcquisitionActions::actionYoutubeToken($desired_lbry_channel_name);
|
||||
?>
|
||||
|
|
|
@ -4,6 +4,7 @@ Response::addJsAsset('/js/yt2/TweenMax.min.js');
|
|||
Response::addJsAsset('/js/yt2/ScrollToPlugin.min.js');
|
||||
Response::addJsAsset('/js/yt2/app.js');
|
||||
Response::addJsAsset('/js/yt2/FormValidation.js');
|
||||
Response::addJsAsset('/js/yt2/SyncStatus.js');
|
||||
$reward = LBRY::youtubeReward();
|
||||
?>
|
||||
<main>
|
||||
|
@ -59,21 +60,16 @@ $reward = LBRY::youtubeReward();
|
|||
endif;?>
|
||||
<div class="zigzag"></div>
|
||||
<h1>Own your identity. For real this time.</h1>
|
||||
<div hidden id="sync-status">
|
||||
|
||||
</div>
|
||||
<form id="youtube_claim" method="post" action="/youtube/token">
|
||||
<div class="form-inner" >
|
||||
<div class="block" hidden id="lbry_error">LBRY channel name is not valid or blank</div>
|
||||
<div class="block">
|
||||
<input id="lbry_channel_name" type="text" name="desired_lbry_channel_name" placeholder="Desired LBRY channel name" />
|
||||
<label>@</label>
|
||||
</div>
|
||||
<div class="block" hidden id="email_error">Email is not valid or blank</div>
|
||||
<div class="block">
|
||||
<input hidden id="email" type="text" name="email_address" placeholder="Your Email" />
|
||||
</div>
|
||||
<div class="block" hidden id="youtube_url_error">Youtube id is not valid or blank</div>
|
||||
<div class="block">
|
||||
<input hidden id="youtube_url" type="text" name="youtube_channel_url" placeholder="Your Channel ID" />
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<div class="block">
|
||||
<input type="submit" value="Claim now" onClick="return submitDetailsForm()"/>
|
||||
|
|
|
@ -1,15 +1,46 @@
|
|||
function submitEditForm(){
|
||||
$("#youtube_settings").submit(function (event) {
|
||||
|
||||
// get value from id
|
||||
var lbry_channel_name = $.trim($('#channel-name').val());
|
||||
var email = $.trim($('#email').val());
|
||||
|
||||
// Hide the error message
|
||||
$('#channel-name-error').hide();
|
||||
$('#email-error').hide();
|
||||
|
||||
// If the channel name is invalid or blank stop the post request
|
||||
if(!validateLBRYName(lbry_channel_name) || lbry_channel_name === ''){
|
||||
$('#lbry_channel_name').addClass('error_form');
|
||||
$('#channel-name-error').show();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
if(!validateEmail(email) || email === ''){
|
||||
$('#email').addClass('error_form');
|
||||
$('#email-error').show();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
// If the checkbox is not check stop the post request
|
||||
if(!$('#sync-consent').prop('checked')){
|
||||
$('#sync-consent').addClass('error_form');
|
||||
$('#sync-consent-error').show();
|
||||
event.preventDefault();
|
||||
}
|
||||
localStorage.setItem("status_token", $.trim($('#status_token').val()));
|
||||
localStorage.setItem("lbry_channel_name_sync", $.trim($('#channel-name').val()));
|
||||
});
|
||||
}
|
||||
|
||||
function submitDetailsForm() {
|
||||
$("#youtube_claim").submit(function (event) {
|
||||
|
||||
// get value from id
|
||||
var lbry_channel_name = $.trim($('#lbry_channel_name').val());
|
||||
var email = $.trim($('#email').val());
|
||||
var youtube_url = $.trim($('#youtube_url').val());
|
||||
|
||||
// Make sure that the error message are hidden before trying to validate value
|
||||
$('#lbry_error').hide();
|
||||
$('#email_error').hide();
|
||||
$('#youtube_url_error').hide();
|
||||
|
||||
// If the lbry name is invalid or blank stop the post request
|
||||
if(!validateLBRYName(lbry_channel_name) || lbry_channel_name === '') {
|
||||
|
@ -17,32 +48,6 @@ function submitDetailsForm() {
|
|||
$('#lbry_error').show();
|
||||
event.preventDefault();
|
||||
}
|
||||
// Show the other field if the LBRY channel name field is validated once
|
||||
else{
|
||||
// Check only if the two fields
|
||||
if ($('#email').is(":visible") && $('#youtube_url').is(":visible")) {
|
||||
// If the email is invalid or blank stop the post request
|
||||
if (!validateEmail(email) || email === '') {
|
||||
$('#email').addClass('error_form');
|
||||
$('#email_error').show();
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
// If the youtube url is invalid or blank stop the post request
|
||||
if (!validateYoutubeChannelUrl(youtube_url) || youtube_url === '') {
|
||||
$('#youtube_url').addClass('error_form');
|
||||
$('#youtube_url_error').show();
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
else{
|
||||
event.preventDefault();
|
||||
}
|
||||
$('#youtube_url').show();
|
||||
$('#email').show();
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
|
10
web/js/yt2/SyncStatus.js
Normal file
10
web/js/yt2/SyncStatus.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
$(document).ready(function () {
|
||||
var status_token = localStorage.getItem("status_token");
|
||||
var lbry_channel_name_sync = localStorage.getItem("lbry_channel_name_sync");
|
||||
|
||||
if (status_token || lbry_channel_name_sync){
|
||||
var url = "/youtube/status/" + status_token;
|
||||
$("#sync-status").show();
|
||||
$("#sync-status").html("To see the sync status of channel: " +lbry_channel_name_sync + " " + "Please" + ' <a href=' +"'" + url + "'" + '>Click Here </a>');
|
||||
}
|
||||
});
|
Loading…
Add table
Reference in a new issue