Added actors page. Added site logos with overview on network page.

This commit is contained in:
ThePendulum 2019-11-10 04:20:22 +01:00
parent 76618cee83
commit a9b91ff76c
44 changed files with 1065 additions and 13 deletions

View File

@ -1,5 +1,126 @@
<template> <template>
<div> <div
<h2>Actor</h2> v-if="actor"
class="content actor"
>
<div class="header">
<h2 class="title">{{ actor.name }}</h2>
</div>
<span class="description">{{ actor.description }}</span>
<div class="content-inner">
<h3 class="heading">Biography</h3>
<ul class="bio">
<li v-if="actor.aliases.length">
<dfn class="bio-heading">Also known as</dfn>
<span>{{ actor.aliases.join(', ') }}</span>
</li>
<li>
<dfn class="bio-heading">Born in</dfn>
<span v-if="actor.city">{{ actor.city }}</span>
<span>{{ actor.country || 'Unknown' }}</span>
</li>
<li>
<dfn class="bio-heading">Date of birth</dfn>
<span>{{ actor.birthdate || 'Unknown' }}</span>
</li>
<li>
<dfn class="bio-heading">Ethnicity</dfn>
<span>{{ actor.ethnicity || 'Unknown' }}</span>
</li>
<li>
<dfn class="bio-heading">Height</dfn>
<span>{{ actor.height || 'Unknown' }}</span>
</li>
<li>
<dfn class="bio-heading">Boobs</dfn>
<span>Size: {{ actor.boobSize || 'Unknown' }}</span>
<span v-if="actor.boobsNatural !== null">{{ actor.boobsNatural ? 'Natural' : 'Enhanced' }}</span>
</li>
</ul>
<h3 class="heading">Latest releases</h3>
<ul class="nolist scenes">
<li
v-for="release in releases"
:key="`release-${release.id}`"
>
<ReleaseTile :release="release" />
</li>
</ul>
</div>
</div> </div>
</template> </template>
<script>
import ReleaseTile from '../tile/release.vue';
async function mounted() {
[this.actor] = await this.$store.dispatch('fetchActors', this.$route.params.actorSlug);
this.releases = await this.$store.dispatch('fetchActorReleases', this.$route.params.actorSlug);
this.pageTitle = this.actor.name;
}
export default {
components: {
ReleaseTile,
},
data() {
return {
actor: null,
releases: null,
pageTitle: null,
};
},
mounted,
};
</script>
<style lang="scss" scoped>
@import 'theme';
.header {
display: flex;
justify-content: space-between;
padding: 1rem;
}
.title {
display: inline-block;
margin: 0 .5rem 0 0;
}
.heading {
padding: 0;
margin: 0 0 1rem 0;
}
.bio-heading {
display: inline-block;
font-weight: bold;
margin: .5rem 0 0 0;
&::after {
content: ':';
}
}
.scenes {
display: grid;
grid-gap: 1rem;
margin: 0 0 1rem 0;
}
.scenes {
grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
}
</style>

View File

@ -0,0 +1,34 @@
<template>
<div class="errorpage">
<h1 class="error">404 - Not Found</h1>
<a
href="/"
class="home"
>Take me home</a>
</div>
</template>
<style lang="scss" scoped>
@import 'theme';
.errorpage {
background: $background;
color: $primary;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: 2rem;
}
.error {
margin: 0;
}
.home {
color: $shadow;
margin: 3rem 0;
}
</style>

View File

