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.
- checksums.yaml +5 -5
- data/bin/pablo +135 -238
- data/lib/neruda/config.rb +137 -0
- data/lib/neruda/config/lisp_config.rb +254 -0
- data/lib/neruda/config/org-config.el +18 -0
- data/lib/neruda/config/ox-neruda.el +114 -0
- data/lib/neruda/emacs.rb +44 -0
- data/lib/neruda/index.rb +122 -0
- data/lib/neruda/index/atom_generator.rb +86 -0
- data/lib/neruda/index/org_generator.rb +115 -0
- data/lib/neruda/org_file.rb +299 -0
- data/lib/neruda/org_file/class_methods.rb +72 -0
- data/lib/neruda/org_file/extracter.rb +72 -0
- data/lib/neruda/org_file/htmlizer.rb +53 -0
- data/lib/neruda/preview.rb +55 -0
- data/lib/neruda/templater.rb +112 -0
- data/lib/neruda/utils.rb +212 -0
- data/lib/neruda/version.rb +6 -0
- data/lib/tasks/org.rake +84 -0
- data/lib/tasks/site.rake +86 -0
- data/lib/tasks/sync.rake +34 -0
- data/lib/tasks/tags.rake +19 -0
- data/locales/en.yml +37 -0
- data/locales/fr.yml +37 -0
- data/themes/default/css/htmlize.css +346 -0
- data/themes/default/css/style.css +153 -0
- data/themes/default/img/bottom.png +0 -0
- data/themes/default/img/tic.png +0 -0
- data/themes/default/img/top.png +0 -0
- metadata +153 -43
- data/README.md +0 -98
- data/docs/Rakefile.example +0 -4
- data/docs/config.yml.example +0 -17
- data/lib/assets/chapter.slim +0 -14
- data/lib/assets/index.slim +0 -13
- data/lib/assets/layout.slim +0 -17
- data/lib/assets/style.css +0 -199
- data/lib/neruda.rb +0 -106
- data/lib/neruda/chapter.rb +0 -26
- data/lib/neruda/url.rb +0 -14
- data/lib/tasks/book.rake +0 -60
- data/lib/tasks/capistrano/chapters.rake +0 -60
- data/lib/tasks/capistrano/sinatra.rake +0 -18
- data/lib/tasks/chapters.rake +0 -132
- data/lib/tasks/sinatra.rake +0 -36
@@ -1,60 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'yaml'
|
4
|
-
|
5
|
-
namespace :chapters do
|
6
|
-
desc 'Upload epub files listed in tmp/epub_to_upload.yml'
|
7
|
-
task :upload_epubs do
|
8
|
-
next unless File.exist?('tmp/epub_to_upload.yml')
|
9
|
-
epub_to_upload = YAML.load_file('tmp/epub_to_upload.yml')
|
10
|
-
next if epub_to_upload.empty?
|
11
|
-
on roles(:app) do
|
12
|
-
epub_to_upload.each do |f|
|
13
|
-
upload! f, "#{shared_path}/#{f}"
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
desc 'Upload the chapters list index'
|
19
|
-
task upload_index: 'chapters:index' do
|
20
|
-
on roles(:app) do
|
21
|
-
upload! 'config/chapters.yml', "#{release_path}/config/chapters.yml"
|
22
|
-
info 'chatpers.yml has been built and uploaded'
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
desc 'Upload the complete book'
|
27
|
-
task upload_book: ['book:make', 'chapters:upload_epubs']
|
28
|
-
|
29
|
-
namespace :purge do
|
30
|
-
desc 'Remove remote orphaned epub files'
|
31
|
-
task :remote do
|
32
|
-
neruda_config = YAML.load_file('config/config.yml')
|
33
|
-
final_org = neruda_config['book_filename'] || 'all'
|
34
|
-
on roles(:app) do
|
35
|
-
within release_path do
|
36
|
-
begin
|
37
|
-
epub_files = capture :ls, '-1', 'private/epubs/*.epub'
|
38
|
-
rescue SSHKit::Command::Failed
|
39
|
-
warn 'No epub files found. Aborting.'
|
40
|
-
next
|
41
|
-
end
|
42
|
-
epub_files.each_line do |filename|
|
43
|
-
filename.delete!("\n")
|
44
|
-
file_radix = File.basename(filename, '.epub')
|
45
|
-
next if file_radix == final_org
|
46
|
-
org_file = "private/chapters/#{file_radix}.org"
|
47
|
-
unless test("[ -e '#{release_path}/#{org_file}' ]")
|
48
|
-
execute :rm, filename
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
desc 'Execute in one call the following: :build_epubs,' \
|
57
|
-
':upload_epubs, :upload_book, :purge:remote'
|
58
|
-
task sync: ['chapters:build_epubs', 'chapters:upload_epubs',
|
59
|
-
'chapters:upload_book', 'chapters:purge:remote']
|
60
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
namespace :sinatra do
|
4
|
-
namespace :restart do
|
5
|
-
desc 'Restart the remote neruda application'
|
6
|
-
task :remote do
|
7
|
-
on roles(:app) do
|
8
|
-
within release_path do
|
9
|
-
if test("[ -e '#{release_path}/tmp/pids/sinatra.pid' ]")
|
10
|
-
execute :pkill, '-F', 'tmp/pids/sinatra.pid'
|
11
|
-
end
|
12
|
-
execute :bundle, :exec, :rackup, '-E', fetch(:app_env),
|
13
|
-
'-P', 'tmp/pids/sinatra.pid', '-D'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
data/lib/tasks/chapters.rake
DELETED
@@ -1,132 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'yaml'
|
4
|
-
|
5
|
-
namespace :chapters do
|
6
|
-
desc 'Identify all org files'
|
7
|
-
task :list_all_orgs do
|
8
|
-
org_to_convert = []
|
9
|
-
File.unlink 'tmp/org_to_convert.yml' if File.exist? 'tmp/org_to_convert.yml'
|
10
|
-
neruda_config = YAML.load_file('config/config.yml')
|
11
|
-
chapters = neruda_config['chapters']
|
12
|
-
next unless chapters.any?
|
13
|
-
chapters.each do |file_radix|
|
14
|
-
filename = "private/chapters/#{file_radix}.org"
|
15
|
-
org_to_convert << filename
|
16
|
-
end
|
17
|
-
next if org_to_convert.empty?
|
18
|
-
Dir.mkdir 'tmp' unless Dir.exist? 'tmp'
|
19
|
-
IO.write 'tmp/org_to_convert.yml', org_to_convert.to_yaml
|
20
|
-
end
|
21
|
-
|
22
|
-
desc 'Identify orphan (without epubs) org files'
|
23
|
-
task list_orphaned_orgs: 'chapters:list_all_orgs' do
|
24
|
-
next unless File.exist? 'tmp/org_to_convert.yml'
|
25
|
-
org_to_convert = []
|
26
|
-
chapters = YAML.load_file('tmp/org_to_convert.yml')
|
27
|
-
next unless chapters.any?
|
28
|
-
chapters.each do |filename|
|
29
|
-
file_radix = File.basename(filename, '.org')
|
30
|
-
epub_file = "private/epubs/#{file_radix}.epub"
|
31
|
-
org_to_convert << filename unless File.exist? epub_file
|
32
|
-
end
|
33
|
-
next if org_to_convert.empty?
|
34
|
-
IO.write 'tmp/org_to_convert.yml', org_to_convert.to_yaml
|
35
|
-
end
|
36
|
-
|
37
|
-
desc 'Convert org files from tmp/org_to_convert.yml to epubs'
|
38
|
-
task :convert_org do
|
39
|
-
next unless File.exist?('tmp/org_to_convert.yml')
|
40
|
-
File.unlink 'tmp/epub_to_upload.yml' if File.exist? 'tmp/epub_to_upload.yml'
|
41
|
-
org_to_convert = YAML.load_file('tmp/org_to_convert.yml')
|
42
|
-
next if org_to_convert.empty?
|
43
|
-
epub_to_upload = []
|
44
|
-
org_to_convert.each do |filename|
|
45
|
-
file_radix = File.basename(filename, '.org')
|
46
|
-
epub_file = "private/epubs/#{file_radix}.epub"
|
47
|
-
epub_to_upload << epub_file
|
48
|
-
puts "Converting #{filename} to #{epub_file}"
|
49
|
-
sh 'pandoc', '-S', "--output=#{epub_file}", filename
|
50
|
-
end
|
51
|
-
next if epub_to_upload.empty?
|
52
|
-
IO.write 'tmp/epub_to_upload.yml', epub_to_upload.to_yaml
|
53
|
-
end
|
54
|
-
|
55
|
-
desc 'Build missing epubs'
|
56
|
-
task build_epubs: ['chapters:list_orphaned_orgs', 'chapters:convert_org']
|
57
|
-
|
58
|
-
namespace :build_epubs do
|
59
|
-
desc '(re)Build all epub files for each org files'
|
60
|
-
task force_all: ['chapters:list_all_orgs', 'chapters:convert_org']
|
61
|
-
end
|
62
|
-
|
63
|
-
desc 'Remove orphaned (epub without org files) epub files'
|
64
|
-
task :purge do
|
65
|
-
neruda_config = YAML.load_file('config/config.yml')
|
66
|
-
final_org = neruda_config['book_filename'] || 'all'
|
67
|
-
chapters = neruda_config['chapters']
|
68
|
-
Dir.glob('private/chapters/*.org') do |filename|
|
69
|
-
file_radix = File.basename(filename, '.org')
|
70
|
-
unless chapters.include? file_radix
|
71
|
-
STDERR.puts "WARNING: #{filename} exists but #{file_radix} " \
|
72
|
-
'is no more in the chapters list.'
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
Dir.glob('private/epubs/*.epub') do |filename|
|
77
|
-
file_radix = File.basename(filename, '.epub')
|
78
|
-
next if file_radix == final_org
|
79
|
-
org_file = "private/chapters/#{file_radix}.org"
|
80
|
-
File.unlink filename unless File.exist? org_file
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
desc 'Create/Update the chapters list index'
|
85
|
-
task :index do
|
86
|
-
require 'org-ruby'
|
87
|
-
neruda_config = YAML.load_file('config/config.yml')
|
88
|
-
next if neruda_config['chapters'].nil?
|
89
|
-
chapters = []
|
90
|
-
neruda_config['chapters'].each do |file_radix|
|
91
|
-
filename = "private/chapters/#{file_radix}.org"
|
92
|
-
next unless File.exist? filename
|
93
|
-
f = Orgmode::Parser.load filename
|
94
|
-
title = f.in_buffer_settings['TITLE']
|
95
|
-
chapters << { slug: file_radix, title: title } unless title.nil?
|
96
|
-
end
|
97
|
-
IO.write 'config/chapters.yml', chapters.to_yaml
|
98
|
-
end
|
99
|
-
|
100
|
-
desc 'Open an editor to create a new chapter'
|
101
|
-
task :create_or_edit, :title do |_, args|
|
102
|
-
if args[:title] == ''
|
103
|
-
filename = 'new'
|
104
|
-
else
|
105
|
-
filename = args[:title].tr(' ', '_').downcase.gsub(/[^a-z0-9_]/, '')
|
106
|
-
end
|
107
|
-
|
108
|
-
filename = "private/chapters/#{filename}.org"
|
109
|
-
|
110
|
-
unless File.exist? filename
|
111
|
-
config = YAML.load_file('config/config.yml')
|
112
|
-
filecontent = <<~ORG
|
113
|
-
#+title: #{args[:title]}
|
114
|
-
#+date: <#{Date.today.strftime('%Y-%m-%d %a.')}>
|
115
|
-
#+author: #{config['author']}
|
116
|
-
|
117
|
-
ORG
|
118
|
-
IO.write filename, filecontent
|
119
|
-
end
|
120
|
-
|
121
|
-
editor = ENV['EDITOR'] || ENV['VISUAL'] || 'emacs'
|
122
|
-
|
123
|
-
puts Rainbow(args[:title]).blue
|
124
|
-
puts "Opening #{filename} with #{editor}"
|
125
|
-
|
126
|
-
if editor.match?(/^emacs/)
|
127
|
-
sh [editor, '+5', filename].join(' ')
|
128
|
-
else
|
129
|
-
sh [editor, filename].join(' ')
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
data/lib/tasks/sinatra.rake
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rainbow'
|
4
|
-
|
5
|
-
namespace :sinatra do
|
6
|
-
desc 'Stop the underlaying sinatra application'
|
7
|
-
task :stop do
|
8
|
-
unless File.exist? 'tmp/pids/neruda.pid'
|
9
|
-
STDERR.puts Rainbow('No pid file found').red
|
10
|
-
exit 1
|
11
|
-
end
|
12
|
-
pid = IO.read('tmp/pids/neruda.pid').strip.to_i
|
13
|
-
Process.kill('TERM', pid)
|
14
|
-
File.unlink 'tmp/pids/neruda.pid'
|
15
|
-
puts Rainbow('Done').green
|
16
|
-
end
|
17
|
-
|
18
|
-
desc 'Start the underlaying sinatra application'
|
19
|
-
task :start do
|
20
|
-
loc_env = ENV['APP_ENV'] || 'development'
|
21
|
-
cmd = ['rackup', "-E #{loc_env}", '-P', 'tmp/pids/neruda.pid']
|
22
|
-
cmd << '-D' if loc_env == 'production'
|
23
|
-
begin
|
24
|
-
if ENV['APP_ENV'].nil?
|
25
|
-
system({ 'APP_ENV' => loc_env }, cmd.join(' '))
|
26
|
-
else
|
27
|
-
sh(*cmd)
|
28
|
-
end
|
29
|
-
rescue Interrupt
|
30
|
-
puts Rainbow('Kthxbye').blue
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
desc 'Restart local sinatra server'
|
35
|
-
task restart: ['sinatra:stop', 'sinatra:start']
|
36
|
-
end
|