Skip to content

Commit

Permalink
Merge pull request #5 from philippebeck/dev
Browse files Browse the repository at this point in the history
Release 0.2.1
  • Loading branch information
philippebeck authored Jan 28, 2023
2 parents af3b992 + 5195fbc commit ead92df
Show file tree
Hide file tree
Showing 18 changed files with 153 additions and 228 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Vesan is a Content Manager System, where you can find 4 "homemade" packages comp
- Animadio, a CSS library built with Sass, as the design
- Nemjs, for JWT, Nodemailer, Sharp & back securities, as the backend services

Vesan uses many other well-known packages, like ExpressJS, Mongoose, Axios, etc...
Vesan uses many other well-known packages, like ExpressJS, Mongoose, etc...

## Summary

Expand Down Expand Up @@ -73,7 +73,7 @@ Available Views (UNDER CONSTRUCTION) :
- **PostView** *(Post of Blog)*
- **ContactView** *(Contact)*
- **LoginView** *(Login & Forgot Password)*
- **AdminView** *(Admin with the 2 Components)*
- **AdminView** *(Admin with all local Components)*
- **ErrorView** *(Error)*

Available Components (UNDER CONSTRUCTION) :
Expand Down
8 changes: 4 additions & 4 deletions api/controller/ArticleCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const form = formidable({
*/
exports.getImgName = (name) => {

return accents.remove(name).replace(" ", "-").toLowerCase() + "-" + Date.now() + "." + process.env.IMG_EXT;
return accents.remove(name).replace(/ /g, "-").toLowerCase() + "-" + Date.now() + "." + process.env.IMG_EXT;
}

/**
Expand Down Expand Up @@ -70,7 +70,7 @@ exports.createArticle = (req, res, next) => {
}

let image = this.getImgName(fields.name);
nem.createImage(files.image.newFilename, image);
nem.createImage("articles/" + files.image.newFilename, "articles/" + image);

let article = new ArticleModel(this.getArticle(fields.name, fields.description, image, fields.price));

Expand All @@ -90,7 +90,7 @@ exports.createArticle = (req, res, next) => {
* @param {function} next
*/
exports.updateArticle = (req, res, next) => {
form.parse(req, (err, fields) => {
form.parse(req, (err, fields, files) => {

if (err) {
next(err);
Expand All @@ -101,7 +101,7 @@ exports.updateArticle = (req, res, next) => {

if (Object.keys(files).length !== 0) {
image = this.getImgName(fields.name);
nem.createImage(files.image.newFilename, image);
nem.createImage("articles/" + files.image.newFilename, "articles/" + image);

ArticleModel
.findOne({ _id: req.params.id })
Expand Down
16 changes: 9 additions & 7 deletions api/controller/PostCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,24 @@ const form = formidable({
*/
exports.getImgName = (name) => {

return accents.remove(name).toLowerCase() + "-" + Date.now() + "." + process.env.IMG_EXT;
return accents.remove(name).replace(/ /g, "-").toLowerCase() + "-" + Date.now() + "." + process.env.IMG_EXT;
}

/**
* GET POST
* @param {string} title
* @param {string} text
* @param {string} image
* @param {string} author
* @returns
*/
exports.getPost = (title, text, image) => {
exports.getPost = (title, text, image, author) => {

return {
title: title,
text: text,
image: image
image: image,
author: author
}
}

Expand Down Expand Up @@ -68,9 +70,9 @@ exports.createPost = (req, res, next) => {
}

let image = this.getImgName(fields.title);
nem.createImage(files.image.newFilename, image);
nem.createImage("posts/" + files.image.newFilename, "posts/" + image);

let post = new PostModel(this.getPost(fields.title, fields.text, image));
let post = new PostModel(this.getPost(fields.title, fields.text, image, fields.author));

fs.unlink(process.env.IMG_URL + "posts/" + files.image.newFilename, () => {
post
Expand All @@ -88,7 +90,7 @@ exports.createPost = (req, res, next) => {
* @param {function} next
*/
exports.updatePost = (req, res, next) => {
form.parse(req, (err, fields) => {
form.parse(req, (err, fields, files) => {

if (err) {
next(err);
Expand All @@ -99,7 +101,7 @@ exports.updatePost = (req, res, next) => {

if (Object.keys(files).length !== 0) {
image = this.getImgName(fields.title);
nem.createImage(files.image.newFilename, image);
nem.createImage("posts/" + files.image.newFilename, "posts/" + image);

PostModel
.findOne({ _id: req.params.id })
Expand Down
6 changes: 3 additions & 3 deletions api/controller/UserCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ exports.checkCredentials = (email, pass, res) => {
*/
exports.getImgName = (name) => {

return accents.remove(name).toLowerCase() + "-" + Date.now() + "." + process.env.IMG_EXT;
return accents.remove(name).replace(/ /g, "-").toLowerCase() + "-" + Date.now() + "." + process.env.IMG_EXT;
}

/**
Expand Down Expand Up @@ -165,7 +165,7 @@ exports.createUser = (req, res, next) => {

this.checkCredentials(fields.email, fields.pass, res);
let image = this.getImgName(fields.name);
nem.createImage(files.image.newFilename, image);
nem.createImage("users/" + files.image.newFilename, "users/" + image);

bcrypt
.hash(fields.pass, 10)
Expand Down Expand Up @@ -202,7 +202,7 @@ exports.updateUser = (req, res, next) => {

if (Object.keys(files).length !== 0) {
image = this.getImgName(fields.name);
nem.createImage(files.image.newFilename, image);
nem.createImage("users/" + files.image.newFilename, "users/" + image);

UserModel
.findOne({ _id: req.params.id })
Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vesan",
"version": "0.2.0",
"version": "0.2.1",
"description": "CMS with Vue-Elt, Servidio, Animadio & NemJS",
"keywords": [
"cms",
Expand Down Expand Up @@ -30,7 +30,7 @@
"core-js": "^3.8.3",
"servidio": "^0.4.1",
"vue": "^3.2.45",
"vue-elt": "^0.6.0",
"vue-elt": "^0.6.1",
"vue-router": "^4.1.6"
},
"devDependencies": {
Expand Down
26 changes: 14 additions & 12 deletions src/components/CreateArticle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

<!-- Article Name -->
<template #item-1>
<FieldElt id="name"
<FieldElt id="article-name"
v-model:value="name"
info="My beautiful article"
@keyup.enter="validateNewArticle()"
info="My beautiful article"
:min="parseInt('2')">
<template #legend>
Name
Expand All @@ -24,11 +24,11 @@

<!-- Article Description -->
<template #item-2>
<FieldElt id="description"
<FieldElt id="article-description"
type="area"
v-model:value="description"
info="This article is wonderful !"
@keyup.enter="validateNewArticle()"
type="textarea">
info="This article is wonderful !">
<template #legend>
Description
</template>
Expand All @@ -40,7 +40,7 @@

<!-- Article Image -->
<template #item-3>
<FieldElt id="image"
<FieldElt id="article-image"
v-model:value="image"
info="Image file only"
type="file">
Expand All @@ -55,11 +55,13 @@

<!-- Article Price -->
<template #item-4>
<FieldElt id="price"
<FieldElt id="article-price"
type="number"
v-model:value="price"
info="100 €"
@keyup.enter="validateNewArticle()"
type="number">
info="100 €"
:min="1"
:max="1000">
<template #legend>
Price
</template>
Expand Down Expand Up @@ -98,11 +100,11 @@ export default {
validateNewArticle() {
if (this.$serve.checkName(this.name)) {
if (typeof document.getElementById('image').files[0] !== "undefined") {
if (typeof document.getElementById('article-image').files[0] !== "undefined") {
this.checkNewArticle();
} else {
alert("Une photo de l'utilisateur doit être uploadée !");
alert("A photo of the article must be uploaded !");
}
}
},
Expand Down Expand Up @@ -140,7 +142,7 @@ export default {
createArticle(isReferenced) {
if (!isReferenced) {
let article = new FormData();
let image = document.getElementById('image').files[0];
let image = document.getElementById('article-image').files[0];
article.append("name", this.name);
article.append("description", this.description);
Expand Down
Loading

0 comments on commit ead92df

Please sign in to comment.