tigefa 1.0.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.markdown +91 -0
- data/Gemfile +2 -0
- data/History.markdown +871 -0
- data/LICENSE +15 -14
- data/README.markdown +59 -0
- data/Rakefile +298 -0
- data/bin/tigefa +158 -0
- data/cucumber.yml +3 -0
- data/features/create_sites.feature +141 -0
- data/features/data.feature +65 -0
- data/features/drafts.feature +25 -0
- data/features/embed_filters.feature +60 -0
- data/features/include_tag.feature +57 -0
- data/features/markdown.feature +67 -0
- data/features/pagination.feature +82 -0
- data/features/permalinks.feature +85 -0
- data/features/post_data.feature +214 -0
- data/features/post_excerpts.feature +50 -0
- data/features/site_configuration.feature +235 -0
- data/features/site_data.feature +107 -0
- data/features/step_definitions/tigefa_steps.rb +189 -0
- data/features/support/env.rb +75 -0
- data/lib/site_template/.gitignore +1 -0
- data/lib/site_template/_config.yml +3 -0
- data/lib/site_template/_layouts/default.html +44 -0
- data/lib/site_template/_layouts/post.html +9 -0
- data/lib/site_template/_posts/0000-00-00-welcome-to-jekyll.markdown.erb +24 -0
- data/lib/site_template/css/main.css +160 -0
- data/lib/site_template/css/syntax.css +60 -0
- data/lib/site_template/index.html +13 -0
- data/lib/tigefa/cleaner.rb +73 -0
- data/lib/tigefa/command.rb +27 -0
- data/lib/tigefa/commands/build.rb +70 -0
- data/lib/tigefa/commands/doctor.rb +67 -0
- data/lib/tigefa/commands/new.rb +67 -0
- data/lib/tigefa/commands/serve.rb +65 -0
- data/lib/tigefa/configuration.rb +238 -0
- data/lib/tigefa/converter.rb +48 -0
- data/lib/tigefa/converters/identity.rb +21 -0
- data/lib/tigefa/converters/markdown/kramdown_parser.rb +29 -0
- data/lib/tigefa/converters/markdown/maruku_parser.rb +56 -0
- data/lib/tigefa/converters/markdown/rdiscount_parser.rb +37 -0
- data/lib/tigefa/converters/markdown/redcarpet_parser.rb +70 -0
- data/lib/tigefa/converters/markdown.rb +43 -0
- data/lib/tigefa/converters/textile.rb +50 -0
- data/lib/tigefa/convertible.rb +174 -0
- data/lib/tigefa/core_ext.rb +90 -0
- data/lib/tigefa/deprecator.rb +36 -0
- data/lib/tigefa/draft.rb +35 -0
- data/lib/tigefa/entry_filter.rb +35 -0
- data/lib/tigefa/errors.rb +4 -0
- data/lib/tigefa/excerpt.rb +113 -0
- data/lib/tigefa/filters.rb +174 -0
- data/lib/tigefa/generator.rb +4 -0
- data/lib/tigefa/generators/pagination.rb +217 -0
- data/lib/tigefa/layout.rb +45 -0
- data/lib/tigefa/mime.types +85 -0
- data/lib/tigefa/page.rb +160 -0
- data/lib/tigefa/plugin.rb +75 -0
- data/lib/tigefa/post.rb +312 -0
- data/lib/tigefa/related_posts.rb +59 -0
- data/lib/tigefa/site.rb +427 -0
- data/lib/tigefa/static_file.rb +70 -0
- data/lib/tigefa/stevenson.rb +89 -0
- data/lib/tigefa/tags/gist.rb +48 -0
- data/lib/tigefa/tags/highlight.rb +85 -0
- data/lib/tigefa/tags/include.rb +134 -0
- data/lib/tigefa/tags/post_url.rb +63 -0
- data/lib/tigefa/url.rb +69 -0
- data/lib/tigefa.rb +98 -4
- data/script/bootstrap +2 -0
- data/site/.gitignore +4 -0
- data/site/CNAME +1 -0
- data/site/README +1 -0
- data/site/_config.yml +6 -0
- data/site/_includes/analytics.html +32 -0
- data/site/_includes/docs_contents.html +16 -0
- data/site/_includes/docs_contents_mobile.html +23 -0
- data/site/_includes/docs_option.html +11 -0
- data/site/_includes/docs_ul.html +20 -0
- data/site/_includes/footer.html +15 -0
- data/site/_includes/header.html +18 -0
- data/site/_includes/news_contents.html +23 -0
- data/site/_includes/news_contents_mobile.html +11 -0
- data/site/_includes/news_item.html +24 -0
- data/site/_includes/primary-nav-items.html +14 -0
- data/site/_includes/section_nav.html +22 -0
- data/site/_includes/top.html +17 -0
- data/site/_layouts/default.html +12 -0
- data/site/_layouts/docs.html +23 -0
- data/site/_layouts/news.html +19 -0
- data/site/_layouts/news_item.html +27 -0
- data/site/_posts/2013-05-06-jekyll-1-0-0-released.markdown +23 -0
- data/site/_posts/2013-05-08-jekyll-1-0-1-released.markdown +27 -0
- data/site/_posts/2013-05-12-jekyll-1-0-2-released.markdown +28 -0
- data/site/_posts/2013-06-07-jekyll-1-0-3-released.markdown +25 -0
- data/site/_posts/2013-07-14-jekyll-1-1-0-released.markdown +27 -0
- data/site/_posts/2013-07-24-jekyll-1-1-1-released.markdown +31 -0
- data/site/_posts/2013-07-25-jekyll-1-0-4-released.markdown +20 -0
- data/site/_posts/2013-07-25-jekyll-1-1-2-released.markdown +20 -0
- data/site/_posts/2013-09-06-jekyll-1-2-0-released.markdown +23 -0
- data/site/_posts/2013-09-14-jekyll-1-2-1-released.markdown +19 -0
- data/site/_posts/2013-10-28-jekyll-1-3-0-rc1-released.markdown +19 -0
- data/site/_posts/2013-11-04-jekyll-1-3-0-released.markdown +43 -0
- data/site/_posts/2013-11-26-jekyll-1-3-1-released.markdown +21 -0
- data/site/_posts/2013-12-07-jekyll-1-4-0-released.markdown +30 -0
- data/site/_posts/2013-12-16-jekyll-1-4-2-released.markdown +18 -0
- data/site/_posts/2014-01-13-jekyll-1-4-3-released.markdown +27 -0
- data/site/css/gridism.css +110 -0
- data/site/css/normalize.css +1 -0
- data/site/css/pygments.css +70 -0
- data/site/css/style.css +946 -0
- data/site/docs/configuration.md +375 -0
- data/site/docs/contributing.md +128 -0
- data/site/docs/datafiles.md +63 -0
- data/site/docs/deployment-methods.md +109 -0
- data/site/docs/drafts.md +21 -0
- data/site/docs/extras.md +56 -0
- data/site/docs/frontmatter.md +180 -0
- data/site/docs/github-pages.md +91 -0
- data/site/docs/heroku.md +9 -0
- data/site/docs/history.md +866 -0
- data/site/docs/index.md +52 -0
- data/site/docs/installation.md +76 -0
- data/site/docs/migrations.md +11 -0
- data/site/docs/pages.md +86 -0
- data/site/docs/pagination.md +211 -0
- data/site/docs/permalinks.md +180 -0
- data/site/docs/plugins.md +534 -0
- data/site/docs/posts.md +181 -0
- data/site/docs/quickstart.md +32 -0
- data/site/docs/resources.md +46 -0
- data/site/docs/sites.md +29 -0
- data/site/docs/structure.md +190 -0
- data/site/docs/templates.md +339 -0
- data/site/docs/troubleshooting.md +150 -0
- data/site/docs/upgrading.md +146 -0
- data/site/docs/usage.md +63 -0
- data/site/docs/variables.md +322 -0
- data/site/favicon.png +0 -0
- data/site/feed.xml +36 -0
- data/site/freenode.txt +1 -0
- data/site/img/article-footer.png +0 -0
- data/site/img/footer-arrow.png +0 -0
- data/site/img/footer-logo.png +0 -0
- data/site/img/logo-2x.png +0 -0
- data/site/img/octojekyll.png +0 -0
- data/site/img/tube.png +0 -0
- data/site/img/tube1x.png +0 -0
- data/site/index.html +90 -0
- data/site/js/modernizr-2.5.3.min.js +4 -0
- data/site/news/index.html +10 -0
- data/site/news/releases/index.html +10 -0
- data/test/fixtures/broken_front_matter1.erb +5 -0
- data/test/fixtures/broken_front_matter2.erb +4 -0
- data/test/fixtures/broken_front_matter3.erb +7 -0
- data/test/fixtures/exploit_front_matter.erb +4 -0
- data/test/fixtures/front_matter.erb +4 -0
- data/test/helper.rb +65 -0
- data/test/source/+/foo.md +7 -0
- data/test/source/.htaccess +8 -0
- data/test/source/_config.dev.toml +2 -0
- data/test/source/_data/languages.yml +2 -0
- data/test/source/_data/members.yaml +7 -0
- data/test/source/_data/products.yml +1 -0
- data/test/source/_includes/params.html +7 -0
- data/test/source/_includes/sig.markdown +3 -0
- data/test/source/_includes/tmp +1 -0
- data/test/source/_layouts/default.html +27 -0
- data/test/source/_layouts/post/simple.html +1 -0
- data/test/source/_layouts/simple.html +1 -0
- data/test/source/_plugins/dummy.rb +8 -0
- data/test/source/_posts/2008-02-02-not-published.textile +8 -0
- data/test/source/_posts/2008-02-02-published.textile +8 -0
- data/test/source/_posts/2008-10-18-foo-bar.textile +8 -0
- data/test/source/_posts/2008-11-21-complex.textile +8 -0
- data/test/source/_posts/2008-12-03-permalinked-post.textile +9 -0
- data/test/source/_posts/2008-12-13-include.markdown +8 -0
- data/test/source/_posts/2009-01-27-array-categories.textile +10 -0
- data/test/source/_posts/2009-01-27-categories.textile +7 -0
- data/test/source/_posts/2009-01-27-category.textile +7 -0
- data/test/source/_posts/2009-01-27-empty-categories.textile +7 -0
- data/test/source/_posts/2009-01-27-empty-category.textile +7 -0
- data/test/source/_posts/2009-03-12-hash-#1.markdown +6 -0
- data/test/source/_posts/2009-05-18-empty-tag.textile +6 -0
- data/test/source/_posts/2009-05-18-empty-tags.textile +6 -0
- data/test/source/_posts/2009-05-18-tag.textile +6 -0
- data/test/source/_posts/2009-05-18-tags.textile +9 -0
- data/test/source/_posts/2009-06-22-empty-yaml.textile +3 -0
- data/test/source/_posts/2009-06-22-no-yaml.textile +1 -0
- data/test/source/_posts/2010-01-08-triple-dash.markdown +5 -0
- data/test/source/_posts/2010-01-09-date-override.textile +7 -0
- data/test/source/_posts/2010-01-09-time-override.textile +7 -0
- data/test/source/_posts/2010-01-09-timezone-override.textile +7 -0
- data/test/source/_posts/2010-01-16-override-data.textile +4 -0
- data/test/source/_posts/2011-04-12-md-extension.md +7 -0
- data/test/source/_posts/2011-04-12-text-extension.text +0 -0
- data/test/source/_posts/2013-01-02-post-excerpt.markdown +14 -0
- data/test/source/_posts/2013-01-12-nil-layout.textile +6 -0
- data/test/source/_posts/2013-01-12-no-layout.textile +5 -0
- data/test/source/_posts/2013-03-19-not-a-post.markdown/.gitkeep +0 -0
- data/test/source/_posts/2013-04-11-custom-excerpt.markdown +10 -0
- data/test/source/_posts/2013-05-10-number-category.textile +7 -0
- data/test/source/_posts/2013-07-22-post-excerpt-with-layout.markdown +23 -0
- data/test/source/_posts/2013-08-01-mkdn-extension.mkdn +0 -0
- data/test/source/_posts/2014-01-06-permalink-traversal.md +5 -0
- data/test/source/_posts/es/2008-11-21-nested.textile +8 -0
- data/test/source/about.html +6 -0
- data/test/source/category/_posts/2008-9-23-categories.textile +6 -0
- data/test/source/contacts/bar.html +5 -0
- data/test/source/contacts/index.html +5 -0
- data/test/source/contacts.html +5 -0
- data/test/source/css/screen.css +76 -0
- data/test/source/deal.with.dots.html +7 -0
- data/test/source/exploit.md +5 -0
- data/test/source/foo/_posts/bar/2008-12-12-topical-post.textile +8 -0
- data/test/source/index.html +22 -0
- data/test/source/products.yml +4 -0
- data/test/source/sitemap.xml +32 -0
- data/test/source/symlink-test/_data +1 -0
- data/test/source/symlink-test/symlinked-dir +1 -0
- data/test/source/symlink-test/symlinked-file +1 -0
- data/test/source/win/_posts/2009-05-24-yaml-linebreak.markdown +7 -0
- data/test/source/z_category/_posts/2008-9-23-categories.textile +6 -0
- data/test/suite.rb +11 -0
- data/test/test_command.rb +39 -0
- data/test/test_configuration.rb +181 -0
- data/test/test_convertible.rb +51 -0
- data/test/test_core_ext.rb +88 -0
- data/test/test_entry_filter.rb +74 -0
- data/test/test_excerpt.rb +78 -0
- data/test/test_filters.rb +113 -0
- data/test/test_generated_site.rb +83 -0
- data/test/test_kramdown.rb +62 -0
- data/test/test_new_command.rb +104 -0
- data/test/test_page.rb +212 -0
- data/test/test_pager.rb +116 -0
- data/test/test_post.rb +592 -0
- data/test/test_rdiscount.rb +22 -0
- data/test/test_redcarpet.rb +61 -0
- data/test/test_redcloth.rb +86 -0
- data/test/test_related_posts.rb +47 -0
- data/test/test_site.rb +333 -0
- data/test/test_tags.rb +490 -0
- data/test/test_url.rb +28 -0
- data/tigefa.gemspec +306 -0
- metadata +575 -45
- data/README.md +0 -4
@@ -0,0 +1,85 @@
|
|
1
|
+
module Tigefa
|
2
|
+
module Tags
|
3
|
+
class HighlightBlock < Liquid::Block
|
4
|
+
include Liquid::StandardFilters
|
5
|
+
|
6
|
+
# The regular expression syntax checker. Start with the language specifier.
|
7
|
+
# Follow that by zero or more space separated options that take one of two
|
8
|
+
# forms:
|
9
|
+
#
|
10
|
+
# 1. name
|
11
|
+
# 2. name=value
|
12
|
+
SYNTAX = /^([a-zA-Z0-9.+#-]+)((\s+\w+(=\w+)?)*)$/
|
13
|
+
|
14
|
+
def initialize(tag_name, markup, tokens)
|
15
|
+
super
|
16
|
+
if markup.strip =~ SYNTAX
|
17
|
+
@lang = $1.downcase
|
18
|
+
@options = {}
|
19
|
+
if defined?($2) && $2 != ''
|
20
|
+
$2.split.each do |opt|
|
21
|
+
key, value = opt.split('=')
|
22
|
+
if value.nil?
|
23
|
+
if key == 'linenos'
|
24
|
+
value = 'inline'
|
25
|
+
else
|
26
|
+
value = true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
@options[key] = value
|
30
|
+
end
|
31
|
+
end
|
32
|
+
else
|
33
|
+
raise SyntaxError.new <<-eos
|
34
|
+
Syntax Error in tag 'highlight' while parsing the following markup:
|
35
|
+
|
36
|
+
#{markup}
|
37
|
+
|
38
|
+
Valid syntax: highlight <lang> [linenos]
|
39
|
+
eos
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def render(context)
|
44
|
+
if context.registers[:site].pygments
|
45
|
+
render_pygments(context, super)
|
46
|
+
else
|
47
|
+
render_codehighlighter(context, super)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def render_pygments(context, code)
|
52
|
+
require 'pygments'
|
53
|
+
|
54
|
+
@options[:encoding] = 'utf-8'
|
55
|
+
|
56
|
+
output = add_code_tags(
|
57
|
+
Pygments.highlight(code, :lexer => @lang, :options => @options),
|
58
|
+
@lang
|
59
|
+
)
|
60
|
+
|
61
|
+
output = context["pygments_prefix"] + output if context["pygments_prefix"]
|
62
|
+
output = output + context["pygments_suffix"] if context["pygments_suffix"]
|
63
|
+
output
|
64
|
+
end
|
65
|
+
|
66
|
+
def render_codehighlighter(context, code)
|
67
|
+
#The div is required because RDiscount blows ass
|
68
|
+
<<-HTML
|
69
|
+
<div>
|
70
|
+
<pre><code class='#{@lang}'>#{h(code).strip}</code></pre>
|
71
|
+
</div>
|
72
|
+
HTML
|
73
|
+
end
|
74
|
+
|
75
|
+
def add_code_tags(code, lang)
|
76
|
+
# Add nested <code> tags to code blocks
|
77
|
+
code = code.sub(/<pre>/,'<pre><code class="' + lang + '">')
|
78
|
+
code = code.sub(/<\/pre>/,"</code></pre>")
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
Liquid::Template.register_tag('highlight', Jekyll::Tags::HighlightBlock)
|
@@ -0,0 +1,134 @@
|
|
1
|
+
module Tigefa
|
2
|
+
module Tags
|
3
|
+
class IncludeTagError < StandardError
|
4
|
+
attr_accessor :path
|
5
|
+
|
6
|
+
def initialize(msg, path)
|
7
|
+
super(msg)
|
8
|
+
@path = path
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class IncludeTag < Liquid::Tag
|
13
|
+
|
14
|
+
SYNTAX_EXAMPLE = "{% include file.ext param='value' param2='value' %}"
|
15
|
+
|
16
|
+
VALID_SYNTAX = /([\w-]+)\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w\.-]+))/
|
17
|
+
|
18
|
+
INCLUDES_DIR = '_includes'
|
19
|
+
|
20
|
+
def initialize(tag_name, markup, tokens)
|
21
|
+
super
|
22
|
+
@file, @params = markup.strip.split(' ', 2);
|
23
|
+
validate_params if @params
|
24
|
+
end
|
25
|
+
|
26
|
+
def parse_params(context)
|
27
|
+
params = {}
|
28
|
+
markup = @params
|
29
|
+
|
30
|
+
while match = VALID_SYNTAX.match(markup) do
|
31
|
+
markup = markup[match.end(0)..-1]
|
32
|
+
|
33
|
+
value = if match[2]
|
34
|
+
match[2].gsub(/\\"/, '"')
|
35
|
+
elsif match[3]
|
36
|
+
match[3].gsub(/\\'/, "'")
|
37
|
+
elsif match[4]
|
38
|
+
context[match[4]]
|
39
|
+
end
|
40
|
+
|
41
|
+
params[match[1]] = value
|
42
|
+
end
|
43
|
+
params
|
44
|
+
end
|
45
|
+
|
46
|
+
def validate_file_name(file)
|
47
|
+
if file !~ /^[a-zA-Z0-9_\/\.-]+$/ || file =~ /\.\// || file =~ /\/\./
|
48
|
+
raise ArgumentError.new <<-eos
|
49
|
+
Invalid syntax for include tag. File contains invalid characters or sequences:
|
50
|
+
|
51
|
+
#{@file}
|
52
|
+
|
53
|
+
Valid syntax:
|
54
|
+
|
55
|
+
#{SYNTAX_EXAMPLE}
|
56
|
+
|
57
|
+
eos
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def validate_params
|
62
|
+
full_valid_syntax = Regexp.compile('\A\s*(?:' + VALID_SYNTAX.to_s + '(?=\s|\z)\s*)*\z')
|
63
|
+
unless @params =~ full_valid_syntax
|
64
|
+
raise ArgumentError.new <<-eos
|
65
|
+
Invalid syntax for include tag:
|
66
|
+
|
67
|
+
#{@params}
|
68
|
+
|
69
|
+
Valid syntax:
|
70
|
+
|
71
|
+
#{SYNTAX_EXAMPLE}
|
72
|
+
|
73
|
+
eos
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Grab file read opts in the context
|
78
|
+
def file_read_opts(context)
|
79
|
+
context.registers[:site].file_read_opts
|
80
|
+
end
|
81
|
+
|
82
|
+
def retrieve_variable(context)
|
83
|
+
if /\{\{([\w\-\.]+)\}\}/ =~ @file
|
84
|
+
raise ArgumentError.new("No variable #{$1} was found in include tag") if context[$1].nil?
|
85
|
+
context[$1]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def render(context)
|
90
|
+
dir = File.join(File.realpath(context.registers[:site].source), INCLUDES_DIR)
|
91
|
+
|
92
|
+
file = retrieve_variable(context) || @file
|
93
|
+
validate_file_name(file)
|
94
|
+
|
95
|
+
path = File.join(dir, file)
|
96
|
+
validate_path(path, dir, context.registers[:site].safe)
|
97
|
+
|
98
|
+
begin
|
99
|
+
partial = Liquid::Template.parse(source(path, context))
|
100
|
+
|
101
|
+
context.stack do
|
102
|
+
context['include'] = parse_params(context) if @params
|
103
|
+
partial.render!(context)
|
104
|
+
end
|
105
|
+
rescue => e
|
106
|
+
raise IncludeTagError.new e.message, File.join(INCLUDES_DIR, @file)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def validate_path(path, dir, safe)
|
111
|
+
if safe && !realpath_prefixed_with?(path, dir)
|
112
|
+
raise IOError.new "The included file '#{path}' should exist and should not be a symlink"
|
113
|
+
elsif !File.exist?(path)
|
114
|
+
raise IOError.new "Included file '#{path}' not found"
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def realpath_prefixed_with?(path, dir)
|
119
|
+
File.exist?(path) && File.realpath(path).start_with?(dir)
|
120
|
+
end
|
121
|
+
|
122
|
+
def blank?
|
123
|
+
false
|
124
|
+
end
|
125
|
+
|
126
|
+
# This method allows to modify the file content by inheriting from the class.
|
127
|
+
def source(file, context)
|
128
|
+
File.read_with_options(file, file_read_opts(context))
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
Liquid::Template.register_tag('include', Jekyll::Tags::IncludeTag)
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module TigefaTigefa
|
2
|
+
module Tags
|
3
|
+
class PostComparer
|
4
|
+
MATCHER = /^(.+\/)*(\d+-\d+-\d+)-(.*)$/
|
5
|
+
|
6
|
+
attr_accessor :date, :slug
|
7
|
+
|
8
|
+
def initialize(name)
|
9
|
+
all, path, date, slug = *name.sub(/^\//, "").match(MATCHER)
|
10
|
+
@slug = path ? path + slug : slug
|
11
|
+
@date = Time.parse(date)
|
12
|
+
end
|
13
|
+
|
14
|
+
def ==(other)
|
15
|
+
slug == post_slug(other) &&
|
16
|
+
date.year == other.date.year &&
|
17
|
+
date.month == other.date.month &&
|
18
|
+
date.day == other.date.day
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
# Construct the directory-aware post slug for a TigefaTigefa::Post
|
23
|
+
#
|
24
|
+
# other - the TigefaTigefa::Post
|
25
|
+
#
|
26
|
+
# Returns the post slug with the subdirectory (relative to _posts)
|
27
|
+
def post_slug(other)
|
28
|
+
path = other.name.split("/")[0...-1].join("/")
|
29
|
+
if path.nil? || path == ""
|
30
|
+
other.slug
|
31
|
+
else
|
32
|
+
path + '/' + other.slug
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
class PostUrl < Liquid::Tag
|
38
|
+
def initialize(tag_name, post, tokens)
|
39
|
+
super
|
40
|
+
@orig_post = post.strip
|
41
|
+
@post = PostComparer.new(@orig_post)
|
42
|
+
end
|
43
|
+
|
44
|
+
def render(context)
|
45
|
+
site = context.registers[:site]
|
46
|
+
|
47
|
+
site.posts.each do |p|
|
48
|
+
if @post == p
|
49
|
+
return p.url
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
raise ArgumentError.new <<-eos
|
54
|
+
Could not find post "#{@orig_post}" in tag 'post_url'.
|
55
|
+
|
56
|
+
Make sure the post exists and the name is correct.
|
57
|
+
eos
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
Liquid::Template.register_tag('post_url', Tigefa::Tags::PostUrl)
|
data/lib/tigefa/url.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Public: Methods that generate a URL for a resource such as a Post or a Page.
|
2
|
+
#
|
3
|
+
# Examples
|
4
|
+
#
|
5
|
+
# URL.new({
|
6
|
+
# :template => /:categories/:title.html",
|
7
|
+
# :placeholders => {:categories => "ruby", :title => "something"}
|
8
|
+
# }).to_s
|
9
|
+
#
|
10
|
+
module Tigefa
|
11
|
+
class URL
|
12
|
+
|
13
|
+
# options - One of :permalink or :template must be supplied.
|
14
|
+
# :template - The String used as template for URL generation,
|
15
|
+
# for example "/:path/:basename:output_ext", where
|
16
|
+
# a placeholder is prefixed with a colon.
|
17
|
+
# :placeholders - A hash containing the placeholders which will be
|
18
|
+
# replaced when used inside the template. E.g.
|
19
|
+
# { "year" => Time.now.strftime("%Y") } would replace
|
20
|
+
# the placeholder ":year" with the current year.
|
21
|
+
# :permalink - If supplied, no URL will be generated from the
|
22
|
+
# template. Instead, the given permalink will be
|
23
|
+
# used as URL.
|
24
|
+
def initialize(options)
|
25
|
+
@template = options[:template]
|
26
|
+
@placeholders = options[:placeholders] || {}
|
27
|
+
@permalink = options[:permalink]
|
28
|
+
|
29
|
+
if (@template || @permalink).nil?
|
30
|
+
raise ArgumentError, "One of :template or :permalink must be supplied."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# The generated relative URL of the resource
|
35
|
+
#
|
36
|
+
# Returns the String URL
|
37
|
+
def to_s
|
38
|
+
sanitize_url(@permalink || generate_url)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Internal: Generate the URL by replacing all placeholders with their
|
42
|
+
# respective values
|
43
|
+
#
|
44
|
+
# Returns the _unsanitizied_ String URL
|
45
|
+
def generate_url
|
46
|
+
@placeholders.inject(@template) do |result, token|
|
47
|
+
result.gsub(/:#{token.first}/, token.last)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Returns a sanitized String URL
|
52
|
+
def sanitize_url(in_url)
|
53
|
+
|
54
|
+
# Remove all double slashes
|
55
|
+
url = in_url.gsub(/\/\//, "/")
|
56
|
+
|
57
|
+
# Remove every URL segment that consists solely of dots
|
58
|
+
url = url.split('/').reject{ |part| part =~ /^\.+$/ }.join('/')
|
59
|
+
|
60
|
+
# Append a trailing slash to the URL if the unsanitized URL had one
|
61
|
+
url += "/" if in_url =~ /\/$/
|
62
|
+
|
63
|
+
# Always add a leading slash
|
64
|
+
url.gsub!(/\A([^\/])/, '/\1')
|
65
|
+
|
66
|
+
url
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/tigefa.rb
CHANGED
@@ -1,6 +1,100 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
$:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
|
2
|
+
|
3
|
+
# Require all of the Ruby files in the given directory.
|
4
|
+
#
|
5
|
+
# path - The String relative path from here to the directory.
|
6
|
+
#
|
7
|
+
# Returns nothing.
|
8
|
+
def require_all(path)
|
9
|
+
glob = File.join(File.dirname(__FILE__), path, '*.rb')
|
10
|
+
Dir[glob].each do |f|
|
11
|
+
require f
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# rubygems
|
16
|
+
require 'rubygems'
|
17
|
+
|
18
|
+
# stdlib
|
19
|
+
require 'fileutils'
|
20
|
+
require 'time'
|
21
|
+
require 'safe_yaml'
|
22
|
+
require 'English'
|
23
|
+
require 'pathname'
|
24
|
+
|
25
|
+
# 3rd party
|
26
|
+
require 'liquid'
|
27
|
+
require 'maruku'
|
28
|
+
require 'colorator'
|
29
|
+
require 'toml'
|
30
|
+
|
31
|
+
# internal requires
|
32
|
+
require 'tigefa/core_ext'
|
33
|
+
require 'tigefa/stevenson'
|
34
|
+
require 'tigefa/deprecator'
|
35
|
+
require 'tigefa/configuration'
|
36
|
+
require 'tigefa/site'
|
37
|
+
require 'tigefa/convertible'
|
38
|
+
require 'tigefa/url'
|
39
|
+
require 'tigefa/layout'
|
40
|
+
require 'tigefa/page'
|
41
|
+
require 'tigefa/post'
|
42
|
+
require 'tigefa/excerpt'
|
43
|
+
require 'tigefa/draft'
|
44
|
+
require 'tigefa/filters'
|
45
|
+
require 'tigefa/static_file'
|
46
|
+
require 'tigefa/errors'
|
47
|
+
require 'tigefa/related_posts'
|
48
|
+
require 'tigefa/cleaner'
|
49
|
+
require 'tigefa/entry_filter'
|
50
|
+
|
51
|
+
# extensions
|
52
|
+
require 'tigefa/plugin'
|
53
|
+
require 'tigefa/converter'
|
54
|
+
require 'tigefa/generator'
|
55
|
+
require 'tigefa/command'
|
56
|
+
|
57
|
+
require_all 'tigefa/commands'
|
58
|
+
require_all 'tigefa/converters'
|
59
|
+
require_all 'tigefa/converters/markdown'
|
60
|
+
require_all 'tigefa/generators'
|
61
|
+
require_all 'tigefa/tags'
|
62
|
+
|
63
|
+
SafeYAML::OPTIONS[:suppress_warnings] = true
|
64
|
+
|
65
|
+
module Jekyll
|
66
|
+
VERSION = '1.1.1'
|
67
|
+
|
68
|
+
# Public: Generate a Jekyll configuration Hash by merging the default
|
69
|
+
# options with anything in _config.yml, and adding the given options on top.
|
70
|
+
#
|
71
|
+
# override - A Hash of config directives that override any options in both
|
72
|
+
# the defaults and the config file. See Jekyll::Configuration::DEFAULTS for a
|
73
|
+
# list of option names and their defaults.
|
74
|
+
#
|
75
|
+
# Returns the final configuration Hash.
|
76
|
+
def self.configuration(override)
|
77
|
+
config = Configuration[Configuration::DEFAULTS]
|
78
|
+
override = Configuration[override].stringify_keys
|
79
|
+
config = config.read_config_files(config.config_files(override))
|
80
|
+
|
81
|
+
# Merge DEFAULTS < _config.yml < override
|
82
|
+
config = config.deep_merge(override).stringify_keys
|
83
|
+
set_timezone(config['timezone']) if config['timezone']
|
84
|
+
|
85
|
+
config
|
86
|
+
end
|
87
|
+
|
88
|
+
# Static: Set the TZ environment variable to use the timezone specified
|
89
|
+
#
|
90
|
+
# timezone - the IANA Time Zone
|
91
|
+
#
|
92
|
+
# Returns nothing
|
93
|
+
def self.set_timezone(timezone)
|
94
|
+
ENV['TZ'] = timezone
|
95
|
+
end
|
96
|
+
|
97
|
+
def self.logger
|
98
|
+
@logger ||= Stevenson.new
|
5
99
|
end
|
6
100
|
end
|
data/script/bootstrap
ADDED
data/site/.gitignore
ADDED
data/site/CNAME
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
jekyllrb.com
|
data/site/README
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Jekyll's awesome website.
|
data/site/_config.yml
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
{% if site.gauges_id %}
|
2
|
+
<!-- Gauges (http://gaug.es/) -->
|
3
|
+
<script type="text/javascript">
|
4
|
+
var _gauges = _gauges || [];
|
5
|
+
(function() {
|
6
|
+
var t = document.createElement('script');
|
7
|
+
t.type = 'text/javascript';
|
8
|
+
t.async = true;
|
9
|
+
t.id = 'gauges-tracker';
|
10
|
+
t.setAttribute('data-site-id', '{{ site.gauges_id }}');
|
11
|
+
t.src = '//secure.gaug.es/track.js';
|
12
|
+
var s = document.getElementsByTagName('script')[0];
|
13
|
+
s.parentNode.insertBefore(t, s);
|
14
|
+
})();
|
15
|
+
</script>
|
16
|
+
{% endif %}
|
17
|
+
|
18
|
+
{% if site.google_analytics_id %}
|
19
|
+
<!-- Google Analytics (http://google.com/analytics) -->
|
20
|
+
<script type="text/javascript">
|
21
|
+
var _gaq = _gaq || [];
|
22
|
+
_gaq.push(['_setAccount', '{{ site.google_analytics_id }}']);
|
23
|
+
_gaq.push(['_setDomainName', '{{ site.url }}']); // Multiple sub-domains
|
24
|
+
_gaq.push(['_setAllowLinker', true]); // Multiple TLDs
|
25
|
+
_gaq.push(['_trackPageview']);
|
26
|
+
(function() {
|
27
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
28
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
29
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
30
|
+
})();
|
31
|
+
</script>
|
32
|
+
{% endif %}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<div class="unit one-fifth hide-on-mobiles">
|
2
|
+
<aside>
|
3
|
+
<h4>Getting Started</h4>
|
4
|
+
{% include docs_ul.html items='home quickstart installation usage structure configuration' %}
|
5
|
+
<h4>Your Content</h4>
|
6
|
+
{% include docs_ul.html items='frontmatter posts drafts pages variables datafiles migrations' %}
|
7
|
+
<h4>Customization</h4>
|
8
|
+
{% include docs_ul.html items='templates permalinks pagination plugins extras' %}
|
9
|
+
<h4>Deployment</h4>
|
10
|
+
{% include docs_ul.html items='github-pages deployment-methods' %}
|
11
|
+
<h4>Miscellaneous</h4>
|
12
|
+
{% include docs_ul.html items='troubleshooting sites resources upgrading' %}
|
13
|
+
<h4>Meta</h4>
|
14
|
+
{% include docs_ul.html items='contributing history' %}
|
15
|
+
</aside>
|
16
|
+
</div>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<div class="docs-nav-mobile unit whole show-on-mobiles">
|
2
|
+
<select onchange="if (this.value) window.location.href=this.value">
|
3
|
+
<option value="">Navigate the docs…</option>
|
4
|
+
<optgroup label="Getting started">
|
5
|
+
{% include docs_option.html items='home quickstart installation usage structure configuration' %}
|
6
|
+
</optgroup>
|
7
|
+
<optgroup label="Your Content">
|
8
|
+
{% include docs_option.html items='frontmatter posts drafts pages variables datafiles migrations' %}
|
9
|
+
</optgroup>
|
10
|
+
<optgroup label="Customization">
|
11
|
+
{% include docs_option.html items='templates permalinks pagination plugins extras' %}
|
12
|
+
</optgroup>
|
13
|
+
<optgroup label="Deployment">
|
14
|
+
{% include docs_option.html items='github-pages deployment-methods' %}
|
15
|
+
</optgroup>
|
16
|
+
<optgroup label="Miscellaneous">
|
17
|
+
{% include docs_option.html items='troubleshooting sites resources upgrading' %}
|
18
|
+
</optgroup>
|
19
|
+
<optgroup label="Meta">
|
20
|
+
{% include docs_option.html items='contributing history' %}
|
21
|
+
</optgroup>
|
22
|
+
</select>
|
23
|
+
</div>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
{% assign items = include.items | split: ' ' %}
|
2
|
+
|
3
|
+
{% for item in items %}
|
4
|
+
{% assign item_url = item | prepend:'/docs/' | append:'/' %}
|
5
|
+
|
6
|
+
{% for p in site.pages %}
|
7
|
+
{% if p.url == item_url %}
|
8
|
+
<option value="{{ site.url }}{{ p.url }}">{{ p.title }}</option>
|
9
|
+
{% endif %}
|
10
|
+
{% endfor %}
|
11
|
+
{% endfor %}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{% assign items = include.items | split: ' ' %}
|
2
|
+
|
3
|
+
<ul>
|
4
|
+
{% for item in items %}
|
5
|
+
{% assign item_url = item | prepend:'/docs/' | append:'/' %}
|
6
|
+
|
7
|
+
{% if item_url == page.url %}
|
8
|
+
{% assign c = 'current' %}
|
9
|
+
{% else %}
|
10
|
+
{% assign c = '' %}
|
11
|
+
{% endif %}
|
12
|
+
|
13
|
+
{% for p in site.pages %}
|
14
|
+
{% if p.url == item_url %}
|
15
|
+
<li class="{{ c }}"><a href="{{ site.url }}{{ p.url }}">{{ p.title }}</a></li>
|
16
|
+
{% endif %}
|
17
|
+
{% endfor %}
|
18
|
+
|
19
|
+
{% endfor %}
|
20
|
+
</ul>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<footer>
|
2
|
+
<div class="grid">
|
3
|
+
<div class="unit one-third center-on-mobiles">
|
4
|
+
<p>By <a href="http://tom.preston-werner.com">Tom Preston-Werner</a>, <a href="http://quaran.to/">Nick Quaranto</a>, and many more <a href="{{ site.repository }}/graphs/contributors">awesome contributors</a>.</p>
|
5
|
+
</div>
|
6
|
+
<div class="unit two-thirds align-right center-on-mobiles">
|
7
|
+
<p>
|
8
|
+
Proudly hosted by
|
9
|
+
<a href="https://github.com">
|
10
|
+
<img src="{{ site.url }}/img/footer-logo.png" alt="GitHub • Social coding">
|
11
|
+
</a>
|
12
|
+
</p>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
</footer>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<header>
|
2
|
+
<nav class="mobile-nav show-on-mobiles">
|
3
|
+
{% include primary-nav-items.html %}
|
4
|
+
</nav>
|
5
|
+
<div class="grid">
|
6
|
+
<div class="unit one-third center-on-mobiles">
|
7
|
+
<h1>
|
8
|
+
<a href="{{ site.url }}/">
|
9
|
+
<span>Jekyll</span>
|
10
|
+
<img src="{{ site.url }}/img/logo-2x.png" width="249" height="115" alt="">
|
11
|
+
</a>
|
12
|
+
</h1>
|
13
|
+
</div>
|
14
|
+
<nav class="main-nav unit two-thirds hide-on-mobiles">
|
15
|
+
{% include primary-nav-items.html %}
|
16
|
+
</nav>
|
17
|
+
</div>
|
18
|
+
</header>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<div class="unit one-fifth hide-on-mobiles">
|
2
|
+
<aside>
|
3
|
+
<ul>
|
4
|
+
<li class="{% if page.title == 'News' %}current{% endif %}">
|
5
|
+
<a href="/news/">All News</a>
|
6
|
+
</li>
|
7
|
+
<li class="{% if page.title == 'Releases' %}current{% endif %}">
|
8
|
+
<a href="/news/releases/">Jekyll Releases</a>
|
9
|
+
</li>
|
10
|
+
</ul>
|
11
|
+
<h4>Recent Releases</h4>
|
12
|
+
<ul>
|
13
|
+
{% for post in site.posts limit:5 %}
|
14
|
+
<li class="{% if page.title == post.title %}current{% endif %}">
|
15
|
+
<a href="{{ post.url }}">Version {{ post.version }}</a>
|
16
|
+
</li>
|
17
|
+
{% endfor %}
|
18
|
+
<li>
|
19
|
+
<a href="/docs/history/">History »</a>
|
20
|
+
</li>
|
21
|
+
</ul>
|
22
|
+
</aside>
|
23
|
+
</div>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<div class="docs-nav-mobile unit whole show-on-mobiles">
|
2
|
+
<select onchange="if (this.value) window.location.href=this.value">
|
3
|
+
<option value="">Navigate the blog…</option>
|
4
|
+
<option value="/news/">Home</option>
|
5
|
+
<optgroup label="v1.x">
|
6
|
+
{% for post in site.posts %}
|
7
|
+
<option value="{{ post.url }}">{{ post.title }}</option>
|
8
|
+
{% endfor %}
|
9
|
+
</optgroup>
|
10
|
+
</select>
|
11
|
+
</div>
|