neruda 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Neruda
4
- VERSION = '0.1.3'
4
+ # @return [String] the version number of the current Neruda release.
5
+ VERSION = '0.2.0'
5
6
  end
@@ -1,26 +1,38 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'open-uri'
4
+
3
5
  # Neruda::Config is required by Neruda::Utils
4
6
  require 'neruda/utils'
5
7
 
6
8
  namespace :org do
7
- desc 'Download last version of org-mode'
9
+ desc 'Download last version of Org'
8
10
  task :download do
11
+ verbose = Rake::FileUtilsExt.verbose_flag
12
+ download = Thread.new do
13
+ Thread.current[:org_version] = Neruda::Config.org_last_version
14
+ Neruda::Utils.download_org
15
+ end
16
+ if verbose
17
+ download.join
18
+ warn "Org version #{download[:org_version]} has been downloaded"
19
+ else
20
+ Neruda::Utils.throbber(download, 'Downloading Org:')
21
+ end
22
+ end
23
+
24
+ desc 'Compile Org'
25
+ task compile: ['org:download'] do
9
26
  verbose = Rake::FileUtilsExt.verbose_flag
10
27
  org_version = "org-#{Neruda::Config.org_last_version}"
11
- next if Neruda::Config.org_last_version.nil?
12
28
  next if Dir.exist?("#{org_version}/lisp")
13
- tarball = "#{org_version}.tar.gz"
14
- curl = ['curl', '--progress-bar', '-O',
15
- "https://orgmode.org/#{tarball}"]
16
29
  make = ['make', '-C', org_version]
17
30
  unless verbose
18
- curl[1] = '-s'
19
31
  make << '-s'
20
32
  make << 'EMACSQ="emacs -Q --eval \'(setq inhibit-message t)\'"'
21
33
  end
22
34
  build = Thread.new do
23
- sh curl.join(' ')
35
+ tarball = "tmp/#{org_version}.tar.gz"
24
36
  sh "tar xzf #{tarball}"
25
37
  File.unlink tarball
26
38
  sh((make + ['compile']).join(' '))
@@ -34,16 +46,18 @@ namespace :org do
34
46
  build.join
35
47
  warn "#{org_version} has been locally installed"
36
48
  else
37
- Neruda::Utils.throbber(build, 'Installing org mode:')
49
+ Neruda::Utils.throbber(build, 'Installing Org:')
38
50
  end
39
51
  end
40
52
 
41
53
  file 'htmlize.el' do
42
54
  verbose = Rake::FileUtilsExt.verbose_flag
43
- curl = ['curl', '--progress-bar', '-O',
44
- 'https://raw.githubusercontent.com/hniksic/emacs-htmlize/master/htmlize.el']
45
- curl[1] = '-s' unless verbose
46
- build = Thread.new { sh curl.join(' ') }
55
+ build = Thread.new do
56
+ htmlize = URI(
57
+ 'https://raw.githubusercontent.com/hniksic/emacs-htmlize/master/htmlize.el'
58
+ ).open.read
59
+ IO.write 'htmlize.el', htmlize
60
+ end
47
61
  if verbose
48
62
  build.join
49
63
  warn 'htmlize.el has been locally installed'
@@ -53,7 +67,6 @@ namespace :org do
53
67
  end
54
68
 
55
69
  file 'org-config.el' => 'htmlize.el' do
56
- next if Neruda::Config.org_last_version.nil?
57
70
  Neruda::Config.write_org_lisp_config
58
71
  end
59
72
 
@@ -62,8 +75,10 @@ namespace :org do
62
75
  end
63
76
 
64
77
  desc 'Install org'
65
- task install: ['org:download', 'org-config.el', '.dir-locals.el'] do
78
+ task install: ['org:compile', 'org-config.el', '.dir-locals.el'] do
66
79
  mkdir_p "#{Neruda::Config.settings['public_folder']}/assets"
67
- mkdir_p 'src'
80
+ Neruda::Config.sources.each do |s|
81
+ mkdir_p s['path'] unless Dir.exist? s['path']
82
+ end
68
83
  end
69
84
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'neruda/emacs'
3
4
  require 'neruda/index'
4
5
  require 'neruda/utils'
5
6
  require 'neruda/org_file'
@@ -8,9 +9,6 @@ require 'neruda/templater'
8
9
  namespace :site do
9
10
  desc 'Generates all index files'
10
11
  task :index do
11
- blog_path = Neruda::Config.settings['blog_path']
12
- next if blog_path.nil?
13
- next unless Dir.exist?("src/#{blog_path}")
14
12
  index = Neruda::Index.new
15
13
  verbose = Rake::FileUtilsExt.verbose_flag
16
14
  if verbose
@@ -18,22 +16,27 @@ namespace :site do
18
16
  next
19
17
  end
20
18
  build = Thread.new do
21
- index.write_all(false)
19
+ index.write_all(verbose: false)
22
20
  end
23
21
  Neruda::Utils.throbber(build, 'Generating indexes:')
22
+ next if index.empty?
23
+ Neruda::Config.write_org_lisp_config(with_tags: true)
24
24
  end
25
25
 
26
26
  desc 'Convert all org files'
27
27
  task build: :index do
28
28
  build_html = Thread.new do
29
- Neruda::OrgFile.new(nil, verbose: Rake::FileUtilsExt.verbose_flag).publish
29
+ Neruda::Emacs.new(verbose: Rake::FileUtilsExt.verbose_flag).publish
30
+ # TODO: Find a way to publish the virtual tag project
30
31
  end
31
32
  begin
32
33
  Neruda::Utils.throbber(build_html, 'Building:')
34
+ # :nocov:
33
35
  rescue RuntimeError
34
36
  warn 'Aborting'
35
37
  next
36
38
  end
39
+ # :nocov:
37
40
  customize_html = Thread.new do
38
41
  pubfolder = Neruda::Config.settings['public_folder']
39
42
  Dir["#{pubfolder}/**/*.html"].each do |f|
@@ -51,26 +54,33 @@ namespace :site do
51
54
  next
52
55
  end
53
56
  verbose = Rake::FileUtilsExt.verbose_flag
54
- o = Thread.new do
55
- Neruda::OrgFile.new(args[:source], verbose: verbose).publish
57
+ project = Neruda::OrgFile.project_for_source(args[:source])
58
+ if project.nil?
59
+ warn "No project found for #{args['source']}"
60
+ next
61
+ end
62
+ build_html = Thread.new do
63
+ o = Neruda::OrgFile.new(
64
+ args[:source], project: project, verbose: verbose
65
+ )
66
+ Thread.current[:org_file] = o
67
+ o.publish
56
68
  end
57
69
  begin
58
- Neruda::Utils.throbber(o, 'Building:')
70
+ Neruda::Utils.throbber(build_html, 'Building:')
59
71
  rescue RuntimeError
60
72
  warn 'Aborting'
61
73
  next
62
74
  end
63
- target = Neruda::OrgFile.target_for_source(args[:source])
75
+ target = Neruda::OrgFile.target_for_source(args[:source], project)
64
76
  warn "Customizing file #{target}" if verbose
65
- Neruda::Templater.customize_output(target, o)
77
+ Neruda::Templater.customize_output(target, build_html[:org_file])
66
78
  end
67
79
  end
68
80
 
69
- # :nocov:
70
81
  desc 'Start a test server'
71
82
  task :preview do
72
83
  require 'neruda/preview'
73
84
  Neruda.start_preview
74
85
  end
75
- # :nocov:
76
86
  end
@@ -5,19 +5,15 @@ require 'neruda/index'
5
5
  namespace :tags do
6
6
  desc 'List all tags by name'
7
7
  task :name do
8
- blog_path = Neruda::Config.settings['blog_path']
9
- next if blog_path.nil?
10
- next unless Dir.exist?("src/#{blog_path}")
11
8
  index = Neruda::Index.new
9
+ next if index.empty?
12
10
  puts index.sort_by(:name).join("\n")
13
11
  end
14
12
 
15
13
  desc 'List all tags by weight'
16
14
  task :weight do
17
- blog_path = Neruda::Config.settings['blog_path']
18
- next if blog_path.nil?
19
- next unless Dir.exist?("src/#{blog_path}")
20
15
  index = Neruda::Index.new
16
+ next if index.empty?
21
17
  puts index.sort_by(:weight).join("\n")
22
18
  end
23
19
  end
@@ -2,7 +2,26 @@
2
2
  pablo:
3
3
  error:
4
4
  no_command: 'ERROR: no command or unknown command given.'
