neruda 0.0.10 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/bin/pablo +105 -246
- data/lib/neruda/config.rb +94 -0
- data/lib/neruda/config/lisp_config.rb +201 -0
- data/lib/neruda/config/org-config.el +17 -0
- data/lib/neruda/config/ox-neruda.el +88 -0
- data/lib/neruda/index.rb +108 -0
- data/lib/neruda/index/atom_generator.rb +86 -0
- data/lib/neruda/index/org_generator.rb +92 -0
- data/lib/neruda/org_file.rb +266 -0
- data/lib/neruda/org_file/class_methods.rb +55 -0
- data/lib/neruda/org_file/extracter.rb +61 -0
- data/lib/neruda/org_file/htmlizer.rb +78 -0
- data/lib/neruda/preview.rb +53 -0
- data/lib/neruda/templater.rb +111 -0
- data/lib/neruda/utils.rb +130 -0
- data/lib/neruda/version.rb +5 -0
- data/lib/tasks/org.rake +69 -0
- data/lib/tasks/site.rake +84 -0
- data/lib/tasks/sync.rake +30 -0
- data/locales/en.yml +18 -0
- data/locales/fr.yml +18 -0
- data/themes/default/css/style.css +216 -0
- data/themes/default/fonts/Yanone_Kaffeesatz_400.woff +0 -0
- data/themes/default/fonts/Yanone_Kaffeesatz_400.woff2 +0 -0
- metadata +145 -39
- 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 -112
- 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/README.md
DELETED
@@ -1,98 +0,0 @@
|
|
1
|
-
![](https://badge.fury.io/rb/neruda.svg)
|
2
|
-
|
3
|
-
**Neruda** is a little [Sinatra](http://sinatrarb.com) app, which aims to offer a quick access for writers to web publication. It is named in memory of Pablo Neruda.
|
4
|
-
|
5
|
-
Source code is available on my [cgit instance](https://git.deparis.io/neruda), while issues should be followed on my [redmine instance](https://projects.deparis.io/projects/neruda).
|
6
|
-
|
7
|
-
Install
|
8
|
-
=======
|
9
|
-
|
10
|
-
These installation instructions use [rvm](https://rvm.io) as ruby provider. If you want to use rbenv or your system ruby, please refer to their specific documentation to know how to install ruby 2.4.
|
11
|
-
|
12
|
-
First we need to upgrade rvm (always do that from time to time):
|
13
|
-
|
14
|
-
``` bash
|
15
|
-
$ rvm get latest
|
16
|
-
$ rvm install ruby-2.4.1
|
17
|
-
```
|
18
|
-
|
19
|
-
Then the installation itself:
|
20
|
-
|
21
|
-
``` bash
|
22
|
-
$ mkdir mysite
|
23
|
-
$ rvm use ruby-2.4.1@neruda --create
|
24
|
-
$ gem install neruda
|
25
|
-
```
|
26
|
-
|
27
|
-
Finally, you need to configure it to your needs.
|
28
|
-
|
29
|
-
``` bash
|
30
|
-
$ pablo setup
|
31
|
-
```
|
32
|
-
|
33
|
-
Running it
|
34
|
-
==========
|
35
|
-
|
36
|
-
For testing it, you should just run:
|
37
|
-
|
38
|
-
``` bash
|
39
|
-
$ pablo start
|
40
|
-
```
|
41
|
-
|
42
|
-
For production use, just pass the right environnement variable:
|
43
|
-
|
44
|
-
``` bash
|
45
|
-
$ APP_ENV=production pablo start
|
46
|
-
```
|
47
|
-
|
48
|
-
To stop it, just enter `ctrl+C` if you are in development mode or enter `pablo stop` in production mode.
|
49
|
-
|
50
|
-
Pablo command
|
51
|
-
=============
|
52
|
-
|
53
|
-
In order to manage you Neruda installation, this gem provides a little helper called `pablo`. You already used it to `setup`, `start` and `stop` your local installation. It can do a little more.
|
54
|
-
|
55
|
-
New
|
56
|
-
---
|
57
|
-
|
58
|
-
`pablo new [article title]` will open your favorite text editor to let you write a new chapter to your book.
|
59
|
-
|
60
|
-
If you don't provide a title to the command, `pablo` will ask you for one before launching your editor.
|
61
|
-
|
62
|
-
If you don't have configured the `EDITOR` or `VISUAL` environnement variable, `pablo` will default to Gnu Emacs.
|
63
|
-
|
64
|
-
Compile
|
65
|
-
-------
|
66
|
-
|
67
|
-
`pablo compile` will first convert your orphaned org files (the ones without a corresponding epub file), then producing the global epub book, made with all your chapters.
|
68
|
-
|
69
|
-
Capify
|
70
|
-
------
|
71
|
-
|
72
|
-
`pablo capify` will add the correct references to Neruda rake tasks in your `Capfile`, what will allow you to call them as part of your deployment workflow.
|
73
|
-
|
74
|
-
You can add the `chapters:sync` task:
|
75
|
-
|
76
|
-
``` ruby
|
77
|
-
after 'deploy:finishing', 'chapters:sync'
|
78
|
-
```
|
79
|
-
|
80
|
-
This task depends on all the following. Or you can just select a bunch of them:
|
81
|
-
|
82
|
-
``` ruby
|
83
|
-
after 'deploy:finishing', 'chapters:build_epubs'
|
84
|
-
after 'deploy:finishing', 'chapters:upload_epubs'
|
85
|
-
after 'deploy:finishing', 'chapters:upload_book'
|
86
|
-
after 'deploy:finishing', 'chapters:purge:remote'
|
87
|
-
```
|
88
|
-
|
89
|
-
Don't forget to restart the remote sinatra server:
|
90
|
-
|
91
|
-
``` ruby
|
92
|
-
after 'deploy:finished', 'sinatra:restart:remote'
|
93
|
-
```
|
94
|
-
|
95
|
-
Known issues
|
96
|
-
============
|
97
|
-
|
98
|
-
See [issues on redmine](https://projects.deparis.io/projects/neruda/issues).
|
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,112 +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
|
-
disable :logging, :method_override, :sessions
|
23
|
-
mime_type :epub, 'application/epub+zip'
|
24
|
-
end
|
25
|
-
|
26
|
-
include Neruda::Url
|
27
|
-
include Neruda::Chapter
|
28
|
-
|
29
|
-
def chdir
|
30
|
-
loc_env = 'development'
|
31
|
-
if ENV.key? 'APP_ENV'
|
32
|
-
loc_env = ENV['APP_ENV']
|
33
|
-
elsif ENV.key? 'RACK_ENV'
|
34
|
-
loc_env = ENV['RACK_ENV']
|
35
|
-
end
|
36
|
-
Dir.chdir settings.root if loc_env == 'production'
|
37
|
-
end
|
38
|
-
|
39
|
-
def find_slug
|
40
|
-
@slug = params[:chapter]
|
41
|
-
halt 404 if @slug.nil?
|
42
|
-
end
|
43
|
-
|
44
|
-
def find_file(kind = 'org')
|
45
|
-
if kind == 'epub'
|
46
|
-
f = File.join('private', 'epubs', "#{@slug}.epub")
|
47
|
-
elsif kind == 'chapters'
|
48
|
-
f = File.join('private', 'chapters', "#{@slug}.org")
|
49
|
-
else
|
50
|
-
f = File.join('private', "#{@slug}.#{kind}")
|
51
|
-
end
|
52
|
-
halt 404 unless File.exist? f
|
53
|
-
f
|
54
|
-
end
|
55
|
-
|
56
|
-
get '/epub/:chapter' do
|
57
|
-
chdir
|
58
|
-
find_slug
|
59
|
-
if @slug == 'all' && !Neruda::CONFIG['book_filename'].nil?
|
60
|
-
@slug = Neruda::CONFIG['book_filename']
|
61
|
-
end
|
62
|
-
epub_file = find_file('epub')
|
63
|
-
halt 404 unless File.exist? epub_file
|
64
|
-
content_type :epub
|
65
|
-
send_file epub_file, filename: "#{@slug}.epub"
|
66
|
-
end
|
67
|
-
|
68
|
-
get '/chapter/:chapter' do
|
69
|
-
chdir
|
70
|
-
find_slug
|
71
|
-
@org_file = find_file('chapters')
|
72
|
-
@content = Orgmode::Parser.load @org_file
|
73
|
-
title # Force the early removal of the title
|
74
|
-
slim :chapter
|
75
|
-
end
|
76
|
-
|
77
|
-
unless Neruda::CONFIG['base_path'].nil?
|
78
|
-
# If we are behind a misconfigured subfolder reverse proxy, this one
|
79
|
-
# could be usefull
|
80
|
-
get Neruda::CONFIG['base_path'] do
|
81
|
-
call env.merge('PATH_INFO' => '/')
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
get '/' do
|
86
|
-
chdir
|
87
|
-
@slug = 'index'
|
88
|
-
text_content = ''
|
89
|
-
index_file = File.join('private', 'index.org')
|
90
|
-
if File.exist? index_file
|
91
|
-
@org_file = index_file
|
92
|
-
@content = Orgmode::Parser.load @org_file
|
93
|
-
title
|
94
|
-
text_content = @content.to_html
|
95
|
-
end
|
96
|
-
|
97
|
-
@chapters = []
|
98
|
-
if File.exist? File.join('config', 'chapters.yml')
|
99
|
-
@chapters = YAML.load_file(File.join('config', 'chapters.yml'))
|
100
|
-
end
|
101
|
-
|
102
|
-
slim :index, locals: { text: text_content }
|
103
|
-
end
|
104
|
-
|
105
|
-
error 403 do
|
106
|
-
slim 'h1 Access forbidden'
|
107
|
-
end
|
108
|
-
|
109
|
-
error 404 do
|
110
|
-
slim 'h1 Not Found'
|
111
|
-
end
|
112
|
-
end
|