Merge pull request #838 from lbryio/master

Cut staging from master
This commit is contained in:
Shawn K 2018-12-18 15:00:54 -06:00 committed by GitHub
commit 544cc6aae0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 36 additions and 13 deletions

View file

@ -132,13 +132,14 @@ Log in as username@domainname or username@ip_address
`sudo apt-get install mysql-server -y` `sudo apt-get install mysql-server -y`
( enter blank password each time if prompted) ( During install, enter blank password each time if prompted. We'll set one during secure setup.)
`sudo systemctl status mysql` (q to exit) `sudo systemctl status mysql` (q to exit)
## Secure Setup ## Secure Setup
`sudo mysql_secure_installation` `sudo mysql_secure_installation`
* Password your_mysql_password * Password your_mysql_password
* No to password validation * No to password validation
* Y to all other options * Y to all other options
@ -225,10 +226,7 @@ tmux allows you to run multiple things in different sessions. Useful for manuall
`npm run configure` `npm run configure`
(once your wallet balance has cleared) The script will ask for the following values:
`npm run configure`
* Database: lbry * Database: lbry
* Username: root * Username: root
@ -238,6 +236,8 @@ tmux allows you to run multiple things in different sessions. Useful for manuall
* Enter your site's domain name: https://example.com or http://localhost:3000 * Enter your site's domain name: https://example.com or http://localhost:3000
* Enter a directory where uploads should be stored: (/home/lbry/Uploads) * Enter a directory where uploads should be stored: (/home/lbry/Uploads)
`npm run build` (or `npm run dev` to build for developing)
`npm run start` `npm run start`
## Try it ## Try it

6
package-lock.json generated
View file

@ -7650,6 +7650,12 @@
"integrity": "sha512-6qE4B9deFBIa9YSpOc9O0Sgc43zTeVYbgDT5veRKSlB2+ZuHNoVVxA1L/ckMUayV9Ay9y7Z/SZCLcGteW9i7bg==", "integrity": "sha512-6qE4B9deFBIa9YSpOc9O0Sgc43zTeVYbgDT5veRKSlB2+ZuHNoVVxA1L/ckMUayV9Ay9y7Z/SZCLcGteW9i7bg==",
"dev": true "dev": true
}, },
"md5-file": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/md5-file/-/md5-file-4.0.0.tgz",
"integrity": "sha512-UC0qFwyAjn4YdPpKaDNw6gNxRf7Mcx7jC1UGCY4boCzgvU2Aoc1mOGzTtrjjLKhM5ivsnhoKpQVxKPp+1j1qwg==",
"dev": true
},
"md5.js": { "md5.js": {
"version": "1.3.5", "version": "1.3.5",
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz", "resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz",

View file

@ -104,6 +104,7 @@
"file-loader": "^2.0.0", "file-loader": "^2.0.0",
"har-validator": "^5.1.3", "har-validator": "^5.1.3",
"husky": "^1.1.3", "husky": "^1.1.3",
"md5-file": "^4.0.0",
"mini-css-extract-plugin": "^0.5.0", "mini-css-extract-plugin": "^0.5.0",
"mocha": "^5.2.0", "mocha": "^5.2.0",
"ndb": "^1.0.26", "ndb": "^1.0.26",

View file

@ -50,8 +50,11 @@ export default (req, res) => {
saga = false, saga = false,
} = httpContext.get('routeData'); } = httpContext.get('routeData');
const runSaga = (action !== false && saga !== false); if (action === 'fallback') {
res.status(404);
}
const runSaga = (action !== false && saga !== false);
const renderPage = (store) => { const renderPage = (store) => {
// Workaround, remove when a solution for async httpContext exists // Workaround, remove when a solution for async httpContext exists
@ -63,7 +66,7 @@ export default (req, res) => {
} else { } else {
const channelKeys = Object.keys(showState.channelList); const channelKeys = Object.keys(showState.channelList);
if(channelKeys.length !== 0) { if (channelKeys.length !== 0) {
res.claimId = showState.channelList[channelKeys[0]].longId; res.claimId = showState.channelList[channelKeys[0]].longId;
res.isChannel = true; res.isChannel = true;
} }
@ -115,10 +118,16 @@ export default (req, res) => {
.then(() => { .then(() => {
// redirect if request does not use canonical url // redirect if request does not use canonical url
const canonicalUrl = getCanonicalUrlFromShow(store.getState().show); const canonicalUrl = getCanonicalUrlFromShow(store.getState().show);
if (!canonicalUrl) {
res.status(404);
}
if (canonicalUrl && canonicalUrl !== req.originalUrl) { if (canonicalUrl && canonicalUrl !== req.originalUrl) {
console.log(`redirecting ${req.originalUrl} to ${canonicalUrl}`); console.log(`redirecting ${req.originalUrl} to ${canonicalUrl}`);
res.redirect(canonicalUrl); res.redirect(canonicalUrl);
} }
return renderPage(store) return renderPage(store)
}); });
} else { } else {

View file

@ -1,3 +1,10 @@
const md5File = require('md5-file');
const path = require('path');
const bundlePath = path.resolve('./public/bundle/bundle.js');
const bundleHash = md5File.sync(bundlePath);
const shortBundleHash = bundleHash.substring(0,4);
module.exports = (helmet, html, preloadedState) => { module.exports = (helmet, html, preloadedState) => {
// take the html and preloadedState and return the full page // take the html and preloadedState and return the full page
return ` return `
@ -22,7 +29,7 @@ module.exports = (helmet, html, preloadedState) => {
<script> <script>
window.__PRELOADED_STATE__ = ${JSON.stringify(preloadedState).replace(/</g, '\\\u003c')} window.__PRELOADED_STATE__ = ${JSON.stringify(preloadedState).replace(/</g, '\\\u003c')}
</script> </script>
<script src="/bundle/bundle.js"></script> <script src="/bundle/bundle.js?${shortBundleHash}"></script>
</body> </body>
</html> </html>
`; `;

View file

@ -22,7 +22,7 @@ module.exports = async (data) => {
let lbrynetFileExt = null; let lbrynetFileExt = null;
if (!data.fileExt) { if (!data.fileExt) {
lbrynetClaimResult = await getClaim(lbrynetUri).catch(() => { return 'invalid URI' }); lbrynetClaimResult = await getClaim(lbrynetUri).catch(() => { return 'invalid URI' });
lbrynetFileExt = lbrynetClaimResult && lbrynetClaimResult.file_name.split('.').slice(-1).pop(); lbrynetFileExt = lbrynetClaimResult && lbrynetClaimResult.file_name && lbrynetClaimResult.file_name.split('.').slice(-1).pop();
} }
// TODO verify that "generated_x" does anything at all // TODO verify that "generated_x" does anything at all

View file

@ -19,7 +19,7 @@ const addAliasesForCustomComponentFolder = (name, aliasObject) => {
for (let i = 0; i < components.length; i++) { for (let i = 0; i < components.length; i++) {
let folderName = components[i]; let folderName = components[i];
let aliasName = `@${name}/${folderName}`; let aliasName = `@${name}/${folderName}`;
aliasObject[aliasName] = resolve(`${CUSTOM_ROOT}/${name}/${folderName}/index.js`); aliasObject[aliasName] = resolve(`${CUSTOM_ROOT}/${name}/${folderName}/`);
} }
return aliasObject; return aliasObject;
}; };