fronde 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8691e788789cb725772213237a67731dc67ae77eeecc8d1d409e6779d94a22c8
4
- data.tar.gz: d2f67191b421f902e1b41d7845fc07026843e227cfd3f70cdeff0f4d87e36b8e
3
+ metadata.gz: 2d233f108a209e4d5a02633de060293ce6f4981393555ebf5f53f16a25f6d3d0
4
+ data.tar.gz: 9efa6cd46fc4d6d33e98bcee3e7cb1dd43a179736bafb552f6ac3e7a8c5bb8ae
5
5
  SHA512:
6
- metadata.gz: b8d3fa0a8bbfbcdecbf7a65ffc93b420876ddb27acf574a5a1a066b988ce2e039ff780b0a71bd6056f3a75b52072f4c37489135a6ead712e0a728f8385453de2
7
- data.tar.gz: d2bd28e4fa15b156a83c61b79426f74e3e48534cfe483f92a03dd3d9a4a0675252843bb991bbb114f45421865b52e6b7f6f7dd500261cc0d8236063838f7baf4
6
+ metadata.gz: a1c7f18af62f3fbd02be2f025c7d6305a7ea1c3751a35490eee4402de3a4aebf11c211cc3efcc4d57d0b82e99807a439ef920eb67182f0f8313905b20d89fd15
7
+ data.tar.gz: 315634038a4eb1df1c07f019894a0b86b591649f58068d771811bc0bbb92402cc03f79ada03f716caae0e8219075937d1df63ab3e6453827fadb03763203d4da
data/lib/ext/nil_time.rb CHANGED
@@ -10,12 +10,9 @@ class NilTime
10
10
  ''
11
11
  end
12
12
 
13
- def l18n_short_date_string
14
- ''
15
- end
16
-
17
- def l18n_long_date_string(*)
18
- ''
13
+ %i[l18n_short_date_string l18n_long_date_string
14
+ l18n_long_date_no_year_string].each do |name|
15
+ define_method(name) { '' }
19
16
  end
20
17
 
21
18
  def l18n_short_date_html
data/lib/ext/time.rb CHANGED
@@ -1,8 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'r18n'
4
- using R18nPatch
5
-
6
3
  # Monkey patch to add some helpers
7
4
  module TimePatch
8
5
  refine Time do
@@ -10,7 +7,7 @@ module TimePatch
10
7
  #
11
8
  # @return [String] the localized Time string representation
12
9
  def l18n_short_date_string
13
- R18n.l to_date
10
+ I18n.l to_date
14
11
  end
15
12
 
16
13
  # Format the current Time as a HTML `time` tag showing a short date.
@@ -22,11 +19,17 @@ module TimePatch
22
19
 
23
20
  # Returns the current Time instance as a localized long string.
24
21
  #
25
- # @param with_year [Boolean] whether or not the string must contain
26
- # the year
27
22
  # @return [String] the localized Time string representation
28
- def l18n_long_date_string(with_year: true)
29
- R18n.t.long_date_string(self, with_year: with_year)
23
+ def l18n_long_date_string
24
+ I18n.l self, format: :long
25
+ end
26
+
27
+ # Returns the current Time instance as a localized long string
28
+ # without year.
29
+ #
30
+ # @return [String] the localized Time string representation
31
+ def l18n_long_date_no_year_string
32
+ I18n.l self, format: :long_no_year
30
33
  end
31
34
 
32
35
  # Format the current Time as a HTML `time` tag showing a long date.
@@ -1,20 +1,24 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'r18n'
4
- using R18nPatch
5
-
6
3
  using TimePatch
7
4
 
8
5
  # A time emulator to keep the fact that the time information was
9
6
  # missing, even if it behaves as a Time object for the given date.
10
7
  class TimeNoTime < Time
