Cambiati i formati delle date di publiccazione del video nei reccomender Random e Related

This commit is contained in:
Giampiero Galeazzi
2019-01-30 22:31:13 +01:00
parent aa425c1689
commit a981178104
4 changed files with 27 additions and 32 deletions
+7 -21
View File
@@ -5879,13 +5879,11 @@
}, },
"balanced-match": { "balanced-match": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true
"optional": true
}, },
"brace-expansion": { "brace-expansion": {
"version": "1.1.11", "version": "1.1.11",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"balanced-match": "^1.0.0", "balanced-match": "^1.0.0",
"concat-map": "0.0.1" "concat-map": "0.0.1"
@@ -5898,18 +5896,15 @@
}, },
"code-point-at": { "code-point-at": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true
"optional": true
}, },
"concat-map": { "concat-map": {
"version": "0.0.1", "version": "0.0.1",
"bundled": true, "bundled": true
"optional": true
}, },
"console-control-strings": { "console-control-strings": {
"version": "1.1.0", "version": "1.1.0",
"bundled": true, "bundled": true
"optional": true
}, },
"core-util-is": { "core-util-is": {
"version": "1.0.2", "version": "1.0.2",
@@ -6012,8 +6007,7 @@
}, },
"inherits": { "inherits": {
"version": "2.0.3", "version": "2.0.3",
"bundled": true, "bundled": true
"optional": true
}, },
"ini": { "ini": {
"version": "1.3.5", "version": "1.3.5",
@@ -6023,7 +6017,6 @@
"is-fullwidth-code-point": { "is-fullwidth-code-point": {
"version": "1.0.0", "version": "1.0.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"number-is-nan": "^1.0.0" "number-is-nan": "^1.0.0"
} }
@@ -6036,20 +6029,17 @@
"minimatch": { "minimatch": {
"version": "3.0.4", "version": "3.0.4",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"brace-expansion": "^1.1.7" "brace-expansion": "^1.1.7"
} }
}, },
"minimist": { "minimist": {
"version": "0.0.8", "version": "0.0.8",
"bundled": true, "bundled": true
"optional": true
}, },
"minipass": { "minipass": {
"version": "2.2.4", "version": "2.2.4",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"safe-buffer": "^5.1.1", "safe-buffer": "^5.1.1",
"yallist": "^3.0.0" "yallist": "^3.0.0"
@@ -6066,7 +6056,6 @@
"mkdirp": { "mkdirp": {
"version": "0.5.1", "version": "0.5.1",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"minimist": "0.0.8" "minimist": "0.0.8"
} }
@@ -6139,8 +6128,7 @@
}, },
"number-is-nan": { "number-is-nan": {
"version": "1.0.1", "version": "1.0.1",
"bundled": true, "bundled": true
"optional": true
}, },
"object-assign": { "object-assign": {
"version": "4.1.1", "version": "4.1.1",
@@ -6150,7 +6138,6 @@
"once": { "once": {
"version": "1.4.0", "version": "1.4.0",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"wrappy": "1" "wrappy": "1"
} }
@@ -6256,7 +6243,6 @@
"string-width": { "string-width": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"optional": true,
"requires": { "requires": {
"code-point-at": "^1.0.0", "code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0", "is-fullwidth-code-point": "^1.0.0",
+4 -5
View File
@@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import Wikipedia from './areainfo/Wikipedia'; import Wikipedia from './areainfo/Wikipedia';
import { Tabs, Tab, Table } from 'react-bootstrap'; import { Tabs, Tab } from 'react-bootstrap';
import {Link, withRouter} from 'react-router-dom'; import {Link, withRouter} from 'react-router-dom';
import axios from 'axios'; import axios from 'axios';
import Linkify from "react-linkify"; import Linkify from "react-linkify";
@@ -12,7 +12,6 @@ import './css/VideoInfo.scss';
const ytclear = require('@c0b41/ytclear'); const ytclear = require('@c0b41/ytclear');
class VideoInfo extends React.Component { class VideoInfo extends React.Component {
state = { state = {
@@ -25,7 +24,7 @@ class VideoInfo extends React.Component {
}; };
momentDuration(duration) { momentDuration(duration) {
return moment.duration(duration).format('hh:mm:ss'); return moment.duration(duration).format('hh:mm:ss')
} }
ISO_8601parse(a) { ISO_8601parse(a) {
@@ -145,8 +144,8 @@ class VideoInfo extends React.Component {
render() { render() {
const { error, isLoaded, VideoDetails, comments } = this.state; const { error, isLoaded, VideoDetails, comments } = this.state;
const momentDuration = this.momentDuration; // bind momentDuration in render to the actual method const momentDuration = this.momentDuration;
const ISO_8601parse = this.ISO_8601parse; // bind momentDuration in render to the actual method const ISO_8601parse = this.ISO_8601parse;
if (error) { if (error) {
return ( return (
<span className="text-white"> <span className="text-white">
+8 -3
View File
@@ -4,6 +4,7 @@ import axios from "axios";
import createpageToken from 'youtube-page-token'; import createpageToken from 'youtube-page-token';
import {Card} from "react-bootstrap"; import {Card} from "react-bootstrap";
import {Link} from "react-router-dom"; import {Link} from "react-router-dom";
import moment from "moment";
class RecommenderRandom extends Component{ class RecommenderRandom extends Component{
constructor(props){ constructor(props){
@@ -13,6 +14,11 @@ class RecommenderRandom extends Component{
}; };
} }
ISO_8601parse(a) {
return moment(a, moment.ISO_8601).format('ddd, DD/MM/YYYY hh:mm:ss');
}
componentDidMount(){ componentDidMount(){
let pos = Math.floor(Math.random() * 500); let pos = Math.floor(Math.random() * 500);
let pageToken = createpageToken(pos); /* createPageToken(pos) restituisce il pageToken relativo al numero let pageToken = createpageToken(pos); /* createPageToken(pos) restituisce il pageToken relativo al numero
@@ -41,6 +47,7 @@ class RecommenderRandom extends Component{
} }
render(){ render(){
const ISO_8601parse = this.ISO_8601parse;
return ( return (
<div style={{width: '100rem',height:'100rem'}}> <div style={{width: '100rem',height:'100rem'}}>
{this.state.items.map(function (item,index) { {this.state.items.map(function (item,index) {
@@ -60,9 +67,7 @@ class RecommenderRandom extends Component{
<Card.ImgOverlay> <Card.ImgOverlay>
<Card.Title className="bg-dark d-inline text-white"> <Card.Title className="bg-dark d-inline text-white">
{item.snippet.title}<br/> {item.snippet.title}<br/>
{item.snippet.channelTitle} - {item.snippet.publishedAt.replace(/(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+).000Z/,function(match,p1,p2,p3,p4,p5,p6){ {item.snippet.channelTitle} - {ISO_8601parse(item.snippet.publishedAt)}
return(p3+'/'+p2+'/'+p1+' at '+p4+':'+p5+':'+p6); //Funzione che trasforma la data e ora di pubblicazione dal formato ISO nel normale formato da cristiani
})}
</Card.Title> </Card.Title>
</Card.ImgOverlay> </Card.ImgOverlay>
</Link> </Link>
+8 -3
View File
@@ -2,6 +2,8 @@ import React, { Component } from 'react';
import axios from 'axios'; import axios from 'axios';
import {Link} from "react-router-dom"; import {Link} from "react-router-dom";
import {Card} from "react-bootstrap"; import {Card} from "react-bootstrap";
import moment from "moment";
class Related extends Component { class Related extends Component {
constructor(props) { constructor(props) {
@@ -12,6 +14,9 @@ class Related extends Component {
} }
} }
ISO_8601parse(a) {
return moment(a, moment.ISO_8601).format('ddd, DD/MM/YYYY hh:mm:ss');
}
componentWillMount() { componentWillMount() {
if(this.props.match.params.id){ if(this.props.match.params.id){
if(this.props.match.params.id === this.state.videoId){} if(this.props.match.params.id === this.state.videoId){}
@@ -51,6 +56,7 @@ class Related extends Component {
} }
render() { render() {
const ISO_8601parse = this.ISO_8601parse;
return ( return (
<div style={{width: '100rem',height:'100rem'}}> <div style={{width: '100rem',height:'100rem'}}>
{this.state.items.map(function (item,index) { {this.state.items.map(function (item,index) {
@@ -70,9 +76,8 @@ class Related extends Component {
<Card.ImgOverlay> <Card.ImgOverlay>
<Card.Title className="bg-dark d-inline text-white"> <Card.Title className="bg-dark d-inline text-white">
{item.snippet.title}<br/> {item.snippet.title}<br/>
{item.snippet.channelTitle} - {item.snippet.publishedAt.replace(/(\d+)-(\d+)-(\d+)T(\d+):(\d+):(\d+).000Z/,function(match,p1,p2,p3,p4,p5,p6){ {item.snippet.channelTitle} - {ISO_8601parse(item.snippet.publishedAt)}
return(p3+'/'+p2+'/'+p1+' at '+p4+':'+p5+':'+p6); //Funzione che trasforma la data e ora di pubblicazione dal formato ISO nel normale formato da cristiani
})}
</Card.Title> </Card.Title>
</Card.ImgOverlay> </Card.ImgOverlay>
</Link> </Link>