Skip to content

Commit

Permalink
Merge pull request #61 from ArtuGit/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
ArtuGit authored Mar 12, 2021
2 parents 855bf04 + 2acca76 commit 8ff1cb8
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 14 deletions.
9 changes: 5 additions & 4 deletions components/UI/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@
Enjoy your word cards!
</v-col>
<v-col cols="12" lg="4" md="6" class="f-section pa-2">
Developed by <a href="https://github.com/ArtuGit">Artu</a>
Developed by
<a href="https://github.com/ArtuGit" rel="noopener">Artu</a>
</v-col>
<v-col cols="12" lg="4" md="12" class="f-section pa-2">
<div>Powered by</div>
<div class="logo">
<a href="https://pixabay.com/" target="_blank"
><img src="@/static/images/logos/Pixabay.svg"
/></a>
<a href="https://pixabay.com/" rel="noopener" target="_blank">
<img src="@/static/images/logos/Pixabay.svg" alt="" />
</a>
</div>
</v-col>
</v-row>
Expand Down
13 changes: 12 additions & 1 deletion components/UI/ImageUpload.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<!--
- Developed by Artu, https://github.com/ArtuGit
- Copyleft 2020-2021.
- Copyleft, 2020-2021.
-->
<template>
<div class="mt-4">
Expand All @@ -24,6 +24,8 @@
label="Image file"
type="file"
accept="image/*"
:hint="hint"
:persistent-hint="hint"
@change="processImage"
></v-file-input>
</v-col>
Expand Down Expand Up @@ -52,6 +54,15 @@ export default {
imageDialogObj: null,
}
},
computed: {
hint() {
if (this.imageDialogObj) {
return ''
} else {
return 'Leave blank to get an image automatically'
}
},
},
watch: {
async imageExisted(newVal, oldVal) {
this.imageDialogURLTemp = newVal
Expand Down
2 changes: 1 addition & 1 deletion layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
</v-navigation-drawer>
<v-app-bar :clipped-left="clipped" fixed app>
<v-app-bar-nav-icon @click.stop="drawer = !drawer" />
<v-btn icon @click.stop="miniVariant = !miniVariant">
<v-btn aria-label="Mini" icon @click.stop="miniVariant = !miniVariant">
<v-icon>mdi-{{ `chevron-${miniVariant ? 'right' : 'left'}` }}</v-icon>
</v-btn>
<h1>
Expand Down
38 changes: 38 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"core-js": "^3.8.3",
"express": "^4.17.1",
"firebase": "^8.2.7",
"image-blob-reduce": "^2.2.2",
"js-cookie": "^2.2.1",
"lodash.orderby": "^4.6.0",
"nuxt": "^2.14.12",
Expand Down
26 changes: 18 additions & 8 deletions plugins/api-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
*/

import { authenticate } from 'pixabay-api'

import imageBlobReduce from 'image-blob-reduce'
const { searchImages } = authenticate(process.env.pixabayKey)
const reduce = imageBlobReduce()

const fakeRequestPromise = (delay = 1000) => {
return new Promise((resolve, reject) => {
Expand Down Expand Up @@ -119,22 +122,29 @@ function getStorageDirName() {
else return 'demo'
}

// ToDo: Resize an uploaded image
// ToDo: Improve readability and error handling
function uploadURLToStorage(url) {
const that = this
const dirName = getStorageDirName.call(this)
const fileName = url.split('/').slice(-1)[0]
return new Promise(function (resolve, reject) {
getFileBlob(url, (blob) => {
try {
const path = `${dirName}/${fileName}`
const storageRef = that.$fire.storage.ref().child(path)
storageRef.put(blob).then(function (snapshot) {
storageRef.getDownloadURL().then(function (url) {
const res = { imagePath: path, url }
resolve(res)
reduce
.toBlob(blob, { max: 400 })
.then((blob) => {
return blob
})
.then((blobResized) => {
const path = `${dirName}/${fileName}`
const storageRef = that.$fire.storage.ref().child(path)
storageRef.put(blobResized).then(function (snapshot) {
storageRef.getDownloadURL().then(function (url) {
const res = { imagePath: path, url }
resolve(res)
})
})
})
})
} catch (e) {
alert(e.message)
}
Expand Down

0 comments on commit 8ff1cb8

Please sign in to comment.