More fixes

This commit is contained in:
Paulus Schoutsen 2015-10-27 00:53:57 -07:00
parent e59252a39b
commit 8f47eb20e5
12 changed files with 30 additions and 232 deletions

10
Gemfile
View File

@ -4,8 +4,6 @@ group :development do
gem 'rake', '~> 10.0'
gem 'jekyll', '~> 3.0'
gem 'pygments.rb', '~> 0.6.3'
# gem 'octopress-hooks', '~> 2.2'
# gem 'octopress-date-format', '~> 2.0'
gem 'rdiscount', '~> 2.0'
gem 'RedCloth', '~> 4.2.9'
gem 'haml', '~> 4.0'
@ -19,10 +17,14 @@ group :development do
end
group :jekyll_plugins do
gem 'jekyll-sitemap'
gem 'jekyll-paginate'
gem 'octopress', '~> 3.0'
gem 'jekyll-sitemap'
gem 'jekyll-time-to-read'
gem 'octopress', '~> 3.0'
gem 'octopress-codefence'
gem 'octopress-filters'
gem 'octopress-include-tag'
# gem 'octopress-solarized'
end
gem 'sinatra', '~> 1.4.2'

View File

@ -26,8 +26,6 @@ email:
# Jekyll & Plugins #
# ----------------------- #
# If publishing to a subdirectory as in http://site.com/project set 'root: /project'
root: /
permalink: /blog/:year/:month/:day/:title/
source: source
destination: public/
@ -44,6 +42,10 @@ highlighter: pygments # default python pygments have been replaced by pygments.r
gems:
- jekyll-time-to-read
- octopress-filters
# - octopress-solarized
- octopress-codefence
- octopress-include-tag
paginate: 10 # Posts per page on the blog index
paginate_path: "blog/posts/:num" # Directory base for pagination URLs eg. /posts/2/

View File

@ -16,7 +16,7 @@ class SinatraStaticServer < Sinatra::Base
def send_sinatra_file(path, &missing_file_block)
file_path = File.join(File.dirname(__FILE__), 'public', path)
file_path = File.join(file_path, 'index.html') unless file_path =~ /\.[a-z]+$/i
file_path = File.join(file_path, 'index.html') if File.directory?(file_path)
File.exist?(file_path) ? send_file(file_path) : missing_file_block.call
end

View File

