Own your identity. For real this time.
-1,000
-250
+
10,000
-1,000
+
100,000
-2,500
+
1,000,000
-7,000
+
diff --git a/controller/Controller.class.php b/controller/Controller.class.php
index 82865cca..f4cba28d 100644
--- a/controller/Controller.class.php
+++ b/controller/Controller.class.php
@@ -121,8 +121,9 @@ class Controller
$router->any('/youtube/thanks', 'AcquisitionActions::executeThanks');
$router->any('/youtube/sub', 'AcquisitionActions::executeYouTubeSub');
- $router->any('/youtube/{campaignId:c}?', 'AcquisitionActions::executeYouTube');
- $router->any('/yt2', 'AcquisitionActions::executeYT2');
+ $router->any('/youtube', 'AcquisitionActions::executeYT2');
+ $router->post('/youtube/token', 'AcquisitionActions::executeYoutubeToken');
+ $router->any('/youtube/status/{token}', 'AcquisitionActions::executeYoutubeStatus');
$router->get('/verify/{token}', 'AcquisitionActions::executeVerify');
$router->get('/news/category/{category}', 'ContentActions::executePostCategoryFilter');
diff --git a/controller/action/AcquisitionActions.class.php b/controller/action/AcquisitionActions.class.php
index 422be407..403832e8 100644
--- a/controller/action/AcquisitionActions.class.php
+++ b/controller/action/AcquisitionActions.class.php
@@ -9,15 +9,13 @@ class AcquisitionActions extends Actions
public static function executeYouTubeSub()
{
- if (!Request::isPost())
- {
+ if (!Request::isPost()) {
return Controller::redirect('/youtube');
}
$email = Request::getPostParam('email');
- if (!filter_var($email, FILTER_VALIDATE_EMAIL))
- {
+ if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
Session::setFlash('error', 'Please enter a valid email.');
return Controller::redirect('/youtube');
}
@@ -33,8 +31,7 @@ class AcquisitionActions extends Actions
public static function executeYouTube(string $campaignId = '')
{
$template = 'acquisition/youtube' . ($campaignId ? '-' . $campaignId : '');
- if (!View::exists($template))
- {
+ if (!View::exists($template)) {
return NavActions::execute404();
}
return [$template];
@@ -42,7 +39,7 @@ class AcquisitionActions extends Actions
public static function executeYT2()
{
- return ['acquisition/yt2', ['_no_layout' => true]];
+ return ['acquisition/yt2'];
}
public static function executeVerify(string $token)
@@ -50,5 +47,64 @@ class AcquisitionActions extends Actions
return ['acquisition/verify', ['token' => $token]];
}
+ public static function executeYoutubeToken()
+ {
+ return ['acquisition/youtube_token', ['_no_layout' => true]];
+ }
+ public static function executeYoutubeStatus(string $token)
+ {
+ return ['acquisition/youtube_status', ['token' => $token]];
+ }
+
+ public static function actionYoutubeToken(string $email, string $desired_lbry_channel_name, string $youtube_channel_id)
+ {
+
+ $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);
+
+
+ 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);
+ }
+ }
+
+ protected static function email_verification($email)
+ {
+ if (preg_match('/\S+@\S+\.\S+/', $email)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ protected static function youtube_channel_verification($youtube_channel_id)
+ {
+ if (preg_match('/^UC[A-Za-z0-9_-]{22}$/', $youtube_channel_id)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ protected static function lbry_channel_verification($lbry_channel)
+ {
+ if (preg_match('/[1-z]+/', $lbry_channel)) {
+ return true;
+ } else {
+ return false;
+ }
+ }
}
diff --git a/lib/thirdparty/LBRY.class.php b/lib/thirdparty/LBRY.class.php
index a3d1325d..255de6a1 100644
--- a/lib/thirdparty/LBRY.class.php
+++ b/lib/thirdparty/LBRY.class.php
@@ -29,4 +29,20 @@ class LBRY
{
return Curl::post(static::getApiUrl('/list/unsubscribe'), ['email' => $email], ['json_response' => true]);
}
+
+ // Register new youtube sync
+ public static function newYoutube($email, $channel_id, $channel_name)
+ {
+ return Curl::post(static::getApiUrl('/yt/new'), ['email' => $email, 'youtube_channel_id' => $channel_id,'desired_lbry_channel_name' => $channel_name], ['json_response' => true]);
+ }
+
+ // Check the sync status
+ public static function statusYoutube($status_token)
+ {
+ return Curl::post(static::getApiUrl('/yt/status'), ['status_token' => $status_token], ['json_response' => true]);
+ }
+
+ public static function youtubeReward(){
+ return CurlWithCache::post(static::getApiUrl('/yt/rewards'),[], ['cache' => 3600, 'json_response' => true ]);
+ }
}
diff --git a/view/Response.class.php b/view/Response.class.php
index 0a5ef721..1862f6c1 100644
--- a/view/Response.class.php
+++ b/view/Response.class.php
@@ -24,7 +24,7 @@ class Response
'/js/jquery-2.1.3.min.js',
'/js/global.js'
],
- 'css' => []
+ 'css' => ['/css/all.css']
],
$headers = [],
$headersSent = false,
@@ -106,11 +106,24 @@ class Response
static::$assets['js'][$src] = $src;
}
+ public static function addCssAsset($src)
+ {
+ static::$assets['css'][$src] = $src;
+ }
+
public static function getJsAssets()
{
return static::$assets['js'];
}
+ public static function getCssAssets()
+ {
+ return static::$assets['css'];
+ }
+
+ public static function setCssAssets(array $assets = []){
+ static::$assets['css'] = $assets;
+ }
public static function setGzipResponseContent($gzip = true)
{
static::$gzipResponseContent = $gzip;
diff --git a/view/template/acquisition/youtube_status.php b/view/template/acquisition/youtube_status.php
new file mode 100644
index 00000000..46f6ec01
--- /dev/null
+++ b/view/template/acquisition/youtube_status.php
@@ -0,0 +1,18 @@
+
+
+ false]) ?>
+ 1,000 250
10,000 1,000
100,000 2,500 1,000,000 7,000 Own your identity. For real this time.
-
{{page.badmethod_details}}
- \ No newline at end of file + diff --git a/view/template/page/join-us.php b/view/template/page/join-us.php index ccf39232..0def0d6e 100644 --- a/view/template/page/join-us.php +++ b/view/template/page/join-us.php @@ -176,7 +176,7 @@ Interested in contributing but not ready for commitment? We have a guide for contributors to help you find other ways to get involved. If none of that suits your fancy, join our Discord chat and we'll help you find something you'll love. - + diff --git a/view/template/page/what.php b/view/template/page/what.php index 76134473..37576e5f 100644 --- a/view/template/page/what.php +++ b/view/template/page/what.php @@ -96,7 +96,7 @@Here is a sample key-value entry in the LBRY blockchain. Here, wonderfullife is the key, and the rest of the description is the value.
$lbrynet-cli resolve_name name=wonderfullife
-
+
wonderfullife : {
title: "It’s a Wonderful Life",
description: "An angel helps a compassionate but despairingly frustrated businessman by showing what life would have been like if he never existed.",
@@ -311,7 +311,7 @@
Content Distribution
Digital content distributors with server-client models are subject to the whims of internet service providers and hostile foreign governments. Traffic from the host servers can be throttled or halted altogether if the owners of cables and routers so choose. However, in case of the LBRY protocol content comes from anywhere and everywhere, and is therefore not so easily stifled.
- Additionally, the market mechanisms of LBRY create a strong incentive for efficient distribution, which will save the costs of producers and ISPs alike. These properties, along with LBRY’s infringement
+
Additionally, the market mechanisms of LBRY create a strong incentive for efficient distribution, which will save the costs of producers and ISPs alike. These properties, along with LBRY’s infringement
disincentivizing properties, make LBRY an appealing technology for large existing data or content distributors.
Transaction Settlement
While payments can be issued directly on the LBRY blockchain, the LBRY protocol encourages a volume of transactions that will not scale without usage of off-chain settlement.
diff --git a/view/template/report/dmca.php b/view/template/report/dmca.php
index 6011fc01..a90bea20 100644
--- a/view/template/report/dmca.php
+++ b/view/template/report/dmca.php
@@ -56,4 +56,4 @@
- $learnFooter ?? false]) ?>
\ No newline at end of file
+ $learnFooter ?? false]) ?>
diff --git a/web/css/yt2.css b/web/css/yt2.css
index 054e78df..14567c87 100644
--- a/web/css/yt2.css
+++ b/web/css/yt2.css
@@ -315,6 +315,8 @@ header .right a.github {
.claim .block {
position: relative;
float: left;
+ margin-top: 10px;
+
}
.claim input {
float: left;
@@ -344,6 +346,11 @@ header .right a.github {
-moz-box-shadow: 0 0 10px 0 rgba(0,0,0,0.15);
box-shadow: 0 0 10px 0 rgba(0,0,0,0.15);
}
+.error_form{
+ -webkit-box-shadow:inset 0px 0px 0px 2px red;
+ -moz-box-shadow:inset 0px 0px 0px 2px red;
+ box-shadow:inset 0px 0px 0px 2px red;
+}
.claim label {
position: absolute;
top: 0;
@@ -1116,4 +1123,4 @@ header .right a.github {
.how .step.three .text {
width: 90%;
}
-}
\ No newline at end of file
+}
diff --git a/web/js/yt2/FormValidation.js b/web/js/yt2/FormValidation.js
new file mode 100644
index 00000000..0ab700d9
--- /dev/null
+++ b/web/js/yt2/FormValidation.js
@@ -0,0 +1,62 @@
+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 === '') {
+ $('#lbry_channel_name').addClass('error_form');
+ $('#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();
+ }
+
+
+ });
+}
+
+function validateEmail(email) {
+ var re = /\S+@\S+\.\S+/;
+ return re.test(email);
+}
+
+function validateLBRYName(lbry_channel_name){
+ var re = /[1-z]+/;
+ return re.test(lbry_channel_name);
+}
+
+function validateYoutubeChannelUrl(youtube_channel_url){
+ var re = /^UC[A-Za-z0-9_-]{22}$/;
+ return re.test(youtube_channel_url)
+}
\ No newline at end of file