11
- # Returns the current Time instance as a localized long string.
8
+ # Returns the current Time instance as a localized long string
9
+ # without time.
10
+ #
11
+ # @return [String] the localized Time string representation
12
+ def l18n_long_date_string
13
+ I18n.l self, format: :long_no_time
14
+ end
15
+
16
+ # Returns the current Time instance as a localized long string
17
+ # without time nor year.
12
18
  #
13
- # @param with_year [Boolean] wether or not the string must contain the
14
- # year
15
19
  # @return [String] the localized Time string representation
16
- def l18n_long_date_string(with_year: true)
17
- R18n.t.long_date_string(self, with_year: with_year, with_time: false)
20
+ def l18n_long_date_no_year_string
21
+ I18n.l self, format: :long_no_time_no_year
18
22
  end
19
23
 
20
24
  def self.parse_no_time(string)
@@ -71,26 +71,26 @@ module Fronde
71
71
  @command = @argv.shift || 'basic' if @command == 'help'
72
72
  cmd_opt = OptParse.command_options(@command)
73
73
  label = cmd_opt[:label] || @command
74
- output = [format_label(R18n.t.fronde.bin.usage(label))]
74
+ output = [format_label(I18n.t('fronde.bin.usage', label:))]
75
75
  cmd = cmd_opt[:name] || @command
76
- output << format_label(R18n.t.fronde.bin.commands[cmd])
76
+ output << format_label(I18n.t("fronde.bin.commands.#{cmd}"))
77
77
  output << OptParse.help_command_body(cmd)
78
- warn output.join
78
+ puts output.join
79
79
  true
80
80
  end
81
81
 
82
82
  private
83
83
 
84
84
  def format_label(label)
85
- return '' if label == '' || label.is_a?(R18n::Untranslated)
85
+ return '' if label == '' || label.start_with?('Translation missing:')
86
86
 
87
- format("%<label>s\n\n", label: label)
87
+ format("%<label>s\n\n", label:)
88
88
  end
89
89
 
90
90
  def file_name_from_title
91
- title = @options[:title] || R18n.t.fronde.bin.options.default_title
91
+ title = @options[:title] || I18n.t('fronde.bin.options.default_title')
92
92
  # No title, nor a reliable file_path? Better abort
93
- raise R18n.t.fronde.error.bin.no_file if title == ''
93
+ raise I18n.t('fronde.error.bin.no_file') if title == ''
94
94
 
95
95
  "#{Fronde::Slug.slug(title)}.org"
96
96
  end
@@ -0,0 +1,20 @@
1
+ function __fronde_main_commands
2
+ echo {{ comcomp }}
3
+ end
4
+
5
+ function __fronde_no_command_yet
6
+ set -f cmd (__fish_print_cmd_args_without_options)
7
+ {%- for com in commands %}
8
+ {% unless forloop.first %}and {% endunless %}not contains {{ com }} $cmd
9
+ {%- endfor %}
10
+ end
11
+
12
+ complete -c fronde -e
13
+ complete -c fronde -f
14
+ complete -c fronde -x -n '__fronde_no_command_yet' -a '(__fronde_main_commands)'
15
+ complete -c fronde -n 'contains help (__fish_print_cmd_args_without_options)' -a '{{ commands | join ' ' }}'
16
+ complete -c fronde -n 'contains new (__fish_print_cmd_args_without_options)' -F
17
+ complete -c fronde -n 'contains open (__fish_print_cmd_args_without_options)' -F
18
+ {%- for compopt in details %}
19
+ complete -c fronde{% unless compopt.command == 'basic' %} -n 'contains {{ compopt.command }} (__fish_print_cmd_args_without_options)'{% endunless %} -s {{ compopt.short_no_dash }} -l {{ compopt.long_no_dash }}{% if compopt.keyword %} -r{% endif %}{% if compopt.choices %} -a '{{ compopt.choices | join ' ' }}'{% endif %} -d {% if compopt.help %}'{{ compopt.help }}'{% else %}{{ compopt.long_no_dash | capitalize }}{% endif %}
20
+ {%- endfor %}
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'uri'
4
- require 'net/http'
5
3
  require 'fileutils'
