Skip to content

Commit

Permalink
Updating some things to support a newer version of MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoe Snow committed Jul 17, 2017
1 parent 5f3091b commit 7c6feda
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

process.env.NODE_ENV = "mamp";
process.env.NODE_ENV = "development";

var express = require('express');
var path = require('path');
Expand Down
45 changes: 28 additions & 17 deletions eanaEltuMigration/dictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ Dictionary.prototype.exportLanguages = function (){
}

return models.Language.bulkCreate(languages).then(function() {
models.Language.findAll().then(function (languages) {
return models.Language.findAll().then(function (languages) {
languages.forEach(function (language) {
self.languages[language.isoCode] = language;
});
Expand All @@ -174,7 +174,7 @@ Dictionary.prototype.exportSources = function(){
}

return models.Source.bulkCreate(sources).then(function() {
models.Source.findAll().then(function (sources) {
return models.Source.findAll().then(function (sources) {
sources.forEach(function (source) {
self.sources[source.name] = source;
});
Expand All @@ -188,22 +188,28 @@ Dictionary.prototype.exportDictionaryTemplates = function () {
var templates = [
{
id: "localized_end",
latex: "__END__"
latex: "__END__",
html: ""
}, {
id: "newpage",
latex: "\\newpage"
latex: "\\newpage",
html: ""
}, {
id: "end_hangparas_multicols",
latex: "\\end{hangparas}}\\end{multicols}"
latex: "\\end{hangparas}}\\end{multicols}",
html: ""
}, {
id: "end_hangparas",
latex: "\\end{hangparas}"
latex: "\\end{hangparas}",
html: ""
}, {
id: "end_document",
latex: "\\end{document}"
latex: "\\end{document}",
html: ""
}, {
id: "end_hangparas_multicols_newpage",
latex: "\\end{hangparas}}\\end{multicols}+\\newpage"
latex: "\\end{hangparas}}\\end{multicols}+\\newpage",
html: ""
}];

for(var id in self.eanaEltu.dictLayout){
Expand All @@ -216,7 +222,8 @@ Dictionary.prototype.exportDictionaryTemplates = function () {
}
templates.push({
id: layout.id.toLowerCase(),
latex: layout.value
latex: layout.value,
html: ""
});
}

Expand Down Expand Up @@ -457,6 +464,9 @@ Dictionary.prototype.exportEntryLayouts = function () {
metadata: template.metadata
});
} else {
if(template.format === undefined || template.format === null){
template.format = "<< BLANK >>";
}
localizedLayouts.push({
EntryTypeId: templateId,
LanguageIsoCode: lang,
Expand Down Expand Up @@ -602,7 +612,7 @@ Dictionary.prototype.export = function (callback) {
var secondLayerPromises = [];
secondLayerPromises.push(self.exportDictionaryBuilds());
secondLayerPromises.push(self.exportMetadata());
secondLayerPromises.push(self.exportPartsOfSpeech());
//secondLayerPromises.push(self.exportPartsOfSpeech());

Promise.all(secondLayerPromises).then(function(){

Expand Down Expand Up @@ -781,20 +791,21 @@ function buildDictionaryMetadata(self) {
};
var localization = self.eanaEltu.dictLoc[index];
for(var lc in localization){
if(localization[lc].value === ''){
if(localization[lc].value === '' || localization[lc].value === null || localization[lc].value === undefined){
if(self.debug){
console.log("Missing " + lc + " translation for [" + index + "]");
}
if(self.missingMetadataTranslations[lc.toLowerCase()] === undefined){
self.missingMetadataTranslations[lc.toLowerCase()] = [];
}
self.missingMetadataTranslations[lc.toLowerCase()].push(index);
} else {
self.metadata[index][lc.toLowerCase()] = {
value: localization[lc].value,
editTime: localization[lc].editTime
};
localization[lc] = {value: "<< NEEDS TRANSLATED >>"};
}

self.metadata[index][lc.toLowerCase()] = {
value: localization[lc].value,
editTime: localization[lc].editTime
};
}
}
}
Expand Down Expand Up @@ -1085,7 +1096,7 @@ function buildDictionaryTemplates(self) {

localizedFormat = localizedFormat.replace(result[0], metadata);

meta[lc].value = metadata === "" ? undefined : metadata;
meta[lc].value = metadata === "" ? "<< NEEDS TRANSLATED >>" : metadata;
}


Expand Down
4 changes: 2 additions & 2 deletions models/dictionaryTemplate.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
module.exports = function (sequelize, DataTypes) {
var DictionaryTemplate = sequelize.define('DictionaryTemplate', {
id: { type: DataTypes.STRING, primaryKey: true },
latex: { type: DataTypes.TEXT, allowNull: false, defaultValue: "" },
html: { type: DataTypes.TEXT, allowNull: false, defaultValue: "" },
latex: { type: DataTypes.TEXT, allowNull: false },
html: { type: DataTypes.TEXT, allowNull: false },
placeholders: { type: DataTypes.INTEGER, allowNull: false, defaultValue: 0 }
});

Expand Down
2 changes: 1 addition & 1 deletion models/localizedMetadata.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
module.exports = function (sequelize, DataTypes) {
var LocalizedMetadata = sequelize.define('LocalizedMetadata', {
value: { type: DataTypes.STRING, allowNull: false }
value: { type: DataTypes.TEXT, allowNull: false }
});

LocalizedMetadata.removeAttribute('id');
Expand Down
2 changes: 1 addition & 1 deletion models/localizedentry.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ var models = require('./index');

module.exports = function (sequelize, DataTypes) {
var LocalizedEntry = sequelize.define('LocalizedEntry', {
odd: DataTypes.STRING
odd: DataTypes.TEXT
});

LocalizedEntry.removeAttribute('id');
Expand Down
Binary file modified vault.js
Binary file not shown.

0 comments on commit 7c6feda

Please sign in to comment.