Added release page.
This commit is contained in:
parent
7825ae2727
commit
fda6d1e475
|
@ -18,5 +18,6 @@
|
|||
"react/jsx-uses-vars": 2,
|
||||
"react/jsx-indent": ["error", 4],
|
||||
"react/jsx-indent-props": ["error", 4],
|
||||
"react/jsx-one-expression-per-line": "off",
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,6 +17,8 @@ const Home = ({ releases }) => (
|
|||
<span className="scene-details">
|
||||
<a
|
||||
href={`/site/${release.site.id}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="scene-site site-link"
|
||||
title={release.network.name}
|
||||
>
|
||||
|
@ -33,16 +35,23 @@ const Home = ({ releases }) => (
|
|||
</a>
|
||||
</span>
|
||||
|
||||
<a
|
||||
href={`/scene/${release.id}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="scene-row scene-link"
|
||||
>
|
||||
<img
|
||||
src={`/${release.site.id}/${release.id}/0.jpg`}
|
||||
alt={release.id}
|
||||
className="scene-thumbnail"
|
||||
/>
|
||||
</a>
|
||||
</span>
|
||||
|
||||
<div className="scene-info">
|
||||
<a
|
||||
href={`/item/${release.id}`}
|
||||
href={`/scene/${release.id}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="scene-row scene-link"
|
||||
|
@ -59,6 +68,8 @@ const Home = ({ releases }) => (
|
|||
>
|
||||
<a
|
||||
href={`/actor/${actor.id}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="actor-link"
|
||||
>
|
||||
{actor.name}
|
||||
|
@ -80,6 +91,8 @@ const Home = ({ releases }) => (
|
|||
>
|
||||
<a
|
||||
href={`/tag/${tag.tag}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="tag-link"
|
||||
>
|
||||
{tag.tag}
|
||||
|
|
|
@ -3,10 +3,13 @@
|
|||
const React = require('react');
|
||||
const PropTypes = require('prop-types');
|
||||
|
||||
const Layout = ({ children }) => (
|
||||
const Layout = ({ children, title }) => (
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Porn Radar</title>
|
||||
{title
|
||||
? <title>Porn Radar | {title}</title>
|
||||
: <title>Porn Radar</title>
|
||||
}
|
||||
|
||||
<link href="/css/style.css" rel="stylesheet" />
|
||||
</head>
|
||||
|
@ -25,6 +28,11 @@ const Layout = ({ children }) => (
|
|||
|
||||
Layout.propTypes = {
|
||||
children: PropTypes.node.isRequired,
|
||||
title: PropTypes.string,
|
||||
};
|
||||
|
||||
Layout.defaultProps = {
|
||||
title: null,
|
||||
};
|
||||
|
||||
module.exports = Layout;
|
||||
|
|
|
@ -0,0 +1,93 @@
|
|||
'use strict';
|
||||
|
||||
const React = require('react');
|
||||
const PropTypes = require('prop-types');
|
||||
const moment = require('moment');
|
||||
|
||||
const Layout = require('./layout.jsx');
|
||||
|
||||
const Release = ({ release, thumbnails }) => (
|
||||
<Layout title={release.title}>
|
||||
<div>
|
||||
<h2>{release.title}</h2>
|
||||
<p>{moment(release.date).format('MMMM DD, YYYY')}</p>
|
||||
<p>{release.shootId}</p>
|
||||
|
||||
<h3>
|
||||
<a
|
||||
href={`/site/${release.site.id}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
title={release.network.name}
|
||||
>
|
||||
{release.site.name}
|
||||
</a>
|
||||
</h3>
|
||||
|
||||
<p>{release.network.name}</p>
|
||||
|
||||
<p>
|
||||
<a
|
||||
href={release.url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
View on {new URL(release.site.url).host.replace('www.', '')}
|
||||
</a>
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
{release.actors.map(actor => (
|
||||
<li key={actor.id}>
|
||||
<a
|
||||
href={`/actor/${actor.id}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="actor-link"
|
||||
>
|
||||
{actor.name}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
<p>{release.description}</p>
|
||||
|
||||
<ul>
|
||||
{release.tags.map(tag => (
|
||||
<li key={tag.tag}>
|
||||
<a
|
||||
href={`/tag/${tag.tag}`}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="actor-link"
|
||||
>
|
||||
{tag.tag}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
{thumbnails.map((thumbnail, index) => (
|
||||
<img
|
||||
key={thumbnail}
|
||||
src={`/${release.site.id}/${release.id}/${thumbnail}`}
|
||||
alt={`Thumbnail ${index}`}
|
||||
className="thumbnail"
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</Layout>
|
||||
);
|
||||
|
||||
Release.propTypes = {
|
||||
release: PropTypes.object,
|
||||
thumbnails: PropTypes.arrayOf(PropTypes.string),
|
||||
};
|
||||
|
||||
Release.defaultProps = {
|
||||
release: null,
|
||||
thumbnails: [],
|
||||
};
|
||||
|
||||
module.exports = Release;
|
|
@ -132,3 +132,7 @@ body {
|
|||
.tag-link {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.thumbnail {
|
||||
width: 300px;
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ async function curateRelease(release) {
|
|||
site: {
|
||||
id: release.site_id,
|
||||
name: release.site_name,
|
||||
url: release.site_url,
|
||||
},
|
||||
network: {
|
||||
id: release.network_id,
|
||||
|
@ -45,9 +46,10 @@ function curateReleases(releases) {
|
|||
return Promise.all(releases.map(async release => curateRelease(release)));
|
||||
}
|
||||
|
||||
async function fetchReleases() {
|
||||
async function fetchReleases(releaseId) {
|
||||
const releases = await knex('releases')
|
||||
.select('releases.*', 'sites.name as site_name', 'sites.network_id', 'networks.name as network_name', 'networks.url as network_url')
|
||||
.where(releaseId ? { 'releases.id': releaseId } : {})
|
||||
.select('releases.*', 'sites.name as site_name', 'sites.url as site_url', 'sites.network_id', 'networks.name as network_name', 'networks.url as network_url')
|
||||
.leftJoin('sites', 'releases.site_id', 'sites.id')
|
||||
.leftJoin('networks', 'sites.network_id', 'networks.id')
|
||||
.orderBy('date', 'desc')
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
'use strict';
|
||||
|
||||
const config = require('config');
|
||||
const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
|
||||
const { fetchReleases } = require('../releases');
|
||||
|
||||
async function fetchReleasesApi(req, res) {
|
||||
|
@ -8,6 +12,14 @@ async function fetchReleasesApi(req, res) {
|
|||
res.render('home', { releases });
|
||||
}
|
||||
|
||||
async function fetchReleaseApi(req, res) {
|
||||
const [release] = await fetchReleases(req.params.id);
|
||||
const thumbnails = await fs.readdir(path.join(config.thumbnailPath, release.site.id.toString(), release.id.toString()));
|
||||
|
||||
res.render('release', { release, thumbnails });
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fetchReleases: fetchReleasesApi,
|
||||
fetchRelease: fetchReleaseApi,
|
||||
};
|
||||
|
|
|
@ -6,7 +6,7 @@ const express = require('express');
|
|||
const Router = require('express-promise-router');
|
||||
const { createEngine } = require('express-react-views');
|
||||
|
||||
const { fetchReleases } = require('./releases');
|
||||
const { fetchReleases, fetchRelease } = require('./releases');
|
||||
|
||||
function initServer() {
|
||||
const app = express();
|
||||
|
@ -20,6 +20,7 @@ function initServer() {
|
|||
app.engine('jsx', createEngine());
|
||||
|
||||
router.get('/', fetchReleases);
|
||||
router.get('/scene/:id', fetchRelease);
|
||||
|
||||
app.use(router);
|
||||
|
||||
|
|
Loading…
Reference in New Issue