version 1.0

This commit is contained in:
Dmytro Barylo
2017-03-04 16:46:53 +02:00
commit ac6d57b46f
44 changed files with 2145 additions and 0 deletions

5
.babelrc Normal file
View File

@@ -0,0 +1,5 @@
{
"presets": [
["es2015", { "modules": false }]
]
}

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
.DS_Store
node_modules/
npm-debug.log

8
.htaccess Normal file
View File

@@ -0,0 +1,8 @@
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>

18
README.md Normal file
View File

@@ -0,0 +1,18 @@
# tmdb-app
> The Movie Database app
## Build Setup
``` bash
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
```
For detailed explanation on how things work, consult the [docs for vue-loader](http://vuejs.github.io/vue-loader).

18
dist/build.js vendored Normal file

File diff suppressed because one or more lines are too long

1
dist/build.js.map vendored Normal file

File diff suppressed because one or more lines are too long

BIN
dist/no-image.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

BIN
dist/placeholder.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
dist/pulp-fiction.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 KiB

BIN
docs/demo.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square150x150logo src="/mstile-150x150.png"/>
<TileColor>#081c24</TileColor>
</tile>
</msapplication>
</browserconfig>

BIN
favicons/favicon-16x16.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 889 B

BIN
favicons/favicon-32x32.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
favicons/favicon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

18
favicons/manifest.json Normal file
View File

@@ -0,0 +1,18 @@
{
"name": "",
"icons": [
{
"src": "/android-chrome-192x192.png",
"sizes": "192x192",
"type": "image/png"
},
{
"src": "/android-chrome-256x256.png",
"sizes": "256x256",
"type": "image/png"
}
],
"theme_color": "#081c24",
"background_color": "#081c24",
"display": "standalone"
}

BIN
favicons/mstile-150x150.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@@ -0,0 +1,33 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="16.000000pt" height="16.000000pt" viewBox="0 0 16.000000 16.000000"
preserveAspectRatio="xMidYMid meet">
<metadata>
Created by potrace 1.11, written by Peter Selinger 2001-2013
</metadata>
<g transform="translate(0.000000,16.000000) scale(0.006154,-0.006154)"
fill="#000000" stroke="none">
<path d="M610 2127 l0 -83 99 1 c83 1 100 -2 103 -14 2 -9 3 -157 2 -328 l-1
-313 83 0 84 0 2 328 3 327 98 0 c80 -1 97 2 98 15 1 17 1 131 0 143 -1 4
-129 7 -286 7 l-285 0 0 -83z"/>
<path d="M1289 2205 c-6 -22 -4 -812 2 -820 8 -11 145 -12 155 -2 4 3 6 106 5
228 -1 123 0 221 3 218 2 -2 39 -49 81 -104 43 -55 80 -102 82 -105 5 -6 27
20 113 133 55 72 60 76 60 50 1 -15 0 -117 0 -225 l-1 -198 23 -1 c25 -1 128
-1 141 0 4 1 7 188 7 416 l0 415 -27 0 c-23 0 -38 -14 -78 -67 -27 -36 -55
-71 -60 -77 -6 -6 -47 -57 -92 -114 l-81 -102 -41 52 c-23 29 -52 67 -66 83
-13 17 -58 74 -101 128 -58 74 -82 97 -100 97 -13 0 -25 -2 -25 -5z"/>
<path d="M617 1234 c-5 -6 0 -805 6 -811 4 -3 74 -6 157 -5 210 1 306 33 391
130 133 151 130 421 -5 564 -92 97 -163 120 -379 123 -92 1 -168 1 -170 -1z
m344 -182 c146 -59 185 -281 70 -400 -46 -47 -104 -68 -186 -68 l-60 1 -1 242
-2 242 37 3 c43 4 106 -5 142 -20z"/>
<path d="M1419 1231 c-7 -36 -2 -804 5 -809 5 -3 89 -5 186 -5 153 1 183 3
221 20 98 44 151 122 151 224 0 60 -15 97 -55 141 -25 27 -25 27 -5 45 11 10
26 33 34 53 48 114 -2 262 -105 312 -43 21 -60 23 -238 24 -106 1 -194 -1
-194 -5z m308 -160 c43 -1 73 -34 73 -80 -1 -64 -18 -76 -124 -79 l-93 -4 -1
80 c-1 90 -1 89 78 85 19 0 49 -2 67 -2z m60 -355 c26 -30 29 -53 12 -90 -15
-33 -49 -44 -140 -45 l-77 -1 0 78 c1 42 2 80 4 83 2 3 42 5 91 4 81 -2 88 -4
110 -29z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.8 KiB

67
index.html Normal file

File diff suppressed because one or more lines are too long

33
package.json Normal file
View File

@@ -0,0 +1,33 @@
{
"name": "tmdb-app",
"description": "The Movie Database app ",
"version": "1.0.0",
"author": "Dmytro Barylo",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"axios": "^0.15.3",
"debounce": "^1.0.0",
"numeral": "^2.0.4",
"vue": "^2.1.0",
"vue-axios": "^1.2.2",
"vue-router": "^2.2.1"
},
"devDependencies": {
"babel-core": "^6.0.0",
"babel-loader": "^6.0.0",
"babel-preset-es2015": "^6.0.0",
"cross-env": "^3.0.0",
"css-loader": "^0.25.0",
"file-loader": "^0.9.0",
"node-sass": "^4.5.0",
"sass-loader": "^5.0.1",
"vue-loader": "^10.0.0",
"vue-template-compiler": "^2.1.0",
"webpack": "^2.2.0",
"webpack-dev-server": "^2.2.0"
}
}

296
src/App.vue Normal file
View File

