diff --git a/.eslintignore b/.eslintignore
index 8b50165d..f2148550 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1 +1,4 @@
-./locales/*.js
\ No newline at end of file
+./locales/*.js
+/public/javascripts/**/*.js
+/locales/**/*.js
+/public/stylesheets/**/*.css
\ No newline at end of file
diff --git a/.eslintrc.json b/.eslintrc.json
index 260a64fb..0ee3260d 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -2,7 +2,8 @@
"extends": "standard",
"plugins": [
"standard",
- "promise"
+ "promise",
+ "extra-rules"
],
"parserOptions": {
"ecmaVersion": 2017
@@ -26,6 +27,7 @@
"space-unary-ops" : 2,
"no-undef": 1,
"no-unused-vars": 1,
+ "extra-rules/no-commented-out-code": "warn",
"keyword-spacing": [
"error", {
"before": false, "after": false, "overrides": {
diff --git a/.gitignore b/.gitignore
index 015212e2..f2f068bb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,10 +4,9 @@ data/sessions.db
data/kb.db
data/votes.db
Rubbish/
-public/images/
-public/uploads/
data/export.zip
.vscode
jsconfig.json
.idea/
.DS_Store
+ecosystem.config.js
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index a3d56c67..8905710c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,8 +1,8 @@
language: node_js
node_js:
- "node"
+ - "12"
+ - "11"
+ - "10"
+ - "9"
- "8"
- - "7"
- - "6"
- - "5"
- - "4"
\ No newline at end of file
diff --git a/Dockerfile b/Dockerfile
index edccc984..f4d04579 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,20 +1,22 @@
-FROM alpine:3.5
-
-RUN apk add --update nodejs
-
+FROM node:10.16.3-alpine as builder
+RUN apk --no-cache add python make g++
WORKDIR /var/openKB
-
-COPY locales/ /var/openKB/locales/
-COPY public/ /var/openKB/public/
-COPY routes/ /var/openKB/routes/
-COPY views/ /var/openKB/views/
-COPY config/ /var/openKB/config/
-COPY app.js /var/openKB/
-COPY package.json /var/openKB/
-
+COPY package* .
RUN npm install
+FROM node:10.16.3-alpine
+WORKDIR /var/openKB
+COPY package.json .
+COPY locales/ locales/
+COPY public/ public/
+COPY routes/ routes/
+COPY views/ views/
+COPY config/ config/
+COPY app.js .
+COPY --from=builder /var/openKB/node_modules node_modules
+
VOLUME /var/openKB/data
+VOLUME /var/openKB/public/uploads
EXPOSE 4444
ENTRYPOINT ["npm", "start"]
diff --git a/README.md b/README.md
index b045273d..eecdbb78 100644
--- a/README.md
+++ b/README.md
@@ -1,248 +1,31 @@
-# openKB
+# Veda-KB
+
+## Présentation
-
+Cette base de données VEDA est un fork du projet OpenKB de Mark Vautin.
+OpenKB est une application de base de connaissances (Knowledge Base) sous forme de FAQ, conçue pour être facile à utiliser et à installer. Elle est basée sur un moteur de recherche, plutôt que sur une architecture en catégories: Recherchez simplement ce que vous voulez, et choisissez parmi les résultats.
-
+* L'édition des pages se fait avec la syntaxe [Markdown](http://spec.commonmark.org/).
+* On peut activer l'éditeur de graphes [Mermaid](http://knsv.github.io/mermaid/).
-[](https://travis-ci.org/mrvautin/openkb)
+## Installation & Configuration
-openKB is a Markdown Knowledge base application (FAQ) built with [Nodejs](https://nodejs.org/) and [ExpressJS](http://expressjs.com/). The application uses an embedded database ([nedb](https://github.com/louischatriot/nedb))
-by default but can also use a MongoDB server by changing the config (see below). The application is designed to be easy to use and install and based around search rather than nested categories. Simply search for what you want and select from the results.
+La description technique de la base de connaissance **openKB** est [ici](docs/technique.md)
-Demo: [http://openkb.markmoffat.com](http://openkb.markmoffat.com)
+Installation sur **Heroku**: voir [ici](docs/installation.md)
-## Support
+Pour la configuration et la customisation: voir [ici](docs/configuration.md)
-If my work helps you, please consider [](https://www.buymeacoffee.com/mrvautin)
+Pour les modification effectuées dans cette branche: voir le [change_log](docs/changelog.md)
-### Installation
+## Gestion des images
-1. Clone Repository: `git clone https://github.com/mrvautin/openKB.git && cd openKB`
-2. Install dependencies: `npm install`
-3. Start application: `npm start`
-4. Go to [http://127.0.0.1:4444](http://127.0.0.1:4444) in your browser
+*Heroku* ne conserve pas les fichiers qui sont uploadées via l'administration du site (le site est resetté toutes les heures). Pour ajouter une image, il faut donc procéder ainsi:
-Running the application in Production using minified code can be done by:
+* Déposer le fichier PNG (ou tout autre fichier, même non-image) dans le repository, dans `public/uploads/inline_files`.
+* Faire un `commit` du repository dans GitHub. Cela déclenche un upload du site actualisé vers *Heroku*.
+* Dans la page où l'on veut faire apparaitre les fichiers, on insère :
+ * `[Exemple de fichier XML](/uploads/inline_files/exemple.xml)` : fait apparaître un lien pour télécharger ou ouvrir le fichier.
+ * `` : fait apparaitre une image (on obtient le lien en allant dans `Administrateur` → `Fichiers` → `clic-droit` sur une image → `copier le lien` )
+ * `` : fait apparaitre une image issue d'un autre site
-1. Create the minified/ugly files: `npm run uglify`
-2. Ensure the minified/ugly files are being used: `NODE_ENV=production node app.js`
-
-> Note: `openKB` supports Nodejs version 4.0 and above.
-
-### Deploy on Heroku
-
-[](https://heroku.com/deploy?template=https://github.com/mrvautin/openKB)
-
-### Hosted/Managed
-
-Don't want to manage, upgrade and install `openKB` yourself? [ezyFAQ](https://www.ezyfaq.com) is a hosted solution with all the benefits and features of `openKB` and more but using a fully managed/hosted
-platform.
-
-### Features
-
-- **Search**: openKB is a search based Knowledge base (FAQ) backed by [Lunr.js](https://github.com/olivernn/lunr.js/) indexing to create the best possible results on searches.
-- **Backend**: openKB uses the pure Javascript [nedb](https://github.com/louischatriot/nedb) embedded database by default or a MongoDB server.
-- **Design/Themes**: openKB is meant to be simple flat design. Themes can be added by creating a theme folder within `public/themes/`. See the example theme for more information.
-- **Responsive**: openKB is built using Bootstrap allowing it to be responsive and work on all devices. The `admin` can be a little difficult editing Markdown on smaller screens.
-- **Mermaid**: openKB allows for [Mermaid](http://knsv.github.io/mermaid/) charts in articles.
-- **Editor**: openKB uses Markdown-it which is based off the [CommonMark spec](http://spec.commonmark.org/). This allows for the very best Markdown experience.
-- **Image management**: openKB allows for drag and drop of images into articles. The image is automatically uploaded to the server in the background. Google Chrome users can also paste images directly from the clipboard.
-
-### Screenshots
-
-**Homepage**
-
-
-
-**Responsive**
-
-
-
-**Fully Configurable**
-
-
-
-**Admin editor**
-
-
-
-**Article view**
-
-
-
-**Admin article management**
-
-
-
-**Managing files**
-
-
-
-**This is a deliberate rip from [https://twitter.com](https://twitter.com) to show an example. All design and credit goes to [https://twitter.com](https://twitter.com) and not openKB.**
-
-
-
-**Live search/typeahead**
-
-
-
-### Admin
-
-Visit: [http://127.0.0.1:4444/login](http://127.0.0.1:4444/login)
-
-A new user form will be shown where a user can be created.
-
-### Config
-
-Most of the configuration can be done on the `/settings` page but there are some addition values which require setting manually in the `/config/config.json` file.
-
-|Setting|Description|
-|--- |--- |
-|`route_name`|Sets the value in the URL for viewing an article (defaults to `kb`)|
-|`num_top_results`|Sets the number of results shown on the home page|
-|`date_format`|Sets the global date formatting. Uses moment.js date formatting, see more here: http://momentjs.com/docs/#/displaying|
-|`show_view_count`|Shows the view count next to the results on the homepage and search|
-|`update_view_count_logged_in`|Updates the view count if the user is logged in, as well as for anonymous users|
-|`show_published_date`|Shows the published date next to the results on the homepage and search|
-|`sort_by`|The order to sort articles|
-|`website_title`|The title of your website|
-|`show_featured_articles`|Whether to show any articles set to featured in a sidebar|
-|`show_featured_in_article`|Whether to show any articles set to featured in a sidebar when viewing an article|
-|`featured_articles_count`|The number of featured articles shown|
-|`theme`|The theme to use for public facing pages. Leave blank for default.|
-|`locale`|The language to use for public facing pages. Leave blank for default (English).|
-|`password_protect`|Setting to "true" will require a user to login before viewing ANY pages|
-|`show_kb_meta`|Whether to show article meta data including published date, last updated date, author etc|
-|`suggest_allowed`|If enabled non authenticated users can submit article suggestions for approval|
-|`show_author_email`|Controls whether the authors email address is displayed in the meta. Requires "Show article meta data" to be true.|
-|`mermaid`|Whether to allow Mermaid charts within articles|
-|`mathjax`|Whether to allow MathJax inputs within articles|
-|`app_context`|Allows for the website to be run from a non root path. Eg: http://127.0.0.1:4444/openkb/|
-|`links_blank_page`|Controls whether links within articles open a new page (tab)|
-|`add_header_anchors`|Whether to add HTML anchors to all heading tags for linking within articles or direct linking from other articles|
-|`typeahead_search`|Add live typeahead search results on the search inputs|
-|`index_article_body`|Whether to add the body of your articles to the search index (requires restart)|
-|`show_website_logo`|Controls whether to show the `website_title` text or a logo located: `/public/logo.png` (by default).|
-|`website_description`|A short website description when listing the homepage URL in search engines|
-|`database`|The database type to use. See **Database setup**|
-|`google_analytics`|Adds Google Analytics to public facing pages. Include the entire code from Google including the <script> tags.|
-|`style`|Add any Hex color codes, HTML color names and fonts to style the public pages of your KB.|
-
-**Data sorting**
-You can control the sort order or articles. You can sort on anything but popular fields are `kb_viewcount`, `kb_published_date`, `kb_last_updated` or `kb_votes`
-
-Setting the `sort_by` field in the `config.json` like so:
-
-``` javascript
-{field: 'kb_viewcount', order: -1};
-```
-
-Valid `order` values are: `-1` or `1`
-
-`1` = ascending order
-
-`-1` = decending order
-
-
-### Database setup
-
-By default, `openKB` uses an embedded Javascript database called [nedb](https://github.com/louischatriot/nedb) for easy installation. This works really well for small to medium sized applications but
-has it's limitations if you wanted to scale your application to handle many articles and concurrent users. For this reason, `openKB` also supports using a MongoDB server by simply changing the config file.
-
-Here is the `config.json` for the embedded database (NeDB):
-
-``` javascript
-"database": {
- "type": "embedded"
-}
-```
-
-Here is an example `config.json` for a MongoDB server. You can use your own localhost MongoDB instance or you may choose a hosted MongoDB server like [mLab](https://mlab.com/) or [Atlas](https://www.mongodb.com/cloud/atlas).
-
-``` javascript
-"database": {
- "type": "mongodb",
- "connection_string": "mongodb://127.0.0.1:27017/openkb"
-}
-```
-
-Alternately, for security reasons, you can use the Node environment variable (below) to store your MongoDB connection string.
-``` javascript
-MONGODB_CONNECTION_STRING
-```
-
-### Public API
-
-An optional public API can be enabled through `/settings` to allow inserting of documents by HTTP POST using services like IFTTT etc.
-
-**Note:The API is disabled by default**
-
-Once turned on, the API is hosted on route: `example.com/api/newArticle` via POST of a Object. The JSON schema is:
-
-``` javascript
- 'type': 'object',
- 'properties': {
- 'api_auth_token': {'type': 'string'},
- 'kb_title': {'type': 'string'},
- 'kb_body': {'type': 'string'},
- 'kb_permalink': {'type': 'string'},
- 'kb_published': {'type': 'boolean'},
- 'kb_keywords': {'type': 'string'},
- 'kb_author_email': {'type': 'string'},
- 'kb_password': {'type': 'string'},
- 'kb_featured': {'type': 'boolean'},
- 'kb_seo_title': {'type': 'string'},
- 'kb_seo_description': {'type': 'string'}
- },
- 'required': ['api_auth_token', 'kb_title', 'kb_body', 'kb_author_email', 'kb_published']
-```
-
-**Note: An API access token is required to be able to use the API. If the API is turned on without a token, all requests will reject. Please use a hard to guess token**
-
-The return Object from the API will be as follows:
-
-``` javascript
-{
- "result": false,
- "errors": [
- "Any error messages"
- ]
-}
-```
-
-The `errors` value will have any validation or error message which have occured. The `result` is an approval boolean. Eg: `true` was successful and `false` wasn't.
-
-### Migrating from NeDB to MongoDB (experimental)
-
-You can upgrade from NeDB to Mongodb by running the following command:
-
-Note: You will first need to setup a valid MongoDB connection as per the "Database setup" instructions.
-
-```
-npm run-script dbUpgrade
-```
-
-**please raise a Github issue if errors are encountered**
-
-### Typeahead search
-
-The typeahead search is great! Your user types in the word or phrase and the results pop up under the search box. But... One of the things to consider is that
-there is a little more data being transmitted from server to browser to enable this functionality. This is not normally a big issue for most browsers
-as the data is cached but you **may** run into issues if the number of articles in your app is quite large.
-
-As a general rule there is about 3KB of compressed data being transferred from server to browser for 20 articles with long titles and keywords. If you have
-hundreds of articles, the amount of data will increase and could cause performance issues. It is something to consider if your app seems to slow down once the
-article numbers increase. If this is the case, you can simply just turn it off.
-
-### Contributing
-
-Have design skills? Want to design theme(s) for `openKB`? Please design and submit PR.
-
-### openKB examples
-
-Have openKB running on a public facing server? Submit a PR with your URL and it will be updated here.
-
-### Running in production
-
-Using [PM2](https://github.com/Unitech/pm2) seems to be the easiest and best option for running production websites.
-See the [PM2](https://github.com/Unitech/pm2) for more information or a short guide here: [https://mrvautin.com/Running-Nodejs-applications-in-production-forever-vs-supervisord-vs-pm2](https://mrvautin.com/Running-Nodejs-applications-in-production-forever-vs-supervisord-vs-pm2).
diff --git a/app.js b/app.js
index bb1b4169..ab58942e 100644
--- a/app.js
+++ b/app.js
@@ -26,7 +26,7 @@ const app = express();
// setup the translation
const i18n = new (require('i18n-2'))({
- locales: ['en', 'de', 'da', 'es', 'cn', 'ru', 'pt-br', 'jp', 'fi', 'sv', 'tr'],
+ locales: ['en', 'de', 'fr', 'da', 'es', 'cn', 'ru', 'pt-br', 'jp', 'fi', 'sv', 'tr'],
directory: path.join(__dirname, 'locales/'),
defaultLocale: 'en',
cookieName: 'locale'
@@ -71,7 +71,7 @@ handlebars = handlebars.create({
app_context = '/' + app_context;
}
if(keywords){
- let array = keywords.split(','); let links = '';
+ const array = keywords.split(','); let links = '';
for(let i = 0; i < array.length; i++){
if(array[i].trim() !== ''){
links += '' + array[i].trim() + ' | ';
@@ -270,7 +270,7 @@ if(app_context !== ''){
// catch 404 and forward to error handler
app.use((req, res, next) => {
- let err = new Error('Not Found');
+ const err = new Error('Not Found');
err.status = 404;
next(err);
});
@@ -329,13 +329,16 @@ if(config.settings.database.type === 'embedded'){
});
});
}else{
- MongoClient.connect(config.settings.database.connection_string, {}, (err, db) => {
+ MongoClient.connect(config.settings.database.connection_string, {}, (err, client) => {
// On connection error we display then exit
if(err){
console.error('Error connecting to MongoDB: ' + err);
process.exit();
}
+ console.log('Connected to MongoDB :');
+ let dbName = "openkb";
+ let db = client.db(dbName);
// setup the collections
db.users = db.collection('users');
db.kb = db.collection('kb');
@@ -345,6 +348,7 @@ if(config.settings.database.type === 'embedded'){
app.db = db;
// add articles to index
+ console.log('Building index');
common.buildIndex(db, (index) => {
// add the index
app.index = index;
@@ -357,32 +361,32 @@ if(config.settings.database.type === 'embedded'){
});
}
-function exitHandler(options, err) {
- if (options.cleanup) {
+function exitHandler(options, err){
+ if(options.cleanup){
console.log('clean');
if(config.settings.database.type !== 'embedded'){
app.db.close();
}
}
- if (err) {
+ if(err){
console.log(err.stack);
}
- if (options.exit) {
+ if(options.exit){
process.exit();
}
}
-//do something when app is closing
-process.on('exit', exitHandler.bind(null,{cleanup:true}));
+// do something when app is closing
+process.on('exit', exitHandler.bind(null, { cleanup: true }));
-//catches ctrl+c event
-process.on('SIGINT', exitHandler.bind(null, {exit:true}));
+// catches ctrl+c event
+process.on('SIGINT', exitHandler.bind(null, { exit: true }));
// catches "kill pid" (for example: nodemon restart)
-process.on('SIGUSR1', exitHandler.bind(null, {exit:true}));
-process.on('SIGUSR2', exitHandler.bind(null, {exit:true}));
+process.on('SIGUSR1', exitHandler.bind(null, { exit: true }));
+process.on('SIGUSR2', exitHandler.bind(null, { exit: true }));
-//catches uncaught exceptions
-process.on('uncaughtException', exitHandler.bind(null, {exit:true}));
+// catches uncaught exceptions
+process.on('uncaughtException', exitHandler.bind(null, { exit: true }));
module.exports = app;
diff --git a/bin/uglify.js b/bin/uglify.js
index 753afb2f..be17247a 100644
--- a/bin/uglify.js
+++ b/bin/uglify.js
@@ -1,7 +1,7 @@
-var uglifycss = require('uglifycss');
-var uglifyjs = require('uglify-js');
-var path = require('path');
-var fs = require('fs');
+const uglifycss = require('uglifycss');
+const uglifyjs = require('uglify-js');
+const path = require('path');
+const fs = require('fs');
// css files
uglifyFile('public/stylesheets/style.css', 'css');
@@ -21,14 +21,14 @@ uglifyFile('public/javascripts/codemirror.inline-attachment.js', 'js');
function uglifyFile(filename, type){
if(type === 'css'){
- var cssfileContents = fs.readFileSync(filename, 'utf8');
- var cssUglified = uglifycss.processString(cssfileContents);
- var cssMiniFilename = filename.substring(0, filename.length - 4) + '.min.' + type;
+ const cssfileContents = fs.readFileSync(filename, 'utf8');
+ const cssUglified = uglifycss.processString(cssfileContents);
+ const cssMiniFilename = filename.substring(0, filename.length - 4) + '.min.' + type;
fs.writeFileSync(cssMiniFilename, cssUglified, 'utf8');
}
if(type === 'js'){
- var rawCode = fs.readFileSync(filename, 'utf8');
- var jsUglified = uglifyjs.minify(rawCode, {
+ const rawCode = fs.readFileSync(filename, 'utf8');
+ const jsUglified = uglifyjs.minify(rawCode, {
compress: {
dead_code: true,
global_defs: {
@@ -37,7 +37,7 @@ function uglifyFile(filename, type){
}
});
- var jsMiniFilename = filename.substring(0, filename.length - 3) + '.min.' + type;
+ const jsMiniFilename = filename.substring(0, filename.length - 3) + '.min.' + type;
fs.writeFileSync(jsMiniFilename, jsUglified.code, 'utf8');
}
}
diff --git a/config/config.json b/config/config.json
index 7473dd9c..4cb2aa3d 100644
--- a/config/config.json
+++ b/config/config.json
@@ -10,14 +10,14 @@
"field": "kb_viewcount",
"order": -1
},
- "website_title": "openKB",
+ "website_title": "veda-KB",
"show_featured_articles": true,
"show_featured_in_article": false,
- "featured_articles_count": "4",
+ "featured_articles_count": "5",
"password_protect": false,
"show_kb_meta": true,
"suggest_allowed": true,
- "show_author_email": true,
+ "show_author_email": false,
"mermaid": false,
"mathjax": false,
"mathjax_input_mode": "TeX-MML-AM_CHTML",
@@ -32,19 +32,19 @@
"show_logon": true,
"add_header_anchors": false,
"typeahead_search": true,
- "index_article_body": false,
- "enable_spellchecker": true,
+ "index_article_body": true,
+ "enable_spellchecker": false,
"show_website_logo": true,
- "website_description": "openKB is an Open Source Node.js Markdown based knowledge base/FAQ/Wiki app with powerful lunr search",
+ "website_description": "FAQ destinée à la mise au point des plateformes de diffusion VEDA.",
"article_versioning": false,
"api_auth_token": "",
"api_allowed": false,
- "locale": "en",
+ "locale": "fr",
"env": "",
"style": {
- "cssHeaderBackgroundColor": "",
+ "cssHeaderBackgroundColor": "#434240",
"cssHeaderTextColor": "",
- "cssFooterBackgroundColor": "",
+ "cssFooterBackgroundColor": "#434240",
"cssFooterTextColor": "",
"cssButtonBackgroundColor": "",
"cssButtonTextColor": "",
diff --git a/data/mongodbUpgrade.js b/data/mongodbUpgrade.js
index 128a62d4..e8211602 100644
--- a/data/mongodbUpgrade.js
+++ b/data/mongodbUpgrade.js
@@ -8,13 +8,13 @@
// There are no duplication checks in place. Please only run this script once.
// ** IMPORTANT **
-var Nedb = require('nedb');
-var mongodb = require('mongodb');
-var async = require('async');
-var path = require('path');
-var common = require('../routes/common');
-var config = common.read_config();
-var ndb;
+const Nedb = require('nedb');
+const mongodb = require('mongodb');
+const async = require('async');
+const path = require('path');
+const common = require('../routes/common');
+const config = common.read_config();
+let ndb;
// check for DB config
if(!config.settings.database.connection_string){
@@ -23,9 +23,9 @@ if(!config.settings.database.connection_string){
}
// Connect to the MongoDB database
-mongodb.connect(config.settings.database.connection_string, {}, function(err, mdb){
+mongodb.connect(config.settings.database.connection_string, {}, (err, mdb) => {
if(err){
- console.log("Couldn't connect to the Mongo database");
+ console.log('Couldn\'t connect to the Mongo database');
console.log(err);
process.exit(1);
}
@@ -33,8 +33,8 @@ mongodb.connect(config.settings.database.connection_string, {}, function(err, md
console.log('Connected to: ' + config.settings.database.connection_string);
console.log('');
- insertKB(mdb, function(KBerr, report){
- insertUsers(mdb, function(Usererr, report){
+ insertKB(mdb, (KBerr, report) => {
+ insertUsers(mdb, (Usererr, report) => {
if(KBerr || Usererr){
console.log('There was an error upgrading to MongoDB. Check the console output');
}else{
@@ -46,17 +46,17 @@ mongodb.connect(config.settings.database.connection_string, {}, function(err, md
});
function insertKB(db, callback){
- var collection = db.collection('kb');
+ const collection = db.collection('kb');
console.log(path.join(__dirname, 'kb.db'));
ndb = new Nedb(path.join(__dirname, 'kb.db'));
- ndb.loadDatabase(function (err){
+ ndb.loadDatabase((err) => {
if(err){
console.error('Error while loading the data from the NeDB database');
console.error(err);
process.exit(1);
}
- ndb.find({}, function (err, docs){
+ ndb.find({}, (err, docs) => {
if(docs.length === 0){
console.error('The NeDB database contains no data, no work required');
console.error('You should probably check the NeDB datafile path though!');
@@ -66,7 +66,7 @@ function insertKB(db, callback){
}
console.log('Inserting articles into MongoDB...');
- async.each(docs, function (doc, cb){
+ async.each(docs, (doc, cb) => {
console.log('Article inserted: ' + doc.kb_title);
// check for permalink. If it is not set we set the old NeDB _id to the permalink to stop links from breaking.
@@ -77,8 +77,8 @@ function insertKB(db, callback){
// delete the old ID and let MongoDB generate new ones
delete doc._id;
- collection.insert(doc, function (err){ return cb(err); });
- }, function (err){
+ collection.insert(doc, (err) => { return cb(err); });
+ }, (err) => {
if(err){
console.log('An error happened while inserting data');
callback(err, null);
@@ -93,16 +93,16 @@ function insertKB(db, callback){
};
function insertUsers(db, callback){
- var collection = db.collection('users');
+ const collection = db.collection('users');
ndb = new Nedb(path.join(__dirname, 'users.db'));
- ndb.loadDatabase(function (err){
+ ndb.loadDatabase((err) => {
if(err){
console.error('Error while loading the data from the NeDB database');
console.error(err);
process.exit(1);
}
- ndb.find({}, function (err, docs){
+ ndb.find({}, (err, docs) => {
if(docs.length === 0){
console.error('The NeDB database contains no data, no work required');
console.error('You should probably check the NeDB datafile path though!');
@@ -112,14 +112,14 @@ function insertUsers(db, callback){
}
console.log('Inserting users into MongoDB...');
- async.each(docs, function (doc, cb){
+ async.each(docs, (doc, cb) => {
console.log('User inserted: ' + doc.user_email);
// delete the old ID and let MongoDB generate new ones
delete doc._id;
- collection.insert(doc, function (err){ return cb(err); });
- }, function (err){
+ collection.insert(doc, (err) => { return cb(err); });
+ }, (err) => {
if(err){
console.error('An error happened while inserting user data');
callback(err, null);
@@ -132,5 +132,3 @@ function insertUsers(db, callback){
});
});
};
-
-
diff --git a/docs/changelog.md b/docs/changelog.md
new file mode 100644
index 00000000..f0a3ee46
--- /dev/null
+++ b/docs/changelog.md
@@ -0,0 +1,16 @@
+# Veda-KB
+
+## Changelog
+
+* [commit 5e15333](https://github.com/Sphinkie/VEDA-KB/commit/5e15333ccb95963d51f021afbb1484b0a1e6a398)
+Change le **nom de la page web** par la variable de configuration "website_title" (au lieu de "openKB" en dur) .
+
+* [commit acc3d24](https://github.com/Sphinkie/VEDA-KB/commit/acc3d2463b22eb53a54c3f58bae92a380d095358)
+Fichier Export avec prefixe et date: Au lieu de `export.xml`, on a `veda-KB_export_2020-09-19.xml`. Le prefixe est défini par la variable de configuration "website_title".
+
+* [commit be111f8](https://github.com/Sphinkie/VEDA-KB/commit/be111f89c04139501d410ee273a7a6e707c75ad0)
+Ajout de la **traduction française**.
+
+* [commit 954f5bb](https://github.com/Sphinkie/VEDA-KB/commit/954f5bbce0fa818a5f78c694b51bc538b45a55bc)
+Ajout de la compatibilité avec une base *mongodb* hébergée sur [mongodb.com](http://mongodb.com). Fix de l'erreur `db.connexion is not a function`.
+
diff --git a/docs/configuration.md b/docs/configuration.md
new file mode 100644
index 00000000..5ea0d85e
--- /dev/null
+++ b/docs/configuration.md
@@ -0,0 +1,88 @@
+# Veda-KB
+
+## Configuration
+A la première utilisation, un formulaire s'affiche pour créer un premier utilisateur (administrateur).
+
+La configuration se fait manuellement dans le fichier `/config/config.json`. on *commite* et on *push* le fichier modifié dans GitHub. Il est détecté par Heroku, qui le prend en compte et rebuilde l'application.
+
+*Les changements de configuration faits dans le module __Admin__ de l'application ne sont pas persistants.
+En effet, les modifications de fichiers locaux sont perdues chaque fois que Heroku réinitialise les containers.*
+
+
+|Setting|Description|
+|--- |--- |
+|`route_name`|Sets the value in the URL for viewing an article (defaults to `kb`)|
+|`num_top_results`|Sets the number of results shown on the home page|
+|`date_format`|Sets the global date formatting. Uses moment.js date formatting, see more here: http://momentjs.com/docs/#/displaying|
+|`show_view_count`|Shows the view count next to the results on the homepage and search|
+|`update_view_count_logged_in`|Updates the view count if the user is logged in, as well as for anonymous users|
+|`show_published_date`|Shows the published date next to the results on the homepage and search|
+|`sort_by`|The order to sort articles (1:ascending / -1:descending). You can sort on anything. Examples: `kb_viewcount`, `kb_published_date`, `kb_last_updated` or `kb_votes`|
+|`website_title`|The title of your website|
+|`show_featured_articles`|Whether to show any articles set to featured in a sidebar|
+|`show_featured_in_article`|Whether to show any articles set to featured in a sidebar when viewing an article|
+|`featured_articles_count`|The number of featured articles shown|
+|`theme`|The theme to use for public facing pages. Leave blank for default.|
+|`locale`|The language to use for public facing pages. Leave blank for default (English).|
+|`password_protect`|Setting to "true" will require a user to login before viewing ANY pages|
+|`show_kb_meta`|Whether to show article meta data including published date, last updated date, author etc|
+|`suggest_allowed`|If enabled non authenticated users can submit article suggestions for approval|
+|`show_author_email`|Controls whether the authors email address is displayed in the meta. Requires "Show article meta data" to be true.|
+|`mermaid`|Whether to allow Mermaid charts within articles|
+|`mathjax`|Whether to allow MathJax inputs within articles|
+|`app_context`|Allows for the website to be run from a non root path. Eg: http://127.0.0.1:4444/openkb/|
+|`links_blank_page`|Controls whether links within articles open a new page (tab)|
+|`add_header_anchors`|Whether to add HTML anchors to all heading tags for linking within articles or direct linking from other articles|
+|`typeahead_search`|Add live typeahead search results on the search inputs|
+|`index_article_body`|Whether to add the body of your articles to the search index (requires restart)|
+|`show_website_logo`|Controls whether to show the `website_title` text or a logo located: `/public/logo.png` (by default).|
+|`website_description`|A short website description when listing the homepage URL in search engines|
+|`database`|The database type to use. See **Database setup**|
+|`google_analytics`|Adds Google Analytics to public facing pages. Include the entire code from Google including the <script> tags.|
+|`style`|Add any Hex color codes, HTML color names and fonts to style the public pages of your KB.|
+
+
+### Stockage des données
+
+L'application **openKB** utilise une base de données.
+Cette database peut être:
+* Soit une base [nedb](https://github.com/louischatriot/nedb) sous forme de fichiers javascript locaux, qui ne nécessite aucune installation particulière, mais ne fonctionne pas dans un hébergement de type heroku.
+* Soit une base MongoDB [mLab](https://mlab.com/) ou [Atlas](https://www.mongodb.com/cloud/atlas).
+ Jusqu'en 2020, heroku fournissait un add-on **MongoDB** que l'on pouvait activer et utiliser. Depuis 2020, ce n'est plus disponible.
+ Il faut donc ouvrir une base *MongoDB*, par exemple avec le *free plan* de [mongodb.com](http://www.mongodb.com) et modifier l'application javascript ([voir le change-log](changelog.md)).
+
+Le type de BDD se configure dans le fichier de configuration `config.json` comme suit:
+
+* Pour une base **NeDB**:
+
+```json
+"database": {
+ "type": "embedded"
+}
+```
+
+* Pour une base **mongoDB**:
+
+```json
+"database": {
+ "type": "mongodb",
+ "connection_string": "mongodb://127.0.0.1:27017/openkb"
+}
+```
+
+La chaine de connexion peut être entrée dans le fichier de configuration (peu sûr) ou dans la variable d'environnement `MONGODB_CONNECTION_STRING` (recommandé) qui est configurable dans **heroku**.
+
+* Format d'une chaine de connexion *mongoDB*:
+```
+mongodb://:@/
+```
+
+* Chaine de connexion pour une base *mongoDB* de **heroku.com**:
+```
+mongodb://heroku_d2db22sn:@ds233763.mlab.com:33763/heroku_d2db22sn
+```
+
+* Chaine de connexion pour une base *mongoDB* de **mongodb.com**:
+```
+mongodb+srv://mongo_user:@openkb.whpvt.mongodb.net/openkb?retryWrites=true&w=majority
+```
diff --git a/docs/installation.md b/docs/installation.md
new file mode 100644
index 00000000..8d60ea5e
--- /dev/null
+++ b/docs/installation.md
@@ -0,0 +1,30 @@
+# Veda-KB
+
+## Installation sur Heroku
+
+Ce bouton permet de faire une installation initiale dans Heroku de openKB.
+
+[](https://heroku.com/deploy?template=https://github.com/mrvautin/openKB)
+
+Configurer ensuite les déploiements automatiques dans Heroku, provenant de votre propre fork.
+
+## Limitations dûes à Heroku
+
+Les dyno de Heroku sont des Containers *Stateless*: les fichiers sont supprimés ou remis à leur état initial toutes les heures environ.
+* La configuration faite par le menu **Admin** n'est donc pas perenne.
+* Les images ou fichiers insérés dans les articles ne sont pas conservés.
+
+
+
+## Base mongoDB
+
+On peut ouvrir une base de données *mongoDB* sur le site [mongodb.com](https://www.mongodb.com), avec le *free plan*. Cela se fait en quelques étapes:
+
+* Créer un *cluster*, et lui donner un nom.
+* Créer un user *administrateur* (par ex: mongo_admin)
+* Créer un user *utilisateur* (par exemple: mongo_user)
+* Dans *Cluster*, cliquer sur le bouton `connect`: cela va afficher la chaine de connection qu'il faudra configurer dans **heroku** dans une `Config Var` nommée **MONGODB_CONNECTION_STRING**, après avoir remplacer les champs prévus par `mongo_user`, son mot de passe, et le nom donné à la base de données.
+
+
+
+Note: Dans la page web de mongodb.com, on peut consulter le contenu de notre base de données.
\ No newline at end of file
diff --git a/docs/openkb_logo_small.png b/docs/openkb_logo_small.png
new file mode 100644
index 00000000..9e03a75c
Binary files /dev/null and b/docs/openkb_logo_small.png differ
diff --git a/docs/technique.md b/docs/technique.md
new file mode 100644
index 00000000..600256ad
--- /dev/null
+++ b/docs/technique.md
@@ -0,0 +1,22 @@
+# Veda-KB
+
+## L'application openKB
+
+L'application openKB est developpée par [Mark Vautin](https://github.com/mrvautin) et est disponible sur [GitHub](https://github.com/mrvautin/openKB).
+
+Elle est développée sous [Nodejs](https://nodejs.org/) et [ExpressJS](http://expressjs.com/) et utilise le moteur de recherche [Lunr.js](https://github.com/olivernn/lunr.js/).
+
+Elle utilise une base de données ([nedb](https://github.com/louischatriot/nedb)) (sous forme de fichier local) ou une base [MongoDB](https://www.mongodb.com)
+(par configuration. Voir plus bas).
+
+Demo: [http://openkb.markmoffat.com](http://openkb.markmoffat.com)
+
+
+
+## Recherche dynamique
+
+Le champ de recherche est dynamique, c'est à dire que les resultats s'affinent au fur et à mesure que vous tapez du texte dans le champ de recheche. Si le nombre d'entrées dans la base de connaissance est élevée, cette fonctionnalité peut ralentir l'application. On peut alors la désactiver dans le fichier de configuration.
+
+## API publique
+
+Une API publique existe qui permet d'ajouter des articles cia HTTP POST. Dans Veda-KB, elle est desactivée.
\ No newline at end of file
diff --git a/docs/vedakb_logo_small.png b/docs/vedakb_logo_small.png
new file mode 100644
index 00000000..2b936d21
Binary files /dev/null and b/docs/vedakb_logo_small.png differ
diff --git a/locales/en.js b/locales/en.js
index 3bbc3b2d..e008688d 100644
--- a/locales/en.js
+++ b/locales/en.js
@@ -180,5 +180,8 @@
"dsdsds is not defined": "dsdsds is not defined",
"dfdfd": "dfdfd",
"url.URL.parse is not a function": "url.URL.parse is not a function",
- "A user with that email does not exist.": "A user with that email does not exist."
+ "A user with that email does not exist.": "A user with that email does not exist.",
+ "Visible state": "Visible state",
+ "Public": "Public",
+ "Private": "Private"
}
\ No newline at end of file
diff --git a/locales/fr.js b/locales/fr.js
new file mode 100644
index 00000000..55a6136d
--- /dev/null
+++ b/locales/fr.js
@@ -0,0 +1,182 @@
+{
+ "Toggle navigation": "Changer le mode de navigation",
+ "Users": "Utilisateurs",
+ "New": "Nouveau",
+ "Edit": "Edition",
+ "My account": "Mon profil",
+ "Article": "Articles",
+ "Settings": "Réglages",
+ "Files": "Fichiers",
+ "Export": "Export",
+ "Cleanup files": "Supprimer les fichiers inutilisés",
+ "Logout": "Déconnexion",
+ "Powered by": "Powered by",
+ "Home": "Home",
+ "Articles": "Articles",
+ "Filter articles": "Filtres... ",
+ "Filter": "Filtrer",
+ "Reset": "Réinitialiser",
+ "All": "Tous",
+ "Published": "Publié",
+ "Recent": "Récents",
+ "Are you sure you want to delete this article?": "Etes-vous sûr de vouloir supprimer cet article?",
+ "Search": "Recherche",
+ "Featured articles": "Articles d'intérêt",
+ "Top articles": "Articles populaires",
+ "Suggest": "Suggestion",
+ "Login": "Connexion",
+ "Please sign in": "Connexion",
+ "email address": "Adresse mail",
+ "Password": "Mot de passe",
+ "Sign in": "Se connecter",
+ "Website": "Website",
+ "Display": "Affichage",
+ "Update": "Enregistrer",
+ "Website title": "Titre du site",
+ "The title of your website": "Le titre du site web",
+ "Website description": "Description du site",
+ "A short website description when listing the homepage URL in search engines": "Une courte description du site, pour apparaitre à coté de l'URL dans les moteurs de recherche",
+ "Show website logo": "Affichage du logo du site web",
+ "true": "Oui",
+ "false": "Non",
+ "Controls whether to show the 'Website title' text or a logo located: '/public/logo.png' (by default)": "Indique si le 'titre du site' doit être un texte ou un logo (par défaut: '/public/logo.png')",
+ "Controls whether to show the \"Website title\" text or a logo located: \"/public/logo.png\" (by default)": "Indique si le 'titre du site' doit être un texte ou un logo (par défaut: '/public/logo.png')",
+ "Website context/base URL": "Website context/base URL (Domain-Name)",
+ "Allows for the website to be run from a non root path. Eg: http://127.0.0.1:4444/openkb/": "Autorise l'application à démarrer depuis un répertoire autre que la racine. Par exemple: http://127.0.0.1:4444/openkb/",
+ "Allow API access": "Autorisation de l'accès par API",
+ "Whether to allow API access to insert articles - See documentation for further information": "Autorise l'ajout d'articles via l'API publique. Voir les informations détaillées dans la documentation",
+ "API access token": "API access token",
+ "Requires 'Allow API access' to be set to 'true'. The value is the access token required to access the public API. Please set to a hard to guess value": "Si l'accès par API est autorisé, définir une valeur de token pour les accès de l'API. (Choisir une valeur complexe)",
+ "Requires \"Allow API access\" to be set to \"true\". The value is the access token required to access the public API. Please set to a hard to guess value": "Si l'accès par API est autorisé, définir une valeur de token pour les accès de l'API publique. (Choisir une valeur complexe)",
+ "Password protect": "Protection par mot de passe",
+ "Setting to 'true' will require a user to login before viewing any pages": "Impose aux utilisateurs de s'identifier avant de pouvoir consulter les articles",
+ "Setting to \"true\" will require a user to login before viewing any pages": "Impose aux utilisateurs de s'identifier avant de pouvoir consulter les articles",
+ "Index article body": "Indexation du corps des articles (pour une recherche plus rapide)",
+ "Whether to add the body of your articles to the search index (requires restart)": "Indique si le corps des articles doit faire partie de l'index de recherche. (Nécessite un redémarrage de l'application)",
+ "Select a theme": "Choix du thème",
+ "The theme to use for public facing pages. Leave blank for default": "Thème graphique pour les pages du site. Laisser blanc pour le thème par défaut",
+ "Show logon link": "Affichage du lien 'Connexion'",
+ "Whether to show/hide the logon link in the top right of screen": "Affiche ou masque le lien 'Connexion' en haut à droite de la page d'accueil",
+ "Date format": "Format d'affichage des dates",
+ "Sets the global date formatting. Uses moment.js date formatting, see more here: http://momentjs.com/docs/#/displaying": "Positionne le format d'affichage des dates. Utilise le format de la librairie 'moment.js'. (Voir http://momentjs.com/docs/#/displaying)",
+ "Article suggestions allowed": "Autoriser les suggestions d'articles",
+ "If enabled non authenticated users can submit article suggestions for approval": "Quand activé, il n'est pas nécessaire que l'utilisateur soit connecté pour rédiger une suggestion d'article avec approbation ultérieure",
+ "Google analytics code": "Code Google Analytics",
+ "Adds Google Analytics to public facing pages. Include the entire code from Google including the <script> tags": "Intégration de Google Analytics aux pages du site. Saisir le code complet de Google Analytics, y compris les balises <script>",
+ "Allow voting": "Autorisation des votes",
+ "Whether to allow users to vote on an article": "Autorise les utilisateurs à voter sur les articles",
+ "Show article meta data": "Affichage des metadata de l'article",
+ "Whether to show article meta data including published date, last updated date, author etc": "Active l'affichage des metadata des articles (date de publication, auteur, etc)",
+ "Show author email": "Affichage de l'adresse mail de l'auteur",
+ "Controls whether the authors email address is displayed in the meta. Requires 'Show article meta data' to be true": "Indique si l'address mail de l'auteur doit être affichée dans les metadata de l'article",
+ "Controls whether the authors email address is displayed in the meta. Requires \"Show article meta data\" to be true": "Indique si l'address mail de l'auteur doit être affichée dans les metadata de l'article",
+ "Article links open new page": "Ouverture des articles dans un nouvel onglet",
+ "Controls whether links within articles open a new page (tab)": "Indique si les articles doivent s'ouvrir dans un nouvel onglet",
+ "Add header anchors": "Ancrage des entête",
+ "Whether to add HTML anchors to all heading tags for linking within articles or direct linking from other articles": "Ajout des 'anchors' html à toutes les balises de heading, pour les liens entre les articles",
+ "Enable editor spellchecker": "Correcteur orthographique",
+ "Controls whether to enable the editor spellchecker": "Active le correcteur orthographique (en Anglais) de la fenêtre d'édition des articles",
+ "Allow article versioning": "Versioning des articles",
+ "Whether to track article versions with each save of the editor": "Permet le suivi des articles à chaque sauvegarde dans l'éditeur",
+ "Number of top articles shown on homepage": "Nombre d'articles populaires dans la page d'accueil",
+ "Sets the number of results shown on the home page": "Définit le nombre d'articles populaires affichés dans la page d'accueil",
+ "Show published date": "Affichage de la date de publication",
+ "Shows the published date next to the results on the homepage and search": "Indique si la date de publication doit être affichée dans la page d'accueil et les résultats de recherche",
+ "Show view count": "Affichage du compteur de vues",
+ "Shows the view count next to the results on the homepage and search": "Indique si le compteur de vues doit être affiché dans la page d'accueil et les résultats de recherche",
+ "Update view count when logged in": "Mise à jour du compteur de vues au login",
+ "Updates the view count also when users are logged in": "Actualise le compteur de vues au moment où l'utilisateur se connecte",
+ "Show featured articles": "Affichage des articles d'intérêt",
+ "Whether to show any articles set to featured in a sidebar": "Définit si les articles d'intérêt doivent être affichés dans la barre latérale",
+ "Show featured articles when viewing article": "Affichage des articles d'intérêt pendant la lecture",
+ "Whether to show any articles set to featured in a sidebar when viewing an article": "Définit si les articles d'intérêt doivent être affichés dans la barre latérale aussi quand on visionne un article",
+ "Featured article count": "Décompte des articles d'intérêt",
+ "The number of featured articles shown": "Définit le nombre d'articles d'intérêt affichés",
+ "Adds Google Analytics to public facing pages. Include the entire code from Google including the