5
+ usage: 'Usage: pablo %1 [options]'
6
+ commands:
7
+ cmd_title: Commands
8
+ alias: Alias for %1.
9
+ init: Initialize your Neruda instance (you just need to do it once).
10
+ preview: 'Start a test web server to preview your website on http://127.0.0.1:5000'
11
+ open: Open or create an org file.
12
+ build: Compile your org files to HTML.
13
+ publish: Push local changes to your public web server.
14
+ help: Alias for the -h switch.
15
+ options:
16
+ cmd_title: Options
17
+ path: Path to the new file.
18
+ directory: Wrap the new org file in this named folder.
19
+ help: Display help for a command and exit.
20
+ version: Display Neruda version and exit.
5
21
  neruda:
22
+ error:
23
+ label: An error occured.
24
+ explanation: To see it, run again your command with more verbosity, i.e. pablo build -v
6
25
  index:
7
26
  unsorted: Unsorted
8
27
  published_on: Published on %1
@@ -14,5 +33,5 @@ neruda:
14
33
  org:
15
34
  postamble:
16
35
  written_by: Written by %a
17
- with_emacs: with %c, and published with <a href="https://deparis.io/neruda">Neruda</a>
36
+ with_emacs: 'with %c, and published with %N'
18
37
  last_modification: Last modification on %C
@@ -2,7 +2,26 @@
2
2
  pablo:
3
3
  error:
4
4
  no_command: 'ERREUR: Aucune commande ou commande inconnue donnée.'