@@ -0,0 +1,296 @@
<template>
<div id="app">
<navigation></navigation>
<header class="header">
<div class="header__search">
<input class="header__search-input" type="text" v-model.trim="searchQuery" @keyup.enter="search" @blur="search" placeholder="Search for a movie...">
<svg class="header__search-icon">
<use xlink:href="#iconSearch"></use>
</svg>
</div>
</header>
<movie-popup v-if="moviePopupIsVisible" @close="closeMoviePopup" :id="moviePopupId"></movie-popup>
<section class="main">
<transition name="fade" @after-leave="afterLeave">
<router-view name="list-router-view" :type="'page'" :mode="'collection'" :key="$route.params.category"></router-view>
<router-view name="search-router-view" :type="'page'" :mode="'search'" :key="$route.params.query"></router-view>
<router-view name="page-router-view"></router-view>
</transition>
</section>
</div>
</template>
<script>
import axios from 'axios'
import storage from './storage.js'
import Navigation from './components/Navigation.vue'
import MoviePopup from './components/MoviePopup.vue'
export default {
name: 'app',
components: { Navigation, MoviePopup},
data(){
return{
moviePopupIsVisible: false,
moviePopupHistoryVisible: false,
moviePopupId: 0,
searchQuery: ''
}
},
computed: {
queryForRouter(){
return encodeURI(this.searchQuery.replace(/ /g, "+"));
}
},
methods: {
// User Session Methods
requestToken(){
storage.sessionId = null;
axios.get(`https://api.themoviedb.org/3/authentication/token/new?api_key=${storage.apiKey}`)
.then(function(resp){
if(typeof resp.data == 'string') {
resp.data = JSON.parse(resp.data);
}
let data = resp.data;
window.location.href = `https://www.themoviedb.org/authenticate/${data.request_token}?redirect_to=${location.protocol}//${location.host}/profile`
}.bind(this));
},
setUserStatus(){
storage.sessionId = localStorage.getItem('session_id') || null;
storage.userId = localStorage.getItem('user_id') || null;
},
// Movie Popup Methods
openMoviePopup(id, newMoviePopup){
if(newMoviePopup){
storage.backTitle = document.title;
}
storage.createMoviePopup = newMoviePopup;
this.moviePopupIsVisible = true;
this.moviePopupId = id;
document.querySelector('body').classList.add('hidden');
},
closeMoviePopup(){
storage.createMoviePopup = false;
this.moviePopupIsVisible = false;
document.querySelector('body').classList.remove('hidden');
window.history.back();
},
onHistoryState(e){
storage.moviePopupOnHistory = e.state ? e.state.hasOwnProperty('popup') : false;
if(!storage.moviePopupOnHistory){
this.moviePopupIsVisible = false;
document.title = storage.backTitle;
}
},
changeHistoryState(){
if(history.state && history.state.popup){
let newState = {
popup: false
};
history.replaceState(newState , null, storage.moviePath);
}
},
// Search Methods
search(){
if(!this.searchQuery.length) return;
this.$router.push({ name: 'search', params: { query: this.queryForRouter }});
},
setSearchQuery(clear){
if(clear){
this.searchQuery = '';
} else {
let query = decodeURIComponent(this.$route.params.query);
this.searchQuery = query ? query.replace(/\+/g, " ") : '';
}
},
// Router After Leave
afterLeave(){
document.querySelector('body').scrollTop = 0;
}
},
created(){
window.addEventListener('popstate', this.onHistoryState);
window.addEventListener('pagehide', this.changeHistoryState);
eventHub.$on('openMoviePopup', this.openMoviePopup);
eventHub.$on('setSearchQuery', this.setSearchQuery);
eventHub.$on('requestToken', this.requestToken);
eventHub.$on('setUserStatus', this.setUserStatus);
}
}
</script>
<style lang="scss">
@import "./src/scss/variables";
@import "./src/scss/media-queries";
*{
box-sizing: border-box;
}
html, body{
height: 100%;
}
body{
font-family: 'Roboto', sans-serif;
line-height: 1.6;
background: $c-light;
color: $c-dark;
&.hidden{
overflow: hidden;
}
}
input, textarea, button{
font-family: 'Roboto', sans-serif;
}
figure{
padding: 0;
margin: 0;
}
img{
display: block;
max-width: 100%;
height: auto;
}
.loader{
animation: load 1s linear infinite;
border: 2px solid $c-white;
border-radius: 50%;
display: block;
height: 30px;
left: 50%;
margin: -1.5em;
position: absolute;
top: 50%;
width: 30px;
&:after {
border: 5px solid $c-green;
border-radius: 50%;
content: '';
left: 10px;
position: absolute;
top: 16px;
}
}
@keyframes load {
100% { transform: rotate(360deg); }
}
.wrapper{
position: relative;
}
.header{
position: fixed;
background: $c-white;
z-index: 15;
display: flex;
@include tablet-min{
width: calc(100% - 170px);
height: 75px;
margin-left: 95px;
border-top: 0;
border-bottom: 0;
top: 0;
}
&__search{
height: 50px;
display: flex;
position: relative;
z-index: 5;
width: calc(100% - 55px);
position: fixed;
top: 0;
right: 0;
@include tablet-min{
position: relative;
height: 75px;
}
&-input{
display: block;
width: 100%;
padding: 15px 20px 15px 50px;
outline: none;
border: 0;
background-color: transparent;
color: $c-dark;
font-weight: 300;
font-size: 16px;
@include tablet-min{
padding: 15px 30px 15px 60px;
}
@include tablet-landscape-min{
padding: 15px 30px 15px 80px;
}
@include desktop-min{
padding: 15px 30px 15px 90px;
}
}
&-icon{
width: 14px;
height: 14px;
fill: rgba($c-dark, 0.5);
transition: fill 0.5s ease;
pointer-events: none;
position: absolute;
top: 50%;
margin-top: -7px;
left: 20px;
@include tablet-min{
width: 18px;
height: 18px;
margin-top: -9px;
left: 30px;
}
@include tablet-landscape-min{
left: 50px;
}
@include desktop-min{
left: 60px;
}
}
&-input:focus + &-icon{
fill: $c-dark;
}
}
}
.main{
position: relative;
padding: 100px 0 0;
@include tablet-min{
width: calc(100% - 95px);
padding: 75px 0 0;
margin-left: 95px;
position: relative;
}
}
.button{
display: inline-block;
border: 1px solid $c-dark;
text-transform: uppercase;
background: $c-dark;
font-weight: 300;
font-size: 11px;
line-height: 2;
letter-spacing: 0.5px;
padding: 5px 20px 4px 20px;
cursor: pointer;
color: $c-dark;
background: transparent;
outline: none;
@include tablet-min{
font-size: 12px;
padding: 6px 20px 5px 20px;
}
}
// router view transition
.fade-enter-active, .fade-leave-active {
transition-property: opacity;
transition-duration: 0.25s;
}
.fade-enter-active {
transition-delay: 0.25s;
}
.fade-enter, .fade-leave-active {
opacity: 0
}
</style>

