Merge pull request #734 from lbryio/staging

Cut release from staging
This commit is contained in:
Shawn K 2018-11-12 14:22:56 -06:00 committed by GitHub
commit 23979f3d13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
55 changed files with 5234 additions and 12952 deletions

View file

@ -3,3 +3,4 @@ node_modules/
public/bundle public/bundle
server/render/build server/render/build
test/ test/
server/chainquery

View file

@ -1,4 +1,5 @@
{ {
"parser": "babel-eslint",
"extends": ["standard", "standard-jsx"], "extends": ["standard", "standard-jsx"],
"env": { "env": {
"es6": true, "es6": true,
@ -13,15 +14,13 @@
"no-multi-spaces": 0, "no-multi-spaces": 0,
"new-cap": 0, "new-cap": 0,
"prefer-promise-reject-errors": 0, "prefer-promise-reject-errors": 0,
"comma-dangle": [ "no-unused-vars": 0,
"error", "standard/object-curly-even-spacing": 0,
"always-multiline" "handle-callback-err": 0,
], "one-var": 0,
"semi": [ "object-curly-spacing": 0,
"error", "comma-dangle": ["error", "always-multiline"],
"always", "semi": ["error", "always", { "omitLastInOneLineBlock": true }],
{ "omitLastInOneLineBlock": true }
],
"key-spacing": [ "key-spacing": [
"error", "error",
{ {

View file

@ -40,7 +40,7 @@ Spee.ch is a react web app that depends on MySQL for local content, and on two o
* [FFmpeg](https://www.ffmpeg.org/download.html) * [FFmpeg](https://www.ffmpeg.org/download.html)
* [Spee.ch] (below) * [Spee.ch] (below)
* [pm2] (optional) process manager such as pm2 to run speech server.js * [pm2] (optional) process manager such as pm2 to run speech server.js
* [http proxy server] caddy, nginx, traefik, etc to forward 443 to speech port 3000 * [http proxy server] caddy, nginx, traefik, etc to forward 80/443 to speech port 3000
#### Clone this repo #### Clone this repo
@ -67,22 +67,12 @@ $ npm install
#### Create the config files using the built-in CLI #### Create the config files using the built-in CLI
_note: make sure lbrynet is running in the background before proceeding_ _note: make sure lbrynet is running in the background before proceeding_
_note: If you are opt to run a local chainquery, such as from [lbry-docker/chainquery](https://github.com/lbryio/lbry-docker/tree/master/chainquery) you will need to specify connection details at this time in:_ ~/spee.ch/docs/setup/conf/speech/chainqueryConfig.json
``` ```
$ npm run configure $ npm run configure
``` ```
* _note: At the moment, you will have to copy chainqueryConfig.json from:_
```
~/spee.ch/docs/setup/conf/speech/chainqueryConfig.json
```
_to:_
```
~/spee.ch/site/config/chainqueryConfig.json
```
* _note: The domain name in this part must be prefixed with http:// or https://_
#### Build & start the app #### Build & start the app
_note: make sure lbrynet is running in the background before proceeding_ _note: make sure lbrynet is running in the background before proceeding_

View file

@ -13,7 +13,7 @@ export function onHandleShowPageUri (params, url) {
data: { data: {
...params, ...params,
url, url,
} },
}; };
} }
@ -23,7 +23,7 @@ export function onHandleShowHomepage (params, url) {
data: { data: {
...params, ...params,
url, url,
} },
}; };
} }

View file

@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import Row from '@components/Row'; import Row from '@components/Row';
import {Link} from "react-router-dom"; import {Link} from 'react-router-dom';
const AboutSpeechDetails = () => { const AboutSpeechDetails = () => {
return ( return (

View file

@ -20,6 +20,6 @@ const ChooseChannelPublishRadio = ({ publishInChannel, toggleAnonymousPublish })
</label> </label>
</div> </div>
); );
} };
export default ChooseChannelPublishRadio; export default ChooseChannelPublishRadio;

View file

@ -6,6 +6,6 @@ const DropzoneDropItDisplay = () => {
Drop it. Drop it.
</div> </div>
); );
} };
export default DropzoneDropItDisplay; export default DropzoneDropItDisplay;

View file

@ -8,5 +8,5 @@ const Label = ({ value }) => {
{value} {value}
</label> </label>
); );
} };
export default Label; export default Label;

View file

@ -1,6 +1,5 @@
import React from 'react'; import React from 'react';
import AssetPreview from '@components/AssetPreview'; import AssetPreview from '@components/AssetPreview';
import HorizontalQuadSplit from '@components/HorizontalQuadSplit';
import Row from '@components/Row'; import Row from '@components/Row';
import ButtonSecondary from '@components/ButtonSecondary'; import ButtonSecondary from '@components/ButtonSecondary';
import { createGroupedList } from '../../utils/createGroupedList.js'; import { createGroupedList } from '../../utils/createGroupedList.js';

View file

