summaryrefslogtreecommitdiff
path: root/content/articles.org
blob: 335ae19379c6a30aa764cf32770669f3049f2201 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#+TITLE: @w96k: Articles
#+OPTIONS: toc:nil
#+LANGUAGE: en

* Articles
  #+BEGIN_SRC emacs-lisp :exports results :results html
    (defun read-lines (filePath)
      "Return a list of lines of a file at filePath."
      (with-temp-buffer
	(insert-file-contents filePath)
	(split-string (buffer-string) "\n" t)))

    ;; Sort by modified date
    (setq list-of-posts (sort (directory-files-and-attributes "./en/posts" nil ".org$")
			      #'(lambda (x y) (time-less-p (nth 6 y) (nth 6 x)))))

    (defun make-links (str)
      (setq file-name (car str))
      (setq str-link (s-replace ".org" ".html" file-name))
      ;; We make an assumption, that #+TITLE is on first line
      (setq article-title (s-replace "#+TITLE: " "" (car (read-lines (concat "en/posts/" file-name)))))
      (concat "<li><a href=\"/en/posts/" str-link "\">" article-title "</a></li>"))

    (concat "<ul>" (mapconcat 'make-links list-of-posts "\n") "</ul>")
  #+END_SRC

** Documentation
- [[https://w96k.dev/public/doc/gnu-c/][GNU C Language Manual]]
  
** Cтатьи

  #+BEGIN_SRC emacs-lisp :exports results :results html
    (defun read-lines (filePath)
      "Return a list of lines of a file at filePath."
      (with-temp-buffer
	(insert-file-contents filePath)
	(split-string (buffer-string) "\n" t)))

    ;; Sort by modified date
    (setq list-of-posts (sort (directory-files-and-attributes "./posts" nil ".org$")
			      #'(lambda (x y) (time-less-p (nth 6 y) (nth 6 x)))))

    (defun make-links (str)
      (setq file-name (car str))
      (setq str-link (s-replace ".org" ".html" file-name))
      ;; We make an assumption, that #+TITLE is on first line
      (setq article-title (s-replace "#+TITLE: " "" (car (read-lines (concat "posts/" file-name)))))
      (concat "<li><a href=\"/posts/" str-link "\">" article-title "</a></li>"))

    (concat "<ul>" (mapconcat 'make-links list-of-posts "\n") "</ul>")
  #+END_SRC

** Переводы
  #+BEGIN_SRC emacs-lisp :exports results :results html
    (defun read-lines (filePath)
      "Return a list of lines of a file at filePath."
      (with-temp-buffer
	(insert-file-contents filePath)
	(split-string (buffer-string) "\n" t)))

;; Sort by modified date
(setq list-of-posts (sort (directory-files-and-attributes "./translations" nil ".org$")
			  #'(lambda (x y) (time-less-p (nth 6 y) (nth 6 x)))))

    (defun make-links (str)
      (setq file-name (car str))
      (setq str-link (s-replace ".org" ".html" file-name))
      ;; We make an assumption, that #+TITLE is on first line
      (setq article-title (s-replace "#+TITLE: " "" (car (read-lines (concat "translations/" file-name)))))
      (concat "<li><a href=\"/translations/" str-link "\">" article-title "</a></li>"))

    (concat "<ul>" (mapconcat 'make-links list-of-posts "\n") "</ul>")
  #+END_SRC