BIN
src/assets/no-image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

BIN
src/assets/placeholder.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
src/assets/pulp-fiction.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 KiB

65
src/components/404.vue Normal file
View File

@@ -0,0 +1,65 @@
<template>
<section class="not-found">
<div class="not-found__content">
<h2 class="not-found__title">Page Not Found</h2>
</div>
</section>
</template>
<script>
import storage from '../storage.js'
export default {
created(){
document.title = 'Page Not Found' + storage.pageTitlePostfix;
}
}
</script>
<style lang="scss">
@import "./src/scss/variables";
@import "./src/scss/media-queries";
.not-found{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: url('~assets/pulp-fiction.jpg') no-repeat 50% 50%;
background-size: cover;
display: flex;
align-items: center;
justify-content: center;
&:before{
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba($c-light, 0.7);
}
&__content{
width: 100%;
padding: 0 20px;
text-align: center;
@include tablet-min{
padding: 0 40px 40px 0;
}
}
&__title{
font-size: 24px;
font-weight: 500;
color: $c-dark;
position: relative;
margin: 0;
@include tablet-min{
font-size: 28px;
}
}
&__button{
position: relative;
margin-top: 20px;
}
}
</style>

127
src/components/Home.vue Normal file
View File

@@ -0,0 +1,127 @@
<template>
<section class="home">
<header class="home__header">
<div class="home__header-wrap">
<h1 class="home__header-title">The Movie DB App</h1>
<strong class="home__header-subtitle">Made with Vue.js</strong>
<a href="https://github.com/dmtrbrl/tmdb-app" target="_blank" class="home__header-link">
<svg class="home__header-link-icon">
<use xlink:href="#iconGithub"></use>
</svg>
<span>View Code</span>
</a>
</div>
</header>
<movies-list v-for="item in listTypes" v-if="item.isCategory" :type="'component'" :mode="'collection'" :category="item.query" :shortList="true"></movies-list>
</section>
</template>
<script>
import axios from 'axios'
import storage from '../storage.js'
import MoviesList from './MoviesList.vue'
export default {
components: { MoviesList },
data(){
return {
listTypes: storage.listTypes
}
},
created(){
document.title = 'TMDb';
storage.backTitle = document.title;
}
}
</script>
<style lang="scss">
@import "./src/scss/variables";
@import "./src/scss/media-queries";
.home{
&__header{
width: 100%;
height: 200px;
display: flex;
align-items: center;
justify-content: center;
background-size: cover;
background-repeat: no-repeat;
background-position: 50% 50%;
position: relative;
background-color: $c-dark;
background-image: url('~assets/pulp-fiction.jpg');
@include tablet-min{
height: 384px;
}
&:before{
content: "";
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba($c-light, 0.7);
}
&-wrap{
text-align: center;
position: relative;
}
&-title{
font-weight: 500;
font-size: 22px;
text-transform: uppercase;
letter-spacing: 0.5px;
color: $c-dark;
margin: 0;
@include tablet-min{
font-size: 28px;
}
}
&-subtitle{
display: block;
font-size: 14px;
font-weight: 300;
color: $c-dark;
margin: 5px 0;
@include tablet-min{
font-size: 16px;
}
}
&-link{
text-decoration: none;
color: $c-dark;
font-size: 13px;
font-weight: 300;
opacity: 0.7;
transition: opacity 0.5s ease;
&:hover{
opacity: 1;
}
span{
display: inline-block;
vertical-align: middle;
}
&-icon{
display: inline-block;
vertical-align: middle;
margin-right: 2px;
width: 16px;
height: 15px;
fill: $c-dark;
}
}
}
.wrapper{
min-height: 0;
}
.movies__list{
.movies__item:last-child{
display: none;
@include desktop-min{
display: block;
}
}
}
}
</style>

364
src/components/Movie.vue Normal file
View File