@ -0,0 +1,127 @@
<template>
<div
v-if="network"
class="content network"
>
<div class="header">
<span class="intro">
<h2 class="title">
{{ network.name }}
<a
:href="network.url"
target="_blank"
rel="noopener noreferrer"
>
<Icon
icon="new-tab"
class="icon-href"
/>
</a>
</h2>
<span class="description">{{ network.description }}</span>
</span>
<a
:href="network.url"
target="_blank"
rel="noopener noreferrer"
>
<img
:src="`/img/networks/${network.slug}.png`"
class="logo"
>
</a>
</div>
<div class="content-inner">
<h3 class="heading">Sites</h3>
<ul class="nolist sites">
<li
v-for="site in network.sites"
:key="`site-${site.id}`"
>
<SiteTile :site="site" />
</li>
</ul>
<h3 class="heading">Latest releases</h3>
<ul class="nolist scenes">
<li
v-for="release in releases"
:key="`release-${release.id}`"
>
<ReleaseTile :release="release" />
</li>
</ul>
</div>
</div>
</template>
<script>
import ReleaseTile from '../tile/release.vue';
import SiteTile from '../tile/site.vue';
async function mounted() {
[this.network] = await this.$store.dispatch('fetchNetworks', this.$route.params.networkSlug);
this.releases = await this.$store.dispatch('fetchNetworkReleases', this.$route.params.networkSlug);
this.pageTitle = this.network.name;
}
export default {
components: {
ReleaseTile,
SiteTile,
},
data() {
return {
network: null,
releases: null,
pageTitle: null,
};
},
mounted,
};
</script>
<style lang="scss" scoped>
@import 'theme';
.header {
display: flex;
justify-content: space-between;
padding: 1rem;
}
.title {
display: inline-block;
margin: 0 .5rem 0 0;
}
.heading {
padding: 0;
margin: 0 0 1rem 0;
}
.logo {
height: 3rem;
}
.sites,
.scenes {
display: grid;
grid-gap: 1rem;
margin: 0 0 1rem 0;
}
.scenes {
grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
}
.sites {
grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
}
</style>

View File

@ -0,0 +1,5 @@
<template>
<div>
<h1>Site</h1>
</div>
</template>

View File

