fronde 0.3.0 → 0.3.1

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: c646347a1cdbe6537384936ec392c1848617524fd7557f3c32566adb14e3c357
4
- data.tar.gz: 41785e0d542baa6ac44c8e2f7b8d12d26db6ea5a5e10349ea4002d71b25f435d
3
+ metadata.gz: 2270e37b7e8d42fa6a70cc1844bcc883db47e21268e463db721887309b65ca23
4
+ data.tar.gz: 2c17f8cf073c980a6050fbad6a2bc91f07999dc0455b0add8d13b234b2609ed9
5
5
  SHA512:
6
- metadata.gz: ecac97edd7c48c3cd808c906195b11e941f84db6254f0548af1d951e8bba215a6545616cc8b425977b5453b158f5b3032e08d4cf702b1087f110054770e3c739
7
- data.tar.gz: adb5628d1999d54284ad38c614ca29bd76b287124fb4ebc434a465225f3c1fb97acf1cce4e844de05aaf66b35c40be8216b9045535dfb05370c77eecb0cb4bde
6
+ metadata.gz: 63906ee9ae84ab6a1b81417dae22e9ab2d90fd0c348c435d35c309568505e5d39d13f98ce5c86c80474f0927796422fe3e89518faebd5c5a1a298a3d16722392
7
+ data.tar.gz: 399c76bd432a76be07efe3729a538e6f2fcee1fa4448043ff637cc77aae7a14df858794f0160d455ffef74ed965267d2f3194a94207bd47bb588c2aa3bb58888
@@ -42,7 +42,7 @@ module Fronde
42
42
  .gsub('__WORK_DIR__', workdir)
43
43
  .gsub('__FRONDE_DIR__', __dir__)
44
44
  .gsub('__ORG_VER__', org_last_version)
45
- .gsub('__ALL_PROJECTS__', all_projects(projects))
45
+ .gsub('__ALL_PROJECTS__', projects.values.join("\n "))
46
46
  .gsub('__THEME_CONFIG__', org_default_theme_config)
47
47
  .gsub('__ALL_PROJECTS_NAMES__', project_names(projects))
48
48
  .gsub('__LONG_DATE_FMT__', r18n_full_datetime_format)
@@ -109,12 +109,6 @@ module Fronde
109
109
  names.join(' ')
110
110
  end
111
111
 
112
- def all_projects(projects)
113
- projects.values.join("\n").strip
114
- .gsub(/\n\s*\n/, "\n")
115
- .gsub(/\n/, "\n ")
116
- end
117
-
118
112
  # Return the full path to the publication path of a given project
119
113
  # configuration.
120
114
  #
@@ -122,49 +116,60 @@ module Fronde
122
116
  # the ~sources~ key)
123
117
  # @return [String] the full path to the target dir of this project
124
118
  def publication_path(project)
125
- publish_in = [Dir.pwd, settings['public_folder']]
119
+ publish_in = [Dir.pwd]
120
+ if project['type'] == 'gemini'
121
+ publish_in << (settings['gemini_public_folder'] || 'public_gmi')
122
+ else
123
+ publish_in << settings['public_folder']
124
+ end
126
125
  publish_in << project['target'] unless project['target'] == '.'
127
126
  publish_in.join('/')
128
127
  end
129
128
 
129
+ # Return the publication function needed for a given project
130
+ # configuration.
131
+ #
132
+ # @param project [Hash] a project configuration (as extracted from
133
+ # the ~sources~ key)
134
+ # @return [String] the org publication function name
135
+ def publication_function(project)
136
+ case project['type']
137
+ when 'gemini'
138
+ 'org-gmi-publish-to-gemini'
139
+ else
140
+ 'org-html-publish-to-html'
141
+ end
142
+ end
143
+
130
144
  def org_project(project_name, opts)