@@ -0,0 +1,364 @@
<template>
<section class="movie">
<div class="movie__container" v-if="loaded">
<header class="movie__header" :class="{'movie__header--page': type=='page'}" :style="{ 'background-image': 'url(' + movieBackdropSrc + ')' }">
<div class="movie__wrap movie__wrap--header" :class="{'movie__wrap--page': type=='page'}">
<figure class="movie__poster">
<img v-if="moviePosterSrc" class="movie__img" src="~assets/placeholder.png" v-img="moviePosterSrc">
<img v-if="!moviePosterSrc" class="movies-item__img is-loaded" src="~assets/no-image.png">
</figure>
<div class="movie__title">
<h1 class="movie__title-text">
{{ movie.title }}
<span v-if="movie.tagline">{{ movie.tagline }}</span>
</h1>
</div>
</div>
</header>
<div class="movie__main">
<div class="movie__wrap movie__wrap--main" :class="{'movie__wrap--page': type=='page'}">
<div class="movie__actions" v-if="userLoggedIn && favoriteChecked">
<a href="#" class="movie__actions-link" :class="{'active' : favorite === true}" @click.prevent="toggleFavorite">
<svg class="movie__actions-icon" :class="{'waiting' : favorite === ''}">
<use xlink:href="#iconFavorite"></use>
</svg>
<span class="movie__actions-text" v-if="favorite === ''">Wait...</span>
<span class="movie__actions-text" v-else-if="favorite">Marked as Favorite</span>
<span class="movie__actions-text" v-else>Mark as Favorite?</span>
</a>
</div>
<div class="movie__info">
<div v-if="movie.overview" class="movie__description">
{{ movie.overview }}
</div>
<div class="movie__details">
<div v-if="movie.genres.length" class="movie__details-block">
<h2 class="movie__details-title">
Genres
</h2>
<div class="movie__details-text">
{{ nestedDataToString(movie.genres) }}
</div>
</div>
<div v-if="movie.release_date" class="movie__details-block">
<h2 class="movie__details-title">
Release Date
</h2>
<div class="movie__details-text" v-formatDate="movie.release_date"></div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
</template>
<script>
import axios from 'axios'
import storage from '../storage.js'
import img from '../directives/v-image.js'
import formatDate from '../directives/v-formatDate.js'
export default {
props: ['id', 'type'],
directives: {
img: img,
formatDate: formatDate
},
data(){
return{
movie: {},
movieLoaded: false,
moviePosterSrc: '',
movieBackdropSrc: '',
userLoggedIn: storage.sessionId ? true : false,
favoriteChecked: false,
favorite: ''
}
},
computed: {
loaded(){
return this.movieLoaded ? true : false;
}
},
methods: {
fetchMovie(id){
axios.get(`https://api.themoviedb.org/3/movie/${id}?api_key=${storage.apiKey}&language=en-US`)
.then(function(resp){
let movie = resp.data;
this.movie = movie;
this.poster();
this.backdrop();
this.movieLoaded = true;
if(this.userLoggedIn){
this.checkIfInFavorites(movie.id);
}
// Push state
if(storage.createMoviePopup){
storage.moviePath = '/movie/' + id;
history.pushState({ popup: true }, null, storage.moviePath);
storage.createMoviePopup = false;
}
// Change Page title
document.title = this.movie.title + storage.pageTitlePostfix;
}.bind(this))
.catch(function(error) {
console.log('error');
this.$router.push({ name: '404' });
}.bind(this));
},
poster() {
if(this.movie.poster_path){
this.moviePosterSrc = 'https://image.tmdb.org/t/p/w600_and_h900_bestv2' + this.movie.poster_path;
}
},
backdrop(){
if(this.movie.backdrop_path){
this.movieBackdropSrc = 'https://image.tmdb.org/t/p/w500' + this.movie.backdrop_path;
}
},
nestedDataToString(data) {
let nestedArray = [], resultString;
data.forEach((item) => nestedArray.push(item.name));
resultString = nestedArray.join(', ');
return resultString;
},
checkIfInFavorites(id){
axios.get(`https://api.themoviedb.org/3/movie/${id}/account_states?api_key=${storage.apiKey}&session_id=${storage.sessionId}`)
.then(function(resp){
this.favorite = resp.data.favorite;
this.favoriteChecked = true;
}.bind(this))
},
toggleFavorite(){
let favoriteInvert = !this.favorite;
this.favorite = '';
axios.post(`https://api.themoviedb.org/3/account/${storage.userId}/favorite?api_key=${storage.apiKey}&session_id=${storage.sessionId}`, {
'media_type': 'movie',
'media_id': this.id,
'favorite': favoriteInvert
})
.then(function(resp){
this.favorite = favoriteInvert;
eventHub.$emit('updateFavorite');
}.bind(this));
}
},
watch: {
id: function(val){
this.fetchMovie(val);
}
},
created(){
this.fetchMovie(this.id);
}
}
</script>
<style lang="scss">
@import "./src/scss/variables";
@import "./src/scss/media-queries";
.movie{
&__wrap{
display: flex;
&--page{
max-width: 768px;
position: relative;
margin: 0 auto;
}
&--header{
align-items: center;
height: 100%;
}
&--main{
display: flex;
flex-wrap: wrap;
flex-direction: column;
@include tablet-min{
flex-direction: row;
}
}
}
&__header{
height: 250px;
position: relative;
background-size: cover;
background-repeat: no-repeat;
background-position: 50% 50%;
background-color: $c-dark;
@include tablet-min{
height: 350px;
&--page{
height: 384px;
}
}
&:before{
content: "";
display: block;
position: absolute;
top: 0;
left: 0;
z-index: 0;
width: 100%;
height: 100%;
background: rgba($c-dark, 0.85);
}
}
&__poster{
display: none;
@include tablet-min{
background: $c-dark;
display: block;
position: absolute;
width: calc(45% - 40px);
top: 40px;
left: 40px;
}
}
&__img{
display: block;
width: 100%;
opacity: 0;
transform: scale(0.97) translateZ(0);
transition: opacity 0.5s ease, transform 0.5s ease;
&.is-loaded{
opacity: 1;
transform: scale(1);
}
}
&__title{
position: relative;
padding: 20px;
color: $c-green;
text-align: center;
width: 100%;
@include tablet-min{
width: 55%;
text-align: left;
margin-left: 45%;
padding: 30px 30px 30px 40px;
}
&-text{
font-weight: 500;
line-height: 1.4;
font-size: 24px;
@include tablet-min{
font-size: 30px;
}
span{
display: block;
font-size: 14px;
font-weight: 300;
color: rgba($c-white, 0.7);
margin-top: 10px;
}
}
}
&__main{
background: $c-light;
min-height: calc(100vh - 250px);
@include tablet-min{
min-height: 0;
}
}
&__actions{
text-align: center;
width: 100%;
order: 2;
padding: 20px;
border-top: 1px solid rgba($c-dark, 0.05);
@include tablet-min{
order: 1;
width: 45%;
padding: 185px 0 40px 40px;
border-top: 0;
}
&-link{
display: flex;
align-items: center;
text-decoration: none;
text-transform: uppercase;
color: rgba($c-dark, 0.5);
transition: color 0.5s ease;
font-size: 11px;
padding: 10px 0;
border-bottom: 1px solid rgba($c-dark, 0.05);
&:hover{
color: rgba($c-dark, 0.75);
}
&.active{
color: $c-dark;
}
}
&-icon{
width: 16px;
height: 16px;
margin: 0 10px 0 0;
fill: rgba($c-dark, 0.5);
transition: fill 0.5s ease, transform 0.5s ease;
&.waiting{
transform: scale(0.8, 0.8);
}
}
&-link:hover &-icon{
fill: rgba($c-dark, 0.75);
}
&-link.active &-icon{
fill: $c-green;
}
&-text{
display: block;
padding-top: 2px;
}
}
&__info{
width: 100%;
padding: 20px;
order: 1;
@include tablet-min{
order: 2;
padding: 40px;
width: 55%;
margin-left: 45%;
}
}
&__actions + &__info{
margin-left: 0;
}
&__description{
font-weight: 300;
font-size: 13px;
line-height: 1.8;
margin-bottom: 20px;
@include tablet-min{
margin-bottom: 30px;
font-size: 14px;
}
}
&__details{
&-block:not(:last-child){
margin-bottom: 20px;
@include tablet-min{
margin-bottom: 30px;
}
}
&-title{
margin: 0;
font-weight: 400;
text-transform: uppercase;
font-size: 14px;
color: $c-green;
@include tablet-min{
font-size: 16px;
}
}
&-text{
font-weight: 300;
font-size: 14px;
margin-top: 5px;
}
}
}
</style>

