1 | #+TITLE: @w96k: Articles
|
---|
2 | #+OPTIONS: toc:nil
|
---|
3 | #+LANGUAGE: en
|
---|
4 |
|
---|
5 | * Articles
|
---|
6 | #+BEGIN_SRC emacs-lisp :exports results :results html
|
---|
7 | (defun read-lines (filePath)
|
---|
8 | "Return a list of lines of a file at filePath."
|
---|
9 | (with-temp-buffer
|
---|
10 | (insert-file-contents filePath)
|
---|
11 | (split-string (buffer-string) "\n" t)))
|
---|
12 |
|
---|
13 | ;; Sort by modified date
|
---|
14 | (setq list-of-posts (sort (directory-files-and-attributes "./en/posts" nil ".org$")
|
---|
15 | #'(lambda (x y) (time-less-p (nth 6 y) (nth 6 x)))))
|
---|
16 |
|
---|
17 | (defun make-links (str)
|
---|
18 | (setq file-name (car str))
|
---|
19 | (setq str-link (s-replace ".org" ".html" file-name))
|
---|
20 | ;; We make an assumption, that #+TITLE is on first line
|
---|
21 | (setq article-title (s-replace "#+TITLE: " "" (car (read-lines (concat "en/posts/" file-name)))))
|
---|
22 | (concat "<li><a href=\"/en/posts/" str-link "\">" article-title "</a></li>"))
|
---|
23 |
|
---|
24 | (concat "<ul>" (mapconcat 'make-links list-of-posts "\n") "</ul>")
|
---|
25 | #+END_SRC
|
---|
26 |
|
---|
27 | ** Documentation
|
---|
28 | - [[https://w96k.dev/public/doc/gnu-c/][GNU C Language Manual]]
|
---|
29 |
|
---|
30 | ** Cтатьи
|
---|
31 |
|
---|
32 | #+BEGIN_SRC emacs-lisp :exports results :results html
|
---|
33 | (defun read-lines (filePath)
|
---|
34 | "Return a list of lines of a file at filePath."
|
---|
35 | (with-temp-buffer
|
---|
36 | (insert-file-contents filePath)
|
---|
37 | (split-string (buffer-string) "\n" t)))
|
---|
38 |
|
---|
39 | ;; Sort by modified date
|
---|
40 | (setq list-of-posts (sort (directory-files-and-attributes "./posts" nil ".org$")
|
---|
41 | #'(lambda (x y) (time-less-p (nth 6 y) (nth 6 x)))))
|
---|
42 |
|
---|
43 | (defun make-links (str)
|
---|
44 | (setq file-name (car str))
|
---|
45 | (setq str-link (s-replace ".org" ".html" file-name))
|
---|
46 | ;; We make an assumption, that #+TITLE is on first line
|
---|
47 | (setq article-title (s-replace "#+TITLE: " "" (car (read-lines (concat "posts/" file-name)))))
|
---|
48 | (concat "<li><a href=\"/posts/" str-link "\">" article-title "</a></li>"))
|
---|
49 |
|
---|
50 | (concat "<ul>" (mapconcat 'make-links list-of-posts "\n") "</ul>")
|
---|
51 | #+END_SRC
|
---|
52 |
|
---|
53 | ** Переводы
|
---|
54 | #+BEGIN_SRC emacs-lisp :exports results :results html
|
---|
55 | (defun read-lines (filePath)
|
---|
56 | "Return a list of lines of a file at filePath."
|
---|
57 | (with-temp-buffer
|
---|
58 | (insert-file-contents filePath)
|
---|
59 | (split-string (buffer-string) "\n" t)))
|
---|
60 |
|
---|
61 | ;; Sort by modified date
|
---|
62 | (setq list-of-posts (sort (directory-files-and-attributes "./translations" nil ".org$")
|
---|
63 | #'(lambda (x y) (time-less-p (nth 6 y) (nth 6 x)))))
|
---|
64 |
|
---|
65 | (defun make-links (str)
|
---|
66 | (setq file-name (car str))
|
---|
67 | (setq str-link (s-replace ".org" ".html" file-name))
|
---|
68 | ;; We make an assumption, that #+TITLE is on first line
|
---|
69 | (setq article-title (s-replace "#+TITLE: " "" (car (read-lines (concat "translations/" file-name)))))
|
---|
70 | (concat "<li><a href=\"/translations/" str-link "\">" article-title "</a></li>"))
|
---|
71 |
|
---|
72 | (concat "<ul>" (mapconcat 'make-links list-of-posts "\n") "</ul>")
|
---|
73 | #+END_SRC
|
---|