diff --git a/controller/Session.class.php b/controller/Session.class.php index ee1e9e50..fdb944d2 100644 --- a/controller/Session.class.php +++ b/controller/Session.class.php @@ -6,6 +6,7 @@ class Session 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', KEY_DEVELOPER_RETURN_URL_SUCCESS = 'developer_return_url_success', diff --git a/controller/action/DeveloperActions.class.php b/controller/action/DeveloperActions.class.php index 5a2dfea4..446d5ce3 100644 --- a/controller/action/DeveloperActions.class.php +++ b/controller/action/DeveloperActions.class.php @@ -3,22 +3,22 @@ class DeveloperActions extends Actions { const DEVELOPER_REWARD = 250, - API_DOC_URL = 'https://lbryio.github.io/lbry/api/'; + API_DOC_URL = 'https://lbryio.github.io/lbry/api/'; public static function executeQuickstart(string $step = null) { - $stepLabels = [ - '' => 'Home', + $stepLabels = [ + '' => 'Home', 'install' => 'Installation', - 'api' => 'The API', + 'api' => 'The API', 'credits' => 'Credits' ]; - $allSteps = array_keys($stepLabels); + $allSteps = array_keys($stepLabels); $currentStep = $step ?: $allSteps[0]; $viewParams = [ 'currentStep' => $currentStep, - 'stepLabels' => $stepLabels + 'stepLabels' => $stepLabels ]; if ($currentStep !== 'all') @@ -49,12 +49,10 @@ class DeveloperActions extends Actions public static function prepareFormNewDeveloperRewardPartial(array $vars) { - $sendToGithub = !Session::get(Session::KEY_GITHUB_ACCESS_TOKEN); return $vars + [ 'defaultWalletAddress' => Session::get(Session::KEY_DEVELOPER_CREDITS_WALLET_ADDRESS), - 'error' => Session::getFlash(Session::KEY_DEVELOPER_CREDITS_ERROR), - 'sendToGithub' => $sendToGithub, - 'apiUrl' => LBRY::getApiUrl('/user/new_github') + 'error' => Session::get(Session::KEY_DEVELOPER_LAST_FORM) == "new_developer" ? Session::getFlash(Session::KEY_DEVELOPER_CREDITS_ERROR) : '', + 'apiUrl' => LBRY::getApiUrl('/user/new_github') ]; } @@ -62,13 +60,15 @@ class DeveloperActions extends Actions { return $vars + [ 'defaultWalletAddress' => Session::get(Session::KEY_DEVELOPER_CREDITS_WALLET_ADDRESS), - 'error' => Session::getFlash(Session::KEY_DEVELOPER_CREDITS_ERROR), + 'error' => Session::get(Session::KEY_DEVELOPER_LAST_FORM) == "new_publish" ? Session::getFlash(Session::KEY_DEVELOPER_CREDITS_ERROR) : '', + 'apiUrl' => LBRY::getApiUrl('/reward/new') ]; } public static function executeQuickstartAuth() { Session::set(Session::KEY_DEVELOPER_CREDITS_WALLET_ADDRESS, trim(Request::getPostParam('wallet_address'))); + Session::set(Session::KEY_DEVELOPER_LAST_FORM, Request::getPostParam('formName')); if (Request::getPostParam('returnUrl')) { @@ -92,7 +92,7 @@ class DeveloperActions extends Actions public static function executeQuickstartGithubCallback() { - $code = Request::getParam('code'); + $code = Request::getParam('code'); if (!$code) { diff --git a/view/template/developer/_formCreditsPublish.php b/view/template/developer/_formCreditsPublish.php index 4ec14101..017f58a7 100644 --- a/view/template/developer/_formCreditsPublish.php +++ b/view/template/developer/_formCreditsPublish.php @@ -1,25 +1,28 @@ -
-

Receive Credits

- -
- -
- + +lbry.quickstartForm('#form-new-publish-reward', ""); + + +

Receive Credits for Publish

+
+
- +
- +
-
- +
+ + + +
\ No newline at end of file diff --git a/view/template/developer/_formNewDeveloperReward.php b/view/template/developer/_formNewDeveloperReward.php index 4d4f1522..184e5a54 100644 --- a/view/template/developer/_formNewDeveloperReward.php +++ b/view/template/developer/_formNewDeveloperReward.php @@ -9,11 +9,12 @@
+ class="required standard " placeholder="bYnFQUPTTDM1BYNCxgxKEav4FFQsrgDBoE">
+
diff --git a/view/template/developer/_quickstartCredits.php b/view/template/developer/_quickstartCredits.php index 2945f187..bbb8f6a8 100644 --- a/view/template/developer/_quickstartCredits.php +++ b/view/template/developer/_quickstartCredits.php @@ -22,8 +22,10 @@ "metadata": {"what goes here": "who knows if you do not work for LBRY, certainly you will not be able to figure it out from response messages or API docs" }]}' [whatever this response looks like] -
- +
+ Request::getRelativeUri() . '#new-developer' + ]) ?>

