This repository has been archived by the owner on Aug 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: README.md
- Loading branch information
Showing
34 changed files
with
147,796 additions
and
70,114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,5 +8,6 @@ | |
}, | ||
"browser": true, | ||
"node": true, | ||
"jquery": true | ||
"jquery": true, | ||
"eqnull": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ module.exports = { | |
bigIcon: pathModule.join(appPath, "/icons/[email protected]"), | ||
defaultDir: isAsar ? appPath + ".unpacked/default" : appPath + "/default", | ||
dictionaries: pathModule.join(userDataPath, "/dict"), | ||
schema: pathModule.join(userDataPath, "/schema.json"), | ||
templatesDir: pathModule.join(userDataPath, "/templates"), | ||
tmp: tmpPath, | ||
tmpThemes: pathModule.join(tmpPath, "/themes"), | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* Abricotine - Markdown Editor | ||
* Copyright (c) 2015 Thomas Brouard | ||
* Licensed under GNU-GPLv3 <http://www.gnu.org/licenses/gpl.html> | ||
*/ | ||
|
||
var constants = require.main.require("./constants.js"), | ||
dialog = require("dialog"), | ||
files = require.main.require("./files.js"), | ||
pathModule = require("path"), | ||
pkg = require("../package.json"); | ||
|
||
var creator = {}; | ||
|
||
// Create configuration folders and copy default config files | ||
creator.create = function () { | ||
return new Promise (function (resolve, reject) { | ||
// 1. Create folders | ||
// Create the app folder if it doesn't already exist (sync) | ||
files.createDir(constants.path.userData); | ||
// Create the temp folder (sync) | ||
files.createDir(constants.path.tmp); | ||
resolve(); | ||
}).then(function () { | ||
// 2. Copy/create contents if not found | ||
return Promise.all([ | ||
new Promise (function (resolve, reject) { | ||
// Create a config file and schema.json | ||
if (!files.fileExists(constants.path.userConfig)) { | ||
// config.json | ||
files.copyFile(pathModule.join(constants.path.defaultDir, "/config.json"), constants.path.userConfig, function () { | ||
// Also see if schema.json exist | ||
if (!files.fileExists(constants.path.schema)) { | ||
var data = "{ \"schema\": " + pkg.abricotine.schema + " }"; | ||
files.writeFile(data, constants.path.schema, resolve); | ||
} | ||
}); | ||
} else { | ||
resolve(); | ||
} | ||
}), | ||
new Promise (function (resolve, reject) { | ||
// Copy default dicts | ||
if (!files.dirExists(constants.path.dictionaries)) { | ||
files.copyLocalDir(pathModule.join(constants.path.defaultDir, "/dict"), constants.path.dictionaries, resolve); | ||
} else { | ||
resolve(); | ||
} | ||
}), | ||
new Promise (function (resolve, reject) { | ||
// Copy default template | ||
if (!files.dirExists(constants.path.templatesDir)) { | ||
files.copyLocalDir(pathModule.join(constants.path.defaultDir, "/templates"), constants.path.templatesDir, resolve); | ||
} else { | ||
resolve(); | ||
} | ||
}) | ||
]); | ||
}); | ||
}; | ||
|
||
// Erase the whole configuration | ||
creator.erase = function () { | ||
return new Promise (function (resolve, reject) { | ||
files.deleteDir(constants.path.userData, function (err) { | ||
if (err) reject(err); | ||
else resolve(); | ||
}); | ||
}); | ||
}; | ||
|
||
// Reset: erase then create a new clear config | ||
creator.reset = function () { | ||
return creator.erase().then(creator.create); | ||
}; | ||
|
||
function askForReset (callback) { | ||
var userChoice = dialog.showMessageBox({ | ||
title: "Abricotine - Configuration update", | ||
message: "The current configuration is deprecated and need to be updated. Do you want to reset Abricotine configuration? \n\nWARNING: Your previous configuration (including custom templates and dictonaries) will be lost.", | ||
type: "question", | ||
buttons: ["No", "Yes (recommended)"], | ||
defaultId: 1 | ||
}); | ||
if (userChoice === 1) { | ||
creator.reset().then(callback); | ||
} else { | ||
callback(); | ||
} | ||
} | ||
|
||
// Check schema (should be removed once the app becomes stable) | ||
// Schema in package.json is increased on each breaking change in Abricotine (beta). When starting an updated version, the user will be ask to reset his configuration in order to avoid bugs. | ||
creator.check = function () { | ||
return new Promise (function (resolve, reject) { | ||
// Read schema | ||
files.readFile(constants.path.schema, function (data) { | ||
// Non-matching schema | ||
if (!data || JSON.parse(data).schema != pkg.abricotine.schema) { | ||
return askForReset(resolve); | ||
} | ||
resolve(); | ||
}); | ||
}); | ||
}; | ||
|
||
module.exports = creator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.