Updated octopress
This commit is contained in:
commit
8aefeb9aa1
|
@ -0,0 +1,22 @@
|
|||
; This file is for unifying the coding style for different editors and IDEs.
|
||||
; More information at http://EditorConfig.org
|
||||
|
||||
root = true
|
||||
|
||||
; Use 2 spaces for indentation in all Ruby files
|
||||
|
||||
[*.rb]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[Rakefile]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[Gemfile*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[config.ru]
|
||||
indent_style = space
|
||||
indent_size = 2
|
|
@ -0,0 +1 @@
|
|||
* text=auto
|
|
@ -0,0 +1,44 @@
|
|||
; This file is for unifying the coding style for different editors and IDEs.
|
||||
; More information at http://EditorConfig.org
|
||||
|
||||
|
||||
; Use 2 spaces for indentation in SCSS, JavaScript, HTML, and XML
|
||||
|
||||
[*.scss]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.js]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.html]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.xml]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
|
||||
; Use 4 spaces for indentation in Markdown files
|
||||
|
||||
[*.md]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
[*.markdown]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
|
||||
; Override default indentation for some library files
|
||||
|
||||
[jwplayer/glow/glow.xml]
|
||||
indent_style = tab
|
||||
|
||||
[libs/jXHR.js]
|
||||
indent_style = tab
|
||||
|
||||
[libs/swfobject-dynamic.js]
|
||||
indent_style = tab
|
|
@ -73,6 +73,7 @@ ol { list-style-type: decimal;
|
|||
ol { list-style-type: lower-roman; margin-bottom: 0px; }}}
|
||||
|
||||
ul, ol { &, ul, ol { margin-left: 1.3em; }}
|
||||
ul, ol { ul, ol { margin-bottom: 0em; }}
|
||||
|
||||
strong { font-weight: bold; }
|
||||
|
||||
|
|
|
@ -1,44 +1,52 @@
|
|||
.highlight, html .gist .gist-file .gist-syntax .gist-highlight {
|
||||
table td.code { width: 100%; }
|
||||
.line-numbers {
|
||||
text-align: right;
|
||||
font-size: 13px;
|
||||
line-height: 1.45em;
|
||||
@if $solarized == light {
|
||||
background: lighten($base03, 1) $noise-bg !important;
|
||||
border-right: 1px solid darken($base02, 2) !important;
|
||||
@include box-shadow(lighten($base03, 2) -1px 0 inset);
|
||||
text-shadow: lighten($base02, 2) 0 -1px;
|
||||
} @else {
|
||||
background: $base02 $noise-bg !important;
|
||||
border-right: 1px solid darken($base03, 2) !important;
|
||||
@include box-shadow(lighten($base02, 2) -1px 0 inset);
|
||||
text-shadow: darken($base02, 10) 0 -1px;
|
||||
}
|
||||
span { color: $base01 !important; }
|
||||
padding: .8em !important;
|
||||
@include border-radius(0);
|
||||
}
|
||||
border: 1px solid $pre-border !important;
|
||||
}
|
||||
.highlight .line-numbers, html .gist .gist-file .gist-syntax .highlight .line_numbers {
|
||||
text-align: right;
|
||||
font-size: 13px;
|
||||
line-height: 1.45em;
|
||||
@if $solarized == light {
|
||||
background: lighten($base03, 1) $noise-bg !important;
|
||||
border-right: 1px solid darken($base02, 2) !important;
|
||||
@include box-shadow(lighten($base03, 2) -1px 0 inset);
|
||||
text-shadow: lighten($base02, 2) 0 -1px;
|
||||
} @else {
|
||||
background: $base02 $noise-bg !important;
|
||||
border-right: 1px solid darken($base03, 2) !important;
|
||||
@include box-shadow(lighten($base02, 2) -1px 0 inset);
|
||||
text-shadow: darken($base02, 10) 0 -1px;
|
||||
}
|
||||
span { color: $base01 !important; }
|
||||
padding: .8em !important;
|
||||
@include border-radius(0);
|
||||
}
|
||||
|
||||
figure.code, .gist-file, pre {
|
||||
@include box-shadow(rgba(#000, .06) 0 0 10px);
|
||||
.highlight pre { @include box-shadow(none); }
|
||||
}
|
||||
|
||||
.gist .highlight, figure.code .highlight {
|
||||
@include selection(adjust-color($base03, $lightness: 23%, $saturation: -65%), $text-shadow: $base03 0 1px);
|
||||
}
|
||||
html .gist .gist-file {
|
||||
margin-bottom: 1.8em;
|
||||
position: relative;
|
||||
border: none;
|
||||
padding-top: image-height("code_bg.png") !important;
|
||||
.highlight {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.gist-syntax {
|
||||
border-bottom: 0 !important;
|
||||
background: none !important;
|
||||
.gist-highlight{
|
||||
.gist-highlight {
|
||||
background: $base03 !important;
|
||||
pre {
|
||||
@extend .pre-code;
|
||||
}
|
||||
}
|
||||
.highlight pre {
|
||||
@extend .pre-code;
|
||||
padding: 0;
|
||||
}
|
||||
}
|
||||
.gist-meta {
|
||||
|
@ -107,12 +115,11 @@ p, li {
|
|||
}
|
||||
|
||||
.pre-code {
|
||||
@include selection(adjust-color($base03, $lightness: 23%, $saturation: -65%), $text-shadow: $base03 0 1px);
|
||||
font-family: $mono !important;
|
||||
overflow: scroll;
|
||||
overflow-y: hidden;
|
||||
display: block;
|
||||
padding: .8em !important;
|
||||
padding: .8em;
|
||||
overflow-x: auto;
|
||||
line-height: 1.45em;
|
||||
background: $base03 $noise-bg !important;
|
||||
|
@ -187,7 +194,7 @@ p, li {
|
|||
}
|
||||
|
||||
.highlight, .gist-highlight {
|
||||
pre { background: none; @include border-radius(none); border: none; padding: 0; margin-bottom: 0; }
|
||||
pre { background: none; @include border-radius(0px); border: none; padding: 0; margin-bottom: 0; }
|
||||
margin-bottom: 1.8em;
|
||||
background: $base03;
|
||||
overflow-y: hidden;
|
||||
|
@ -206,7 +213,9 @@ pre, .highlight, .gist-highlight {
|
|||
&::-webkit-scrollbar-thumb:horizontal { background: $solar-scroll-thumb; -webkit-border-radius: 4px; border-radius: 4px }
|
||||
}
|
||||
|
||||
.highlight code { @extend .pre-code; background: #000;}
|
||||
.highlight code {
|
||||
@extend .pre-code; background: #000;
|
||||
}
|
||||
figure.code {
|
||||
background: none;
|
||||
padding: 0;
|
||||
|
@ -250,4 +259,3 @@ figure.code {
|
|||
text-shadow: #cbcccc 0 1px 0;
|
||||
padding-left: 3em;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<script>(function(d, s, id) {
|
||||
var js, fjs = d.getElementsByTagName(s)[0];
|
||||
if (d.getElementById(id)) {return;}
|
||||
js = d.createElement(s); js.id = id;
|
||||
js = d.createElement(s); js.id = id; js.async = true;
|
||||
js.src = "//connect.facebook.net/en_US/all.js#appId=212934732101925&xfbml=1";
|
||||
fjs.parentNode.insertBefore(js, fjs);
|
||||
}(document, 'script', 'facebook-jssdk'));</script>
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
<meta name="MobileOptimized" content="320">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
{% capture canonical %}{{ site.url }}{% if site.permalink contains '.html' %}{{ page.url }}{% else %}{{ page.url | remove:'index.html' }}{% endif %}{% endcapture %}
|
||||
{% capture canonical %}{{ site.url }}{% if site.permalink contains '.html' %}{{ page.url }}{% else %}{% if page.url contains site.category_dir %}/{% endif %}{{ page.url | remove:'index.html' }}{% endif %}{% endcapture %}
|
||||
<link rel="canonical" href="{{ canonical }}">
|
||||
<link href="{{ root_url }}/favicon.png" rel="icon">
|
||||
<link href="{{ root_url }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
|
||||
<link href="{{ site.subscribe_rss }}" rel="alternate" title="{{site.title}}" type="application/atom+xml">
|
||||
{% include custom/head.html %}
|
||||
<script src="{{ root_url }}/javascripts/modernizr-2.0.js"></script>
|
||||
<script src="{{ root_url }}/javascripts/ender.js"></script>
|
||||
<script src="{{ root_url }}/javascripts/octopress.js" type="text/javascript"></script>
|
||||
<link href="{{ site.subscribe_rss }}" rel="alternate" title="{{site.title}}" type="application/atom+xml">
|
||||
{% include custom/head.html %}
|
||||
{% include google_analytics.html %}
|
||||
</head>
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,16 +1,19 @@
|
|||
var github = (function(){
|
||||
function escapeHtml(str) {
|
||||
return $('<div/>').text(str).html();
|
||||
}
|
||||
function render(target, repos){
|
||||
var i = 0, fragment = '', t = $(target)[0];
|
||||
|
||||
for(i = 0; i < repos.length; i++) {
|
||||
fragment += '<li><a href="'+repos[i].html_url+'">'+repos[i].name+'</a><p>'+(repos[i].description||'')+'</p></li>';
|
||||
fragment += '<li><a href="'+repos[i].html_url+'">'+repos[i].name+'</a><p>'+escapeHtml(repos[i].description||'')+'</p></li>';
|
||||
}
|
||||
t.innerHTML = fragment;
|
||||
}
|
||||
return {
|
||||
showRepos: function(options){
|
||||
$.ajax({
|
||||
url: "https://api.github.com/users/"+options.user+"/repos?callback=?"
|
||||
url: "https://api.github.com/users/"+options.user+"/repos?sort=pushed&callback=?"
|
||||
, type: 'jsonp'
|
||||
, error: function (err) { $(options.target + ' li.loading').addClass('error').text("Error loading feed"); }
|
||||
, success: function(data) {
|
||||
|
@ -20,14 +23,6 @@ var github = (function(){
|
|||
if (options.skip_forks && data.data[i].fork) { continue; }
|
||||
repos.push(data.data[i]);
|
||||
}
|
||||
repos.sort(function(a, b) {
|
||||
var aDate = new Date(a.pushed_at).valueOf(),
|
||||
bDate = new Date(b.pushed_at).valueOf();
|
||||
|
||||
if (aDate === bDate) { return 0; }
|
||||
return aDate > bDate ? -1 : 1;
|
||||
});
|
||||
|
||||
if (options.count) { repos.splice(options.count); }
|
||||
render(options.target, repos);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -11,6 +11,7 @@ function getNav() {
|
|||
mobileNav.children('select').bind('change', function(event) {
|
||||
if (event.target.value) { window.location.href = event.target.value; }
|
||||
});
|
||||
mobileNav.children('select').val('');
|
||||
}
|
||||
|
||||
function addSidebarToggler() {
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
layout: nil
|
||||
---
|
||||
User-agent: *
|
||||
Disallow:
|
||||
|
||||
Sitemap: {{ site.url }}/sitemap.xml
|
|
@ -0,0 +1,5 @@
|
|||
language: ruby
|
||||
rvm:
|
||||
- 1.9.3
|
||||
- 1.9.2
|
||||
script: bundle exec rake install; bundle exec rake generate
|
12
Gemfile
12
Gemfile
|
@ -1,18 +1,18 @@
|
|||
source "http://rubygems.org"
|
||||
|
||||
group :development do
|
||||
gem 'rake', '~> 0.9.2'
|
||||
gem 'rake', '~> 0.9'
|
||||
gem 'rack', '~> 1.4.1'
|
||||
gem 'jekyll', '~> 0.11.2'
|
||||
gem 'jekyll', '~> 0.12'
|
||||
gem 'rdiscount', '~> 1.6.8'
|
||||
gem 'pygments.rb', '~> 0.2.12'
|
||||
gem 'pygments.rb', '~> 0.3.4'
|
||||
gem 'RedCloth', '~> 4.2.9'
|
||||
gem 'haml', '~> 3.1.6'
|
||||
gem 'compass', '~> 0.12.1'
|
||||
gem 'haml', '~> 3.1.7'
|
||||
gem 'compass', '~> 0.12.2'
|
||||
gem 'rubypants', '~> 0.2.0'
|
||||
gem 'rb-fsevent', '~> 0.9'
|
||||
gem 'stringex', '~> 1.4.0'
|
||||
gem 'liquid', '~> 2.3.0'
|
||||
end
|
||||
|
||||
gem 'sinatra', '~> 1.3.2'
|
||||
gem 'sinatra', '~> 1.3.5'
|
||||
|
|
47
Gemfile.lock
47
Gemfile.lock
|
@ -2,9 +2,6 @@ GEM
|
|||
remote: http://rubygems.org/
|
||||
specs:
|
||||
RedCloth (4.2.9)
|
||||
albino (1.3.3)
|
||||
posix-spawn (>= 0.3.6)
|
||||
blankslate (2.1.2.4)
|
||||
chunky_png (1.2.5)
|
||||
classifier (1.3.3)
|
||||
fast-stemmer (>= 1.0.0)
|
||||
|
@ -14,56 +11,54 @@ GEM
|
|||
sass (~> 3.1)
|
||||
directory_watcher (1.4.1)
|
||||
fast-stemmer (1.0.1)
|
||||
ffi (1.0.11)
|
||||
fssm (0.2.9)
|
||||
haml (3.1.6)
|
||||
jekyll (0.11.2)
|
||||
albino (~> 1.3)
|
||||
haml (3.1.7)
|
||||
jekyll (0.12.0)
|
||||
classifier (~> 1.3)
|
||||
directory_watcher (~> 1.1)
|
||||
kramdown (~> 0.13)
|
||||
kramdown (~> 0.13.4)
|
||||
liquid (~> 2.3)
|
||||
maruku (~> 0.5)
|
||||
kramdown (0.13.7)
|
||||
pygments.rb (~> 0.3.2)
|
||||
kramdown (0.13.8)
|
||||
liquid (2.3.0)
|
||||
maruku (0.6.0)
|
||||
maruku (0.6.1)
|
||||
syntax (>= 1.0.0)
|
||||
posix-spawn (0.3.6)
|
||||
pygments.rb (0.2.13)
|
||||
rubypython (~> 0.5.3)
|
||||
rack (1.4.1)
|
||||
rack-protection (1.2.0)
|
||||
pygments.rb (0.3.4)
|
||||
posix-spawn (~> 0.3.6)
|
||||
yajl-ruby (~> 1.1.0)
|
||||
rack (1.4.5)
|
||||
rack-protection (1.3.2)
|
||||
rack
|
||||
rake (0.9.2.2)
|
||||
rb-fsevent (0.9.1)
|
||||
rdiscount (1.6.8)
|
||||
rubypants (0.2.0)
|
||||
rubypython (0.5.3)
|
||||
blankslate (>= 2.1.2.3)
|
||||
ffi (~> 1.0.7)
|
||||
sass (3.1.20)
|
||||
sinatra (1.3.2)
|
||||
rack (~> 1.3, >= 1.3.6)
|
||||
rack-protection (~> 1.2)
|
||||
sinatra (1.3.5)
|
||||
rack (~> 1.4)
|
||||
rack-protection (~> 1.3)
|
||||
tilt (~> 1.3, >= 1.3.3)
|
||||
stringex (1.4.0)
|
||||
syntax (1.0.0)
|
||||
tilt (1.3.3)
|
||||
yajl-ruby (1.1.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
RedCloth (~> 4.2.9)
|
||||
compass (~> 0.12.1)
|
||||
haml (~> 3.1.6)
|
||||
jekyll (~> 0.11.2)
|
||||
compass (~> 0.12.2)
|
||||
haml (~> 3.1.7)
|
||||
jekyll (~> 0.12)
|
||||
liquid (~> 2.3.0)
|
||||
pygments.rb (~> 0.2.12)
|
||||
pygments.rb (~> 0.3.4)
|
||||
rack (~> 1.4.1)
|
||||
rake (~> 0.9.2)
|
||||
rake (~> 0.9)
|
||||
rb-fsevent (~> 0.9)
|
||||
rdiscount (~> 1.6.8)
|
||||
rubypants (~> 0.2.0)
|
||||
sinatra (~> 1.3.2)
|
||||
sinatra (~> 1.3.5)
|
||||
stringex (~> 1.4.0)
|
||||
|
|
|
@ -16,13 +16,15 @@ Check out [Octopress.org](http://octopress.org/docs) for guides and documentatio
|
|||
|
||||
## Contributing
|
||||
|
||||
[![Build Status](https://travis-ci.org/imathis/octopress.png?branch=master)](https://travis-ci.org/imathis/octopress)
|
||||
|
||||
We love to see people contributing to Octopress, whether it's a bug report, feature suggestion or a pull request. At the moment, we try to keep the core slick and lean, focusing on basic blogging needs, so some of your suggestions might not find their way into Octopress. For those ideas, we started a [list of 3rd party plug-ins](https://github.com/imathis/octopress/wiki/3rd-party-plugins), where you can link your own Octopress plug-in repositories. For the future, we're thinking about ways to easier add them them into our main releases.
|
||||
|
||||
|
||||
## License
|
||||
(The MIT License)
|
||||
|
||||
Copyright © 2009-2011 Brandon Mathis
|
||||
Copyright © 2009-2013 Brandon Mathis
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
|
16
Rakefile
16
Rakefile
|
@ -9,6 +9,7 @@ ssh_port = "22"
|
|||
document_root = "~/website.com/"
|
||||
rsync_delete = false
|
||||
deploy_default = "push"
|
||||
rsync_args = "" # Any extra arguments to pass to rsync
|
||||
|
||||
# This will be configured for you when you run config_deploy
|
||||
deploy_branch = "master"
|
||||
|
@ -91,10 +92,13 @@ end
|
|||
# usage rake new_post[my-new-post] or rake new_post['my new post'] or rake new_post (defaults to "new-post")
|
||||
desc "Begin a new post in #{source_dir}/#{posts_dir}"
|
||||
task :new_post, :title do |t, args|
|
||||
if args.title
|
||||
title = args.title
|
||||
else
|
||||
title = get_stdin("Enter a title for your post: ")
|
||||
end
|
||||
raise "### You haven't set anything up yet. First run `rake install` to set up an Octopress theme." unless File.directory?(source_dir)
|
||||
mkdir_p "#{source_dir}/#{posts_dir}"
|
||||
args.with_defaults(:title => 'new-post')
|
||||
title = args.title
|
||||
filename = "#{source_dir}/#{posts_dir}/#{Time.now.strftime('%Y-%m-%d')}-#{title.to_url}.#{new_post_ext}"
|
||||
if File.exist?(filename)
|
||||
abort("rake aborted!") if ask("#{filename} already exists. Do you want to overwrite?", ['y', 'n']) == 'n'
|
||||
|
@ -151,7 +155,7 @@ task :new_page, :filename do |t, args|
|
|||
end
|
||||
|
||||
# usage rake isolate[my-post]
|
||||
desc "Move all other posts than the one currently being worked on to a temporary stash location (stash) so regenerating the site happens much quicker."
|
||||
desc "Move all other posts than the one currently being worked on to a temporary stash location (stash) so regenerating the site happens much more quickly."
|
||||
task :isolate, :filename do |t, args|
|
||||
stash_dir = "#{source_dir}/#{stash_dir}"
|
||||
FileUtils.mkdir(stash_dir) unless File.exist?(stash_dir)
|
||||
|
@ -237,7 +241,7 @@ task :rsync do
|
|||
exclude = "--exclude-from '#{File.expand_path('./rsync-exclude')}'"
|
||||
end
|
||||
puts "## Deploying website via Rsync"
|
||||
ok_failed system("rsync -avze 'ssh -p #{ssh_port}' #{exclude} #{"--delete" unless rsync_delete == false} #{public_dir}/ #{ssh_user}:#{document_root}")
|
||||
ok_failed system("rsync -avze 'ssh -p #{ssh_port}' #{exclude} #{rsync_args} #{"--delete" unless rsync_delete == false} #{public_dir}/ #{ssh_user}:#{document_root}")
|
||||
end
|
||||
|
||||
desc "deploy public directory to github pages"
|
||||
|
@ -304,9 +308,9 @@ task :setup_github_pages, :repo do |t, args|
|
|||
repo_url = get_stdin("Repository url: ")
|
||||
end
|
||||
user = repo_url.match(/:([^\/]+)/)[1]
|
||||
branch = (repo_url.match(/\/[\w-]+.github.com/).nil?) ? 'gh-pages' : 'master'
|
||||
branch = (repo_url.match(/\/[\w-]+\.github\.com/).nil?) ? 'gh-pages' : 'master'
|
||||
project = (branch == 'gh-pages') ? repo_url.match(/\/([^\.]+)/)[1] : ''
|
||||
unless `git remote -v`.match(/origin.+?octopress.git/).nil?
|
||||
unless (`git remote -v` =~ /origin.+?octopress(?:\.git)?/).nil?
|
||||
# If octopress is still the origin remote (from cloning) rename it to octopress
|
||||
system "git remote rename origin octopress"
|
||||
if branch == 'master'
|
||||
|
|
|
@ -2,7 +2,7 @@ require './plugins/pygments_code'
|
|||
|
||||
module BacktickCodeBlock
|
||||
include HighlightCode
|
||||
AllOptions = /([^\s]+)\s+(.+?)(https?:\/\/\S+)\s*(.+)?/i
|
||||
AllOptions = /([^\s]+)\s+(.+?)\s+(https?:\/\/\S+|\/\S+)\s*(.+)?/i
|
||||
LangCaption = /([^\s]+)\s*(.+)?/i
|
||||
def render_code_block(input)
|
||||
@options = nil
|
||||
|
|
|
@ -21,6 +21,7 @@ module Jekyll
|
|||
class Blockquote < Liquid::Block
|
||||
FullCiteWithTitle = /(\S.*)\s+(https?:\/\/)(\S+)\s+(.+)/i
|
||||
FullCite = /(\S.*)\s+(https?:\/\/)(\S+)/i
|
||||
AuthorTitle = /([^,]+),([^,]+)/
|
||||
Author = /(.+)/
|
||||
|
||||
def initialize(tag_name, markup, tokens)
|
||||
|
@ -30,17 +31,15 @@ module Jekyll
|
|||
if markup =~ FullCiteWithTitle
|
||||
@by = $1
|
||||
@source = $2 + $3
|
||||
@title = $4.titlecase
|
||||
@title = $4.titlecase.strip
|
||||
elsif markup =~ FullCite
|
||||
@by = $1
|
||||
@source = $2 + $3
|
||||
elsif markup =~ AuthorTitle
|
||||
@by = $1
|
||||
@title = $2.titlecase.strip
|
||||
elsif markup =~ Author
|
||||
if $1 =~ /([^,]+),([^,]+)/
|
||||
@by = $1
|
||||
@title = $2.titlecase
|
||||
else
|
||||
@by = $1
|
||||
end
|
||||
@by = $1
|
||||
end
|
||||
super
|
||||
end
|
||||
|
|
|
@ -19,6 +19,8 @@
|
|||
# - category_title_prefix: The string used before the category name in the page title (default is
|
||||
# 'Category: ').
|
||||
|
||||
require 'stringex'
|
||||
|
||||
module Jekyll
|
||||
|
||||
# The CategoryIndex class creates a single category page for the specified category.
|
||||
|
@ -106,12 +108,22 @@ module Jekyll
|
|||
if self.layouts.key? 'category_index'
|
||||
dir = self.config['category_dir'] || 'categories'
|
||||
self.categories.keys.each do |category|
|
||||
self.write_category_index(File.join(dir, category.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase), category)
|
||||
self.write_category_index(File.join(dir, category.to_url), category)
|
||||
end
|
||||
|
||||
# Throw an exception if the layout couldn't be found.
|
||||
else
|
||||
throw "No 'category_index' layout found."
|
||||
raise <<-ERR
|
||||
|
||||
|
||||
===============================================
|
||||
Error for category_generator.rb plugin
|
||||
-----------------------------------------------
|
||||
No 'category_index.hmtl' in source/_layouts/
|
||||
Perhaps you haven't installed a theme yet.
|
||||
===============================================
|
||||
|
||||
ERR
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -141,10 +153,7 @@ module Jekyll
|
|||
# Returns string
|
||||
#
|
||||
def category_links(categories)
|
||||
dir = @context.registers[:site].config['category_dir']
|
||||
categories = categories.sort!.map do |item|
|
||||
"<a class='category' href='/#{dir}/#{item.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase}/'>#{item}</a>"
|
||||
end
|
||||
categories = categories.sort!.map { |c| category_link c }
|
||||
|
||||
case categories.length
|
||||
when 0
|
||||
|
@ -156,6 +165,17 @@ module Jekyll
|
|||
end
|
||||
end
|
||||
|
||||
# Outputs a single category as an <a> link.
|
||||
#
|
||||
# +category+ is a category string to format as an <a> link
|
||||
#
|
||||
# Returns string
|
||||
#
|
||||
def category_link(category)
|
||||
dir = @context.registers[:site].config['category_dir']
|
||||
"<a class='category' href='/#{dir}/#{category.to_url}/'>#{category}</a>"
|
||||
end
|
||||
|
||||
# Outputs the post.date as formatted html, with hooks for CSS styling.
|
||||
#
|
||||
# +date+ is the date object to format as HTML.
|
||||
|
|
|
@ -49,8 +49,7 @@ module Jekyll
|
|||
class CodeBlock < Liquid::Block
|
||||
include HighlightCode
|
||||
include TemplateWrapper
|
||||
CaptionUrlTitle = /(\S[\S\s]*)\s+(https?:\/\/)(\S+)\s+(.+)/i
|
||||
CaptionUrl = /(\S[\S\s]*)\s+(https?:\/\/)(\S+)/i
|
||||
CaptionUrlTitle = /(\S[\S\s]*)\s+(https?:\/\/\S+|\/\S+)\s*(.+)?/i
|
||||
Caption = /(\S[\S\s]*)/
|
||||
def initialize(tag_name, markup, tokens)
|
||||
@title = nil
|
||||
|
@ -63,10 +62,7 @@ module Jekyll
|
|||
end
|
||||
if markup =~ CaptionUrlTitle
|
||||
@file = $1
|
||||
@caption = "<figcaption><span>#{$1}</span><a href='#{$2 + $3}'>#{$4}</a></figcaption>"
|
||||
elsif markup =~ CaptionUrl
|
||||
@file = $1
|
||||
@caption = "<figcaption><span>#{$1}</span><a href='#{$2 + $3}'>link</a></figcaption>"
|
||||
@caption = "<figcaption><span>#{$1}</span><a href='#{$2}'>#{$3 || 'link'}</a></figcaption>"
|
||||
elsif markup =~ Caption
|
||||
@file = $1
|
||||
@caption = "<figcaption><span>#{$1}</span></figcaption>\n"
|
||||
|
|
|
@ -40,7 +40,9 @@ module Jekyll
|
|||
end
|
||||
|
||||
def script_url_for(gist_id, filename)
|
||||
"https://gist.github.com/#{gist_id}.js?file=#{filename}"
|
||||
url = "https://gist.github.com/#{gist_id}.js"
|
||||
url = "#{url}?file=#{filename}" unless filename.nil? or filename.empty?
|
||||
url
|
||||
end
|
||||
|
||||
def get_gist_url_for(gist, file)
|
||||
|
@ -82,6 +84,9 @@ module Jekyll
|
|||
https.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
request = Net::HTTP::Get.new raw_uri.request_uri
|
||||
data = https.request request
|
||||
if data.code.to_i != 200
|
||||
raise RuntimeError, "Gist replied with #{data.code} for #{gist_url}"
|
||||
end
|
||||
data = data.body
|
||||
cache gist, file, data unless @cache_disabled
|
||||
data
|
||||
|
|
|
@ -21,7 +21,11 @@ module HighlightCode
|
|||
if File.exist?(path)
|
||||
highlighted_code = File.read(path)
|
||||
else
|
||||
highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8'})
|
||||
begin
|
||||
highlighted_code = Pygments.highlight(code, :lexer => lang, :formatter => 'html', :options => {:encoding => 'utf-8'})
|
||||
rescue MentosError
|
||||
raise "Pygments can't parse unknown language: #{lang}."
|
||||
end
|
||||
File.open(path, 'w') {|f| f.print(highlighted_code) }
|
||||
end
|
||||
else
|
||||
|
|
|
@ -22,22 +22,31 @@ module Jekyll
|
|||
@width = ''
|
||||
|
||||
def initialize(tag_name, markup, tokens)
|
||||
if markup =~ /((https?:\/\/|\/)(\S+))(\s+(\d+)\s(\d+))?(\s+(https?:\/\/|\/)(\S+))?/i
|
||||
@video = $1
|
||||
@width = $5
|
||||
@height = $6
|
||||
@poster = $7
|
||||
if markup =~ /(https?:\S+)(\s+(https?:\S+))?(\s+(https?:\S+))?(\s+(\d+)\s(\d+))?(\s+(https?:\S+))?/i
|
||||
@video = [$1, $3, $5].compact
|
||||
@width = $7
|
||||
@height = $8
|
||||
@poster = $10
|
||||
end
|
||||
super
|
||||
end
|
||||
|
||||
def render(context)
|
||||
output = super
|
||||
if @video
|
||||
type = {
|
||||
'mp4' => "type='video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"'",
|
||||
'ogv' => "type='video/ogg; codecs=theora, vorbis'",
|
||||
'webm' => "type='video/webm; codecs=vp8, vorbis'"
|
||||
}
|
||||
if @video.size > 0
|
||||
video = "<video width='#{@width}' height='#{@height}' preload='none' controls poster='#{@poster}'>"
|
||||
video += "<source src='#{@video}' type='video/mp4; codecs=\"avc1.42E01E, mp4a.40.2\"'/></video>"
|
||||
@video.each do |v|
|
||||
t = v.match(/([^\.]+)$/)[1]
|
||||
video += "<source src='#{v}' #{type[t]}>"
|
||||
end
|
||||
video += "</video>"
|
||||
else
|
||||
"Error processing input, expected syntax: {% video url/to/video [width height] [url/to/poster] %}"
|
||||
"Error processing input, expected syntax: {% video url/to/video [url/to/video] [url/to/video] [width height] [url/to/poster] %}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue