Fix regex whitespace

This commit is contained in:
maximest-pierre 2018-03-21 16:13:47 -04:00
parent 2c30c33861
commit 09bd310037
8 changed files with 28 additions and 49 deletions

View file

@ -30,7 +30,10 @@ class AcquisitionActions extends Actions
public static function executeYouTube() public static function executeYouTube()
{ {
return ['acquisition/youtube']; return ['acquisition/youtube', [
'reward' => LBRY::youtubeReward(),
'error_message' => $_GET['error_message'] ?? null
]];
} }
public static function executeVerify(string $token) public static function executeVerify(string $token)
@ -45,7 +48,11 @@ class AcquisitionActions extends Actions
public static function executeYoutubeStatus(string $token) public static function executeYoutubeStatus(string $token)
{ {
return ['acquisition/youtube_status', ['token' => $token]]; return ['acquisition/youtube_status', [
'token' => $token,
'status_token' => LBRY::statusYoutube($token),
'error_message' => $_GET['error_message'] ?? null
]];
} }
public static function actionYoutubeToken(string $desired_lbry_channel_name) public static function actionYoutubeToken(string $desired_lbry_channel_name)
@ -66,8 +73,9 @@ class AcquisitionActions extends Actions
} }
} }
public static function actionYoutubeEdit($status_token, $channel_name, $email, $sync_consent, $current_value) public static function actionYoutubeEdit($status_token, $channel_name, $email, $sync_consent)
{ {
$current_value = LBRY::statusYoutube($status_token);
if($current_value['data']['email'] == $email) if($current_value['data']['email'] == $email)
{ {
$status = LBRY::editYoutube($status_token, $channel_name, null, $sync_consent); $status = LBRY::editYoutube($status_token, $channel_name, null, $sync_consent);
@ -114,14 +122,4 @@ 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

@ -142,8 +142,8 @@ class View
$all_css = $scssCompiler->compile(file_get_contents(self::SCSS_DIR . '/all.scss')); $all_css = $scssCompiler->compile(file_get_contents(self::SCSS_DIR . '/all.scss'));
file_put_contents(self::CSS_DIR . '/all.css', $all_css); file_put_contents(self::CSS_DIR . '/all.css', $all_css);
$yt2_css = $scssCompiler->compile(file_get_contents(self::SCSS_DIR . '/yt2.scss')); $youtube_css = $scssCompiler->compile(file_get_contents(self::SCSS_DIR . '/youtube.scss'));
file_put_contents(self::CSS_DIR . '/yt2.css', $yt2_css); file_put_contents(self::CSS_DIR . '/youtube.css', $youtube_css);
} }
public static function gzipAssets() public static function gzipAssets()

View file

@ -1,12 +1,11 @@
<?php <?php
Response::setCssAssets(['/css/yt2.css']); Response::setCssAssets(['/css/youtube.css']);
Response::addJsAsset('/js/yt2/TweenMax.min.js'); Response::addJsAsset('/js/yt2/TweenMax.min.js');
Response::addJsAsset('/js/yt2/ScrollToPlugin.min.js'); Response::addJsAsset('/js/yt2/ScrollToPlugin.min.js');
Response::addJsAsset('/js/yt2/app.js'); 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 = 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.");
?> ?>
@ -77,7 +76,7 @@ Response::setMetaDescription("Put your content on the blockchain, experience tru
<div class="boxes"> <div class="boxes">
<div class="box"> <div class="box">
<div class="image" target="_blank"> <div class="image" target="_blank">
<div id="play-video1" class="to-play" onclick="playVideo1()"><span></span></div> <div id="play-video1" class="to-play" onclick="playVideo('video1')"><span></span></div>
<video id="video1" width="100%" poster="/img/youtube/01@2x.jpg" src="https://spee.ch/1ac47b8b3def40a25850dc726a09ce23d09e7009/ever-wonder-how-bitcoin-and-other.mp4" style="cursor: pointer" onclick="this.paused ? this.play() : this.pause();"/></video> <video id="video1" width="100%" poster="/img/youtube/01@2x.jpg" src="https://spee.ch/1ac47b8b3def40a25850dc726a09ce23d09e7009/ever-wonder-how-bitcoin-and-other.mp4" style="cursor: pointer" onclick="this.paused ? this.play() : this.pause();"/></video>
</div> </div>
@ -87,7 +86,7 @@ Response::setMetaDescription("Put your content on the blockchain, experience tru
</div> </div>
<div class="box"> <div class="box">
<div class="image" target="_blank"> <div class="image" target="_blank">
<div id="play-video2" class="to-play" onclick="playVideo2()"><span></span></div> <div id="play-video2" class="to-play" onclick="playVideo('video2')"><span></span></div>
<video id="video2" width="100%" poster="/img/youtube/02@2x.jpg" src="https://spee.ch/3c96f32de285db6c04e80bd6f5fad573250541e9/casually-successful.mp4" style="cursor: pointer" onclick="this.paused ? this.play() : this.pause();" /></video> <video id="video2" width="100%" poster="/img/youtube/02@2x.jpg" src="https://spee.ch/3c96f32de285db6c04e80bd6f5fad573250541e9/casually-successful.mp4" style="cursor: pointer" onclick="this.paused ? this.play() : this.pause();" /></video>
</div> </div>
@ -97,7 +96,7 @@ Response::setMetaDescription("Put your content on the blockchain, experience tru
</div> </div>
<div class="box"> <div class="box">
<div class="image" target="_blank"> <div class="image" target="_blank">
<div id="play-video3" class="to-play" onclick="playVideo3()"><span></span></div> <div id="play-video3" class="to-play" onclick="playVideo('video3')"><span></span></div>
<video id="video3" width="100%" poster="/img/youtube/03@2x.jpg" src="https://spee.ch/8958c5d573d71f5c2d0c1bfdf752737ce39744cb/the-historical-elements-of-wolfenstein.mp4" style="cursor: pointer" onclick="this.paused ? this.play() : this.pause();"></video> <video id="video3" width="100%" poster="/img/youtube/03@2x.jpg" src="https://spee.ch/8958c5d573d71f5c2d0c1bfdf752737ce39744cb/the-historical-elements-of-wolfenstein.mp4" style="cursor: pointer" onclick="this.paused ? this.play() : this.pause();"></video>
</div> </div>
<div class="text"> <div class="text">

View file

@ -4,10 +4,10 @@ $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 = 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;
} }
AcquisitionActions::actionYoutubeEdit($status_token, $channel_name, $email, $sync_consent, $current_value); AcquisitionActions::actionYoutubeEdit($status_token, $channel_name, $email, $sync_consent);

View file

@ -1,11 +1,10 @@
<?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::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 Response::setMetaTitle(__('YouTubers! Take back control.')) ?>
<?php Response::setCssAssets(['/css/yt2.css']) ?> <?php Response::setCssAssets(['/css/youtube.css']) ?>
<?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 = AcquisitionActions::actionGetYoutubeStatus($token) ?> <?php $statusData = $status_token['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 ?>
<main class="channel-settings"> <main class="channel-settings">
@ -79,7 +78,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']) && isset($_GET['error_message'])): echo "<div>" . "The following error occurred: ". $_GET['error_message'] . " For support please send an email to hello@lbry.io" . "</div>"; if ($error_message): echo "<div>" . "The following error occurred: ". $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>

View file

@ -63,7 +63,7 @@ function validateEmail(email) {
} }
function validateLBRYName(lbry_channel_name){ function validateLBRYName(lbry_channel_name){
var re = /[@A-Za-z0-9_-]+$/; var re = /^[@A-Za-z0-9_-]*$/g;
return re.test(lbry_channel_name); return re.test(lbry_channel_name);
} }

View file

@ -1,25 +1,8 @@
function playVideo1(){ function playVideo(id){
var myVideo = document.getElementById("video1"); var myVideo = document.getElementById(id);
myVideo.play(); myVideo.play();
$('#video1').prop("controls", true); $('#' + id).prop("controls", true);
$('#play-video1').hide(); $('#play-' + id).hide();
} }
function playVideo2(){
var myVideo = document.getElementById("video2");
myVideo.play();
$('#video2').prop("controls", true);
$('#play-video2').hide();
}
function playVideo3() {
var myVideo = document.getElementById("video3");
myVideo.play();
$('#video3').prop("controls", true);
$('#play-video3').hide();
}