Browse Source

🎉 Hello world

master
cdesmidt 2 years ago
commit
ade7ab4dec
  1. 22
      .gitignore
  2. 29
      README.md
  3. 5
      babel.config.js
  4. 49
      package.json
  5. 17
      public/email.php
  6. 116
      public/emails.json
  7. 4
      public/emails.php
  8. BIN
      public/favicon.ico
  9. 17
      public/index.php
  10. 31
      src/App.vue
  11. BIN
      src/assets/hero.png
  12. 73
      src/components/EmailModel.vue
  13. 13
      src/main.js
  14. 4
      vue.config.js
  15. 8487
      yarn.lock

22
.gitignore

@ -0,0 +1,22 @@
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
/package-lock.json

29
README.md

@ -0,0 +1,29 @@
# email-templates
## Project setup
```
yarn install
```
### Compiles and hot-reloads for development
```
yarn run serve
```
### Compiles and minifies for production
```
yarn run build
```
### Run your tests
```
yarn run test
```
### Lints and fixes files
```
yarn run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).

5
babel.config.js

@ -0,0 +1,5 @@
module.exports = {
presets: [[
'@vue/app', { useBuiltIns: "entry" }
]]
}

49
package.json

@ -0,0 +1,49 @@
{
"name": "email-templates",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^2.6.5",
"vue": "^2.6.10",
"vue-nl2br": "^0.1.2",
"vue-resource": "^1.5.1"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.11.0",
"@vue/cli-plugin-eslint": "^3.11.0",
"@vue/cli-service": "^3.11.0",
"babel-eslint": "^10.0.1",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"vue-devtools": "^5.1.3",
"vue-template-compiler": "^2.6.10"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended"
],
"rules": {},
"parserOptions": {
"parser": "babel-eslint"
}
},
"postcss": {
"plugins": {
"autoprefixer": {}
}
},
"browserslist": [
"> 1%",
"last 2 versions"
]
}

17
public/email.php

@ -0,0 +1,17 @@
<?php
$slug = $_POST['slug'];
$emails_json = json_decode(file_get_contents(__DIR__.'/emails.json'), true);
$emails = [];
foreach ($emails_json as $email) {
$emails[$email['slug']] = $email;
}
if (!array_key_exists($slug, $emails)) {
header('HTTP/1.0 404 Not Found');
}
$email = $emails[$slug];
header('Content-Type: application/json');
die(json_encode($email));

116
public/emails.json
File diff suppressed because it is too large
View File

4
public/emails.php

@ -0,0 +1,4 @@
<?php
header('Content-Type: application/json');
readfile(__DIR__.'/emails.json');

BIN
public/favicon.ico

17
public/index.php

@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="favicon.ico">
<title>Modèles d'Email</title>
</head>
<body>
<noscript>
<strong>Désolé mais cette application ne fonctionne pas sans JavaScript. Merci de l'activer pour continuer.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>

31
src/App.vue

@ -0,0 +1,31 @@
<template>
<div id="app">
<img alt="Vue logo" src="./assets/hero.png">
<EmailModel/>
</div>
</template>
<script>
import EmailModel from './components/EmailModel.vue'
export default {
name: 'app',
components: {
EmailModel
}
}
</script>
<style>
#app {
font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
margin-top: 60px;
margin-left: auto;
margin-right: auto;
width: 500px;
}
</style>

BIN
src/assets/hero.png

After

Width: 207  |  Height: 400  |  Size: 81 KiB

73
src/components/EmailModel.vue

@ -0,0 +1,73 @@
<template>
<div class="hello">
<h1>Modèles d'Email</h1>
<h2>Templates d'email potentiellement pré-rempli à usage professionnel et personnel !</h2>
<select v-model="selected" v-on:change="selectEmail">
<option v-for="template in emails" :value="template.slug" :key="template.slug">
{{ template.name }}
</option>
</select>
<div v-if="email != null">
<h4 class="email-subject">Sujet : {{ email.subject }}</h4>
<nl2br tag="p" :text="email.body" class-name="email-body"></nl2br>
</div>
</div>
</template>
<script>
import Vue from 'vue';
import VueResource from 'vue-resource';
import Nl2br from 'vue-nl2br';
Vue.component('nl2br', Nl2br);
Vue.use(VueResource);
export default {
name: "EmailModel",
components: {
Nl2br
},
data: function() {
return {
emails: [],
selected: "",
email: null
}
},
beforeCreate() {
let $this = this;
Vue.http.get("emails.php").then(response => {
$this.emails = response.body
});
},
methods: {
selectEmail: function() {
let $this = this;
Vue.http.post("email.php", {"slug": $this.selected}).then(response => {
$this.email = response.body;
// $this.email.body.replace(/(\r\n|\n\r|\r|\n)/g, '<br>$1');
});
}
}
}
</script>
<style scoped>
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
.email-subject, .email-body {
text-align: left;
}
</style>

13
src/main.js

@ -0,0 +1,13 @@
import Vue from 'vue'
import App from './App.vue'
import VueResource from 'vue-resource';
Vue.use(VueResource);
Vue.config.productionTip = false;
Vue.config.debug = true;
Vue.config.devtools = true;
Vue.http.options.emulateJSON = true;
new Vue({
render: h => h(App),
}).$mount('#app');

4
vue.config.js

@ -0,0 +1,4 @@
// vue.config.js
module.exports = {
publicPath: "/shikiryu/email-templates/dist/"
}

8487
yarn.lock
File diff suppressed because it is too large
View File

Loading…
Cancel
Save