6
4
 
7
5
  module Fronde
@@ -10,13 +10,13 @@ module Fronde
10
10
  '-a' => { long: 'author' },
11
11
  '-f' => { long: 'force', boolean: true },
12
12
  '-h' => { long: 'help', boolean: true, method: :on_tail,
13
- help: R18n.t.fronde.bin.options.help },
13
+ help: I18n.t('fronde.bin.options.help') },
14
14
  '-l' => { long: 'lang', keyword: 'LOCALE' },
15
15
  '-o' => { long: 'output', keyword: 'FORMAT', choices: %w[gemini html] },
16
16
  '-t' => { long: 'title' },
17
17
  '-v' => { long: 'verbose', boolean: true, method: :on_tail },
18
18
  '-V' => { long: 'version', boolean: true, method: :on_tail,
19
- help: R18n.t.fronde.bin.options.version }
19
+ help: I18n.t('fronde.bin.options.version') }
20
20
  }.freeze
21
21
 
22
22
  # TODO: jekyll new [path] / jekyll build / jekyll clean / jekyll serve
@@ -28,13 +28,13 @@ module Fronde
28
28
  FRONDE_COMMANDS = {
29
29
  'new' => { opts: ['-a', '-l', '-o', '-t', '-v'], label: 'new <path>' },
30
30
  'init' => { alias: 'new' },
31
- 'update' => {},
31
+ 'update' => { opts: ['-v'] },
32
32
  'config' => { alias: 'update' },
33
33
  'preview' => {},
34
- 'open' => { opts: ['-a', '-l', '-t', '-v'], label: 'open <path>' },
34
+ 'open' => { opts: ['-a', '-l', '-t'], label: 'open <path>' },
35
35
  'edit' => { alias: 'open' },
36
- 'build' => { opts: ['-f'] },
37
- 'publish' => {},
36
+ 'build' => { opts: ['-f', '-v'] },
37
+ 'publish' => { opts: ['-v'] },
38
38
  'help' => {},
39
39
  'basic' => { opts: ['-h', '-V'], label: '<command>' }
40
40
  }.freeze
@@ -59,7 +59,7 @@ module Fronde
59
59
  config = [short, long]
60
60
  else
61
61
  key = opt[:keyword] || opt[:long].upcase
62
- config = [short, format('%<long>s %<key>s', long: long, key: key)]
62
+ config = [short, format('%<long>s %<key>s', long:, key:)]
63
63
  end
64
64
  config.push opt[:choices], opt[:help]
65
65
  config.compact
@@ -86,9 +86,9 @@ module Fronde
86
86
  command_opts_doc = summarize_command(command)
87
87
  return '' if command_opts_doc == ''
88
88
 
89
- body = [R18n.t.fronde.bin.options.cmd_title, command_opts_doc]
89
+ body = [I18n.t('fronde.bin.options.cmd_title'), command_opts_doc]
90
90
  if command == 'basic'
91
- body += ['', R18n.t.fronde.bin.commands.cmd_title, list_commands]
91
+ body += ['', I18n.t('fronde.bin.commands.cmd_title'), list_commands]
92
92
  end
93
93
  body.join("\n")
94
94
  end
@@ -102,9 +102,9 @@ module Fronde
102
102
 
103
103
  line = [' ', cmd.ljust(10)]
104
104
  if opt.has_key? :alias
105
- line << R18n.t.fronde.bin.commands.alias(opt[:alias])
105
+ line << I18n.t('fronde.bin.commands.alias', alias: opt[:alias])
106
106
  else
107
- line << R18n.t.fronde.bin.commands[cmd]
107
+ line << I18n.t("fronde.bin.commands.#{cmd}")
108
108
  end
109
109
  line.join(' ')
110
110
  end.join("\n")
