From de2def240a17a934a57925b20cac8f3a29471a3c Mon Sep 17 00:00:00 2001 From: Jeremy Kauffman Date: Fri, 28 Jul 2017 20:45:52 -0400 Subject: [PATCH] website changes for open beta, drop prefinery/referrals --- controller/Session.class.php | 2 - controller/action/DownloadActions.class.php | 109 +---------- data/i18n/en.yaml | 16 +- lib/thirdparty/Prefinery.class.php | 189 -------------------- lib/tools/OS.class.php | 2 +- view/template/developer/_quickstartApi.php | 6 +- view/template/download/_betaNotice.php | 4 - view/template/download/_linux.php | 6 +- view/template/download/_osx.php | 4 +- view/template/download/_publish.php | 5 - view/template/download/_refer.php | 42 ----- view/template/download/_signup.php | 60 +------ view/template/download/_unavailable.php | 3 - view/template/download/_videoIntro.php | 2 +- view/template/download/_windows.php | 4 +- view/template/download/get.php | 34 ++-- view/template/download/getAllowed.php | 38 ---- view/template/page/home.php | 4 +- view/template/page/learn.php | 31 ++-- view/template/social/_listDev.php | 3 + web/js/global.js | 34 ++-- web/scss/_basic.scss | 6 + 22 files changed, 90 insertions(+), 514 deletions(-) delete mode 100644 lib/thirdparty/Prefinery.class.php delete mode 100644 view/template/download/_betaNotice.php delete mode 100644 view/template/download/_publish.php delete mode 100644 view/template/download/_refer.php delete mode 100644 view/template/download/_unavailable.php delete mode 100644 view/template/download/getAllowed.php diff --git a/controller/Session.class.php b/controller/Session.class.php index fdb944d2..a0885bd6 100644 --- a/controller/Session.class.php +++ b/controller/Session.class.php @@ -4,8 +4,6 @@ class Session { const KEY_DOWNLOAD_ACCESS_ERROR = 'download_error2', KEY_DOWNLOAD_ALLOWED = 'beta_download_allowed2', - KEY_PREFINERY_USER_ID = 'prefinery_user_id', - KEY_PREFINER_USED_CUSTOM_CODE = 'prefinery_used_custom_code', KEY_DEVELOPER_LAST_FORM = 'developer_last_form', KEY_DEVELOPER_CREDITS_ERROR = 'developer_credits_error', KEY_DEVELOPER_CREDITS_WALLET_ADDRESS = 'developer_credits_wallet_address', diff --git a/controller/action/DownloadActions.class.php b/controller/action/DownloadActions.class.php index b6359abd..e97f7389 100644 --- a/controller/action/DownloadActions.class.php +++ b/controller/action/DownloadActions.class.php @@ -28,58 +28,16 @@ class DownloadActions extends Actions public static function executeGet() { - $email = static::getEmailParam(); - $user = []; - - if ($email) - { - if (filter_var($email, FILTER_VALIDATE_EMAIL)) - { - $user = Prefinery::findUser($email); - } - - if (!$user) - { - Session::unsetKey(Session::KEY_PREFINERY_USER_ID); - Session::unsetKey(Session::KEY_DOWNLOAD_ALLOWED); - } - } - elseif (Session::get(Session::KEY_PREFINERY_USER_ID)) - { - try - { - $user = Prefinery::findUser(Session::get(Session::KEY_PREFINERY_USER_ID)); - } - catch (PrefineryException $e) - { - if (stripos($e->getMessage(), 'Tester is hidden.') === false) - { - throw $e; - } - } - } - - if ($user) - { - static::setSessionVarsForPrefineryUser($user); - } - - if (!Session::get(Session::KEY_DOWNLOAD_ALLOWED)) - { - return ['download/get']; - } - $osChoices = OS::getAll(); $os = static::guessOs(); if ($os && isset($osChoices[$os])) { list($uri, $osTitle, $osIcon, $partial) = $osChoices[$os]; - return ['download/getAllowed', [ + return ['download/get', [ 'os' => $os, 'osTitle' => $osTitle, 'osIcon' => $osIcon, - 'prefineryUser' => $user ?: [], 'downloadHtml' => View::exists('download/' . $partial) ? View::render('download/' . $partial, ['downloadUrl' => Github::getAppDownloadUrl($os)]) : false @@ -93,7 +51,6 @@ class DownloadActions extends Actions public static function executeSignup() { $email = Request::getParam('email'); - $code = Request::getParam('code'); if (!$email || !filter_var($email, FILTER_VALIDATE_EMAIL)) { @@ -101,39 +58,10 @@ class DownloadActions extends Actions } else { - $referrerId = Request::getParam('referrer_id'); - $failure = false; Mailgun::sendSubscriptionConfirmation($email); - - try - { - $user = Prefinery::findOrCreateUser($email, $code, $referrerId); - static::setSessionVarsForPrefineryUser($user); - if ($code && strlen($code) > 2 && in_array(substr($code, 0, 2), ['my', 'pf', 'sl'])) - { - Session::set(Session::KEY_PREFINER_USED_CUSTOM_CODE, true); - } - } - catch (CurlException $e) - { - $failure = true; - Slack::sendErrorIfProd($e); - } - catch (PrefineryException $e) - { - $failure = true; - } - - if ($failure) - { - Session::set(Session::KEY_DOWNLOAD_ALLOWED, false); - Session::set(Session::KEY_DOWNLOAD_ACCESS_ERROR, - 'We were unable to add you to the wait list. Received error "' . $e->getMessage() . '". Please contact ' . - Config::HELP_CONTACT_EMAIL . ' if you think this is a mistake.'); - } } - return Controller::redirect('/get'); + return Controller::redirect(Request::getReferrer('/get')); } public static function prepareListPartial(array $vars) @@ -148,39 +76,6 @@ class DownloadActions extends Actions { return $vars + [ 'defaultEmail' => static::getEmailParam(), - 'allowInviteCode' => true, - 'referralCode' => Request::getParam('r', '') - ]; - } - - protected static function setSessionVarsForPrefineryUser($userData) - { - Session::set(Session::KEY_DOWNLOAD_ALLOWED, in_array($userData['status'], [Prefinery::STATE_ACTIVE, Prefinery::STATE_INVITED])); - Session::set(Session::KEY_PREFINERY_USER_ID, (int)$userData['id']); - } - - public static function prepareReferPartial(array $vars) - { - $userId = (int)Session::get(Session::KEY_PREFINERY_USER_ID); - if (!$userId) - { - return null; - } - - $prefineryUser = Prefinery::findUser($userId); - - if ($prefineryUser) - { - preg_match('/\?r\=(\w+)/', $prefineryUser['share_link'], $matches); - } - else - { - $matches = null; - } - - return $vars + [ - 'prefineryUser' => $prefineryUser, - 'referralCode' => $matches[1] ?? 'unknown' ]; } diff --git a/data/i18n/en.yaml b/data/i18n/en.yaml index b847f5d9..8f5dbda5 100644 --- a/data/i18n/en.yaml +++ b/data/i18n/en.yaml @@ -15,9 +15,8 @@ bounty: completed_notice: This bounty has already been completed and can no longer be claimed. pull_request_link: View the Pull Request description: - allowed: Download/install the latest version of LBRY for %os%. faq: Frequently asked questions about LBRY. - get: Download/install the latest version of LBRY. + get: Experience content freedom! Download the latest version of LBRY for Windows, mac OS, or Linux. home: Meet LBRY, a content sharing and publishing platform that is decentralized and owned by its users. join: Follow along and receive updates about LBRY via email. learn: Learn more about LBRY, the technology that puts you back in control of the internet. @@ -29,10 +28,10 @@ description: test: WHAT WHAT what: Access information and content in ways you never dreamed possible. Earn credits for your unused bandwidth and diskspace. download: - beta: This is still a beta. + beta: This software is in beta. creator: Creator? Skip the Line credits: Claim Credits - curse: While LBRY is now live, it may crash, work unreliably, or inadvertently put a curse on your family for generations (a common programming error). Use at your own risk. + curse: It may crash, work unreliably, or inadvertently put a curse on your family for generations (a common programming error). deb: Download .deb earn1: Earn # this many credits @@ -43,11 +42,11 @@ download: for-os: LBRY for %os% github: Or, view the source and compile instructions on osx: Arrival is expected by July 5. - osx2: Download for OS X + osx2: Download for macOS other: Other Systems popular: Popular publishers can earn $1,000 and early access for publishing via LBRY. select: Select an OS - unavailable: LBRY is not yet out on your platform. You will receive an email as we expand LBRY to your preferred platform. + unavailable: LBRY is not yet out on this platform, but will be soon. Enter your email to be notified when it is released. verb: Download windows: Download for Windows works: "Works with Ubuntu, Debian, or any distro with apt or dpkg." @@ -79,7 +78,6 @@ global: sentence: Watch, read and play in a decentralized digital library controlled by the community. tagline: Content Freedom learn: - 100: LBRY in 100 Seconds art: Art in the Internet Age essay: Read the Essay exchange_faq: Buy/Sell LBRY Credits @@ -237,8 +235,8 @@ social: github: GitHub (source code) header: Build With Us humansheader: Humans - humanstext: Let's create a freer, more creative world. - robotsheader: Wanna Be Robots + humanstext: Join the LBRY community. + robotsheader: Robots robotstext: Make with us. All LBRY code is open source. slack: Slack (chat) tweets: Tweets by @LBRYio diff --git a/lib/thirdparty/Prefinery.class.php b/lib/thirdparty/Prefinery.class.php deleted file mode 100644 index 91c1215d..00000000 --- a/lib/thirdparty/Prefinery.class.php +++ /dev/null @@ -1,189 +0,0 @@ - [ - 'Accept: application/json', - 'Content-type: application/json' - ], - 'json_data' => true, - 'json_response' => true - ]; - - public static function findUser($emailOrId, $useApc = true) - { - $apcEnabled = Apc::isEnabled(); - if ($useApc && $apcEnabled) - { - $cached = apc_fetch('prefinery-user-' . $emailOrId, $success); - if ($success) - { - return $cached; - } - } - - try - { - $user = is_numeric($emailOrId) ? Prefinery::findTesterById($emailOrId) : Prefinery::findTesterByEmail($emailOrId); - } - catch (PrefineryException $e) - { - if (stripos($e->getMessage(), 'Tester is hidden.') === false) - { - throw $e; - } - } - - if ($user) - { - unset($user['invitation_code']); // so we dont leak it - if ($useApc && $apcEnabled) - { - apc_store('prefinery-user-' . $emailOrId, $user, 3600); - } - } - - return $user; - } - - protected static function findTesterById($id) - { - return static::get('/testers/' . (int)$id); - } - - protected static function findTesterByEmail($email) - { - $data = static::get('/testers', ['email' => $email]); - - if ($data && is_array($data) && count($data)) - { - foreach ($data as $userData) //can partial match on email, very unlikely though - { - if (strtolower($userData['email']) == strtolower($email)) - { - return $userData; - } - } - return $data[0]; - } - - return null; - } - - public static function findOrCreateUser($email, $inviteCode = null, $referrerId = null) - { - $user = static::findUser($email); - if (!$user) - { - // dont record ip for lbry.io addresses, for testing - $ip = !preg_match('/@lbry\.io$/', $email) ? Request::getOriginalIp() : null; - $ua = Request::getUserAgent(); - $user = Prefinery::createTester(array_filter([ - 'email' => $email, - 'status' => $inviteCode ? static::STATE_ACTIVE : static::STATE_APPLIED, # yes, has to be ACTIVE to validate invite code - 'invitation_code' => $inviteCode, - 'referrer_id' => $referrerId, - 'profile' => ['ip' => $ip, 'user_agent' => $ua] - ])); - -// if ($inviteCode) -// { -// $user = static::updateTester(array_intersect_key($user, ['id' => null]) + ['status' => static::STATE_ACTIVE]); -// if ($user['invitation_code'] != $inviteCode) -// { -// $user['is_custom_code'] = true; -// } -// } - - $user['is_custom_code'] = false; - } - -// unset($user['invitation_code']); // so we dont leak it - return $user; - } - - protected static function createTester(array $testerData) - { - return static::post('/testers', ['tester' => array_filter($testerData)], false); - } - - public static function updateTester(array $testerData) - { - if (!$testerData['id']) - { - throw new PrefineryException('Update tester must be called with a tester id'); - } - if (Apc::isEnabled()) - { - apc_delete('prefinery-user-' . $testerData['id']); - } - return static::put('/testers/' . $testerData['id'], ['tester' => array_diff_key(array_filter($testerData), ['id' => null])], false); - } - - protected static function put($endpoint, array $data = []) - { - $apiKey = Config::get('prefinery_key'); - $options = static::$curlOptions; - $options['headers'][] = 'X-HTTP-Method-Override: PUT'; - return static::decodePrefineryResponse( - Curl::put(static::DOMAIN . static::PREFIX . $endpoint . '.json?api_key=' . $apiKey, $data, $options) - ); - } - - protected static function get($endpoint, array $data = []) - { - return static::decodePrefineryResponse( - Curl::get(static::DOMAIN . static::PREFIX . $endpoint . '.json?api_key=' . Config::get('prefinery_key'), - $data, array_merge(static::$curlOptions, ['retry' => 3]) - ) - ); - } - - protected static function post($endpoint, array $data = [], bool $allowEmptyResponse = true) - { - return static::decodePrefineryResponse( - Curl::post(static::DOMAIN . static::PREFIX . $endpoint . '.json?api_key=' . Config::get('prefinery_key'), - $data, array_merge(static::$curlOptions, ['retry' => 3]) - ), - $allowEmptyResponse - ); - } - - protected static function decodePrefineryResponse($data, $allowEmptyResponse = true) - { - if (!$allowEmptyResponse && !$data && $data !== []) - { - throw new PrefineryException('Received empty or improperly encoded response.'); - } - - if (isset($data['error'])) - { - throw new PrefineryException($data['error']); - } - - if (isset($data['errors'])) - { - throw new PrefineryException($data['errors'] ? - implode("\n", array_map(function ($error) { return $error['message']; }, (array)$data['errors'])) : - 'Received empty error array.' - ); - } - - return $data; - } -} - -class PrefineryException extends Exception -{ -} diff --git a/lib/tools/OS.class.php b/lib/tools/OS.class.php index ce00a676..ff88e877 100644 --- a/lib/tools/OS.class.php +++ b/lib/tools/OS.class.php @@ -14,7 +14,7 @@ class OS //yes, this is probably a bad pattern return [ OS::OS_WINDOWS => ['/windows', 'Windows', 'icon-windows', '_windows'], - OS::OS_OSX => ['/osx', 'OS X', 'icon-apple', '_osx'], + OS::OS_OSX => ['/osx', 'macOS', 'icon-apple', '_osx'], OS::OS_LINUX => ['/linux', 'Linux', 'icon-linux', '_linux'], OS::OS_ANDROID => ['/android', 'Android', 'icon-android', '_android'], OS::OS_IOS => ['/ios', 'iOS', 'icon-mobile', '_ios'] diff --git a/view/template/developer/_quickstartApi.php b/view/template/developer/_quickstartApi.php index 2171dc10..1f65000b 100644 --- a/view/template/developer/_quickstartApi.php +++ b/view/template/developer/_quickstartApi.php @@ -3,7 +3,7 @@ When running, the LBRY daemon provides a JSON-RPC server running at http://localhost:5279/lbryapi.

- It can be accessed by any utility capable of making HTTPS GET and POST requests, such as cURL or possibly your toaster. Psst, if you are on windows you could use PowerShell while testing, scroll down to the bottom of this page to get more info. + It can be accessed by any utility capable of making HTTPS GET and POST requests, such as cURL or possibly your toaster. On Windows? You can also use PowerShell. Learn more.

To verify the LBRY daemon is running correctly, let's try looking up a URI: @@ -54,12 +54,12 @@

You can also list all of the commands available by calling the help command.

$curl 'http://localhost:5279/lbryapi' --data '{"method":"help"}' -

Windows

+

Windows

If you are running Windows and would like to follow this guide you could substitute curl with a PowerShell console and the following code.

$Invoke-RestMethod -Uri 'http://localhost:5279/lbryapi' -Body 'THE_JSON_DATA' -Method POST | ConvertTo-Json -

If PowerShell does not work and you want to continue with cURL, you'll need to escape inner double quotes with a \ to pass the JSON properly via Command Prompt. +

If PowerShell does not work and you want to continue with cURL, you'll need to escape inner double quotes with a \ to pass the JSON properly via Command Prompt.

$curl "http://localhost:5279/lbryapi" --data "{\"method\":\"get\",\"params\":{\"uri\":\"what\"} }" diff --git a/view/template/download/_betaNotice.php b/view/template/download/_betaNotice.php deleted file mode 100644 index 6cbdc9c1..00000000 --- a/view/template/download/_betaNotice.php +++ /dev/null @@ -1,4 +0,0 @@ -

- {{download.beta}} - {{download.curse}} -

\ No newline at end of file diff --git a/view/template/download/_linux.php b/view/template/download/_linux.php index 23589ce8..1c730d65 100644 --- a/view/template/download/_linux.php +++ b/view/template/download/_linux.php @@ -1,7 +1,7 @@

- - href="" + + href=""

diff --git a/view/template/download/_osx.php b/view/template/download/_osx.php index 92123bfc..f4dee380 100644 --- a/view/template/download/_osx.php +++ b/view/template/download/_osx.php @@ -1,7 +1,7 @@

- - href="" + + href="" -

Know the command line?
Skip the real line.

-

Developers and other technical users can try LBRY before it goes public.

-
Developer Program -
\ No newline at end of file diff --git a/view/template/download/_refer.php b/view/template/download/_refer.php deleted file mode 100644 index 2cdf0a65..00000000 --- a/view/template/download/_refer.php +++ /dev/null @@ -1,42 +0,0 @@ -

{{title.refer}}

-

{{page.refer.earn1}} '2017-06-19' ? 2.5 : 5)) ?> {{page.refer.earn2}}

-

- - - $('#referral-url-input') - .focus(function() { $(this).select(); }) - .click(function() { $(this).select(); }); - -

-

{{page.refer.status}}

-

$prefineryUser['share_signups_count']]) ?> - - -

-
{{page.refer.more}}
diff --git a/view/template/download/_signup.php b/view/template/download/_signup.php index ab096395..c7e46f25 100644 --- a/view/template/download/_signup.php +++ b/view/template/download/_signup.php @@ -1,7 +1,8 @@ -
-
- -
+ + +
+ +
- -
- -
- -
-
- -
-
- -
-
- -
- -
- -
-
+
- - -(function(){ - var form = $('#signup-form'), - codeRadioInputs = form.find('input[name="code_select"]'); - codeRadioInputs.change(function() { - var selectedInput = codeRadioInputs.filter(':checked'), - hasChoice = selectedInput.length, - hasCode = selectedInput.val() == 'yes'; - - form.find('.has-code')[hasChoice && hasCode ? 'show' : 'hide'](); - form.find('.no-code')[hasChoice && !hasCode ? 'show' : 'hide'](); - if (!hasCode) - { - form.find('input[name="code"]').val(''); - } - }).change(); - - form.show(); -})(); - \ No newline at end of file + \ No newline at end of file diff --git a/view/template/download/_unavailable.php b/view/template/download/_unavailable.php deleted file mode 100644 index 7bbcf809..00000000 --- a/view/template/download/_unavailable.php +++ /dev/null @@ -1,3 +0,0 @@ -
-

{{download.unavailable}}

-
\ No newline at end of file diff --git a/view/template/download/_videoIntro.php b/view/template/download/_videoIntro.php index c5b0fe3e..95a14f98 100644 --- a/view/template/download/_videoIntro.php +++ b/view/template/download/_videoIntro.php @@ -1,3 +1,3 @@
- +
diff --git a/view/template/download/_windows.php b/view/template/download/_windows.php index 13cfb045..029809b2 100644 --- a/view/template/download/_windows.php +++ b/view/template/download/_windows.php @@ -1,7 +1,7 @@

- - href="" + + href=""

+ $os + ]) ?> -
- + \ No newline at end of file diff --git a/view/template/download/getAllowed.php b/view/template/download/getAllowed.php deleted file mode 100644 index a91aa1b7..00000000 --- a/view/template/download/getAllowed.php +++ /dev/null @@ -1,38 +0,0 @@ - $osTitle])) ?> - - false]) ?> - -
-
-
-

