Jelajahi Sumber

1.update ReadMe.md && Screenshots
2.add lose file
3.add error catch

zhuzhuyule 8 tahun lalu
induk
melakukan
18dfceb545

+ 57 - 24
README.md

@@ -1,33 +1,54 @@
-# If you are a developer, please read [The future of HexoEditor](https://github.com/Moeditor/Moeditor/issues/153)
-# If you are a developer, please read [The future of Moeditor](https://github.com/Moeditor/Moeditor/issues/153)
 
-# Moeditor
-Your all-purpose markdown editor.
+# HexoEditor
+This is markdown editor for Hexo.
 
 Built with Electron.
 
-Visit our [homepage](https://moeditor.org/) or download [releases](https://github.com/Moeditor/Moeditor/releases).
+Inherit [Moeditor](https://github.com/Moeditor/Moeditor), I want to fix it appropriate to Hexo Blog!
 
 # Features
-* GitHub Flavored Markdown
-* TeX math expressions
-* UML diagrams
-* Code highlight in editor
-* Read/Write/Preview mode
-* Custom font / line height / font size
-* Code highlight themes (powered by [highlight.js](https://highlightjs.org/))
-* Auto reload
-* Localization
-* Focus mode
+* HexoEditor 
+  * Hexo Post Preview same as in Browser
+  * Hexo Tag/Filter/Renderer support
+  * Custom tag support
+  * Use Hexo `_config.yml` support
+    * highlight setting
+    * theme tag support
+* HexoEditor (Inherit [Moeditor](https://github.com/Moeditor/Moeditor))
+  * GitHub Flavored Markdown
+  * TeX math expressions
+  * UML diagrams
+  * Code highlight in editor
+  * Read/Write/Preview mode
+  * Custom font / line height / font size
+  * Custom themes
+  * Code highlight themes (powered by [highlight.js](https://highlightjs.org/))
+  * Auto reload
+  * Localization
+  * Focus mode
 
 # Screenshots
+
 ![Moeditor Main](screenshots/main.png)
 
-![Moeditor Side Menu](screenshots/side-menu.png)
+![Moeditor Write Mode](screenshots/side-menu.png)
+
+![Moeditor Write Mode](screenshots/settings.png)
 
 ![Moeditor About](screenshots/about.png)
 
-![Moeditor Write Mode](screenshots/write-mode.png)
+# Gif Screenshots
+![Moeditor About](screenshots/gif-tag.gif)
+
+![Moeditor About](screenshots/gif-mode.gif)
+
+![Moeditor About](screenshots/gif-hexo.gif)
+# Plan To Do
+- [ ] Add Toc
+- [ ] Add Hexo Title Header setting
+.....
+- [ ] Deploy Post
+- [ ] Add multi-editing in tabs
 
 # Building
 ```bash
@@ -42,7 +63,6 @@ npm install cnpm -g --registry=https://registry.npm.taobao.org
 cnpm install
 cnpm start
 ```
-
 # Debugging
 There's three ways to open the [Chromium Developer Tools](https://developer.chrome.com/devtools).
 
@@ -55,10 +75,6 @@ npm start -- --debug
 
 * `Ctrl` + `Shift` + `I` in Linux / Windows or `Command` + `Option` + `I` in OS X / macOS to toggle devtools for a window.
 
-# Todo
-* [ ] Custom themes
-* [ ] Spell check
-* [ ] UI/UX
 
 # Localization
 Moeditor will auto detect your system language and use the localization.
@@ -79,5 +95,22 @@ The `Raleway` font is licensed under the OFL open font license.
 # Credits
 The domain `moeditor.org` is sponsored by [Showfom](https://ttt.tt/).
 
-# Known Bug(s)
-Issue #31.
+
+```
+Support Tag
+- {% cq - %}
+[HexoEditor](https://github.com/zhuzhuyule/HexoEditor)
+{% endcq %}
+
+- {% blockquote zhuzhuyule https://github.com/zhuzhuyule/HexoEditor HexoEditor %}
+This is markdown editor for Hexo.
+{% endblockquote %}
+
+- {% quotelist Reference %}
+Moeditorhttps://github.com/Moeditor/Moeditor
+{% endquotelist %}
+ 
+- {% exturl HexoEditor url "title" %}
+- {% btn https://github.com/zhuzhuyule/HexoEditor, HexoEditor, , HexoEditor Button %}
+- {% lb,HexoEditor %}
+```

+ 7 - 0
icons/HexoEditor.svg

@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Generator: Adobe Illustrator 17.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg version="1.1" id="main" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
+	 width="512px" height="512px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
+<path fill="#dcdcdc" d="M256.4 25.8L56.4 141.3L56 371.5L255.6 486.2L455.6 370.7L456 140.5L256.4 25.8ZM160 360L160 160L180.3333 149.3333L200 160L255 310L310 160L330.3333 149.3333L350 160L350 360.5L336 370.3333L320 360L320 210L270.3333 341L255 351L240 340.6667L190 210L190 360.5L175 370.6667L160 360Z" xmlns="http://www.w3.org/2000/svg" />
+</svg>

+ 16 - 8
package.json

@@ -11,7 +11,7 @@
   },
   "build": {
     "appId": "com.zhuzhuyule.hexoeditor",
-    "productName":"HexoEditor",
+    "productName": "HexoEditor",
     "asar": false,
     "nsis": {
       "artifactName": "${productName}-x64.${ext}",
@@ -31,7 +31,9 @@
       "target": [
         {
           "target": "nsis",
-          "arch": ["x64"]
+          "arch": [
+            "x64"
+          ]
         }
       ],
       "icon": "icons/HexoEditor.ico"
@@ -54,12 +56,19 @@
   "homepage": "https://github.com/zhuzhuyule/HexoEditor#readme",
   "dependencies": {
     "biu.js": "^1.2.0",
+    "bluebird": "^3.5.1",
     "cheerio": "^1.0.0-rc.2",
     "codemirror": "^5.18.2",
     "configstore": "^2.1.0",
     "electron-localshortcut": "^0.6.1",
+    "electron-titlebar": "0.0.2",
     "flowchart.js": "^1.6.3",
     "font-awesome": "^4.6.3",
+    "hexo-front-matter": "^0.2.3",
+    "hexo-fs": "^0.2.2",
+    "hexo-renderer-ejs": "^0.3.1",
+    "hexo-renderer-marked": "^0.3.0",
+    "hexo-renderer-stylus": "^0.3.3",
     "hexo-util": "^0.6.2",
     "highlight.js": "^9.6.0",
     "jquery": "^3.1.0",
@@ -72,16 +81,15 @@
     "mime": "^1.3.4",
     "moemark": "^0.3.8",
     "moment-timezone": "^0.5.14",
+    "nunjucks": "^3.0.1",
     "os-locale": "^1.4.0",
     "raphael": "^2.2.1",
-    "titlecase": "^1.1.2",
-    "bluebird": "^3.5.1",
-    "hexo-fs": "^0.2.2",
-    "nunjucks": "^3.0.1",
     "strip-indent": "^2.0.0",
+    "swig": "^1.4.2",
+    "swig-extras": "0.0.1",
+    "titlecase": "^1.1.2",
     "util": "^0.10.3",
-    "yamljs": "^0.3.0",
-    "electron-titlebar": "0.0.2"
+    "yamljs": "^0.3.0"
   },
   "devDependencies": {
     "electron": "^1.7.9"

TEMPAT SAMPAH
screenshots/about.png


TEMPAT SAMPAH
screenshots/gif-hexo.gif


TEMPAT SAMPAH
screenshots/gif-mode.gif


TEMPAT SAMPAH
screenshots/gif-tag.gif


TEMPAT SAMPAH
screenshots/main.png


TEMPAT SAMPAH
screenshots/settings.png


TEMPAT SAMPAH
screenshots/side-menu.png


TEMPAT SAMPAH
screenshots/write-mode.png


+ 2 - 2
views/about/moe-about.css

@@ -46,10 +46,10 @@ body {
     font-family: Raleway;
     font-size: 60px;
     font-weight: lighter;
-    letter-spacing: 13px;
+    letter-spacing: 15px;
     position: fixed;
     color: #666;
-    left: 195px;
+    left: 173px;
     top: 45px;
 }
 

+ 2 - 2
views/main/index.html

@@ -23,7 +23,7 @@
 <html>
     <head>
         <meta charset="UTF-8">
-        <title>Moeditor</title>
+        <title>HexoEditor</title>
         <base href="../href.html">
 
 		<script>
@@ -116,7 +116,7 @@
             <div class="drag" id="drag-right"></div>
         </div>
         <div id="side-menu">
-            <div id="logo">MOEDITOR</div>
+            <div id="logo">HexoEditor</div>
             <ul>
                 <li data-action="new" class="l10n">New</li>
                 <li data-action="open" class="l10n">Open</li>

+ 3 - 3
views/main/moe-style.css

@@ -33,7 +33,7 @@ html, body {
     height: 100%;
     background: #fafafa;
     transition: all 200ms ease-in-out;
-    padding-top: 45px;
+    padding-top: 20px;
     padding-bottom: 45px;
     cursor: default;
     z-index: 1;
@@ -45,11 +45,11 @@ html, body {
     font-family: Raleway;
     font-size: 35px;
     font-weight: lighter;
-    letter-spacing: 10px;
+    letter-spacing: 5px;
     text-align: center;
     color: #666;
     border-bottom: 1px solid #ececec;
-    padding-bottom: 30px;
+    padding-bottom: 15px;
 }
 
 #side-menu ul {

+ 60 - 0
views/main/unit/default_config.js

@@ -0,0 +1,60 @@
+'use strict';
+
+module.exports = {
+    // Site
+    title: 'Hexo',
+    subtitle: '',
+    description: '',
+    author: 'John Doe',
+    language: '',
+    timezone: '',
+    // URL
+    url: 'http://yoursite.com',
+    root: '/',
+    permalink: ':year/:month/:day/:title/',
+    permalink_defaults: {},
+    // Directory
+    __themedir: '',
+    source_dir: 'source',
+    public_dir: 'public',
+    tag_dir: 'tags',
+    archive_dir: 'archives',
+    category_dir: 'categories',
+    code_dir: 'downloads/code',
+    i18n_dir: ':lang',
+    skip_render: [],
+    // Writing
+    new_post_name: ':title.md',
+    default_layout: 'post',
+    titlecase: false,
+    external_link: true,
+    filename_case: 0,
+    render_drafts: false,
+    post_asset_folder: false,
+    relative_link: false,
+    future: true,
+    highlight: {
+        enable: true,
+        auto_detect: false,
+        line_number: true,
+        tab_replace: ''
+    },
+    // Category & Tag
+    default_category: 'uncategorized',
+    category_map: {},
+    tag_map: {},
+    // Date / Time format
+    date_format: 'YYYY-MM-DD',
+    time_format: 'HH:mm:ss',
+    // Pagination
+    per_page: 10,
+    pagination_dir: 'page',
+    // Extensions
+    theme: 'landscape',
+    // Deployment
+    deploy: {},
+
+    //ignore files from processing
+    ignore: []
+};
+

+ 27 - 9
views/main/unit/hexo.js

@@ -33,6 +33,9 @@ Hexo.prototype.init = function() {
     require('./plugins/helper')(this);
     require('./plugins/renderer')(this);
     require('./plugins/tag')(this);
+    require('hexo-renderer-ejs');
+    require('hexo-renderer-marked');
+    require('hexo-renderer-stylus');
 };
 
 Hexo.prototype.execFilter = function(type, data, options) {
@@ -44,14 +47,18 @@ Hexo.prototype.execFilterSync = function(type, data, options) {
 };
 
 Hexo.prototype.loadConfig = function () {
-    if (this.enable) {
-        let file = moeApp.config.get('hexo-config');
-        let customCfg = loadfile(file);
-        if (typeof customCfg === 'object')
-            this.config = lodash.extend(this.config, customCfg);
-    } else {
-        this.config = {};
-        this.config = $.extend({},defConfig);
+    try {
+        if (this.enable) {
+            let file = moeApp.config.get('hexo-config');
+            let customCfg = loadfile(file);
+            if (typeof customCfg === 'object')
+                this.config = lodash.extend(this.config, customCfg);
+        } else {
+            this.config = {};
+            this.config = $.extend({}, defConfig);
+        }
+    }catch (e){
+        console.log(e);
     }
 }
 
@@ -62,12 +69,23 @@ Hexo.prototype.loadTags = function () {
         paths = [];
     if (this.config.__themedir)
         paths = [path.join(this.config.__themedir,'scripts','tags')].concat(paths);
-    for(let i=0,len=paths.length; i<len;i++)
+    for(let i=0,len=paths.length; i<len;i++)  {
         loaddir(paths[i]);
+    }
 }
 
 Hexo.prototype.changeConfig = function () {
     hexo.enable = moeApp.config.get('hexo-config-enable');
+    // var sep = path.sep;
+    // this.base_dir = base + sep;
+    // this.public_dir = pathFn.join(base, 'public') + sep;
+    // this.source_dir = pathFn.join(base, 'source') + sep;
+    // this.plugin_dir = pathFn.join(base, 'node_modules') + sep;
+    // this.script_dir = pathFn.join(base, 'scripts') + sep;
+    // this.scaffold_dir = pathFn.join(base, 'scaffolds') + sep;
+    // this.theme_dir = pathFn.join(base, 'themes', defaultConfig.theme) + sep;
+    // this.theme_script_dir = pathFn.join(this.theme_dir, 'scripts') + sep;
+
     // Load Hexo config
     this.loadConfig();
     // Load tags file

+ 27 - 0
views/main/unit/load_dir.js

@@ -0,0 +1,27 @@
+var fs = require('fs');
+var path = require('path');
+
+var load = function(path, name) {
+    if (name) {
+        delete require.cache[require.resolve(path + name)]
+        return require(path + name);
+    }
+    delete require.cache[require.resolve(path)]
+    return require(path)
+};
+
+module.exports = function (dir) {
+    try{
+        dir = dir.toString().replace(/\\+/g, '\\\\');
+        fs.readdirSync(dir).forEach(function (filename) {
+            if (!/\.js$/.test(filename)) {
+                return;
+            }
+            var name = path.basename(filename, '.js');
+            load(path.join(dir,name));
+        });
+    } catch(e) {
+        console.log(dir,e)
+    }
+
+}

+ 26 - 0
views/main/unit/loadconfig.js

@@ -0,0 +1,26 @@
+var fs = require('hexo-fs');
+var YAML = require('yamljs');
+var path = require('path');
+var loadsh = require('lodash');
+var defConfig = require('./default_config');
+
+function loadYAMLFile(file) {
+    if (!file) return loadsh.extend({}, defConfig);
+    file = file.toString().replace(/\\+/g, '\\\\');
+    var configPath = file;
+    if (fs.statSync(file).isDirectory()) {
+        configPath = (path.join(file, '_config.yml'));
+    }
+    var baseDir = path.dirname(configPath);
+    var config = fs.existsSync(configPath) ? YAML.parse(fs.readFileSync(configPath).toString()) : {};
+    var themeConfig = {};
+    if (config.theme) {
+        defConfig.__themedir = path.join( baseDir,'themes',config.theme);
+        configPath = path.join( defConfig.__themedir,'_config.yml');
+        themeConfig = fs.existsSync(configPath) ? YAML.parse(fs.readFileSync(configPath).toString()) : {};
+    }
+    return loadsh.extend({}, defConfig, config, themeConfig);
+}
+
+
+module.exports = loadYAMLFile;

+ 5 - 0
views/main/unit/plugins/renderer/index.js

@@ -12,5 +12,10 @@ module.exports = function(ctx) {
 
   renderer.register('json', 'json', require('./json'), true);
 
+  renderer.register('swig', 'html', require('./swig'), true);
 
+  var yaml = require('./yaml');
+
+  renderer.register('yml', 'json', yaml, true);
+  renderer.register('yaml', 'json', yaml, true);
 };

+ 47 - 0
views/main/unit/plugins/renderer/swig.js

@@ -0,0 +1,47 @@
+'use strict';
+
+var swig = require('swig');
+var extras = require('swig-extras');
+var forTag = require('swig/lib/tags/for');
+
+extras.useTag(swig, 'markdown');
+extras.useTag(swig, 'switch');
+extras.useTag(swig, 'case');
+
+extras.useFilter(swig, 'batch');
+extras.useFilter(swig, 'groupby');
+extras.useFilter(swig, 'markdown');
+extras.useFilter(swig, 'nl2br');
+extras.useFilter(swig, 'pluck');
+extras.useFilter(swig, 'split');
+extras.useFilter(swig, 'trim');
+extras.useFilter(swig, 'truncate');
+
+swig.setDefaults({
+  cache: false,
+  autoescape: false
+});
+
+// Hack: Override for tag of Swig
+swig.setTag('for', forTag.parse, function(compiler, args, content, parents, options, blockName) {
+  var compile = forTag.compile.apply(this, arguments).split('\n');
+
+  compile.splice(3, 0, '  if (!Array.isArray(__l) && typeof __l.toArray === "function") { __l = __l.toArray(); }');
+
+  return compile.join('\n');
+}, forTag.ends, true);
+
+function swigRenderer(data, locals) {
+  return swig.render(data.text, {
+    locals: locals,
+    filename: data.path
+  });
+}
+
+swigRenderer.compile = function(data, locals) {
+  return swig.compile(data.text, {
+    filename: data.path
+  });
+};
+
+module.exports = swigRenderer;

+ 10 - 0
views/main/unit/plugins/renderer/yaml.js

@@ -0,0 +1,10 @@
+'use strict';
+
+var yaml = require('yamljs');
+var escapeYAML = require('hexo-front-matter').escape;
+
+function yamlHelper(data) {
+  return yaml.load(escapeYAML(data.text));
+}
+
+module.exports = yamlHelper;