mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
youtube acquisition refactor, support multiple campaign pages, support alternative domains, fix flashes on redirects
This commit is contained in:
parent
41aaa10790
commit
90eae9cbfc
12 changed files with 197 additions and 64 deletions
|
@ -98,7 +98,8 @@ class Controller
|
|||
$router->any('/dmca', 'ReportActions::executeDmca');
|
||||
|
||||
$router->any('/youtube/thanks', 'AcquisitionActions::executeThanks');
|
||||
$router->any('/youtube/sub', 'ReportActions::executeYoutubeSub');
|
||||
$router->any('/youtube/sub', 'AcquisitionActions::executeYouTubeSub');
|
||||
$router->any('/youtube/{campaignId:c}?', 'AcquisitionActions::executeYouTube');
|
||||
|
||||
$router->post('/set-culture', 'i18nActions::setCulture');
|
||||
|
||||
|
|
|
@ -74,6 +74,18 @@ class Request
|
|||
return static::getHttpHeader('User-Agent') ?? '';
|
||||
}
|
||||
|
||||
public static function getRoutingUri()
|
||||
{
|
||||
$host = preg_replace('/^www\./', '', $_SERVER['HTTP_HOST']);
|
||||
switch($host)
|
||||
{
|
||||
case 'betteryoutube.com':
|
||||
case 'lbrycreators.com':
|
||||
return '/youtube';
|
||||
}
|
||||
return static::getRelativeUri();
|
||||
}
|
||||
|
||||
public static function getHost(): string
|
||||
{
|
||||
// apparently trailing period is legal: http://www.dns-sd.org/TrailingDotsInDomainNames.html
|
||||
|
@ -95,6 +107,11 @@ class Request
|
|||
return static::getHeader('SERVER_NAME');
|
||||
}
|
||||
|
||||
public static function getReferrer(string $fallback = '/')
|
||||
{
|
||||
return Request::getHttpHeader('Referer', $fallback);
|
||||
}
|
||||
|
||||
public static function getRelativeUri(): string
|
||||
{
|
||||
return static::getHeader('REQUEST_URI') ? parse_url(static::getHeader('REQUEST_URI'), PHP_URL_PATH) : '';
|
||||
|
|
|
@ -6,4 +6,37 @@ class AcquisitionActions extends Actions
|
|||
{
|
||||
return ['acquisition/thanks'];
|
||||
}
|
||||
|
||||
|
||||
public static function executeYouTubeSub()
|
||||
{
|
||||
if (!Request::isPost())
|
||||
{
|
||||
return Controller::redirect('/youtube');
|
||||
}
|
||||
|
||||
$email = Request::getPostParam('email');
|
||||
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL))
|
||||
{
|
||||
Session::setFlash('error', 'Please enter a valid email.');
|
||||
return Controller::redirect('/youtube');
|
||||
}
|
||||
|
||||
Mailgun::sendYouTubeWarmLead(['email' => $email]);
|
||||
|
||||
Session::setFlash('success', 'Thanks! We\'ll be in touch. The good kind of touch.');
|
||||
|
||||
return Controller::redirect(Request::getReferrer(), 303);
|
||||
}
|
||||
|
||||
public static function executeYouTube(string $campaignId = '')
|
||||
{
|
||||
$template = 'acquisition/youtube' . ($campaignId ? '-' . $campaignId : '');
|
||||
if (!View::exists($template))
|
||||
{
|
||||
return NavActions::execute404();
|
||||
}
|
||||
return [$template];
|
||||
}
|
||||
}
|
|
@ -38,24 +38,4 @@ class ReportActions extends Actions
|
|||
|
||||
return ['report/dmca', ['errors' => $errors, 'values' => $values]];
|
||||
}
|
||||
|
||||
public static function executeYouTubeSub()
|
||||
{
|
||||
if (!Request::isPost())
|
||||
{
|
||||
return Controller::redirect('/youtube');
|
||||
}
|
||||
|
||||
$email = Request::getPostParam('email');
|
||||
|
||||
if (!filter_var($email, FILTER_VALIDATE_EMAIL))
|
||||
{
|
||||
Session::setFlash('error', 'Please enter a valid email.');
|
||||
return Controller::redirect('/youtube');
|
||||
}
|
||||
|
||||
Mailgun::sendYouTubeWarmLead(['email' => $email]);
|
||||
|
||||
return Controller::redirect(Request::getRelativeUri(), 303);
|
||||
}
|
||||
}
|
|
@ -24,6 +24,6 @@ class i18nActions extends Actions
|
|||
//if session changes update domain
|
||||
//english language = www
|
||||
|
||||
return Controller::redirect(Request::getHttpHeader('Referer', '/'));
|
||||
return Controller::redirect(Request::getReferrer());
|
||||
}
|
||||
}
|
||||
|
|
2
lib/thirdparty/Mailgun.class.php
vendored
2
lib/thirdparty/Mailgun.class.php
vendored
|
@ -50,7 +50,7 @@ class Mailgun
|
|||
{
|
||||
list($status, $headers, $body) = static::post('/' . static::MAIL_DOMAIN . '/messages', [
|
||||
'from' => 'LBRY <mail@' . static::MAIL_DOMAIN . '>',
|
||||
'to' => 'reilly@lbry.io',
|
||||
'to' => 'jeremy@lbry.io',
|
||||
'subject' => 'Interested YouTuber',
|
||||
'html' => '<pre>' . var_export($data, true) . '</pre>',
|
||||
'o:tracking-clicks' => 'no',
|
||||
|
|
95
view/template/acquisition/youtube.php
Normal file
95
view/template/acquisition/youtube.php
Normal file
|
@ -0,0 +1,95 @@
|
|||
<?php Response::setMetaDescription('description.publish') ?>
|
||||
<?php Response::setMetaTitle(__('YouTubers! Take back control.')) ?>
|
||||
<?php echo View::render('nav/_header', ['isDark' => true, 'isAbsolute' => true]) ?>
|
||||
<main >
|
||||
<?php //if you change the image, change it on download/_publish too! ?>
|
||||
<div class="cover cover-dark cover-center cover-full" style="padding-top: 80px; background-image: url('/img/youtube/tanks3.jpg')" >
|
||||
<div style="max-width: 700px; text-align: center">
|
||||
<?php echo View::render('nav/_flashes') ?>
|
||||
<h1 class="cover-title">
|
||||
YouTube Creator?<br/>
|
||||
Take Back Control.
|
||||
</h1>
|
||||
<div class="cover-subtitle" style="font-weight: bold">
|
||||
Join thousands of other creators in a world where your content is made available directly to your audience, free of censorship and corporate influence.
|
||||
</div>
|
||||
<div class="text-center spacer2">
|
||||
<a href="https://api.lbry.io/yt/connect" class="btn-alt">Let's Do This</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content content-light">
|
||||
<h2 class="spacer2" style="text-align: center">
|
||||
<img src="/img/lbry-dark-1600x528.png" style="max-height: 80px" alt="LBRY"/>
|
||||
</h2>
|
||||
<div class="column-fluid" >
|
||||
<?php foreach([
|
||||
'icon-group' => ['Community Run', 'Share (and optionally monetize) your content via a network powered entirely by users themselves.'],
|
||||
'icon-cubes' => ['Blockchain', 'The power of decentralized consensus allows your content to be discovered and accessed by anyone in the world -- on your terms.'],
|
||||
'icon-thumbs-up' => ['Take Control', 'Publish your content with whatever terms, price, and quality you desire. Update, re-release, and unpublish at any time.'],
|
||||
'icon-money' => ['Make More', 'You control whether your content is free or paid. If paid, you get 100% of the price.'],
|
||||
'icon-lock' => ['Secure', 'Made with encryption and love by dozens of bright contributors from MIT, CMU, RPI, Udacity, Dyn and more.'],
|
||||
'icon-code' => ['Open Source', 'Entirely open-source and permissively licensed (MIT). Maintained by stewards, not overlords.'],
|
||||
//Easy
|
||||
] as $iconClass => $copyTuple): ?>
|
||||
<?php list($title, $body) = $copyTuple ?>
|
||||
<div class="span4 spacer2">
|
||||
<div class="content content-light content-tile">
|
||||
<div class="text-center spacer-half">
|
||||
<div class="icon-in-circle">
|
||||
<span class="<?php echo $iconClass ?>"></span>
|
||||
</div>
|
||||
</div>
|
||||
<h3><?php echo $title ?></h3>
|
||||
<p>
|
||||
<?php echo $body ?>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="column-fluid" >
|
||||
<div class="span6" id="yes">
|
||||
<div class="cover cover-dark cover-dark-grad">
|
||||
<div class="content content-dark content-tile">
|
||||
<h3 class="cover-title cover-title-tile cover-title-flat">I'm in.</h3>
|
||||
<ol>
|
||||
<li>
|
||||
Clicking below will authenticate with YouTube and grant permission for your content to be available on the decentralized LBRY network.
|
||||
You may revoke this permission and unpublish* your content at any time.
|
||||
</li>
|
||||
<li>
|
||||
Our team will automate publishing your content to LBRY. When it's done, you'll receive a notification and a login to review, update, and manage it.
|
||||
</li>
|
||||
</ol>
|
||||
<div class="text-center spacer2">
|
||||
<a href="https://api.lbry.io/yt/connect" class="btn-alt">Let's Do This</a>
|
||||
</div>
|
||||
<div class="meta">*Unpublishing means removing the ability to decrypt and accessing your content via LBRY, but we cannot guarantee the deletion of all encrypted data.</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span6">
|
||||
<div class="cover cover-light-alt cover-light-alt-grad">
|
||||
<div class="content content-light content-tile">
|
||||
<h3 class="cover-title cover-title-tile cover-title-flat">I Have Questions</h3>
|
||||
<p>
|
||||
Schedule a meeting with Reilly, one of LBRY's founders and an experienced producer.
|
||||
Or, <a class="link-primary" href=mailto:reilly@lbry.io?subject=YouTube+Freedom">email him directly</a>.
|
||||
</p>
|
||||
<form action="/youtube/sub" method="POST" class="spacer2">
|
||||
<?php echo View::render('form/_formRow', [
|
||||
'field' => 'email',
|
||||
'type' => 'email',
|
||||
'label' => 'Email',
|
||||
'required' => true,
|
||||
]) ?>
|
||||
<input type="submit" value="Let's Talk" class="btn-primary">
|
||||
</form>
|
||||
<?php echo View::render('content/_bio', ['person' => 'reilly-smith-youtube', 'orientation' => 'horizontal']) ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
<?php echo View::render('nav/_footer') ?>
|
|
@ -51,7 +51,7 @@
|
|||
|
||||
<base target="_parent" />
|
||||
</head>
|
||||
<body>
|
||||
<body>
|
||||
<?php echo $content ?>
|
||||
<div class="hide">
|
||||
<div id="fb-root"></div>
|
||||
|
|
8
view/template/nav/_flashes.php
Normal file
8
view/template/nav/_flashes.php
Normal file
|
@ -0,0 +1,8 @@
|
|||
<?php $success = Session::getFlash('success') ?>
|
||||
<?php $error = Session::getFlash('error') ?>
|
||||
|
||||
<?php if ($error): ?>
|
||||
<div class="notice notice-error spacer1"><?php echo $error ?></div>
|
||||
<?php elseif ($success): ?>
|
||||
<div class="notice notice-success spacer1"><?php echo $success ?></div>
|
||||
<?php endif ?>
|
|
@ -9,49 +9,48 @@
|
|||
<h1>{{dmca.header}}</h1>
|
||||
<br>
|
||||
|
||||
<?php if ($notice = Session::getFlash('success')): ?>
|
||||
<div class="notice notice-success spacer1"><?php echo $notice ?></div>
|
||||
<?php else: ?>
|
||||
<form action="<?php echo Request::getRelativeUri() ?>" method="POST">
|
||||
<?php echo View::render('form/_formRow', [
|
||||
'field' => 'name',
|
||||
'value' => $values['name'] ?? null,
|
||||
'error' => $errors['name'] ?? null,
|
||||
'label' => __('dmca.form_labels.name'),
|
||||
'required' => true,
|
||||
]) ?>
|
||||
<?php echo View::render('nav/_flashes') ?>
|
||||
|
||||
<form action="<?php echo Request::getRelativeUri() ?>" method="POST">
|
||||
<?php echo View::render('form/_formRow', [
|
||||
'field' => 'name',
|
||||
'value' => $values['name'] ?? null,
|
||||
'error' => $errors['name'] ?? null,
|
||||
'label' => __('dmca.form_labels.name'),
|
||||
'required' => true,
|
||||
]) ?>
|
||||
|
||||
<?php echo View::render('form/_formRow', [
|
||||
'field' => 'rightsholder',
|
||||
'value' => $values['rightsholder'] ?? null,
|
||||
'error' => $errors['rightsholder'] ?? null,
|
||||
'label' => __('dmca.form_labels.rightsholder'),
|
||||
'help' => __('dmca.form_help.rightsholder'),
|
||||
'required' => true,
|
||||
]) ?>
|
||||
<?php echo View::render('form/_formRow', [
|
||||
'field' => 'rightsholder',
|
||||
'value' => $values['rightsholder'] ?? null,
|
||||
'error' => $errors['rightsholder'] ?? null,
|
||||
'label' => __('dmca.form_labels.rightsholder'),
|
||||
'help' => __('dmca.form_help.rightsholder'),
|
||||
'required' => true,
|
||||
]) ?>
|
||||
|
||||
<?php echo View::render('form/_formRow', [
|
||||
'field' => 'email',
|
||||
'type' => 'email',
|
||||
'value' => $values['email'] ?? null,
|
||||
'error' => $errors['email'] ?? null,
|
||||
'label' => __('dmca.form_labels.email'),
|
||||
'help' => __('dmca.form_help.email'),
|
||||
'required' => true,
|
||||
]) ?>
|
||||
<?php echo View::render('form/_formRow', [
|
||||
'field' => 'email',
|
||||
'type' => 'email',
|
||||
'value' => $values['email'] ?? null,
|
||||
'error' => $errors['email'] ?? null,
|
||||
'label' => __('dmca.form_labels.email'),
|
||||
'help' => __('dmca.form_help.email'),
|
||||
'required' => true,
|
||||
]) ?>
|
||||
|
||||
<?php echo View::render('form/_formRow', [
|
||||
'field' => 'identifier',
|
||||
'value' => $values['identifier'] ?? null,
|
||||
'error' => $errors['identifier'] ?? null,
|
||||
'label' => __('dmca.form_labels.identifier'),
|
||||
'help' => __('dmca.form_help.identifier'),
|
||||
'required' => true,
|
||||
]) ?>
|
||||
<?php echo View::render('form/_formRow', [
|
||||
'field' => 'identifier',
|
||||
'value' => $values['identifier'] ?? null,
|
||||
'error' => $errors['identifier'] ?? null,
|
||||
'label' => __('dmca.form_labels.identifier'),
|
||||
'help' => __('dmca.form_help.identifier'),
|
||||
'required' => true,
|
||||
]) ?>
|
||||
|
||||
<input type="submit" value="{{dmca.form_submit}}" class="btn-primary">
|
||||
</form>
|
||||
|
||||
<input type="submit" value="{{dmca.form_submit}}" class="btn-primary">
|
||||
</form>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -31,7 +31,7 @@ try
|
|||
{
|
||||
View::compileCss();
|
||||
}
|
||||
Controller::dispatch(Request::getRelativeUri());
|
||||
Controller::dispatch(Request::getRoutingUri());
|
||||
}
|
||||
catch(Throwable $e)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue