neruda 0.0.9 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. checksums.yaml +5 -5
  2. data/bin/pablo +135 -238
  3. data/lib/neruda/config.rb +137 -0
  4. data/lib/neruda/config/lisp_config.rb +254 -0
  5. data/lib/neruda/config/org-config.el +18 -0
  6. data/lib/neruda/config/ox-neruda.el +114 -0
  7. data/lib/neruda/emacs.rb +44 -0
  8. data/lib/neruda/index.rb +122 -0
  9. data/lib/neruda/index/atom_generator.rb +86 -0
  10. data/lib/neruda/index/org_generator.rb +115 -0
  11. data/lib/neruda/org_file.rb +299 -0
  12. data/lib/neruda/org_file/class_methods.rb +72 -0
  13. data/lib/neruda/org_file/extracter.rb +72 -0
  14. data/lib/neruda/org_file/htmlizer.rb +53 -0
  15. data/lib/neruda/preview.rb +55 -0
  16. data/lib/neruda/templater.rb +112 -0
  17. data/lib/neruda/utils.rb +212 -0
  18. data/lib/neruda/version.rb +6 -0
  19. data/lib/tasks/org.rake +84 -0
  20. data/lib/tasks/site.rake +86 -0
  21. data/lib/tasks/sync.rake +34 -0
  22. data/lib/tasks/tags.rake +19 -0
  23. data/locales/en.yml +37 -0
  24. data/locales/fr.yml +37 -0
  25. data/themes/default/css/htmlize.css +346 -0
  26. data/themes/default/css/style.css +153 -0
  27. data/themes/default/img/bottom.png +0 -0
  28. data/themes/default/img/tic.png +0 -0
  29. data/themes/default/img/top.png +0 -0
  30. metadata +153 -43
  31. data/README.md +0 -98
  32. data/docs/Rakefile.example +0 -4
  33. data/docs/config.yml.example +0 -17
  34. data/lib/assets/chapter.slim +0 -14
  35. data/lib/assets/index.slim +0 -13
  36. data/lib/assets/layout.slim +0 -17
  37. data/lib/assets/style.css +0 -199
  38. data/lib/neruda.rb +0 -106
  39. data/lib/neruda/chapter.rb +0 -26
  40. data/lib/neruda/url.rb +0 -14
  41. data/lib/tasks/book.rake +0 -60
  42. data/lib/tasks/capistrano/chapters.rake +0 -60
  43. data/lib/tasks/capistrano/sinatra.rake +0 -18
  44. data/lib/tasks/chapters.rake +0 -132
  45. data/lib/tasks/sinatra.rake +0 -36
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Neruda
4
+ # @return [String] the version number of the current Neruda release.
5
+ VERSION = '0.2.0'
6
+ end
@@ -0,0 +1,84 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'open-uri'
4
+
5
+ # Neruda::Config is required by Neruda::Utils
6
+ require 'neruda/utils'
7
+
8
+ namespace :org do
9
+ desc 'Download last version of Org'
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
26
+ verbose = Rake::FileUtilsExt.verbose_flag
27
+ org_version = "org-#{Neruda::Config.org_last_version}"
28
+ next if Dir.exist?("#{org_version}/lisp")
29
+ make = ['make', '-C', org_version]
30
+ unless verbose
31
+ make << '-s'
32
+ make << 'EMACSQ="emacs -Q --eval \'(setq inhibit-message t)\'"'
33
+ end
34
+ build = Thread.new do
35
+ tarball = "tmp/#{org_version}.tar.gz"
36
+ sh "tar xzf #{tarball}"
37
+ File.unlink tarball
38
+ sh((make + ['compile']).join(' '))
39
+ sh((make + ['autoloads']).join(' '))
40
+ Dir.glob('org-[0-9.]*').each do |ov|
41
+ next if ov == org_version
42
+ rm_r ov
43
+ end
44
+ end
45
+ if verbose
46
+ build.join
47
+ warn "#{org_version} has been locally installed"
48
+ else
49
+ Neruda::Utils.throbber(build, 'Installing Org:')
50
+ end
51
+ end
52
+
53
+ file 'htmlize.el' do
54
+ verbose = Rake::FileUtilsExt.verbose_flag
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
61
+ if verbose
62
+ build.join
63
+ warn 'htmlize.el has been locally installed'
64
+ else
65
+ Neruda::Utils.throbber(build, 'Installing htmlize.el:')
66
+ end
67
+ end
68
+
69
+ file 'org-config.el' => 'htmlize.el' do
70
+ Neruda::Config.write_org_lisp_config
71
+ end
72
+
73
+ file '.dir-locals.el' do
74
+ Neruda::Config.write_dir_locals
75
+ end
76
+
77
+ desc 'Install org'
78
+ task install: ['org:compile', 'org-config.el', '.dir-locals.el'] do
79
+ mkdir_p "#{Neruda::Config.settings['public_folder']}/assets"
80
+ Neruda::Config.sources.each do |s|
81
+ mkdir_p s['path'] unless Dir.exist? s['path']
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,86 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'neruda/emacs'
4
+ require 'neruda/index'
5
+ require 'neruda/utils'
6
+ require 'neruda/org_file'
7
+ require 'neruda/templater'
8
+
9
+ namespace :site do
10
+ desc 'Generates all index files'
11
+ task :index do
12
+ index = Neruda::Index.new
13
+ verbose = Rake::FileUtilsExt.verbose_flag
14
+ if verbose
15
+ index.write_all
16
+ next
17
+ end
18
+ build = Thread.new do
19
+ index.write_all(verbose: false)
20
+ end
21
+ Neruda::Utils.throbber(build, 'Generating indexes:')
22
+ next if index.empty?
23
+ Neruda::Config.write_org_lisp_config(with_tags: true)
24
+ end
25
+
26
+ desc 'Convert all org files'
27
+ task build: :index do
28
+ build_html = Thread.new do
29
+ Neruda::Emacs.new(verbose: Rake::FileUtilsExt.verbose_flag).publish
30
+ # TODO: Find a way to publish the virtual tag project
31
+ end
32
+ begin
33
+ Neruda::Utils.throbber(build_html, 'Building:')
34
+ # :nocov:
35
+ rescue RuntimeError
36
+ warn 'Aborting'
37
+ next
38
+ end
39
+ # :nocov:
40
+ customize_html = Thread.new do
41
+ pubfolder = Neruda::Config.settings['public_folder']
42
+ Dir["#{pubfolder}/**/*.html"].each do |f|
43
+ Neruda::Templater.customize_output(f)
44
+ end
45
+ end
46
+ Neruda::Utils.throbber(customize_html, 'Customizing:')
47
+ end
48
+
49
+ namespace :build do
50
+ desc 'Convert one org file'
51
+ task :one, :source do |_, args|
52
+ if args[:source].nil?
53
+ warn 'No source file given'
54
+ next
55
+ end
56
+ verbose = Rake::FileUtilsExt.verbose_flag
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
68
+ end
69
+ begin
70
+ Neruda::Utils.throbber(build_html, 'Building:')
71
+ rescue RuntimeError
72
+ warn 'Aborting'
73
+ next
74
+ end
75
+ target = Neruda::OrgFile.target_for_source(args[:source], project)
76
+ warn "Customizing file #{target}" if verbose
77
+ Neruda::Templater.customize_output(target, build_html[:org_file])
78
+ end
79
+ end
80
+
81
+ desc 'Start a test server'
82
+ task :preview do
83
+ require 'neruda/preview'
84
+ Neruda.start_preview
85
+ end
86
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'neruda/config'
4
+ require 'neruda/utils'
5
+
6
+ def rsync_command(verbose, test = nil)
7
+ rsync_command = Neruda::Config.settings['rsync']
8
+ return rsync_command unless rsync_command.nil?
9
+ optstring = []
10
+ optstring << 'n' if test
11
+ if verbose
12
+ optstring << 'v'
13
+ else
14
+ optstring << 'q'
15
+ end
16
+ "rsync -#{optstring.join}rlpD --delete"
17
+ end
18
+
19
+ namespace :sync do
20
+ desc 'Push change to server'
21
+ task :push, :test? do |_, args|
22
+ remote_path = Neruda::Config.settings['remote']
23
+ if remote_path.nil?
24
+ warn 'No remote path set'
25
+ next
26
+ end
27
+ public_folder = Neruda::Config.settings['public_folder']
28
+ publish_thread = Thread.new do
29
+ sh [rsync_command(Rake::FileUtilsExt.verbose_flag, args[:test?]),
30
+ "#{public_folder}/", remote_path].join(' ')
31
+ end
32
+ Neruda::Utils.throbber(publish_thread, 'Publishing:')
33
+ end
34
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'neruda/index'
4
+
5
+ namespace :tags do
6
+ desc 'List all tags by name'
7
+ task :name do
8
+ index = Neruda::Index.new
9
+ next if index.empty?
10
+ puts index.sort_by(:name).join("\n")
11
+ end
12
+
13
+ desc 'List all tags by weight'
14
+ task :weight do
15
+ index = Neruda::Index.new
16
+ next if index.empty?
17
+ puts index.sort_by(:weight).join("\n")
18
+ end
19
+ end
@@ -0,0 +1,37 @@
1
+ ---
2
+ pablo:
3
+ error:
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.
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
25
+ index:
26
+ unsorted: Unsorted
27
+ published_on: Published on %1
28
+ all_tags: All tags
29
+ by_name: By alphabetical order
30
+ by_weight: By publication number
31
+ full_date_format: '%A %{date}'
32
+ full_date_with_time_format: '%{date} at %{time}'
33
+ org:
34
+ postamble:
35
+ written_by: Written by %a
36
+ with_emacs: 'with %c, and published with %N'
37
+ last_modification: Last modification on %C
@@ -0,0 +1,37 @@
1
+ ---
2
+ pablo:
3
+ error:
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.
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
25
+ index:
26
+ unsorted: Non triés
27
+ published_on: Publié le %1
28
+ all_tags: Toutes les étiquettes
29
+ by_name: Par ordre alphabétique
30
+ by_weight: Par nombre de publication
31
+ full_date_format: '%A %{date}'
32
+ full_date_with_time_format: '%{date} à %{time}'
33
+ org:
34
+ postamble:
35
+ written_by: Écrit par %a
36
+ with_emacs: 'avec %c et publié avec %N'
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
+ }