@@ -35,11 +35,11 @@ module Fronde
35
35
  raise e
36
36
  # :nocov: not sure how to emulate a Ctrl+c in rspec
37
37
  rescue Interrupt => e
38
- show_message Rainbow(R18n.t.fronde.bin.interrupted).red, "\n"
38
+ show_message Rainbow(I18n.t('fronde.bin.interrupted')).red, "\n"
39
39
  raise e
40
40
  # :nocov:
41
41
  else
42
- show_message Rainbow(R18n.t.fronde.bin.done).green, "\n"
42
+ show_message Rainbow(I18n.t('fronde.bin.done')).green, "\n"
43
43
  end
44
44
 
45
45
  class << self
@@ -56,10 +56,16 @@ module Fronde
56
56
  #
57
57
  # @param thread [Thread] the long-running operation to decorate
58
58
  # @param message [String] the message to display before the throbber
59
+ # @param verbose [Boolean] whether the decoration should be shown
60
+ # or skipped
59
61
  # @return [void]
60
- def run(thread, message)
61
- throbber = new(thread, message)
62
- throbber.run
62
+ def run(thread, message, verbose)
63
+ if verbose
64
+ thread.join
65
+ else
66
+ throbber = new(thread, message)
67
+ throbber.run
68
+ end
63
69
  end
64
70
  end
65
71
 
@@ -93,8 +99,8 @@ module Fronde
93
99
  format(
94
100
  "%<message>s %<label>s\n%<explanation>s",
95
101
  message: @message,
96
- label: Rainbow(R18n.t.fronde.error.bin.label).bold.red,
97
- explanation: Rainbow(R18n.t.fronde.error.bin.explanation).bold
102
+ label: Rainbow(I18n.t('fronde.error.bin.label')).bold.red,
103
+ explanation: Rainbow(I18n.t('fronde.error.bin.explanation')).bold
98
104
  )
99
105
  )
100
106
  end
data/lib/fronde/cli.rb CHANGED
@@ -51,7 +51,7 @@ module Fronde
51
51
  def method_unknown?(method)
52
52
  return false if respond_to?(method)
53
53
 
54
- warn R18n.t.fronde.error.bin.no_command
54
+ warn I18n.t('fronde.error.bin.no_command')
55
55
  fronde_help
56
56
  true
57
57
  end
@@ -47,31 +47,37 @@
47
47
  "Location of the local Org temporary directory.
48
48
  This is where to place org timestamps and id locations.")
49
49
 
