Skip to content

Commit

Permalink
Merge pull request #26 from ww24/develop
Browse files Browse the repository at this point in the history
Add config file for theme selecting
  • Loading branch information
ww24 committed Dec 26, 2014
2 parents 6b5232a + 0ab383a commit 253a474
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 50 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ How to build
1. `npm start`
1. open `example/index.html`

Config
------
`config/default.yml`

For example it can change the theme.

Test
----
1. install PhantomJS and Firefox
Expand Down
56 changes: 43 additions & 13 deletions build/deps/ace.min.js

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions build/deps/mace-core.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@

/*!
* Mace 0.1.2
* copyright: Takenori Nakagawa
* license: MIT
* Mace 0.1.3
* https://github.com/ww24/mace
*
* Copyright (c) 2014 Takenori Nakagawa
* Licensed under the MIT license.
*/

(function() {
"use strict";
var Mace;
var Mace, ace_theme;

ace_theme = "monokai";

Mace = (function() {
function Mace(editor, preview, options) {
Expand All @@ -23,7 +27,7 @@
};
this.ace = ace.edit(this.editor);
this.ace.getSession().setMode("ace/mode/markdown");
this.ace.setTheme("ace/theme/monokai");
this.ace.setTheme("ace/theme/" + ace_theme);
marked.setOptions({
renderer: new marked.Renderer(),
gfm: true,
Expand Down
10 changes: 6 additions & 4 deletions build/deps/mace-core.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 49 additions & 17 deletions build/mace.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions config/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ace:
theme: monokai
20 changes: 14 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@
* Gulp build script
*/

var gulp = require("gulp"),
plug = require("gulp-load-plugins")(),
del = require("del"),
config = require("config");

var ace_deps = [
"ace.js",
"mode-markdown.js",
"theme-monokai.js"
"mode-markdown.js"
];

var gulp = require("gulp"),
plug = require("gulp-load-plugins")(),
del = require("del");
// set ace theme
ace_deps.push("theme-" + config.ace.theme + ".js");

ace_deps = ace_deps.map(function (file) {
return "ace/build/src-min-noconflict/" + file;
return "ace/build/src-noconflict/" + file;
});

gulp.task("clean", function (done) {
Expand All @@ -22,6 +25,7 @@ gulp.task("clean", function (done) {

gulp.task("mace", function () {
return gulp.src("src/*.coffee")
.pipe(plug.replace("((\"monokai\"))", "\"" + config.ace.theme + "\""))
.pipe(plug.coffee())
.pipe(plug.concat("mace-core.js"))
.pipe(gulp.dest("build/deps"))
Expand All @@ -33,6 +37,10 @@ gulp.task("mace", function () {
gulp.task("ace", function () {
return gulp.src(ace_deps)
.pipe(plug.insert.append(";"))
.pipe(plug.uglify({preserveComments: function (node, comment) {
// check license comment
return !!~ comment.value.indexOf("license");
}}))
.pipe(plug.concat("ace.min.js"))
.pipe(gulp.dest("build/deps"));
});
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mace",
"version": "0.1.2",
"version": "0.1.3",
"description": "Mace = Markdown editor powered by Ace.",
"main": "gulpfile.js",
"scripts": {
Expand All @@ -22,15 +22,18 @@
"homepage": "http://ww24.info/mace",
"devDependencies": {
"chai": "^1.9.2",
"config": "^1.9.0",
"coveralls": "^2.11.2",
"del": "^0.1.3",
"gulp": "^3.8.8",
"gulp-coffee": "^2.2.0",
"gulp-concat": "^2.4.1",
"gulp-insert": "^0.4.0",
"gulp-load-plugins": "^0.7.0",
"gulp-replace": "^0.5.0",
"gulp-uglify": "^1.0.1",
"istanbul": "^0.3.2",
"js-yaml": "^3.2.4",
"karma": "^0.12.24",
"karma-coverage": "^0.2.6",
"karma-mocha": "^0.1.9",
Expand Down
12 changes: 8 additions & 4 deletions src/mace.coffee
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
###!
# Mace 0.1.2
# copyright: Takenori Nakagawa
# license: MIT
# Mace 0.1.3
# https://github.com/ww24/mace
#
# Copyright (c) 2014 Takenori Nakagawa
# Licensed under the MIT license.
###

"use strict"

ace_theme = (("monokai"))

## new mace(DOMElement editor, DOMElement preview[, options])
class Mace
constructor: (@editor, @preview = null, options = {}) ->
Expand All @@ -18,7 +22,7 @@ class Mace
## ace settings
@ace = ace.edit @editor
@ace.getSession().setMode "ace/mode/markdown"
@ace.setTheme "ace/theme/monokai"
@ace.setTheme "ace/theme/#{ace_theme}"

## marked settings
marked.setOptions
Expand Down

0 comments on commit 253a474

Please sign in to comment.