Commit df07d28b authored by Colin Shea's avatar Colin Shea

New type of posts: Link posts!

parent 1d2e1ff8
......@@ -31,19 +31,37 @@ task :article do
require 'shellwords'
# And run middleman
sh "bundle exec middleman article #{Shellwords.escape(title_string)}"
# Then find the latest post, by looking for a file with the latest creation
# time.
latest_post = Dir['source/posts/*'].map{|f| [f, File.stat(f)] }.sort_by{|s| s[1].ctime}.last[0]
# then open that file in $EDITOR
system("#{ENV['EDITOR']} #{latest_post}")
sh "bundle exec middleman article --edit #{Shellwords.escape(title_string)}"
system("git add #{latest_post}")
system("git commit -m 'New Post: #{title_string}'")
end
desc "A blog post that's about a link"
task :linkpost do
# Same technique as the :article task. See above for details
ARGV.shift
ARGV.each do |arg|
task arg.to_sym do
next
end
end
link = ARGV.join(' ')
if link =~ /^[:space:]*$/
puts "ERROR: You need to pass a link!"
puts "Usage: rake linkpost LINK"
next
end
# Fetch the link's title, that will be used as the blog post's title
require 'open-uri'
require 'nokogiri'
title_string = Nokogiri::HTML(open(link)).xpath('//head/title').text
require 'shellwords'
sh "bundle exec middleman article --edit -t link -c #{Shellwords.escape(link)} #{Shellwords.escape("Link: " + title_string)}"
end
task :dirty_git do
# Throw an error if we don't have a clean git checkout
fail "Directory not clean" unless (`git diff --shortstat 2> /dev/null`.split('\n')[-1].nil?)
......
---
title: "<%= @title %>"
title: "<%= @title.gsub(/^Link: /, '') %>"
date: <%= @date.strftime('%F %R %Z') %>
tags:
tags: <%= @tags.join(",") %>
<%- if @tags.include? 'link' -%>
link: <%= @content %>
layout: link_post
<% end -%>
---
<%- if !@tags.include? 'link' -%><%= @content %><% end -%>
......@@ -36,7 +36,7 @@ activate :blog do |blog|
blog.layout = 'blog_post'
blog.tag_template = 'tag.html'
blog.calendar_template = 'calendar.html'
blog.new_article_template = 'article.tt'
blog.new_article_template = File.join(File.expand_path(File.dirname(__FILE__)), 'article.tt')
# Don't generate any date-specific pages, just the blog post pages.
blog.calendar_template = false
......
......@@ -7,5 +7,12 @@ module EvaryontsHelpers
GeoPattern.generate(path, color: $color_palette[base_color_i]).to_data_uri
end
def post_title(article)
anchor_text = article.title
if article.tags.include? "link"
anchor_text += " 🔗"
end
'<h3 class="post-title">' + link_to(anchor_text, article) + '</h3>'
end
end
end
......@@ -6,6 +6,8 @@ module EvaryontsHelpers
def onebox(article)
if article.data.onebox
Onebox.preview(article.data.onebox).placeholder_html
elsif article.data.link and article.tags.include? "link"
Onebox.preview(article.data.link).placeholder_html
else
"<!-- No 'onebox:' specified in frontmatter -->"
end
......
---
layout: blog_post
layout: page
title: "Blog Archive"
---
<% page_articles.each do |article| %>
<article class='archive-article'>
<header>
<h3 class="post-title"><%= link_to article.title, article %></h3>
<%= post_title(article) %>
<p class='post-date'>
<time datetime='<%= article.date %>'><%= article.date.strftime('%b %e, %Y') %></time>
......
......@@ -12,6 +12,9 @@
</span>
<section>
<% if article.data.link %>
<%= link_to "Read the original article &raquo;", article.data.link, class: 'upstream-link' %>
<% end %>
<%= onebox(article) %>
<%= article.body %>
<%= review_rating(article) %>
......
<!-- missing comments for now :-( -->
<!-- Geopattern header! Fancy! 🎩 -->
<div class="fartsy-header" style="background-image: <%= geopattern(current_page.path) %>">
<div class='air'></div>
</div>
......@@ -18,7 +18,10 @@
<p><%= link_to "Subscribe via RSS", "#{blog.options.prefix.to_s}/feed.xml", class: "entypo-rss" %><br />
&copy; <%= Date.today.year %>. Licensed under <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">CC BY-SA 4.0</a>.</p>
<% if development? %>
<div style="background-color: red; font-size: smaller;">LOCAL DEVELOPMENT SERVER</div>
<% end %>
</div>
</div>
<!-- /sidebar -->
......@@ -2,19 +2,12 @@
<%= partial "layouts/sidebar" %>
<!-- Geopattern header! Fancy! 🎩 -->
<div class="fartsy-header" style="background-image: <%= geopattern(current_page.path) %>">
<div class='air'></div>
</div>
<%= partial "layouts/fartsy_header" %>
<div role="main" class="content container">
<% if current_article %>
<%= partial "layouts/article", locals: {article: current_article} %>
<%= partial "layouts/article", locals: {article: current_article} %>
<!-- and missing comments :-( -->
<% else %>
<%= yield %>
<% end %>
<%= partial "layouts/comments", locals: {article: current_article} %>
</div>
<% end %>
<% wrap_layout :default do %>
<%= partial "layouts/sidebar" %>
<%= partial "layouts/fartsy_header" %>
<div role="main" class="content container">
<%= partial "layouts/article", locals: {article: current_article} %>
</div>
<% end %>
......@@ -2,7 +2,7 @@
<%= partial "layouts/sidebar" %>
<div class="fartsy-header"></div>
<%= partial "layouts/fartsy_header" %>
<div role="main" class="content container">
<%= yield %>
......
---
title: "Hide title bars in GNOME Shell"
date: 2017-08-26 05:24 UTC
tags: link,linux
link: https://joshtronic.com/2017/07/26/hide-title-bars-in-gnome-shell/
layout: link_post
---
Such a lovely trick. I'm using it now. Hopefully I do this better with a fork
of the [no-title-bar](https://github.com/franglais125/no-title-bar) extension.
[Follow along on Github!](https://github.com/evaryont/no-title-bar)
---
layout: blog_post
layout: page
title: "Tags"
---
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment