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

Version 2.1.0 #40

Merged
merged 36 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
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
ae7c27a
Merge pull request #38 from CodeWe-projet/dev
BhasherBEL Dec 2, 2020
e90f501
remove line bugfix
Dec 2, 2020
dc3fb34
Merge pull request #39 from CodeWe-projet/editable-bugfix
AlexandreDewilde Dec 2, 2020
50ba6c6
preparing for deployment
Dec 2, 2020
2605aa9
Merge branch 'dev' of https://github.com/CodeWe-projet/CodeWe into dev
Dec 2, 2020
5e2ea9c
Archive old ToS and PP
TheoTechnicguy Dec 3, 2020
a4c820b
Change ToS and PP contact details
TheoTechnicguy Dec 3, 2020
afad3d8
Update header.html - Add ToS update mention
TheoTechnicguy Dec 3, 2020
ec347f0
Create .gitattributes
BhasherBEL Dec 3, 2020
8df69ed
Update .gitattributes
BhasherBEL Dec 3, 2020
e7645e8
Linguist ignore .htm files
Dec 3, 2020
003eac4
Merge pull request #42 from BhasherBEL/master
BhasherBEL Dec 3, 2020
94051a6
Remove all ToS and PP PDF archives
TheoTechnicguy Dec 3, 2020
26e2bb2
Archive old ToS and PP in htm
TheoTechnicguy Dec 3, 2020
c5672b5
Update Section 5 - Limits on using Our intelectual property
TheoTechnicguy Dec 3, 2020
2cc542a
Merge pull request #44 from CodeWe-projet/Legal
BhasherBEL Dec 3, 2020
08a2f23
reformat qrcode tests files
Dec 3, 2020
2d65f13
Merge branch 'dev' of https://github.com/CodeWe-projet/CodeWe into dev
Dec 3, 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
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.htm linguist-detectable=false
55 changes: 47 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

