octopress 3.0.0.alpha1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.editorconfig +22 -0
- data/.gitattributes +1 -0
- data/.gitignore +20 -0
- data/.powrc +4 -0
- data/.rspec +5 -0
- data/.rubocop.yml +119 -0
- data/.slugignore +3 -0
- data/.themes/classic/.editorconfig +44 -0
- data/.themes/classic/_config/adn-timeline.yml +10 -0
- data/.themes/classic/_config/delicious-feed.yml +4 -0
- data/.themes/classic/_config/deploy/gh_pages.yml +9 -0
- data/.themes/classic/_config/deploy/rsync.yml +14 -0
- data/.themes/classic/_config/disqus.yml +11 -0
- data/.themes/classic/_config/facebook-like.yml +2 -0
- data/.themes/classic/_config/gauges-analytics.yml +6 -0
- data/.themes/classic/_config/github-repos.yml +24 -0
- data/.themes/classic/_config/google-analytics.yml +6 -0
- data/.themes/classic/_config/google-plus.yml +13 -0
- data/.themes/classic/_config/jekyll.yml +37 -0
- data/.themes/classic/_config/pinboard-feed.yml +4 -0
- data/.themes/classic/_config/require-js.yml +19 -0
- data/.themes/classic/_config/theme.yml +54 -0
- data/.themes/classic/_config/twitter-timeline.yml +9 -0
- data/.themes/classic/assets/javascripts/lib/ios-rotate-scaling-fix.js +18 -0
- data/.themes/classic/assets/javascripts/lib/jquery.cookie.js +92 -0
- data/.themes/classic/assets/javascripts/lib/modernizr.js +447 -0
- data/.themes/classic/assets/javascripts/lib/octopress.js +83 -0
- data/.themes/classic/assets/javascripts/modules/adn-timeline.coffee +68 -0
- data/.themes/classic/assets/javascripts/modules/delicious-feed.coffee +38 -0
- data/.themes/classic/assets/javascripts/modules/github-repos.coffee +60 -0
- data/.themes/classic/assets/javascripts/modules/github.coffee +60 -0
- data/.themes/classic/assets/javascripts/modules/helpers.coffee +96 -0
- data/.themes/classic/assets/javascripts/modules/pinboard-feed.coffee +42 -0
- data/.themes/classic/assets/javascripts/modules/site.coffee +11 -0
- data/.themes/classic/assets/stylesheets/_base.scss +5 -0
- data/.themes/classic/assets/stylesheets/_partials.scss +8 -0
- data/.themes/classic/assets/stylesheets/base/_layout.scss +191 -0
- data/.themes/classic/assets/stylesheets/base/_solarized.scss +75 -0
- data/.themes/classic/assets/stylesheets/base/_theme.scss +92 -0
- data/.themes/classic/assets/stylesheets/base/_typography.scss +168 -0
- data/.themes/classic/assets/stylesheets/base/_utilities.scss +27 -0
- data/.themes/classic/assets/stylesheets/custom/_colors.scss +49 -0
- data/.themes/classic/assets/stylesheets/custom/_fonts.scss +10 -0
- data/.themes/classic/assets/stylesheets/custom/_layout.scss +17 -0
- data/.themes/classic/assets/stylesheets/custom/_styles.scss +2 -0
- data/.themes/classic/assets/stylesheets/partials/_archive.scss +77 -0
- data/.themes/classic/assets/stylesheets/partials/_blog.scss +165 -0
- data/.themes/classic/assets/stylesheets/partials/_footer.scss +19 -0
- data/.themes/classic/assets/stylesheets/partials/_header.scss +18 -0
- data/.themes/classic/assets/stylesheets/partials/_navigation.scss +136 -0
- data/.themes/classic/assets/stylesheets/partials/_sharing.scss +73 -0
- data/.themes/classic/assets/stylesheets/partials/_sidebar.scss +4 -0
- data/.themes/classic/assets/stylesheets/partials/_syntax.scss +234 -0
- data/.themes/classic/assets/stylesheets/partials/sidebar/_base.scss +106 -0
- data/.themes/classic/assets/stylesheets/partials/sidebar/_delicious.scss +4 -0
- data/.themes/classic/assets/stylesheets/partials/sidebar/_googleplus.scss +26 -0
- data/.themes/classic/assets/stylesheets/partials/sidebar/_pinboard.scss +12 -0
- data/.themes/classic/assets/stylesheets/plugins/_plugins.scss +5 -0
- data/.themes/classic/assets/stylesheets/screen.scss +11 -0
- data/.themes/classic/source/404.markdown +9 -0
- data/.themes/classic/source/_includes/after_footer.html +7 -0
- data/.themes/classic/source/_includes/archive_post.html +12 -0
- data/.themes/classic/source/_includes/article.html +23 -0
- data/.themes/classic/source/_includes/comments.html +9 -0
- data/.themes/classic/source/_includes/custom/after_footer.html +3 -0
- data/.themes/classic/source/_includes/custom/after_page.html +1 -0
- data/.themes/classic/source/_includes/custom/after_post.html +0 -0
- data/.themes/classic/source/_includes/custom/comments.html +5 -0
- data/.themes/classic/source/_includes/custom/footer.html +4 -0
- data/.themes/classic/source/_includes/custom/head.html +7 -0
- data/.themes/classic/source/_includes/custom/header.html +6 -0
- data/.themes/classic/source/_includes/custom/navigation.html +4 -0
- data/.themes/classic/source/_includes/custom/page_meta.html +1 -0
- data/.themes/classic/source/_includes/custom/post_meta.html +1 -0
- data/.themes/classic/source/_includes/custom/sharing.html +3 -0
- data/.themes/classic/source/_includes/disqus.html +22 -0
- data/.themes/classic/source/_includes/facebook_like.html +10 -0
- data/.themes/classic/source/_includes/feed_entry.xml +10 -0
- data/.themes/classic/source/_includes/footer.html +1 -0
- data/.themes/classic/source/_includes/gauges_analytics.html +15 -0
- data/.themes/classic/source/_includes/google_analytics.html +13 -0
- data/.themes/classic/source/_includes/google_plus_one.html +9 -0
- data/.themes/classic/source/_includes/head.html +33 -0
- data/.themes/classic/source/_includes/header.html +1 -0
- data/.themes/classic/source/_includes/navigation.html +15 -0
- data/.themes/classic/source/_includes/post/author.html +8 -0
- data/.themes/classic/source/_includes/post/categories.html +10 -0
- data/.themes/classic/source/_includes/post/date.html +15 -0
- data/.themes/classic/source/_includes/post/disqus_thread.html +1 -0
- data/.themes/classic/source/_includes/post/meta.html +3 -0
- data/.themes/classic/source/_includes/post/sharing.html +36 -0
- data/.themes/classic/source/_includes/post/title.html +5 -0
- data/.themes/classic/source/_includes/post/variables.html +14 -0
- data/.themes/classic/source/_includes/sidebars/blog_index_default.html +3 -0
- data/.themes/classic/source/_includes/sidebars/page_default.html +4 -0
- data/.themes/classic/source/_includes/sidebars/post_default.html +4 -0
- data/.themes/classic/source/_includes/sidebars/sections/delicious.html +8 -0
- data/.themes/classic/source/_includes/sidebars/sections/github.html +9 -0
- data/.themes/classic/source/_includes/sidebars/sections/google_plus.html +5 -0
- data/.themes/classic/source/_includes/sidebars/sections/pinboard.html +17 -0
- data/.themes/classic/source/_includes/sidebars/sections/recent_posts.html +10 -0
- data/.themes/classic/source/_includes/twitter_sharing.html +11 -0
- data/.themes/classic/source/_layouts/category_feed.xml +24 -0
- data/.themes/classic/source/_layouts/category_index.html +19 -0
- data/.themes/classic/source/_layouts/default.html +14 -0
- data/.themes/classic/source/_layouts/page.html +34 -0
- data/.themes/classic/source/_layouts/post.html +39 -0
- data/.themes/classic/source/archives/index.html +20 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/background.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/blankButton.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/divider.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/fullscreenButton.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/fullscreenButtonOver.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/muteButton.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/muteButtonOver.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/normalscreenButton.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/normalscreenButtonOver.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/pauseButton.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/pauseButtonOver.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/playButton.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/playButtonOver.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/timeSliderBuffer.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/timeSliderCapLeft.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/timeSliderCapRight.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/timeSliderProgress.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/timeSliderRail.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/unmuteButton.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/controlbar/unmuteButtonOver.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/display/background.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/display/bufferIcon.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/display/muteIcon.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/display/playIcon.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/dock/button.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/glow.xml +115 -0
- data/.themes/classic/source/assets/jwplayer/glow/playlist/item.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/playlist/itemOver.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/playlist/sliderCapBottom.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/playlist/sliderCapTop.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/playlist/sliderRail.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/playlist/sliderThumb.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/sharing/embedIcon.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/sharing/embedScreen.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/sharing/shareIcon.png +0 -0
- data/.themes/classic/source/assets/jwplayer/glow/sharing/shareScreen.png +0 -0
- data/.themes/classic/source/assets/jwplayer/player.swf +0 -0
- data/.themes/classic/source/atom.xml +23 -0
- data/.themes/classic/source/images/bird_32_gray.png +0 -0
- data/.themes/classic/source/images/bird_32_gray_fail.png +0 -0
- data/.themes/classic/source/images/code_bg.png +0 -0
- data/.themes/classic/source/images/dotted-border.png +0 -0
- data/.themes/classic/source/images/email.png +0 -0
- data/.themes/classic/source/images/icon/facebook.png +0 -0
- data/.themes/classic/source/images/icon/github.png +0 -0
- data/.themes/classic/source/images/icon/googleplus.png +0 -0
- data/.themes/classic/source/images/icon/twitter-bird.png +0 -0
- data/.themes/classic/source/images/icon/twitter.png +0 -0
- data/.themes/classic/source/images/line-tile.png +0 -0
- data/.themes/classic/source/images/noise.png +0 -0
- data/.themes/classic/source/images/rss.png +0 -0
- data/.themes/classic/source/images/search.png +0 -0
- data/.themes/classic/source/index.html +30 -0
- data/.themes/classic/source/javascripts/jquery.min.js +5 -0
- data/.themes/classic/source/octopress-favicon.png +0 -0
- data/.themes/classic/source/robots.txt +7 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.markdown +46 -0
- data/CONTRIBUTING.markdown +17 -0
- data/Gemfile +2 -0
- data/README.markdown +37 -0
- data/Rakefile +76 -0
- data/bin/octopress +66 -0
- data/lib/console +17 -0
- data/lib/guard/jekyll.rb +33 -0
- data/lib/octopress.rb +89 -0
- data/lib/octopress/command.rb +9 -0
- data/lib/octopress/commands.rb +14 -0
- data/lib/octopress/commands/build.rb +17 -0
- data/lib/octopress/commands/build_javascripts.rb +11 -0
- data/lib/octopress/commands/build_jekyll.rb +25 -0
- data/lib/octopress/commands/build_stylesheets.rb +13 -0
- data/lib/octopress/commands/install.rb +45 -0
- data/lib/octopress/commands/new.rb +21 -0
- data/lib/octopress/commands/scaffold.rb +101 -0
- data/lib/octopress/commands/serve.rb +25 -0
- data/lib/octopress/configuration.rb +231 -0
- data/lib/octopress/core_ext.rb +44 -0
- data/lib/octopress/dependency_installer.rb +287 -0
- data/lib/octopress/errors.rb +3 -0
- data/lib/octopress/filters/content.rb +66 -0
- data/lib/octopress/filters/date.rb +46 -0
- data/lib/octopress/filters/post.rb +175 -0
- data/lib/octopress/filters/url.rb +34 -0
- data/lib/octopress/formatters.rb +9 -0
- data/lib/octopress/formatters/base_formatter.rb +17 -0
- data/lib/octopress/formatters/simple_formatter.rb +9 -0
- data/lib/octopress/formatters/verbose_formatter.rb +9 -0
- data/lib/octopress/generators/category_generator.rb +196 -0
- data/lib/octopress/generators/sitemap_generator.rb +308 -0
- data/lib/octopress/guardfile +43 -0
- data/lib/octopress/helpers/titlecase.rb +37 -0
- data/lib/octopress/ink.rb +12 -0
- data/lib/octopress/inquirable_string.rb +12 -0
- data/lib/octopress/installer.rb +92 -0
- data/lib/octopress/js_asset_manager.rb +98 -0
- data/lib/octopress/liquid_helpers/conditional.rb +36 -0
- data/lib/octopress/liquid_helpers/config.rb +58 -0
- data/lib/octopress/liquid_helpers/include.rb +33 -0
- data/lib/octopress/liquid_helpers/url.rb +29 -0
- data/lib/octopress/liquid_helpers/vars.rb +30 -0
- data/lib/octopress/plugin.rb +33 -0
- data/lib/octopress/rake.rb +16 -0
- data/lib/octopress/scaffold/.gitignore +18 -0
- data/lib/octopress/scaffold/site/Gemfile +3 -0
- data/lib/octopress/scaffold/site/config/compass.rb +27 -0
- data/lib/octopress/scaffold/site/config/rack.rb +25 -0
- data/lib/octopress/scaffold/site/config/site.yml +0 -0
- data/lib/octopress/scaffold/site/javascripts/lib/ios-rotate-scaling-fix.js +19 -0
- data/lib/octopress/scaffold/site/javascripts/lib/jquery-1.9.1.js +9598 -0
- data/lib/octopress/scaffold/site/javascripts/lib/jquery.cookie.js +93 -0
- data/lib/octopress/scaffold/site/stylesheets/_config.scss +1 -0
- data/lib/octopress/scaffold/site/stylesheets/_style.scss +1 -0
- data/lib/octopress/scaffold/site/stylesheets/site.scss +16 -0
- data/lib/octopress/tags/assign.rb +34 -0
- data/lib/octopress/tags/capture.rb +31 -0
- data/lib/octopress/tags/config-tag.rb +23 -0
- data/lib/octopress/tags/include.rb +63 -0
- data/lib/octopress/tags/js-assets.rb +23 -0
- data/lib/octopress/tags/puts.rb +39 -0
- data/lib/octopress/tags/render-partial.rb +89 -0
- data/lib/octopress/tags/return.rb +21 -0
- data/lib/octopress/version.rb +3 -0
- data/lib/rake/clean.rake +8 -0
- data/lib/rake/clobber.rake +5 -0
- data/lib/rake/console.rake +5 -0
- data/lib/rake/deploy.rake +4 -0
- data/lib/rake/gen_deploy.rake +2 -0
- data/lib/rake/generate.rake +4 -0
- data/lib/rake/generate_only.rake +14 -0
- data/lib/rake/hygiene.rake +29 -0
- data/lib/rake/install.rake +8 -0
- data/lib/rake/integrate.rake +4 -0
- data/lib/rake/isolate.rake +13 -0
- data/lib/rake/list_drafts.rake +7 -0
- data/lib/rake/new.rake +7 -0
- data/lib/rake/new_page.rake +49 -0
- data/lib/rake/new_post.rake +32 -0
- data/lib/rake/nuke.rake +4 -0
- data/lib/rake/preview.rake +4 -0
- data/lib/rake/push.rake +37 -0
- data/lib/rake/rsync.rake +20 -0
- data/lib/rake/set_root_dir.rake +35 -0
- data/lib/rake/setup_github_pages.rake +115 -0
- data/lib/rake/watch.rake +11 -0
- data/lib/scaffold/Rakefile +142 -0
- data/lib/scaffold/plugin-name.gemspec +43 -0
- data/lib/spec/fixtures/env/defaults/classic.yml +2 -0
- data/lib/spec/fixtures/no_override/defaults/classic.yml +11 -0
- data/lib/spec/fixtures/override/defaults/classic.yml +11 -0
- data/lib/spec/fixtures/override/site.yml +11 -0
- data/lib/spec/octopress/configuration_spec.rb +67 -0
- data/lib/spec/octopress/dependency_installer_spec.rb +66 -0
- data/lib/spec/octopress/ink_spec.rb +10 -0
- data/lib/spec/octopress/octopress_spec.rb +97 -0
- data/lib/spec/spec_helper.rb +22 -0
- data/lib/spec/support/env.rb +36 -0
- data/lib/spec/support/simplecov.rb +52 -0
- data/octopress.gemspec +52 -0
- metadata +697 -0
@@ -0,0 +1,308 @@
|
|
1
|
+
# Sitemap.xml Generator is a Jekyll plugin that generates a sitemap.xml file by
|
2
|
+
# traversing all of the available posts and pages.
|
3
|
+
#
|
4
|
+
# How To Use:
|
5
|
+
# 1) Copy source file into your _plugins folder within your Jekyll project.
|
6
|
+
# 2) Change modify the url variable in _config.yml to reflect your domain name.
|
7
|
+
# 3) Run Jekyll: jekyll build to re-generate your site.
|
8
|
+
#
|
9
|
+
# Variables:
|
10
|
+
# * Change SITEMAP_FILE_NAME if you want your sitemap to be called something
|
11
|
+
# other than sitemap.xml.
|
12
|
+
# * Change the PAGES_INCLUDE_POSTS list to include any pages that are looping
|
13
|
+
# through your posts (e.g. "index.html", "archive.html", etc.). This will
|
14
|
+
# ensure that right after you make a new post, the last modified date will
|
15
|
+
# be updated to reflect the new post.
|
16
|
+
# * A sitemap.xml should be included in your _site folder.
|
17
|
+
# * If there are any files you don't want included in the sitemap, add them
|
18
|
+
# to the EXCLUDED_FILES list. The name should match the name of the source
|
19
|
+
# file.
|
20
|
+
# * If you want to include the optional changefreq and priority attributes,
|
21
|
+
# simply include custom variables in the YAML Front Matter of that file.
|
22
|
+
# The names of these custom variables are defined below in the
|
23
|
+
# CHANGE_FREQUENCY_CUSTOM_VARIABLE_NAME and PRIORITY_CUSTOM_VARIABLE_NAME
|
24
|
+
# constants.
|
25
|
+
#
|
26
|
+
# Notes:
|
27
|
+
# * The last modified date is determined by the latest from the following:
|
28
|
+
# system modified date of the page or post, system modified date of
|
29
|
+
# included layout, system modified date of included layout within that
|
30
|
+
# layout, ...
|
31
|
+
#
|
32
|
+
# Author: Michael Levin
|
33
|
+
# Site: http://www.kinnetica.com
|
34
|
+
# Distributed Under A Creative Commons License
|
35
|
+
# - http://creativecommons.org/licenses/by/3.0/
|
36
|
+
#
|
37
|
+
# Modified for Octopress by John W. Long
|
38
|
+
#
|
39
|
+
require 'colorator'
|
40
|
+
require 'rexml/document'
|
41
|
+
require 'fileutils'
|
42
|
+
|
43
|
+
module Jekyll
|
44
|
+
|
45
|
+
# Change SITEMAP_FILE_NAME if you would like your sitemap file
|
46
|
+
# to be called something else
|
47
|
+
SITEMAP_FILE_NAME = "sitemap.xml"
|
48
|
+
|
49
|
+
# Any files to exclude from being included in the sitemap.xml
|
50
|
+
EXCLUDED_FILES = ["atom.xml", "404.markdown"]
|
51
|
+
|
52
|
+
# Any files that include posts, so that when a new post is added, the last
|
53
|
+
# modified date of these pages should take that into account
|
54
|
+
PAGES_INCLUDE_POSTS = ["index.html"]
|
55
|
+
|
56
|
+
# Custom variable names for changefreq and priority elements
|
57
|
+
# These names are used within the YAML Front Matter of pages or posts
|
58
|
+
# for which you want to include these properties
|
59
|
+
CHANGE_FREQUENCY_CUSTOM_VARIABLE_NAME = "change_frequency"
|
60
|
+
PRIORITY_CUSTOM_VARIABLE_NAME = "priority"
|
61
|
+
|
62
|
+
class Post
|
63
|
+
attr_accessor :name
|
64
|
+
|
65
|
+
def full_path_to_source
|
66
|
+
File.join(@base, @name)
|
67
|
+
end
|
68
|
+
|
69
|
+
def location_on_server
|
70
|
+
"#{site.config['url']}#{url}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
class Page
|
75
|
+
attr_accessor :name
|
76
|
+
|
77
|
+
def full_path_to_source
|
78
|
+
File.join(@base, @dir, @name)
|
79
|
+
end
|
80
|
+
|
81
|
+
def location_on_server
|
82
|
+
location = "#{site.config['url']}#{@dir}#{url}"
|
83
|
+
location.gsub(/index.html$/, "")
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
class Layout
|
88
|
+
def full_path_to_source
|
89
|
+
File.join(@base, @name)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
# Recover from strange exception when starting server without --auto
|
94
|
+
class SitemapFile < StaticFile
|
95
|
+
def write(dest)
|
96
|
+
begin
|
97
|
+
super(dest)
|
98
|
+
rescue
|
99
|
+
end
|
100
|
+
|
101
|
+
true
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
class SitemapGenerator < Generator
|
106
|
+
|
107
|
+
# Valid values allowed by sitemap.xml spec for change frequencies
|
108
|
+
VALID_CHANGE_FREQUENCY_VALUES = ["always", "hourly", "daily", "weekly",
|
109
|
+
"monthly", "yearly", "never"]
|
110
|
+
|
111
|
+
# Goes through pages and posts and generates sitemap.xml file
|
112
|
+
#
|
113
|
+
# Returns nothing
|
114
|
+
def generate(site)
|
115
|
+
sitemap = REXML::Document.new << REXML::XMLDecl.new("1.0", "UTF-8")
|
116
|
+
|
117
|
+
urlset = REXML::Element.new "urlset"
|
118
|
+
urlset.add_attribute("xmlns",
|
119
|
+
"http://www.sitemaps.org/schemas/sitemap/0.9")
|
120
|
+
|
121
|
+
@last_modified_post_date = fill_posts(site, urlset)
|
122
|
+
fill_pages(site, urlset)
|
123
|
+
|
124
|
+
sitemap.add_element(urlset)
|
125
|
+
|
126
|
+
# File I/O: create sitemap.xml file and write out pretty-printed XML
|
127
|
+
unless File.exists?(site.dest)
|
128
|
+
FileUtils.mkdir_p(site.dest)
|
129
|
+
end
|
130
|
+
file = File.new(File.join(site.dest, SITEMAP_FILE_NAME), "w")
|
131
|
+
formatter = REXML::Formatters::Pretty.new(4)
|
132
|
+
formatter.compact = true
|
133
|
+
formatter.write(sitemap, file)
|
134
|
+
file.close
|
135
|
+
|
136
|
+
# Keep the sitemap.xml file from being cleaned by Jekyll
|
137
|
+
site.static_files << Jekyll::SitemapFile.new(site, site.dest, "/", SITEMAP_FILE_NAME)
|
138
|
+
end
|
139
|
+
|
140
|
+
# Create url elements for all the posts and find the date of the latest one
|
141
|
+
#
|
142
|
+
# Returns last_modified_date of latest post
|
143
|
+
def fill_posts(site, urlset)
|
144
|
+
last_modified_date = nil
|
145
|
+
site.posts.each do |post|
|
146
|
+
if !excluded?(post.name)
|
147
|
+
url = fill_url(site, post)
|
148
|
+
urlset.add_element(url)
|
149
|
+
end
|
150
|
+
|
151
|
+
path = post.full_path_to_source
|
152
|
+
date = File.mtime(path)
|
153
|
+
last_modified_date = date if last_modified_date == nil or date > last_modified_date
|
154
|
+
end
|
155
|
+
|
156
|
+
last_modified_date
|
157
|
+
end
|
158
|
+
|
159
|
+
# Create url elements for all the normal pages and find the date of the
|
160
|
+
# index to use with the pagination pages
|
161
|
+
#
|
162
|
+
# Returns last_modified_date of index page
|
163
|
+
def fill_pages(site, urlset)
|
164
|
+
site.pages.each do |page|
|
165
|
+
if !excluded?(page.name)
|
166
|
+
path = page.full_path_to_source
|
167
|
+
if File.exists?(path)
|
168
|
+
url = fill_url(site, page)
|
169
|
+
urlset.add_element(url)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# Fill data of each URL element: location, last modified,
|
176
|
+
# change frequency (optional), and priority.
|
177
|
+
#
|
178
|
+
# Returns url REXML::Element
|
179
|
+
def fill_url(site, page_or_post)
|
180
|
+
url = REXML::Element.new "url"
|
181
|
+
|
182
|
+
loc = fill_location(page_or_post)
|
183
|
+
url.add_element(loc)
|
184
|
+
|
185
|
+
lastmod = fill_last_modified(site, page_or_post)
|
186
|
+
url.add_element(lastmod) if lastmod
|
187
|
+
|
188
|
+
if (page_or_post.data[CHANGE_FREQUENCY_CUSTOM_VARIABLE_NAME])
|
189
|
+
change_frequency =
|
190
|
+
page_or_post.data[CHANGE_FREQUENCY_CUSTOM_VARIABLE_NAME].downcase
|
191
|
+
|
192
|
+
if (valid_change_frequency?(change_frequency))
|
193
|
+
changefreq = REXML::Element.new "changefreq"
|
194
|
+
changefreq.text = change_frequency
|
195
|
+
url.add_element(changefreq)
|
196
|
+
else
|
197
|
+
$stderr.puts "ERROR: Invalid Change Frequency In #{page_or_post.name}".red
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
if (page_or_post.data[PRIORITY_CUSTOM_VARIABLE_NAME])
|
202
|
+
priority_value = page_or_post.data[PRIORITY_CUSTOM_VARIABLE_NAME]
|
203
|
+
if valid_priority?(priority_value)
|
204
|
+
priority = REXML::Element.new "priority"
|
205
|
+
priority.text = page_or_post.data[PRIORITY_CUSTOM_VARIABLE_NAME]
|
206
|
+
url.add_element(priority)
|
207
|
+
else
|
208
|
+
$stderr.puts "ERROR: Invalid Priority In #{page_or_post.name}".red
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
url
|
213
|
+
end
|
214
|
+
|
215
|
+
# Get URL location of page or post
|
216
|
+
#
|
217
|
+
# Returns the location of the page or post
|
218
|
+
def fill_location(page_or_post)
|
219
|
+
loc = REXML::Element.new "loc"
|
220
|
+
loc.text = page_or_post.location_on_server
|
221
|
+
|
222
|
+
loc
|
223
|
+
end
|
224
|
+
|
225
|
+
# Fill lastmod XML element with the last modified date for the page or post.
|
226
|
+
#
|
227
|
+
# Returns lastmod REXML::Element or nil
|
228
|
+
def fill_last_modified(site, page_or_post)
|
229
|
+
path = page_or_post.full_path_to_source
|
230
|
+
|
231
|
+
lastmod = REXML::Element.new "lastmod"
|
232
|
+
date = File.mtime(path)
|
233
|
+
latest_date = find_latest_date(date, site, page_or_post)
|
234
|
+
|
235
|
+
if @last_modified_post_date == nil
|
236
|
+
# This is a post
|
237
|
+
lastmod.text = latest_date.iso8601
|
238
|
+
else
|
239
|
+
# This is a page
|
240
|
+
if posts_included?(page_or_post.name)
|
241
|
+
# We want to take into account the last post date
|
242
|
+
final_date = greater_date(latest_date, @last_modified_post_date)
|
243
|
+
lastmod.text = final_date.iso8601
|
244
|
+
else
|
245
|
+
lastmod.text = latest_date.iso8601
|
246
|
+
end
|
247
|
+
end
|
248
|
+
lastmod
|
249
|
+
end
|
250
|
+
|
251
|
+
# Go through the page/post and any implemented layouts and get the latest
|
252
|
+
# modified date
|
253
|
+
#
|
254
|
+
# Returns formatted output of latest date of page/post and any used layouts
|
255
|
+
def find_latest_date(latest_date, site, page_or_post)
|
256
|
+
layouts = site.layouts
|
257
|
+
layout = layouts[page_or_post.data["layout"]]
|
258
|
+
while layout
|
259
|
+
path = layout.full_path_to_source
|
260
|
+
date = File.mtime(path)
|
261
|
+
|
262
|
+
latest_date = date if (date > latest_date)
|
263
|
+
|
264
|
+
layout = layouts[layout.data["layout"]]
|
265
|
+
end
|
266
|
+
|
267
|
+
latest_date
|
268
|
+
end
|
269
|
+
|
270
|
+
# Which of the two dates is later
|
271
|
+
#
|
272
|
+
# Returns latest of two dates
|
273
|
+
def greater_date(date1, date2)
|
274
|
+
[date1, date2].max
|
275
|
+
end
|
276
|
+
|
277
|
+
# Is the page or post listed as something we want to exclude?
|
278
|
+
#
|
279
|
+
# Returns boolean
|
280
|
+
def excluded?(name)
|
281
|
+
EXCLUDED_FILES.include? name
|
282
|
+
end
|
283
|
+
|
284
|
+
def posts_included?(name)
|
285
|
+
PAGES_INCLUDE_POSTS.include? name
|
286
|
+
end
|
287
|
+
|
288
|
+
# Is the change frequency value provided valid according to the spec
|
289
|
+
#
|
290
|
+
# Returns boolean
|
291
|
+
def valid_change_frequency?(change_frequency)
|
292
|
+
VALID_CHANGE_FREQUENCY_VALUES.include? change_frequency
|
293
|
+
end
|
294
|
+
|
295
|
+
# Is the priority value provided valid according to the spec
|
296
|
+
#
|
297
|
+
# Returns boolean
|
298
|
+
def valid_priority?(priority)
|
299
|
+
begin
|
300
|
+
priority_val = Float(priority)
|
301
|
+
return true if priority_val >= 0.0 and priority_val <= 1.0
|
302
|
+
rescue ArgumentError
|
303
|
+
end
|
304
|
+
|
305
|
+
false
|
306
|
+
end
|
307
|
+
end
|
308
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
$:.unshift File.expand_path("../", File.dirname(__FILE__))
|
2
|
+
|
3
|
+
# A sample Guardfile
|
4
|
+
# More info at https://github.com/guard/guard#readme
|
5
|
+
require 'octopress'
|
6
|
+
require 'guard/jekyll'
|
7
|
+
|
8
|
+
stylesheets_dir = "stylesheets"
|
9
|
+
javascripts_dir = "javascripts"
|
10
|
+
|
11
|
+
configurator = Octopress::Configuration.new
|
12
|
+
configuration = configurator.read_configuration
|
13
|
+
js_assets = Octopress::JSAssetsManager.new if Dir.exists? javascripts_dir
|
14
|
+
|
15
|
+
if Dir.exists? stylesheets_dir
|
16
|
+
guard :compass do
|
17
|
+
watch %r{^#{stylesheets_dir}/(.*)\.s[ac]ss$}
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
guard :jekyll do
|
22
|
+
# If a template file changes, trigger a Jekyll build
|
23
|
+
watch /^#{configuration[:source]}\/.+\.(md|markdown|textile|html|haml|slim|xml)/
|
24
|
+
end
|
25
|
+
|
26
|
+
guard :shell do
|
27
|
+
# If a non template file changes, copy it to destination
|
28
|
+
watch /^#{configuration[:source]}\/.+\.[^(md|markdown|textile|html|haml|slim|xml)]/ do |m|
|
29
|
+
if File.exists?(m.first)
|
30
|
+
file = File.basename(m.first)
|
31
|
+
path = m.first.sub /^#{configuration[:source]}/, "#{configuration[:destination]}"
|
32
|
+
FileUtils.mkdir_p path.sub /#{file}/,''
|
33
|
+
FileUtils.cp m.first, path
|
34
|
+
"Copied #{m.first} -> #{path}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
if Dir.exists? javascripts_dir
|
39
|
+
watch /^#{javascripts_dir}\/.+\.(js|coffee|mustache|eco|tmpl)/ do |change|
|
40
|
+
puts js_assets.compile
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class String
|
2
|
+
def titlecase
|
3
|
+
small_words = %w(a an and as at but by en for if in of on or the to v v. via vs vs.)
|
4
|
+
|
5
|
+
x = split(" ").map do |word|
|
6
|
+
# note: word could contain non-word characters!
|
7
|
+
# downcase all small_words, capitalize the rest
|
8
|
+
small_words.include?(word.gsub(/\W/, "").downcase) ? word.downcase! : word.smart_capitalize!
|
9
|
+
word
|
10
|
+
end
|
11
|
+
# capitalize first and last words
|
12
|
+
x.first.to_s.smart_capitalize!
|
13
|
+
x.last.to_s.smart_capitalize!
|
14
|
+
# small words are capitalized after colon, period, exclamation mark, question mark
|
15
|
+
x.join(" ").gsub(/(:|\.|!|\?)\s?(\W*#{small_words.join("|")}\W*)\s/) { "#{$1} #{$2.smart_capitalize} " }
|
16
|
+
end
|
17
|
+
|
18
|
+
def titlecase!
|
19
|
+
replace(titlecase)
|
20
|
+
end
|
21
|
+
|
22
|
+
def smart_capitalize
|
23
|
+
# ignore any leading crazy characters and capitalize the first real character
|
24
|
+
if self =~ /^['"\(\[']*([a-z])/
|
25
|
+
i = index($1)
|
26
|
+
x = self[i,self.length]
|
27
|
+
# word with capitals and periods mid-word are left alone
|
28
|
+
self[i,1] = self[i,1].upcase unless x =~ /[A-Z]/ or x =~ /\.\w+/
|
29
|
+
end
|
30
|
+
self
|
31
|
+
end
|
32
|
+
|
33
|
+
def smart_capitalize!
|
34
|
+
replace(smart_capitalize)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module Octopress
|
2
|
+
class Installer
|
3
|
+
|
4
|
+
OCTO_DIRS = {
|
5
|
+
"configs" => "config",
|
6
|
+
"includes" => "source/_includes",
|
7
|
+
"layouts" => "source/_layouts",
|
8
|
+
"javascripts/lib" => "javascripts/lib",
|
9
|
+
"javascripts/modules" => "javascripts/modules",
|
10
|
+
"source" => "source",
|
11
|
+
"stylesheets" => "stylesheets",
|
12
|
+
"plugins" => "plugins"
|
13
|
+
}
|
14
|
+
|
15
|
+
def initalize(plugin_name)
|
16
|
+
begin
|
17
|
+
require "#{plugin_name}"
|
18
|
+
rescue LoadError
|
19
|
+
Octopress.logger.error "We can't load the plugin '#{plugin_name}'. Please add it" +
|
20
|
+
" to your Gemfile and run 'bundle install' and try" +
|
21
|
+
" installing the plugin again."
|
22
|
+
raise LoadError
|
23
|
+
end
|
24
|
+
|
25
|
+
@plugin_name = plugin_name
|
26
|
+
@class_name = plugin_name.gsub(/-_\ /, "_").split("_").map(&:capitalize).join("")
|
27
|
+
@plugin_class = Object.const_get(@class_name)
|
28
|
+
@verbose = Octopress.logger.level == Logger::DEBUG
|
29
|
+
end
|
30
|
+
|
31
|
+
def type
|
32
|
+
manifest_yml.fetch('type') || "plugin"
|
33
|
+
end
|
34
|
+
|
35
|
+
def theme?
|
36
|
+
type == "theme"
|
37
|
+
end
|
38
|
+
|
39
|
+
def plugin?
|
40
|
+
type == "plugin"
|
41
|
+
end
|
42
|
+
|
43
|
+
def plugin_slug
|
44
|
+
plugin? ? manifest_yml.fetch('slug') : "theme"
|
45
|
+
end
|
46
|
+
|
47
|
+
####################
|
48
|
+
# Fetchers
|
49
|
+
####################
|
50
|
+
|
51
|
+
def namespace?(subdir)
|
52
|
+
plugin? && !%w[javascripts/lib source].include?(subdir)
|
53
|
+
end
|
54
|
+
|
55
|
+
def source(*subdirs)
|
56
|
+
File.join(@plugin_class.root, *subdirs, ".")
|
57
|
+
end
|
58
|
+
|
59
|
+
def local(subdir)
|
60
|
+
dir = File.join(Octopress.root, subdir)
|
61
|
+
dir = File.join(dir, "plugins") if subdir == "stylesheets" && plugin?
|
62
|
+
dir = File.join(dir, "theme") if subdir == "stylesheets" && theme?
|
63
|
+
dir = File.join(dir, plugin_slug) if namespace?
|
64
|
+
dir
|
65
|
+
end
|
66
|
+
|
67
|
+
###################
|
68
|
+
# Installers
|
69
|
+
###################
|
70
|
+
|
71
|
+
def install
|
72
|
+
OCTO_DIRS.each do |source_dir, local_dir|
|
73
|
+
install(source_dir, local_dir)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def install(source_dir, local_dir)
|
78
|
+
FileUtils.mkdir_p local(local_dir), verbose: @verbose
|
79
|
+
FileUtils.cp_r source(source_dir), local(local_dir), verbose: @verbose
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
def manifest_yml
|
84
|
+
@manifest ||= YAML.safe_load_file(File.join(@plugin_class.root, "MANIFEST.yml"))
|
85
|
+
rescue Errno::ENOENT
|
86
|
+
Octopress.logger.error "The plugin '#{@plugin_name}' doesn't seem to have a " +
|
87
|
+
"MANIFEST.yml file and thus isn't a valid Octopress plugin."
|
88
|
+
raise StandardError
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|