View File

@@ -0,0 +1,12 @@
<template>
<div class="container info">
<movie :id="$route.params.id" :type="'page'"></movie>
</div>
</template>
<script>
import Movie from './Movie.vue';
export default {
components: { Movie }
}
</script>

View File

@@ -0,0 +1,86 @@
<template>
<div class="movie-popup" @click="$emit('close')">
<div class="movie-popup__box" @click.stop>
<movie :id="id"></movie>
<button class="movie-popup__close" @click="$emit('close')"></button>
</div>
<i class="loader"></i>
</div>
</template>
<script>
import Movie from './Movie.vue';
export default {
props: ['id'],
components: { Movie },
created(){
window.addEventListener('keyup', function(e){
if (e.keyCode == 27) {
this.$emit('close');
}
}.bind(this));
}
}
</script>
<style lang="scss">
@import "./src/scss/variables";
@import "./src/scss/media-queries";
.movie-popup{
position: fixed;
top: 0;
left: 0;
z-index: 20;
width: 100%;
height: 100vh;
background: rgba($c-dark, 0.98);
-webkit-overflow-scrolling: touch;
overflow: auto;
&__box{
width: 100%;
max-width: 768px;
position: relative;
z-index: 5;
background: $c-dark;
padding-bottom: 50px;
@include tablet-min{
padding-bottom: 0;
margin: 40px auto;
}
}
&__close{
display: block;
position: absolute;
top: 0;
right: 0;
border: 0;
background: transparent;
width: 40px;
height: 40px;
transition: background 0.5s ease;
cursor: pointer;
&:before,
&:after{
content: "";
display: block;
position: absolute;
top: 19px;
left: 10px;
width: 20px;
height: 2px;
background: $c-white;
}
&:before{
transform: rotate(45deg);
}
&:after{
transform: rotate(-45deg);
}
&:hover{
background: $c-green;
}
}
}
</style>

View File

@@ -0,0 +1,246 @@
<template>
<div class="wrapper" v-if="listLoaded">
<div class="movies" v-if="movies.length">
<header class="movies__header">
<h2 class="movies__title">{{ listTitle }}</h2>
<span class="movies__results" v-if="!shortList">{{ countResults }}</span>
<router-link v-if="shortList" class="movies__link" :to="{name: 'home-category', params: {category: category}}">
View All
</router-link>
</header>
<ul class="movies__list">
<movies-list-item class="movies__item" v-for="(movie, index) in movies" :movie="movie"></movies-list-item>
</ul>
<div class="movies__nav" v-if="!shortList" :class="{'is-hidden' : currentPage == pages}">
<button @click="loadMore" class="button">Load More</button>
</div>
</div>
<i v-if="!listLoaded" class="loader"></i>
<section v-if="!movies.length" class="not-found">
<div class="not-found__content">
<h2 class="not-found__title" v-if="mode == 'search'">Nothing Found</h2>
<h2 class="not-found__title" v-if="mode == 'favorite'">You haven't added any favorite movies</h2>
</div>
</section>
</div>
</template>
<script>
import axios from 'axios'
import numeral from 'numeral'
import storage from '../storage.js'
import MoviesListItem from './MoviesListItem.vue'
// Storage for removed favorite item
let removed;
export default {
props: ['type', 'mode', 'category', 'shortList'],
components: { MoviesListItem },
beforeRouteLeave (to, from, next) {
if(from.name == 'search'){
eventHub.$emit('setSearchQuery', true);
}
next();
},
data() {
return {
listTitle: '',
movies: [],
pages: '',
results: '',
currentPage: 1,
listLoaded: false
}
},
computed: {
pageTitle(){
return this.listTitle + storage.pageTitlePostfix;
},
query(){
return this.$route.params.query || '';
},
request(){
if(this.mode == 'search'){
return `https://api.themoviedb.org/3/search/movie?api_key=${storage.apiKey}&language=en-US&query=${this.query}&page=${this.currentPage}`;
} else if(this.mode == 'collection') {
let caregory = this.$route.params.category || this.category;
return `https://api.themoviedb.org/3/movie/${caregory}?api_key=${storage.apiKey}&language=en-US&page=${this.currentPage}`;
} else if(this.mode == 'favorite') {
return `https://api.themoviedb.org/3/account/${storage.userId}/favorite/movies?api_key=${storage.apiKey}&session_id=${storage.sessionId}&language=en-US&sort_by=created_at.desc&page=${this.currentPage}`;
}
},
countResults(){
if(this.results > 1){
return numeral(this.results).format('0,0') + ' results';
} else {
return numeral(this.results).format('0,0') + ' result';
}
}
},
methods: {
fetchCategory(){
axios.get(this.request)
.then(function(resp){
let data = resp.data;
if(this.shortList){
this.movies = data.results.slice(0, 5);
this.pages = 1;
this.results = 5;
} else {
this.movies = data.results;
this.pages = data.total_pages;
this.results = data.total_results;
}
this.listLoaded = true;
// Change Page title
if(this.type == 'page'){
document.title = this.pageTitle;
}
}.bind(this));
},
loadMore(){
this.currentPage++;
axios.get(this.request)
.then(function(resp){
let data = resp.data;
let newData = this.movies.concat(data.results);
this.movies = newData;
}.bind(this));
},
updateFavorite(){
if(this.mode == 'favorite'){
let promises = [], movies = [], pages, results;
for(let i = 1; i <= this.currentPage; i++){
promises.push(axios.get(`https://api.themoviedb.org/3/account/${storage.userId}/favorite/movies?api_key=${storage.apiKey}&session_id=${storage.sessionId}&language=en-US&sort_by=created_at.desc&page=${i}`))
}
axios.all(promises).then(function(results) {
results.forEach(function(resp) {
let data = resp.data;
movies = movies.concat(data.results);
pages = data.total_pages;
results = data.total_results;
});
this.movies = movies;
this.pages = pages;
if(this.currentPage > pages){
this.currentPage -= 1;
}
this.results = results;
}.bind(this));
}
}
},
watch: {
query(value){
this.fetchCategory(value);
}
},
created(){
// Set List Title
if(this.mode == 'search'){
this.listTitle = storage.categories['search'];
eventHub.$emit('setSearchQuery');
} else if(this.mode == 'collection') {
let caregory = this.$route.params.category || this.category;
this.listTitle = storage.categories[caregory];
} else if(this.mode == 'favorite') {
this.listTitle = storage.categories['favorite'];
}
this.fetchCategory();
eventHub.$on('updateFavorite', this.updateFavorite);
}
}
</script>
<style lang="scss">
@import "./src/scss/variables";
@import "./src/scss/media-queries";
.movies{
padding: 10px;
@include tablet-min{
padding: 15px;
}
@include tablet-landscape-min{
padding: 25px;
}
@include desktop-min{
padding: 30px;
}
&__header{
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px 10px;
@include tablet-min{
padding: 23px 15px;
}
@include tablet-landscape-min{
padding: 16px 25px;
}
@include desktop-min{
padding: 8px 30px;
}
}
&__title{
margin: 0;
font-size: 16px;
line-height: 16px;
color: $c-dark;
font-weight: 300;
@include tablet-min{
font-size: 18px;
line-height: 18px;
}
}
&__results{
font-size: 12px;
font-weight: 300;
letter-spacing: 0.5px;
color: rgba($c-dark, 0.5);
}
&__link{
font-size: 12px;
font-weight: 300;
letter-spacing: 0.5px;
color: rgba($c-dark, 0.5);
text-decoration: none;
transition: color 0.5s ease;
&:after{
content: " →";
}
&:hover{
color: $c-dark;
}
}
&__list{
padding: 0;
margin: 0;
list-style: none;
display: flex;
flex-wrap: wrap;
}
&__item{
padding: 10px;
width: 50%;
@include tablet-min{
padding: 15px;
}
@include tablet-landscape-min{
padding: 20px;
width: 25%;
}
@include desktop-min{
padding: 30px;
width: 20%;
}
}
&__nav{
padding: 25px 0;
text-align: center;
&.is-hidden{
display: none;
}
}
}
</style>

