Giter Site home page Giter Site logo

Comments (6)

TevinLi avatar TevinLi commented on May 11, 2024 1

后续可能会考虑允许从 Atom 左边的目录树直接拖过来,嗯,这个操作貌似还挺不错的,后面某一版本会加入这个功能

from amwiki.

TevinLi avatar TevinLi commented on May 11, 2024

您好,感谢选择 amWiki !
之所以链接形式不一样,是因为 amWiki 是通过 ajax 加载来读取 md 文件内容的,所以就不是直接用文件地址,但是链接还是有很大的相似性:

library\000-Index\001-todo.md
?file=000-Index/001-todo

其实也就是把文件路径改为 url 参数了,从 library 开始往下,将文件路径改为 file 参数值来传递,加粗的部分就是相同的地方
暂时还没有设置生成这个链接的快捷方式

from amwiki.

ni-chen avatar ni-chen commented on May 11, 2024

能从目录树直接拖过来就太好了。
另外如果文件改名了能同步更新链接就太好了,因为目前似乎只有navagation能同步更新来着。
辛苦你了。

from amwiki.

TevinLi avatar TevinLi commented on May 11, 2024

同时更新链接这个可能需要再考察一下
主要是 Atom 重命名事件本身只能知道更改后的文件名,更改前的文件名除非事先记录了,而且这个记录不同于 navagation 还涉另外涉及几个问题不是很好处理,囧... 暂时先用 Atom 的 Search in Directory 功能来批量替换吧

from amwiki.

awfeeling avatar awfeeling commented on May 11, 2024

直接在md文件中使用相对路径,然后在解析时补全访问路径,下面是我修改的一段代码:
amWiki.js:

392c392
<                 docs.renderDoc(content);
---
>                 docs.renderDoc(homePage.path, content);
406c406
<         docs.renderDoc(localDoc);
---
>         docs.renderDoc(path, localDoc);
434c434
<                     docs.renderDoc(content);
---
>                     docs.renderDoc(path, content);

amWiki.docs.js:

13a14,40
>     
> 	function getPath(basePath, targetPath) {
> 		targetPath.replace(/^\.\//, "");
> 		if (/^mailto:|http[s]*:\/\/|\?file=/.test(targetPath)) {
> 			return targetPath;
> 		}
> 		
> 		var baseAry = basePath.split("/");
> 		var targetAry = targetPath.split("/");
> 		
> 		var baseAryLength = baseAry.length - 1;
> 		while (true) {
> 			var targetAryFirst = targetAry[0];
> 			if (targetAryFirst == ".." && baseAryLength >= 0) {
> 				targetAry.splice(0, 1);
> 				baseAryLength --;
> 			} else {
> 				break;
> 			}
> 		}
> 		
> 		if (baseAryLength == -1) {
> 			throw new Error("Invalid targetPath: " + targetPath);
> 		}
> 		
> 		return "?file=" + baseAry.slice(0, baseAryLength).concat(targetAry).join("/");
> 	}
418c445
<     Docs.prototype.renderDoc = function (content) {
---
>     Docs.prototype.renderDoc = function (path, content) {
425c452,475
<         html = marked(content);
---
>         var renderer = new marked.Renderer();
> 		renderer.link = function(href, title, text) {
> 		  if (this.options.sanitize) {
> 			try {
> 			  var prot = decodeURIComponent(unescape(href))
> 				.replace(/[^\w:]/g, '')
> 				.toLowerCase();
> 			} catch (e) {
> 			  return '';
> 			}
> 			if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
> 			  return '';
> 			}
> 		  }
> 		  
> 		  var out = '<a href="' + getPath(path, href) + '"';
> 		  if (title) {
> 			out += ' title="' + title + '"';
> 		  }
> 		  out += '>' + text + '</a>';
> 		  return out;
> 		};
> 	
>         html = marked(content, { renderer: renderer });

from amwiki.

TevinLi avatar TevinLi commented on May 11, 2024

嗯嗯,最近已经打算调整 #17 的策略了,更改成如同你代码的意思,在 md 上使用相对地址,web 端则转换成实际访问地址
不过策略也略有些区别,我只打算对和当前 index.html 平级的 assets 和 library 这两个文件及其深子级下的文件引用进行地址转换,如果相对路径计算出并不匹配这两个文件夹,则不激活转换

from amwiki.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.