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
data/docs/Rakefile.example
DELETED
data/docs/config.yml.example
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
---
|
2
|
-
|
3
|
-
title: My Awesome Title
|
4
|
-
author: Me Myself
|
5
|
-
# license: © Me
|
6
|
-
# lang: en_US
|
7
|
-
|
8
|
-
book_filename: my_awesome_title
|
9
|
-
|
10
|
-
## If we are behind a subfolder reverse proxy
|
11
|
-
# base_path: /subfolder
|
12
|
-
|
13
|
-
chapters:
|
14
|
-
- in_the
|
15
|
-
- order
|
16
|
-
- we_wish
|
17
|
-
- they_appear
|
data/lib/assets/chapter.slim
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
.chapter
|
2
|
-
h1.chapter-title = title
|
3
|
-
|
4
|
-
.chapter-meta
|
5
|
-
p.chapter-info
|
6
|
-
span.chapter-date = meta_data 'date'
|
7
|
-
br
|
8
|
-
span.chapter-epub
|
9
|
-
a href=proxy_url("/epub/#{@slug}") epub version
|
10
|
-
' -
|
11
|
-
span.chapter-permalink
|
12
|
-
a href=proxy_url("/chapter/#{@slug}") permalink
|
13
|
-
|
14
|
-
== @content.to_html
|
data/lib/assets/index.slim
DELETED
data/lib/assets/layout.slim
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
doctype html
|
2
|
-
html
|
3
|
-
head
|
4
|
-
title #{title}
|
5
|
-
meta name='author' content=author
|
6
|
-
link rel='stylesheet' href=proxy_url('/style.css') type='text/css'
|
7
|
-
|
8
|
-
body
|
9
|
-
#content
|
10
|
-
== yield
|
11
|
-
|
12
|
-
footer#footer.status
|
13
|
-
p © #{author}
|
14
|
-
p#gotop
|
15
|
-
a href=proxy_url('/') Accueil
|
16
|
-
' ·
|
17
|
-
a href='#top' Aller en haut
|
data/lib/assets/style.css
DELETED
@@ -1,199 +0,0 @@
|
|
1
|
-
body {
|
2
|
-
font-family: serif;
|
3
|
-
font-size: 20pt;
|
4
|
-
}
|
5
|
-
|
6
|
-
a:hover {
|
7
|
-
text-decoration: none;
|
8
|
-
}
|
9
|
-
|
10
|
-
dt {
|
11
|
-
font-weight: bold;
|
12
|
-
}
|
13
|
-
dt:after {
|
14
|
-
font-weight: bold;
|
15
|
-
content: ":";
|
16
|
-
}
|
17
|
-
|
18
|
-
figure {
|
19
|
-
text-align: center;
|
20
|
-
}
|
21
|
-
|
22
|
-
kbd {
|
23
|
-
border-width: .3em;
|
24
|
-
border-style: solid;
|
25
|
-
}
|
26
|
-
|
27
|
-
#content,
|
28
|
-
#footer,
|
29
|
-
.status {
|
30
|
-
width: 968px;
|
31
|
-
margin: 1em auto;
|
32
|
-
}
|
33
|
-
|
34
|
-
#content img {
|
35
|
-
max-width: 100%;
|
36
|
-
}
|
37
|
-
|
38
|
-
|
39
|
-
/**
|
40
|
-
* Content
|
41
|
-
*/
|
42
|
-
|
43
|
-
#content {
|
44
|
-
padding: 1em;
|
45
|
-
line-height: 1.5em;
|
46
|
-
}
|
47
|
-
|
48
|
-
#content h1.chapter-title {
|
49
|
-
margin: 0;
|
50
|
-
line-height: 1.5em;
|
51
|
-
}
|
52
|
-
|
53
|
-
.chapter-meta {
|
54
|
-
font-size: smaller;
|
55
|
-
padding: 0 .4em;
|
56
|
-
border-left-style: solid;
|
57
|
-
border-left-width: .4em;
|
58
|
-
border-radius: .4em;
|
59
|
-
}
|
60
|
-
.chapter-meta p {
|
61
|
-
margin: .3em 0;
|
62
|
-
}
|
63
|
-
|
64
|
-
.src {
|
65
|
-
font-family: Inconsolata, monospace;
|
66
|
-
font-size: 1em;
|
67
|
-
display:block;
|
68
|
-
padding-left:.4em;
|
69
|
-
margin:1em 1.5em;
|
70
|
-
line-height:1.5em;
|
71
|
-
border-left-width: .4em;
|
72
|
-
border-left-style: solid;
|
73
|
-
border-radius: .4em;
|
74
|
-
overflow-x: auto;
|
75
|
-
}
|
76
|
-
|
77
|
-
blockquote {
|
78
|
-
display: block;
|
79
|
-
padding: 0 1.5em;
|
80
|
-
font-style: italic;
|
81
|
-
margin: 1em 0;
|
82
|
-
}
|
83
|
-
blockquote::after {
|
84
|
-
display: table;
|
85
|
-
content: "";
|
86
|
-
clear: both;
|
87
|
-
}
|
88
|
-
blockquote>*:first-child::before {
|
89
|
-
content: "« ";
|
90
|
-
font-size: 3em;
|
91
|
-
}
|
92
|
-
blockquote>*:last-child::after {
|
93
|
-
content: " »";
|
94
|
-
font-size: 2em;
|
95
|
-
}
|
96
|
-
|
97
|
-
div.footnotes,
|
98
|
-
.footdef {
|
99
|
-
font-size: smaller;
|
100
|
-
}
|
101
|
-
div.footnotes::before,
|
102
|
-
.footdef::before {
|
103
|
-
content: "---";
|
104
|
-
display: block;
|
105
|
-
}
|
106
|
-
div.footnotes,
|
107
|
-
.footdef sup {
|
108
|
-
font-size: smaller;
|
109
|
-
}
|
110
|
-
|
111
|
-
#content .chapter::after {
|
112
|
-
content: "❦";
|
113
|
-
font-size: xx-large;
|
114
|
-
display: block;
|
115
|
-
text-align: center;
|
116
|
-
}
|
117
|
-
|
118
|
-
/**
|
119
|
-
* Footer
|
120
|
-
*/
|
121
|
-
#gotop {
|
122
|
-
position: fixed;
|
123
|
-
bottom: 0em;
|
124
|
-
right: 1em;
|
125
|
-
font-size: smaller;
|
126
|
-
}
|
127
|
-
|
128
|
-
#footer {
|
129
|
-
clear: both;
|
130
|
-
padding-top: 0;
|
131
|
-
font-size: smaller;
|
132
|
-
margin-bottom: .5em;
|
133
|
-
}
|
134
|
-
|
135
|
-
/**
|
136
|
-
* Responsive...
|
137
|
-
*/
|
138
|
-
@media screen and (max-width: 968px) {
|
139
|
-
#content, .status {
|
140
|
-
width: 90%;
|
141
|
-
}
|
142
|
-
}
|
143
|
-
|
144
|
-
|
145
|
-
/**
|
146
|
-
* Colors
|
147
|
-
* We used the Dracula color theme
|
148
|
-
* https://draculatheme.com/
|
149
|
-
*/
|
150
|
-
|
151
|
-
body {
|
152
|
-
background: #282a36;
|
153
|
-
color: #f8f8f2;
|
154
|
-
}
|
155
|
-
|
156
|
-
h1 {
|
157
|
-
color: #ffb86c;
|
158
|
-
}
|
159
|
-
|
160
|
-
h2 {
|
161
|
-
color: #bd93f9;
|
162
|
-
}
|
163
|
-
|
164
|
-
a:link, a:visited {
|
165
|
-
color: #ff79c6;
|
166
|
-
}
|
167
|
-
|
168
|
-
kbd {
|
169
|
-
border-color: #f8f8f2;
|
170
|
-
}
|
171
|
-
|
172
|
-
code {
|
173
|
-
background: #373844;
|
174
|
-
color: #e2e2dc;
|
175
|
-
}
|
176
|
-
|
177
|
-
mark {
|
178
|
-
background: #f1fa8c;
|
179
|
-
}
|
180
|
-
|
181
|
-
.chapter-meta {
|
182
|
-
border-left-color: #373844;
|
183
|
-
background-color: #464752;
|
184
|
-
}
|
185
|
-
|
186
|
-
.src {
|
187
|
-
border-left-color: #bd93f9;
|
188
|
-
}
|
189
|
-
|
190
|
-
blockquote>*:first-child::before {
|
191
|
-
color: #50fa7b;
|
192
|
-
}
|
193
|
-
blockquote>*:last-child::after {
|
194
|
-
color: #50fa7b;
|
195
|
-
}
|
196
|
-
|
197
|
-
.comment-content {
|
198
|
-
border-left-color: #bd93f9;
|
199
|
-
}
|
data/lib/neruda.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'yaml'
|
5
|
-
require 'org-ruby'
|
6
|
-
require 'sinatra/base'
|
7
|
-
|
8
|
-
# Namespacing
|
9
|
-
module Neruda
|
10
|
-
CONFIG = YAML.load_file(File.join('config', 'config.yml')).freeze
|
11
|
-
end
|
12
|
-
|
13
|
-
# The following must be required after to allow compact name style
|
14
|
-
require 'neruda/url'
|
15
|
-
require 'neruda/chapter'
|
16
|
-
|
17
|
-
# Main Sinatra application
|
18
|
-
class Neruda::App < Sinatra::Base
|
19
|
-
configure :production, :development do
|
20
|
-
# When used as a Gem, we lose the correct path.
|
21
|
-
set :root, Dir.pwd
|
22
|
-
enable :logging
|
23
|
-
disable :method_override, :sessions
|
24
|
-
mime_type :epub, 'application/epub+zip'
|
25
|
-
end
|
26
|
-
|
27
|
-
include Neruda::Url
|
28
|
-
include Neruda::Chapter
|
29
|
-
|
30
|
-
def chdir
|
31
|
-
Dir.chdir settings.root if ENV['APP_ENV'] == 'production'
|
32
|
-
end
|
33
|
-
|
34
|
-
def find_slug
|
35
|
-
@slug = params[:chapter]
|
36
|
-
halt 404 if @slug.nil?
|
37
|
-
end
|
38
|
-
|
39
|
-
def find_file(kind = 'org')
|
40
|
-
if kind == 'epub'
|
41
|
-
f = File.join('private', 'epubs', "#{@slug}.epub")
|
42
|
-
elsif kind == 'chapters'
|
43
|
-
f = File.join('private', 'chapters', "#{@slug}.org")
|
44
|
-
else
|
45
|
-
f = File.join('private', "#{@slug}.#{kind}")
|
46
|
-
end
|
47
|
-
halt 404 unless File.exist? f
|
48
|
-
f
|
49
|
-
end
|
50
|
-
|
51
|
-
get '/epub/:chapter' do
|
52
|
-
chdir
|
53
|
-
find_slug
|
54
|
-
if @slug == 'all' && !Neruda::CONFIG['book_filename'].nil?
|
55
|
-
@slug = Neruda::CONFIG['book_filename']
|
56
|
-
end
|
57
|
-
epub_file = find_file('epub')
|
58
|
-
halt 404 unless File.exist? epub_file
|
59
|
-
content_type :epub
|
60
|
-
send_file epub_file, filename: "#{@slug}.epub"
|
61
|
-
end
|
62
|
-
|
63
|
-
get '/chapter/:chapter' do
|
64
|
-
chdir
|
65
|
-
find_slug
|
66
|
-
@org_file = find_file('chapters')
|
67
|
-
@content = Orgmode::Parser.load @org_file
|
68
|
-
title # Force the early removal of the title
|
69
|
-
slim :chapter
|
70
|
-
end
|
71
|
-
|
72
|
-
unless Neruda::CONFIG['base_path'].nil?
|
73
|
-
# If we are behind a misconfigured subfolder reverse proxy, this one
|
74
|
-
# could be usefull
|
75
|
-
get Neruda::CONFIG['base_path'] do
|
76
|
-
call env.merge('PATH_INFO' => '/')
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
get '/' do
|
81
|
-
chdir
|
82
|
-
@slug = 'index'
|
83
|
-
text_content = ''
|
84
|
-
if File.exist? File.join('private', 'index.org')
|
85
|
-
@org_file = find_file
|
86
|
-
@content = Orgmode::Parser.load @org_file
|
87
|
-
title
|
88
|
-
text_content = @content.to_html
|
89
|
-
end
|
90
|
-
|
91
|
-
@chapters = []
|
92
|
-
if File.exist? File.join('config', 'chapters.yml')
|
93
|
-
@chapters = YAML.load_file(File.join('config', 'chapters.yml'))
|
94
|
-
end
|
95
|
-
|
96
|
-
slim :index, locals: { text: text_content }
|
97
|
-
end
|
98
|
-
|
99
|
-
error 403 do
|
100
|
-
slim 'h1 Access forbidden'
|
101
|
-
end
|
102
|
-
|
103
|
-
error 404 do
|
104
|
-
slim 'h1 Not Found'
|
105
|
-
end
|
106
|
-
end
|
data/lib/neruda/chapter.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# Various method to handle org conversion and metadata access
|
4
|
-
module Neruda::Chapter
|
5
|
-
def meta_data(key)
|
6
|
-
return nil if @content.nil?
|
7
|
-
value = @content.in_buffer_settings[key.upcase]
|
8
|
-
return value if value.nil? || !key.casecmp('date').zero?
|
9
|
-
time_for(value).strftime('%A %d %B %Y')
|
10
|
-
end
|
11
|
-
|
12
|
-
def title
|
13
|
-
return Neruda::CONFIG['title'] if @content.nil?
|
14
|
-
return @title unless @title.nil?
|
15
|
-
# We use an instance variable to avoid Orgmode::Parser to render
|
16
|
-
# title with the rest of the file
|
17
|
-
# Thus we are removing title from the buffer_settings
|
18
|
-
@title = @content.in_buffer_settings.delete('TITLE')
|
19
|
-
return @title unless @title.nil?
|
20
|
-
@title = Neruda::CONFIG['title']
|
21
|
-
end
|
22
|
-
|
23
|
-
def author
|
24
|
-
meta_data('author') || Neruda::CONFIG['author']
|
25
|
-
end
|
26
|
-
end
|
data/lib/neruda/url.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'uri'
|
4
|
-
|
5
|
-
# Various method to ease url handling
|
6
|
-
module Neruda::Url
|
7
|
-
def proxy_url(url)
|
8
|
-
wanted_uri = url(url)
|
9
|
-
return wanted_uri if Neruda::CONFIG['base_path'].nil?
|
10
|
-
uri_data = URI.parse(wanted_uri)
|
11
|
-
uri_data.path = Neruda::CONFIG['base_path'] + uri_data.path
|
12
|
-
uri_data.to_s
|
13
|
-
end
|
14
|
-
end
|
data/lib/tasks/book.rake
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'yaml'
|
4
|
-
require 'rainbow'
|
5
|
-
|
6
|
-
namespace :book do
|
7
|
-
desc 'List various book elements'
|
8
|
-
task :list, :list_type do |_, args|
|
9
|
-
list_type = args[:list_type]
|
10
|
-
unless ['chapters', 'characters',
|
11
|
-
'notes', 'sceneries'].include?(list_type)
|
12
|
-
STDERR.puts Rainbow("ERROR: #{list_type} is not a valid list type.").red
|
13
|
-
STDERR.puts 'Enter one of [chapters, characters, notes, sceneries].'
|
14
|
-
next
|
15
|
-
end
|
16
|
-
Dir.glob("private/#{list_type}/*.org") do |filename|
|
17
|
-
file_radix = File.basename(filename, '.org')
|
18
|
-
title = file_radix.split('_').map(&:capitalize).join(' ')
|
19
|
-
absolute_filename = File.join(Dir.pwd, filename)
|
20
|
-
puts Rainbow(title).blue + ": #{absolute_filename}"
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
desc 'Create the org file of the complete book'
|
25
|
-
task prepare: 'chapters:index' do
|
26
|
-
chapters = YAML.load_file('config/chapters.yml')
|
27
|
-
next if chapters.nil?
|
28
|
-
|
29
|
-
neruda_config = YAML.load_file('config/config.yml')
|
30
|
-
final_org = neruda_config['book_filename'] || 'all'
|
31
|
-
final_org = "tmp/#{final_org}.org"
|
32
|
-
|
33
|
-
Dir.mkdir 'tmp' unless Dir.exist? 'tmp'
|
34
|
-
File.unlink final_org if File.exist? final_org
|
35
|
-
|
36
|
-
org_file = File.open(final_org, 'a')
|
37
|
-
org_file.write("#+title: #{neruda_config['title']}\n")
|
38
|
-
org_file.write("#+author: #{neruda_config['author']}\n")
|
39
|
-
org_file.write("#+rights: #{neruda_config['license']}\n")
|
40
|
-
org_file.write("#+language: #{neruda_config['lang']}\n\n")
|
41
|
-
|
42
|
-
chapters.each do |c|
|
43
|
-
file_radix = c[:slug]
|
44
|
-
filename = "private/chapters/#{file_radix}.org"
|
45
|
-
next unless File.exist? filename
|
46
|
-
file_content = IO.read(filename)
|
47
|
-
file_content.gsub!(/^#\+date:.*$/i, '')
|
48
|
-
file_content.gsub!(/^#\+author:.*$/i, '')
|
49
|
-
file_content.gsub!(/^(\*+)\s+(.*)$/i, '*\1 \2')
|
50
|
-
file_content.gsub!(/^#\+title:\s?(.*)$/i, '* \1')
|
51
|
-
|
52
|
-
org_file.write(file_content + "\n")
|
53
|
-
end
|
54
|
-
org_file.close
|
55
|
-
|
56
|
-
IO.write 'tmp/org_to_convert.yml', [final_org].to_yaml
|
57
|
-
end
|
58
|
-
|
59
|
-
task make: ['book:prepare', 'chapters:convert_org']
|
60
|
-
end
|