50
+ (defvar fronde--keywords-slugs-alist nil
51
+ "A list associating each keywords to its related slug.
52
+
53
+ Can be hydrated with `fronde--build-keywords-list'.")
54
+
55
+ (defun fronde--build-keywords-list ()
56
+ (let ((keywords-file (format "%s/keywords" fronde-org-temp-dir))
57
+ keywords-slugs)
58
+ (when (file-readable-p keywords-file)
59
+ (let ((content (with-temp-buffer
60
+ (insert-file-contents keywords-file)
61
+ (string-trim-right (buffer-string)))))
62
+ (mapcar
63
+ (lambda (line)
64
+ (push (split-string line "\x1f") keywords-slugs))
65
+ (split-string content "\x1e"))))
66
+ keywords-slugs))
67
+
50
68
  (defun fronde--format-rich-keywords (info function)
51
69
  "Extract keywords from INFO and apply FUNCTION on them.
52
70
  FUNCTION is expected to format each keyword for a rich display for the
53
71
  current export backend. FUNCTION must receive 3 arguments: the current
54
72
  KEYWORD, its related SLUG and the current project BASE-URI."
55
- (let ((base-uri (plist-get info :fronde-base-uri))
56
- (current-path (symbol-file 'fronde--format-rich-keywords))
57
- sluglib)
58
- (when current-path
59
- (setq sluglib
60
- (expand-file-name
61
- (format "%s../../slug" (file-name-directory current-path)))))
73
+ (let ((base-uri (plist-get info :fronde-base-uri)))
62
74
  (mapcar
63
- (lambda (k)
64
- (let ((slug (if sluglib
65
- (string-trim-right
66
- (shell-command-to-string
67
- (format "ruby -r %s -e \"puts Fronde::Slug.slug '%s'\""
68
- (shell-quote-argument sluglib)
69
- (shell-quote-argument k))))
70
- k)))
71
- (funcall function k slug base-uri)))
72
- (split-string
73
- (org-export-data (plist-get info :keywords) info)
74
- ",+ *"))))
75
+ (lambda (k)
76
+ (let ((slug (cadr (assoc k fronde--keywords-slugs-alist))))
77
+ (funcall function k slug base-uri)))
78
+ (split-string
79
+ (org-export-data (plist-get info :keywords) info)
80
+ ",+ *"))))
75
81
 
76
82
  (defun fronde--org-html-format-spec (upstream info)
77
83
  "Advise UPSTREAM to return format specification for preamble and postamble.
@@ -79,35 +85,35 @@ INFO is a plist used as a communication channel."
79
85
  (let ((output (funcall upstream info)))
80
86
  (push `(?A . ,(format "<span class=\"author\">%s</span>"
81
87
  (org-export-data (plist-get info :author) info)))
82
- output)
88
+ output)
83
89
  (push `(?k . ,(org-export-data (plist-get info :keywords) info)) output)
84
90
  (push `(?K . ,(format "<ul class=\"keywords-list\">\n%s</ul>"
85
91
  (apply #'concat
86
92
  (fronde--format-rich-keywords
87
93
  info
88
- (lambda (k slug base-uri)
94
+ (lambda (k slug base-uri)
89
95
  (format "<li class=\"keyword\"><a href=\"%stags/%s.html\">%s</a></li>\n"
90
96
  base-uri slug k))))))
91
- output)
97
+ output)
92
98
  (push `(?l . ,(org-export-data (plist-get info :language) info)) output)
93
99
  (push `(?n . ,(format "Fronde %s" fronde-version)) output)
94
100
  (push `(?N . ,(format "<a href=\"https://etienne.depar.is/fronde/\">Fronde</a> %s" fronde-version)) output)
95
101
  (push `(?x . ,(org-export-data (plist-get info :description) info)) output)