5
+ usage: 'Usage : pablo %1 [options]'
6
+ commands:
7
+ cmd_title: Commandes
8
+ alias: Alias pour %1.
9
+ init: Initialise votre instance de Neruda (vous ne devriez faire cela qu'une fois).
10
+ preview: "Démarre un serveur web de test pour prévisualiser votre site à l'adresse http://127.0.0.1:5000"
11
+ open: Ouvre ou crée un fichier org.
12
+ build: Compile vos fichiers org en HTML.
13
+ publish: Pousse vos changements locaux vers votre serveur web public.
14
+ help: Alias pour l'argument -h.
15
+ options:
16
+ cmd_title: Options
17
+ path: Chemin vers le nouveau fichier.
18
+ directory: Place le nouveau fichier org dans un dossier à ce nom.
19
+ help: Affiche l'aide pour une commande et quitte.
20
+ version: Affiche la version de Neruda et quitte.
5
21
  neruda:
22
+ error:
23
+ label: Une erreur est survenue
24
+ explanation: Pour voir le détail, lancez de nouveau la commande avec plus de verbosité, par exemple pablo build -v
6
25
  index:
7
26
  unsorted: Non triés
8
27
  published_on: Publié le %1
@@ -14,5 +33,5 @@ neruda:
14
33
  org:
15
34
  postamble:
16
35
  written_by: Écrit par %a
17
- with_emacs: avec %c et publié avec <a href="https://deparis.io/neruda">Neruda</a>
36
+ with_emacs: 'avec %c et publié avec %N'
18
37
  last_modification: dernière modification le %C
@@ -0,0 +1,346 @@
1
+ /**
2
+ * This file has been generated with the `org-html-htmlize-generate-css'
3
+ * command of org mode, with the Dracula theme enabled.
4
+ * The Dracula theme is released under an MIT license and thus the
5
+ * following is also released under this license.
6
+ * See https://github.com/dracula/emacs for details.
7
+ */
8
+
9
+ .src {
10
+ color: #f8f8f2;
11
+ background-color: #282a36;
12
+ padding: .6em 1em;
13
+ }
14
+ pre.src a:hover {
15
+ text-decoration: underline;
16
+ }
17
+
18
+ .org-bold {
19
+ /* bold */
20
+ font-weight: bold;
21
+ }
22
+ .org-bold-italic {
23
+ /* bold-italic */
24
+ font-weight: bold;
25
+ font-style: italic;
26
+ }
27
+
28
+ .org-builtin {
29
+ /* font-lock-builtin-face */
30
+ color: #ffb86c;
31
+ }
32
+ .org-button {
33
+ /* button */
34
+ color: #8be9fd;
35
+ text-decoration: underline;
36
+ }
37
+ .org-comment {
38
+ /* font-lock-comment-face */
39
+ color: #6272a4;
40
+ }
41
+ .org-comment-delimiter {
42
+ /* font-lock-comment-delimiter-face */
43
+ color: #6272a4;
44
+ }
45
+ .org-constant {
46
+ /* font-lock-constant-face */
47
+ color: #8be9fd;
48
+ }
49
+ .org-cursor {
50
+ /* cursor */
51
+ background-color: #8be9fd;
52
+ }
53
+ .org-doc {
54
+ /* font-lock-doc-face */
55
+ color: #6272a4;
56
+ }
57
+ .org-error {
58
+ /* error */
59
+ color: #ffc0cb;
60
+ font-weight: bold;
61
+ }
62
+ .org-escape-glyph {
63
+ /* escape-glyph */
64
+ color: #00ffff;
65
+ }
66
+ .org-file-name-shadow {
67
+ /* file-name-shadow */
68
+ color: #b3b3b3;
69
+ }
70
+ .org-fringe {
71
+ /* fringe */
72
+ color: #b6b6b2;
73
+ background-color: #282a36;
74
+ }
75
+ .org-function-name {
76
+ /* font-lock-function-name-face */
77
+ color: #50fa7b;
78
+ font-weight: bold;
79
+ }
80
+ .org-glyphless-char {
81
+ /* glyphless-char */
82
+ font-size: 60%;
83
+ }
84
+ .org-header-line {
85
+ /* header-line */
86
+ background-color: #282a36;
87
+ }
88
+ .org-header-line-highlight {
89
+ /* header-line-highlight */
90
+ color: #ccccc7;
91
+ background-color: #464752;
92
+ }
93
+ .org-help-argument-name {
94
+ /* help-argument-name */
95
+ font-style: italic;
96
+ }
97
+ .org-highlight {
98
+ /* highlight */
99
+ color: #ccccc7;
100
+ background-color: #464752;
101
+ }
102
+ .org-hl-line {
103
+ /* hl-line */
104
+ background-color: #44475a;
105
+ }
106
+ .org-homoglyph {
107
+ /* homoglyph */
108
+ color: #00ffff;
109
+ }
110
+ .org-italic {
111
+ /* italic */
112
+ font-style: italic;
113
+ }
114
+ .org-keyword {
115
+ /* font-lock-keyword-face */
116
+ color: #ff79c6;
117
+ font-weight: bold;
118
+ }
119
+ .org-lazy-highlight {
120
+ /* lazy-highlight */
121
+ color: #e2e2dc;
122
+ background-color: #464752;
123
+ }
124
+ .org-line-number-current-line {
125
+ /* line-number-current-line */
126
+ color: #b3b3b3;
127
+ background-color: #282a36;
128
+ }
129
+ .org-link {
130
+ /* link */
131
+ color: #8be9fd;
132
+ text-decoration: underline;
133
+ }
134
+ .org-link-visited {
135
+ /* link-visited */
136
+ color: #ee82ee;
137
+ text-decoration: underline;
138
+ }
139
+ .org-linum {
140
+ /* linum */
141
+ color: #565761;
142
+ background-color: #282a36;
143
+ font-style: italic;
144
+ }
145
+ .org-match {
146
+ /* match */
147
+ background-color: #3a5fcd;
148
+ }
149
+ .org-negation-char {
150
+ /* font-lock-negation-char-face */
151
+ color: #8be9fd;
152
+ }
153
+ .org-next-error {
154
+ /* next-error */
155
+ color: #282a36;
156
+ background-color: #f1fa8c;
157
+ }
158
+ .org-nobreak-hyphen {
159
+ /* nobreak-hyphen */
160
+ color: #00ffff;
161
+ }
162
+ .org-nobreak-space {
163
+ /* nobreak-space */
164
+ color: #00ffff;
165
+ text-decoration: underline;
166
+ }
167
+ .org-outline-1 {
168
+ /* outline-1 */
169
+ color: #50fa7b;
170
+ }
171
+ .org-outline-2 {
172
+ /* outline-2 */
173
+ color: #bd93f9;
174
+ }
175
+ .org-outline-3 {
176
+ /* outline-3 */
177
+ color: #8be9fd;
178
+ }
179
+ .org-outline-4 {
180
+ /* outline-4 */
181
+ color: #ffb86c;
182
+ }
183
+ .org-outline-5 {
184
+ /* outline-5 */
185
+ color: #ffb86c;
186
+ }
187
+ .org-outline-6 {
188
+ /* outline-6 */
189
+ color: #0189cc;
190
+ }
191
+ .org-outline-7 {
192
+ /* outline-7 */
193
+ color: #ffb86c;
194
+ }
195
+ .org-outline-8 {
196
+ /* outline-8 */
197
+ color: #f1fa8c;
198
+ }
199
+ .org-page-break-lines {
200
+ /* page-break-lines */
201
+ color: #6272a4;
202
+ }
203
+ .org-preprocessor {
204
+ /* font-lock-preprocessor-face */
205
+ color: #ffb86c;
206
+ }
207
+ .org-py-builtins {
208
+ /* py-builtins-face */
209
+ color: #ffb86c;
210
+ }
211
+ .org-py-class-name {
212
+ /* py-class-name-face */
213
+ color: #bd93f9;
214
+ }
215
+ .org-py-decorators {
216
+ /* py-decorators-face */
217
+ color: #ff79c6;
218
+ font-weight: bold;
219
+ }
220
+ .org-py-def-class {
221
+ /* py-def-class-face */
222
+ color: #ff79c6;
223
+ font-weight: bold;
224
+ }
225
+ .org-py-exception-name {
226
+ /* py-exception-name-face */
227
+ color: #ffb86c;
228
+ }
229
+ .org-py-import-from {
230
+ /* py-import-from-face */
231
+ color: #ff79c6;
232
+ font-weight: bold;
233
+ }
234
+ .org-py-number {
235
+ /* py-number-face */
236
+ color: #f8f8f2;
237
+ background-color: #282a36;
238
+ }
239
+ .org-py-object-reference {
240
+ /* py-object-reference-face */
241
+ color: #ff79c6;
242
+ font-weight: bold;
243
+ }
244
+ .org-py-pseudo-keyword {
245
+ /* py-pseudo-keyword-face */
246
+ color: #ff79c6;
247
+ font-weight: bold;
248
+ }
249
+ .org-py-try-if {
250
+ /* py-try-if-face */
251
+ color: #ff79c6;
252
+ font-weight: bold;
253
+ }
254
+ .org-py-variable-name {
255
+ /* py-variable-name-face */
256
+ color: #f8f8f2;
257
+ background-color: #282a36;
258
+ }
259
+ .org-py-xxx-tag {
260
+ /* py-XXX-tag-face */
261
+ color: #f1fa8c;
262
+ }
263
+ .org-query-replace {
264
+ /* query-replace */
265
+ color: #ffb86c;
266
+ background-color: #464752;
267
+ font-weight: bold;
268
+ }
269
+ .org-regexp-grouping-backslash {
270
+ /* font-lock-regexp-grouping-backslash */
271
+ font-weight: bold;
272
+ }
273
+ .org-regexp-grouping-construct {
274
+ /* font-lock-regexp-grouping-construct */
275
+ font-weight: bold;
276
+ }
277
+ .org-region {
278
+ /* region */
279
+ color: #282a36;
280
+ background-color: #f1fa8c;
281
+ }
282
+ .org-shadow {
283
+ /* shadow */
284
+ color: #b3b3b3;
285
+ }
286
+ .org-show-paren-match {
287
+ /* show-paren-match */
288
+ background-color: #4f94cd;
289
+ }
290
+ .org-show-paren-match-expression {
291
+ /* show-paren-match-expression */
292
+ background-color: #4f94cd;
293
+ }
294
+ .org-show-paren-mismatch {
295
+ /* show-paren-mismatch */
296
+ color: #ffffff;
297
+ background-color: #a020f0;
298
+ }
299
+ .org-string {
300
+ /* font-lock-string-face */
301
+ color: #f1fa8c;
302
+ }
303
+ .org-success {
304
+ /* success */
305
+ color: #00ff00;
306
+ font-weight: bold;
307
+ }
308
+ .org-tooltip {
309
+ /* tooltip */
310
+ color: #000000;
311
+ background-color: #ffffe0;
312
+ }
313
+ .org-trailing-whitespace {
314
+ /* trailing-whitespace */
315
+ background-color: #ffb86c;
316
+ }
317
+ .org-type {
318
+ /* font-lock-type-face */
319
+ color: #bd93f9;
320
+ }
321
+ .org-underline {
322
+ /* underline */
323
+ text-decoration: underline;
324
+ }
325
+ .org-variable-name {
326
+ /* font-lock-variable-name-face */
327
+ color: #f8f8f2;
328
+ }
329
+ .org-vertical-border {
330
+ /* vertical-border */
331
+ color: #373844;
332
+ }
333
+ .org-warning {
334
+ /* warning */
335
+ color: #ffb86c;
336
+ }
337
+ .org-warning-1 {
338
+ /* font-lock-warning-face */
339
+ color: #ffb86c;
340
+ background-color: #373844;
341
+ }
342
+ .org-which-func {
343
+ /* which-func */
344
+ color: #50fa7b;
345
+ font-weight: bold;
346
+ }