View File

@@ -0,0 +1,90 @@
<template>
<li class="movies-item">
<a class="movies-item__link" :class="{'no-image': noImage}" :href="'/movie/' + movie.id" @click.prevent="openMoviePopup(movie.id, true)">
<figure class="movies-item__poster">
<img v-if="!noImage" class="movies-item__img" src="~assets/placeholder.png" v-img="poster()" alt="">
<img v-if="noImage" class="movies-item__img is-loaded" src="~assets/no-image.png" alt="">
</figure>
<div class="movies-item__content">
<p class="movies-item__title">{{ movie.title }}</p>
</div>
</a>
</li>
</template>
<script>
import img from '../directives/v-image.js'
export default {
props: ['movie'],
directives: {
img: img
},
data(){
return{
noImage: false
}
},
methods: {
poster() {
if(this.movie.poster_path){
return 'https://image.tmdb.org/t/p/w370_and_h556_bestv1' + this.movie.poster_path;
} else {
this.noImage = true;
}
},
openMoviePopup(id, event){
eventHub.$emit('openMoviePopup', id, event);
}
}
}
</script>
<style lang="scss">
@import "./src/scss/variables";
@import "./src/scss/media-queries";
.movies-item{
&__link{
text-decoration: none;
color: rgba($c-dark, 0.5);
font-weight: 300;
}
&__content{
padding-top: 15px;
}
&__poster{
transition: transform 0.5s ease, box-shadow 0.5s ease;
transform: translateZ(0);
background: $c-white;
}
&__img{
width: 100%;
opacity: 0;
transform: scale(0.97) translateZ(0);
transition: opacity 0.5s ease, transform 0.5s ease;
&.is-loaded{
opacity: 1;
transform: scale(1);
}
}
&__link:not(.no-image):hover &__poster{
transform: scale(1.03);
box-shadow: 0 0 10px rgba($c-dark, 0.1);
}
&__title{
margin: 0;
font-size: 11px;
letter-spacing: 0.5px;
transition: color 0.5s ease;
@include mobile-ls-min{
font-size: 12px;
}
@include tablet-min{
font-size: 14px;
}
}
&__link:hover &__title{
color: $c-dark;
}
}
</style>

View File

