How to use the evt.localUrl function in evt

To help you get started, we’ve selected a few evt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github leanote / desktop-app / src / node_modules / note.js View on Github external
var content = note.Content;

		// 1. 先得到附件
		var attachs = note.Attachs || [];
		for(var i in attachs) {
			var attach = attachs[i];
			attach.IsAttach = true;
		}

		// 1. 先得到图片

		// 得到图片信息, 通过内容
		// http://localhost:8002/api/file/getImage?fileId=xxxxxx, 得到fileId, 查询数据库, 得到图片
		// console.log(content);
		// console.log(Evt.localUrl + '/api/file/getImage?fileId=([0-9a-zA-Z]{24})');
		var reg = new RegExp(Evt.localUrl + "/api/file/getImage\\?fileId=([0-9a-zA-Z]{24})", 'g');
		var fileIds = [];
		// var fileIdsMap = {}; // 防止多个
		while((result = reg.exec(content)) != null) {
			// result = [所有, 子表达式1, 子表达式2]
			if(result && result.length > 1) {
	            // console.log(result);
				var fileId = result[1];
				fileIds.push(fileId);
			}
        }
        var files = []; // {localFileId: "must", fileId: "", hasBody: true, filename: "xx.png"}
        if(fileIds.length > 0) {
        	// 得到所有的图片
        	File.getAllImages(fileIds, function(images) {
        		// attach与图片结合
        		if(images) {
github leanote / desktop-app / node_modules / server.js View on Github external
});
			}
			else {
				var sh = 'kill -9 $(lsof -i:' + Evt.port + ' -t)';
				child_process.exec(sh, callback);
			}
		}
		// killPort(function (error, stdout, stderr) {
	        // if (error !== null) {
		        // console.log('kill port error: ' + error);
	        // }

			server.listen(Evt.port);
			console.log("Server runing at port: " + Evt.port + ".");

			me.localUrl = Evt.localUrl;
			me._started = true;

			me.server = server;
	    // });
	},
github leanote / desktop-app / src / node_modules / note.js View on Github external
fixNoteContent: function(content) {
		if(!content) {
			return content;
		}
		// http://leanote.com/file/outputImage?fileId=54f9079f38f4115c0200001b
		var reg0 = new RegExp(Evt.leanoteUrl + '/file/outputImage', 'g');
		content = content.replace(reg0, Evt.localUrl + '/api/file/getImage');

		var reg = new RegExp(Evt.leanoteUrl + '/api/file/getImage', 'g');
		content = content.replace(reg, Evt.localUrl + '/api/file/getImage');

		var reg2 = new RegExp(Evt.leanoteUrl + '/api/file/getAttach', 'g');
		content = content.replace(reg2, Evt.localUrl + '/api/file/getAttach');

		// api/file/getAllAttachs?noteId=xxxxxxxxx, 这里的noteId是服务器上的noteId啊
		var reg3 = new RegExp(Evt.leanoteUrl + '/api/file/getAllAttachs', 'g');
		content = content.replace(reg3, Evt.localUrl + '/api/file/getAllAttachs');

		return content;
	},
github leanote / desktop-app / src / node_modules / server.js View on Github external
killPort(function (error, stdout, stderr) {
	        if (error !== null) {
		        console.log('kill port error: ' + error);
	        }

			server.listen(Evt.port);
			console.log("Server runing at port: " + Evt.port + ".");

			me.localUrl = Evt.localUrl;
			me._started = true;

			me.server = server;
	    });
	},