diff --git a/neo4j/db_manipulation/add_image_aspect_ratio.sh b/neo4j/db_manipulation/add_image_aspect_ratio.sh
index 7fe2c5871..8e2a16a01 100755
--- a/neo4j/db_manipulation/add_image_aspect_ratio.sh
+++ b/neo4j/db_manipulation/add_image_aspect_ratio.sh
@@ -12,19 +12,11 @@ do
sleep 1
done
-shopt -s nullglob
-for image in uploads/*; do
- [ -e "$image" ] || continue
- IMAGE_WIDTH=$( identify -format '%w' "$image" )
- IMAGE_HEIGHT=$( identify -format '%h' "$image" )
- IMAGE_ASPECT_RATIO=$(echo | awk "{ print ${IMAGE_WIDTH}/${IMAGE_HEIGHT}}")
-
-
- echo "$image"
- echo "$IMAGE_ASPECT_RATIO"
- echo "
- match (post:Post {image: '/"${image}"'})
- set post.imageAspectRatio = "${IMAGE_ASPECT_RATIO}"
- return post;
- " | cypher-shell
-done
+echo "
+ CALL apoc.periodic.iterate('
+ CALL apoc.load.csv("out.csv") yield map as row return row
+ ','
+ MATCH (post:Post) where post.image = row.image
+ set post.imageAspectRatio = row.aspectRatio
+ ', {batchSize:10000, iterateList:true, parallel:true});
+" | cypher-shell
diff --git a/webapp/components/MasonryGrid/MasonryGridItem.spec.js b/webapp/components/MasonryGrid/MasonryGridItem.spec.js
index 66b0607fd..86233efc9 100644
--- a/webapp/components/MasonryGrid/MasonryGridItem.spec.js
+++ b/webapp/components/MasonryGrid/MasonryGridItem.spec.js
@@ -1,4 +1,4 @@
-import { config, shallowMount } from '@vue/test-utils'
+import { config, mount } from '@vue/test-utils'
import MasonryGridItem from './MasonryGridItem'
const localVue = global.localVue
@@ -8,24 +8,39 @@ config.stubs['ds-grid-item'] = ''
describe('MasonryGridItem', () => {
let wrapper
- beforeEach(() => {
- wrapper = shallowMount(MasonryGridItem, { localVue })
- wrapper.vm.$parent.$emit = jest.fn()
- })
+ describe('given an imageAspectRatio', () => {
+ it('sets the initial rowSpan to 13 when the ratio is higher than 1.3', () => {
+ const propsData = { imageAspectRatio: 2 }
+ wrapper = mount(MasonryGridItem, { localVue, propsData })
- it('emits "calculating-item-height" when starting calculation', async () => {
- wrapper.vm.calculateItemHeight()
- await wrapper.vm.$nextTick()
+ expect(wrapper.vm.rowSpan).toBe(13)
+ })
- const firstCallArgument = wrapper.vm.$parent.$emit.mock.calls[0][0]
- expect(firstCallArgument).toBe('calculating-item-height')
- })
+ it('sets the initial rowSpan to 15 when the ratio is between 1.3 and 1', () => {
+ const propsData = { imageAspectRatio: 1.1 }
+ wrapper = mount(MasonryGridItem, { localVue, propsData })
- it('emits "finished-calculating-item-height" after the calculation', async () => {
- wrapper.vm.calculateItemHeight()
- await wrapper.vm.$nextTick()
+ expect(wrapper.vm.rowSpan).toBe(15)
+ })
- const secondCallArgument = wrapper.vm.$parent.$emit.mock.calls[1][0]
- expect(secondCallArgument).toBe('finished-calculating-item-height')
+ it('sets the initial rowSpan to 18 when the ratio is between 1 and 0.7', () => {
+ const propsData = { imageAspectRatio: 0.7 }
+ wrapper = mount(MasonryGridItem, { localVue, propsData })
+
+ expect(wrapper.vm.rowSpan).toBe(18)
+ })
+
+ it('sets the initial rowSpan to 25 when the ratio is lower than 0.7', () => {
+ const propsData = { imageAspectRatio: 0.3 }
+ wrapper = mount(MasonryGridItem, { localVue, propsData })
+ expect(wrapper.vm.rowSpan).toBe(25)
+ })
+
+ describe('given no aspect ratio', () => {
+ it('sets the initial rowSpan to 8 when not given an imageAspectRatio', () => {
+ wrapper = mount(MasonryGridItem, { localVue })
+ expect(wrapper.vm.rowSpan).toBe(8)
+ })
+ })
})
})
diff --git a/webapp/components/MasonryGrid/MasonryGridItem.vue b/webapp/components/MasonryGrid/MasonryGridItem.vue
index 937da8f1f..663060f87 100644
--- a/webapp/components/MasonryGrid/MasonryGridItem.vue
+++ b/webapp/components/MasonryGrid/MasonryGridItem.vue
@@ -5,6 +5,16 @@
diff --git a/webapp/components/PostCard/PostCard.vue b/webapp/components/PostCard/PostCard.vue
index d5afe90e1..0a4ced550 100644
--- a/webapp/components/PostCard/PostCard.vue
+++ b/webapp/components/PostCard/PostCard.vue
@@ -99,6 +99,14 @@ export default {
default: () => {},
},
},
+ mounted() {
+ const width = this.$el.offsetWidth
+ const height = Math.min(width / this.post.imageAspectRatio, 2000)
+ const imageElement = this.$el.querySelector('.ds-card-image')
+ if (imageElement) {
+ imageElement.style.height = `${height}px`
+ }
+ },
computed: {
...mapGetters({
user: 'auth/user',
diff --git a/webapp/pages/index.vue b/webapp/pages/index.vue
index c3f01d548..6d0f8c669 100644
--- a/webapp/pages/index.vue
+++ b/webapp/pages/index.vue
@@ -21,10 +21,13 @@
-
+
{{ $t('post.moreInfo.titleOfRelatedContributionsSection') }}
-
+
-
+