131
- publish_in = publication_path(opts)
132
- other_lines = [
133
- format(':recursive %<value>s',
134
- value: ruby_to_lisp_boolean(opts['recursive']))
145
+ shared_lines = org_project_shared_lines(opts)
146
+ project_config = [
147
+ org_project_config(project_name, opts, shared_lines),
148
+ org_assets_config(project_name, shared_lines)
135
149
  ]
136
- if opts['exclude']
137
- other_lines << format(':exclude "%<value>s"',
138
- value: opts['exclude'])
139
- end
140
150
  themeconf = org_theme_config(opts['theme'])
141
- <<~ORGPROJECT
142
- ("#{project_name}"
143
- :base-directory "#{opts['path']}"
144
- :base-extension "org"
145
- #{other_lines.join("\n ")}
146
- :publishing-directory "#{publish_in}"
147
- :publishing-function org-html-publish-to-html
148
- #{opts['org_headers']})
149
- ("#{project_name}-assets"
150
- :base-directory "#{opts['path']}"
151
- :base-extension "jpg\\\\\\|gif\\\\\\|png\\\\\\|svg\\\\\\|pdf"
152
- #{other_lines[0]}
153
- :publishing-directory "#{publish_in}"
154
- :publishing-function org-publish-attachment)
155
- #{themeconf}
156
- ORGPROJECT
151
+ project_config << themeconf unless themeconf == ''
152
+ project_config.join("\n ")
157
153
  end
158
154
 
159
- def org_default_postamble
155
+ def org_default_html_postamble
160
156
  <<~POSTAMBLE
161
157
  <p><span class="author">#{R18n.t.fronde.org.postamble.written_by}</span>
162
- #{R18n.t.fronde.org.postamble.with_emacs}</p>
158
+ #{R18n.t.fronde.org.postamble.with_emacs_html}</p>
163
159
  <p class="date">#{R18n.t.fronde.org.postamble.last_modification}</p>
164
160
  <p class="validation">%v</p>
165
161
  POSTAMBLE
166
162
  end
167
163
 
164
+ def org_default_gemini_postamble
165
+ format(
166
+ "📅 %<date>s\n📝 %<author>s %<creator>s",
167
+ author: R18n.t.fronde.org.postamble.written_by,
168
+ creator: R18n.t.fronde.org.postamble.with_emacs,
169
+ date: R18n.t.fronde.org.postamble.last_modification
170
+ )
171
+ end
172
+
168
173
  def org_default_html_head
169
174
  <<~HTMLHEAD
170
175
  <link rel="stylesheet" type="text/css" media="screen"
@@ -177,9 +182,7 @@ module Fronde
177
182
 
178
183
  def org_default_html_options(project)
179
184
  defaults = {
180
- 'section-numbers' => 'nil',
181
- 'with-toc' => 'nil',
182
- 'html-postamble' => org_default_postamble,
185
+ 'html-postamble' => org_default_html_postamble,
183
186
  'html-head' => '__ATOM_FEED__',
184
187
  'html-head-include-default-style' => 't',
185
188
  'html-head-include-scripts' => 't'
@@ -192,6 +195,23 @@ module Fronde
192
195
  defaults
193
196
  end
194
197
 
198
+ def org_publish_options(project)
199
+ defaults = {
200
+ 'section-numbers' => 'nil',
201
+ 'with-toc' => 'nil'
202
+ }
203
+ if project['type'] == 'gemini'
204
+ defaults['gemini-postamble'] = org_default_gemini_postamble
205
+ else
206
+ defaults.merge!(
207
+ org_default_html_options(project),
208
+ settings['org-html'] || {},
209
+ project['org-html'] || {}
210
+ )
211
+ end
212
+ defaults.merge(project['org-options'] || {})
213
+ end
214
+
195
215
  def expand_vars_in_html_head(head, project)
196
216
  curtheme = project['theme'] || settings['theme']
197
217
  # Head may be frozen when coming from settings
@@ -212,21 +232,17 @@ module Fronde
212
232
  end
213
233
 
214
234
  def build_project_org_headers(project)
215
- orgtplopts = org_default_html_options(project).merge(
216
- settings['org-html'] || {}, project['org-html'] || {}
217
- )
218
- orgtpl = []
235
+ orgtplopts = org_publish_options(project)
219
236
  lisp_keywords = ['t', 'nil', '1', '-1', '0'].freeze
220
- orgtplopts.each do |k, v|
237
+ orgtplopts.map do |k, v|
221
238
  v = expand_vars_in_html_head(v, project) if k == 'html-head'
222
239
  val = cast_lisp_value(v)
223
240
  if lisp_keywords.include? val
224
- orgtpl << ":#{k} #{val}"
241
+ ":#{k} #{val}"
225
242
  else
226
- orgtpl << ":#{k} \"#{val}\""
243
+ ":#{k} \"#{val}\""
227
244
  end
228
245
  end
229
- orgtpl.join("\n ")
230
246
  end
231
247
 
232
248
  def org_generate_projects(with_tags: false)
@@ -247,23 +263,64 @@ module Fronde
247
263
  def org_default_theme_config
248
264
  theme_config = org_theme_config(settings['theme'])
249
265
  return theme_config if theme_config == ''
250
- output = theme_config.split("\n").map do |line|
251
- " #{line}"
252
- end
253
- format("\n%<conf>s", conf: output.join("\n"))
266
+ format("\n %<conf>s", conf: theme_config)
254
267
  end
255
268
 
256
269
  def org_theme_config(theme)
257
270
  return '' if theme.nil? || theme == 'default'
258
271
  workdir = Dir.pwd
259
- <<~THEMECONFIG
260
- ("theme-#{theme}"
261
- :base-directory "#{workdir}/themes/#{theme}"
262
- :base-extension "jpg\\\\\\|gif\\\\\\|png\\\\\\|js\\\\\\|css\\\\\\|otf\\\\\\|ttf\\\\\\|woff2?"
263
- :recursive t
264
- :publishing-directory "#{workdir}/#{settings['public_folder']}/assets/#{theme}"
265
- :publishing-function org-publish-attachment)
266
- THEMECONFIG
272
+ [
273
+ format('("theme-%<theme>s"', theme: theme),
274
+ format(' :base-directory "%<wd>s/themes/%<theme>s"',
275
+ wd: workdir, theme: theme),
276
+ # rubocop:disable Layout/LineLength
277
+ ' :base-extension "jpg\\\\\\|gif\\\\\\|png\\\\\\|js\\\\\\|css\\\\\\|otf\\\\\\|ttf\\\\\\|woff2?"',
278
+ # rubocop:enable Layout/LineLength
279
+ ' :recursive t',
280
+ format(' :publishing-directory "%<wd>s/%<pub>s/assets/%<theme>s"',
281
+ wd: workdir, pub: settings['public_folder'], theme: theme),
282
+ ' :publishing-function org-publish-attachment)'
283
+ ].join("\n ").strip
284
+ end
285
+
286
+ def org_project_shared_lines(project)
287
+ [
288
+ format(':base-directory "%<path>s"', path: project['path']),
289
+ format(
290
+ ':publishing-directory "%<path>s"',
291
+ path: publication_path(project)
292
+ ),
293
+ format(
294
+ ':recursive %<rec>s',
295
+ rec: ruby_to_lisp_boolean(project['recursive'])
296
+ )
297
+ ]
298
+ end
299
+
300
+ def org_project_config(project_name, project, shared_lines)
301
+ project_lines = [
302
+ format('"%<name>s"', name: project_name),
303
+ ':base-extension "org"',
304
+ format(
305
+ ':publishing-function %<fun>s',
306
+ fun: publication_function(project)
307
+ )
308
+ ] + shared_lines + project['org_headers']
309
+ if project['exclude']
310
+ project_lines << format(
311
+ ':exclude "%<value>s"', value: project['exclude']
312
+ )
313
+ end
314
+ format('(%<pr>s)', pr: project_lines.join("\n "))
315
+ end
316
+
317
+ def org_assets_config(project_name, shared_lines)
318
+ assets_lines = [
319
+ format('"%<name>s-assets"', name: project_name),
320
+ ':base-extension "jpg\\\\\\|gif\\\\\\|png\\\\\\|svg\\\\\\|pdf"',
321
+ ':publishing-function org-publish-attachment'
322
+ ] + shared_lines
323
+ format('(%<assets>s)', assets: assets_lines.join("\n "))
267
324
  end
268
325
  end
269
326
  end
@@ -9,9 +9,11 @@
9
9
  user-mail-address "__AUTHOR_EMAIL__"
10
10
  user-full-name "__AUTHOR_NAME__"
11
11
  org-html-metadata-timestamp-format "__LONG_DATE_FMT__"
12
+ org-gmi-timestamp-format "__LONG_DATE_FMT__"
12
13
  org-publish-project-alist
13
14
  `(__ALL_PROJECTS____THEME_CONFIG__
14
15
  ("website" :components (__ALL_PROJECTS_NAMES__))))
15
16
 
16
17
  ;; Load fronde lib
18
+ (load-file (expand-file-name "ox-gmi.el" "__WORK_DIR__/lib"))
17
19
  (load-file (expand-file-name "ox-fronde.el" "__FRONDE_DIR__"))
@@ -30,6 +30,7 @@
30
30
 
31
31
  (require 'org)
32
32
  (require 'ox-html)
33
+ (require 'ox-gmi)
33
34
 
34
35
  ;;; Function Declarations
35
36
 
@@ -65,6 +66,12 @@ INFO is a plist used as a communication channel."
65
66
  (org-export-data (plist-get info :description) info)))
66
67
  output)))
67
68
 
69
+ (defun fronde/org-gmi-format-spec (upstream info)
70
+ "Return format specification for gemini postamble.
71
+ INFO is a plist used as a communication channel."
72
+ (let ((output (funcall upstream info)))
73
+ (push `(?n . ,(format "Fronde %s" fronde/version)) output)))
74
+
68
75
  (defun fronde/org-i18n-export (link description format)
69
76
  "Export a i18n link"
70
77
  (let* ((splitted-link (split-string link "|"))
@@ -77,8 +84,7 @@ INFO is a plist used as a communication channel."
77
84
  path lang desc)
78
85
  (format "<a href=\"%s\">%s</a>" path desc)))