96
102
  (push `(?X . ,(format "<p>%s</p>"
97
103
  (org-export-data (plist-get info :description) info)))
98
- output)))
104
+ output)))
99
105
 
100
106
  (defun fronde--org-gmi-format-spec (upstream info)
101
107
  "Advise UPSTREAM to return format specification for gemini postamble.
102
108
  INFO is a plist used as a communication channel."
103
109
  (let ((output (funcall upstream info)))
104
110
  (push `(?K . ,(org-gmi--build-links-list
105
- (fronde--format-rich-keywords
106
- info
107
- (lambda (k slug base-uri)
108
- (list (format "%stags/%s.gmi" base-uri slug)
109
- (format "🏷️ %s" k))))))
110
- output)
111
+ (fronde--format-rich-keywords
112
+ info
113
+ (lambda (k slug base-uri)
114
+ (list (format "%stags/%s.gmi" base-uri slug)
115
+ (format "🏷️ %s" k))))))
116
+ output)
111
117
  (push `(?n . ,(format "Fronde %s" fronde-version)) output)))
112
118
 
113
119
  (defun fronde--org-i18n-export (link description backend)
@@ -135,21 +141,23 @@ INFO is a plist used as a communication channel."
135
141
  ;;; Set configuration options
136
142
 
137
143
  (setq fronde-org-temp-dir (expand-file-name "var/tmp" fronde-current-work-dir)
144
+ fronde--keywords-slugs-alist (fronde--build-keywords-list)
138
145
  org-publish-timestamp-directory (expand-file-name "timestamps/" fronde-org-temp-dir)
139
146
  org-id-locations-file (expand-file-name "id-locations.el" fronde-org-temp-dir)
140
147
  make-backup-files nil
141
- enable-local-variables :all
142
- org-confirm-babel-evaluate nil
148
+ enable-dir-local-variables nil
149
+ enable-local-variables t ;; enforce default
150
+ org-confirm-babel-evaluate t ;; enforce default
143
151
  org-export-with-broken-links t
144
152
  org-html-doctype "html5"
145
153
  org-html-html5-fancy t
146
154
  org-html-htmlize-output-type 'css
147
155
  org-html-text-markup-alist '((bold . "<strong>%s</strong>")
148
- (code . "<code>%s</code>")
149
- (italic . "<em>%s</em>")
150
- (strike-through . "<del>%s</del>")
151
- (underline . "<span class=\"underline\">%s</span>")
152
- (verbatim . "<code>%s</code>")))
156
+ (code . "<code>%s</code>")
157
+ (italic . "<em>%s</em>")
158
+ (strike-through . "<del>%s</del>")
159
+ (underline . "<span class=\"underline\">%s</span>")
160
+ (verbatim . "<code>%s</code>")))
153
161
  (advice-add 'org-html-format-spec :around #'fronde--org-html-format-spec)
154
162
  (advice-add 'org-gmi--format-spec :around #'fronde--org-gmi-format-spec)
155
163
 
@@ -14,7 +14,7 @@ module Fronde
14
14
  def self.migrate(config)
15
15
  return config unless config.has_key?('public_folder')
16
16
 
17
- warn R18n.t.fronde.error.config.deprecated_public_folder
17
+ warn I18n.t('fronde.error.config.deprecated_public_folder')
18
18
  old_pub_folder = config.delete('public_folder')
19
19
  return config if config.has_key?('html_public_folder')
20
20
 
@@ -6,9 +6,6 @@ require_relative '../version'
6
6
  require_relative '../org'
7
7
  require_relative 'helpers'
8
8
 
9
- require_relative '../../ext/r18n'
10
- using R18nPatch
11
-
12
9
  module Fronde
13
10
  module Config
14
11
  # This module contains utilitary methods to ease ~org-config.el~
@@ -33,7 +30,7 @@ module Fronde
33
30
  'work_dir' => workdir,
34
31
  'fronde_data_dir' => File.expand_path('data', __dir__),
35
32
  'org_version' => Fronde::Org.current_version,
36
- 'long_date_fmt' => R18n.t.full_datetime_format.to_s,
33
+ 'long_date_fmt' => I18n.t('time.formats.long'),
37
34
  'author' => { 'email' => get('author_email', ''),
38
35
  'name' => get('author') },
39
36
  'domain' => get('domain'),
data/lib/fronde/config.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'yaml'
4
- require 'r18n-core'
4
+ require 'i18n'
5
5
  require 'singleton'
6
6
 
7
7
  require_relative 'config/lisp'
@@ -141,7 +141,7 @@ module Fronde
141
141
  get('sources', default_sources).filter_map do |source_conf|
142
142
  config = Source.canonical_config source_conf.dup
143
143
  unless config['path']
144
- warn R18n.t.fronde.error.source.no_path(source: config.inspect)
144
+ warn I18n.t('fronde.error.source.no_path', source: config.inspect)
145
145
  next
146
146
  end
147
147
  Source.new_from_config config
@@ -153,7 +153,8 @@ module Fronde
153
153
  return path unless collection[type].has_key?(path)
154
154
 
155
155
  warn(
156
- R18n.t.fronde.error.source.duplicate(
156
+ I18n.t(
157
+ 'fronde.error.source.duplicate',
157
158
  source: source['name'], type: type
158
159
  )
159
160
  )
@@ -182,7 +183,8 @@ module Fronde
182
183
  def warn_on_existing_inclusion(type, other, possible_matchs, sources)
183
184
  possible_matchs.each do |match|
184
185
  warn(
185
- R18n.t.fronde.error.source.inclusion(
186
+ I18n.t(
187
+ 'fronde.error.source.inclusion',
186
188
  source: sources[match]['title'],
187
189
  other_source: other, type: type
188
190
  )
@@ -221,8 +223,8 @@ module Fronde
221
223
  CONFIG = Config::Store.instance
222
224
  end
223
225
 
224
- R18n.default_places = File.expand_path('../../locales', __dir__)
225
- R18n::Filters.on(:named_variables)
226
- R18n.set Fronde::CONFIG.get('lang')
226
+ i18n_glob = File.expand_path('../../locales', __dir__)
227
+ I18n.load_path = Dir.glob("#{i18n_glob}/*.yml")
228
+ I18n.default_locale = Fronde::CONFIG.get('lang')
227
229
 
228
230
  Fronde::CONFIG.load_sources
data/lib/fronde/emacs.rb CHANGED
@@ -10,8 +10,22 @@ module Fronde
10
10
  @command = nil
11
11
  end
12
12
 
13
- def publish(project = 'website')
14
- build_command("(org-publish \"#{project}\")")
13
+ def publish(project = 'website', force: false)
14
+ if force
15
+ build_command %[(org-publish "#{project}" t)]
16
+ else
17
+ build_command %[(org-publish "#{project}")]
18
+ end
19
+ run_command
20
+ end
21
+
22
+ def publish_file(file_path, force: false)
23
+ if force
24
+ build_command '(org-publish-current-file t)'
25
+ else
26
+ build_command '(org-publish-current-file)'
27
+ end
28
+ @command.insert(-2, %(--visit "#{file_path}"))
15
29
  run_command
16
30
  end
17
31
 
@@ -20,21 +34,21 @@ module Fronde
20
34
  def run_command
21
35
  cmd = @command.join(' ')
22
36
  if @verbose
23
- warn cmd
24
- return system(cmd, exception: true)
37
+ puts cmd
38
+ return system(cmd, err: $stdout, exception: true)
25
39
  end
26
40
  system cmd, out: File::NULL, err: File::NULL, exception: true
27
41
  end
28
42
 
29
43
  def build_command(org_action)
30
44
  default_emacs = Fronde::CONFIG.get('emacs')
31
- @command = [default_emacs || 'emacs -Q --batch -nw']
32
- @command << '--eval \'(setq inhibit-message t)\'' unless @verbose
33
- @command += [
34
- '--eval \'(setq enable-dir-local-variables nil)\'',
45
+ @command = [
46
+ default_emacs || 'emacs -Q --batch -nw',
47
+ '--eval \'(setq inhibit-message t)\'',
35
48
  '-l ./var/lib/org-config.el',
36
49
  "--eval '#{org_action}'"
37
50
  ]
51
+ @command.delete_at(1) if @verbose
38
52
  end
39
53
  end
40
54
  end
@@ -22,7 +22,7 @@ module Fronde
22
22
  FileUtils.mkdir_p "#{@project.publication_path}/feeds"
23
23
  @index.each_key do |tag|
24
24
  write_atom(tag)
25
- warn R18n.t.fronde.index.atom_generated(tag: tag) if verbose
25
+ puts I18n.t('fronde.index.atom_generated', tag:) if verbose
26
26
  end
27
27
  end
28
28
 
@@ -30,7 +30,7 @@ module Fronde
30
30
  FileUtils.mkdir_p "#{@project['path']}/tags"
31
31
  @index.each_key do |tag|
32
32
  write_org(tag)
33
- warn R18n.t.fronde.index.index_generated(tag: tag) if verbose
33
+ puts I18n.t('fronde.index.index_generated', tag:) if verbose
34
34
  end
35
35
  write_blog_home_page(verbose)
36
36
  end
@@ -47,7 +47,9 @@ module Fronde
47
47
  entries.map! do |article|
48
48
  published = article['published']
49
49
  unless published == ''
50
- article['published'] = R18n.t.fronde.index.published_on published
50
+ article['published'] = I18n.with_locale(article['lang']) do
51
+ I18n.t('fronde.index.published_on', date: published)
52
+ end
51
53
  end
52
54
  article
53
55
  end
@@ -60,7 +62,7 @@ module Fronde
60
62
  'domain' => Fronde::CONFIG.get('domain'),
61
63
  'lang' => Fronde::CONFIG.get('lang'),
62
64
  'author' => Fronde::CONFIG.get('author'),
63
- 'unsorted' => R18n.t.fronde.index.unsorted,
65
+ 'unsorted' => I18n.t('fronde.index.unsorted'),
64
66
  'entries' => entries
65
67
  )
66
68
  end
@@ -73,11 +75,11 @@ module Fronde
73
75
  'weight' => @index[tag].length
74
76
  }
75
77
  end
76
- { 'title' => R18n.t.fronde.index.send(title), 'tags' => all_tags }
78
+ { 'title' => I18n.t("fronde.index.#{title}"), 'tags' => all_tags }
77
79
  end
78
80
  Config::Helpers.render_liquid_template(
79
81
  File.read(File.expand_path('./data/all_tags.org', __dir__)),
80
- 'title' => R18n.t.fronde.index.all_tags,
82
+ 'title' => I18n.t('fronde.index.all_tags'),
81
83
  'lang' => Fronde::CONFIG.get('lang'),
82
84
  'author' => Fronde::CONFIG.get('author'),
83
85
  'domain' => Fronde::CONFIG.get('domain'),
@@ -90,7 +92,7 @@ module Fronde
90
92
  def write_blog_home_page(verbose)
91
93
  orgdest = format('%<root>s/index.org', root: @project['path'])
92
94
  if verbose
93
- warn R18n.t.fronde.org.generate_blog_index(name: @project['name'])
95
+ puts I18n.t('fronde.org.generate_blog_index', name: @project['name'])
94
96
  end
95
97
  File.write(orgdest, blog_home_page)
96
98
  end
data/lib/fronde/index.rb CHANGED
@@ -8,7 +8,7 @@ module Fronde
8
8
  # Generates website indexes and atom feeds for all the org documents
9
9
  # keywords.
10
10
  class Index
11
- attr_reader :date
11
+ attr_reader :date, :project
12
12
 
13
13
  def initialize(project)
14
14
  @project = project
@@ -31,7 +31,8 @@ module Fronde
31
31
  def sort_by(kind)
32
32
  accepted_values = %i[name weight]
33
33
  unless accepted_values.include?(kind)
34
- error_msg = R18n.t.fronde.error.index.wrong_sort_kind(
34
+ error_msg = I18n.t(
35
+ 'fronde.error.index.wrong_sort_kind',
35
36
  kind: kind, accepted_values: accepted_values.inspect
36
37
  )
37
38
  raise ArgumentError, error_msg
@@ -43,6 +44,10 @@ module Fronde
43
44
  # and avoid to scroll to find the beginning of the list.
44
45
  end
45
46
 
47
+ def emacs_keywords
48
+ @tags_names.map { |slug, title| "#{title}\x1f#{slug}" }.join("\x1e")
49
+ end
50
+
46
51
  class << self
47
52
  def all_blog_index(&block)
48
53
  all_blogs = CONFIG.sources.filter_map do |project|
@@ -91,7 +96,7 @@ module Fronde
91
96
  all_keys = all_tags
92
97
  {
93
98
  by_name: all_keys.sort,
94
- by_weight: all_keys.sort_by { @index[_1].length }.reverse
99
+ by_weight: all_keys.sort_by { [-@index[_1].length, _1] }
95
100
  }
96
101
  end
97
102
  end