Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
Conflicts:
	README.md
  • Loading branch information
brrd committed Mar 11, 2016
2 parents 1a0a0b7 + deac740 commit 82fd7e1
Show file tree
Hide file tree
Showing 34 changed files with 147,796 additions and 70,114 deletions.
3 changes: 2 additions & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
},
"browser": true,
"node": true,
"jquery": true
"jquery": true,
"eqnull": true
}
91 changes: 7 additions & 84 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
![Screenshot](screenshot.jpg)

In **Abricotine**, you can preview your document directly in the text editor rather than in a side pane.
In **Abricotine**, you can preview your document directly in the text editor rather than in a side pane.

![Another screenshot](screenshot2.jpg)

Expand All @@ -15,98 +15,21 @@ In **Abricotine**, you can preview your document directly in the text editor rat
* Write in markdown (or GFM) and export your documents in HTML,
* Preview text elements (such as headers, images, math, embedded videos, todo lists...) while you type,
* Display document table of content in the side pane,
* Display syntax highlighting for supported languages (HTML, XML, CSS, Javascript, and more to come...),
* Display syntax highlighting for code,
* Show helpers, anchors and hidden characters,
* Copy formatted HTML in the clipboard,
* Write in a distraction-free fullscreen view,
* Manage and beautify markdown tables,
* Search and replace text,
* And more features to come...

