octopress 3.0.0.alpha2 → 3.0.0.alpha3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.gitignore +15 -18
- data/Gemfile +3 -1
- data/LICENSE +20 -0
- data/README.md +66 -0
- data/Rakefile +1 -76
- data/bin/octopress +14 -58
- data/lib/octopress.rb +40 -79
- data/lib/octopress/command.rb +10 -4
- data/lib/octopress/commands/new.rb +50 -12
- data/lib/octopress/commands/publish.rb +18 -0
- data/lib/octopress/core_ext.rb +1 -0
- data/lib/octopress/draft.rb +43 -0
- data/lib/octopress/page.rb +109 -0
- data/lib/octopress/post.rb +30 -0
- data/lib/octopress/version.rb +1 -1
- data/octopress.gemspec +7 -32
- metadata +31 -437
- data/.editorconfig +0 -22
- data/.gitattributes +0 -1
- data/.powrc +0 -4
- data/.rspec +0 -5
- data/.rubocop.yml +0 -119
- data/.slugignore +0 -3
- data/.travis.yml +0 -6
- data/CHANGELOG.markdown +0 -46
- data/CONTRIBUTING.markdown +0 -17
- data/README.markdown +0 -37
- data/lib/console +0 -17
- data/lib/guard/jekyll.rb +0 -33
- data/lib/octopress/commands.rb +0 -14
- data/lib/octopress/commands/build.rb +0 -17
- data/lib/octopress/commands/build_javascripts.rb +0 -11
- data/lib/octopress/commands/build_jekyll.rb +0 -42
- data/lib/octopress/commands/build_stylesheets.rb +0 -13
- data/lib/octopress/commands/install.rb +0 -44
- data/lib/octopress/commands/scaffold.rb +0 -102
- data/lib/octopress/commands/serve.rb +0 -25
- data/lib/octopress/configuration.rb +0 -237
- data/lib/octopress/dependency_installer.rb +0 -287
- data/lib/octopress/errors.rb +0 -3
- data/lib/octopress/filters/content.rb +0 -66
- data/lib/octopress/filters/date.rb +0 -46
- data/lib/octopress/filters/post.rb +0 -175
- data/lib/octopress/filters/url.rb +0 -34
- data/lib/octopress/formatters.rb +0 -9
- data/lib/octopress/formatters/base_formatter.rb +0 -17
- data/lib/octopress/formatters/simple_formatter.rb +0 -9
- data/lib/octopress/formatters/verbose_formatter.rb +0 -9
- data/lib/octopress/generators/category_generator.rb +0 -196
- data/lib/octopress/generators/sitemap_generator.rb +0 -308
- data/lib/octopress/guardfile +0 -43
- data/lib/octopress/helpers/titlecase.rb +0 -37
- data/lib/octopress/ink.rb +0 -12
- data/lib/octopress/inquirable_string.rb +0 -12
- data/lib/octopress/installer.rb +0 -96
- data/lib/octopress/js_assets_manager.rb +0 -97
- data/lib/octopress/liquid_helpers/conditional.rb +0 -36
- data/lib/octopress/liquid_helpers/config.rb +0 -58
- data/lib/octopress/liquid_helpers/include.rb +0 -33
- data/lib/octopress/liquid_helpers/url.rb +0 -29
- data/lib/octopress/liquid_helpers/vars.rb +0 -30
- data/lib/octopress/plugin.rb +0 -33
- data/lib/octopress/rake.rb +0 -16
- data/lib/octopress/scaffold/.gitignore +0 -18
- data/lib/octopress/scaffold/site/Gemfile +0 -3
- data/lib/octopress/scaffold/site/config.ru +0 -25
- data/lib/octopress/scaffold/site/config/compass.rb +0 -27
- data/lib/octopress/scaffold/site/config/rack.rb +0 -25
- data/lib/octopress/scaffold/site/config/site.yml +0 -0
- data/lib/octopress/scaffold/site/javascripts/lib/ios-rotate-scaling-fix.js +0 -19
- data/lib/octopress/scaffold/site/javascripts/lib/jquery-1.9.1.js +0 -9598
- data/lib/octopress/scaffold/site/javascripts/lib/jquery.cookie.js +0 -93
- data/lib/octopress/scaffold/site/stylesheets/_config.scss +0 -1
- data/lib/octopress/scaffold/site/stylesheets/_style.scss +0 -1
- data/lib/octopress/scaffold/site/stylesheets/site.scss +0 -16
- data/lib/octopress/tags/assign.rb +0 -34
- data/lib/octopress/tags/capture.rb +0 -31
- data/lib/octopress/tags/config-tag.rb +0 -23
- data/lib/octopress/tags/include.rb +0 -63
- data/lib/octopress/tags/js-assets.rb +0 -23
- data/lib/octopress/tags/puts.rb +0 -39
- data/lib/octopress/tags/render-partial.rb +0 -89
- data/lib/octopress/tags/return.rb +0 -21
- data/lib/rake/clean.rake +0 -8
- data/lib/rake/clobber.rake +0 -5
- data/lib/rake/console.rake +0 -5
- data/lib/rake/deploy.rake +0 -4
- data/lib/rake/gen_deploy.rake +0 -2
- data/lib/rake/generate.rake +0 -4
- data/lib/rake/generate_only.rake +0 -14
- data/lib/rake/hygiene.rake +0 -29
- data/lib/rake/install.rake +0 -8
- data/lib/rake/integrate.rake +0 -4
- data/lib/rake/isolate.rake +0 -13
- data/lib/rake/list_drafts.rake +0 -7
- data/lib/rake/new.rake +0 -7
- data/lib/rake/new_page.rake +0 -49
- data/lib/rake/new_post.rake +0 -32
- data/lib/rake/nuke.rake +0 -4
- data/lib/rake/preview.rake +0 -4
- data/lib/rake/push.rake +0 -37
- data/lib/rake/rsync.rake +0 -20
- data/lib/rake/set_root_dir.rake +0 -35
- data/lib/rake/setup_github_pages.rake +0 -115
- data/lib/rake/watch.rake +0 -11
- data/lib/scaffold/Rakefile +0 -142
- data/lib/scaffold/plugin-name.gemspec +0 -43
- data/lib/spec/fixtures/env/defaults/classic.yml +0 -2
- data/lib/spec/fixtures/no_override/defaults/classic.yml +0 -11
- data/lib/spec/fixtures/override/defaults/classic.yml +0 -11
- data/lib/spec/fixtures/override/site.yml +0 -11
- data/lib/spec/octopress/configuration_spec.rb +0 -67
- data/lib/spec/octopress/dependency_installer_spec.rb +0 -66
- data/lib/spec/octopress/ink_spec.rb +0 -10
- data/lib/spec/octopress/octopress_spec.rb +0 -97
- data/lib/spec/spec_helper.rb +0 -22
- data/lib/spec/support/env.rb +0 -36
- data/lib/spec/support/simplecov.rb +0 -52
@@ -1,308 +0,0 @@
|
|
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
|
data/lib/octopress/guardfile
DELETED
@@ -1,43 +0,0 @@
|
|
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
|
@@ -1,37 +0,0 @@
|
|
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
|
-
|
data/lib/octopress/ink.rb
DELETED
data/lib/octopress/installer.rb
DELETED
@@ -1,96 +0,0 @@
|
|
1
|
-
module Octopress
|
2
|
-
class Installer
|
3
|
-
|
4
|
-
OCTO_DIRS = {
|
5
|
-
"configs" => "config",
|
6
|
-
"javascripts/lib" => "javascripts/lib",
|
7
|
-
"javascripts/modules" => "javascripts/modules",
|
8
|
-
"source" => "source",
|
9
|
-
"includes" => "source/_includes",
|
10
|
-
"layouts" => "source/_layouts",
|
11
|
-
"stylesheets" => "stylesheets",
|
12
|
-
"plugins" => "plugins"
|
13
|
-
}
|
14
|
-
|
15
|
-
def initialize(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
|
-
!%w[javascripts/lib source].include?(subdir)
|
53
|
-
end
|
54
|
-
|
55
|
-
def stylesheets?(subdir)
|
56
|
-
"stylesheets" == subdir
|
57
|
-
end
|
58
|
-
|
59
|
-
def source(*subdirs)
|
60
|
-
File.join(@plugin_class.root, *subdirs, ".")
|
61
|
-
end
|
62
|
-
|
63
|
-
def local(subdir)
|
64
|
-
dir = File.join(Octopress.root, subdir)
|
65
|
-
dir = File.join(dir, "plugins") if stylesheets?(subdir) && plugin?
|
66
|
-
dir = File.join(dir, "theme") if stylesheets?(subdir) && theme?
|
67
|
-
dir = File.join(dir, plugin_slug) if namespace?(subdir)
|
68
|
-
dir
|
69
|
-
end
|
70
|
-
|
71
|
-
###################
|
72
|
-
# Installers
|
73
|
-
###################
|
74
|
-
|
75
|
-
def install
|
76
|
-
OCTO_DIRS.each do |source_dir, local_dir|
|
77
|
-
_install(source_dir, local_dir)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def _install(source_dir, local_dir)
|
82
|
-
FileUtils.mkdir_p local(local_dir), verbose: @verbose
|
83
|
-
FileUtils.cp_r source(source_dir), local(local_dir), verbose: @verbose
|
84
|
-
end
|
85
|
-
|
86
|
-
private
|
87
|
-
def manifest_yml
|
88
|
-
@manifest ||= YAML.safe_load_file(File.join(@plugin_class.root, "MANIFEST.yml"))
|
89
|
-
rescue Errno::ENOENT
|
90
|
-
Octopress.logger.error "The plugin '#{@plugin_name}' doesn't seem to have a " +
|
91
|
-
"MANIFEST.yml file and thus isn't a valid Octopress plugin."
|
92
|
-
raise LoadError
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
|
-
end
|