3.0 source code

This commit is contained in:
agolybev
2015-04-28 17:59:00 +03:00
parent c69fd34bdd
commit 7b3b2248e5
16311 changed files with 1445974 additions and 3108429 deletions

View File

@@ -1,36 +1,39 @@
{
"server": {
"port": 8080,
"mode": "development"
},
"dictionaries": [
{"name": "ca_ES", "id": 1027},
{"name": "cs_CZ", "id": 1029},
{"name": "da_DK", "id": 1030},
{"name": "de_DE", "id": 1031},
{"name": "el_GR", "id": 1032},
{"name": "en_US", "id": 1033},
{"name": "fr_FR", "id": 1036},
{"name": "hu_HU", "id": 1038},
{"name": "it_IT", "id": 1040},
{"name": "ko_KR", "id": 1042},
{"name": "nl_NL", "id": 1043},
{"name": "nb_NO", "id": 1044},
{"name": "pl_PL", "id": 1045},
{"name": "pt_BR", "id": 1046},
{"name": "ro_RO", "id": 1048},
{"name": "ru_RU", "id": 1049},
{"name": "sk_SK", "id": 1051},
{"name": "sv_SE", "id": 1053},
{"name": "tr_TR", "id": 1055},
{"name": "uk_UA", "id": 1058},
{"name": "lv_LV", "id": 1062},
{"name": "lt_LT", "id": 1063},
{"name": "vi_VN", "id": 1066},
{"name": "de_CH", "id": 2055},
{"name": "nn_NO", "id": 2068},
{"name": "pt_PT", "id": 2070},
{"name": "de_AT", "id": 3079},
{"name": "es_ES", "id": 3082}
]
{
"server": {
"port": 8080,
"mode": "development"
},
"dictionaries": [
{"name": "ca_ES", "id": 1027},
{"name": "cs_CZ", "id": 1029},
{"name": "da_DK", "id": 1030},
{"name": "de_DE", "id": 1031},
{"name": "el_GR", "id": 1032},
{"name": "en_US", "id": 1033},
{"name": "fr_FR", "id": 1036},
{"name": "hu_HU", "id": 1038},
{"name": "it_IT", "id": 1040},
{"name": "ko_KR", "id": 1042},
{"name": "nl_NL", "id": 1043},
{"name": "nb_NO", "id": 1044},
{"name": "pl_PL", "id": 1045},
{"name": "pt_BR", "id": 1046},
{"name": "ro_RO", "id": 1048},
{"name": "ru_RU", "id": 1049},
{"name": "sk_SK", "id": 1051},
{"name": "sv_SE", "id": 1053},
{"name": "tr_TR", "id": 1055},
{"name": "uk_UA", "id": 1058},
{"name": "lv_LV", "id": 1062},
{"name": "lt_LT", "id": 1063},
{"name": "vi_VN", "id": 1066},
{"name": "az_Latn_AZ", "id": 1068},
{"name": "de_CH", "id": 2055},
{"name": "en_GB", "id": 2057},
{"name": "nn_NO", "id": 2068},
{"name": "pt_PT", "id": 2070},
{"name": "de_AT", "id": 3079},
{"name": "en_AU", "id": 3081},
{"name": "es_ES", "id": 3082}
]
}

View File

@@ -1,71 +1,60 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
var config = require("./config.json");
process.env.NODE_ENV = config["server"]["mode"];
var logger = require("./../../Common/sources/logger");
var express = require("express");
var http = require("http");
var https = require("https");
var fs = require("fs");
var app = express();
var server = {};
if (config["ssl"]) {
var privateKey = fs.readFileSync(config["ssl"]["key"]).toString();
var certificateKey = fs.readFileSync(config["ssl"]["cert"]).toString();
var trustedCertificate = fs.readFileSync(config["ssl"]["ca"]).toString();
var options = {
key: privateKey,
cert: certificateKey,
ca: [trustedCertificate]
};
server = https.createServer(options, app);
} else {
server = http.createServer(app);
}
app.configure("development", function () {
app.use(express.errorHandler({
dumpExceptions: true,
showStack: true
}));
});
app.configure("production", function () {
app.use(express.errorHandler());
});
var spellCheck = require("./spellCheck");
spellCheck.install(server, function () {
server.listen(config["server"]["port"], function () {
logger.info("Express server listening on port %d in %s mode", config["server"]["port"], app.settings.env);
});
app.get("/index.html", function (req, res) {
res.send("Server is functioning normally");
});
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
var config = require("./config.json");
process.env.NODE_ENV = config["server"]["mode"];
var logger = require("./../../Common/sources/logger");
var express = require("express");
var http = require("http");
var https = require("https");
var fs = require("fs");
var app = express();
var server = {};
if (config["ssl"]) {
var privateKey = fs.readFileSync(config["ssl"]["key"]).toString();
var certificate = fs.readFileSync(config["ssl"]["cert"]).toString();
var options = {
key: privateKey,
cert: certificate
};
server = https.createServer(options, app);
} else {
server = http.createServer(app);
}
var spellCheck = require("./spellCheck");
spellCheck.install(server, function () {
server.listen(config["server"]["port"], function () {
logger.info("Express server listening on port %d in %s mode", config["server"]["port"], app.settings.env);
});
app.get("/index.html", function (req, res) {
res.send("Server is functioning normally");
});
});

View File

@@ -1,131 +1,131 @@
/*
* (c) Copyright Ascensio System SIA 2010-2014
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
var sockjs = require("sockjs"),
nodehun = require("nodehun"),
config = require("./config.json"),
logger = require("./../../Common/sources/logger");
var arrDictionaries = {};
(function () {
var arrDictionariesConfig = config["dictionaries"];
var oDictTmp = null,
pathTmp = "",
oDictName = null;
for (var indexDict = 0, lengthDict = arrDictionariesConfig.length; indexDict < lengthDict; ++indexDict) {
oDictTmp = arrDictionariesConfig[indexDict];
oDictName = oDictTmp.name;
pathTmp = __dirname + "/../Dictionaries/" + oDictName + "/" + oDictName + ".";
arrDictionaries[oDictTmp.id] = new nodehun.Dictionary(pathTmp + "aff", pathTmp + "dic");
}
})();
exports.install = function (server, callbackFunction) {
var sockjs_opts = {
sockjs_url: "http://cdn.sockjs.org/sockjs-0.3.min.js"
},
sockjs_echo = sockjs.createServer(sockjs_opts),
dataHandler;
sockjs_echo.on("connection", function (conn) {
if (null == conn) {
logger.error("null == conn");
return;
}
conn.on("data", function (message) {
try {
var data = JSON.parse(message);
dataHandler[data.type](conn, data);
} catch(e) {
logger.error("error receiving response:" + e);
}
});
conn.on("error", function () {
logger.error("On error");
});
conn.on("close", function () {
logger.info("Connection closed or timed out");
});
});
function sendData(conn, data) {
conn.write(JSON.stringify(data));
}
dataHandler = (function () {
function spellCheck(conn, data) {
function checkEnd() {
if (0 === data.usrWordsLength) {
sendData(conn, {
type: "spellCheck",
spellCheckData: JSON.stringify(data)
});
}
}
function spellSuggest(index, word, lang) {
var oDictionary = arrDictionaries[lang];
if (undefined === oDictionary) {
data.usrCorrect[index] = false;
--data.usrWordsLength;
checkEnd();
} else {
if ("spell" === data.type) {
oDictionary.spellSuggest(word, function (a, b) {
data.usrCorrect[index] = a;
--data.usrWordsLength;
checkEnd();
});
} else {
if ("suggest" === data.type) {
oDictionary.spellSuggestions(word, function (a, b) {
data.usrSuggest[index] = b;
--data.usrWordsLength;
checkEnd();
});
}
}
}
}
data = JSON.parse(data.spellCheckData);
data.usrCorrect = [];
data.usrSuggest = [];
data.usrWordsLength = data.usrWords.length;
for (var i = 0, length = data.usrWords.length; i < length; ++i) {
spellSuggest(i, data.usrWords[i], data.usrLang[i]);
}
}
return {
spellCheck: spellCheck
};
} ());
sockjs_echo.installHandlers(server, {
prefix: "/doc/[0-9-.a-zA-Z_=]*/c",
log: function (severity, message) {
logger.info(message);
}
});
callbackFunction();
/*
* (c) Copyright Ascensio System SIA 2010-2015
*
* This program is a free software product. You can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License (AGPL)
* version 3 as published by the Free Software Foundation. In accordance with
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
* that Ascensio System SIA expressly excludes the warranty of non-infringement
* of any third-party rights.
*
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
*
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
* EU, LV-1021.
*
* The interactive user interfaces in modified source and object code versions
* of the Program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU AGPL version 3.
*
* Pursuant to Section 7(b) of the License you must retain the original Product
* logo when distributing the program. Pursuant to Section 7(e) we decline to
* grant you any rights under trademark law for use of our trademarks.
*
* All the Product's GUI elements, including illustrations and icon sets, as
* well as technical writing content are licensed under the terms of the
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
*
*/
var sockjs = require("sockjs"),
nodehun = require("nodehun"),
config = require("./config.json"),
logger = require("./../../Common/sources/logger");
var arrDictionaries = {};
(function () {
var arrDictionariesConfig = config["dictionaries"];
var oDictTmp = null,
pathTmp = "",
oDictName = null;
for (var indexDict = 0, lengthDict = arrDictionariesConfig.length; indexDict < lengthDict; ++indexDict) {
oDictTmp = arrDictionariesConfig[indexDict];
oDictName = oDictTmp.name;
pathTmp = __dirname + "/../Dictionaries/" + oDictName + "/" + oDictName + ".";
arrDictionaries[oDictTmp.id] = new nodehun.Dictionary(pathTmp + "aff", pathTmp + "dic");
}
})();
exports.install = function (server, callbackFunction) {
var sockjs_opts = {
sockjs_url: "./../../Common/sources/sockjs-0.3.min.js"
},
sockjs_echo = sockjs.createServer(sockjs_opts),
dataHandler;
sockjs_echo.on("connection", function (conn) {
if (null == conn) {
logger.error("null == conn");
return;
}
conn.on("data", function (message) {
try {
var data = JSON.parse(message);
dataHandler[data.type](conn, data);
} catch(e) {
logger.error("error receiving response:" + e);
}
});
conn.on("error", function () {
logger.error("On error");
});
conn.on("close", function () {
logger.info("Connection closed or timed out");
});
});
function sendData(conn, data) {
conn.write(JSON.stringify(data));
}
dataHandler = (function () {
function spellCheck(conn, data) {
function checkEnd() {
if (0 === data.usrWordsLength) {
sendData(conn, {
type: "spellCheck",
spellCheckData: JSON.stringify(data)
});
}
}
function spellSuggest(index, word, lang) {
var oDictionary = arrDictionaries[lang];
if (undefined === oDictionary) {
data.usrCorrect[index] = false;
--data.usrWordsLength;
checkEnd();
} else {
if ("spell" === data.type) {
oDictionary.spellSuggest(word, function (a, b) {
data.usrCorrect[index] = a;
--data.usrWordsLength;
checkEnd();
});
} else {
if ("suggest" === data.type) {
oDictionary.spellSuggestions(word, function (a, b) {
data.usrSuggest[index] = b;
--data.usrWordsLength;
checkEnd();
});
}
}
}
}
data = JSON.parse(data.spellCheckData);
data.usrCorrect = [];
data.usrSuggest = [];
data.usrWordsLength = data.usrWords.length;
for (var i = 0, length = data.usrWords.length; i < length; ++i) {
spellSuggest(i, data.usrWords[i], data.usrLang[i]);
}
}
return {
spellCheck: spellCheck
};
} ());
sockjs_echo.installHandlers(server, {
prefix: "/doc/[0-9-.a-zA-Z_=]*/c",
log: function (severity, message) {
logger.info(message);
}
});
callbackFunction();
};