Archived
commit prepotente
This commit is contained in:
+7
-3
@@ -1,4 +1,4 @@
|
|||||||
process.env['NODE_ENV'] = 'development';
|
process.env['NODE_ENV'] = 'production';
|
||||||
process.env.APIKEY = 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig';
|
process.env.APIKEY = 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig';
|
||||||
const express = require('express');
|
const express = require('express');
|
||||||
const compression = require('compression')
|
const compression = require('compression')
|
||||||
@@ -11,7 +11,6 @@ const app = express(); // app is an instance of express
|
|||||||
app.use(compression()); // enables gzip compression
|
app.use(compression()); // enables gzip compression
|
||||||
app.use(bodyParser.urlencoded({ extended: false })) // parse application/x-www-form-urlencoded
|
app.use(bodyParser.urlencoded({ extended: false })) // parse application/x-www-form-urlencoded
|
||||||
app.use(bodyParser.json()) // parse application/json
|
app.use(bodyParser.json()) // parse application/json
|
||||||
app.use(express.static(__dirname + '/build')); // serve static build site
|
|
||||||
|
|
||||||
|
|
||||||
app.get('/a', (req, res) => {
|
app.get('/a', (req, res) => {
|
||||||
@@ -23,7 +22,6 @@ res.send(process.env);
|
|||||||
// Create database instance and start server
|
// Create database instance and start server
|
||||||
// const adapter = new FileAsync(__dirname + '/db.json');
|
// const adapter = new FileAsync(__dirname + '/db.json');
|
||||||
low(new FileAsync(__dirname + '/db.json')) // production
|
low(new FileAsync(__dirname + '/db.json')) // production
|
||||||
// low(new FileAsync('/tmp/db.json')) // dev
|
|
||||||
.then(db => {
|
.then(db => {
|
||||||
db._.mixin(lodashId);
|
db._.mixin(lodashId);
|
||||||
// DATABASE ROUTES
|
// DATABASE ROUTES
|
||||||
@@ -46,6 +44,11 @@ low(new FileAsync(__dirname + '/db.json')) // production
|
|||||||
|
|
||||||
// ==============
|
// ==============
|
||||||
|
|
||||||
|
// GET /videotrack/:id?
|
||||||
|
app.get('/globpop', (req, res) => {
|
||||||
|
req.query.id ? res.send(req.query.id):res.status(400).send('Bad Request');
|
||||||
|
});
|
||||||
|
|
||||||
// GET /videotrack/:id?
|
// GET /videotrack/:id?
|
||||||
app.get('/videotrack/:id?', (req, res) => {
|
app.get('/videotrack/:id?', (req, res) => {
|
||||||
const videos = db.get('videos');
|
const videos = db.get('videos');
|
||||||
@@ -76,5 +79,6 @@ low(new FileAsync(__dirname + '/db.json')) // production
|
|||||||
return db.defaults({ videos: [] }).write();
|
return db.defaults({ videos: [] }).write();
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
app.use(express.static(__dirname + '/build')); // serve static build site
|
||||||
app.listen(8000, () => console.log('listen on 8000')); // bind to port 8000 as required from specs
|
app.listen(8000, () => console.log('listen on 8000')); // bind to port 8000 as required from specs
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-2
@@ -17,7 +17,7 @@ class App extends React.Component {
|
|||||||
navHeight: null,
|
navHeight: null,
|
||||||
blackbgHeight: null,
|
blackbgHeight: null,
|
||||||
isInfoToggled: false,
|
isInfoToggled: false,
|
||||||
videoId: localStorage['lastId']?localStorage['lastId']:'0J2QdDbelmY'
|
videoId: localStorage['lastId']
|
||||||
};
|
};
|
||||||
|
|
||||||
// componentDidMount(){
|
// componentDidMount(){
|
||||||
@@ -79,7 +79,7 @@ static getDerivedStateFromProps(nextProps, prevState) {
|
|||||||
</Collapse>
|
</Collapse>
|
||||||
</Col>
|
</Col>
|
||||||
</ReactHeight>
|
</ReactHeight>
|
||||||
<Row style={{ "max-height": `calc(98vh - ${this.state.blackbgHeight}px - ${this.state.navHeight}px)` }} className='mt-1 downSection'>
|
<Row style={{ "max-height": `calc(90vh - ${this.state.blackbgHeight}px )` }} className='mt-1 downSection'>
|
||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path='/' component={VideoList} />
|
<Route exact path='/' component={VideoList} />
|
||||||
<Route path={["/video/:id", "/search/:query"]} component={Suggestion} />
|
<Route path={["/video/:id", "/search/:query"]} component={Suggestion} />
|
||||||
|
|||||||
+12
-7
@@ -7,12 +7,15 @@ import { withRouter } from 'react-router-dom';
|
|||||||
class VideoPlayer extends React.Component {
|
class VideoPlayer extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
opt: {
|
opt: {
|
||||||
height: '390',
|
// height: '390',
|
||||||
width: '640',
|
// width: '640',
|
||||||
playerVars: {
|
playerVars: {
|
||||||
// https://developers.google.com/youtube/player_parameters
|
// https://developers.google.com/youtube/player_parameters
|
||||||
autoplay: 0,
|
autoplay: 0,
|
||||||
modestbranding: 1
|
modestbranding: 1,
|
||||||
|
fs: 0,
|
||||||
|
iv_load_policy:3,
|
||||||
|
rel: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
promise1: null,
|
promise1: null,
|
||||||
@@ -91,10 +94,12 @@ class VideoPlayer extends React.Component {
|
|||||||
error => console.info(error, videoIdWatched.toString())
|
error => console.info(error, videoIdWatched.toString())
|
||||||
);
|
);
|
||||||
// local storage logic for recent reccomender
|
// local storage logic for recent reccomender
|
||||||
// let temp=localStorage.getItem('lastWatched');
|
let tmp = JSON.parse(localStorage.getItem('lastWatched'))
|
||||||
// temp.push({id: videoIdWatched.toString(), date: new Date})
|
tmp.push({
|
||||||
|
'id': videoIdWatched.toString(),
|
||||||
|
'date' : new Date()
|
||||||
|
});
|
||||||
|
localStorage.setItem('lastWatched', JSON.stringify(tmp));
|
||||||
//.finally(()=>{})
|
//.finally(()=>{})
|
||||||
clearInterval(timerId1);
|
clearInterval(timerId1);
|
||||||
},
|
},
|
||||||
|
|||||||
+3
-4
@@ -5,9 +5,8 @@ import ReactDOM from 'react-dom';
|
|||||||
import App from './App';
|
import App from './App';
|
||||||
import registerServiceWorker from './registerServiceWorker';
|
import registerServiceWorker from './registerServiceWorker';
|
||||||
import { HashRouter, BrowserRouter } from 'react-router-dom'; // eslint-disable-line
|
import { HashRouter, BrowserRouter } from 'react-router-dom'; // eslint-disable-line
|
||||||
|
localStorage.setItem('lastWatched', JSON.stringify([]))
|
||||||
|
localStorage['lastId'] ? function (){}() : localStorage.setItem('lastId','0J2QdDbelmY')
|
||||||
|
|
||||||
let lastWatchedList=[];
|
ReactDOM.render(<HashRouter><App /></HashRouter>, document.getElementById('root'));
|
||||||
localStorage.setItem('lastWatched', lastWatchedList)
|
|
||||||
|
|
||||||
ReactDOM.render(<BrowserRouter><App /></BrowserRouter>, document.getElementById('root'));
|
|
||||||
registerServiceWorker();
|
registerServiceWorker();
|
||||||
|
|||||||
+39
-19
@@ -15,7 +15,43 @@ class Search extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
axios.get('https://www.googleapis.com/youtube/v3/search', { //Richiesta per ottenere i commenti del video
|
console.log('called didmo');
|
||||||
|
}
|
||||||
|
|
||||||
|
// shouldComponentUpdate(nextProps, nextState) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
componentDidUpdate(prevProps, prevState) {
|
||||||
|
console.log('called didup');
|
||||||
|
if(new RegExp("[0-9A-Za-z_-]{10}[048AEIMQUYcgkosw]").test(this.state.query.toString()))
|
||||||
|
axios.get('https://www.googleapis.com/youtube/v3/videos',{
|
||||||
|
params: {
|
||||||
|
'part':'id',
|
||||||
|
'id': this.state.query,
|
||||||
|
'key': process.env.APIKEY ? process.env.APIKEY : 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig',
|
||||||
|
'field': 'pageInfo/resultsPerPage'
|
||||||
|
}
|
||||||
|
}).then(
|
||||||
|
res => {
|
||||||
|
res.data.pageInfo.resultsPerPage ?
|
||||||
|
this.props.history.push('/video/' + this.state.query) :
|
||||||
|
this.youtubeSearch()
|
||||||
|
},
|
||||||
|
error => {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
else
|
||||||
|
this.youtubeSearch();
|
||||||
|
}
|
||||||
|
|
||||||
|
// componentWillUnmount() {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
youtubeSearch() {
|
||||||
|
return axios.get('https://www.googleapis.com/youtube/v3/search', {
|
||||||
params: {
|
params: {
|
||||||
'part': 'snippet',
|
'part': 'snippet',
|
||||||
'q': this.state.query,
|
'q': this.state.query,
|
||||||
@@ -23,7 +59,7 @@ class Search extends React.Component {
|
|||||||
'type': 'video',
|
'type': 'video',
|
||||||
'maxResults': 30,
|
'maxResults': 30,
|
||||||
'topicId': '/m/04rlf, /m/02jjt',
|
'topicId': '/m/04rlf, /m/02jjt',
|
||||||
'key': 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig' // process.env.APIKEY in production
|
'key': process.env.APIKEY ? process.env.APIKEY : 'AIzaSyA21Odw9UdfiOJnxvA_eDfOW0OxuUfHKig'
|
||||||
}
|
}
|
||||||
}).then(
|
}).then(
|
||||||
res => {
|
res => {
|
||||||
@@ -32,26 +68,10 @@ class Search extends React.Component {
|
|||||||
res: res.data
|
res: res.data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
error => {console.error(error)}
|
error => { console.error(error) }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// shouldComponentUpdate(nextProps, nextState) {
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// componentDidUpdate(prevProps, prevState) {
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
// componentWillUnmount() {
|
|
||||||
|
|
||||||
// }
|
|
||||||
|
|
||||||
youtubeSearch() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
Reference in New Issue
Block a user