├── public ├── robots.txt ├── favicon.ico ├── logo192.png ├── logo512.png ├── manifest.json └── index.html ├── .idea ├── misc.xml ├── modules.xml ├── miniflix.iml ├── inspectionProfiles │ └── Project_Default.xml └── workspace.xml ├── src ├── setupTests.js ├── App.test.js ├── components │ ├── Callback.jsx │ ├── Upload.jsx │ ├── Nav.jsx │ └── Display.jsx ├── index.css ├── App.js ├── App.css ├── index.js ├── logo.svg ├── utils │ └── AuthService.js └── serviceWorker.js ├── .gitignore ├── package.json └── README.md /public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmilAbdullazadeh/miniflix/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmilAbdullazadeh/miniflix/HEAD/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AmilAbdullazadeh/miniflix/HEAD/public/logo512.png -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/miniflix.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/App.test.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /src/components/Callback.jsx: -------------------------------------------------------------------------------- 1 | import { Component } from 'react'; 2 | import { setIdToken, setAccessToken } from '../utils/AuthService'; 3 | 4 | class Callback extends Component { 5 | 6 | componentDidMount() { 7 | setAccessToken(); 8 | setIdToken(); 9 | window.location.href = "/"; 10 | } 11 | 12 | render() { 13 | return null; 14 | } 15 | } 16 | 17 | export default Callback; -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import logo from './logo.svg'; 3 | import './App.css'; 4 | 5 | function App() { 6 | return ( 7 |
8 |
9 | logo 10 |

11 | Edit src/App.js and save to reload. 12 |

13 | 19 | Learn React 20 | 21 |
22 |
23 | ); 24 | } 25 | 26 | export default App; 27 | -------------------------------------------------------------------------------- /src/App.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import 'bootstrap/dist/css/bootstrap.min.css'; 4 | import Upload from './components/Upload'; 5 | import Display from './components/Display'; 6 | import Callback from './components/Callback'; 7 | import * as serviceWorker from './serviceWorker'; 8 | import { Router, Route, browserHistory } from 'react-router'; 9 | import { requireAuth } from './utils/AuthService'; 10 | 11 | 12 | const Root = () => { 13 | return ( 14 |
15 | 16 | 17 | 18 | 19 | 20 |
21 | ) 22 | }; 23 | 24 | ReactDOM.render(, document.getElementById('root')); 25 | serviceWorker.unregister(); 26 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "miniflix", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.4.0", 8 | "@testing-library/user-event": "^7.2.1", 9 | "auth0-js": "^9.12.1", 10 | "axios": "^0.19.0", 11 | "bootstrap": "^4.4.1", 12 | "cloudinary-react": "^1.3.0", 13 | "jwt-decode": "^2.2.0", 14 | "react": "^16.12.0", 15 | "react-dom": "^16.12.0", 16 | "react-router": "^3.0.0", 17 | "react-scripts": "3.3.0", 18 | "react-twitter-widgets": "^1.7.1" 19 | }, 20 | "scripts": { 21 | "start": "react-scripts start", 22 | "build": "react-scripts build", 23 | "test": "react-scripts test", 24 | "eject": "react-scripts eject" 25 | }, 26 | "eslintConfig": { 27 | "extends": "react-app" 28 | }, 29 | "browserslist": { 30 | "production": [ 31 | ">0.2%", 32 | "not dead", 33 | "not op_mini all" 34 | ], 35 | "development": [ 36 | "last 1 chrome version", 37 | "last 1 firefox version", 38 | "last 1 safari version" 39 | ] 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/components/Upload.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | // import { Link } from 'react-router'; 3 | import Nav from './Nav'; 4 | 5 | class Upload extends Component { 6 | 7 | uploadWidget = () => { 8 | window.cloudinary.openUploadWidget( 9 | { cloud_name: 'localhostreact', 10 | upload_preset: 'xd7ufndo', 11 | tags: ['miniflix'], 12 | sources: ['local', 'url', 'google_photos', 'facebook', 'image_search'] 13 | }, 14 | function(error, result) { 15 | console.log("This is the result of the last upload", result); 16 | }); 17 | } 18 | 19 | render() { 20 | return ( 21 |
22 |
32 | ); 33 | } 34 | } 35 | 36 | export default Upload; -------------------------------------------------------------------------------- /src/components/Nav.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Link } from 'react-router'; 3 | import { login, logout, isLoggedIn } from '../utils/AuthService'; 4 | import '../App.css'; 5 | 6 | class Nav extends Component { 7 | 8 | render() { 9 | return ( 10 | 32 | ); 33 | } 34 | } 35 | export default Nav; -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 12 | 13 | 17 | 18 | 19 | 28 | Miniflix App 29 | 30 | 31 | 32 |
33 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 37 | -------------------------------------------------------------------------------- /src/components/Display.jsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | // import { Link } from 'react-router'; 3 | import Nav from './Nav'; 4 | // import { isLoggedIn } from '../utils/AuthService'; 5 | import { CloudinaryContext, Video } from 'cloudinary-react'; 6 | import axios from 'axios'; 7 | import { Share } from 'react-twitter-widgets' 8 | 9 | class Display extends Component { 10 | 11 | state = { videos: [] }; 12 | 13 | getVideos() { 14 | axios.get('http://res.cloudinary.com/localhostreact/video/list/miniflix.json') 15 | .then(res => { 16 | console.log(res.data.resources); 17 | this.setState({ videos: res.data.resources}); 18 | }); 19 | } 20 | 21 | componentDidMount() { 22 | this.getVideos(); 23 | } 24 | 25 | render() { 26 | 27 | const { videos } = this.state; 28 | 29 | return ( 30 |
31 |
50 | ); 51 | } 52 | } 53 | 54 | export default Display; -------------------------------------------------------------------------------- /src/logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/utils/AuthService.js: -------------------------------------------------------------------------------- 1 | import decode from 'jwt-decode'; 2 | import { browserHistory } from 'react-router'; 3 | import auth0 from 'auth0-js'; 4 | const ID_TOKEN_KEY = 'id_token'; 5 | const ACCESS_TOKEN_KEY = 'access_token'; 6 | 7 | const CLIENT_ID = 'EeobY3jxsMoFREmqfmsZwAALQb73WeWm'; 8 | const CLIENT_DOMAIN = 'unicoder.auth0.com'; 9 | const REDIRECT = 'http://localhost:3000/callback'; 10 | const SCOPE = 'full:access'; 11 | const AUDIENCE = 'http://miniflix.com'; 12 | 13 | var auth = new auth0.WebAuth({ 14 | clientID: CLIENT_ID, 15 | domain: CLIENT_DOMAIN 16 | }); 17 | 18 | export function login() { 19 | auth.authorize({ 20 | responseType: 'token id_token', 21 | redirectUri: REDIRECT, 22 | audience: AUDIENCE, 23 | scope: SCOPE 24 | }); 25 | } 26 | 27 | export function logout() { 28 | clearIdToken(); 29 | clearAccessToken(); 30 | browserHistory.push('/'); 31 | } 32 | 33 | export function requireAuth(nextState, replace) { 34 | if (!isLoggedIn()) { 35 | replace({pathname: '/'}); 36 | } 37 | } 38 | 39 | export function getIdToken() { 40 | return localStorage.getItem(ID_TOKEN_KEY); 41 | } 42 | 43 | export function getAccessToken() { 44 | return localStorage.getItem(ACCESS_TOKEN_KEY); 45 | } 46 | 47 | function clearIdToken() { 48 | localStorage.removeItem(ID_TOKEN_KEY); 49 | } 50 | 51 | function clearAccessToken() { 52 | localStorage.removeItem(ACCESS_TOKEN_KEY); 53 | } 54 | 55 | // Helper function that will allow us to extract the access_token and id_token 56 | function getParameterByName(name) { 57 | let match = RegExp('[#&]' + name + '=([^&]*)').exec(window.location.hash); 58 | return match && decodeURIComponent(match[1].replace(/\+/g, ' ')); 59 | } 60 | 61 | // Get and store access_token in local storage 62 | export function setAccessToken() { 63 | let accessToken = getParameterByName('access_token'); 64 | localStorage.setItem(ACCESS_TOKEN_KEY, accessToken); 65 | } 66 | 67 | // Get and store id_token in local storage 68 | export function setIdToken() { 69 | let idToken = getParameterByName('id_token'); 70 | localStorage.setItem(ID_TOKEN_KEY, idToken); 71 | } 72 | 73 | export function isLoggedIn() { 74 | const idToken = getIdToken(); 75 | return !!idToken && !isTokenExpired(idToken); 76 | } 77 | 78 | function getTokenExpirationDate(encodedToken) { 79 | const token = decode(encodedToken); 80 | if (!token.exp) { return null; } 81 | 82 | const date = new Date(0); 83 | date.setUTCSeconds(token.exp); 84 | 85 | return date; 86 | } 87 | 88 | function isTokenExpired(token) { 89 | const expirationDate = getTokenExpirationDate(token); 90 | return expirationDate < new Date(); 91 | } -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 10 | 11 | 16 | 17 | 18 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 |