@ -1,7 +1,7 @@
import {connect} from 'react-redux'; import {connect} from 'react-redux';
import View from './view'; import View from './view';
import {selectAsset} from "../../selectors/show"; import {selectAsset} from '../../selectors/show';
import {buildURI} from "../../utils/buildURI"; import {buildURI} from '../../utils/buildURI';
const mapStateToProps = props => { const mapStateToProps = props => {
const { show, publish } = props; const { show, publish } = props;

View file

@ -14,20 +14,20 @@ class FaqPage extends React.Component {
</Row> </Row>
<Row> <Row>
<h3>What is spee.ch?</h3> <h3>What is spee.ch?</h3>
<p>Spee.ch is a media-hosting site that reads from and publishes content to the <a href="http://lbry.io/">LBRY blockchain</a>.</p> <p>Spee.ch is a media-hosting site that reads from and publishes content to the <a href='http://lbry.io/'>LBRY blockchain</a>.</p>
</Row> </Row>
<Row> <Row>
<h3>OK But Why Should I Care?</h3> <h3>OK But Why Should I Care?</h3>
<p>Spee.ch is a fast and easy way to host your images, videos, and other content. What makes this different from other similar sites is that Speech is hosted on the LBRY blockchain. That means it is impossible for your content to be censored via digital means. Even if we took down Speech today, all content would remain immutably stored on the LBRY blockchain.</p> <p>Spee.ch is a fast and easy way to host your images, videos, and other content. What makes this different from other similar sites is that Speech is hosted on the LBRY blockchain. That means it is impossible for your content to be censored via digital means. Even if we took down Speech today, all content would remain immutably stored on the LBRY blockchain.</p>
<p>Blockchain technology doesnt solve <a href="https://xkcd.com/538/">the 5 dollar wrench attack</a>, but it solves just about every other problem in media hosting and distribution.</p> <p>Blockchain technology doesnt solve <a href='https://xkcd.com/538/'>the 5 dollar wrench attack</a>, but it solves just about every other problem in media hosting and distribution.</p>
<p>Even better - you can host your own clone of Speech to get even more control over your content. <a href="https://github.com/lbryio/spee.ch/blob/master/README.md">CLICK HERE FOR INFO</a>.</p> <p>Even better - you can host your own clone of Speech to get even more control over your content. <a href='https://github.com/lbryio/spee.ch/blob/master/README.md'>CLICK HERE FOR INFO</a>.</p>
<p>Speech is just the beginning of what will soon be a vibrant ecosystem of LBRY-powered apps. Use LBRY and youre one step closer to true freedom.</p> <p>Speech is just the beginning of what will soon be a vibrant ecosystem of LBRY-powered apps. Use LBRY and youre one step closer to true freedom.</p>
</Row> </Row>
<Row> <Row>
<h3>How to Use spee.ch</h3> <h3>How to Use spee.ch</h3>
<p>Its easy. Drag the image or video file of your choice into the center of the spee.ch homepage.</p> <p>Its easy. Drag the image or video file of your choice into the center of the spee.ch homepage.</p>
<p>Spee.ch is currently best suited for web optimized MP4 video and standard image filetypes (JPEG, GIF).</p> <p>Spee.ch is currently best suited for web optimized MP4 video and standard image filetypes (JPEG, GIF).</p>
<p>If you want to refer to a piece of content repeatedly, or to build a collection of related content, you could create a channel. Channels work both for private collections and for public repositories. Theres more info about how to do this <a href="https://spee.ch/login">on the channel page</a>.</p> <p>If you want to refer to a piece of content repeatedly, or to build a collection of related content, you could create a channel. Channels work both for private collections and for public repositories. Theres more info about how to do this <a href='https://spee.ch/login'>on the channel page</a>.</p>
<p>Published files will be wiewable and embeddable with any web browser and accesible in the LBRY app. You can also use spee.ch to view free and non-NSFW content published on LBRY network from LBRY app. You just need to replace "lbry://" with "http://spee.ch/" in the URL.</p> <p>Published files will be wiewable and embeddable with any web browser and accesible in the LBRY app. You can also use spee.ch to view free and non-NSFW content published on LBRY network from LBRY app. You just need to replace "lbry://" with "http://spee.ch/" in the URL.</p>
</Row> </Row>
<Row> <Row>
@ -36,8 +36,8 @@ class FaqPage extends React.Component {
</Row> </Row>
<Row> <Row>
<h3>Contribute</h3> <h3>Contribute</h3>
<p>If you have an idea for your own spee.ch-like site on top of LBRY, fork our <a href="https://github.com/lbryio/spee.ch">github repo</a> and go to town!</p> <p>If you have an idea for your own spee.ch-like site on top of LBRY, fork our <a href='https://github.com/lbryio/spee.ch'>github repo</a> and go to town!</p>
<p>If you want to improve spee.ch, join <a href="https://chat.lbry.io/">our discord channel</a> or solve one of our <a href="https://github.com/lbryio/spee.ch/issues">github issues</a>.</p> <p>If you want to improve spee.ch, join <a href='https://chat.lbry.io/'>our discord channel</a> or solve one of our <a href='https://github.com/lbryio/spee.ch/issues'>github issues</a>.</p>
</Row> </Row>
</PageLayout> </PageLayout>
); );

View file

@ -16,7 +16,7 @@ class PopularPage extends React.Component {
const { homeChannel } = this.props; const { homeChannel } = this.props;
return ( return (
<ContentPageWrapper homeChannel={homeChannel} /> <ContentPageWrapper homeChannel={homeChannel} />
) );
} }
}; };

View file

