From e50152d3d1102ee4d50d4c5dbc4de35597ec7661 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Sat, 24 Dec 2016 17:26:51 -0500 Subject: [PATCH 1/3] Include original markdown files in build output. --- _plugins/markdown_and_sign.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 _plugins/markdown_and_sign.rb diff --git a/_plugins/markdown_and_sign.rb b/_plugins/markdown_and_sign.rb new file mode 100644 index 0000000..939b5eb --- /dev/null +++ b/_plugins/markdown_and_sign.rb @@ -0,0 +1,11 @@ +# Copy all of the source markdown files directly into the destination. +Jekyll::Hooks.register :site, :post_write do |site| + dest = site.dest + categories = site.config['category_metadata'].each_key do |category| + dir = Dir.new("#{site.source}/_posts/#{category}") + dir.each do |filename| + next unless filename =~ /\.md$/ + FileUtils.cp("#{dir.path}/#{filename}", "#{dest}/#{category}/") + end + end +end From 9cf8456d7cc2f31614b45f2369b13a206d7fc5d9 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Sat, 24 Dec 2016 19:01:43 -0500 Subject: [PATCH 2/3] Rework plugin to work a bit more cleanly. Add metadata and print blurb at bottom of posts. --- _layouts/post.html | 5 +++++ _plugins/markdown_and_sign.rb | 15 +++++++++------ _sass/_custom.scss | 4 ++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/_layouts/post.html b/_layouts/post.html index 5e5b91f..fac08fa 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -12,4 +12,9 @@ layout: default {{ content }} +
+ {% if page.md_file %} + The markdown source for this post is available here: {{page.md_file}}
+ {% endif %} +
diff --git a/_plugins/markdown_and_sign.rb b/_plugins/markdown_and_sign.rb index 939b5eb..7030bfa 100644 --- a/_plugins/markdown_and_sign.rb +++ b/_plugins/markdown_and_sign.rb @@ -1,11 +1,14 @@ +# Adds metadata to the post object for linking to the source page. +Jekyll::Hooks.register :posts, :pre_render do |post, payload| + if post.path =~ /\.md$/ + post.data['md_file'] = "/#{post.data['category']}/#{post.basename}" + end +end + # Copy all of the source markdown files directly into the destination. Jekyll::Hooks.register :site, :post_write do |site| dest = site.dest - categories = site.config['category_metadata'].each_key do |category| - dir = Dir.new("#{site.source}/_posts/#{category}") - dir.each do |filename| - next unless filename =~ /\.md$/ - FileUtils.cp("#{dir.path}/#{filename}", "#{dest}/#{category}/") - end + site.posts.docs.select{|p| p.path =~ /\.md$/}.each do |post| + FileUtils.cp(post.path, "#{dest}/#{post.data['category']}/#{post.basename}") end end diff --git a/_sass/_custom.scss b/_sass/_custom.scss index 122f8da..9f7ecb6 100644 --- a/_sass/_custom.scss +++ b/_sass/_custom.scss @@ -36,3 +36,7 @@ font-size: $large-font-size; padding: 0px 10px; } + +.post-verify { + font-size: $small-font-size; +} From b6cb5dff9755a5e44f4444a10be383161d8f18f9 Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Sun, 25 Dec 2016 15:33:55 -0500 Subject: [PATCH 3/3] Add signature detection in addition to markdown inclusion. --- _config.yml | 1 + _layouts/post.html | 4 ++++ _plugins/markdown_and_sign.rb | 16 ++++++++++++++-- _sass/_custom.scss | 2 +- css/main.scss | 1 + 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/_config.yml b/_config.yml index d0ff763..fa22851 100644 --- a/_config.yml +++ b/_config.yml @@ -15,6 +15,7 @@ baseurl: "" # the subpath of your site, e.g. /blog url: "http://annabunch.es" # the base hostname & protocol for your site twitter_username: annabunches github_username: annabunches +exclude: ["_posts/**/*.asc"] permalink: none timezone: America/New_York diff --git a/_layouts/post.html b/_layouts/post.html index fac08fa..07ce3c1 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -14,7 +14,11 @@ layout: default
{% if page.md_file %} +
The markdown source for this post is available here: {{page.md_file}}
+ {% if page.sig_file %} + The gpg signature for the markdown source is available here: {{page.sig_file}}
+ {% endif %} {% endif %}
diff --git a/_plugins/markdown_and_sign.rb b/_plugins/markdown_and_sign.rb index 7030bfa..b946681 100644 --- a/_plugins/markdown_and_sign.rb +++ b/_plugins/markdown_and_sign.rb @@ -1,14 +1,26 @@ # Adds metadata to the post object for linking to the source page. +# Also adds metadata linking to the gpg signature file, if it exists. Jekyll::Hooks.register :posts, :pre_render do |post, payload| if post.path =~ /\.md$/ post.data['md_file'] = "/#{post.data['category']}/#{post.basename}" + + sig_filename = "#{post.path}.asc" + if File.exist?(sig_filename) + post.data['sig_file'] = post.data['md_file'] + '.asc' + end end end -# Copy all of the source markdown files directly into the destination. +# Copy all of the source markdown files and signature files +# directly into the destination. Jekyll::Hooks.register :site, :post_write do |site| dest = site.dest site.posts.docs.select{|p| p.path =~ /\.md$/}.each do |post| - FileUtils.cp(post.path, "#{dest}/#{post.data['category']}/#{post.basename}") + FileUtils.cp(post.path, "#{dest}/#{post.data['md_file']}") + + sig_filename = "#{post.path}.asc" + if File.exist?(sig_filename) + FileUtils.cp(sig_filename, "#{dest}/#{post.data['sig_file']}") + end end end diff --git a/_sass/_custom.scss b/_sass/_custom.scss index 9f7ecb6..5651d4a 100644 --- a/_sass/_custom.scss +++ b/_sass/_custom.scss @@ -38,5 +38,5 @@ } .post-verify { - font-size: $small-font-size; + font-size: $very-small-font-size; } diff --git a/css/main.scss b/css/main.scss index 7698d96..ad87348 100644 --- a/css/main.scss +++ b/css/main.scss @@ -12,6 +12,7 @@ $base-font-weight: 400; $small-font-size: $base-font-size * 0.875; $base-line-height: 1.5; $large-font-size: $base-font-size * 1.125; +$very-small-font-size: $base-font-size * 0.750; $spacing-unit: 30px;