diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..95af295c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,44 @@ +sudo: true +dist: xenial +#addons: +# apt: +# sources: +# - mysql-5.7-trusty +# packages: +# - mysql-server +# - mysql-client +language: node_js +node_js: + - "lts/*" +cache: + directories: + - "node_modules" +#services: +# - mysql + +jobs: + include: + - stage: "Build" + name: "Build and run test environment" + + before_install: + # - sudo mysql -e "use mysql; update user set authentication_string=PASSWORD('password') where User='root'; update user set plugin='mysql_native_password';FLUSH PRIVILEGES;" + # - sudo mysql_upgrade -u root -ppassword + # - sudo service mysql restart + # - mysql -u root -ppassword -e 'CREATE DATABASE IF NOT EXISTS lbry;' + # - mysql -u root -ppassword -e "CREATE USER 'lbry'@'localhost' IDENTIFIED BY 'lbry';" + # - mysql -u root -ppassword -e "GRANT ALL ON lbry.* TO 'lbry'@'localhost';" + # - sudo service mysql restart + - dpkg --compare-versions `npm -v` ge 6.4.0 || npm i -g npm@^6.4.0 + + install: + - npm i + + script: + - cp ./cli/defaults/* ./site/config/ + - | + echo '{ "sessionKey": "session", "masterPassword": false }' > ./site/private/authConfig.json + # - npm run fix + - npm run build + - npm start & + - sleep 10 # Attempt to collect output for 10 seconds diff --git a/README.md b/README.md index 2e505ab2..64d44cb6 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ For a closed, custom-hosted and branded example, check out https://lbry.theantim #### Get some information ready: * mysqlusername * mysqlpassword - * domainname or 'http://localhost' + * domainname or 'http://localhost:3000' * speechport = 3000 #### Install and Set Up Dependencies @@ -31,10 +31,10 @@ For a closed, custom-hosted and branded example, check out https://lbry.theantim * 3333 * 4444 * [NodeJS](https://nodejs.org) - * [MySQL](https://dev.mysql.com/doc/refman/8.0/en/installing.html) + * [MySQL version 5.7 or higher](https://dev.mysql.com/doc/refman/8.0/en/installing.html) * mysqlusername or root * mysqlpassword - * You may need + * Requires mysql_native_password plugin ``` mysql> `ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'yourpassword';` ``` @@ -89,7 +89,7 @@ $ npm run start ``` #### View in browser - * Visit [http://localhost:3000](http://localhost:3000) in your browser + * Visit [http://localhost:3000](http://localhost:3000) in your browser #### Customize your app diff --git a/client/src/containers/AssetInfo/view.jsx b/client/src/containers/AssetInfo/view.jsx index 6876d8a1..8b76b907 100644 --- a/client/src/containers/AssetInfo/view.jsx +++ b/client/src/containers/AssetInfo/view.jsx @@ -9,6 +9,8 @@ import HorizontalSplit from '@components/HorizontalSplit'; import siteConfig from '@config/siteConfig.json'; import createCanonicalLink from '../../../../utils/createCanonicalLink'; import AssetInfoFooter from '../../components/AssetInfoFooter/index'; +import { createPermanentURI } from '@clientutils/createPermanentURI'; + const { details: { host } } = siteConfig; class AssetInfo extends React.Component { @@ -121,7 +123,7 @@ class AssetInfo extends React.Component { content={ } /> @@ -142,7 +144,7 @@ class AssetInfo extends React.Component { LBRY URL diff --git a/client/src/containers/PublishTool/index.js b/client/src/containers/PublishTool/index.js index 0e0d4b4f..335553d9 100644 --- a/client/src/containers/PublishTool/index.js +++ b/client/src/containers/PublishTool/index.js @@ -1,14 +1,14 @@ import {connect} from 'react-redux'; import View from './view'; import {selectAsset} from '../../selectors/show'; -import {buildURI} from '../../utils/buildURI'; +import {createPermanentURI} from '@clientutils/createPermanentURI'; const mapStateToProps = props => { const { show, publish } = props; const asset = selectAsset(show); let uri; if (asset) { - uri = `lbry://${buildURI(asset)}`; + uri = `lbry://${createPermanentURI(asset)}`; } return { disabled : publish.disabled, diff --git a/client/src/utils/buildURI.js b/client/src/utils/buildURI.js deleted file mode 100644 index b6fb599c..00000000 --- a/client/src/utils/buildURI.js +++ /dev/null @@ -1,10 +0,0 @@ -export const buildURI = asset => { - let channelName, certificateId, name, claimId; - if (asset.claimData) { - ({ channelName, certificateId, name, claimId } = asset.claimData); - } - if (channelName) { - return `${channelName}:${certificateId}/${name}`; - } - return `${claimId}/${name}`; -}; diff --git a/client/src/utils/createPermanentURI.js b/client/src/utils/createPermanentURI.js new file mode 100644 index 00000000..10f570e4 --- /dev/null +++ b/client/src/utils/createPermanentURI.js @@ -0,0 +1,24 @@ +/* +{ channelName, certificateId, name, claimId } = { claimData } = asset + +permanentUrl for a channel +@channelName#certificateId + +permanentUrl for an asset in a channel +@channelName#certificateId/name + +permanentUrl for an asset published anonymously +name#claimId +*/ + +export const createPermanentURI = asset => { + let channelName, certificateId, name, claimId; + if (asset.claimData) { + ({ channelName, certificateId, name, claimId } = asset.claimData); + } + else return 'Error: unknown asset at createPermanentURI.js'; + if (channelName) { + return `${channelName}#${certificateId}/${name}`; + } + return `${name}#${claimId}`; +}; diff --git a/docs/ubuntuinstall.md b/docs/ubuntuinstall.md index 9f1f98aa..454cb327 100644 --- a/docs/ubuntuinstall.md +++ b/docs/ubuntuinstall.md @@ -6,23 +6,23 @@ * Ability to use SSH (putty + public key for windows users) * Ubuntu 16.04 or 18.04 VPS with root access * Your login info ready + * Exposed ports: 22, 80, 443, 3333, 4444 * Domain name with @ and www pointed at your VPS IP - * alternatively, specify http://localhost + * _alternatively, specify http://localhost:3000 as domain during speech configuration_ * Ability to send 5+ LBRY credits to an address * Noncommercial use - * _(configuration examples for nginx and certbot are included as an alternative)_ + * _alternative configuration examples for nginx and certbot are [here](https://github.com/lbryio/spee.ch/tree/master/docs/setup/conf/nginx)_ ## You'll be installing: - * MySQL DB + * MySQL DB version 5.7 or higher * Default Port 3306 + * mysql_native_password plugin * NodeJS v8+ - * Https proxy server - * Caddy for personal use - * Exposed ports: 22, 80, 443, 3333, 4444 - * Reverse proxies 80 redirected to 443 to App on 3000 - * Spee.ch started on port 3000 + * Caddy - https reverse proxy server + * automatically obtains tls certificate + * Redirects 80 (http) to 443 (https) to Speech on 3000 * Lbrynet DAEMON started on ports 3333 and 4444 - + * Spee.ch started on port 3000 # 1. Setup OS and install dependencies ## OS @@ -184,15 +184,13 @@ tmux allows you to run multiple things in different sessions. Useful for manuall ## Detatch tmux session `Control + b`, then `d` -<<<<<<< Updated upstream * `tmux` if you want to get back into tmux * `Control+b`, then `)` while in tmux session to cycle back to your lbrynet session to see output -======= + `tmux` _note: `Control+b`, then `)` while in tmux session to cycle back to your lbrynet session to see output_ ->>>>>>> Stashed changes ## Display wallet address to which to send 5+ LBC. @@ -227,19 +225,17 @@ tmux allows you to run multiple things in different sessions. Useful for manuall `npm run configure` -<<<<<<< Updated upstream -======= (once your wallet balance has cleared) `npm run configure` ->>>>>>> Stashed changes + * Database: lbry * Username: root * Password: your_mysql_password * Port: 3000 * Site Title: Your Site Name - * Enter your site's domain name: https://example.com or http://localhost + * Enter your site's domain name: https://example.com or http://localhost:3000 * Enter a directory where uploads should be stored: (/home/lbry/Uploads) `npm run start` @@ -255,7 +251,7 @@ tmux allows you to run multiple things in different sessions. Useful for manuall npm install -g pm2 ``` -### 7 Maintenance Proceedures +### 7 Maintenance Procedures #### Change daemon * backup wallet (private keys!) to a safe place diff --git a/server/controllers/assets/utils/serveFile.js b/server/controllers/assets/utils/serveFile.js index 7344fdb2..8500dbe6 100644 --- a/server/controllers/assets/utils/serveFile.js +++ b/server/controllers/assets/utils/serveFile.js @@ -6,8 +6,10 @@ const serveFile = ({ filePath, fileType }, res) => { } const sendFileOptions = { headers: { - 'X-Content-Type-Options': 'nosniff', - 'Content-Type' : fileType, + 'X-Content-Type-Options' : 'nosniff', + 'Content-Type' : fileType, + 'Access-Control-Allow-Origin' : '*', + 'Access-Control-Allow-Headers': 'Origin, X-Requested-With, Content-Type, Accept', }, }; logger.debug(`fileOptions for ${filePath}:`, sendFileOptions); diff --git a/utils/createModuleAliases.js b/utils/createModuleAliases.js index b9129f47..00506bb9 100644 --- a/utils/createModuleAliases.js +++ b/utils/createModuleAliases.js @@ -34,6 +34,11 @@ module.exports = () => { moduleAliases['@config'] = resolve('site/config'); moduleAliases['@private'] = resolve('site/private'); + // aliases for utils + moduleAliases['@globalutils'] = resolve('utils'); + moduleAliases['@clientutils'] = resolve(`${DEFAULT_ROOT}/utils`); + // moduleAliases['@serverutils'] = resolve('server/utils'); + // create specific aliases for locally defined components in the following folders moduleAliases = addAliasesForCustomComponentFolder('containers', moduleAliases); moduleAliases = addAliasesForCustomComponentFolder('components', moduleAliases); @@ -48,6 +53,7 @@ module.exports = () => { moduleAliases['@sagas'] = resolve(`${DEFAULT_ROOT}/sagas`); moduleAliases['@app'] = resolve(`${DEFAULT_ROOT}/app.js`); + // return finished aliases return moduleAliases; };