Cleanup of LBRY api calls

This commit is contained in:
maximest-pierre 2018-03-20 23:29:45 -04:00
parent e0b0d0e96b
commit 8d93b03f50
4 changed files with 29 additions and 9 deletions

View file

@ -114,4 +114,14 @@ class AcquisitionActions extends Actions
return false; return false;
} }
} }
public static function actionGetLBRYReward()
{
return LBRY::youtubeReward();
}
public static function actionGetYoutubeStatus($status_token)
{
return LBRY::statusYoutube($status_token);
}
} }

View file

@ -6,7 +6,7 @@ Response::addJsAsset('/js/yt2/app.js');
Response::addJsAsset('/js/yt2/FormValidation.js'); Response::addJsAsset('/js/yt2/FormValidation.js');
Response::addJsAsset('/js/yt2/SyncStatus.js'); Response::addJsAsset('/js/yt2/SyncStatus.js');
Response::addJsAsset('/js/yt2/youtube_video.js'); Response::addJsAsset('/js/yt2/youtube_video.js');
$reward = LBRY::youtubeReward(); $reward = AcquisitionActions::actionGetLBRYReward();
Response::setMetaTitle("LBRY YouTube Partner Program"); Response::setMetaTitle("LBRY YouTube Partner Program");
Response::setMetaDescription("Put your content on the blockchain, experience true content freedom, and earn rewards."); Response::setMetaDescription("Put your content on the blockchain, experience true content freedom, and earn rewards.");
?> ?>
@ -44,7 +44,7 @@ Response::setMetaDescription("Put your content on the blockchain, experience tru
<div class="content"> <div class="content">
<?php <?php
if (isset($_GET['error'])): echo "<div>" . "The following error occurred: ". $_GET['error_message'] . " For support please send an email to hello@lbry.io" . "</div>"; if (isset($_GET['error']) && $_GET['error_message']): echo "<div>" . "The following error occurred: ". $_GET['error_message'] . " For support please send an email to hello@lbry.io" . "</div>";
endif;?> endif;?>
<div class="zigzag"></div> <div class="zigzag"></div>
<h1>Create on a stable platform. For real this time.</h1> <h1>Create on a stable platform. For real this time.</h1>
@ -139,13 +139,23 @@ Response::setMetaDescription("Put your content on the blockchain, experience tru
<div class="zigzag"></div> <div class="zigzag"></div>
<h1>Sync &amp; Earn</h1> <h1>Sync &amp; Earn</h1>
<p>LBRY offers a single-click sync process<br>for existing YouTubers</p> <p>LBRY offers a single-click sync process<br>for existing YouTubers</p>
<form id="sync" method="get" action="/123"> <form class="form" id="sync" method="post" action="http://api.lbry.io/yt/connect">
<input hidden name="type" value="sync"/> <div class="form-inner">
<div class="block">
<input type="text" hidden name="type" value="sync"/>
</div>
<div class="block">
<input name="immediate_sync" type="checkbox" value="true"/>I want to sync my content. <input name="immediate_sync" type="checkbox" value="true"/>I want to sync my content.
<div class="button"> </div>
<input type="submit"/> Sync now <div class="block">
<input type="submit" value="Sync Now"/>
</div>
</div> </div>
</form> </form>
<div class="meta"> <div class="meta">
By syncing, you agree to mirror your content to the LBRY network for 1 year, and acknowledge <a href="/faq/youtube-terms">these terms</a>. By syncing, you agree to mirror your content to the LBRY network for 1 year, and acknowledge <a href="/faq/youtube-terms">these terms</a>.
</div> </div>

View file

@ -4,7 +4,7 @@ $channel_name = $_POST['new_preferred_channel'];
$email = $_POST['new_email']; $email = $_POST['new_email'];
$sync_consent = isset($_POST['sync_consent']); $sync_consent = isset($_POST['sync_consent']);
$current_value = LBRY::statusYoutube($status_token); $current_value = AcquisitionActions::actionGetYoutubeStatus($status_token);
if(!preg_match("/@[A-Za-z0-9_-]+$/", $channel_name)){ if(!preg_match("/@[A-Za-z0-9_-]+$/", $channel_name)){
$channel_name = "@" . $channel_name; $channel_name = "@" . $channel_name;

View file

@ -4,7 +4,7 @@
<?php Response::addJsAsset('/js/yt2/FormValidation.js')?> <?php Response::addJsAsset('/js/yt2/FormValidation.js')?>
<?php Response::addJsAsset('/js/yt2/youtube_status.js') ?> <?php Response::addJsAsset('/js/yt2/youtube_status.js') ?>
<?php Response::addJsAsset('/js/yt2/youtube_video.js')?> <?php Response::addJsAsset('/js/yt2/youtube_video.js')?>
<?php $statusResponse = LBRY::statusYoutube($token); ?> <?php $statusResponse = AcquisitionActions::actionGetYoutubeStatus($token) ?>
<?php $statusData = $statusResponse['data'] ?> <?php $statusData = $statusResponse['data'] ?>
<?php $isSyncAgreed = false ?> <?php $isSyncAgreed = false ?>
<?php $isRewardClaimed = $statusData['is_reward_claimed'] ?? false ?> <?php $isRewardClaimed = $statusData['is_reward_claimed'] ?? false ?>
@ -79,7 +79,7 @@
<input type="hidden" name="status_token" id="status_token" value="<?php echo $token?>"/> <input type="hidden" name="status_token" id="status_token" value="<?php echo $token?>"/>
</div> </div>
<?php <?php
if (isset($_GET['error'])): echo "<div>" . "The following error occurred: ". $_GET['error_message'] . " For support please send an email to hello@lbry.io" . "</div>"; if (isset($_GET['error']) && isset($_GET['error_message'])): echo "<div>" . "The following error occurred: ". $_GET['error_message'] . " For support please send an email to hello@lbry.io" . "</div>";
endif;?> endif;?>
<div class="block"> <div class="block">
<label for="channel-name">LBRY Channel ID</label> <label for="channel-name">LBRY Channel ID</label>