From 502bf88feba19a10ffe82e64fc777f60f14d3ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Delattre?= Date: Wed, 26 Jun 2019 14:08:25 +0200 Subject: [PATCH] Update asset management in webpack This hashes every file and forces the browser to download updated assets. --- backend/movies/movies.go | 3 +- backend/shows/shows.go | 3 +- frontend/index.html | 9 +- frontend/js/app.js | 15 +- frontend/js/components/list/poster.js | 6 +- package.json | 2 + webpack.config.js | 47 +++- yarn.lock | 360 +++++++++++++++++++++++++- 8 files changed, 406 insertions(+), 39 deletions(-) diff --git a/backend/movies/movies.go b/backend/movies/movies.go index 6a04234..5639c85 100644 --- a/backend/movies/movies.go +++ b/backend/movies/movies.go @@ -245,8 +245,7 @@ func (m *Movie) imgFile() string { func (m *Movie) PosterURL() string { // Check if the movie image exists if _, err := os.Stat(m.imgFile()); os.IsNotExist(err) { - // TODO image in the config ? - return m.imgURLPrefix + "noimage.png" + return "" } return m.imgURLPrefix + m.imgURL() } diff --git a/backend/shows/shows.go b/backend/shows/shows.go index 09f0ee2..6393476 100644 --- a/backend/shows/shows.go +++ b/backend/shows/shows.go @@ -154,8 +154,7 @@ func (s *Show) Refresh(env *web.Env, detailers []polochon.Detailer) error { func (s *Show) GetImageURL(imgType string) string { // Check if the show image exists if _, err := os.Stat(s.imgFile(imgType)); os.IsNotExist(err) { - // TODO image in the config ? - return s.imgURLPrefix + "noimage.png" + return "" } return s.imgURLPrefix + s.imgURL(imgType) } diff --git a/frontend/index.html b/frontend/index.html index 30486c5..7e9610d 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -5,18 +5,17 @@ - - - + "> + " sizes="32x32"> + " sizes="16x16"> - + " color="#5bbad5"> Canapé
- diff --git a/frontend/js/app.js b/frontend/js/app.js index 1cad240..13ed328 100644 --- a/frontend/js/app.js +++ b/frontend/js/app.js @@ -1,15 +1,12 @@ -// Html page -import "file-loader?name=[name].[ext]!../index.html" - // Import default image -import "file-loader?name=img/[name].[ext]!../img/noimage.png" +import "../img/noimage.png" // Import favicon settings -import "file-loader?name=[name].[ext]!../img/apple-touch-icon.png" -import "file-loader?name=[name].[ext]!../img/favicon-16x16.png" -import "file-loader?name=[name].[ext]!../img/favicon-32x32.png" -import "file-loader?name=[name].[ext]!../img/favicon.ico" -import "file-loader?name=[name].[ext]!../img/safari-pinned-tab.svg" +import "../img/apple-touch-icon.png" +import "../img/favicon-16x16.png" +import "../img/favicon-32x32.png" +import "../img/favicon.ico" +import "../img/safari-pinned-tab.svg" // Styles import "../scss/app.scss" diff --git a/frontend/js/components/list/poster.js b/frontend/js/components/list/poster.js index d7178d0..485e4dd 100644 --- a/frontend/js/components/list/poster.js +++ b/frontend/js/components/list/poster.js @@ -2,11 +2,15 @@ import React from "react" import PropTypes from "prop-types" import { Map } from "immutable" +import EmptyImg from "../../../img/noimage.png" + const Poster = (props) => { const className = props.selected ? "border-primary thumbnail-selected" : "border-secondary"; + const src = (props.data.get("poster_url") === "") ? EmptyImg : props.data.get("poster_url"); + return (