@ -1,142 +0,0 @@
#custom filters for Octopress
require './plugins/backtick_code_block'
# require 'octopress-hooks'
require 'jekyll-sitemap'
# require 'octopress-date-format'
require './plugins/raw'
require 'rubypants'
module OctopressFilters
def self.pre_filter(page)
if page.ext.match('html|textile|markdown|md|haml|slim|xml')
input = BacktickCodeBlock::render_code_block(page.content)
page.content = input.gsub /(<figure.+?>.+?<\/figure>)/m do
TemplateWrapper::safe_wrap($1)
end
end
end
def self.post_filter(page)
if page.ext.match('html|textile|markdown|md|haml|slim|xml')
page.output = TemplateWrapper::unwrap(page.output)
end
page.output = RubyPants.new(page.output).to_html
end
# class PageFilters < Octopress::Hooks::Page
# def pre_render(page)
# OctopressFilters::pre_filter(page)
# end
# def post_render(page)
# OctopressFilters::post_filter(page)
# end
# end
# class PostFilters < Octopress::Hooks::Post
# def pre_render(post)
# OctopressFilters::pre_filter(post)
# end
# def post_render(post)
# OctopressFilters::post_filter(post)
# end
# end
end
module OctopressLiquidFilters
# Used on the blog index to split posts on the <!--more--> marker
def excerpt(input)
if input.index(/<!--\s*more\s*-->/i)
input.split(/<!--\s*more\s*-->/i)[0]
else
input
end
end
# Checks for excerpts (helpful for template conditionals)
def has_excerpt(input)
input =~ /<!--\s*more\s*-->/i ? true : false
end
# Summary is used on the Archive pages to return the first block of content from a post.
def summary(input)
if input.index(/\n\n/)
input.split(/\n\n/)[0]
else
input
end
end
# Extracts raw content DIV from template, used for page description as {{ content }}
# contains complete sub-template code on main page level
def raw_content(input)
/<div class="entry-content">(?<content>[\s\S]*?)<\/div>\s*<(footer|\/article)>/ =~ input
return (content.nil?) ? input : content
end
# Escapes CDATA sections in post content
def cdata_escape(input)
input.gsub(/<!\[CDATA\[/, '&lt;![CDATA[').gsub(/\]\]>/, ']]&gt;')
end
# Replaces relative urls with full urls
def expand_urls(input, url='')
url ||= '/'
input.gsub /(\s+(href|src)\s*=\s*["|']{1})(\/[^\/>]{1}[^\"'>]*)/ do
$1+url+$3
end
end
# Improved version of Liquid's truncate:
# - Doesn't cut in the middle of a word.
# - Uses typographically correct ellipsis (…) insted of '...'
def truncate(input, length)
if input.length > length && input[0..(length-1)] =~ /(.+)\b.+$/im
$1.strip + ' &hellip;'
else
input
end
end
# Improved version of Liquid's truncatewords:
# - Uses typographically correct ellipsis (…) insted of '...'
def truncatewords(input, length)
truncate = input.split(' ')
if truncate.length > length
truncate[0..length-1].join(' ').strip + ' &hellip;'
else
input
end
end
# Condenses multiple spaces and tabs into a single space
def condense_spaces(input)
input.gsub(/\s{2,}/, ' ')
end
# Removes trailing forward slash from a string for easily appending url segments
def strip_slash(input)
if input =~ /(.+)\/$|^\/$/
input = $1
end
input
end
# Returns a url without the protocol (http://)
def shorthand_url(input)
input.gsub /(https?:\/\/)(\S+)/ do
$2
end
end
# Returns a title cased string based on John Gruber's title case http://daringfireball.net/2008/08/title_case_update
def titlecase(input)
input.titlecase
end
end
Liquid::Template.register_filter OctopressLiquidFilters

View File

@ -1,69 +0,0 @@
# Title: Render Partial Tag for Jekyll
# Author: Brandon Mathis http://brandonmathis.com
# Description: Import files on your filesystem into any blog post and render them inline.
# Note: Paths are relative to the source directory, if you import a file with yaml front matter, the yaml will be stripped out.
#
# Syntax {% render_partial path/to/file %}
#
# Example 1:
# {% render_partial about/_bio.markdown %}
#
# This will import source/about/_bio.markdown and render it inline.
# In this example I used an underscore at the beginning of the filename to prevent Jekyll
# from generating an about/bio.html (Jekyll doesn't convert files beginning with underscores)
#
# Example 2:
# {% render_partial ../README.markdown %}
#
# You can use relative pathnames, to include files outside of the source directory.
# This might be useful if you want to have a page for a project's README without having
# to duplicated the contents
#
#
require 'pathname'
require './plugins/octopress_filters'
module Jekyll
class RenderPartialTag < Liquid::Tag
include OctopressFilters
def initialize(tag_name, markup, tokens)
@file = nil
@raw = false
if markup =~ /^(\S+)\s?(\w+)?/
@file = $1.strip
@raw = $2 == 'raw'
end
super
end
def render(context)
file_dir = (context.registers[:site].source || 'source')
file_path = Pathname.new(file_dir).expand_path
file = file_path + @file
unless file.file?
return "File #{file} could not be found"
end
Dir.chdir(file_path) do
contents = file.read
if contents =~ /\A-{3}.+[^\A]-{3}\n(.+)/m
contents = $1.lstrip
end
contents = pre_filter(contents)
if @raw
contents
else
partial = Liquid::Template.parse(contents)
context.stack do
partial.render(context)
end
end
end
end
end
end
Liquid::Template.register_tag('render_partial', Jekyll::RenderPartialTag)

View File

@ -17,9 +17,15 @@
</header>
{% endunless %}
{% if index %}
<div class="entry-content">{{ content | excerpt }}</div>
{% capture excerpted %}{{ content | has_excerpt }}{% endcapture %}
{% if excerpted == 'true' %}
<div class="entry-content">
{% if post.excerpted %}
{{ post.excerpt }}
<a href="{{ post.url }}"Continue reading </a>
{% else %}
{{ post.content }}
{% endif %}
</div>
{% if post.excerpted %}
<footer>
<a rel="full-article" href="{{ root_url }}{{ post.url }}">{{ site.excerpt_link }}</a>
</footer>

View File

@ -22,13 +22,11 @@
{% endunless %}
</header>
{% capture excerpted %}{{ content | has_excerpt }}{% endcapture %}
{% if excerpted == 'true' and index %}
{% if post.excerpted and index %}
<div class="entry-content clearfix">
{{ content | excerpt }}
{{ post.excerpt }}
<a class="btn pull-right" href="{{ root_url }}{{ post.url }}#read-more">{{ site.excerpt_link }}</a>
</div>
{% else %}
{{ content | replace: site.excerpt_separator, '<a name="read-more"></a>' }}
{% endif %}
{{ post.content | replace: site.excerpt_separator, '<a name="read-more"></a>' }}
{% endif %}

View File

@ -1 +1 @@
<span><i class='icon-time'></i> {{ content | reading_time_as_s }} reading time</span>
<span><i class='icon-time'></i> {{ post.content | reading_time_as_s }} reading time</span>

View File

@ -4,7 +4,7 @@
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html> <!--<![endif]-->
{% capture canonical %}{{ site.url }}{% if site.permalink contains '.html' %}{{ page.url }}{% else %}{{ page.url | remove:'index.html' | strip_slash }}{% endif %}{% endcapture %}
{% capture canonical %}{{ site.url }}{% if site.permalink contains '.html' %}{{ page.url }}{% else %}{{ page.url | remove:'index.html' }}{% endif %}{% endcapture %}
{% if page.description %} {% capture fb_description %}{{ page.description }}{% endcapture %} {% else %} {% capture fb_description %}{{ content | raw_content }}{% endcapture %} {% endif %}
<head>
<meta charset="utf-8">

View File

@ -4,10 +4,11 @@ is_post: true
---
<article class="post">
{% assign post = page %}
{% include blog/post/article.html %}
</article>
{% if site.disqus_short_name and page.comments == true %}
{% if site.disqus_short_name and page.comments == true %}
<section id="disqus">
<h3 class="indent title">Comments</h3>
<div id="disqus_thread" aria-live="polite">{% include blog/post/disqus_thread.html %}</div>

View File

@ -1,10 +1,10 @@
---
layout: default
sidebar: false
regenerate: true
---
{% assign index = true %}
{% for post in paginator.posts %}
{% assign content = post.content %}
<article class="listing">
{% include blog/post/article.html %}
</article>

View File

@ -169,7 +169,7 @@ go automate!
- Learn about the available [automation conditions](/components/automation/#conditions)
- Learn about [scripts](/components/script/) to help you trigger multiple actions and delays
- Learn about [scenes](/components/scene/) to help you set many entities at once to your liking
- Setup the [notification component](/components/#notify-service) to sent yourself messages
- Setup a [notification platform](/components/#notifications) to sent yourself messages
<p class='note warning'>
Whenever you write the value <code>on</code> or <code>off</code>, surround it with quotes to avoid