![codeWe](https://github.com/allEyezOnCode/CodeWe/blob/master/imgs/ex.gif?raw=True "codeWe - exemple")

---

## Installation

### Classic installation
Expand All @@ -19,7 +21,7 @@ The first step is to clone this repository.
Open a terminal and run:

```bash
git clone https://github.com/allEyezOnCode/CodeWe.git
git clone https://github.com/CodeWe-projet/CodeWe.git
```

Next step is to install depedencies
Expand Down Expand Up @@ -47,17 +49,54 @@ To run the server, run a shell in the `CodeWe/src` folder and run:
node ./src/server.js
```

## Next features

* Document with privileges (anon auth, and jwt usage)
* New programming langages
* More options
* Server montioring with prometheus and grafana
---

## Contribution

Feel free to contribute, open an issue, then fork the repo and submit a PR.


## Licence

This project is under MIT licence. The full licence can be read [here](https://github.com/allEyezOnCode/CodeWe).
This project is under MIT licence. The full licence can be read [here](https://github.com/CodeWe-projet/CodeWe/blob/master/LICENCE.md).

---

## Next features

* Document with privileges (anon auth, and jwt usage)


## Changelog

### Version [2.1.0](https://github.com/CodeWe-projet/CodeWe/pull/40)
#### Back-end
* Preparing the back-end for authentication.
* New prometheus gauges and counter.

#### Front-end
* Adding support of 20+ languages.
* Allow sharing URL by QR Code.
* Customize tabulation size.
* Remove line and others major bugfixes.

### Version [2.0.1](https://github.com/CodeWe-projet/CodeWe/pull/26)
#### Back-end
* Ability to redirect an http port to the main https port.
* Update configuration.
* Minor bug fixes.

#### Front-end
* Update legal content.
* Major bug fixes.

### Version [2.0.0](https://github.com/CodeWe-projet/CodeWe/tree/ad25d132ab92c0b9de227c9aedf04bda3f19681b)
#### Back-end
* Rewriting of the back end in nodejs.

#### Front-end
* Report issue button.
* Minor bug fixes.

### 1.0.0
* Initialisation of project using python and Flask for backend.
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',
];
10 changes: 6 additions & 4 deletions src/db/MongoDB.js
Original file line number Diff line number Diff line change
@@ -1,8 +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 @@ -12,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 @@ -35,7 +36,7 @@ class MongoDB {
}
}

async createDocument (language) {
async createDocument (documentLanguage) {
let doc = {
content: baseCode,
creationDate: Date.now(),
Expand All @@ -45,7 +46,7 @@ class MongoDB {
editors: [],
documentLink: '',
linkView: '',
language: language,
language: documentLanguage,
tab: 4
};
try {
Expand Down Expand Up @@ -173,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 @@ -216,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+ */
}
}
}
}
}
61 changes: 60 additions & 1 deletion src/publics/js/dev/component/custom.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,62 @@
/**
* Tab customization (allow convert current file)
* Tab customization
*/

import {editor, socket} from "/js/dev/page/editor.js";
import {patterns} from "/js/dev/page/editor/prism/patterns.js";
import PrismCustom from "/js/dev/page/editor/prism/prismCustom.js";

export default class Customize{
/** Init the customize object
* @param {Editable} editable
*/
constructor(editable) {
this.editable = editable;

document.getElementById('option-language').addEventListener('change', e => {
language = e.target.value.toLowerCase();
this.editable.updateAllHighlighting();
socket.send('language', {language});
});

document.addEventListener('socket.receive.language', e => {
if(Object.keys(patterns).includes(e.detail.language.toLowerCase())){
language = e.detail.language.toLowerCase();
document.getElementById('option-language').value = language;
this.editable.updateAllHighlighting();
}
});

for(const lang of Object.keys(patterns)){
const option = document.createElement('option');
option.innerText = lang;
if(lang === language) option.selected = true;
document.getElementById('option-language').appendChild(option);
}

document.getElementById('option-space-size').addEventListener('change', e => {
editor.tab.setSize(e.target.value);

for(const child of this.editable.editable.children){
child.innerText = editor.tab.updateText(child.innerText);
new PrismCustom(child, language).apply();
}

socket.send('changeTabSize', {size: e.target.value});
});

document.getElementById('option-space-size').value = this.editable.tab.size;

document.addEventListener('socket.receive.changeTabSize', e => {
if(e.detail.size && Number.isInteger(parseInt(e.detail.size))){
editor.tab.setSize(e.detail.size);
document.getElementById('option-space-size').value = e.detail.size;

for(const child of this.editable.editable.children){
child.innerText = editor.tab.updateText(child.innerText);
new PrismCustom(child, language).apply();
}
}
});
}
}
11 changes: 11 additions & 0 deletions src/publics/js/dev/lib/qrcode.min.js

Large diffs are not rendered by default.

13 changes: 11 additions & 2 deletions src/publics/js/dev/page/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,28 @@
* @date Last modification on 16/11/2020
* @version 1.0.1
*/
import Customize from "/js/dev/component/custom.js";
import Cursor from "/js/dev/page/editor/cursor.js";
import download from "/js/dev/page/editor/download.js";
import Editable from "/js/dev/page/editor/editable.js";
import {patterns} from "/js/dev/page/editor/prism/patterns.js";
import PrismCustom from "/js/dev/page/editor/prism/prismCustom.js";
import EditorSocket from "/js/dev/page/editor/socket.js";
import _ from "/js/dev/utils/element.js";
import qrCode from "/js/dev/utils/qrcode/qrcode-m-2.js";

export const socket = new EditorSocket(doc_id);
export const editor = new Editable(_.id('editor'));
export const cursor = new Cursor(_.id('editor'));

download(_.id('download'), _.id('editor'));

if(!Object.keys(patterns).includes(language)) language = 'generic';

for(const child of _.id('editor').children){
new PrismCustom(child, 'python').ApplyWithCaret();
new PrismCustom(child, language).apply();
}

download(_.id('download'), _.id('editor'));
export const customize = new Customize(editor);

qrCode('qrcode', document.documentURI.replace('/editor/', '/e/'));
Loading