@ -61,7 +61,7 @@ export function * newAssetRequest (action) {
if (loggedInChannel && loggedInChannel.longId) { if (loggedInChannel && loggedInChannel.longId) {
const { const {
data: claimViewData data: claimViewData,
} = yield call(getClaimViews, longId); } = yield call(getClaimViews, longId);
claimViews = claimViewData[longId] || 0; claimViews = claimViewData[longId] || 0;
@ -93,7 +93,7 @@ export function * updateAssetViews (action) {
if (longId) { if (longId) {
const { const {
data: claimViewData data: claimViewData,
} = yield call(getClaimViews, longId); } = yield call(getClaimViews, longId);
claimViews = claimViewData[longId] || 0; claimViews = claimViewData[longId] || 0;
@ -103,12 +103,12 @@ export function * updateAssetViews (action) {
} }
} }
} catch (error) { } catch (error) {
console.log(error) console.log(error);
} }
}; };
export function * watchUpdateAssetViews (action) { export function * watchUpdateAssetViews (action) {
yield takeLatest(channelActions.CHANNEL_UPDATE, updateAssetViews) yield takeLatest(channelActions.CHANNEL_UPDATE, updateAssetViews);
}; };
export function * watchNewAssetRequest () { export function * watchNewAssetRequest () {

View file

@ -30,8 +30,8 @@ function * parseAndUpdateIdentifierAndClaim (modifier, claim) {
} }
function * parseAndUpdateClaimOnly (claim) { function * parseAndUpdateClaimOnly (claim) {
if(/^special\:/.test(claim) === true) { if (/^special:/.test(claim) === true) {
const assetName = /special\:(.*)/.exec(claim)[1]; const assetName = /special:(.*)/.exec(claim)[1];
return yield call(newSpecialAssetRequest, onNewSpecialAssetRequest(assetName)); return yield call(newSpecialAssetRequest, onNewSpecialAssetRequest(assetName));
} else { } else {
// this could be a request for an asset or a channel page // this could be a request for an asset or a channel page

View file

@ -1,261 +0,0 @@
# Create Your Own Spee.ch on Ubuntu 16.x 18.x VPS
# Overview
## Prerequisites
* UBUNTU 16+ VPS with root access
* Your login info ready
* Domain name with @ and www pointed at your VPS IP
* Email Address
* Ability to send 5+ LBRY credits to an address
* Noncommercial use (highly suggested, but you still _could_)
* We recommend that you fork Spee.ch so that you can customize the site.
## You'll be installing:
* MYSQL DB
* Default Port
* NODE v8+
* HTTPS PROXY SERVER
* Caddy for personal use
* Exposed ports: 22, 80, 443, 3333, 4444
* Reverse proxies to App on 3000
* SPEE.CH
* LBRYNET DAEMON
# 1. Update OS and install packages
## OS
`sudo apt-get update -y`
`ulimit -n 8192`
## Git
`sudo apt-get install git -y`
## NODE v8
`wget -qO- https://deb.nodesource.com/setup_8.x | sudo -E bash -`
`sudo apt-get install -y nodejs`
## Curl, Tmux, Unzip, ffmpeg
`sudo apt-get install curl tmux unzip ffmpeg -y`
## Grab config files
`git clone https://github.com/jessopb/speechconfigs.git`
`chmod 640 -R ~/speechconfigs`
# 2 Secure the UFW firewall
## UFW
`sudo ufw status`
`sudo ufw allow 80`
`sudo ufw allow 443`
`sudo ufw allow 22`
`sudo ufw allow 3333`
`sudo ufw allow 4444`
`sudo ufw default allow outgoing`
`sudo ufw default deny incoming`
`sudo ufw show added`
`sudo ufw enable` (yes, you've allowed ssh 22)
`sudo ufw status`
# 3 Install Caddy to handle https and reverse proxy
## Get Caddy
`curl https://getcaddy.com | bash -s personal`
## Set up Caddy
`mkdir -p /opt/caddy/logs/`
`mkdir -p /opt/caddy/store/`
`cp ~/speechconfigs/caddy/Caddyfile.speechsample ~/speechconfigs/caddy/Caddyfile`
`nano ~/speechconfigs/caddy/Caddyfile`
( Change {{EXAMPLE.COM}} to YOURDOMAIN.COM )
`cp ~/speechconfigs/caddy/Caddyfile /opt/caddy/`
## Set up Caddy to run as systemd service
`cp ~/speechconfigs/caddy/caddy.service /etc/systemd/system/caddy.service`
`chmod 644 /etc/systemd/system/caddy.service`
`chown -R www-data:www-data /opt/caddy/`
`setcap 'cap_net_bind_service=+ep' /usr/local/bin/caddy`
`systemctl daemon-reload`
`systemctl start caddy`
`systemctl status caddy`
At this point, navigating to yourdomain.com should give you a 502 bad gateway error. That's good!
# 4 Set up MySql
## Install MySql
`sudo apt-get install mysql-server -y`
( enter blank password each time )
`sudo systemctl status mysql` (q to exit)
## Secure Setup
`sudo mysql_secure_installation`
* No to password validation
* Y to all other options
* password abcd1234
## Login to mysql from root to complete setup:
`mysql` to enter mysql> console
mysql> `ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'abcd1234';`
mysql> `FLUSH PRIVILEGES;`
Control+D to exit
Verify:
`mysql -u root -p` and then entering your password abcd1234 should give you the mysql> shell
# 5 Get Lbrynet Daemon
### TODO: Enable something like sudo systemctl start lbrynet so it runs as www-data
## Enter tmux
`tmux`
* Ctrl+b, d detaches leaving session running.
* ~# `tmux`, Ctrl+b, ( goes back to that session.
## Get the daemon
`wget -O ~/latest_daemon.zip https://lbry.io/get/lbrynet.linux.zip`
`unzip -o -u ~/latest_daemon.zip`
## Start the daemon
~# `./lbrynet start`
## Detatch tmux session
`Control+b, then d` to leave lbrynet daemon running and exit the session
`tmux` if you want to get back into tmux
`Control+b, then ) in tmux` to cycle back to your lbrynet session to see output
## Display wallet address to which to send 5+ LBC.
### These commands work when `lbrynet start` is already running in another tmux
`./lbrynet commands` to check out the current commands
`./lbrynet address_list` to get your wallet address
`Ctrl + Shift + C` after highlighting an address to copy.
Use a LBRY app or daemon to send LBC to the address. Sending LBC may take a few seconds or longer.
`./lbrynet account_balance` to check your balance after you've sent LBC.
# 6 Set up spee.ch
## Clone speech either from your own fork, or from the lbryio/spee.ch repo.
### Developers
SSH?
`git clone git@github.com:{{youraccount}}/spee.ch`
HTTPS?
`git clone https://github.com/{{youraccount}}/spee.ch.git`
### Publishers
`git clone -b release https://github.com/lbryio/spee.ch`
## Build it
`cd spee.ch`
~/spee.ch# `npm install`
`cp ~/speechconfigs/speech/chainqueryConfig.json ~/spee.ch/site/config/chainqueryConfig.json`
~/spee.ch# `npm run configure` (once your wallet balance has cleared)
* DATABASE: lbry
* USER NAME: root
* PASSWORD: abcd1234
* PORT: 3000
* Site Title: Your Site Name
* Enter your site's domain name: https://freezepeach.fun (this must include https://)
* Enter a directory where uploads should be stored: (/home/lbry/Uploads)
~/spee.ch/# `npm run start`
## Try it
Navigate to yourdomain.fun!
### 7 Maintenance Proceedures
* Change wallet
* TODO
* Change daemon
* wget daemon from https://github.com/lbryio/lbry/releases
* wget --quiet -O ~/your_name_daemon.zip https://your_copied_file_path.zip
* rm ./lbrynet
* unzip -o -u ~/your_name_daemon.zip
### 7 TODO
* Don't run as root
* Use Dockerized Spee.ch and Lbrynet
* https://github.com/lbryio/lbry-docker/tree/master/www.spee.ch
* https://github.com/lbryio/lbry-docker/tree/master/lbrynet-daemon
* https://blog.hasura.io/an-exhaustive-guide-to-writing-dockerfiles-for-node-js-web-apps-bbee6bd2f3c4
* https://docs.traefik.io/user-guide/docker-and-lets-encrypt/
* https://docs.traefik.io/configuration/acme/
* Systemd unit files
* https://nodesource.com/blog/running-your-node-js-app-with-systemd-part-1/
* Spee.ch
* sudo nano /lib/systemd/system/speech.service
* Lbrynet
* sudo nano /lib/systemd/system/lbrynet.service
```
[Unit]
Description=hello_env.js - making your environment variables read
Documentation=https://example.com
After=network.target
[Service]
Environment=NODE_PORT=3001
Type=simple
User=ubuntu
ExecStart=node path/server.js
Restart=on-failure
[Install]
WantedBy=multi-user.target
```
* Provide spee.ch build releases?
* Provide system to configure chainqueryConfig.json
* Clone speech to stripped version, streamline customization
* Automate for testing

View file

@ -19,12 +19,12 @@
* Https proxy server * Https proxy server
* Caddy for personal use * Caddy for personal use
* Exposed ports: 22, 80, 443, 3333, 4444 * Exposed ports: 22, 80, 443, 3333, 4444
* Reverse proxies 443 to App on 3000 * Reverse proxies 80 redirected to 443 to App on 3000
* Spee.ch started on port 3000 * Spee.ch started on port 3000
* Lbrynet DAEMON started on ports 3333 and 4444 * Lbrynet DAEMON started on ports 3333 and 4444
# 1. Update OS and install packages # 1. Setup OS and install dependencies
## OS ## OS
### Secure your server by creating a non-root sudoer. ### Secure your server by creating a non-root sudoer.
@ -59,25 +59,21 @@ Log in as username@domainname or username@ip_address
## Clone speech either from your own fork, or from the lbryio/spee.ch repo. ## Clone speech either from your own fork, or from the lbryio/spee.ch repo.
### For Developers or those with their own forked repo * For Developers - our master branch
`git clone https://github.com/lbryio/spee.ch`
`git clone -b master https://github.com/lbryio/spee.ch` * For Developers - your fork
SSH:
`git clone git@github.com:{{youraccount}}/spee.ch`
HTTPS:
`git clone https://github.com/{{youraccount}}/spee.ch.git` `git clone https://github.com/{{youraccount}}/spee.ch.git`
### For Publishers and Content creators `git clone git@github.com:{{youraccount}}/spee.ch`
* For Publishers and Content creators - stable release
`git clone -b release https://github.com/lbryio/spee.ch` `git clone -b release https://github.com/lbryio/spee.ch`
### Prepare the scripts ## Prepare the scripts
`chmod 750 -R ~/spee.ch/docs/setup` `chmod 750 -R ~/spee.ch/docs/setup`
@ -181,9 +177,9 @@ This just allows you to run multiple things in different sessions. Useful for ma
## Detatch tmux session ## Detatch tmux session
* `Control + b`, then `d` to leave lbrynet daemon running and exit the session * `Control + b`, then `d` to leave lbrynet daemon running and exit the session
`tmux` if you want to get back into tmux * `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 * `Control+b`, then `)` while in tmux session to cycle back to your lbrynet session to see output
## Display wallet address to which to send 5+ LBC. ## Display wallet address to which to send 5+ LBC.
@ -212,22 +208,25 @@ This just allows you to run multiple things in different sessions. Useful for ma
`npm install` `npm install`
`cp ~/spee.ch/docs/setup/conf/speech/chainqueryConfig.json ~/spee.ch/site/config/chainqueryConfig.json` _note: if you have installed your own local chainquery instance, you will need to specify it in your own /site/config/chainqueryConfig.json_
Once your wallet has a balance, run this:
`npm run configure`
`npm run configure` (once your wallet balance has cleared)
* Database: lbry * Database: lbry
* Username: root * Username: root
* Password: abcd1234 * Password: abcd1234
* Port: 3000 * Port: 3000
* Site Title: Your Site Name * Site Title: Your Site Name
* Enter your site's domain name: https://freezepeach.fun (this must include 'https://') * Enter your site's domain name: https://example.com or http://localhost
* Enter a directory where uploads should be stored: (/home/lbry/Uploads) * Enter a directory where uploads should be stored: (/home/lbry/Uploads)
`npm run start` `npm run start`
## Try it ## Try it
Navigate to yourdomain.fun! Navigate to example.com!
# 7 Production # 7 Production

View file

@ -128,7 +128,7 @@ $ npm run configure
Check your site configs Check your site configs
``` ```
$ cd config/ $ cd /site/config/
$ nano siteConfig.json $ nano siteConfig.json
``` ```
@ -161,14 +161,3 @@ $ pm2 start server.js
``` ```
Visit your site and see if it is running! Visit your site and see if it is running!
### Sync Your Spee.ch Instance with the full **Blockchain**
Install **lbrycrdd**
Install **lbry-decoder**
Start **lbry-decoder**
Install & run [spee.ch-sync](https://github.com/billbitt/spee.ch-sync)

8981
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -11,7 +11,6 @@
"configure": "node cli/configure.js", "configure": "node cli/configure.js",
"fix": "eslint . --fix", "fix": "eslint . --fix",
"lint": "eslint .", "lint": "eslint .",
"precommit": "eslint .",
"prestart": "builder run bundle", "prestart": "builder run bundle",
"start": "node server.js", "start": "node server.js",
"start:build": "builder run start", "start:build": "builder run start",
@ -50,33 +49,33 @@
"axios": "^0.18.0", "axios": "^0.18.0",
"bcrypt": "^2.0.1", "bcrypt": "^2.0.1",
"body-parser": "^1.18.3", "body-parser": "^1.18.3",
"connect-multiparty": "^2.1.1", "connect-multiparty": "^2.2.0",
"cookie-session": "^2.0.0-beta.3", "cookie-session": "^2.0.0-beta.3",
"express": "^4.15.2", "express": "^4.16.4",
"express-handlebars": "^3.0.0", "express-handlebars": "^3.0.0",
"express-http-context": "^1.1.0", "express-http-context": "^1.2.0",
"get-video-dimensions": "^1.0.0", "get-video-dimensions": "^1.0.0",
"helmet": "^3.13.0", "helmet": "^3.15.0",
"image-size": "^0.6.3", "image-size": "^0.6.3",
"inquirer": "^5.2.0", "inquirer": "^5.2.0",
"ip": "^1.1.5", "ip": "^1.1.5",
"make-dir": "^1.3.0", "make-dir": "^1.3.0",
"module-alias": "^2.1.0", "module-alias": "^2.1.0",
"mysql2": "^1.6.1", "mysql2": "^1.6.4",
"npm": "^6.3.0", "npm": "^6.3.0",
"passport": "^0.4.0", "passport": "^0.4.0",
"passport-local": "^1.0.0", "passport-local": "^1.0.0",
"prop-types": "^15.6.2", "prop-types": "^15.6.2",
"react": "^16.4.2", "react": "^16.4.2",
"react-dom": "^16.4.2", "react-feather": "^1.1.4",
"react-feather": "^1.1.3", "react-dom": "^16.6.1",
"react-ga": "^2.5.3", "react-ga": "^2.5.3",
"react-helmet": "^5.2.0", "react-helmet": "^5.2.0",
"react-redux": "^5.0.6", "react-redux": "^5.1.1",
"react-router-dom": "^4.3.1", "react-router-dom": "^4.3.1",
"redux": "^4.0.0", "redux": "^4.0.1",
"redux-saga": "^0.16.0", "redux-saga": "^0.16.2",
"sequelize": "^4.38.0", "sequelize": "^4.41.1",
"sequelize-cli": "^4.0.0", "sequelize-cli": "^4.0.0",
"universal-analytics": "^0.4.20", "universal-analytics": "^0.4.20",
"webpack": "^3.10.0", "webpack": "^3.10.0",
@ -87,43 +86,49 @@
"winston-slack-webhook": "github:billbitt/winston-slack-webhook" "winston-slack-webhook": "github:billbitt/winston-slack-webhook"
}, },
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.0.0", "@babel/cli": "^7.1.5",
"@babel/core": "^7.0.0", "@babel/core": "^7.1.5",
"@babel/plugin-proposal-object-rest-spread": "^7.0.0", "@babel/plugin-proposal-object-rest-spread": "^7.0.0",
"@babel/polyfill": "^7.0.0", "@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.0.0", "@babel/preset-env": "^7.1.5",
"@babel/preset-react": "^7.0.0", "@babel/preset-react": "^7.0.0",
"@babel/preset-stage-2": "^7.0.0", "@babel/preset-stage-2": "^7.0.0",
"@babel/register": "^7.0.0", "@babel/register": "^7.0.0",
"babel-loader": "^7.1.2", "babel-loader": "^7.1.2",
"babel-plugin-module-resolver": "^3.1.1", "babel-plugin-module-resolver": "^3.1.1",
"babel-eslint": "9.0.0-beta.3",
"builder": "^4.0.0", "builder": "^4.0.0",
"chai": "^4.1.2", "chai": "^4.2.0",
"chai-http": "^4.0.0", "chai-http": "^4.2.0",
"cross-fetch": "^2.2.2", "cross-fetch": "^2.2.3",
"css-loader": "^0.28.11", "css-loader": "^0.28.11",
"eslint": "4.19.1", "eslint": "5.9.0",
"eslint-config-standard": "^11.0.0", "eslint-config-standard": "^12.0.0",
"eslint-config-standard-jsx": "^5.0.0", "eslint-config-standard-jsx": "^6.0.2",
"eslint-plugin-import": "^2.12.0", "eslint-plugin-import": "^2.14.0",
"eslint-plugin-node": "^6.0.1", "eslint-plugin-node": "^8.0.0",
"eslint-plugin-promise": "^3.8.0", "eslint-plugin-promise": "^4.0.1",
"eslint-plugin-react": "^7.9.1", "eslint-plugin-react": "^7.11.1",
"eslint-plugin-standard": "^3.0.1", "eslint-plugin-standard": "^4.0.0",
"extract-text-webpack-plugin": "^3.0.2", "extract-text-webpack-plugin": "^3.0.2",
"file-loader": "^1.1.11", "file-loader": "^1.1.11",
"husky": "^0.14.3", "husky": "^1.1.3",
"mocha": "^5.2.0", "mocha": "^5.2.0",
"ndb": "^1.0.24", "ndb": "^1.0.26",
"node-sass": "^4.9.3", "node-sass": "^4.10.0",
"nodemon": "^1.17.5", "nodemon": "^1.18.6",
"redux-devtools": "^3.4.1", "redux-devtools": "^3.4.1",
"regenerator-transform": "^0.13.0", "regenerator-transform": "^0.13.3",
"rollup": "^0.66.2", "rollup": "^0.67.0",
"sass-loader": "^7.1.0", "sass-loader": "^7.1.0",
"sequelize-cli": "^4.0.0", "sequelize-cli": "^4.0.0",
"style-loader": "^0.21.0", "style-loader": "^0.23.1",
"url-loader": "^1.0.1", "url-loader": "^1.1.2",
"wait-on": "^3.1.0" "wait-on": "^3.2.0"
},
"husky": {
"hooks": {
"pre-commit": "eslint ."
}
} }
} }

View file

@ -7,7 +7,7 @@ const claimAvailability = async (name) => {
const claimAddresses = additionalClaimAddresses || []; const claimAddresses = additionalClaimAddresses || [];
claimAddresses.push(primaryClaimAddress); claimAddresses.push(primaryClaimAddress);
// find any records where the name is used // find any records where the name is used
return await chainquery.claim return chainquery.claim
.findAll({ .findAll({
attributes: ['claim_address'], attributes: ['claim_address'],
where : { where : {

View file

@ -10,7 +10,6 @@ const db = require('server/models');
*/ */
const claimData = async ({ ip, originalUrl, body, params }, res) => { const claimData = async ({ ip, originalUrl, body, params }, res) => {
try { try {
const resolvedClaim = await fetchClaimData(params); const resolvedClaim = await fetchClaimData(params);

View file

@ -125,7 +125,7 @@ const claimPublish = ({ body, files, headers, ip, originalUrl, user, tor }, res)
if (channelName) { if (channelName) {
canonicalUrl = createCanonicalLink({ asset: { ...claimData, channelShortId: shortId } }); canonicalUrl = createCanonicalLink({ asset: { ...claimData, channelShortId: shortId } });
} else { } else {
canonicalUrl = createCanonicalLink({ asset: { ...claimData, shortId } }) canonicalUrl = createCanonicalLink({ asset: { ...claimData, shortId } });
} }
res.status(200).json({ res.status(200).json({

View file

@ -107,7 +107,6 @@ const claimUpdate = ({ body, files, headers, ip, originalUrl, user, tor }, res)
return [null, null]; return [null, null];
}) })
.then(([fileResult, resolution]) => { .then(([fileResult, resolution]) => {
metadata = Object.assign({}, { metadata = Object.assign({}, {
title : claimRecord.title, title : claimRecord.title,
description: claimRecord.description, description: claimRecord.description,
@ -164,7 +163,7 @@ const claimUpdate = ({ body, files, headers, ip, originalUrl, user, tor }, res)
if (channelName) { if (channelName) {
canonicalUrl = createCanonicalLink({ asset: { ...publishResult, channelShortId: shortId } }); canonicalUrl = createCanonicalLink({ asset: { ...publishResult, channelShortId: shortId } });
} else { } else {
canonicalUrl = createCanonicalLink({ asset: { ...publishResult, shortId } }) canonicalUrl = createCanonicalLink({ asset: { ...publishResult, shortId } });
} }
if (publishResult.error) { if (publishResult.error) {

View file

@ -28,7 +28,7 @@ const channelClaims = async ({ ip, originalUrl, body, params }, res) => {
previousPage : null, previousPage : null,
totalPages : 1, totalPages : 1,
totalResults : claims.length, totalResults : claims.length,
} },
}); });
} }

View file

@ -56,8 +56,6 @@ const getClaimIdAndServeAsset = (channelName, channelClaimId, claimName, claimId
ip, ip,
}); });
} }
return;
}); });
}) })
.then(() => { .then(() => {

View file

@ -12,24 +12,19 @@ const padSizes = {
const argumentProcessors = { const argumentProcessors = {
'bottom': async (config) => { 'bottom': async (config) => {
config.classNames.push('bottom'); config.classNames.push('bottom');
return;
}, },
'right': async (config) => { 'right': async (config) => {
config.classNames.push('right'); config.classNames.push('right');
return;
}, },
'pad': async (config, val) => { 'pad': async (config, val) => {
config.classNames.push(padSizes[val]); config.classNames.push(padSizes[val]);
return;
}, },
'logoClaim': async (config, val) => { 'logoClaim': async (config, val) => {
config.logoUrl = `${host}/${val}`; config.logoUrl = `${host}/${val}`;
return;
}, },
'link': async (config, val) => { 'link': async (config, val) => {
config.logoLink = val; config.logoLink = val;
return; },
}
}; };
const parseLogoConfigParam = async (rawConfig) => { const parseLogoConfigParam = async (rawConfig) => {
@ -66,7 +61,7 @@ const parseLogoConfigParam = async (rawConfig) => {
} }
return false; return false;
} };
const sendVideoEmbedPage = async ({ params }, res) => { const sendVideoEmbedPage = async ({ params }, res) => {
let { let {

View file

@ -24,7 +24,7 @@ const getClaimIdByChannel = async (channelName, channelClaimId, claimName) => {
const getClaimId = async (channelName, channelClaimId, name, claimId) => { const getClaimId = async (channelName, channelClaimId, name, claimId) => {
logger.debug(`getClaimId: ${channelName}, ${channelClaimId}, ${name}, ${claimId})`); logger.debug(`getClaimId: ${channelName}, ${channelClaimId}, ${name}, ${claimId})`);
if (channelName) { if (channelName) {
return await getClaimIdByChannel(channelName, channelClaimId, name); return getClaimIdByChannel(channelName, channelClaimId, name);
} else { } else {
let claimIdResult = await chainquery.claim.queries.getLongClaimId(name, claimId); let claimIdResult = await chainquery.claim.queries.getLongClaimId(name, claimId);

View file

@ -182,7 +182,7 @@ function Server () {
.then(() => { .then(() => {
logger.info('Spee.ch startup is complete'); logger.info('Spee.ch startup is complete');
setInterval(processTrending, 30 * 60000) // 30 minutes setInterval(processTrending, 30 * 60000); // 30 minutes
}) })
.catch(error => { .catch(error => {
if (error.code === 'ECONNREFUSED') { if (error.code === 'ECONNREFUSED') {

View file

@ -2,7 +2,7 @@ const fs = require('fs');
const logger = require('winston'); const logger = require('winston');
const { publishing: { publishingChannelWhitelist } } = require('@config/siteConfig'); const { publishing: { publishingChannelWhitelist } } = require('@config/siteConfig');
const ipBanFile = './config/ipBan.txt'; const ipBanFile = './site/config/ipBan.txt';
const forbiddenMessage = '<h1>Forbidden</h1>If you are seeing this by mistake, please contact us using <a href="https://chat.lbry.io/">https://chat.lbry.io/</a>'; const forbiddenMessage = '<h1>Forbidden</h1>If you are seeing this by mistake, please contact us using <a href="https://chat.lbry.io/">https://chat.lbry.io/</a>';
let ipCounts = {}; let ipCounts = {};
@ -39,7 +39,7 @@ const autoblockPublishMiddleware = (req, res, next) => {
delete ipCounts[ip]; delete ipCounts[ip];
} }
} }
}, 600000 /* 10 minute retainer */) }, 600000 /* 10 minute retainer */);
if (count === 10) { if (count === 10) {
logger.error(`Banning IP: ${ip}`); logger.error(`Banning IP: ${ip}`);
@ -51,19 +51,19 @@ const autoblockPublishMiddleware = (req, res, next) => {
} else { } else {
next(); next();
} }
} };
const autoblockPublishBodyMiddleware = (req, res, next) => { const autoblockPublishBodyMiddleware = (req, res, next) => {
if (req.body && publishingChannelWhitelist) { if (req.body && publishingChannelWhitelist) {
let ip = (req.headers['x-forwarded-for'] || req.connection.remoteAddress).split(/,\s?/)[0]; let ip = (req.headers['x-forwarded-for'] || req.connection.remoteAddress).split(/,\s?/)[0];
const { channelName } = req.body; const { channelName } = req.body;
if(channelName && publishingChannelWhitelist.indexOf(channelName) !== -1) { if (channelName && publishingChannelWhitelist.indexOf(channelName.toLowerCase()) !== -1) {
delete ipCounts[ip]; delete ipCounts[ip];
} }
} }
next(); next();
} };
module.exports = { module.exports = {
autoblockPublishMiddleware, autoblockPublishMiddleware,

View file

@ -15,7 +15,7 @@ function logMetricsMiddleware(req, res, next) {
referrer = /(.*?)#.*/.exec(referrer)[1]; referrer = /(.*?)#.*/.exec(referrer)[1];
} catch (e) { } catch (e) {
// Cheap forced string conversion & clamp // Cheap forced string conversion & clamp
referrer = new String(referrer); referrer = String(referrer);
referrer = referrer.substr(0, 255); referrer = referrer.substr(0, 255);
} }
@ -27,7 +27,7 @@ function logMetricsMiddleware(req, res, next) {
db.Metrics.create({ db.Metrics.create({
time : Date.now(), time : Date.now(),
isInternal: /node\-fetch/.test(userAgent), isInternal: /node-fetch/.test(userAgent),
isChannel : res.isChannel, isChannel : res.isChannel,
claimId : res.claimId, claimId : res.claimId,
routePath : httpContext.get('routePath'), routePath : httpContext.get('routePath'),

View file

@ -40,7 +40,7 @@ module.exports = (sequelize, { BOOLEAN, DATE, STRING }) => {
params: { params: {
type : STRING, type : STRING,
defaultValue: null, defaultValue: null,
} },
}, },
{ {
freezeTableName: true, freezeTableName: true,

View file

@ -55,7 +55,7 @@ module.exports = (sequelize, { BOOLEAN, DATE, FLOAT, INTEGER, STRING }) => {
Trending.getTrendingWeightData = async ({ Trending.getTrendingWeightData = async ({
hours = 2, hours = 2,
minutes = 0, minutes = 0,
limit = 20 limit = 20,
} = {}) => { } = {}) => {
let time = new Date(); let time = new Date();
time.setHours(time.getHours() - hours); time.setHours(time.getHours() - hours);
@ -65,9 +65,9 @@ module.exports = (sequelize, { BOOLEAN, DATE, FLOAT, INTEGER, STRING }) => {
const selectString = 'DISTINCT(claimId), weight'; const selectString = 'DISTINCT(claimId), weight';
const whereString = `isChannel = false and time > '${sqlTime}'`; const whereString = `isChannel = false and time > '${sqlTime}'`;
const query = `SELECT ${selectString} FROM Trending WHERE ${whereString} ORDER BY weight DESC LIMIT ${limit}` const query = `SELECT ${selectString} FROM Trending WHERE ${whereString} ORDER BY weight DESC LIMIT ${limit}`;
return await sequelize.query(query, { type: sequelize.QueryTypes.SELECT }); return sequelize.query(query, { type: sequelize.QueryTypes.SELECT });
}; };
Trending.getTrendingClaims = async () => { Trending.getTrendingClaims = async () => {
@ -77,7 +77,7 @@ module.exports = (sequelize, { BOOLEAN, DATE, FLOAT, INTEGER, STRING }) => {
const trendingClaims = trendingWeightData.reduce((claims, trendingData) => { const trendingClaims = trendingWeightData.reduce((claims, trendingData) => {
trendingClaimIds.push(trendingData.claimId); trendingClaimIds.push(trendingData.claimId);
claims[trendingData.claimId] = { claims[trendingData.claimId] = {
...trendingData ...trendingData,
}; };
return claims; return claims;

View file

@ -28,7 +28,7 @@ const getInformationFromValues = (numArr) => {
return { return {
mean, mean,
standardDeviation: getStandardDeviation(numArr, mean), standardDeviation: getStandardDeviation(numArr, mean),
} };
}; };
const getZScore = (value, mean, sDeviation) => (sDeviation !== 0 ? (value - mean) / sDeviation : 0); const getZScore = (value, mean, sDeviation) => (sDeviation !== 0 ? (value - mean) / sDeviation : 0);
@ -57,7 +57,6 @@ const getFastPValue = (zScore) => {
return sum; return sum;
}; };
const getWeight = (zScore, pValue) => (zScore * pValue); const getWeight = (zScore, pValue) => (zScore * pValue);
module.exports = { module.exports = {

View file

@ -59,8 +59,8 @@ module.exports = (sequelize, { BOOLEAN, DATE, STRING }) => {
claimId, claimId,
}, },
distinct: true, distinct: true,
col: 'ip' col : 'ip',
}) });
}; };
return Views; return Views;

View file

@ -26,8 +26,6 @@ const getTorList = require('../../controllers/api/tor');
const getBlockedList = require('../../controllers/api/blocked'); const getBlockedList = require('../../controllers/api/blocked');
const getOEmbedData = require('../../controllers/api/oEmbed'); const getOEmbedData = require('../../controllers/api/oEmbed');
module.exports = { module.exports = {
// homepage routes // homepage routes
'/api/homepage/data/channels' : { controller: [ torCheckMiddleware, channelData ] }, '/api/homepage/data/channels' : { controller: [ torCheckMiddleware, channelData ] },

View file

@ -28,5 +28,5 @@ module.exports = async (data) => {
thumbnail : data.generated_thumbnail || data.thumbnail_url || data.thumbnail, thumbnail : data.generated_thumbnail || data.thumbnail_url || data.thumbnail,
outpoint : data.transaction_hash_id || data.outpoint, outpoint : data.transaction_hash_id || data.outpoint,
host, host,
}) });
} };

View file

@ -3,4 +3,4 @@ module.exports = function(req) {
let host = req.get('host'); let host = req.get('host');
return reqIp === '127.0.0.1' || reqIp === '::ffff:127.0.0.1' || reqIp === '::1' || host.indexOf('localhost') !== -1; return reqIp === '127.0.0.1' || reqIp === '::ffff:127.0.0.1' || reqIp === '::1' || host.indexOf('localhost') !== -1;
} };

View file

@ -55,4 +55,4 @@ module.exports = async () => {
} catch (e) { } catch (e) {
logger.error('Error processing trending content:', e); logger.error('Error processing trending content:', e);
} }
} };

8288
yarn.lock

File diff suppressed because it is too large Load diff