$osTitle]) ?>

- - - -
- It looks like you may have been invited via a custom code. - If so, please check your email for a single-use code to claim credits after installing. -
- - - - $os - ]) ?> - -
- -
- -
- -
-
- $os - ]) ?> - -
-
- - \ No newline at end of file diff --git a/view/template/page/home.php b/view/template/page/home.php index 622bd61f..c075333b 100644 --- a/view/template/page/home.php +++ b/view/template/page/home.php @@ -6,7 +6,7 @@

Content Freedom

- Picture of LBRY Browser + Picture of LBRY Browser
@@ -15,7 +15,7 @@

Hollywood films, college lessons, amazing streamers and more are on the first media network ruled by you.

diff --git a/view/template/page/learn.php b/view/template/page/learn.php index 5718eac3..62c4b5e1 100644 --- a/view/template/page/learn.php +++ b/view/template/page/learn.php @@ -3,22 +3,23 @@ false]) ?>
-
-
-

{{learn.100}}

+
+

{{learn.art}}

+

{{learn.how}}

+ +
+
+
+
+
+

Hello LBRY

+

See previews of the LBRY UI and the great content available now on LBRY.

-
-
-

{{learn.art}}

-

{{learn.how}}

- -
-
-
+

{{learn.explore}}

@@ -26,9 +27,10 @@
About the Team @@ -40,14 +42,15 @@
-
+
-

