serif 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +10 -14
- data/LICENSE +1 -1
- data/README.md +62 -31
- data/bin/serif +2 -0
- data/lib/serif/markup_renderer.rb +7 -12
- data/lib/serif/server.rb +0 -1
- data/lib/serif/site.rb +10 -7
- data/lib/serif.rb +1 -1
- data/serif.gemspec +2 -3
- data/statics/templates/admin/edit_post.liquid +1 -1
- data/test/site_dir/_site/drafts/another-sample-draft/{79d6aaed09deaead24960fd3b070d01802b9e1d2a3711dda9f6dbaab26d3.html → 9094f3a34ce2ecfe188ad813e0d3229d2488350fb0c5bca4f8b4bcfe7b11.html} +1 -1
- data/test/site_dir/_site/drafts/sample-draft/{af5fd3ce4acf764fca7fad9bf23b8d83644b2f0b42bd25bcfc1c67213c23.html → 359dca7a7237a1317c5e8ac2d3a01cd29db433f4caeb0b2209484ca09a7a.html} +1 -1
- data/test/site_dir/_trash/1363284991-autopublish-draft +5 -0
- data/test/site_dir/_trash/{1362841029-test-draft → 1363284991-test-draft} +1 -1
- metadata +9 -26
- data/statics/skeleton/_posts/2012-01-05-sample-post +0 -4
- data/test/site_dir/_trash/1362841029-autopublish-draft +0 -5
data/Gemfile.lock
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
serif (0.
|
4
|
+
serif (0.3.3)
|
5
5
|
liquid (~> 2.4)
|
6
|
-
pygments.rb (~> 0.3)
|
7
6
|
rack (~> 1.0)
|
8
|
-
rack-rewrite (~> 1.3.0)
|
9
7
|
redcarpet (~> 2.2)
|
10
8
|
redhead (~> 0.0.8)
|
9
|
+
rouge (~> 0.3.2)
|
11
10
|
sinatra (~> 1.3)
|
12
11
|
slop (~> 3.3)
|
13
12
|
timeout_cache
|
@@ -16,19 +15,16 @@ GEM
|
|
16
15
|
remote: http://rubygems.org/
|
17
16
|
specs:
|
18
17
|
diff-lcs (1.1.3)
|
19
|
-
liquid (2.
|
18
|
+
liquid (2.5.0)
|
20
19
|
multi_json (1.6.1)
|
21
|
-
posix-spawn (0.3.6)
|
22
|
-
pygments.rb (0.3.7)
|
23
|
-
posix-spawn (~> 0.3.6)
|
24
|
-
yajl-ruby (~> 1.1.0)
|
25
20
|
rack (1.5.2)
|
26
|
-
rack-protection (1.
|
21
|
+
rack-protection (1.5.0)
|
27
22
|
rack
|
28
|
-
rack-rewrite (1.3.3)
|
29
23
|
rake (0.9.6)
|
30
24
|
redcarpet (2.2.2)
|
31
25
|
redhead (0.0.8)
|
26
|
+
rouge (0.3.2)
|
27
|
+
thor
|
32
28
|
rspec (2.12.0)
|
33
29
|
rspec-core (~> 2.12.0)
|
34
30
|
rspec-expectations (~> 2.12.0)
|
@@ -41,15 +37,15 @@ GEM
|
|
41
37
|
multi_json (~> 1.0)
|
42
38
|
simplecov-html (~> 0.7.1)
|
43
39
|
simplecov-html (0.7.1)
|
44
|
-
sinatra (1.3.
|
40
|
+
sinatra (1.3.5)
|
45
41
|
rack (~> 1.4)
|
46
42
|
rack-protection (~> 1.3)
|
47
43
|
tilt (~> 1.3, >= 1.3.3)
|
48
|
-
slop (3.4.
|
49
|
-
|
44
|
+
slop (3.4.4)
|
45
|
+
thor (0.17.0)
|
46
|
+
tilt (1.3.5)
|
50
47
|
timecop (0.5.9.2)
|
51
48
|
timeout_cache (0.0.2)
|
52
|
-
yajl-ruby (1.1.0)
|
53
49
|
|
54
50
|
PLATFORMS
|
55
51
|
ruby
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -4,25 +4,24 @@
|
|
4
4
|
|
5
5
|
Serif is a file-based blogging engine intended for simple sites. It compiles Markdown content to static files, and there is a web interface for editing and publishing ([simple video demo](https://docs.google.com/open?id=0BxPQpxGSOOyKS1J4MmlnM3JIaXM)), because managing everything with `ssh` and `git` can be a pain, compared to having a more universally accessible editing interface.
|
6
6
|
|
7
|
+
Having problems with Serif? [Open an issue on GitHub](https://github.com/aprescott/serif/issues), or use the [Serif Google Group](https://groups.google.com/forum/#!forum/serif-rb)
|
8
|
+
|
7
9
|
# Changes and what's new
|
8
10
|
|
9
|
-
|
11
|
+
# Latest release (v0.3.3)
|
12
|
+
|
13
|
+
* Allow drag-and-drop to work on posts as well as drafts. (9ea3bebf)
|
14
|
+
* `serif new` no longer creates a sample published post (#37) and generates immediately. (#39)
|
15
|
+
* Pygments.rb is replaced with Rouge for code highlighting. (#34)
|
16
|
+
|
17
|
+
## v0.3.1 and v0.3.2
|
10
18
|
|
11
19
|
* Be kinder about the space used by the private URL characters. (#32)
|
12
20
|
* The keyup event on any input or textarea now marks the page as having changed. Previously only on blur events. (e0df1375dd)
|
13
21
|
* Order the list of drafts by most-recently-modified first, clarify draft and post ordering above each list. (#33)
|
14
22
|
* Support custom layouts for posts as well as non-post files. (#35)
|
15
|
-
* Drag-and-drop image uploads no longer use exclusively rw
|
16
|
-
|
17
|
-
|
18
|
-
## v0.3
|
19
|
-
|
20
|
-
* Add some caching to improve performance of post generation. (#29)
|
21
|
-
* Remove super-linear performance cost of file_digest, reducing site generation time by > 85% for 50+ posts. (#30 -- charts available in the issue)
|
22
|
-
* Make `site` available to both preview templates and archive templates. (c3e2f28)
|
23
|
-
* Intelligently add blank lines before the markdown image text strings. (#27)
|
24
|
-
* Add a `smarty` filter to do smarty processing without full Markdown. (#28)
|
25
|
-
* Fix broken URL renames for drafts in the admin interface. (#31)
|
23
|
+
* Drag-and-drop image uploads no longer use exclusively `rw-------` permissions, now rely on umask. (605487d98)
|
24
|
+
* (v0.3.2) Fix caching problems caused by #30, allowing the most recently published to appear in files that use `site.posts`. (#36)
|
26
25
|
|
27
26
|
See `CHANGELOG` for more.
|
28
27
|
|
@@ -40,24 +39,16 @@ See `CHANGELOG` for more.
|
|
40
39
|
* [Custom tags](#custom-tags)
|
41
40
|
* [Template variables](#template-variables)
|
42
41
|
* [Developing Serif](#developing-serif)
|
42
|
+
* [Planned features](#planned-features)
|
43
43
|
|
44
44
|
# Intro
|
45
45
|
|
46
|
-
Serif is a lot like Jekyll with a few extra moving parts
|
46
|
+
Serif is a lot like Jekyll with a few extra moving parts. Its main aim is to provide two things:
|
47
47
|
|
48
48
|
1. Simplicity: the source and generated content are just files that can be served by any web server.
|
49
|
-
2. Ease of publishing, wherever you are
|
50
|
-
|
51
|
-
With this in mind, you might think of Serif's aim as to merge Jekyll, [Second Crack](https://github.com/marcoarment/secondcrack) and ideas from [Svbtle](http://dcurt.is/codename-svbtle). There should be many ways of editing and publishing, such as using the web interface, `rsync`ing from a remote machine, or editing a draft file on the remote server and having everything happen for you.
|
52
|
-
|
53
|
-
## Planned features
|
49
|
+
2. Ease of publishing, wherever you are.
|
54
50
|
|
55
|
-
|
56
|
-
|
57
|
-
1. Custom hooks to fire after particular events, such as minifying CSS after publish, or committing changes and pushing to a git repository.
|
58
|
-
2. Simple Markdown pages instead of plain HTML for non-post content.
|
59
|
-
3. Automatically detecting file changes and regenerating the site.
|
60
|
-
4. Adding custom Liquid filters and tags.
|
51
|
+
Serif is sort of a blend between Jekyll, [Second Crack](https://github.com/marcoarment/secondcrack) and ideas from [Svbtle](http://dcurt.is/codename-svbtle). There should be flexibility with writing content, such as using the web interface, `rsync`ing from a remote machine, or editing a draft file on the remote server and having everything happen for you.
|
61
52
|
|
62
53
|
# License and contributing
|
63
54
|
|
@@ -370,7 +361,7 @@ error_page 404 @not_found_page;
|
|
370
361
|
location / {
|
371
362
|
index index.html index.htm;
|
372
363
|
|
373
|
-
try_files $uri.html $uri $uri/ 404;
|
364
|
+
try_files $uri.html $uri $uri/ =404;
|
374
365
|
}
|
375
366
|
|
376
367
|
location @not_found_page {
|
@@ -424,6 +415,12 @@ These tags can be used in templates, in addition to the [standard Liquid filters
|
|
424
415
|
|
425
416
|
This runs the given input through a Markdown + SmartyPants renderer, with fenced codeblocks enabled.
|
426
417
|
|
418
|
+
* `smarty`
|
419
|
+
|
420
|
+
e.g., `{{ post.title | smarty }}`.
|
421
|
+
|
422
|
+
This runs the given input through a SmartyPants processor, so quotes, dashes and ellipses come out better. Note that the **`markdown` filter already does SmartyPants** processing.
|
423
|
+
|
427
424
|
* `strip`
|
428
425
|
|
429
426
|
Strips trailing and leading whitespace.
|
@@ -459,15 +456,40 @@ These tags can be used in templates, in addition to the [standard Liquid filters
|
|
459
456
|
|
460
457
|
# Template variables
|
461
458
|
|
462
|
-
In addition to those mentioned above, such as the archive page variables, there are others. *This
|
459
|
+
In addition to those mentioned above, such as the archive page variables, there are others. *This may not be an exhaustive list.*
|
460
|
+
|
461
|
+
## General template variables
|
462
|
+
|
463
|
+
These should be available in any template:
|
464
|
+
|
465
|
+
* `{{ site }}` --- a container for the site itself, containing:
|
466
|
+
* `{{ site.posts }}` --- the published posts of the site
|
467
|
+
* `{{ site.latest_update_time }}` --- a [Ruby `Time`](http://ruby-doc.org/core/Time.html) instance for the latest time that any post was updated. Useful for RSS/Atom feeds.
|
468
|
+
* `{{ site.archives }}` --- a nested hash structure that groups posts by month. See above for how to use it.
|
469
|
+
* `{{ draft_preview }}` -- Set to true if this is part of generating a draft preview.
|
470
|
+
|
471
|
+
## Post variables
|
472
|
+
|
473
|
+
A published post has variables like `post.url` and `post.title`. Here's a list of what's available wherever `{{ post }}` is available. If the variable is, e.g., `post.url`, use as `{{ post.url }}`.
|
474
|
+
|
475
|
+
Name | Value
|
476
|
+
------------ |:-----
|
477
|
+
`post.title` | Title of the post
|
478
|
+
`post.url` | Permalink to the post based on the config or any `permalink` header on the post
|
479
|
+
`post.slug` | URL slug of the post. A filename like `2013-06-02-my-post` will correspond to a `{{ post.slug }}` value of `my-post`
|
480
|
+
`post.created` | A [Ruby `Time`](http://ruby-doc.org/core/Time.html) instance for the time the post was first published.
|
481
|
+
`post.updated` | A [Ruby `Time`](http://ruby-doc.org/core/Time.html) instance for the time the post was last updated.
|
482
|
+
`post.content` | The raw post content. Example use: `{{ post.content | markdown }}`.
|
463
483
|
|
464
|
-
##
|
484
|
+
## Variables available within post templates
|
465
485
|
|
466
486
|
These are available on individual post pages, in `_template/post.html`.
|
467
487
|
|
468
|
-
|
469
|
-
|
470
|
-
|
488
|
+
Variable | Value
|
489
|
+
----------- |:----
|
490
|
+
`post` | The post being processed. See above for what values (`post.url`, ...) are available.
|
491
|
+
`prev_post` | The post published chronologically before `post`.
|
492
|
+
`next_post` | The post published chronologically after `post`.
|
471
493
|
|
472
494
|
# Developing Serif
|
473
495
|
|
@@ -480,4 +502,13 @@ These are available on individual post pages, in `_template/post.html`.
|
|
480
502
|
## Directory structure
|
481
503
|
|
482
504
|
* `lib/serif/` is generally where files go.
|
483
|
-
* `test/` contains the test files. Any new files should have `require "test_helper"` at the top of the, which pulls in `test/test_helper.rb`.
|
505
|
+
* `test/` contains the test files. Any new files should have `require "test_helper"` at the top of the, which pulls in `test/test_helper.rb`.
|
506
|
+
|
507
|
+
# Planned features
|
508
|
+
|
509
|
+
Some things I'm hoping to implement one day:
|
510
|
+
|
511
|
+
1. Custom hooks to fire after particular events, such as minifying CSS after publish, or committing changes and pushing to a git repository.
|
512
|
+
2. Simple Markdown pages instead of plain HTML for non-post content.
|
513
|
+
3. Automatically detecting file changes and regenerating the site.
|
514
|
+
4. Adding custom Liquid filters and tags.
|
data/bin/serif
CHANGED
@@ -5,19 +5,14 @@ class MarkupRenderer < Redcarpet::Render::SmartyHTML
|
|
5
5
|
#
|
6
6
|
# note that we add a new line after the initial ``` but not before the closing
|
7
7
|
# ``` because otherwise it introduces an extra \n.
|
8
|
-
|
9
|
-
#{code}```}
|
8
|
+
if !language
|
9
|
+
simple_code = %Q{```\n#{code}```}
|
10
|
+
renderer = Redcarpet::Markdown.new(Redcarpet::Render::SmartyHTML, fenced_code_blocks: true)
|
11
|
+
return renderer.render(simple_code).strip
|
12
|
+
end
|
10
13
|
|
11
|
-
out =
|
12
|
-
|
13
|
-
# first, get rid of the div, since we want
|
14
|
-
# to stick the class onto the <pre>, to stay
|
15
|
-
# clean markup-wise.
|
16
|
-
out.sub!(/^<div[^>]*>/, "")
|
17
|
-
out.strip!
|
18
|
-
out.sub!(/<\/div>\z/, "")
|
19
|
-
|
20
|
-
out.sub!(/^<pre>/, "<pre#{" class=\"highlight\""}><code>")
|
14
|
+
out = Rouge.highlight(code, language, "html")
|
15
|
+
out.sub!(/^(<pre class=\"highlight\">)/, '\1<code>')
|
21
16
|
out.sub!(/<\/pre>\z/, "</code></pre>\n")
|
22
17
|
|
23
18
|
out
|
data/lib/serif/server.rb
CHANGED
data/lib/serif/site.rb
CHANGED
@@ -299,12 +299,17 @@ class Site
|
|
299
299
|
end
|
300
300
|
end
|
301
301
|
|
302
|
-
# the posts are iterated over in reverse chrological order
|
303
|
-
next_post = nil
|
304
|
-
|
305
302
|
# run through the posts + nil so we can keep |a, b| such that a hits every element
|
306
303
|
# while iterating.
|
307
|
-
|
304
|
+
posts.each.with_index do |post, i|
|
305
|
+
# the posts are iterated over in reverse chrological order, and
|
306
|
+
# next_post here is post published chronologically after than
|
307
|
+
# the post in the iteration.
|
308
|
+
#
|
309
|
+
# if i == 0, we don't want posts.last, so return nil if i - 1 == -1
|
310
|
+
next_post = (i == 0 ? nil : posts[i - 1])
|
311
|
+
prev_post = posts[i + 1]
|
312
|
+
|
308
313
|
puts "Processing post: #{post.path}"
|
309
314
|
|
310
315
|
FileUtils.mkdir_p(tmp_path(File.dirname(post.url)))
|
@@ -329,8 +334,6 @@ class Site
|
|
329
334
|
"content" => Liquid::Template.parse(File.read("_templates/post.html")).render!(post_template_variables)
|
330
335
|
)
|
331
336
|
end
|
332
|
-
|
333
|
-
next_post = post
|
334
337
|
end
|
335
338
|
|
336
339
|
generate_draft_previews(default_layout)
|
@@ -383,7 +386,7 @@ class Site
|
|
383
386
|
"site" => self,
|
384
387
|
"draft_preview" => true,
|
385
388
|
"page" => { "title" => [ "Draft Preview", draft.title ] },
|
386
|
-
"content" => template.render!("site" => self, "post" => draft)
|
389
|
+
"content" => template.render!("site" => self, "post" => draft, "draft_preview" => true)
|
387
390
|
)
|
388
391
|
end
|
389
392
|
end
|
data/lib/serif.rb
CHANGED
data/serif.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "serif"
|
3
|
-
s.version = "0.3.
|
3
|
+
s.version = "0.3.3"
|
4
4
|
s.authors = ["Adam Prescott"]
|
5
5
|
s.email = ["adam@aprescott.com"]
|
6
6
|
s.homepage = "https://github.com/aprescott/serif"
|
@@ -14,9 +14,8 @@ Gem::Specification.new do |s|
|
|
14
14
|
|
15
15
|
[
|
16
16
|
"rack", "~> 1.0",
|
17
|
-
"rack-rewrite", "~> 1.3.0",
|
18
17
|
"redcarpet", "~> 2.2",
|
19
|
-
"
|
18
|
+
"rouge", "~> 0.3.2",
|
20
19
|
"sinatra", "~> 1.3",
|
21
20
|
"redhead", "~> 0.0.8",
|
22
21
|
"liquid", "~> 2.4",
|
@@ -17,7 +17,7 @@
|
|
17
17
|
<div class="post draft">
|
18
18
|
<header>
|
19
19
|
<h1 id="heading" class="post">
|
20
|
-
<textarea
|
20
|
+
<textarea spellcheck="false" placeholder="It was a dark and stormy night" name="title" autofocus>{{ post.title | escape }}</textarea>
|
21
21
|
</h1>
|
22
22
|
|
23
23
|
<time datetime="{{ post.created | date: "%Y-%m-%d" }}">{{ post.created | date: "%B %d %Y" }}</time>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serif
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack
|
@@ -27,22 +27,6 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '1.0'
|
30
|
-
- !ruby/object:Gem::Dependency
|
31
|
-
name: rack-rewrite
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
|
-
requirements:
|
35
|
-
- - ~>
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: 1.3.0
|
38
|
-
type: :runtime
|
39
|
-
prerelease: false
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
|
-
requirements:
|
43
|
-
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version: 1.3.0
|
46
30
|
- !ruby/object:Gem::Dependency
|
47
31
|
name: redcarpet
|
48
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -60,13 +44,13 @@ dependencies:
|
|
60
44
|
- !ruby/object:Gem::Version
|
61
45
|
version: '2.2'
|
62
46
|
- !ruby/object:Gem::Dependency
|
63
|
-
name:
|
47
|
+
name: rouge
|
64
48
|
requirement: !ruby/object:Gem::Requirement
|
65
49
|
none: false
|
66
50
|
requirements:
|
67
51
|
- - ~>
|
68
52
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
53
|
+
version: 0.3.2
|
70
54
|
type: :runtime
|
71
55
|
prerelease: false
|
72
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -74,7 +58,7 @@ dependencies:
|
|
74
58
|
requirements:
|
75
59
|
- - ~>
|
76
60
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
61
|
+
version: 0.3.2
|
78
62
|
- !ruby/object:Gem::Dependency
|
79
63
|
name: sinatra
|
80
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -247,7 +231,6 @@ files:
|
|
247
231
|
- statics/skeleton/_templates/post.html
|
248
232
|
- statics/skeleton/_drafts/sample-draft
|
249
233
|
- statics/skeleton/_config.yml
|
250
|
-
- statics/skeleton/_posts/2012-01-05-sample-post
|
251
234
|
- statics/skeleton/_layouts/default.html
|
252
235
|
- statics/skeleton/archive.html
|
253
236
|
- statics/assets/js/mousetrap.min.js
|
@@ -280,8 +263,8 @@ files:
|
|
280
263
|
- test/site_dir/_site/test-archive/2012/11/index.html
|
281
264
|
- test/site_dir/_site/test-archive/2400/01/index.html
|
282
265
|
- test/site_dir/_site/test-archive/2399/01/index.html
|
283
|
-
- test/site_dir/_site/drafts/another-sample-draft/
|
284
|
-
- test/site_dir/_site/drafts/sample-draft/
|
266
|
+
- test/site_dir/_site/drafts/another-sample-draft/9094f3a34ce2ecfe188ad813e0d3229d2488350fb0c5bca4f8b4bcfe7b11.html
|
267
|
+
- test/site_dir/_site/drafts/sample-draft/359dca7a7237a1317c5e8ac2d3a01cd29db433f4caeb0b2209484ca09a7a.html
|
285
268
|
- test/site_dir/_site/index.html
|
286
269
|
- test/site_dir/_site/file-digest-test.html
|
287
270
|
- test/site_dir/_site/page-alt-layout.html
|
@@ -295,8 +278,8 @@ files:
|
|
295
278
|
- test/site_dir/_site/test-blog/penultimate-post.html
|
296
279
|
- test/site_dir/_site/test-smarty-filter.html
|
297
280
|
- test/site_dir/_site/archive.html
|
298
|
-
- test/site_dir/_trash/
|
299
|
-
- test/site_dir/_trash/
|
281
|
+
- test/site_dir/_trash/1363284991-test-draft
|
282
|
+
- test/site_dir/_trash/1363284991-autopublish-draft
|
300
283
|
- test/site_dir/_posts/2013-03-07-post-with-custom-layout
|
301
284
|
- test/site_dir/_posts/2012-01-05-sample-post
|
302
285
|
- test/site_dir/_posts/2400-01-01-final-post
|