Abricotine is still in beta development. If you find a bug please report it [in the dedicated bug tracker](https://github.com/brrd/Abricotine/issues).
Abricotine is still in beta development. If you find a bug please report it [in the dedicated bug tracker](https://github.com/brrd/Abricotine/issues).

## Installation and usage
## Documentation

Abricotine is working on Windows (7 and later), Linux and OSX.

### Installation from binaries

For Windows and Linux users, the following installation method is recommended:

1. Download prebuilt binaries from the [Releases page](https://github.com/brrd/Abricotine/releases),
2. Extract the archive,
3. Run `Abricotine.exe` (on Windows) or `Abricotine` (on Linux).

Installers are not released yet.

For OS X users, you must have [Homebrew](http://brew.sh) and [Hombrew Cask](http://caskroom.io) installed. The run:

```
brew cask install abricotine
```

### Building and packaging

#### Requirements

* [Node.js](https://nodejs.org/en/) and `npm`,
* Make sure you meet [node-gyp](https://github.com/nodejs/node-gyp) requirements (specific to your platform and architecture),
* `git` (for Bower installation).

#### Building

1. Install requirements,
2. Download [the latest Abricotine release source](https://github.com/brrd/Abricotine/releases) and extract the archive,
3. Run `$ npm install` in the extracted folder.
4. You can use Abricotine by running `$npm start` from its directory. To open a specific file, run `$npm start -- [path-to-file]`.

#### Packaging

Run `$ npm run packager` from the built project directory and select your platform and architecture.

Packages are created in the `dist` directory.

## Configuration

You can open and edit Abricotine `JSON` configuration file by clicking "Edit preferences" in the "Edit" menu.

Most of the configuration entries are already handled by menus so you do not need to edit a file for changing them. However there is no menu for editing the following options:

### `autopreview-security`

If set to `true`, only iframes loaded from domains listed in `autopreview-domains` will be previewed.

Default is `true`.

### `autopreview-domains`

Contains the list of domains considered as safe when previewing iframes (see `autopreview-security`).

Default:

```
"autopreview-domains": [
"dailymotion.com",
"deezer.com",
"dribbble.com",
"facebook.com",
"github.com",
"google.com",
"instagram.com",
"pinterest.com",
"soundcloud.com",
"spotify.com",
"twitter.com",
"vimeo.com",
"youtube.com"
]
```

## Adding spell checker dictionaries

Abricotine uses [hunspell](http://hunspell.sourceforge.net/) dictionaries for Linux and Windows 7. If you want to add dictionaries, simply drop the dictionary folder in the `dict` subdirectory of Abricotine configuration folder.

Otherwise Abricotine uses the OS builtIn dictionaries when supported.
* [Installation and usage](https://github.com/brrd/Abricotine/tree/master/docs/installation-and-usage.md)
* [Configuration](https://github.com/brrd/Abricotine/tree/master/docs/configuration.md)
* [Templates](https://github.com/brrd/Abricotine/tree/master/docs/templates.md)

## Contributing

Expand Down
36 changes: 35 additions & 1 deletion app/abr-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
var BrowserWindow = require("browser-window"),
constants = require.main.require("./constants"),
files = require.main.require("./files"),
fs = require("fs"),
langmap = require("langmap"),
Menu = require("menu"),
pathModule = require("path"),
Expand Down Expand Up @@ -47,6 +48,9 @@ function preprocessTemplate (element, config) {
if (item.id === "spelling") {
item.submenu = spellingMenuGenerator(item.submenu, config);
}
if (item.id === "exportHtml") {
item.submenu = exportHtmlMenuGenerator(item.submenu, config);
}
preprocessTemplate(item.submenu, config);
}
return item;
Expand Down Expand Up @@ -82,7 +86,7 @@ function spellingMenuGenerator (submenu, config) {
};
}
// Get hunspell dictionaries path
// Search 1) the abricotine builtin hunspell dict, 2) then the dict dir in abricotine config folder
// Search the dict dir in abricotine config folder
// Returns an object { "en_US": "path/to/en_US", etc. }
function getHunspellDictionaries () {
var dicts = {},
Expand Down Expand Up @@ -122,6 +126,36 @@ function spellingMenuGenerator (submenu, config) {
return submenu;
}

// Generate export Html menu template (before preprocesssing)
function exportHtmlMenuGenerator (submenu, config) {
// Get a template menu item
function getTemplateMenu (tplName) {
var tplPath = pathModule.join(constants.path.templatesDir, tplName),
tplInfos = (function (tplPath) {
var jsonPath = pathModule.join(tplPath, "/template.json");
try {
var str = fs.readFileSync(jsonPath, "utf-8"); // TODO: async
return JSON.parse(str);
} catch (err) {
return {};
}
})(tplPath);
var menuItem = {
label: tplInfos.label || tplInfos.name || tplName,
command: "exportHtml",
accelerator: tplInfos.accelerator,
parameters: tplName
};
return menuItem;
}
// Walk in template dir and find templates
var subdirs = files.getDirectories(constants.path.templatesDir);
for (var i in subdirs) {
submenu.push(getTemplateMenu(subdirs[i]));
}
return submenu;
}

// Electron's menu wrapper
function AbrMenu (abrWin, menuTemplate, config) {
this.abrWin = abrWin;
Expand Down
6 changes: 3 additions & 3 deletions app/abr-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ function alreadyOpen (abrApp, path) {
function createConfig () {
var config = new nconf.Provider(); // https://github.com/indexzero/nconf/issues/39
config.overrides({})
.argv()
.file(constants.path.userConfig)
.defaults(defaultConfig);
.file(constants.path.userConfig)
.defaults(defaultConfig);
if (process.argv.indexOf("--debug") !== -1) config.set("debug", true);
return config;
}

Expand Down
1 change: 1 addition & 0 deletions app/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
49 changes: 0 additions & 49 deletions app/create.js

This file was deleted.

107 changes: 107 additions & 0 deletions app/creator.js
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;
10 changes: 8 additions & 2 deletions app/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ var fs = require("fs"),
ncp = require("ncp"),
parsePath = require("parse-filepath"),
path = require("path"),
request = require("request");
request = require("request"),
rimraf = require("rimraf");

var files = {

Expand Down Expand Up @@ -96,6 +97,11 @@ var files = {
return destDir;
},

// rm -rf wrapper
deleteDir: function (target, callback) {
rimraf(target, fs, callback);
},

dirExists: function (dirPath) {
try {
return fs.statSync(dirPath).isDirectory();
Expand Down Expand Up @@ -142,7 +148,7 @@ var files = {
fs.readFile(path, 'utf8', function (err, data) {
if (err) {
console.error(err);
return false;
callback(null);
} else if (typeof callback === 'function') {
callback(data, path);
}
Expand Down
Loading

0 comments on commit 82fd7e1

Please sign in to comment.