Skip to content
This repository was archived by the owner on Mar 10, 2024. It is now read-only.
Merged

Dev #38

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
9b0c172
Update legal.less
TheoTechnicguy Nov 21, 2020
a3c30d0
Redirection fixes
TheoTechnicguy Nov 21, 2020
572c7fc
Update welcome.html
TheoTechnicguy Nov 22, 2020
3a0f5af
Merge branch 'master' into Legal
TheoTechnicguy Nov 22, 2020
28d4a15
Move Legal documents
TheoTechnicguy Nov 22, 2020
ddd7c54
Update Terms and Conditions - CodeWe.docx
TheoTechnicguy Nov 22, 2020
f4eeb20
Update Privacy Policy - CodeWe.docx
TheoTechnicguy Nov 22, 2020
9d5a293
Move old ToS and PP HTML and PDF to archive
TheoTechnicguy Nov 22, 2020
81996bd
Update privacy.html
TheoTechnicguy Nov 22, 2020
fdc61fa
Update tos.html
TheoTechnicguy Nov 22, 2020
9556efa
ToS and PP PDF versions
TheoTechnicguy Nov 22, 2020
b948e53
Update legal.js
TheoTechnicguy Nov 22, 2020
ad8b039
Update footer.html
TheoTechnicguy Nov 22, 2020
8f05a98
Production minified js
Nov 22, 2020
ad6379b
.gitattributes
Nov 24, 2020
13c6cb0
Update .gitattributes
BhasherBEL Nov 24, 2020
404a5f8
Autoformating and licence route fix
TheoTechnicguy Nov 25, 2020
5abb3df
Postponed Begin Date
TheoTechnicguy Nov 25, 2020
f85733a
Merge pull request #22 from CodeWe-projet/Legal
BhasherBEL Nov 25, 2020
ab9df58
Merge pull request #23 from CodeWe-projet/editable-bugfix
BhasherBEL Nov 25, 2020
0574586
Redirect http to https
Nov 25, 2020
1e0baee
Update text on start
Nov 25, 2020
8b00759
Verify than redirect port is not null
Nov 25, 2020
908a2f4
Update LICENCE.md
TheoTechnicguy Nov 25, 2020
66b230a
Merge pull request #24 from CodeWe-projet/http-redirect
BhasherBEL Nov 25, 2020
ad25d13
Merge pull request #25 from CodeWe-projet/Legal
BhasherBEL Nov 25, 2020
b33ee68
Merge pull request #26 from CodeWe-projet/dev
BhasherBEL Nov 26, 2020
3f24818
minify editor
Nov 26, 2020
8f47ad0
Update .gitattributes
BhasherBEL Nov 26, 2020
f61d02b
change url gen
AlexandreDewilde Nov 26, 2020
b924ecd
Update .gitattributes
BhasherBEL Nov 26, 2020
9a30345
Update .gitattributes
BhasherBEL Nov 26, 2020
77a8d8c
FIX bug when one line
AlexandreDewilde Nov 26, 2020
d783095
fix bug with one line(be sure )
AlexandreDewilde Nov 26, 2020
803f201
Delete .gitattributes
BhasherBEL Nov 26, 2020
8647463
Delete editor.min.js
BhasherBEL Nov 26, 2020
0d25d19
Merge pull request #28 from CodeWe-projet/master
Nov 26, 2020
efecd76
Merge remote-tracking branch 'origin/urlgen' into dev
Nov 26, 2020
632170f
first step of customisation
Nov 26, 2020
812fe86
add regex from rainbow library to support new langage
AlexandreDewilde Nov 26, 2020
e1020ae
change backend to accept other langage
AlexandreDewilde Nov 26, 2020
16a5b1e
change backend for new langages support
AlexandreDewilde Nov 26, 2020
06d8f67
next customisation step
Nov 27, 2020
367a746
add oz regex
AlexandreDewilde Nov 27, 2020
71c5f15
avoid error when creating a new document
AlexandreDewilde Nov 27, 2020
5e9aac6
Language, tabsize and qrcode update
Nov 27, 2020
3eb631a
QR Code first part
Nov 28, 2020
af7f583
Merge pull request #35 from CodeWe-projet/customisation
AlexandreDewilde Nov 29, 2020
35ef0ae
QR-code
Nov 30, 2020
0216a06
QR-code utils and compressed editor
Nov 30, 2020
ef7f36f
Prometheus data update
Nov 30, 2020
c0a2f39
Merge pull request #36 from CodeWe-projet/qrcode
Nov 30, 2020
6b0ced0
Merge branch 'dev' into prom-update
Nov 30, 2020
385e252
Merge pull request #37 from CodeWe-projet/prom-update
Nov 30, 2020
90eb1cc
chrome qr-code rendering bug fix
Nov 30, 2020
7d2bf67
remove line bugfix
Nov 30, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENCE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Dewilde Alexandre, Dubois Brieuc and Fischer Nicolas
Copyright (c) 2020 Dewilde Alexandre, Dubois Brieuc and Technicguy Theo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Binary file removed Privacy Policy - CodeWe.docx
Binary file not shown.
Binary file removed Terms and Conditions - CodeWe.docx
Binary file not shown.
5 changes: 5 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 @@ -27,6 +27,7 @@
"mongodb": "^3.6.3",
"morgan": "^1.10.0",
"mysql": "^2.18.1",
"nanoid": "^3.1.18",
"nunjucks": "^3.2.2",
"prom-client": "^12.0.0",
"prometheus-api-metrics": "^3.1.0",
Expand Down
19 changes: 12 additions & 7 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,22 @@ const index = require('./routes/index');
const editor = require('./routes/editor');
const legal = require('./routes/legal');
const config = require('./config/config');
const ssl = config.SSL;