@ -0,0 +1,257 @@
<template>
<div class="tile">
<span class="banner">
<span class="details">
<a
:href="`/site/${release.site.slug}`"
:title="release.network.name"
target="_blank"
rel="noopener noreferrer"
class="site site-link"
>{{ release.site.name }}</a>
<a
v-if="release.date"
:href="release.url"
target="_blank"
rel="noopener noreferrer"
class="date"
>{{ formatDate(release.date, 'MMM D, YYYY') }}</a>
<a
v-else
:href="release.url"
title="Scene date N/A, showing date added"
target="_blank"
rel="noopener noreferrer"
class="date"
>{{ `(${formatDate(release.dateAdded, 'MMM D, YYYY')})` }}`</a>
</span>
<a
:href="`/scene/${release.id}`"
class="link"
>
<img
v-if="release.poster"
:src="`/media/${release.poster.path}`"
:alt="release.title"
class="thumbnail"
>
<img
v-else-if="release.photos.length > 0"
:src="`/media/${release.photos[0].path}`"
:alt="release.title"
class="thumbnail"
>
<div
v-else
:title="release.title"
class="thumbnail"
>No thumbnail available</div>
</a>
</span>
<div class="info">
<a
:href="`/scene/${release.id}`"
class="row link"
>
<h3
:title="release.title"
class="title"
>{{ release.title }}</h3>
</a>
<span class="row">
<ul class="actors nolist">
<li
v-for="actor in release.actors"
:key="actor.id"
class="actor"
>
<a
:href="`/actor/${actor.slug}`"
class="actor-link"
>{{ actor.name }}</a>
</li>
</ul>
</span>
<span
:title="release.tags.map(tag => tag.name).join(', ')"
class="row"
>
<ul class="tags nolist">
<li
v-for="tag in release.tags"
:key="`tag-${tag.slug}`"
class="tag"
>
<a
:href="`/tag/${tag.slug}`"
target="_blank"
rel="noopener noreferrer"
class="tag-link"
>{{ tag.name }}</a>
</li>
</ul>
</span>
</div>
</div>
</template>
<script>
export default {
props: {
release: {
type: Object,
default: null,
},
},
};
</script>
<style lang="scss" scoped>
@import 'theme';
.tile {
display: flex;
flex-direction: column;
box-sizing: border-box;
padding: 0 0 .5rem 0;
border-radius: .25rem;
overflow: hidden;
box-shadow: 0 0 3px rgba(0, 0, 0, .25);
height: 100%;
}
.banner {
position: relative;
margin: 0 0 .5rem 0;
}
.thumbnail {
width: 100%;
height: 12rem;
display: flex;
justify-content: center;
align-items: center;
object-fit: cover;
background-position: center;
background-size: cover;
background-color: $shadow-hint;
color: $shadow;
text-shadow: 1px 1px 0 $highlight;
}
.row {
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
padding: 0 .5rem;
margin: 0 0 .25rem 0;
}
.details {
width: 100%;
display: flex;
align-items: center;
justify-content: space-between;
position: absolute;
}
.site,
.date {
color: #fff;
background: rgba(0, 0, 0, .5);
font-size: .8rem;
padding: .25rem;
text-decoration: none;
}
.site {
border-radius: 0 0 .25rem 0;
font-weight: bold;
}
.date {
border-radius: 0 0 0 .25rem;
}
.info {
flex-grow: 1;
}
.link {
text-decoration: none;
}
.title {
color: $text;
margin: 0;
font-size: 1rem;
word-wrap: break-word;
overflow: hidden;
max-height: 3rem;
line-height: 1.5rem;
}
.network {
color: #555;
margin: 0 .25rem 0 0;
font-size: .8rem;
}
.actors {
word-wrap: break-word;
overflow: hidden;
max-height: 2.5rem;
line-height: 1.25rem;
}
.tags {
word-wrap: break-word;
overflow: hidden;
max-height: 2.5rem;
line-height: 1.25rem;
}
.actor,
.tag {
margin: 0 .25rem 0 0;
}
.actor {
font-size: .9rem;
}
.tag {
font-size: .75rem;
}
.actor:not(:last-of-type)::after,
.tag:not(:last-child):after {
content: ",";
}
.actor-link,
.tag-link {
text-decoration: none;
&:hover {
color: $primary;
}
}
.actor-link {
color: $link;
}
.tag-link {
color: $shadow-strong;
}
</style>

View File

@ -0,0 +1,60 @@
<template>
<a
:href="`/site/${site.slug}`"
class="tile"
>
<h3 class="title">
<object
:data="`/img/sites/${site.slug}.png`"
type="image/png"
class="logo"
>{{ site.name }}</object>
</h3>
</a>
</template>
<script>
export default {
props: {
site: {
type: Object,
default: null,
},
},
};
</script>
<style lang="scss" scoped>
@import 'theme';
.tile {
display: flex;
flex-direction: column;
align-items: center;
box-sizing: border-box;
padding: 1rem;
border-radius: .25rem;
box-shadow: 0 0 3px rgba(0, 0, 0, .25);
height: 100%;
text-align: center;
}
.link {
text-decoration: none;
}
.logo {
width: 100%;
height: 4rem;
object-fit: contain;
}
.title {
color: $text;
height: 100%;
display: flex;
align-items: center;
margin: 0;
font-size: 1rem;
}
</style>

6
assets/img/link.svg Normal file
View File

@ -0,0 +1,6 @@
<!-- Generated by IcoMoon.io -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<title>link</title>
<path d="M6.879 9.934c-0.208 0-0.416-0.079-0.575-0.238-1.486-1.486-1.486-3.905 0-5.392l3-3c0.72-0.72 1.678-1.117 2.696-1.117s1.976 0.397 2.696 1.117c1.486 1.487 1.486 3.905 0 5.392l-1.371 1.371c-0.317 0.317-0.832 0.317-1.149 0s-0.317-0.832 0-1.149l1.371-1.371c0.853-0.853 0.853-2.241 0-3.094-0.413-0.413-0.963-0.641-1.547-0.641s-1.134 0.228-1.547 0.641l-3 3c-0.853 0.853-0.853 2.241 0 3.094 0.317 0.317 0.317 0.832 0 1.149-0.159 0.159-0.367 0.238-0.575 0.238z"></path>
<path d="M4 15.813c-1.018 0-1.976-0.397-2.696-1.117-1.486-1.486-1.486-3.905 0-5.392l1.371-1.371c0.317-0.317 0.832-0.317 1.149 0s0.317 0.832 0 1.149l-1.371 1.371c-0.853 0.853-0.853 2.241 0 3.094 0.413 0.413 0.962 0.641 1.547 0.641s1.134-0.228 1.547-0.641l3-3c0.853-0.853 0.853-2.241 0-3.094-0.317-0.317-0.317-0.832 0-1.149s0.832-0.317 1.149 0c1.486 1.486 1.486 3.905 0 5.392l-3 3c-0.72 0.72-1.678 1.117-2.696 1.117z"></path>
</svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

6
assets/img/new-tab.svg Normal file
View File

@ -0,0 +1,6 @@
<!-- Generated by IcoMoon.io -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<title>new-tab</title>
<path d="M11 13h-8v-8h4.5l2-2h-8.5v12h12v-8.5l-2 2v4.5z"></path>
<path d="M16 0h-6.5l2.5 2.5-7.5 7.5 1.5 1.5 7.5-7.5 2.5 2.5v-6.5z"></path>
</svg>

After

Width:  |  Height:  |  Size: 301 B

6
assets/img/new-tab2.svg Normal file
View File

@ -0,0 +1,6 @@
<!-- Generated by IcoMoon.io -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<title>new-tab2</title>
<path d="M3 1v12h12v-12h-12zM14 12h-10v-10h10v10zM2 14v-10.5l-1-1v12.5h12.5l-1-1h-10.5z"></path>
<path d="M5.5 4l2.5 2.5-3 3 1.5 1.5 3-3 2.5 2.5v-6.5z"></path>
</svg>

After

Width:  |  Height:  |  Size: 322 B

5
assets/img/share2.svg Normal file
View File

@ -0,0 +1,5 @@
<!-- Generated by IcoMoon.io -->
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<title>share2</title>
<path d="M4 10c0 0 0.919-3 6-3v3l6-4-6-4v3c-4 0-6 2.495-6 5zM11 12h-9v-6h1.967c0.158-0.186 0.327-0.365 0.508-0.534 0.687-0.644 1.509-1.135 2.439-1.466h-6.914v10h13v-4.197l-2 1.333v0.864z"></path>
</svg>

After

Width:  |  Height:  |  Size: 356 B

View File

@ -0,0 +1,22 @@
import { get } from '../api';
function initActorActions(_store, _router) {
async function fetchActors({ _commit }, actorId) {
const networks = await get(`/actors/${actorId || ''}`);
return networks;
}
async function fetchActorReleases({ _commit }, actorId) {
const releases = await get(`/actors/${actorId}/releases`);
return releases;
}
return {
fetchActors,
fetchActorReleases,
};
}
export default initActorActions;

View File

@ -0,0 +1,13 @@
import state from './state';
import mutations from './mutations';
import actions from './actions';
function initActorsStore(store, router) {
return {
state,
mutations,
actions: actions(store, router),
};
}
export default initActorsStore;

View File

@ -0,0 +1 @@
export default {};

View File

@ -0,0 +1 @@
export default {};

View File

@ -0,0 +1,22 @@
import { get } from '../api';
function initNetworksActions(_store, _router) {
async function fetchNetworks({ _commit }, networkId) {
const networks = await get(`/networks/${networkId || ''}`);
return networks;
}
async function fetchNetworkReleases({ _commit }, networkId) {
const releases = await get(`/networks/${networkId}/releases`);
return releases;
}
return {
fetchNetworks,
fetchNetworkReleases,
};
}
export default initNetworksActions;

View File

@ -0,0 +1 @@
export default {};

View File

@ -0,0 +1,13 @@
import state from './state';
import mutations from './mutations';
import actions from './actions';
function initNetworksStore(store, router) {
return {
state,
mutations,
actions: actions(store, router),
};
}
export default initNetworksStore;

View File

@ -0,0 +1 @@
export default {};

View File

@ -4,6 +4,7 @@ import Vuex from 'vuex';
import initAuthStore from './auth/auth'; import initAuthStore from './auth/auth';
import initReleasesStore from './releases/releases'; import initReleasesStore from './releases/releases';
import initNetworksStore from './networks/networks'; import initNetworksStore from './networks/networks';
import initActorsStore from './actors/actors';
function initStore(router) { function initStore(router) {
Vue.use(Vuex); Vue.use(Vuex);
@ -12,6 +13,7 @@ function initStore(router) {
store.registerModule('auth', initAuthStore(store, router)); store.registerModule('auth', initAuthStore(store, router));
store.registerModule('releases', initReleasesStore(store, router)); store.registerModule('releases', initReleasesStore(store, router));
store.registerModule('actors', initActorsStore(store, router));
store.registerModule('networks', initNetworksStore(store, router)); store.registerModule('networks', initNetworksStore(store, router));
return store; return store;

View File

@ -5,7 +5,16 @@ exports.up = knex => Promise.resolve()
table.string('name') table.string('name')
.unique() .unique()
.notNullable(); .notNullable();
table.string('gender', 18); table.string('gender', 18);
table.text('description');
table.date('birthdate');
table.string('ethnicity');
table.string('country_alpha2', 2);
table.string('city');
table.integer('height');
table.string('boobs_size');
table.boolean('boobs_natural');
table.integer('alias_for', 12) table.integer('alias_for', 12)
.references('id') .references('id')

View File

@ -15,7 +15,7 @@
} }
.thumbnail[data-v-3abcf101] { .thumbnail[data-v-3abcf101] {
width: 100%; width: 100%;
height: 200px; height: 12rem;
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
@ -227,14 +227,40 @@
} }
/* $primary: #ff886c; */ /* $primary: #ff886c; */
.network[data-v-757c14c2] { .tile[data-v-f4958086] {
display: flex; display: flex;
flex-direction: column;
align-items: center;
box-sizing: border-box;
padding: 1rem; padding: 1rem;
overflow: hidden; border-radius: .25rem;
box-shadow: 0 0 3px rgba(0, 0, 0, 0.25);
height: 100%;
text-align: center;
} }
.link[data-v-f4958086] {
text-decoration: none;
}
.logo[data-v-f4958086] {
width: 100%;
height: 4rem;
-o-object-fit: contain;
object-fit: contain;
}
.title[data-v-f4958086] {
color: #222;
height: 100%;
display: flex;
align-items: center;
margin: 0;
font-size: 1rem;
}
/* $primary: #ff886c; */
.header[data-v-757c14c2] { .header[data-v-757c14c2] {
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
padding: 1rem;
} }
.title[data-v-757c14c2] { .title[data-v-757c14c2] {
display: inline-block; display: inline-block;
@ -242,15 +268,53 @@
} }
.heading[data-v-757c14c2] { .heading[data-v-757c14c2] {
padding: 0; padding: 0;
margin: 1rem 0; margin: 0 0 1rem 0;
} }
.logo[data-v-757c14c2] { .logo[data-v-757c14c2] {
height: 3rem; height: 3rem;
} }
.sites[data-v-757c14c2],
.scenes[data-v-757c14c2] { .scenes[data-v-757c14c2] {
display: grid; display: grid;
grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
grid-gap: 1rem; grid-gap: 1rem;
margin: 0 0 1rem 0;
}
.scenes[data-v-757c14c2] {
grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
}
.sites[data-v-757c14c2] {
grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
}
/* $primary: #ff886c; */
.header[data-v-677a8360] {
display: flex;
justify-content: space-between;
padding: 1rem;
}
.title[data-v-677a8360] {
display: inline-block;
margin: 0 .5rem 0 0;
}
.heading[data-v-677a8360] {
padding: 0;
margin: 0 0 1rem 0;
}
.bio-heading[data-v-677a8360] {
display: inline-block;
font-weight: bold;
margin: .5rem 0 0 0;
}
.bio-heading[data-v-677a8360]::after {
content: ':';
}
.scenes[data-v-677a8360] {
display: grid;
grid-gap: 1rem;
margin: 0 0 1rem 0;
}
.scenes[data-v-677a8360] {
grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
} }
/* $primary: #ff886c; */ /* $primary: #ff886c; */

BIN
public/img/404.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
public/img/sites/deeper.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
public/img/sites/nympho.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 86 KiB

BIN
public/img/sites/tushy.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
public/img/sites/vixen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 170 KiB

40
src/actors.js Normal file
View File

@ -0,0 +1,40 @@
'use strict';
const knex = require('./knex');
async function curateActor(actor) {
const aliases = await knex('actors')
.where({ alias_for: actor.id });
return {
id: actor.id,
name: actor.name,
description: actor.description,
birthdate: actor.birthdate && new Date(actor.birthdate),
country: actor.country_alpha2,
city: actor.city,
ethnicity: actor.ethnicity,
height: actor.height,
boobSize: actor.boobs_size,
boobsNatural: actor.boobs_natural,
aliases: aliases.map(({ name }) => name),
slug: actor.slug,
};
}
function curateActors(releases) {
return Promise.all(releases.map(async release => curateActor(release)));
}
async function fetchActors(actorId, actorSlug) {
const releases = await knex('actors')
.where({ id: actorId })
.orWhere({ slug: actorSlug })
.limit(100);
return curateActors(releases);
}
module.exports = {
fetchActors,
};

63
src/networks.js Normal file
View File

@ -0,0 +1,63 @@
'use strict';
const knex = require('./knex');
async function curateNetwork(network) {
const [sites, studios] = await Promise.all([
knex('sites')
.where({ network_id: network.id }),
knex('studios')
.where({ network_id: network.id }),
]);
return {
id: network.id,
name: network.name,
url: network.url,
description: network.description,
slug: network.slug,
sites: sites.map(site => ({
id: site.id,
name: site.name,
url: site.url,
description: site.description,
slug: site.slug,
})),
studios: studios.map(studio => ({
id: studio.id,
name: studio.name,
url: studio.url,
description: studio.description,
slug: studio.slug,
})),
};
}
function curateNetworks(releases) {
return Promise.all(releases.map(async release => curateNetwork(release)));
}
async function fetchNetworks(networkId, networkSlug) {
const releases = await knex('networks')
.where({ id: networkId })
.orWhere({ slug: networkSlug })
.limit(100);
return curateNetworks(releases);
}
async function fetchNetworksFromReleases() {
const releases = await knex('releases')
.select('site_id', '')
.leftJoin('sites', 'sites.id', 'releases.site_id')
.leftJoin('networks', 'networks.id', 'sites.network_id')
.groupBy('networks.id')
.limit(100);
return curateNetworks(releases);
}
module.exports = {
fetchNetworks,
fetchNetworksFromReleases,
};

View File

@ -69,7 +69,8 @@ async function fetchReleases(releaseId) {
const releases = await knex('releases') const releases = await knex('releases')
.where(releaseId ? { 'releases.id': releaseId } : {}) .where(releaseId ? { 'releases.id': releaseId } : {})
.select( .select(
'releases.*', 'sites.name as site_name', 'sites.slug as site_slug', 'sites.url as site_url', 'sites.network_id', 'releases.*',
'sites.name as site_name', 'sites.slug as site_slug', 'sites.url as site_url', 'sites.network_id',
'studios.name as studio_name', 'sites.slug as site_slug', 'studios.url as studio_url', 'studios.name as studio_name', 'sites.slug as site_slug', 'studios.url as studio_url',
'networks.name as network_name', 'networks.slug as network_slug', 'networks.url as network_url', 'networks.name as network_name', 'networks.slug as network_slug', 'networks.url as network_url',
) )
@ -87,7 +88,8 @@ async function fetchSiteReleases(siteId, siteSlug) {
.where({ 'sites.id': siteId }) .where({ 'sites.id': siteId })
.orWhere({ 'sites.slug': siteSlug }) .orWhere({ 'sites.slug': siteSlug })
.select( .select(
'releases.*', 'sites.name as site_name', 'sites.slug as site_slug', 'sites.url as site_url', 'sites.network_id', 'releases.*',
'sites.name as site_name', 'sites.slug as site_slug', 'sites.url as site_url', 'sites.network_id',
'studios.name as studio_name', 'sites.slug as site_slug', 'studios.url as studio_url', 'studios.name as studio_name', 'sites.slug as site_slug', 'studios.url as studio_url',
'networks.name as network_name', 'networks.slug as network_slug', 'networks.url as network_url', 'networks.name as network_name', 'networks.slug as network_slug', 'networks.url as network_url',
) )
@ -105,7 +107,8 @@ async function fetchNetworkReleases(networkId, networkSlug) {
.where({ 'networks.id': networkId }) .where({ 'networks.id': networkId })
.orWhere({ 'networks.slug': networkSlug }) .orWhere({ 'networks.slug': networkSlug })
.select( .select(
'releases.*', 'sites.name as site_name', 'sites.slug as site_slug', 'sites.url as site_url', 'sites.network_id', 'releases.*',
'sites.name as site_name', 'sites.slug as site_slug', 'sites.url as site_url', 'sites.network_id',
'studios.name as studio_name', 'sites.slug as site_slug', 'studios.url as studio_url', 'studios.name as studio_name', 'sites.slug as site_slug', 'studios.url as studio_url',
'networks.name as network_name', 'networks.slug as network_slug', 'networks.url as network_url', 'networks.name as network_name', 'networks.slug as network_slug', 'networks.url as network_url',
) )
@ -118,8 +121,31 @@ async function fetchNetworkReleases(networkId, networkSlug) {
return curateReleases(releases); return curateReleases(releases);
} }
async function fetchActorReleases(actorId, actorSlug) {
const releases = await knex('actors_associated')
.where({ 'actors.id': actorId })
.orWhere({ 'actors.slug': actorSlug })
.select(
'releases.*',
'actors.name as actor_name',
'sites.name as site_name', 'sites.slug as site_slug', 'sites.url as site_url', 'sites.network_id',
'studios.name as studio_name', 'sites.slug as site_slug', 'studios.url as studio_url',
'networks.name as network_name', 'networks.slug as network_slug', 'networks.url as network_url',
)
.leftJoin('releases', 'actors_associated.release_id', 'releases.id')
.leftJoin('actors', 'actors_associated.actor_id', 'actors.id')
.leftJoin('sites', 'releases.site_id', 'sites.id')
.leftJoin('studios', 'releases.studio_id', 'studios.id')
.leftJoin('networks', 'sites.network_id', 'networks.id')
.orderBy([{ column: 'releases.date', order: 'desc' }, { column: 'releases.created_at', order: 'desc' }])
.limit(100);
return curateReleases(releases);
}
module.exports = { module.exports = {
fetchReleases, fetchReleases,
fetchActorReleases,
fetchSiteReleases, fetchSiteReleases,
fetchNetworkReleases, fetchNetworkReleases,
}; };

50
src/sites.js Normal file
View File

@ -0,0 +1,50 @@
'use strict';
const knex = require('./knex');
async function curateSite(site) {
const network = await knex('network').where({ id: site.network_id });
return {
id: site.id,
name: site.name,
url: site.url,
description: site.description,
slug: site.slug,
network: {
id: network.id,
name: network.name,
url: network.url,
description: network.description,
slug: network.slug,
},
};
}
function curateSites(releases) {
return Promise.all(releases.map(async site => curateSite(site)));
}
async function fetchSites(siteId, siteSlug) {
const releases = await knex('sites')
.where({ id: siteId })
.orWhere({ slug: siteSlug })
.limit(100);
return curateSites(releases);
}
async function fetchSitesFromReleases() {
const releases = await knex('releases')
.select('site_id', '')
.leftJoin('sites', 'sites.id', 'releases.site_id')
.groupBy('sites.id')
.limit(100);
return curateSites(releases);
}
module.exports = {
fetchSites,
fetchSitesFromReleases,
};

16
src/web/actors.js Normal file
View File

@ -0,0 +1,16 @@
'use strict';
const { fetchActors } = require('../actors');
async function fetchActorsApi(req, res) {
const actorId = typeof req.params.actorId === 'number' ? req.params.actorId : null;
const actorSlug = typeof req.params.actorId === 'string' ? req.params.actorId : null;
const actors = await fetchActors(actorId, actorSlug);
res.send(actors);
}
module.exports = {
fetchActors: fetchActorsApi,
};

23
src/web/networks.js Normal file
View File

@ -0,0 +1,23 @@
'use strict';
const { fetchNetworks, fetchNetworksFromReleases } = require('../networks');
async function fetchNetworksApi(req, res) {
const networkId = typeof req.params.networkId === 'number' ? req.params.networkId : null;
const networkSlug = typeof req.params.networkId === 'string' ? req.params.networkId : null;
const networks = await fetchNetworks(networkId, networkSlug);
res.send(networks);
}
async function fetchNetworksFromReleasesApi(req, res) {
const networks = await fetchNetworksFromReleases();
res.send(networks);
}
module.exports = {
fetchNetworks: fetchNetworksApi,
fetchNetworksFromReleases: fetchNetworksFromReleasesApi,
};

View File

@ -1,6 +1,11 @@
'use strict'; 'use strict';
const { fetchReleases, fetchNetworkReleases, fetchSiteReleases } = require('../releases'); const {
fetchReleases,
fetchActorReleases,
fetchNetworkReleases,
fetchSiteReleases,
} = require('../releases');
async function fetchReleasesApi(req, res) { async function fetchReleasesApi(req, res) {
const releases = await fetchReleases(req.params.releaseId); const releases = await fetchReleases(req.params.releaseId);
@ -8,6 +13,15 @@ async function fetchReleasesApi(req, res) {
res.send(releases); res.send(releases);
} }
async function fetchActorReleasesApi(req, res) {
const actorId = Number.isInteger(Number(req.params.actorId)) ? Number(req.params.actorId) : null;
const actorSlug = typeof req.params.actorId === 'string' ? req.params.actorId : null;
const releases = await fetchActorReleases(actorId, actorSlug);
res.send(releases);
}
async function fetchNetworkReleasesApi(req, res) { async function fetchNetworkReleasesApi(req, res) {
const networkId = typeof req.params.networkId === 'number' ? req.params.networkId : null; const networkId = typeof req.params.networkId === 'number' ? req.params.networkId : null;
const networkSlug = typeof req.params.networkId === 'string' ? req.params.networkId : null; const networkSlug = typeof req.params.networkId === 'string' ? req.params.networkId : null;
@ -28,6 +42,7 @@ async function fetchSiteReleasesApi(req, res) {
module.exports = { module.exports = {
fetchReleases: fetchReleasesApi, fetchReleases: fetchReleasesApi,
fetchActorReleases: fetchActorReleasesApi,
fetchNetworkReleases: fetchNetworkReleasesApi, fetchNetworkReleases: fetchNetworkReleasesApi,
fetchSiteReleases: fetchSiteReleasesApi, fetchSiteReleases: fetchSiteReleasesApi,
}; };

View File

@ -6,8 +6,19 @@ const express = require('express');
const Router = require('express-promise-router'); const Router = require('express-promise-router');
const bodyParser = require('body-parser'); const bodyParser = require('body-parser');
const { fetchReleases, fetchNetworkReleases, fetchSiteReleases } = require('./releases'); const {
const { fetchNetworks, fetchNetworksFromReleases } = require('./networks'); fetchReleases,
fetchActorReleases,
fetchNetworkReleases,
fetchSiteReleases,
} = require('./releases');
const {
fetchNetworks,
fetchNetworksFromReleases,
} = require('./networks');
const { fetchActors } = require('./actors');
const { fetchSites } = require('./sites'); const { fetchSites } = require('./sites');
function initServer() { function initServer() {
@ -16,12 +27,21 @@ function initServer() {
router.use('/media', express.static(config.photoPath)); router.use('/media', express.static(config.photoPath));
router.use(express.static('public')); router.use(express.static('public'));
router.use('/img', (req, res) => {
res.status(404).send();
});
router.use(bodyParser.json({ strict: false })); router.use(bodyParser.json({ strict: false }));
router.get('/api/releases', fetchReleases); router.get('/api/releases', fetchReleases);
router.get('/api/releases/:releaseId', fetchReleases); router.get('/api/releases/:releaseId', fetchReleases);
router.get('/api/releases/networks', fetchNetworksFromReleases); router.get('/api/releases/networks', fetchNetworksFromReleases);
router.get('/api/actors', fetchActors);
router.get('/api/actors/:actorId', fetchActors);
router.get('/api/actors/:actorId/releases', fetchActorReleases);
router.get('/api/networks', fetchNetworks); router.get('/api/networks', fetchNetworks);
router.get('/api/networks/:networkId', fetchNetworks); router.get('/api/networks/:networkId', fetchNetworks);
router.get('/api/networks/:networkId/releases', fetchNetworkReleases); router.get('/api/networks/:networkId/releases', fetchNetworkReleases);

23
src/web/sites.js Normal file
View File

@ -0,0 +1,23 @@
'use strict';
const { fetchSites, fetchSitesFromReleases } = require('../networks');
async function fetchSitesApi(req, res) {
const siteId = typeof req.params.siteId === 'number' ? req.params.siteId : null;
const siteSlug = typeof req.params.siteId === 'string' ? req.params.siteId : null;
const sites = await fetchSites(siteId, siteSlug);
res.send(sites);
}
async function fetchSitesFromReleasesApi(req, res) {
const sites = await fetchSitesFromReleases();
res.send(sites);
}
module.exports = {
fetchSites: fetchSitesApi,
fetchSitesFromReleases: fetchSitesFromReleasesApi,
};