@@ -0,0 +1,208 @@
<template>
<nav class="nav">
<router-link class="nav__logo" :to="{name: 'home'}" exact title="Vue.js — TMDb App">
<svg class="nav__logo-image">
<use xlink:href="#svgLogo"></use>
</svg>
</router-link>
<ul class="nav__list">
<li class="nav__item" v-for="item in listTypes" v-if="item.isCategory">
<router-link class="nav__link" :to="{name: 'home-category', params: {category: item.query}}">
<div class="nav__link-wrap">
<svg class="nav__link-icon">
<use :xlink:href="'#icon_' + item.query"></use>
</svg>
<span class="nav__link-title">{{ item.shortTitle }}</span>
</div>
</router-link>
</li>
<li class="nav__item nav__item--profile">
<div class="nav__link nav__link--profile" @click="requestToken" v-if="!userLoggedIn">
<div class="nav__link-wrap">
<svg class="nav__link-icon">
<use xlink:href="#iconLogin"></use>
</svg>
<span class="nav__link-title">Log In</span>
</div>
</div>
<router-link class="nav__link nav__link--profile" :to="{name: 'profile'}" v-if="userLoggedIn">
<div class="nav__link-wrap">
<svg class="nav__link-icon">
<use xlink:href="#iconLogin"></use>
</svg>
<span class="nav__link-title">Profile</span>
</div>
</router-link>
</li>
</ul>
</nav>
</template>
<script>
import storage from '../storage.js'
export default {
data(){
return {
listTypes: storage.listTypes,
userLoggedIn: storage.sessionId ? true : false
}
},
methods: {
setUserStatus(){
this.userLoggedIn = storage.sessionId ? true : false;
},
requestToken(){
eventHub.$emit('requestToken');
}
},
created(){
eventHub.$on('setUserStatus', this.setUserStatus);
}
}
</script>
<style lang="scss">
@import "./src/scss/variables";
@import "./src/scss/media-queries";
.nav{
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 50px;
background: $c-white;
display: flex;
z-index: 10;
@include tablet-min{
display: block;
width: 95px;
height: 100vh;
}
&__logo{
display: block;
width: 55px;
height: 50px;
display: flex;
align-items: center;
justify-content: center;
background: $c-dark;
@include tablet-min{
width: 95px;
height: 75px;
}
&-image{
width: 35px;
height: 31px;
fill: $c-green;
transition: transform 0.5s ease;
@include tablet-min{
width: 45px;
height: 40px;
}
}
&:hover &-image{
transform: scale(1.04);
}
}
&__list{
list-style: none;
padding: 0;
margin: 0;
text-align: center;
width: 100%;
display: flex;
position: fixed;
left: 0;
top: 50px;
background: $c-white;
border-top: 1px solid $c-light;
@include tablet-min{
background: transparent;
position: relative;
display: block;
width: 100%;
border-top: 0;
top: 0;
}
}
&__item{
width: 20%;
&:not(:first-child){
border-left: 1px solid $c-light;
}
@include tablet-min{
width: 100%;
border-left: 0;
border-bottom: 1px solid $c-light;
&--profile{
position: fixed;
right: 0;
top: 0;
width: 75px;
height: 75px;
border-bottom: 0;
}
}
}
&__link{
width: 100%;
height: 50px;
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
font-size: 7px;
font-weight: 300;
text-decoration: none;
text-transform: uppercase;
letter-spacing: 0.5px;
color: rgba($c-dark, 0.7);
transition: color 0.5s ease, background 0.5s ease;
position: relative;
cursor: pointer;
@include mobile-ls-min{
font-size: 8px;
}
@include tablet-min{
width: 95px;
height: 95px;
font-size: 9px;
&--profile{
width: 75px;
height: 75px;
background: $c-white;
}
}
&-icon{
width: 15px;
height: 15px;
margin-bottom: 3px;
fill: rgba($c-dark, 0.7);
transition: fill 0.5s ease;
@include tablet-min{
width: 20px;
height: 20px;
margin-bottom: 5px;
}
}
&-title{
display: block;
width: 100%;
}
&:hover{
color: $c-dark;
}
&:hover &-icon{
fill: $c-dark;
}
&.is-active{
color: $c-dark;
background: $c-light;
}
&.is-active &-icon{
fill: $c-dark;
}
}
}
</style>

136
src/components/Profile.vue Normal file
View File

@@ -0,0 +1,136 @@
<template>
<section class="profile">
<div class="profile__content" v-if="userLoggedIn === true">
<header class="profile__header">
<h2 class="profile__title">Hello {{ userName }}</h2>
<button class="button" @click="logOut">Log Out</button>
</header>
<movies-list :type="'component'" :mode="'favorite'"></movies-list>
<!-- <created-lists></created-lists> -->
</div>
<section class="not-found" v-if="userLoggedIn === false">
<div class="not-found__content">
<h2 class="not-found__title">Authentication Request Failed</h2>
<button class="not-found__button button" @click="requestToken">Log In</button>
</div>
</section>
</section>
</template>
<script>
import axios from 'axios'
import storage from '../storage.js'
import MoviesList from './MoviesList.vue'
// import CreatedLists from './CreatedLists.vue'
export default {
components: { MoviesList },
data(){
return{
userLoggedIn: '',
userName: ''
}
},
methods: {
requestPermission(){
let query = location.search.substring(1);
if(query.length){
let params = query.split('&');
let token = params[0].split('=')[1];
let status = params[1].split('=')[0];
if(status == 'approved'){
this.createSession(token);
} else {
this.userLoggedIn = false;
}
} else {
this.userLoggedIn = false;
}
},
createSession(token){
axios.get(`https://api.themoviedb.org/3/authentication/session/new?api_key=${storage.apiKey}&request_token=${token}`)
.then(function(resp){
let data = resp.data;
if(data.success){
let id = data.session_id;
localStorage.setItem('session_id', id);
eventHub.$emit('setUserStatus');
this.userLoggedIn = true;
this.getUserInfo();
}
}.bind(this));
},
getUserInfo(){
axios.get(`https://api.themoviedb.org/3/account?api_key=${storage.apiKey}&session_id=${storage.sessionId}`)
.then(function(resp){
let data = resp.data;
this.userName = data.username;
if (!localStorage.getItem('user_id')) localStorage.setItem('user_id', data.id);
}.bind(this))
.catch(function (error) {
this.logOut();
}.bind(this));
},
requestToken(){
eventHub.$emit('requestToken');
},
logOut(){
localStorage.clear();
eventHub.$emit('setUserStatus');
this.$router.push({ name: 'home' });
}
},
created(){
document.title = 'Profile' + storage.pageTitlePostfix;
storage.backTitle = document.title;
if(!storage.sessionId){
this.requestPermission();
} else {
this.userLoggedIn = true;
this.getUserInfo();
}
}
}
</script>
<style lang="scss">
@import "./src/scss/variables";
@import "./src/scss/media-queries";
.profile{
&__content{
.wrapper{
min-height: calc(100vh - 175px);
@include tablet-min{
min-height: calc(100vh - 171px);
}
}
}
&__header{
display: flex;
align-items: center;
justify-content: space-between;
padding: 20px;
border-bottom: 1px solid rgba($c-dark, 0.05);
@include tablet-min{
padding: 29px 30px;
}
@include tablet-landscape-min{
padding: 29px 50px;
}
@include desktop-min{
padding: 29px 60px;
}
}
&__title{
margin: 0;
font-size: 16px;
line-height: 16px;
color: $c-dark;
font-weight: 300;
@include tablet-min{
font-size: 18px;
line-height: 18px;
}
}
}
</style>

