Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

考虑用org的文件名作为URL? #85

Closed
Liu233w opened this issue Aug 22, 2016 · 3 comments
Closed

考虑用org的文件名作为URL? #85

Liu233w opened this issue Aug 22, 2016 · 3 comments

Comments

@Liu233w
Copy link
Member

Liu233w commented Aug 22, 2016

目前URL是使用文章的标题来生成的,如果修改了标题,会被当做不同的文章来处理,为什么不考虑用org的文件名来当做URL呢?感觉一般情况下用户是不会修改文件名的,而且每个文件名必须不同,也能防止URL重复了。

@kuangdash
Copy link
Member

kuangdash commented Aug 22, 2016

配合 #+URI 这个功能的话,

可以通过修改 ego--generate-uri 这个函数来实现这个功能。

譬如说添加一个 encode-file-name,再用 format-spec 增加一个 ?f 的模板,

然后 #+URI 里面用个 %f 。

……不过我不想在这个版本的 EGO 上继续修改了,当然,还是接受 pull-request 的。

目前 EGO 2.0 龟速开发中,目标和之前提到的 enhancement 一致,要集合 blog-admin(使用 ctable 咯)、org-iv(实时浏览,呃,至少是 save 时浏览) 和 EGO 目前的功能,并添加 tags 管理以及 ego-map 这种用于自由改主题的文件(可能是 json 格式)。

模板方面还是用 mustache (配合 ego-map 使用),因为任何一种模板(template)只要添加 if 语句就会变成 PHP。mustache 刚好够用了。

然而进度条停在 1% 的位置(- -)

@Liu233w
Copy link
Member Author

Liu233w commented Aug 22, 2016

差不多是这样吗

(let ((uri-template (or (ego--read-org-option "URI")
                        default-uri-template))
      (date-list (split-string (if creation-date
                                   (ego--fix-timestamp-string creation-date)
                                 (format-time-string "%Y-%m-%d"))
                               "-"))
      (encoded-title (ego--encode-string-to-url title))
      (encoded-file-name (ego--encode-string-to-url
                          ;; 获取buffer的文件名
                          (replace-regexp-in-string "^.*/\\|\\.org$" "" (buffer-file-name)))))
  (format-spec uri-template `((?y . ,(car date-list))
                              (?m . ,(cadr date-list))
                              (?d . ,(cl-caddr date-list))
                              (?t . ,encoded-title)
                              (?f . ,encoded-file-name))))

@kuangdash
Copy link
Member

kuangdash commented Aug 22, 2016

👍 好了,已经直接添加了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants