Merge branch 'wysiwyg-preview-fullscreen' of github.com:strapi/strapi into improve-wys-upload

This commit is contained in:
soupette 2018-04-02 12:06:51 +02:00
commit b0c93135a4
6 changed files with 241 additions and 0 deletions

View File

@ -0,0 +1,7 @@
root = true
[*]
end_of_line = lf
insert_final_newline = false
indent_style = space
indent_size = 2

View File

@ -0,0 +1,103 @@
# From https://github.com/Danimoth/gitattributes/blob/master/Web.gitattributes
# Handle line endings automatically for files detected as text
# and leave all files detected as binary untouched.
* text=auto
#
# The above will handle all files NOT found below
#
#
## These files are text and should be normalized (Convert crlf => lf)
#
# source code
*.php text
*.css text
*.sass text
*.scss text
*.less text
*.styl text
*.js text eol=lf
*.coffee text
*.json text
*.htm text
*.html text
*.xml text
*.svg text
*.txt text
*.ini text
*.inc text
*.pl text
*.rb text
*.py text
*.scm text
*.sql text
*.sh text
*.bat text
# templates
*.ejs text
*.hbt text
*.jade text
*.haml text
*.hbs text
*.dot text
*.tmpl text
*.phtml text
# git config
.gitattributes text
.gitignore text
.gitconfig text
# code analysis config
.jshintrc text
.jscsrc text
.jshintignore text
.csslintrc text
# misc config
*.yaml text
*.yml text
.editorconfig text
# build config
*.npmignore text
*.bowerrc text
# Heroku
Procfile text
.slugignore text
# Documentation
*.md text
LICENSE text
AUTHORS text
#
## These files are binary and should be left untouched
#
# (binary is a macro for -text -diff)
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
*.ico binary
*.mov binary
*.mp4 binary
*.mp3 binary
*.flv binary
*.fla binary
*.swf binary
*.gz binary
*.zip binary
*.7z binary
*.ttf binary
*.eot binary
*.woff binary
*.pyc binary
*.pdf binary

View File

@ -0,0 +1,8 @@
# Don't check auto-generated stuff into git
node_modules
package-lock.json
# Cruft
.DS_Store
npm-debug.log
.idea

View File

@ -0,0 +1,11 @@
# strapi-upload-cloudinary
## Resources
- [MIT License](LICENSE.md)
## Links
- [Strapi website](http://strapi.io/)
- [Strapi community on Slack](http://slack.strapi.io)
- [Strapi news on Twitter](https://twitter.com/strapijs)

View File

@ -0,0 +1,66 @@
'use strict';
/**
* Module dependencies
*/
// Public node modules.
const _ = require('lodash');
const cloudinary = require('cloudinary').v2;
const intoStream = require('into-stream');
module.exports = {
provider: 'cloudinary',
name: 'Cloudinary',
auth: {
cloud_name: {
label: 'Cloud name',
type: 'text'
},
api_key: {
label: 'API Key',
type: 'text'
},
api_secret: {
label: 'API Secret',
type: 'text'
}
},
init: (config) => {
cloudinary.config({
cloud_name: config.cloud_name,
api_key: config.api_key,
api_secret: config.api_secret
});
return {
upload (file) {
return new Promise((resolve, reject) => {
const upload_stream = cloudinary.uploader.upload_stream({}, (err, image) => {
if (err) {
return reject(err);
}
file.public_id = image.public_id;
file.url = image.secure_url;
resolve();
});
intoStream(file.buffer).pipe(upload_stream);
})
},
async delete (file) {
try {
const response = await cloudinary.uploader.destroy(file.public_id + '3', {
invalidate: true
});
if (response.result !== 'ok') {
throw {
error: new Error(response.result)
}
}
} catch (error) {
throw error.error;
}
}
};
}
};

View File

@ -0,0 +1,46 @@
{
"name": "strapi-upload-cloudinary",
"version": "3.0.0-alpha.11.1",
"description": "Cloudinary provider for strapi upload",
"homepage": "http://strapi.io",
"keywords": [
"upload",
"cloudinary",
"strapi"
],
"directories": {
"lib": "./lib"
},
"main": "./lib",
"dependencies": {
"cloudinary": "^1.11.0",
"into-stream": "^3.1.0"
},
"strapi": {
"isProvider": true
},
"author": {
"email": "perret.luca@gmail.com",
"name": "Luca Perret",
"url": "https://github.com/lucaperret"
},
"maintainers": [
{
"name": "Strapi team",
"email": "hi@strapi.io",
"url": "http://strapi.io"
}
],
"repository": {
"type": "git",
"url": "git://github.com/strapi/strapi.git"
},
"bugs": {
"url": "https://github.com/strapi/strapi/issues"
},
"engines": {
"node": ">= 9.0.0",
"npm": ">= 5.3.0"
},
"license": "MIT"
}