79
86
  (`latex (format "\\href{%s}{%s}" path desc))
80
- (`ascii (format "%s (%s)" desc path))
81
- (_ path))))
87
+ (_ (format "%s (%s)" desc path)))))
82
88
 
83
89
  (defun fronde/org-i18n-follow (link)
84
90
  "Visit a i18n link"
@@ -108,6 +114,7 @@ INFO is a plist used as a communication channel."
108
114
  (underline . "<span class=\"underline\">%s</span>")
109
115
  (verbatim . "<code>%s</code>")))
110
116
  (advice-add 'org-html-format-spec :around #'fronde/org-html-format-spec)
117
+ (advice-add 'org-gmi--format-spec :around #'fronde/org-gmi-format-spec)
111
118
 
112
119
  (provide 'ox-fronde)
113
120
 
@@ -109,9 +109,6 @@ module Fronde
109
109
  # @option opts [String] title ('') the title of the new Org file
110
110
  # @option opts [String] author (system user or '') the author of the
111
111
  # document
112
- # @option opts [Boolean] verbose (false) if the
113
- # {Fronde::OrgFileHtmlizer#publish publish} method should output
114
- # emacs process messages
115
112
  # @option opts [String] project the project owning this file
116
113
  # must be stored
117
114
  # @return [Fronde::OrgFile] the new instance of Fronde::OrgFile
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Fronde
4
4
  # @return [String] the version number of the current Fronde release.
5
- VERSION = '0.3.0'
5
+ VERSION = '0.3.1'
6
6
  end
@@ -67,7 +67,14 @@ namespace :org do
67
67
  IO.write 'lib/htmlize.el', htmlize
68
68
  end
69
69
 
70
- file 'var/lib/org-config.el' => 'lib/htmlize.el' do
70
+ file 'lib/ox-gmi.el' => 'lib' do
71
+ ox_gmi = URI(
72
+ 'https://git.umaneti.net/ox-gmi.el/plain/ox-gmi.el'
73
+ ).open.read
74
+ IO.write 'lib/ox-gmi.el', ox_gmi
75
+ end
76
+
77
+ file 'var/lib/org-config.el' => ['lib/htmlize.el', 'lib/ox-gmi.el'] do
71
78
  Fronde::Config.write_org_lisp_config
72
79
  end
73
80
 
@@ -20,8 +20,8 @@ fronde:
20
20
  no_command: 'ERROR: no command or unknown command given.'
21
21
  no_file: 'ERROR: no file to open or edit.'
22
22
  error:
23
- label: An error occured.
24
- explanation: To see it, run again your command with more verbosity, i.e. fronde build -v
23
+ label: An error occurred.
24
+ explanation: To see the error, run your command again with more verbosity, for example, fronde build -v
25
25
  index:
26
26
  unsorted: Unsorted
27
27
  published_on: Published on %1
@@ -33,5 +33,6 @@ fronde:
33
33
  org:
34
34
  postamble:
35
35
  written_by: Written by %a
36
- with_emacs: 'with %c, and published with %N'
37
36
  last_modification: Last modification on %C
37
+ with_emacs: 'with %c, and published with %n'
38
+ with_emacs_html: 'with %c, and published with %N'
@@ -33,5 +33,6 @@ fronde:
33
33
  org:
34
34
  postamble:
35
35
  written_by: Écrit par %a
36
- with_emacs: 'avec %c et publié avec %N'
37
36
  last_modification: dernière modification le %C
37
+ with_emacs: 'avec %c et publié avec %n'
38
+ with_emacs_html: 'avec %c et publié avec %N'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fronde
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Étienne Deparis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-12 00:00:00.000000000 Z
11
+ date: 2020-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri