mirror of
https://github.com/LBRYFoundation/lbry.com.git
synced 2025-08-23 17:47:26 +00:00
quickstart almost gtg
This commit is contained in:
parent
8ed05b4586
commit
8d0c394d59
5 changed files with 132 additions and 43 deletions
|
@ -88,7 +88,10 @@ class Controller
|
|||
$router->get(['/android', 'get-android'], 'DownloadActions::executeGet');
|
||||
$router->get(['/ios', 'get-ios'], 'DownloadActions::executeGet');
|
||||
$router->get('/roadmap', 'ContentActions::executeRoadmap');
|
||||
$router->get('/credits-for-developers', 'AcquisitionActions::executeCreditsForDevelopers');
|
||||
|
||||
$router->get('/developer-program', 'AcquisitionActions::executeDeveloperProgram');
|
||||
$router->post('/developer-program', 'AcquisitionActions::executeDeveloperProgramRedirect');
|
||||
$router->get('/developer-program/callback', 'AcquisitionActions::executeDeveloperProgramGithubCallback');
|
||||
|
||||
$router->get(['/press-kit.zip', 'press-kit'], 'ContentActions::executePressKit');
|
||||
|
||||
|
|
|
@ -2,8 +2,11 @@
|
|||
|
||||
class AcquisitionActions extends Actions
|
||||
{
|
||||
const DEVELOPER_REWARD = 250;
|
||||
|
||||
const DEVELOPER_REWARD = 250,
|
||||
SESSION_KEY_DEVELOPER_CREDITS_ERROR = 'acquisition.developer-credits-error',
|
||||
SESSION_KEY_DEVELOPER_CREDITS_SUCCESS = 'acquisition.developer-credits-success',
|
||||
SESSION_KEY_DEVELOPER_CREDITS_WALLET_ADDRESS = 'acquisition.developer-credits-wallet-address';
|
||||
|
||||
public static function executeThanks()
|
||||
{
|
||||
return ['acquisition/thanks'];
|
||||
|
@ -42,8 +45,98 @@ class AcquisitionActions extends Actions
|
|||
return [$template];
|
||||
}
|
||||
|
||||
public static function executeCreditsForDevelopers()
|
||||
public static function executeDeveloperProgram()
|
||||
{
|
||||
return ['acquisition/credits-for-developers'];
|
||||
$vars = [
|
||||
'defaultWalletAddress' => Session::get(static::SESSION_KEY_DEVELOPER_CREDITS_WALLET_ADDRESS),
|
||||
'error' => Session::get(static::SESSION_KEY_DEVELOPER_CREDITS_ERROR),
|
||||
'success' => Session::get(static::SESSION_KEY_DEVELOPER_CREDITS_SUCCESS)
|
||||
];
|
||||
Session::unsetKey(static::SESSION_KEY_DEVELOPER_CREDITS_SUCCESS);
|
||||
Session::unsetKey(static::SESSION_KEY_DEVELOPER_CREDITS_ERROR);
|
||||
return ['acquisition/developer-program', $vars];
|
||||
}
|
||||
|
||||
public static function executeDeveloperProgramRedirect()
|
||||
{
|
||||
$walletAddress = trim(Request::getPostParam('wallet'));
|
||||
Session::set(static::SESSION_KEY_DEVELOPER_CREDITS_WALLET_ADDRESS, $walletAddress);
|
||||
if (!$walletAddress)
|
||||
{
|
||||
Session::set(static::SESSION_KEY_DEVELOPER_CREDITS_ERROR, 'Please provide a wallet address.');
|
||||
}
|
||||
elseif (!preg_match('/^b[1-9A-HJ-NP-Za-km-z]{33}$/', $walletAddress))
|
||||
{
|
||||
Session::set(static::SESSION_KEY_DEVELOPER_CREDITS_ERROR, 'This does not appear to be a valid wallet address.');
|
||||
}
|
||||
else
|
||||
{
|
||||
$githubParams = [
|
||||
'client_id' => Config::get('github_developer_credits_client_id'),
|
||||
'redirect_uri' => 'http://localhost:8000/developer-program/callback',
|
||||
'scope' => 'user:email',
|
||||
'allow_signup' => false
|
||||
];
|
||||
return Controller::redirect('https://github.com/login/oauth/authorize?' . http_build_query($githubParams));
|
||||
}
|
||||
return Controller::redirect('/developer-program');
|
||||
}
|
||||
|
||||
public static function executeDeveloperProgramGithubCallback()
|
||||
{
|
||||
$code = Request::getParam('code');
|
||||
$walletAddress = Session::get(static::SESSION_KEY_DEVELOPER_CREDITS_WALLET_ADDRESS);
|
||||
if (!$walletAddress || !$code)
|
||||
{
|
||||
Session::set(static::SESSION_KEY_DEVELOPER_CREDITS_ERROR, 'Your wallet address disappeared while authenticated with GitHub.');
|
||||
}
|
||||
elseif (!$code)
|
||||
{
|
||||
Session::set(static::SESSION_KEY_DEVELOPER_CREDITS_ERROR, 'This does not appear to be a valid response from GitHub.');
|
||||
}
|
||||
else
|
||||
{
|
||||
$authResponseData = Curl::post('https://github.com/login/oauth/access_token', [
|
||||
'code' => $code,
|
||||
'client_id' => Config::get('github_developer_credits_client_id'),
|
||||
'client_secret' => Config::get('github_developer_credits_client_secret')
|
||||
], [
|
||||
'headers' => ['Accept: application/json'],
|
||||
'json_response' => true
|
||||
]);
|
||||
if (!$authResponseData || !isset($authResponseData['access_token']))
|
||||
{
|
||||
Session::set(static::SESSION_KEY_DEVELOPER_CREDITS_ERROR, 'Request to GitHub failed.');
|
||||
}
|
||||
elseif (isset($authResponseData['error_description']))
|
||||
{
|
||||
Session::set(static::SESSION_KEY_DEVELOPER_CREDITS_ERROR, 'GitHub replied: ' . $authResponseData['error_description']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$accessToken = $authResponseData['access_token'];
|
||||
$userResponseData = Curl::get('https://api.github.com/user', [], [
|
||||
'headers' => ['Authorization: token ' . $accessToken, 'Accept: application/json', 'User-Agent: lbryio'],
|
||||
'json_response' => true
|
||||
]);
|
||||
|
||||
if (date('Y-m', strtotime($userResponseData['created_at'])) > '2017-01')
|
||||
{
|
||||
Session::set(static::SESSION_KEY_DEVELOPER_CREDITS_ERROR, 'This GitHub account is too recent.');
|
||||
}
|
||||
else
|
||||
{
|
||||
// print_r($userResponseData);
|
||||
/*
|
||||
* TODO: send credits here, see success message below for relevant values
|
||||
* (keep wallet address in success message)
|
||||
*/
|
||||
|
||||
Session::set(static::SESSION_KEY_DEVELOPER_CREDITS_SUCCESS,
|
||||
'Send credits to GitHub user ' . $userResponseData['login'] . ' (' . $userResponseData['email'] . ') at wallet address ' . $walletAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Controller::redirect('/developer-program');
|
||||
}
|
||||
}
|
|
@ -4,18 +4,24 @@
|
|||
<?php echo View::render('nav/_header', ['isDark' => false, 'isAbsolute' => false]) ?>
|
||||
<main >
|
||||
<div class="content content-light markdown">
|
||||
<h1>Credits For Developers</h1>
|
||||
<p>All developers with a GitHub account prior to 2017 are eligible for <?php echo AcquisitionActions::DEVELOPER_REWARD ?> free credits.</p>
|
||||
<h1>Developer Program</h1>
|
||||
<p>All developers with a GitHub account prior to January 31st, 2017 are eligible for <?php echo AcquisitionActions::DEVELOPER_REWARD ?> free credits.</p>
|
||||
<p>To claim your credits, enter a wallet address in the form below and authenticate with GitHub.</p>
|
||||
<p>
|
||||
We will store your GitHub username and email address, but nothing else.
|
||||
</p>
|
||||
<form method="POST" action="/go-somewhere" class="form-inset">
|
||||
<form method="POST" action="/developer-program" class="form-inset">
|
||||
<h3 style="margin-top: 0">Receive Credits</h3>
|
||||
<?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 ?>
|
||||
<div class="form-row">
|
||||
<label for="wallet">Wallet Address</label>
|
||||
<div class="form-input">
|
||||
<input type="text" name="wallet" class="required standard input-wallet" placeholder="bYnFQUPTTDM1BYNCxgxKEav4FFQsrgDBoE">
|
||||
<input type="text" name="wallet" value="<?php echo $defaultWalletAddress ?>"
|
||||
class="required standard input-wallet" placeholder="bYnFQUPTTDM1BYNCxgxKEav4FFQsrgDBoE">
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" value="Continue to GitHub" class="btn-primary">
|
|
@ -10,9 +10,8 @@
|
|||
<ol class="table-of-contents">
|
||||
<li><a href="#installation" class="link-primary">Installation</a></li>
|
||||
<li><a href="#running-lbry" class="link-primary">Running LBRY</a></li>
|
||||
<li><a href="#api-basics" class="link-primary">API Basics</a></li>
|
||||
<li><a href="#api" class="link-primary">The API</a></li>
|
||||
<li><a href="#credits" class="link-primary">Credits</a></li>
|
||||
<li><a href="#start-building" class="link-primary">Start Building</a></li>
|
||||
<li><a href="#community" class="link-primary">Community & Issues</a></li>
|
||||
</ol>
|
||||
<section>
|
||||
|
@ -52,7 +51,7 @@
|
|||
<p>The first time you run the daemon, it must catch-up with most recent blockheaders. This can take several minutes.</p>
|
||||
</section>
|
||||
<section>
|
||||
<h3 id="api-basics">3. API Basics</h3>
|
||||
<h3 id="api">3. The API</h3>
|
||||
<p>
|
||||
When running, the LBRY daemon provides a JSON-RPC server running at <code>https://localhost:5279/lbryapi</code>.
|
||||
</p>
|
||||
|
@ -62,57 +61,45 @@
|
|||
<p>
|
||||
To verify the LBRY daemon is running correctly and responding to requests, run:
|
||||
</p>
|
||||
<p>
|
||||
<code>
|
||||
curl --data "{ method: 'status' }" http://localhost:5279/lbryapi
|
||||
</code>
|
||||
</p>
|
||||
<p>
|
||||
You should receive a response like:
|
||||
</p>
|
||||
<p>
|
||||
<code>
|
||||
(will copy/paste once it works)
|
||||
</code>
|
||||
</p>
|
||||
<p>This makes it easy to interact with the LBRY API in the programming language of your choice.</p>
|
||||
<pre><code>curl --data "{ method: 'status' }" http://localhost:5279/lbryapi
|
||||
(add response when this works)</code></pre>
|
||||
<p>This makes it easy to interact with the LBRY API in the programming language of your choice. Here's another example:</p>
|
||||
<pre><code>curl --data "{ method: 'resolve_name', params: [{ name: "what"}] }" http://localhost:5279/lbryapi
|
||||
(add response when this works)</code></pre>
|
||||
<p>LBRY can be used to build everything from a censorship-proof image host, to a store for 3D printing files, to distribute large files or datasets, or use cases even we can't imagine!</p>
|
||||
<p><a class="btn-alt" href="http://lbryio.github.io/lbry/api/">View Full API Documentation</a></p>
|
||||
</section>
|
||||
<section>
|
||||
<h3 id="credits">4. Getting Credits</h3>
|
||||
<p>Many actions, such as publishing or purchasing paid content, require credits.</p>
|
||||
<p>Many actions, such as reserving a name or purchasing paid content, require credits.</p>
|
||||
<p>To receive credits, first generate a wallet address:</p>
|
||||
<p>
|
||||
<code>
|
||||
curl --data "{ method: 'wallet_new_address' }" http://localhost:5279/lbryapi<br/>
|
||||
I am a response
|
||||
</code>
|
||||
</p>
|
||||
<pre><code>curl --data "{ method: 'wallet_new_address' }" http://localhost:5279/lbryapi
|
||||
I am a response</code></pre>
|
||||
<p>Use this address to get credits in one of two ways:</p>
|
||||
<div class="row-fluid">
|
||||
<div class="span6">
|
||||
<h4>4a) Get Credits For Free</h4>
|
||||
<h4>4a) Receive Free Credits</h4>
|
||||
<p>
|
||||
All developers are eligible to receive <?php echo AcquisitionActions::DEVELOPER_REWARD ?> free credits.
|
||||
<a href="/credits-for-developers" class="link-primary">Go here</a> to claim them.</a>
|
||||
All developers with a valid GitHub account are eligible to receive <?php echo AcquisitionActions::DEVELOPER_REWARD ?> free credits.
|
||||
</p>
|
||||
<a href="/developer-program" class="btn-alt">Claim Your Free Credits</a>
|
||||
</div>
|
||||
<div class="span6">
|
||||
<h4>4b) Purchase Credits</h4>
|
||||
<p>
|
||||
Credits can be bought on a variety of exchanges.
|
||||
Go <a href="https://lbry.io/faq/exchanges" class="link-primary">here</a> to see a full list.
|
||||
After purchasing them, send them to the address generated above.
|
||||
Credits can be bought on <a href="https://lbry.io/faq/exchanges" class="link-primary">a variety of exchanges</a>.
|
||||
After purchasing, send them to the address generated above.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<h3 id="community">6. Community & Issues</h3>
|
||||
<h3 id="community">5. Community & Issues</h3>
|
||||
<p>
|
||||
<a href="http://slack.lbry.io" class="link-primary">Join our Slack Channel</a> to interact with LBRY developers and other community members. Please visit the #dev room (this is not a default channel).
|
||||
<a href="http://slack.lbry.io" class="link-primary">Join our Slack Channel</a> to interact with LBRY developers and other community members. Please visit the #dev room (note: this is not a default channel).
|
||||
</p>
|
||||
<p>
|
||||
Visit our <a href="https://github.com/lbryio" class="link-primary">GitHub</a> to view the source code or report issues.
|
||||
Visit our <a href="https://github.com/lbryio" class="link-primary">GitHub page</a> to view the source code or report issues.
|
||||
</p>
|
||||
</section>
|
||||
</div>
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<br>
|
||||
|
||||
<?php echo View::render('nav/_flashes') ?>
|
||||
|
||||
|
||||
<form action="<?php echo Request::getRelativeUri() ?>" method="POST">
|
||||
<?php echo View::render('form/_formRow', [
|
||||
'field' => 'name',
|
||||
|
|
Loading…
Add table
Reference in a new issue