mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Initial commit to add placeholder image for Post
This commit is contained in:
parent
694fb52381
commit
95be6eaee6
33
backend/add_teaser_image_heights.sh
Executable file
33
backend/add_teaser_image_heights.sh
Executable file
@ -0,0 +1,33 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
shopt -s nullglob
|
||||||
|
TEMP_FILE=/var/lib/neo4j/import/temp.json
|
||||||
|
for image in public/uploads/*; do
|
||||||
|
[ -e "$image" ] || continue
|
||||||
|
export IMAGE_METADATA=$( identify -format '%w %h' "$image" )
|
||||||
|
JSON_STRING=$( jq -n \
|
||||||
|
--arg imageURL "$image" \
|
||||||
|
--arg imageMetaData "$IMAGE_METADATA" \
|
||||||
|
'{imageURL: $imageURL, imageMetaData: $imageMetaData}' )
|
||||||
|
echo "$JSON_STRING," >> "$TEMP_FILE"
|
||||||
|
done
|
||||||
|
|
||||||
|
ENV_FILE=$(dirname "$0")/.env
|
||||||
|
[[ -f "$ENV_FILE" ]] && source "$ENV_FILE"
|
||||||
|
|
||||||
|
if [ -z "$NEO4J_USERNAME" ] || [ -z "$NEO4J_PASSWORD" ]; then
|
||||||
|
echo "Please set NEO4J_USERNAME and NEO4J_PASSWORD environment variables."
|
||||||
|
echo "Database manipulation is not possible without connecting to the database."
|
||||||
|
echo "E.g. you could \`cp .env.template .env\` unless you run the script in a docker container"
|
||||||
|
fi
|
||||||
|
|
||||||
|
until echo 'RETURN "Connection successful" as info;' | cypher-shell
|
||||||
|
do
|
||||||
|
echo "Connecting to neo4j failed, trying again..."
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
echo "
|
||||||
|
WITH "file:${TEMP_FILE}"
|
||||||
|
AS url
|
||||||
|
CALL apoc.load.json(url) YIELD value as post
|
||||||
|
MATCH (p:Post {image: post.imageURL}) return p;
|
||||||
|
" | cypher-shell
|
||||||
@ -297,7 +297,7 @@ export default {
|
|||||||
},
|
},
|
||||||
Post: {
|
Post: {
|
||||||
...Resolver('Post', {
|
...Resolver('Post', {
|
||||||
undefinedToNull: ['activityId', 'objectId', 'image', 'language', 'pinnedAt', 'pinned'],
|
undefinedToNull: ['activityId', 'objectId', 'image', 'language', 'pinnedAt', 'pinned', 'teaserImageHeight'],
|
||||||
hasMany: {
|
hasMany: {
|
||||||
tags: '-[:TAGGED]->(related:Tag)',
|
tags: '-[:TAGGED]->(related:Tag)',
|
||||||
categories: '-[:CATEGORIZED]->(related:Category)',
|
categories: '-[:CATEGORIZED]->(related:Category)',
|
||||||
|
|||||||
@ -118,6 +118,7 @@ type Post {
|
|||||||
contentExcerpt: String
|
contentExcerpt: String
|
||||||
image: String
|
image: String
|
||||||
imageUpload: Upload
|
imageUpload: Upload
|
||||||
|
teaserImageHeight: String
|
||||||
visibility: Visibility
|
visibility: Visibility
|
||||||
deleted: Boolean
|
deleted: Boolean
|
||||||
disabled: Boolean
|
disabled: Boolean
|
||||||
@ -194,6 +195,7 @@ type Mutation {
|
|||||||
visibility: Visibility
|
visibility: Visibility
|
||||||
language: String
|
language: String
|
||||||
categoryIds: [ID]
|
categoryIds: [ID]
|
||||||
|
teaserImageHeight: String
|
||||||
): Post
|
): Post
|
||||||
DeletePost(id: ID!): Post
|
DeletePost(id: ID!): Post
|
||||||
AddPostEmotions(to: _PostInput!, data: _EMOTEDInput!): EMOTED
|
AddPostEmotions(to: _PostInput!, data: _EMOTEDInput!): EMOTED
|
||||||
|
|||||||
@ -12,6 +12,6 @@
|
|||||||
# On Windows this resolves to C:\Users\dornhoeschen\AppData\Local\Temp\mongo-export (MinGW)
|
# On Windows this resolves to C:\Users\dornhoeschen\AppData\Local\Temp\mongo-export (MinGW)
|
||||||
EXPORT_PATH='/tmp/mongo-export/'
|
EXPORT_PATH='/tmp/mongo-export/'
|
||||||
EXPORT_MONGOEXPORT_BIN='mongoexport'
|
EXPORT_MONGOEXPORT_BIN='mongoexport'
|
||||||
MONGO_EXPORT_SPLIT_SIZE=6000
|
MONGO_EXPORT_SPLIT_SIZE=500000
|
||||||
# On Windows use something like this
|
# On Windows use something like this
|
||||||
# EXPORT_MONGOEXPORT_BIN='C:\Program Files\MongoDB\Server\3.6\bin\mongoexport.exe'
|
# EXPORT_MONGOEXPORT_BIN='C:\Program Files\MongoDB\Server\3.6\bin\mongoexport.exe'
|
||||||
|
|||||||
@ -39,6 +39,7 @@ function import_collection () {
|
|||||||
echo "Import $1 ${CHUNK_FILE_NAME} (${chunk})"
|
echo "Import $1 ${CHUNK_FILE_NAME} (${chunk})"
|
||||||
echo "${NEO4J_COMMAND}" | "${IMPORT_CYPHERSHELL_BIN}" > /dev/null
|
echo "${NEO4J_COMMAND}" | "${IMPORT_CYPHERSHELL_BIN}" > /dev/null
|
||||||
# add file to array and file
|
# add file to array and file
|
||||||
|
echo "$IMPORT_CHUNK_PATH_CQL_FILE"
|
||||||
IMPORT_INDEX+=("${CHUNK_FILE_NAME}")
|
IMPORT_INDEX+=("${CHUNK_FILE_NAME}")
|
||||||
echo "${CHUNK_FILE_NAME}" >> ${INDEX_FILE}
|
echo "${CHUNK_FILE_NAME}" >> ${INDEX_FILE}
|
||||||
else
|
else
|
||||||
|
|||||||
28
neo4j/add_teaser_image_heights.sh
Normal file
28
neo4j/add_teaser_image_heights.sh
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
echo "images"
|
||||||
|
shopt -s nullglob
|
||||||
|
for image in *; do
|
||||||
|
# [ -e "$image" ] || continue
|
||||||
|
echo "$image"
|
||||||
|
done
|
||||||
|
|
||||||
|
# ENV_FILE=$(dirname "$0")/.env
|
||||||
|
# [[ -f "$ENV_FILE" ]] && source "$ENV_FILE"
|
||||||
|
|
||||||
|
# if [ -z "$NEO4J_USERNAME" ] || [ -z "$NEO4J_PASSWORD" ]; then
|
||||||
|
# echo "Please set NEO4J_USERNAME and NEO4J_PASSWORD environment variables."
|
||||||
|
# echo "Database manipulation is not possible without connecting to the database."
|
||||||
|
# echo "E.g. you could \`cp .env.template .env\` unless you run the script in a docker container"
|
||||||
|
# fi
|
||||||
|
|
||||||
|
# until echo 'RETURN "Connection successful" as info;' | cypher-shell
|
||||||
|
# do
|
||||||
|
# echo "Connecting to neo4j failed, trying again..."
|
||||||
|
# sleep 1
|
||||||
|
# done
|
||||||
|
|
||||||
|
# echo "
|
||||||
|
# MATCH (post:Post) where post.teaserImageHeight is not null return post;
|
||||||
|
# " | cypher-shell
|
||||||
@ -7,7 +7,7 @@
|
|||||||
@submit="submit"
|
@submit="submit"
|
||||||
>
|
>
|
||||||
<template slot-scope="{ errors }">
|
<template slot-scope="{ errors }">
|
||||||
<hc-teaser-image :contribution="contribution" @addTeaserImage="addTeaserImage">
|
<hc-teaser-image :contribution="contribution" @addTeaserImage="addTeaserImage" @addTeaserImageHeight="addTeaserImageHeight">
|
||||||
<img
|
<img
|
||||||
v-if="contribution"
|
v-if="contribution"
|
||||||
class="contribution-image"
|
class="contribution-image"
|
||||||
@ -190,9 +190,12 @@ export default {
|
|||||||
content,
|
content,
|
||||||
image,
|
image,
|
||||||
teaserImage,
|
teaserImage,
|
||||||
|
teaserImageHeight,
|
||||||
categoryIds,
|
categoryIds,
|
||||||
} = this.form
|
} = this.form
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
console.log('file', teaserImage)
|
||||||
|
console.log('imageHeight', typeof teaserImageHeight)
|
||||||
this.$apollo
|
this.$apollo
|
||||||
.mutate({
|
.mutate({
|
||||||
mutation: this.id ? PostMutations().UpdatePost : PostMutations().CreatePost,
|
mutation: this.id ? PostMutations().UpdatePost : PostMutations().CreatePost,
|
||||||
@ -204,6 +207,7 @@ export default {
|
|||||||
language,
|
language,
|
||||||
image,
|
image,
|
||||||
imageUpload: teaserImage,
|
imageUpload: teaserImage,
|
||||||
|
teaserImageHeight
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
@ -227,6 +231,10 @@ export default {
|
|||||||
addTeaserImage(file) {
|
addTeaserImage(file) {
|
||||||
this.form.teaserImage = file
|
this.form.teaserImage = file
|
||||||
},
|
},
|
||||||
|
addTeaserImageHeight(height) {
|
||||||
|
console.log(height.toString())
|
||||||
|
this.form.teaserImageHeight = height.toString()
|
||||||
|
},
|
||||||
categoryIds(categories) {
|
categoryIds(categories) {
|
||||||
return categories.map(c => c.id)
|
return categories.map(c => c.id)
|
||||||
},
|
},
|
||||||
|
|||||||
@ -22,11 +22,24 @@ export default {
|
|||||||
content: content,
|
content: content,
|
||||||
duration: [400, 200],
|
duration: [400, 200],
|
||||||
inertia: true,
|
inertia: true,
|
||||||
|
<<<<<<< Updated upstream
|
||||||
interactive: true,
|
interactive: true,
|
||||||
|
=======
|
||||||
|
// interactive: true,
|
||||||
|
>>>>>>> Stashed changes
|
||||||
placement,
|
placement,
|
||||||
showOnInit,
|
showOnInit,
|
||||||
theme: 'human-connection',
|
theme: 'human-connection',
|
||||||
trigger,
|
trigger,
|
||||||
|
<<<<<<< Updated upstream
|
||||||
|
=======
|
||||||
|
onCreate(instance) {
|
||||||
|
instance.popperInstance.reference = {
|
||||||
|
...virtualNode,
|
||||||
|
// popperOptions: { positionFixed: true },
|
||||||
|
}
|
||||||
|
},
|
||||||
|
>>>>>>> Stashed changes
|
||||||
onMount(instance) {
|
onMount(instance) {
|
||||||
const input = instance.popper.querySelector('input')
|
const input = instance.popper.querySelector('input')
|
||||||
|
|
||||||
@ -79,6 +92,7 @@ export default {
|
|||||||
.tippy-roundarrow {
|
.tippy-roundarrow {
|
||||||
fill: $color-primary;
|
fill: $color-primary;
|
||||||
}
|
}
|
||||||
|
<<<<<<< Updated upstream
|
||||||
.tippy-popper[x-placement^='top'] & .tippy-arrow {
|
.tippy-popper[x-placement^='top'] & .tippy-arrow {
|
||||||
border-top-color: $color-primary;
|
border-top-color: $color-primary;
|
||||||
}
|
}
|
||||||
@ -91,5 +105,10 @@ export default {
|
|||||||
.tippy-popper[x-placement^='right'] & .tippy-arrow {
|
.tippy-popper[x-placement^='right'] & .tippy-arrow {
|
||||||
border-right-color: $color-primary;
|
border-right-color: $color-primary;
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
// .tippy-popper {
|
||||||
|
// pointer-events: auto;
|
||||||
|
// }
|
||||||
|
>>>>>>> Stashed changes
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -22,6 +22,7 @@ export default {
|
|||||||
},
|
},
|
||||||
endCalculation() {
|
endCalculation() {
|
||||||
this.itemsCalculating -= 1
|
this.itemsCalculating -= 1
|
||||||
|
this.$emit('hidePlaceholder')
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,9 @@
|
|||||||
:image="post.image | proxyApiUrl"
|
:image="post.image | proxyApiUrl"
|
||||||
:class="{ 'post-card': true, 'disabled-content': post.disabled, 'post--pinned': isPinned }"
|
:class="{ 'post-card': true, 'disabled-content': post.disabled, 'post--pinned': isPinned }"
|
||||||
>
|
>
|
||||||
|
<ds-placeholder v-if="showPlaceholder && post.teaserImageHeight" class="placeholder-image">
|
||||||
|
I'm a placeholder
|
||||||
|
</ds-placeholder>
|
||||||
<!-- Post Link Target -->
|
<!-- Post Link Target -->
|
||||||
<nuxt-link
|
<nuxt-link
|
||||||
class="post-link"
|
class="post-link"
|
||||||
@ -98,6 +101,15 @@ export default {
|
|||||||
type: Object,
|
type: Object,
|
||||||
default: () => {},
|
default: () => {},
|
||||||
},
|
},
|
||||||
|
showPlaceholder: {
|
||||||
|
type: Boolean,
|
||||||
|
default: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
imageLoading: true,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters({
|
...mapGetters({
|
||||||
@ -121,6 +133,11 @@ export default {
|
|||||||
isPinned() {
|
isPinned() {
|
||||||
return this.post && this.post.pinnedBy
|
return this.post && this.post.pinnedBy
|
||||||
},
|
},
|
||||||
|
cssVars() {
|
||||||
|
return {
|
||||||
|
'--height': this.post.teaserImageHeight + 'px'
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async deletePostCallback() {
|
async deletePostCallback() {
|
||||||
@ -140,6 +157,10 @@ export default {
|
|||||||
unpinPost(post) {
|
unpinPost(post) {
|
||||||
this.$emit('unpinPost', post)
|
this.$emit('unpinPost', post)
|
||||||
},
|
},
|
||||||
|
hidePlaceholder() {
|
||||||
|
console.log('this has been called')
|
||||||
|
this.imageLoading = false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -184,4 +205,8 @@ export default {
|
|||||||
.post--pinned {
|
.post--pinned {
|
||||||
border: 1px solid $color-warning;
|
border: 1px solid $color-warning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.placeholder-image {
|
||||||
|
height: var(--height)
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -111,12 +111,16 @@ export default {
|
|||||||
cropImage() {
|
cropImage() {
|
||||||
this.showCropper = false
|
this.showCropper = false
|
||||||
const canvas = this.cropper.getCroppedCanvas()
|
const canvas = this.cropper.getCroppedCanvas()
|
||||||
|
console.log('canvas', canvas)
|
||||||
canvas.toBlob(blob => {
|
canvas.toBlob(blob => {
|
||||||
this.setupPreview(canvas)
|
this.setupPreview(canvas)
|
||||||
this.removeCropper()
|
this.removeCropper()
|
||||||
const croppedImageFile = new File([blob], this.file.name, { type: 'image/jpeg' })
|
console.log(blob)
|
||||||
|
const croppedImageFile = new File([blob], this.file.name, { type: this.file.type })
|
||||||
|
console.log('croppedImageFile', croppedImageFile)
|
||||||
this.$emit('addTeaserImage', croppedImageFile)
|
this.$emit('addTeaserImage', croppedImageFile)
|
||||||
}, 'image/jpeg')
|
this.$emit('addTeaserImageHeight', canvas.height)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
setupPreview(canvas) {
|
setupPreview(canvas) {
|
||||||
this.image = new Image()
|
this.image = new Image()
|
||||||
|
|||||||
@ -64,6 +64,7 @@ export const postFragment = lang => gql`
|
|||||||
role
|
role
|
||||||
}
|
}
|
||||||
pinnedAt
|
pinnedAt
|
||||||
|
teaserImageHeight
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
export const commentFragment = lang => gql`
|
export const commentFragment = lang => gql`
|
||||||
|
|||||||
@ -34,6 +34,7 @@ export default () => {
|
|||||||
$imageUpload: Upload
|
$imageUpload: Upload
|
||||||
$categoryIds: [ID]
|
$categoryIds: [ID]
|
||||||
$image: String
|
$image: String
|
||||||
|
$teaserImageHeight: String
|
||||||
) {
|
) {
|
||||||
UpdatePost(
|
UpdatePost(
|
||||||
id: $id
|
id: $id
|
||||||
@ -43,6 +44,7 @@ export default () => {
|
|||||||
imageUpload: $imageUpload
|
imageUpload: $imageUpload
|
||||||
categoryIds: $categoryIds
|
categoryIds: $categoryIds
|
||||||
image: $image
|
image: $image
|
||||||
|
teaserImageHeight: $teaserImageHeight
|
||||||
) {
|
) {
|
||||||
id
|
id
|
||||||
title
|
title
|
||||||
@ -55,6 +57,7 @@ export default () => {
|
|||||||
name
|
name
|
||||||
role
|
role
|
||||||
}
|
}
|
||||||
|
teaserImageHeight
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<masonry-grid>
|
<masonry-grid @hidePlaceholder="hidePlaceholder">
|
||||||
<ds-grid-item v-show="hashtag" :row-span="2" column-span="fullWidth">
|
<ds-grid-item v-show="hashtag" :row-span="2" column-span="fullWidth">
|
||||||
<filter-menu :hashtag="hashtag" @clearSearch="clearSearch" />
|
<filter-menu :hashtag="hashtag" @clearSearch="clearSearch" />
|
||||||
</ds-grid-item>
|
</ds-grid-item>
|
||||||
@ -20,6 +20,7 @@
|
|||||||
<hc-post-card
|
<hc-post-card
|
||||||
:post="post"
|
:post="post"
|
||||||
:width="{ base: '100%', xs: '100%', md: '50%', xl: '33%' }"
|
:width="{ base: '100%', xs: '100%', md: '50%', xl: '33%' }"
|
||||||
|
:showPlaceholder="showPlaceholder"
|
||||||
@removePostFromList="deletePost"
|
@removePostFromList="deletePost"
|
||||||
@pinPost="pinPost"
|
@pinPost="pinPost"
|
||||||
@unpinPost="unpinPost"
|
@unpinPost="unpinPost"
|
||||||
@ -83,6 +84,7 @@ export default {
|
|||||||
offset: 0,
|
offset: 0,
|
||||||
pageSize: 12,
|
pageSize: 12,
|
||||||
hashtag,
|
hashtag,
|
||||||
|
showPlaceholder: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -204,6 +206,9 @@ export default {
|
|||||||
})
|
})
|
||||||
.catch(error => this.$toast.error(error.message))
|
.catch(error => this.$toast.error(error.message))
|
||||||
},
|
},
|
||||||
|
hidePlaceholder() {
|
||||||
|
this.showPlaceholder = false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
apollo: {
|
apollo: {
|
||||||
Post: {
|
Post: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user