Try the UI

LBRY comes with a UI so that normal people can use it to. You can download it here.

diff --git a/web/js/quickstart.js b/web/js/quickstart.js index 9e783349..5c8c18bc 100644 --- a/web/js/quickstart.js +++ b/web/js/quickstart.js @@ -2,17 +2,21 @@ lbry.quickstartForm = function (selector, apiUrl) { var form = $(selector), accessToken = form.find(':input[name="access_token"]').val(), walletAddressInput = form.find(':input[name="wallet_address"]'), + transactionHashInput = form.find(':input[name="transaction_hash"]'), + storageKey = form.attr('id') + "SuccessHTML", submitButton = form.find(':input[type="submit"]'), + isAutomaticSubmit = false, isSubmitting = false; function resetFormState() { isSubmitting = false; walletAddressInput.attr('readonly', null); + transactionHashInput.attr('readonly', null); submitButton.val(submitButton.data('submitLabel')).attr('disabled', null); } - if (window.localStorage.getItem("quickstartFormSuccessHtml")) { - form.find('.notice-success').html(window.localStorage.getItem("quickstartFormSuccessHtml")).show(); + if (window.localStorage.getItem(storageKey)) { + form.find('.notice-success').html(window.localStorage.getItem(storageKey)).show(); form.find('.form-row, .submit-row').hide(); } else if (accessToken) { form.submit(function (event) { @@ -20,23 +24,39 @@ lbry.quickstartForm = function (selector, apiUrl) { return false; } + var postData = { + access_token: accessToken, + wallet_address: walletAddressInput.val() + }; + form.find('.notice-success, .notice-error').hide(); if (!walletAddressInput.val()) { resetFormState(); - form.find('.notice-error').html("Please supply a wallet address.").show(); + if (!isAutomaticSubmit) { + form.find('.notice-error').html("Please supply a wallet address.").show(); + } return false; } + if (transactionHashInput.length) { + if (!transactionHashInput.val()) { + resetFormState(); + if (!isAutomaticSubmit) { + form.find('.notice-error').html("Please supply a transaction ID.").show(); + } + return false; + } + postData.transaction_hash = transactionHashInput.val(); + } + event.preventDefault(); walletAddressInput.attr('readonly', 'readonly'); + transactionHashInput.attr('readonly', 'readonly'); submitButton.val(submitButton.data('submittingLabel')).attr('disabled', 'disabled'); - $.post(apiUrl, { - access_token: accessToken, - wallet_address: walletAddressInput.val() - }) + $.post(apiUrl) .done(function (responseData) { var data = responseData.data; var anchor = $(''); @@ -46,7 +66,7 @@ lbry.quickstartForm = function (selector, apiUrl) { .html(data.RewardAmount + " credits sent in transaction ") .append(anchor) .show(); - window.localStorage.setItem("quickstartFormSuccessHtml", form.find('.notice-success').html()); + window.localStorage.setItem(storageKey, form.find('.notice-success').html()); }) .fail(function (xhr) { var responseData = $.parseJSON(xhr.responseText); @@ -54,6 +74,9 @@ lbry.quickstartForm = function (selector, apiUrl) { }) .always(resetFormState); }) + + isAutomaticSubmit = true; form.submit(); + isAutomaticSubmit = false; } } \ No newline at end of file diff --git a/web/scss/_form.scss b/web/scss/_form.scss index 1194d479..2f3d4d4b 100644 --- a/web/scss/_form.scss +++ b/web/scss/_form.scss @@ -81,11 +81,6 @@ input[type="date"] { vertical-align: middle; } -input.input-wallet -{ - width: 400px; -} - textarea { height: auto; min-height: 60px; diff --git a/web/scss/_quickstart.scss b/web/scss/_quickstart.scss index 65e15895..4c5bad69 100644 --- a/web/scss/_quickstart.scss +++ b/web/scss/_quickstart.scss @@ -27,6 +27,7 @@ .quickstart__claim-form { margin: $spacing-vertical * 2 0; + input[type="text"] { width: 100%; } } .quickstart__progress-bar