mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-14 07:00:53 +00:00
plugins 异步加载模块
This commit is contained in:
4
node_modules/resanitize/resanitize.js
generated
vendored
4
node_modules/resanitize/resanitize.js
generated
vendored
@@ -195,13 +195,13 @@ function stripUnsafeAttrs (str) {
|
||||
}
|
||||
module.exports.stripUnsafeAttrs = stripUnsafeAttrs;
|
||||
|
||||
function stripUnsafeTags (str) {
|
||||
function stripUnsafeTags (str, tags) {
|
||||
|
||||
// var el = /<(?:wbr|form|input|font|blink|script|style|comment|plaintext|xmp|link|listing|meta|body|frame|frameset)\b/;
|
||||
var ct = 0, max = 2;
|
||||
|
||||
// Prohibited elements
|
||||
var otherTags = ['wbr','style', 'comment', 'plaintext', 'xmp', 'listing',
|
||||
var otherTags = tags || ['wbr','style', 'comment', 'plaintext', 'xmp', 'listing',
|
||||
// 以下是evernote禁止的
|
||||
'applet','base','basefont','bgsound','blink','body','button','dir','embed','fieldset','frameset','head',
|
||||
'html','iframe','ilayer','input','isindex','label','layer','legend','link','marquee','menu','meta','noframes',
|
||||
|
@@ -19,9 +19,8 @@ Before submitting HTML content over the EDAM API the client application is expec
|
||||
|
||||
*/
|
||||
define(function() {
|
||||
var async = require('async');
|
||||
|
||||
var enml = nodeRequire('./public/plugins/export_evernote/enml');
|
||||
var async; // = require('async');
|
||||
var enml; // = nodeRequire('./public/plugins/export_evernote/enml');
|
||||
|
||||
//==============
|
||||
// tpls
|
||||
@@ -93,6 +92,12 @@ define(function() {
|
||||
_inited: false,
|
||||
init: function() {
|
||||
var me = this;
|
||||
if (me._inited) {
|
||||
return;
|
||||
}
|
||||
async = require('async');
|
||||
enml= nodeRequire('./public/plugins/export_evernote/enml');
|
||||
|
||||
me._inited = true;
|
||||
},
|
||||
|
||||
@@ -547,6 +552,7 @@ define(function() {
|
||||
},
|
||||
click: (function() {
|
||||
return function(noteIds) {
|
||||
me.init();
|
||||
me.exportEvernote(noteIds);
|
||||
}
|
||||
})()
|
||||
@@ -560,6 +566,7 @@ define(function() {
|
||||
},
|
||||
click: (function() {
|
||||
return function(notebookId) {
|
||||
me.init();
|
||||
me.exportEvernoteForNotebook(notebookId);
|
||||
}
|
||||
})()
|
||||
|
@@ -5,7 +5,7 @@
|
||||
* 注意, fs.existsSync总返回false, readFileSync可用
|
||||
*/
|
||||
define(function() {
|
||||
var async = require('async');
|
||||
var async; // = require('async');
|
||||
|
||||
var exportHTML = {
|
||||
langs: {
|
||||
@@ -36,6 +36,10 @@ define(function() {
|
||||
_inited: false,
|
||||
init: function() {
|
||||
var me = this;
|
||||
if (me._inited) {
|
||||
return;
|
||||
}
|
||||
async = require('async');
|
||||
me._inited = true;
|
||||
},
|
||||
|
||||
@@ -342,6 +346,7 @@ define(function() {
|
||||
},
|
||||
click: (function() {
|
||||
return function(noteIds) {
|
||||
me.init();
|
||||
me.exportHTML(noteIds);
|
||||
}
|
||||
})()
|
||||
@@ -355,6 +360,7 @@ define(function() {
|
||||
},
|
||||
click: (function() {
|
||||
return function(notebookId) {
|
||||
me.init();
|
||||
me.exportHTMLForNotebook(notebookId);
|
||||
}
|
||||
})()
|
||||
|
@@ -27,7 +27,8 @@
|
||||
*
|
||||
*/
|
||||
define(function() {
|
||||
var async = require('async');
|
||||
var async; // = require('async');
|
||||
var resanitize; // = require('resanitize');
|
||||
|
||||
//===========
|
||||
// start
|
||||
@@ -61,6 +62,13 @@ define(function() {
|
||||
_inited: false,
|
||||
init: function() {
|
||||
var me = this;
|
||||
if (me._inited) {
|
||||
return;
|
||||
}
|
||||
|
||||
async = require('async');
|
||||
resanitize = require('resanitize');
|
||||
|
||||
me._inited = true;
|
||||
},
|
||||
|
||||
@@ -89,6 +97,21 @@ define(function() {
|
||||
return filename;
|
||||
},
|
||||
|
||||
fixContent: function (content) {
|
||||
// srip unsage attrs
|
||||
var unsafeAttrs = ['id', , /on\w+/i, /data-\w+/i, 'clear', 'target'];
|
||||
content = content.replace(/<([^ >]+?) [^>]*?>/g, resanitize.filterTag(resanitize.stripAttrs(unsafeAttrs)));
|
||||
|
||||
// strip unsafe tags
|
||||
content = resanitize.stripUnsafeTags(content,
|
||||
['wbr','style', 'comment', 'plaintext', 'xmp', 'listing',
|
||||
'applet','base','basefont','bgsound','blink','body','button','dir','embed','fieldset','frameset','head',
|
||||
'html','iframe','ilayer','input','isindex','label','layer','legend','link','marquee','menu','meta','noframes',
|
||||
'noscript','object','optgroup','option','param','plaintext','script','select','style','textarea','xml']
|
||||
);
|
||||
return content;
|
||||
},
|
||||
|
||||
getLeanoteTime: function(t) {
|
||||
// 20151026T033928Z
|
||||
// 2015 10 26 T 03 39 28 Z
|
||||
@@ -121,7 +144,7 @@ define(function() {
|
||||
|
||||
var noteInfo = {
|
||||
title: note.Title,
|
||||
content: content,
|
||||
content: me.fixContent(content),
|
||||
tags: note.Tags,
|
||||
author: Api.userService.email || Api.userService.username || '',
|
||||
isMarkdown: note.IsMarkdown,
|
||||
@@ -537,6 +560,7 @@ define(function() {
|
||||
},
|
||||
click: (function() {
|
||||
return function(noteIds) {
|
||||
me.init();
|
||||
me.exportLeanote(noteIds);
|
||||
}
|
||||
})()
|
||||
@@ -550,6 +574,7 @@ define(function() {
|
||||
},
|
||||
click: (function() {
|
||||
return function(notebookId) {
|
||||
me.init();
|
||||
me.exportLeanoteForNotebook(notebookId);
|
||||
}
|
||||
})()
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* @date 2015/04/09
|
||||
*/
|
||||
define(function() {
|
||||
var importService = nodeRequire('./public/plugins/import_evernote/import');
|
||||
var importService; // = nodeRequire('./public/plugins/import_evernote/import');
|
||||
|
||||
var evernote = {
|
||||
|
||||
@@ -57,12 +57,6 @@ define(function() {
|
||||
<div class="modal-body" id="">
|
||||
<div role="tabpanel">
|
||||
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li role="presentation" class="active"><a href="#evernoteTab" aria-controls="evernoteTab" role="tab" data-toggle="tab">Evernote</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
<div role="tabpanel" class="tab-pane active" id="evernoteTab">
|
||||
@@ -132,6 +126,9 @@ define(function() {
|
||||
var n = 0;
|
||||
|
||||
me.clear();
|
||||
if (!importService) {
|
||||
importService = nodeRequire('./public/plugins/import_evernote/import');
|
||||
}
|
||||
|
||||
importService.importFromEvernote(notebookId, paths,
|
||||
// 全局
|
||||
|
@@ -6,6 +6,7 @@ var Web = require('web');
|
||||
var Tag = require('tag');
|
||||
var async = require('async');
|
||||
var Common = require('common');
|
||||
var resanitize = require('resanitize');
|
||||
|
||||
var Import = {
|
||||
// 解析Leanote
|
||||
@@ -210,6 +211,21 @@ var Import = {
|
||||
note.content = content;
|
||||
},
|
||||
|
||||
fixContent: function (content) {
|
||||
// srip unsage attrs
|
||||
var unsafeAttrs = ['id', , /on\w+/i, /data-\w+/i, 'clear', 'target'];
|
||||
content = content.replace(/<([^ >]+?) [^>]*?>/g, resanitize.filterTag(resanitize.stripAttrs(unsafeAttrs)));
|
||||
|
||||
// strip unsafe tags
|
||||
content = resanitize.stripUnsafeTags(content,
|
||||
['wbr','style', 'comment', 'plaintext', 'xmp', 'listing',
|
||||
'applet','base','basefont','bgsound','blink','body','button','dir','embed','fieldset','frameset','head',
|
||||
'html','iframe','ilayer','input','isindex','label','layer','legend','link','marquee','menu','meta','noframes',
|
||||
'noscript','object','optgroup','option','param','plaintext','script','select','style','textarea','xml']
|
||||
);
|
||||
return content;
|
||||
},
|
||||
|
||||
// 解析笔记
|
||||
parseNote: function (notebookId, note, callback) {
|
||||
var me = this;
|
||||
@@ -242,7 +258,7 @@ var Import = {
|
||||
// 添加到数据库中
|
||||
var jsonNote = {
|
||||
Title: note.title,
|
||||
Content: note.content,
|
||||
Content: me.fixContent(note.content),
|
||||
Tags: note.tags || [],
|
||||
CreatedTime: me.parseLeanoteTime(note.createdTime),
|
||||
UpdatedTime: me.parseLeanoteTime(note.updatedTime),
|
||||
|
@@ -4,7 +4,7 @@
|
||||
* @date 2015/04/09
|
||||
*/
|
||||
define(function() {
|
||||
var importService = nodeRequire('./public/plugins/import_leanote/import');
|
||||
var importService; // = nodeRequire('./public/plugins/import_leanote/import');
|
||||
|
||||
var leanote = {
|
||||
|
||||
@@ -57,12 +57,6 @@ define(function() {
|
||||
<div class="modal-body" id="">
|
||||
<div role="tabpanel">
|
||||
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li role="presentation" class="active"><a href="#leanoteTab" aria-controls="leanoteTab" role="tab" data-toggle="tab">Leanote</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
<!-- Tab panes -->
|
||||
<div class="tab-content">
|
||||
<div role="tabpanel" class="tab-pane active" id="leanoteTab">
|
||||
@@ -133,6 +127,10 @@ define(function() {
|
||||
|
||||
me.clear();
|
||||
|
||||
if (!importService) {
|
||||
importService = nodeRequire('./public/plugins/import_leanote/import');
|
||||
}
|
||||
|
||||
importService.importFromLeanote(notebookId, paths,
|
||||
// 全局
|
||||
function(ok) {
|
||||
|
8
tests/testNeedle.js
Normal file
8
tests/testNeedle.js
Normal file
@@ -0,0 +1,8 @@
|
||||
var needle = require('needle');
|
||||
var url = 'http://i7.baidu.com/it/u=401605395,2928249378&fm=96&s=5DAEA85217785B88557C00640300B062';
|
||||
url = 'http://i7.baidu.com/it/u=401605395,2928249378&fm=96&s=5DAEA85217785B88557C00640300B062';
|
||||
// url = 'http://leanote.com/images/logo.png';
|
||||
needle.get(url, function(err, resp) {
|
||||
console.log(resp.statusCode);
|
||||
console.log(typeof resp.body);
|
||||
});
|
Reference in New Issue
Block a user