{{learn.nerd}}

+

For Developers

LBRY is 100% open source in the Bazaar tradition.

+
diff --git a/view/template/social/_listDev.php b/view/template/social/_listDev.php index 42c39962..e1362add 100644 --- a/view/template/social/_listDev.php +++ b/view/template/social/_listDev.php @@ -12,3 +12,6 @@ + \ No newline at end of file diff --git a/web/js/global.js b/web/js/global.js index ba3cd405..9daf4c77 100644 --- a/web/js/global.js +++ b/web/js/global.js @@ -97,21 +97,21 @@ $(document).ready(function() { if (!ga) return; ga('send', 'social', 'Facebook', 'like', window.location.href); } - - $('.video > iframe').each(function() { - var iframe = $(this); - iframe.data('maxWidth', iframe.attr('width')); - iframe.data('maxHeight', iframe.attr('height')); - iframe.data('aspectRatio', iframe.attr('height') / iframe.attr('width')) - .removeAttr('height') - .removeAttr('width'); - - resizeVideo(iframe); - }); - - $(window).resize(function() { - $('.video > iframe').each(function() { - resizeVideo($(this)); - }) - }); + // + // $('.video > video').each(function() { + // var iframe = $(this); + // iframe.data('maxWidth', iframe.attr('width')); + // iframe.data('maxHeight', iframe.attr('height')); + // iframe.data('aspectRatio', iframe.attr('height') / iframe.attr('width')) + // .removeAttr('height') + // .removeAttr('width'); + // + // resizeVideo(iframe); + // }); + // + // $(window).resize(function() { + // $('.video > video').each(function() { + // resizeVideo($(this)); + // }) + // }); }); diff --git a/web/scss/_basic.scss b/web/scss/_basic.scss index 596df726..869d8c9f 100644 --- a/web/scss/_basic.scss +++ b/web/scss/_basic.scss @@ -231,3 +231,9 @@ body @include flex(2); } } + +video { + width: 100%; + max-width: 800px; + height: auto; +} \ No newline at end of file