View File

@@ -0,0 +1,15 @@
let setValue = function(el, binding) {
let value = binding.value;
let dateArray = value.split('-');
let monthsArray = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'June', 'July', 'Aug', 'Sept', 'Oct', 'Nov', 'Dec'];
el.innerText = `${dateArray[2]} ${monthsArray[+dateArray[1] - 1]} ${dateArray[0]}`;
};
module.exports = {
isLiteral: true,
bind(el, binding) {
setValue(el, binding);
},
update(el, binding) {
setValue(el, binding);
}
}

19
src/directives/v-image.js Normal file
View File

@@ -0,0 +1,19 @@
let setValue = function(el, binding) {
let img = new Image();
img.src = binding.value;
img.onload = function() {
this.src = img.src;
this.classList.add("is-loaded");
}.bind(el);
};
module.exports = {
isLiteral: true,
bind(el, binding){
setValue(el, binding);
},
update(el, binding){
setValue(el, binding);
}
}

17
src/main.js Normal file
View File

@@ -0,0 +1,17 @@
import Vue from 'vue'
import VueRouter from 'vue-router'
import axios from 'axios'
import router from './routes'
import App from './App.vue'
window.eventHub = new Vue();
Vue.use(VueRouter, axios)
new Vue({
el: '#app',
router,
render: h => h(App)
})

BIN
src/no-image.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

65
src/routes.js Normal file
View File

@@ -0,0 +1,65 @@
import VueRouter from 'vue-router';
let routes = [
{
name: 'home',
path: '/',
components: {
'list-router-view': require('./components/Home.vue')
}
},
{
name: 'home-category',
path: '/movies/:category',
components: {
'list-router-view': require('./components/MoviesList.vue')
}
},
{
name: 'search',
path: '/search/:query',
components: {
'search-router-view': require('./components/MoviesList.vue')
}
},
{
name: 'movie',
path: '/movie/:id',
components: {
'page-router-view': require('./components/MoviePage.vue')
},
beforeEnter: (to, from, next) => {
if(history.state && history.state.popup){
eventHub.$emit('openMoviePopup', to.params.id, false);
return;
}
next();
}
},
{
name: 'profile',
path: '/profile',
components: {
'search-router-view': require('./components/Profile.vue')
}
},
{
name: '404',
path: '/404',
components: {
'page-router-view': require('./components/404.vue')
}
},
{
path: '*',
redirect: '/404'
}
];
const router = new VueRouter({
mode: 'history',
routes,
linkActiveClass: 'is-active'
});
export default router;

View File

@@ -0,0 +1,48 @@
// Media queries settings
$phone-xs-width: 480px;
$tablet-p-width: 768px;
$tablet-l-width: 1024px;
$desktop-width: 1200px;
// Media
@mixin mobile-ls-only{
@media (min-width: #{$phone-xs-width}) and (max-width: #{$tablet-p-width - 1px}){
@content;
}
}
@mixin mobile-ls-min{
@media (min-width: #{$phone-xs-width}){
@content;
}
}
@mixin tablet-only{
@media (min-width: #{$tablet-p-width}) and (max-width: #{$desktop-width - 1px}){
@content;
}
}
@mixin tablet-min{
@media (min-width: #{$tablet-p-width}){
@content;
}
}
@mixin tablet-portrait-only{
@media (min-width: #{$tablet-p-width}) and (max-width: #{$tablet-l-width - 1px}){
@content;
}
}
@mixin tablet-landscape-min{
@media (min-width: #{$tablet-l-width}){
@content;
}
}
@mixin desktop-min{
@media (min-width: #{$desktop-width}){
@content;
}
}
@mixin retina{
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi){
@content;
}
}

5
src/scss/variables.scss Normal file
View File

@@ -0,0 +1,5 @@
// Colors
$c-green: #01d277;
$c-dark: #081c24;
$c-white: #ffffff;
$c-light: #f8f8f8;

59
src/storage.js Normal file
View File

@@ -0,0 +1,59 @@
let storage = {
apiKey: 'a70dbfe19b800809dfdd3e89e8532c9e',
sessionId: localStorage.getItem('session_id') || null,
userId: localStorage.getItem('user_id') || null,
pageTitlePostfix: ' — ' + document.title,
listTypes: [
{
title: 'Popular Movies',
shortTitle: 'Popular',
query: 'popular',
type: 'collection',
isCategory: true
},
{
title: 'Top Rated Movies',
shortTitle: 'Top Rated',
query: 'top_rated',
type: 'collection',
isCategory: true
},
{
title: 'Upcoming Movies',
shortTitle: 'Upcoming',
query: 'upcoming',
type: 'collection',
isCategory: true
},
{
title: 'Now Playing Movies',
shortTitle: 'Now Playing',
query: 'now_playing',
type: 'collection',
isCategory: true
},
{
title: 'Search Results',
query: 'search',
isCategory: false
},
{
title: 'Your Favorite Movies',
query: 'favorite',
isCategory: false
}
],
categories: {},
// For Browser History
backTitle: '',
moviePath: '',
createMoviePopup: false,
moviePopupOnHistory: false
};
// Create categories titles
storage.listTypes.forEach(function(listType){
storage.categories[listType.query] = listType.title;
});
export default storage;

74
webpack.config.js Normal file
View File

@@ -0,0 +1,74 @@
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build.js'
},
module: {
rules: [
{
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
'scss': 'vue-style-loader!css-loader!sass-loader',
'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
}
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.common.js',
'src': path.resolve(__dirname, './src'),
'assets': path.resolve(__dirname, './src/assets'),
'components': path.resolve(__dirname, './src/components')
}
},
devServer: {
historyApiFallback: true,
noInfo: true
},
performance: {
hints: false
},
devtool: '#eval-source-map'
}
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}