const app = express();
app.disable("x-powered-by");

if (ssl) {
app.use('*', function (req, res, next) {
if (req.secure) {
next();
} else {
const target = (req.headers.host.includes(':') ? req.headers.host.split(':')[0] : req.headers.host) + ':' + config.PORT;
res.redirect('https://' + target + req.url);
}
});
}

// Configure views folder
nunjucks.configure(path.join(__dirname, 'views'), {
autoescape: true,
Expand Down Expand Up @@ -51,13 +63,6 @@ app.use('/', index);
app.use('/editor', editor);
app.use('/legal', legal);

// redirect to https when ssl is active
if (config.SSL) {
app.get('*', function(req, res) {
res.redirect('https://' + req.headers.host + req.url);
});
}

// 404 error
app.all('*', (req, res) => {
res.status(404).render('404.html', {production: config.PRODUCTION, client_versobe: config.CLIENT_VERBOSE});
Expand Down
1 change: 1 addition & 0 deletions src/config/config dist.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"SSL": false,
"KEY_FILE_SSL": null,
"CERT_FILE_SSL" : null,
"REDIRECT_PORT": null,
"METRICS": false,
"METRICS_PORT": 8000
}
25 changes: 25 additions & 0 deletions src/config/langages.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module.exports = [
"python",
"c",
"c++",
"c#",
"javascript",
"java",
"haskell",
"smalltalk",
"coffescript",
"css",
"d",
"go",
"haskell",
"html",
"json",
"lua",
"php",
"r",
"ruby",
"scheme",
"shell",
"sql",
'oz',
];
15 changes: 9 additions & 6 deletions src/db/MongoDB.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
const { MongoClient, ObjectID } = require("mongodb");
var crypto = require('crypto');
const { nanoid } = require('nanoid');
const languages = require('../config/langages');
const configs = require('../config/config');
const utils = require('../utils');
const prom = require('../socket/prom')

const baseCode = [
{uuid: utils.uuid(Math.random().toString(), 10), content: 'def main(text: str) -> None:'},
Expand All @@ -11,7 +14,6 @@ const baseCode = [
{uuid: utils.uuid(Math.random().toString(), 10), content: ' main(\'Hello World !\')'}
];


class MongoDB {
constructor (url) {
this.client = new MongoClient(url, {
Expand All @@ -34,7 +36,7 @@ class MongoDB {
}
}

async createDocument (language) {
async createDocument (documentLanguage) {
let doc = {
content: baseCode,
creationDate: Date.now(),
Expand All @@ -44,13 +46,13 @@ class MongoDB {
editors: [],
documentLink: '',
linkView: '',
language: language,
language: documentLanguage,
tab: 4
};
try {
let results = (await this.documentsCollection.insertOne(doc));
const documentLink = utils.uuid(results.insertedId.toString());
const linkView = utils.uuid(documentLink);
const linkView = nanoid(5);
this.documentsCollection.updateOne({_id: results.insertedId}, {$set: {documentLink: documentLink, linkView: linkView}});
return documentLink;
} catch (err) {
Expand Down Expand Up @@ -117,7 +119,7 @@ class MongoDB {
let index = doc.content.findIndex(line => {
return line.uuid == previousUuid;
});
if (index) {
if (index || index === 0) {
this.documentsCollection.updateOne({documentLink: documentLink}, {
$push: {
content: {
Expand Down Expand Up @@ -172,7 +174,7 @@ class MongoDB {
}

async changeLanguage(documentLink, newLanguage) {
if (["python"].includes(newLanguage)) {
if (languages.includes(newLanguage)) {
return this.changeParam(documentLink, 'language', newLanguage);
}
}
Expand Down Expand Up @@ -215,6 +217,7 @@ class MongoDB {
case 'new-line':
results = await this.newLine(documentLink, data.previous, data.id, data.content);
if (!results) success = false;
prom.total_new_lines.inc();
break;
case 'delete-line':
results = await this.deleteLine(documentLink, data.id);
Expand Down
2 changes: 1 addition & 1 deletion src/publics/css/base.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
| Generic |
\*******************/

@background-color: #222;
@background-color: #222222;
@color: #fff;
@font: sans-serif;
@absolute-color: #d5e6ed;
Expand Down
71 changes: 71 additions & 0 deletions src/publics/css/editor.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
@background-color: #222222;
@color: #fff;
@header-height: 60px;

/******************\
| Header |
\******************/
Expand Down Expand Up @@ -57,3 +61,70 @@ section#editor{
background-color: red;
border-radius: 10px;
}

/*******************\
| Navigation Bar |
\*******************/

#customise{
position: fixed;
top: 1.1 * @header-height;
right: 0;
width: 20%;
height: 100%;
max-width: 300px;
min-width: 200px;
padding: 20px;
background-color: darken(@background-color, 2%);
border-left: 1px solid #111111;
z-index: 5;

ul{
list-style: none;

li{
padding-bottom: 20px;

h3{
padding: 5px 0;
color: darken(@color, 50%);
letter-spacing: 3px;
border-bottom: 1px solid lighten(@background-color, 10%);
display: inline;
}

> :not(h3){
padding: 7px;
margin-top: 20px;
border-radius: 10px;
}

select,
input{
color: @color;
background-color: lighten(@background-color, 5%);
border-color: @background-color;
width: 90%;
}

#qrcode{
background-color: white;
display: inline-block;

canvas{
width: 128px;
height: 128px;
margin: 10px;
background-color: white;
image-rendering: optimizeSpeed; /* */
image-rendering: -moz-crisp-edges; /* Firefox */
image-rendering: -o-crisp-edges; /* Opera */
image-rendering: -webkit-optimize-contrast; /* Chrome (and Safari) */
image-rendering: pixelated; /* Chrome as of 2019 */
image-rendering: optimize-contrast; /* CSS3 Proposed */
-ms-interpolation-mode: nearest-neighbor; /* IE8+ */
}
}
}
}
}
102 changes: 68 additions & 34 deletions src/publics/css/legal.less
Original file line number Diff line number Diff line change
@@ -1,36 +1,70 @@
section{
width: 50%;
min-width: 700px;
margin: auto;
color: rgb(193, 187, 177);
line-height: 1.7;
word-wrap: break-word;
text-align: justify;
font-family: helvetica neue,Helvetica,Arial,sans-serif;
font-size: 1.125rem;

h1{
font-size: 2.125rem;
margin-top: 25px;
line-height: 1.4;
}

p{
font-size: 1rem;
margin-bottom: 10px;
}

a{
color: inherit;
text-decoration: none;
transition: color ease-in-out 0.2s;
}

a:hover{
color: #ddd;
}

ul{
margin-left: 20px;
}
width: 50%;
min-width: 700px;
margin: auto;
color: rgb(193, 187, 177);
line-height: 1.7;
word-wrap: break-word;
text-align: justify;
font-family: helvetica neue, Helvetica, Arial, sans-serif;
font-size: 1.125rem;

h1{
font-size: 2.125rem;
margin-top: 25px;
line-height: 1.4;
}

p{
font-size: 1rem;
margin-bottom: 10px;
}

a{
color: inherit;
text-decoration: none;
transition: color ease-in-out 0.2s;
}

a:hover{
color: #ddd;
}

ul{
margin-left: 20px;
}
}


table {
width: 100%
}

td.align-right {
text-align: right;
}

#not-valid {
width: 100%;
background-color: red;
text-align: center;
font-size: 38px;
color: white;
}
#redirect {
width: 100%;
background-color: darkred;
text-align: center;
font-size: 18px;
color: white;
}

#redirect:hover {
background-color: maroon;
transition: 0.2s ease-in-out;
}

div.revision {
border: 1px darkcyan solid;
padding: 5px;
}
Loading