导入导出leanote的图片附件前缀为leanote://file/getX 去掉api

This commit is contained in:
life
2015-10-29 22:55:31 +08:00
parent 603e8b4f2c
commit 91bc298d94
2 changed files with 11 additions and 12 deletions

View File

@@ -10,7 +10,7 @@
notes: [
{
title: 'life',
content: 'laldfadf', // 图片, 附件链接为 leanote://api/file/getImage?fileId=xxxx, leanote://api/file/getAttach?fileId=3232323
content: 'laldfadf', // 图片, 附件链接为 leanote://file/getImage?fileId=xxxx, leanote://file/getAttach?fileId=3232323
tags: [1,2,3],
isMarkdown: true,
author: 'leanote', // 作者, 没用
@@ -298,21 +298,21 @@ define(function() {
if (note.IsMarkdown) {
var href;
if (!eachMatch.isAttach) {
href = 'leanote://api/file/getImage?fileId=' + eachMatch.fileId;
href = 'leanote://file/getImage?fileId=' + eachMatch.fileId;
link = '![' + eachMatch.title + '](' + href + ')';
}
else {
href = 'leanote://api/file/getAttach?fileId=' + eachMatch.fileId;
href = 'leanote://file/getAttach?fileId=' + eachMatch.fileId;
link = '[' + eachMatch.title + '](' + href + ')';
}
}
else {
if (!eachMatch.isAttach) {
var href = 'leanote://api/file/getImage?fileId=' + eachMatch.fileId;
var href = 'leanote://file/getImage?fileId=' + eachMatch.fileId;
link = '<img ' + eachMatch.pre + 'src="' + href + '"' + eachMatch.back + '>';
}
else {
var href = 'leanote://api/file/getAttach?fileId=' + eachMatch.fileId;
var href = 'leanote://file/getAttach?fileId=' + eachMatch.fileId;
link = '<a ' + eachMatch.pre + 'href="' + href + '"' + eachMatch.back + '>' + eachMatch.title + '</a>';
}
}

View File

@@ -18,7 +18,7 @@ var Import = {
notes: [
{
title: 'life',
content: 'laldfadf', // 图片, 附件链接为 leanote://api/file/getImage?fileId=xxxx, leanote://api/file/getAttach?fileId=3232323
content: 'laldfadf', // 图片, 附件链接为 leanote://file/getImage?fileId=xxxx, leanote://file/getAttach?fileId=3232323
tags: [1,2,3],
isMarkdown: true,
author: 'leanote', // 作者, 没用
@@ -92,7 +92,7 @@ var Import = {
if (note.isMarkdown) {
// image
var reg = new RegExp('!\\[([^\\]]*?)\\]\\(leanote://api/file/getImage\\?fileId=([0-9a-zA-Z]{24})\\)', 'g');
var reg = new RegExp('!\\[([^\\]]*?)\\]\\(leanote://file/getImage\\?fileId=([0-9a-zA-Z]{24})\\)', 'g');
var matches = reg.exec(content);
// 先找到所有的
while(matches) {
@@ -110,7 +110,7 @@ var Import = {
}
// attach
var reg = new RegExp('\\[([^\\]]*?)\\]\\(leanote://api/file/getAttach\\?fileId=([0-9a-zA-Z]{24})\\)', 'g');
var reg = new RegExp('\\[([^\\]]*?)\\]\\(leanote://file/getAttach\\?fileId=([0-9a-zA-Z]{24})\\)', 'g');
var matches = reg.exec(content);
// 先找到所有的
while(matches) {
@@ -130,8 +130,8 @@ var Import = {
else {
// 图片处理后, 可以替换内容中的链接了
// leanote://api/file/getImage?fileId=xxxx,
var reg = new RegExp('<img([^>]*?)src=["\']?leanote://api/file/getImage\\?fileId=([0-9a-zA-Z]{24})["\']?(.*?)>', 'g');
// leanote://file/getImage?fileId=xxxx,
var reg = new RegExp('<img([^>]*?)src=["\']?leanote://file/getImage\\?fileId=([0-9a-zA-Z]{24})["\']?(.*?)>', 'g');
var matches = reg.exec(content);
while(matches) {
var all = matches[0];
@@ -149,7 +149,7 @@ var Import = {
}
// 处理附件
var reg = new RegExp('<a([^>]*?)href=["\']?leanote://api/file/getAttach\\?fileId=([0-9a-zA-Z]{24})["\']?(.*?)>([^<]*)</a>', 'g');
var reg = new RegExp('<a([^>]*?)href=["\']?leanote://file/getAttach\\?fileId=([0-9a-zA-Z]{24})["\']?(.*?)>([^<]*)</a>', 'g');
var matches = reg.exec(content);
// 先找到所有的
while(matches) {
@@ -204,7 +204,6 @@ var Import = {
link = '<a ' + eachMatch.pre + 'href="' + href + '"' + eachMatch.back + '>' + eachMatch.title + '</a>';
}
}
}
content = content.replace(eachMatch.all, link);
}